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 pokemons = [ | |
| { | |
| "name":"Bulbasaur", | |
| "attack":49, | |
| "defense":49, | |
| "evolveLevel":16, | |
| "evolveTo":"2", | |
| "type":"grass", | |
| "moves":[ | |
| "tackle", |
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
| [ | |
| { | |
| name: 'ghost', | |
| multipliers: { | |
| "ghost": 2.0, | |
| "steel": 0.5, | |
| "psychic": 2.0, | |
| "dark": 0.5, | |
| "normal": 0.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
| {"struggle":{"name":"Struggle","power":35,"accuracy":0.95,"type":"normal"},"air cutter":{"name":"Air Cutter","power":55,"accuracy":0.95,"type":"flying"},"crabhammer":{"name":"Crabhammer","power":90,"accuracy":0.85,"type":"water"},"cross chop":{"name":"Cross Chop","power":100,"accuracy":0.8,"type":"fighting"},"drill peck":{"name":"Drill Peck","power":80,"accuracy":1,"type":"flying"},"egg bomb":{"name":"Egg Bomb","power":100,"accuracy":0.75,"type":"normal"},"horn attack":{"name":"Horn Attack","power":65,"accuracy":1,"type":"normal"},"hydro pump":{"name":"Hydro Pump","power":120,"accuracy":0.8,"type":"water"},"hyper voice":{"name":"Hyper Voice","power":90,"accuracy":1,"type":"normal"},"karate chop":{"name":"Karate Chop","power":50,"accuracy":1,"type":"fighting"},"megahorn":{"name":"Megahorn","power":120,"accuracy":0.85,"type":"bug"},"mega kick":{"name":"Mega Kick","power":120,"accuracy":0.75,"type":"normal"},"mega punch":{"name":"Mega Punch","power":80,"accuracy":0.85,"type":"normal"},"peck":{"name":"Peck","powe |
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 editable = ( | |
| ({ appendTo, map, pipe }, sticky) => { | |
| const exec = (command, value = null) => document.execCommand(command, false, value) | |
| const setDefaultEditableAttrs = element => Object.assign( | |
| element, | |
| { | |
| spellcheck: false, | |
| contentEditable: 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
| const pipable = { | |
| ᗌ(fn = () => {}) { | |
| return fn(this) | |
| } | |
| } | |
| const types = [Object, Number] | |
| types.forEach(type => Object.assign(type.prototype, pipable)) |
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 zero = () => {} | |
| const succ = nat => () => nat | |
| const natToInt = nat => nat() ? natToInt(nat()) + 1 : 0 | |
| const intToNat = int => int > 0 ? succ(intToNat(int - 1)) : zero | |
| const toString = nat => nat() ? `succ(${toString(nat())})` : 'zero' |
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 { ceil } = Math | |
| const { fromCharCode } = String | |
| const emptyMap = (length, mapFn) => Array(length).fill(null).map(mapFn) | |
| const stringRange = (start = '', end = '') => emptyMap( | |
| end.charCodeAt() - start.charCodeAt() + 1 | |
| (_, i) => fromCharCode(i + start.charCodeAt()) | |
| ) |
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
| f = (...fns) => { | |
| const [main, ...variations] = fns.reverse() | |
| const ƒunction = (...appliedArgs) => { | |
| const variation = variations.find( | |
| args => appliedArgs.every( | |
| (appliedArg, i) => args.slice().splice(0, args.length - 1)[i] === appliedArg | |
| ) | |
| ) |
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 decoupleMethods = (Type, ...names) => names.map( | |
| name => ({ [name]: (a, b) => Type.prototype[name].call(b, a) }) // could be curried | |
| ).reduce((acc, next) => Object.assign({}, acc, next)) | |
| const { map, filter, forEach, find } = decoupleMethods( | |
| Array, | |
| 'map', | |
| 'filter', | |
| 'forEach', | |
| 'find' |
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 createObserver = ( | |
| ({ curry, pipe, evolve, merge, forEach, filter }) => { | |
| const filterNodes = curry( | |
| (filter, container) => { | |
| let currentNode | |
| const nodes = [] | |
| const walker = document.createTreeWalker(container, filter) | |
| while (currentNode = walker.nextNode()) nodes.push(currentNode) |
OlderNewer