Immutable data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization and change detection techniques with simple logic. Persistent data presents a mutative API which does not update the data in-place, but instead always yields new updated data.--- Immutable.js
This file contains hidden or 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
export const createReferenceNumbers = ( | |
baseStr: string = "000", | |
qty = 10, | |
international = false | |
): string[] => { | |
const baseNumber = BigInt(baseStr); | |
return Array.from({ length: qty }, (_value, idx) => { | |
const base = String(baseNumber + BigInt(idx)); | |
const checksum: number = |
This file contains hidden or 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
// does not work on edge | |
((a, {b = 0, c = 3}) => { return a === 1 && b === 2 && c === 3; })(1, { b: 2 }); | |
// works, surprisingly | |
((a, {b = 0, c = 3} = {}) => { return a === 1 && b === 2 && c === 3; })(1, { b: 2 }); | |
// works | |
(({b = 0, c = 3}) => { return b === 2 && c === 3; })({ b: 2 }); | |
// works |
This file contains hidden or 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
const a = (idx = 1, color = 'black') => { console.log(`%c ${ [...new Array(Math.round(50*(1+Math.sin(idx/10))))].map(() => '*').join('') }`, `color: ${color}`); setTimeout(() => a(idx+1, color), 20) }; a() | |
// Node | |
var x = idx => { console.log(''.padStart(Math.floor(process.stdout.columns / 2 * (1 + Math.sin(idx))), '*')); setTimeout(() => x((idx + 0.1) % (2 * Math.PI)), 20) }; x(0) |
This file contains hidden or 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
Show hidden characters
{ | |
"env": { | |
"browser": true, | |
"node": true, | |
"es6": true, | |
"amd": true, | |
"jest/globals": true | |
}, | |
"extends": "eslint:recommended", | |
"parserOptions": { |
This file contains hidden or 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
const webpack = require('webpack') | |
module.exports = { | |
devtool: process.env.NODE_ENV === 'production' ? 'cheap-module-source-map' : 'eval', | |
module: { | |
loaders: [ | |
{ | |
test: /\.js?$/, | |
exclude: /node_modules/, | |
loader: 'babel', |
This file contains hidden or 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
import User from './User' | |
import Session from './Session' | |
/* Associations */ | |
User.hasMany(Session) | |
/* Hooks */ | |
User.afterDestroy(async (user, options) => { | |
await Session.destroy({ | |
where: { userId: user.id }, |