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 variance = (n) => (l = n.length, n.reduce((a, b) => a + ((b - (n.reduce((a, b) => a + b, 0) / l)) ** 2), 0) / l); |
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 rot13(message){ | |
| return [...message].map((c) => (n = c.charCodeAt(0),String.fromCharCode(n >= 65 && n <= 90?((n - 65 + 13) % 26) + 65:(n >= 97 && n <= 122 ? (n - 97 + 13) % 26 + 97 : n)))).join(''); | |
| } | |
| console.log(rot13('§""§$§Ruby is cool!')); // "grfg" |
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
| console.log(((s)=>[...s].map(c =>(n=c.charCodeAt(0),String.fromCharCode(n^(32*(n>=97&&n<=122))))).join(''))('a4raf32aso"§%&/fu4f22')); |
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 fizzbuzz = n => (n % 3 ? '' : 'Fizz') + (n % 5 ? '' : 'Buzz') || n; | |
| arr = [...Array(100).keys()] | |
| .map((i) => ++i) | |
| .map((i) => fizzbuzz(i)); | |
| console.log(arr); |
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 uppercase = s => [...s].map(c =>(n = c.charCodeAt(0), String.fromCharCode(n - 32 * (n >= 97 && n <= 122)))).join(''); | |
| console.log(uppercase('a4raf32aso"§%&/fu4f22')) // "A4RAF32ASO'§%&/FU4F22" |
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 deepEqual = (objA: any, objB: any, map = new WeakMap()) => { | |
| if (Object.is(objA, objB)) { | |
| return true; | |
| } | |
| if (objA instanceof Date && objB instanceof Date) { | |
| return objA.getTime() === objB.getTime(); | |
| } | |
| if (objA instanceof RegExp && objB instanceof RegExp) { |
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
| class ExpiringDataCache { | |
| private _cache: any[] = []; | |
| public expirationTime = 100; | |
| set cache(value: any) { | |
| this.expiredCache.push({value, ttl: Date.now() + this.expirationTime}); | |
| } | |
| get cache() { | |
| return this.expiredCache.map(item => item.value); |
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
| /** | |
| * @module namespace/Closure | |
| * @requires module:namespace/Model | |
| * @lends namespace | |
| */ | |
| (function (window) { | |
| 'use strict'; | |
| /** | |
| * @namespace |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.5.5/webcomponents-lite.min.js"></script> | |
| <link rel="import" href="my-component.html" /> | |
| <link rel="import" href="my-component-input.html" /> | |
| <link rel="import" href="my-component-extend.html" /> | |
| </head> |
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 ExtendedArray() { | |
| let arr = []; | |
| arr.push.apply(arr, arguments); | |
| /** | |
| * Returns a circulating range of an Array | |
| * @param index {Number} starting position | |
| * @param size {Number} size of the range | |
| * @param [reverse] {Boolean} reverse the range lookup | |
| * @return {Array} The returned array length will not exceed the length of the original array if size > arr.length |
NewerOlder