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 createQueue = (worker) => { | |
| const queue = []; | |
| const working = false; | |
| const run = () => { | |
| if (working || queue.length === 0) return; | |
| working = true; | |
| const { data, callback } = queue.shift(); | |
| worker(data, (...args) => { |
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
| {"version":1,"resource":"file:///Users/wjhwang/Documents/workspace/baeminmart-front/client/src/utils/date/index.ts","entries":[{"id":"uDgd.ts","timestamp":1659057591928},{"id":"mdQp.ts","timestamp":1659057742950},{"id":"qqIS.ts","source":"undoRedo.source","timestamp":1659057774967},{"id":"w0DV.ts","timestamp":1659057829108}]} |
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
| type ValueType = 'ARRAY' | 'OBJECT'; | |
| type LinkedLisType = null | { | |
| parentKey: string; | |
| type: ValueType | undefined; | |
| node: [string, any][]; | |
| linkedList: LinkedLisType; | |
| }; | |
| const isObject = (value: unknown) => /Object/.test(Object.prototype.toString.call(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
| const HTMLRegExp = { | |
| OPEN_TAG: /^\s*<([\w]|\w.+?)\s*>/, | |
| ATTRIBUTES:/([\w|-]+)*[^\s|\"|\=]/g, | |
| OPEN_TAG_IN_SLASH: /[/]$/, | |
| CLOSE_TAG: /^\s*<[/]([\w]|\w.+?)\s*>/, | |
| DATA_PROPERTY_KEY: /[-]\w/g, | |
| TEXT_NODE: /(.*?)<:?/, | |
| } | |
| const UNPAIRED_TAGS = ['br', 'hr', 'img', 'meta', 'link', '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
| const Element = new (class { | |
| #regExp = { | |
| number: /^\s*,?(\d+)\s*,?/, | |
| date: /^\s*,?"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)"\s*,?/, | |
| string: /^\s*,?"(\w+)"\s*,?/, | |
| boolean: /^\s*,?(true|false)\s*,?/, | |
| }; | |
| parse(v) { |
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 Escape = new (class { | |
| #data = [ | |
| [/[\r\n\l]/g, "\\n"], | |
| [/"/g, '\\"'], | |
| [/\t/g, "\\t"], | |
| ]; | |
| replace = (v) => { | |
| for (let i = 0; i < this.#data.length; i = i + 1) | |
| v = v.replace.apply(v, this.#data[i]); | |
| return v; |
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 Escape = new (class { | |
| #data = [ | |
| [/[\r\n\l]/g, "\\n"], | |
| [/"/g, '\\"'], | |
| [/\t/g, "\\t"], | |
| ]; | |
| replace = (v) => { | |
| for (let i = 0; i < this.#data.length; i = i + 1) | |
| v = v.replace.apply(v, this.#data[i]); | |
| return v; |
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 Escape = (() => { | |
| const data = [ | |
| [/[\r\n\l]/g, "\\n"], | |
| [/"/g, '\\"'], | |
| [/\t/g, "\\t"], | |
| ]; | |
| const replace = (v) => { | |
| for (let i = 0; i < data.length; i = i + 1) v = v.replace.apply(v, data[i]); | |
| return v; | |
| }; |
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 appendSeparator = (v, begin, end) => { | |
| if (!begin) { | |
| v = "[" + v; | |
| } | |
| if (begin && begin <= end) { | |
| v = "," + v; | |
| } | |
| if (begin == end) { | |
| v = v + "]"; | |
| } |
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 sum = (arr) => { | |
| let acc = 0; | |
| for (let i = arr.length - 1; i >= 0; i--) acc += arr[i]; | |
| return acc; | |
| }; | |
| console.log(sum([])) | |
| console.log(sum([1])) | |
| console.log(sum([1,2])) | |
| console.log(sum([1,2,3])) |
NewerOlder