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 { BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
export class ObsService { | |
private val$:BehaviorSubject<number> = new BehaviorSubject(42); | |
val = this.val$.asObservable(); | |
} |
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
/** | |
* @param array of unary functions | |
* @param array of any | |
* @return array of any | |
*/ | |
filterMany = (f, d) => | |
f.length < 2 ? d.filter(f[0]) : filterMany(f, d.filter(f.shift())) | |
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
/** | |
* empty array | |
* empty string | |
* function of zero arity | |
* empty object | |
* null | |
* undefined | |
*/ | |
var empty = x => Array.isArray(x) || typeof x === 'string' || typeof x === 'function' ? | |
!x.length : null == x || Object.keys(x).length === 0 && x.constructor === Object |
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
let methods = { | |
upp: function() { | |
return Chain(this.x.toUpperCase()); | |
}, | |
slice: function(len) { | |
return Chain(this.x.slice(len)); | |
}, | |
val: function() { | |
return this.x | |
} |
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
/** | |
* Test for null when chaining functor wrappers | |
* If not null, call chained functions on passed value | |
* If null occurs, disregard the function and pass along null | |
* When folding value, provide error and success handlers | |
*/ | |
// functor setup | |
const Call = x => |
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
/** | |
* create a pipeline of unary functions | |
* examples at https://github.com/crshmk/pipe/blob/master/index.js | |
*/ | |
let pipe = function() { | |
var fs = Array.prototype.slice.call(arguments); | |
function caller(fs, acc) { | |
return fs.length === 0 ? acc | |
: caller(fs.slice(1), fs[0](acc)); | |
}; |
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
/** | |
* @param xs array | |
* @param oneLevel boolean -> pass true to flatten only one level | |
*/ | |
let flatten = (xs, oneLevel) => | |
oneLevel ? xs.reduce( (acc, xs) => acc.concat(xs), []) : | |
xs.reduce( (acc, x) => Array.isArray(x) ? acc.concat(flatten(x)) : acc.concat(x), []); | |
let nums = [1, [2, [3, 4, [5] ]]] |
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 { m, sm, mountWithPlugin } from './utils.js' | |
// reduce mounting boilerplate | |
import Component from '@/views/Comp.vue' | |
const wrapper = m(Component) |
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/creationix/nvm | |
nvm install node --reinstall-packages-from=node | |
nvm ls | |
nvm alias default ${newVersion} | |
nvm uninstall ${oldVersion} |
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 fetcher(url) { | |
return fetch(url).then(res => res.json()) | |
} | |
async function get(url) { | |
var result = await fetcher(url); | |
return result | |
} | |
get('https://jsonplaceholder.typicode.com/users') |
OlderNewer