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
| { | |
| "exclude": [ | |
| ".git/**", | |
| "node_modules/**", | |
| "bower_components/**" | |
| ], | |
| "always-semicolon": true, | |
| "block-indent": "\t", | |
| "color-case": "lower", | |
| "color-shorthand": true, |
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
| # Set this up in .profile or remember to call it after nvm install | |
| ln -s $(dirname $(nvm which $(nvm current))) "$NVM_DIR"/current |
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 letters = xdmp.toJSON(['a', 'b', 'c']).root; // ArrayNode | |
| Array.from(letters); // [Text, Text, Text] | |
| ArrayNode.prototype[Symbol.iterator] = function*() { | |
| for (let i = 0; i < this.length; i++) { | |
| yield this[String(i)]; | |
| } | |
| }; |
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 multiEntry from 'rollup-plugin-multi-entry'; | |
| import nodeResolve from 'rollup-plugin-node-resolve'; | |
| import typescript from 'rollup-plugin-typescript2'; | |
| export default { | |
| input: 'src/**/*.test.ts', | |
| output: [ | |
| /* Command-line in Node | |
| ```shell | |
| rollup -c test.config.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
| // https://github.com/github/fetch/issues/175#issuecomment-216791333 | |
| function timeoutPromise(ms, promise) { | |
| return new Promise((resolve, reject) => { | |
| const timeoutId = setTimeout(() => { | |
| reject(new Error('promise timeout')); | |
| }, ms); | |
| promise.then( | |
| res => { | |
| clearTimeout(timeoutId); | |
| resolve(res); |
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
| // https://www.codementor.io/michelre/use-function-composition-in-javascript-gkmxos5mj | |
| function compose(...functions) { | |
| return args => functions.reduceRight((arg, fn) => fn(arg), args); | |
| } | |
| const cntk = { | |
| c1(input, options = {}) { | |
| // console.log('c1', input, options); | |
| return 'c1: ' + input; | |
| }, |
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
| try { | |
| System.out.println( | |
| new ObjectMapper() | |
| .writerWithDefaultPrettyPrinter() | |
| .writeValueAsString(api) | |
| ); | |
| } catch (JsonProcessingException e) { | |
| throw new RuntimeException(e); | |
| } |
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
| function* takeWhile(iterable /* Sequence, Array, etc. */, predicate = () => true) { | |
| // TODO: Test that iterable is, well, iterable and not something else | |
| for (const item of iterable) { | |
| if (predicate(item)) { | |
| yield item; | |
| } else { | |
| break; | |
| } | |
| } | |
| } |
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 nodeResolve from 'rollup-plugin-node-resolve'; | |
| import commonjs from 'rollup-plugin-commonjs'; | |
| import replace from 'rollup-plugin-replace'; | |
| export default { | |
| /* https://engineering.mixmax.com/blog/rollup-externals */ | |
| external: ['react', 'react-dom'], | |
| /* | |
| * Then in the host HTML page: | |
| * <script crossorigin="anonymous" src="//cdn.jsdelivr.net/combine/npm/react@16.8.6/umd/react.development.min.js,npm/react-dom@16.8.6/umd/react-dom.development.min.js"></script> |
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
| /** | |
| * Logs generated values and re-yields them. Keeps the same | |
| * signature and behavior as the wrapped geneator. | |
| * | |
| * @example const myGenerator = logAdvice(function*(…){…}) | |
| * | |
| * @param {GeneratorFunction} generator The generator to wrap | |
| * @param {Function} [filter = () => true] Only log yielded values that evaluate to `true` | |
| * @returns {GeneratorFunction} A generator that can be called exactly like the one passed in | |
| */ |