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
| interface Accessor<T, U> { | |
| (state: T): U; | |
| } | |
| function property_access(p: string, optionally_chained: boolean): string { | |
| let result = p; | |
| const letter_start = /^[A-Za-z]/.test(p); | |
| if (!letter_start) { | |
| if (!/^\d+$/.test(p)) { | |
| result = `'${ result }'` |
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 lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" | |
| content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| <style> | |
| @media (prefers-color-scheme: dark) { |
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 { uniques, uniquesByAtt } from './uniques'; | |
| describe('uniques function', () => { | |
| it('should filter unique elements by strict equality by default', () => { | |
| const value = [1, 2, 3, 3, 2, 1, 4, 5, 5]; | |
| const res = uniques(value); | |
| expect(res).toEqual([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
| function deepSet(value: any, obj: object, ...path: string[]) { | |
| const target = path.slice(0, -1).reduce((p: any, k) => (p[k] = p[k] || {}), obj); | |
| path.slice(-1).forEach(k => target[k] = value); | |
| } | |
| let o; | |
| deepSet(99, o = { a: { x: 88 } }, ...'a.b.c'.split('.')); | |
| console.log(o); |
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 idx = (o, ...p) => p.reduce((a, i) => a && a[i], o) |
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
| export {}; | |
| declare global { | |
| interface ArrayConstructor { | |
| range(size, start?): number[]; | |
| } | |
| } | |
| Array.range = Array.range || function (size, start = 0) { | |
| return Array.from(Array(size + start).keys()).slice(start); |
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
| export function* LazySequence(to, from = 0) { | |
| while (from < to) { | |
| yield from++; | |
| } | |
| } |
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 appendHtml(element, content) { | |
| const aux = document.createElement(element.tagName); | |
| aux.innerHTML = content; | |
| for (let i = 0; i < aux.children.length; i++) { | |
| element.appendChild(aux.children[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
| export interface Action { | |
| readonly type: string; | |
| } |
NewerOlder