This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Malaysia new IC | |
const icRegEx = new RegExp(/\d{6}-\d{2}-\d{4}/) | |
icRegEx.test('931223-14-6957') // true | |
icRegEx.test('931223146957') // false | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var users = [ | |
{ | |
"id": 1, | |
"name": "Leanne Graham", | |
"username": "Bret", | |
"email": "[email protected]", | |
"address": { | |
"street": "Kulas Light", | |
"suite": "Apt. 556", | |
"city": "Gwenborough", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var greetUsers = users.map(user => { | |
const { name, ...payload } = user // we collect all others key into payload | |
return { | |
id: payload.id, | |
name: `Hello ${name}`, | |
email: payload.email, | |
phone: payload.phone, | |
website: payload.website, | |
company: payload.company, | |
address: payload.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var greetUsers = users.map(user => { | |
const { name, ...payload } = user // we collect all others key into payload | |
return { | |
...payload, | |
name: `Hello ${name}`, | |
} | |
}) | |
// 👍 more shorter syntax |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var greetUsers = users.map(user) => ({ | |
id: payload.id, | |
name: `Hello ${name}`, | |
email: payload.email, | |
phone: payload.phone, | |
website: payload.website, | |
company: payload.company, | |
address: payload.id, | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stream = new ReadableStream({ | |
start(controller) { | |
console.log(controller) | |
controller.enqueue('Hello'); | |
controller.enqueue('12312312313123') | |
controller.close(); | |
}, | |
pull(controller) { | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public ngOnDestroy() { | |
... // things that you need to clean up | |
super.ngOnDestroy(); // don't forget to call this line. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tslint:disable:no-reserved-keywords | |
import { switchMap } from 'rxjs/operators'; | |
import { Observable, merge, Subject, of } from 'rxjs'; | |
export enum DOC_ACTION { | |
DnD = 'drag-and-drop', | |
UPLOAD_DOC = 'upload-doc', | |
RENAME_DOC = 'rename-doc', | |
DELETE_DOC = 'delete-doc' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://kentcdodds.com/blog/listify-a-java-script-array | |
// unfortunately TypeScript doesn't have Intl.ListFormat yet 😢 | |
// so we'll just add it ourselves: | |
type ListFormatOptions = { | |
type?: 'conjunction' | 'disjunction' | 'unit' | |
style?: 'long' | 'short' | 'narrow' | |
localeMatcher?: 'lookup' | 'best fit' | |
} | |
declare namespace Intl { | |
class ListFormat { |
OlderNewer