Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 626706a

Browse files
committed
fix
1 parent 3a37f36 commit 626706a

File tree

1 file changed

+5
-83
lines changed

1 file changed

+5
-83
lines changed

‎public/data/javascript.json‎

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@
885885
"description": "Composes multiple functions into a single function, where the output of one function becomes the input of the next.",
886886
"code": [
887887
"const compose = (...funcs) => (initialValue) => {",
888-
" return funcs.reduceRight((acc, func) => func(acc), initialValue);",
888+
" return funcs.reduce((acc, func) => func(acc), initialValue);",
889889
"};",
890890
"",
891891
"// Usage:",
@@ -897,46 +897,6 @@
897897
"tags": ["javascript", "function", "compose", "utility"],
898898
"author": "axorax"
899899
},
900-
{
901-
"title": "Pipe Functions",
902-
"description": "Pipes multiple functions into a single function, where the output of one function becomes the input of the next.",
903-
"code": [
904-
"const pipe = (...funcs) => (initialValue) => {",
905-
" return funcs.reduce((acc, func) => func(acc), initialValue);",
906-
"};",
907-
"",
908-
"// Usage:",
909-
"const add2 = (x) => x + 2;",
910-
"const multiply3 = (x) => x * 3;",
911-
"const piped = pipe(add2, multiply3);",
912-
"console.log(piped(5)); // Output: 21 ((5 + 2) * 3)"
913-
],
914-
"tags": ["javascript", "function", "pipe", "utility"],
915-
"author": "axorax"
916-
},
917-
{
918-
"title": "Once Per Interval",
919-
"description": "Ensures that a function can only be invoked once within a specific time interval.",
920-
"code": [
921-
"const oncePerInterval = (func, interval) => {",
922-
" let lastCallTime = 0;",
923-
" return (...args) => {",
924-
" const now = Date.now();",
925-
" if (now - lastCallTime >= interval) {",
926-
" lastCallTime = now;",
927-
" func(...args);",
928-
" }",
929-
" };",
930-
"};",
931-
"",
932-
"// Usage:",
933-
"const logMessage = () => console.log('Message logged');",
934-
"const logOncePerSecond = oncePerInterval(logMessage, 1000);",
935-
"setInterval(() => logOncePerSecond(), 200); // Logs once per second"
936-
],
937-
"tags": ["javascript", "function", "interval", "utility"],
938-
"author": "axorax"
939-
},
940900
{
941901
"title": "Rate Limit Function",
942902
"description": "Limits how often a function can be executed within a given time window.",
@@ -1062,22 +1022,6 @@
10621022
],
10631023
"tags": ["javascript", "dom", "remove", "utility"],
10641024
"author": "axorax"
1065-
},
1066-
{
1067-
"title": "Toggle Visibility",
1068-
"description": "Toggles the visibility of an element.",
1069-
"code": [
1070-
"const toggleVisibility = (element) => {",
1071-
" const currentDisplay = window.getComputedStyle(element).display;",
1072-
" element.style.display = currentDisplay === 'none' ? 'block' : 'none';",
1073-
"};",
1074-
"",
1075-
"// Usage:",
1076-
"const element = document.querySelector('.my-element');",
1077-
"toggleVisibility(element);"
1078-
],
1079-
"tags": ["javascript", "dom", "visibility", "toggle"],
1080-
"author": "axorax"
10811025
}
10821026
]
10831027
},
@@ -1143,10 +1087,10 @@
11431087
"author": "axorax"
11441088
},
11451089
{
1146-
"title": "Check Storage Capacity",
1147-
"description": "Checks the available space in the localStorage.",
1090+
"title": "Check bytes used",
1091+
"description": "Checks the amount of bytes used in the localStorage.",
11481092
"code": [
1149-
"const checkLocalStorageCapacity = () => {",
1093+
"const checkBytesUsed = () => {",
11501094
" let spaceUsed = 0;",
11511095
" for (let i = 0; i < localStorage.length; i++) {",
11521096
" spaceUsed += localStorage.key(i).length + localStorage.getItem(localStorage.key(i)).length;",
@@ -1155,7 +1099,7 @@
11551099
"};",
11561100
"",
11571101
"// Usage:",
1158-
"checkLocalStorageCapacity();"
1102+
"checkBytesUsed();"
11591103
],
11601104
"tags": ["javascript", "localStorage", "storage", "utility"],
11611105
"author": "axorax"
@@ -1276,28 +1220,6 @@
12761220
"tags": ["javascript", "number", "words", "utility"],
12771221
"author": "axorax"
12781222
},
1279-
{
1280-
"title": "Format Large Numbers with Abbreviations",
1281-
"description": "Formats large numbers with abbreviations like K, M, B, etc.",
1282-
"code": [
1283-
"const abbreviateNumber = (num) => {",
1284-
" const abbreviations = ['K', 'M', 'B', 'T'];",
1285-
" let i = 0;",
1286-
" while (num >= 1000 && i < abbreviations.length) {",
1287-
" num /= 1000;",
1288-
" i++;",
1289-
" }",
1290-
" return num.toFixed(1) + abbreviations[i];",
1291-
"};",
1292-
"",
1293-
"// Usage:",
1294-
"console.log(abbreviateNumber(2500)); // Output: '2.5K'",
1295-
"console.log(abbreviateNumber(10500000)); // Output: '10.5M'",
1296-
"console.log(abbreviateNumber(1000000000)); // Output: '1.0B'"
1297-
],
1298-
"tags": ["javascript", "number", "abbreviate", "utility"],
1299-
"author": "axorax"
1300-
},
13011223
{
13021224
"title": "Convert to Scientific Notation",
13031225
"description": "Converts a number to scientific notation.",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /