-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d00aaa
commit 7149ff5
Showing
18 changed files
with
2,348 additions
and
2,250 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const foo = () => { | ||
const a: number[] = []; | ||
const start = Date.now(); | ||
for (let i = 0; i < 100000; i++) { | ||
a.unshift(1); | ||
} | ||
return Date.now() - start; | ||
} | ||
console.log((foo())) | ||
const bar = () => { | ||
const a: number[] = []; | ||
const start = Date.now(); | ||
for (let i = 0; i < 100000; i++) { | ||
a.push(1); | ||
} | ||
return Date.now() - start; | ||
} | ||
console.log(bar()) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import { DisplayValue } from '../types'; | ||
import { DisplayValues } from '../types'; | ||
|
||
const sanitize_inline_html = (inline_html: string): string => ( | ||
inline_html.replace(/\n|\s{2,}|(<!--.*-->)/g, '') | ||
); | ||
|
||
const make_display_value_lists = (topics: DisplayValue[]) => { | ||
const topic_elements = topics.map(({ display, value }) => (/* html */` | ||
<dt> | ||
[${sanitize_inline_html(display)}](${value}) | ||
</dt> | ||
`)); | ||
const full_topic_list = /* html */` | ||
<dl> | ||
${topic_elements.join('')} | ||
</dl> | ||
`; | ||
return sanitize_inline_html(full_topic_list); | ||
const make_display_value_lists = (topics: DisplayValues[]) => { | ||
const topic_elements = topics.map(({ display, values }) => { | ||
const sanitized_display = /* html */`<dt>${sanitize_inline_html(display)}</dt>`; | ||
const sanitized_values = ( | ||
values | ||
.map(v => (/* html */`<dd>${sanitize_inline_html(v)}</dd>`)) | ||
.join('<br />') | ||
); | ||
return sanitized_display + sanitized_values; | ||
}); | ||
// const full_topic_list = /* html */`<dl>${topic_elements.join('')}</dl>`; | ||
return /* html */`<dl>${topic_elements.join('')}</dl>`; | ||
}; | ||
|
||
export default make_display_value_lists; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
import { is_stringified_safe_integer } from '../validators'; | ||
|
||
const splice_array_chunks = <T, >(raw_array: T[], chunkSize: number) => { | ||
if (!is_stringified_safe_integer(chunkSize.toString()) || chunkSize > raw_array.length) { | ||
const splice_array_chunks = <T, >( | ||
raw_array: T[], | ||
chunkSize: number, | ||
options?: { | ||
delimiter?: (items: T[]) => void; | ||
}, | ||
// delimiter?: T | ||
) => { | ||
if (!is_stringified_safe_integer(chunkSize.toString())) { | ||
return []; | ||
} | ||
const res: T[][] = []; | ||
while (raw_array.length > 0) { | ||
res.push(raw_array.splice(0, chunkSize)); | ||
if (chunkSize > raw_array.length) { | ||
return [raw_array]; | ||
} | ||
return res; | ||
const result: T[][] = []; | ||
while (raw_array.length > 1) { | ||
result.push(raw_array.splice(0, chunkSize)); | ||
options?.delimiter?.(raw_array); | ||
} | ||
return result; | ||
} | ||
|
||
|
||
// const test_string = "2006. Count"; | ||
// console.log( | ||
// splice_array_chunks(test_string.split(''), 9, { | ||
// delimiter: (items: string[]) => { | ||
// if (items[0] === ' ') { | ||
// items.shift(); | ||
// } | ||
// else { | ||
// items.unshift('-'); | ||
// } | ||
// }, | ||
// }) | ||
// .map(it => it.join('')) | ||
// // .join('<br />') | ||
// ) | ||
|
||
export default splice_array_chunks; |