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
const chain = (obj, op = obj => obj, ...restOps) => restOps.length > 0 | |
? chain(op(obj), ...restOps) | |
: op(obj); |
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
function Deferred() { | |
this.resolve = null; | |
this.reject = null; | |
this.promise = new Promise((resolve, reject) => { | |
this.resolve = resolve; | |
this.reject = reject; | |
}); | |
} |
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
import { wrapInDisablerProxyFactory } from "./wrapInDebugModeProxy" | |
describe("Enable/disable functions", () => { | |
const obj = { | |
flipTheFlag(target) { | |
target.flag = true | |
}, | |
inner: { | |
anotherFlipTheFlag(target) { |
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
Show hidden characters
{ | |
"presets": [ | |
["@babel/preset-env", {"modules": "commonjs"}] | |
], | |
"plugins": [ | |
["@babel/plugin-proposal-object-rest-spread", {}], | |
["@babel/plugin-proposal-class-properties", { "loose": false }], | |
["@babel/plugin-proposal-nullish-coalescing-operator"], | |
["@babel/plugin-proposal-optional-chaining"], | |
["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }] |
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
module.exports = { | |
"env": | |
{ | |
"browser": true, | |
"es6": true, | |
"node": true | |
}, | |
"extends": "eslint:recommended", | |
"parserOptions": | |
{ |
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
{ | |
"version": "0.1.0", | |
"command": "mocha", | |
"isShellCommand": true, | |
"showOutput": "silent", | |
"args": [ | |
"--reporter", | |
"tap", | |
"--colors" | |
], |
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
const combinePredicates = (predicate1, predicate2, ...predicateRest) => | |
(item) => | |
predicate1(item) && (predicateRest.length > 0? combinePredicates(predicate2, predicateRest[0]): predicate2)(item); | |
// sample predicates | |
const exclude = (val) => (item) => item !== val; | |
const excludeRange = (from, to) => (item) => item < from || item > to; | |
// sample data | |
let arr = [1,2,3,4,5,6,7,8,9,10]; |
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
function wrapInReadOnlyProxy(orig, throwOnSet = false) { | |
if (typeof orig !== "object") { | |
return orig; | |
} | |
return new Proxy(orig, { | |
get: function(target, property) { | |
if (property in target) { | |
return wrapInReadOnlyProxy(target[property]); | |
} |
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
// traditional version | |
function toggleValueInArray1(val, arr) { | |
var ix = arr.indexOf(val); | |
if(ix === -1){ | |
// add to array | |
arr.push(val); | |
} | |
else | |
{ | |
// remove from array |
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
import ko from 'knockout'; | |
import $ from 'jquery'; | |
var templateFromUrlLoader = { | |
loadTemplate(name, templateConfig, callback) { | |
if (templateConfig.fromUrl) { | |
var fullUrl = templateConfig.fromUrl; | |
$.get(fullUrl, markupString => { | |
ko.components.defaultLoader.loadTemplate(name, markupString, callback); | |
}); |