chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
972b88a8-f0d1-4123-9af5-a7b36dc46f0d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sudoku-validator.md
unknown
70c493f0-6ae5-4b30-8f6d-58f2f6bd0cb3
5
SemanticChunker@1.0.0
d57ecbfa375178ca05f28e366b5b57a573f4516504816e26d8e3a071ca25f075
[Approach > Performance] ## Performance Even with such a brute-force approach, the **performance difference** is quite substantial. Here are my results with each of the implementations: | Implementation | Runtime (ms) | Memory (MB) | |-----------------|--------------|-------------| | Original | 13 | 60.08 | | No int...
unknown
unknown
[Approach > Performance] ## Performance Even with such a brute-force approach, the **performance difference** is quite substantial. Here are my results with each of the implementations: | Implementation | Runtime (ms) | Memory (MB) | |-----------------|--------------|-------------| | Original | 13 | 60.08 | | No int...
[Approach > Performance] ## Performance Even with such a brute-force approach, the **performance difference** is quite substantial. Here are my results with each of the implementations: | Implementation | Runtime (ms) | Memory (MB) | |-----------------|--------------|-------------| | Original | 13 | 60.08 | | No int...
code_snippets
b3636011-b31e-465b-91a3-d21a3eebabe7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sudoku-validator.md
unknown
70c493f0-6ae5-4b30-8f6d-58f2f6bd0cb3
3
SemanticChunker@1.0.0
85a9a81ee1f5a3f4391d4b8c1c4d3d87608ad7ea7355fce483c12d5f2a9997b0
[Optimization > Remove intermediate arrays] ### Remove intermediate arrays One of the first things that stood out was the **creation of intermediate arrays**, especially `boardValues`. In the rows and sub-boxes check, it's entirely unnecessary. In the columns check, it can be replaced with `Array.prototype.reduce()` ...
unknown
unknown
[Optimization > Remove intermediate arrays] ### Remove intermediate arrays One of the first things that stood out was the **creation of intermediate arrays**, especially `boardValues`. In the rows and sub-boxes check, it's entirely unnecessary. In the columns check, it can be replaced with `Array.prototype.reduce()` ...
[Optimization > Remove intermediate arrays] ### Remove intermediate arrays One of the first things that stood out was the **creation of intermediate arrays**, especially `boardValues`. In the rows and sub-boxes check, it's entirely unnecessary. In the columns check, it can be replaced with `Array.prototype.reduce()` ...
code_snippets
b50dfe60-e2dd-4e73-81ef-a649410d60db
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sudoku-validator.md
unknown
70c493f0-6ae5-4b30-8f6d-58f2f6bd0cb3
0
SemanticChunker@1.0.0
5ad353100e9a9a0b41b328e1c2436fe56bee48b242b63a18548e9d05f29699aa
--- title: Implementing a Sudoku validator in JavaScript shortTitle: Sudoku Validator language: javascript tags: [algorithm,array] cover: bhutan-building excerpt: Sudoku is a logic-based combinatorial number-placement puzzle. This article discusses how to implement a Sudoku validator in JavaScript. listed: true dateMod...
unknown
unknown
--- title: Implementing a Sudoku validator in JavaScript shortTitle: Sudoku Validator language: javascript tags: [algorithm,array] cover: bhutan-building excerpt: Sudoku is a logic-based combinatorial number-placement puzzle. This article discusses how to implement a Sudoku validator in JavaScript. listed: true dateMod...
--- title: Implementing a Sudoku validator in JavaScript shortTitle: Sudoku Validator language: javascript tags: [algorithm,array] cover: bhutan-building excerpt: Sudoku is a logic-based combinatorial number-placement puzzle. This article discusses how to implement a Sudoku validator in JavaScript. listed: true dateMod...
code_snippets
d0ec2602-17ce-40b0-9fc2-3c6d9639e3d9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sudoku-validator.md
unknown
70c493f0-6ae5-4b30-8f6d-58f2f6bd0cb3
6
SemanticChunker@1.0.0
a73f9f76d69a763c442f6d709daee91f0fa6b8da06684a35472c94366c26dfa9
[Performance > Conclusion] ### Conclusion Coding challenges have a lot to teach us, in terms of **approaching problems**, as well as **optimizing our solutions**. Even if you aren't familiar with advanced techniques and are only just starting out, you can still advance your way of thinking and your skills by tackling...
unknown
unknown
[Performance > Conclusion] ### Conclusion Coding challenges have a lot to teach us, in terms of **approaching problems**, as well as **optimizing our solutions**. Even if you aren't familiar with advanced techniques and are only just starting out, you can still advance your way of thinking and your skills by tackling...
[Performance > Conclusion] ### Conclusion Coding challenges have a lot to teach us, in terms of **approaching problems**, as well as **optimizing our solutions**. Even if you aren't familiar with advanced techniques and are only just starting out, you can still advance your way of thinking and your skills by tackling...
code_snippets
d8380cf9-9a33-41c9-9e55-79712cf2543a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sudoku-validator.md
unknown
70c493f0-6ae5-4b30-8f6d-58f2f6bd0cb3
1
SemanticChunker@1.0.0
78e94e14eef431dec76b2008d376b4d13978718dc544f8312fe2347f16cfd251
[Approach] ## Approach There are various ways to go about this, but we'll be using a simple **brute-force approach**, as I think there's still a lot to learn from **tackling the sub-box problem**, as well as **optimizing the solution** for the given input constraints. One of the first things that came to mind was to...
unknown
unknown
[Approach] ## Approach There are various ways to go about this, but we'll be using a simple **brute-force approach**, as I think there's still a lot to learn from **tackling the sub-box problem**, as well as **optimizing the solution** for the given input constraints. One of the first things that came to mind was to...
[Approach] ## Approach There are various ways to go about this, but we'll be using a simple **brute-force approach**, as I think there's still a lot to learn from **tackling the sub-box problem**, as well as **optimizing the solution** for the given input constraints. One of the first things that came to mind was to...
code_snippets
672cbac6-5349-45d7-a32d-39831cb25206
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/substring-generator.md
unknown
0445f39a-a334-4beb-912f-ab545dc5cc59
1
SemanticChunker@1.0.0
09838f41c4cb79abef399823598e4fd4708bb077924795ac0b6242372625f039
[Left substring generator] ## Left substring generator Using a `for...in` loop, we can iterate over the string, and `yield` each substring, starting at the beginning. We can use `String.prototype.slice()` to get the substring. In order to terminate early, we can use `String.prototype.length` to check if the string is...
unknown
unknown
[Left substring generator] ## Left substring generator Using a `for...in` loop, we can iterate over the string, and `yield` each substring, starting at the beginning. We can use `String.prototype.slice()` to get the substring. In order to terminate early, we can use `String.prototype.length` to check if the string is...
[Left substring generator] ## Left substring generator Using a `for...in` loop, we can iterate over the string, and `yield` each substring, starting at the beginning. We can use `String.prototype.slice()` to get the substring. In order to terminate early, we can use `String.prototype.length` to check if the string is...
code_snippets
d0e26e3b-39d2-4bf5-b6a9-a8f37494a9eb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/substring-generator.md
unknown
0445f39a-a334-4beb-912f-ab545dc5cc59
0
SemanticChunker@1.0.0
acdc61634e58a27ddff5d432070a080b77905f6441d7bbe5f1d5c9003bf3eea7
--- title: How can I generate all partial substrings of a string in JavaScript? shortTitle: Substring generator language: javascript tags: [string,generator] cover: boutique-home-office-1 excerpt: Get all the partial substrings of a string in JavaScript using generator functions. listed: true dateModified: 2023-10-25 -...
unknown
unknown
--- title: How can I generate all partial substrings of a string in JavaScript? shortTitle: Substring generator language: javascript tags: [string,generator] cover: boutique-home-office-1 excerpt: Get all the partial substrings of a string in JavaScript using generator functions. listed: true dateModified: 2023-10-25 -...
--- title: How can I generate all partial substrings of a string in JavaScript? shortTitle: Substring generator language: javascript tags: [string,generator] cover: boutique-home-office-1 excerpt: Get all the partial substrings of a string in JavaScript using generator functions. listed: true dateModified: 2023-10-25 -...
code_snippets
e41559d5-eb9d-4e41-a6e5-03eb58a2634b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/substring-generator.md
unknown
0445f39a-a334-4beb-912f-ab545dc5cc59
2
SemanticChunker@1.0.0
a7a2bdd2fa4a8e9bd708dd998bac5848f46920ef942ba22daab6998681464bc9
[Left substring generator > Right substring generator] ## Right substring generator The exact same technique with a `for...in` loop can be used when starting at the end of the string. Same as before, albeit with a slight modification, we can use `String.prototype.slice()` to get the substring. And again, we use `Stri...
unknown
unknown
[Left substring generator > Right substring generator] ## Right substring generator The exact same technique with a `for...in` loop can be used when starting at the end of the string. Same as before, albeit with a slight modification, we can use `String.prototype.slice()` to get the substring. And again, we use `Stri...
[Left substring generator > Right substring generator] ## Right substring generator The exact same technique with a `for...in` loop can be used when starting at the end of the string. Same as before, albeit with a slight modification, we can use `String.prototype.slice()` to get the substring. And again, we use `Stri...
code_snippets
721dc007-25a9-4ef7-822d-7c814ec1de47
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/strip-html-tags.md
unknown
61422aaf-909d-438c-bd26-af65332aa76c
0
SemanticChunker@1.0.0
205eb3d6425b2431c222d79d1e9a06b64d8b9ed41ff9ddaf08e355764e946591
--- title: Strip HTML tags using JavaScript shortTitle: Strip HTML tags language: javascript tags: [string,regexp] cover: coffee-phone-tray-3 excerpt: Use a regular expression to remove HTML/XML tags from a string. listed: true dateModified: 2024-03-15 --- I've often found myself in need of stripping HTML tags from a ...
unknown
unknown
--- title: Strip HTML tags using JavaScript shortTitle: Strip HTML tags language: javascript tags: [string,regexp] cover: coffee-phone-tray-3 excerpt: Use a regular expression to remove HTML/XML tags from a string. listed: true dateModified: 2024-03-15 --- I've often found myself in need of stripping HTML tags from a ...
--- title: Strip HTML tags using JavaScript shortTitle: Strip HTML tags language: javascript tags: [string,regexp] cover: coffee-phone-tray-3 excerpt: Use a regular expression to remove HTML/XML tags from a string. listed: true dateModified: 2024-03-15 --- I've often found myself in need of stripping HTML tags from a ...
code_snippets
7e9d6ebd-54fd-4d64-b6f5-84a881a206d7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/stringify-circular-json.md
unknown
5f08a080-6e5f-4917-97fd-bea77058e2c8
0
SemanticChunker@1.0.0
212cbbfecb534e007555d166a0c6de4e691d850462af9e5771128592880c6e6d
--- title: Convert a JSON object with circular references to a JavaScript string shortTitle: Convert circular JSON to string language: javascript tags: [object] cover: waving-over-lake excerpt: Circular JSON objects can't be serialized using `JSON.stringify()`, but you can use this trick to handle them. listed: true da...
unknown
unknown
--- title: Convert a JSON object with circular references to a JavaScript string shortTitle: Convert circular JSON to string language: javascript tags: [object] cover: waving-over-lake excerpt: Circular JSON objects can't be serialized using `JSON.stringify()`, but you can use this trick to handle them. listed: true da...
--- title: Convert a JSON object with circular references to a JavaScript string shortTitle: Convert circular JSON to string language: javascript tags: [object] cover: waving-over-lake excerpt: Circular JSON objects can't be serialized using `JSON.stringify()`, but you can use this trick to handle them. listed: true da...
code_snippets
8cf56337-7f3d-41c2-a175-8889fb7cc785
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-to-words.md
unknown
c3a5abe3-1939-42ec-b6aa-372fee1791bc
0
SemanticChunker@1.0.0
2ff142922b90a6abae04cc3eeb1c41ce8d562d7e99010db45905851042443e69
--- title: Split a JavaScript string into words shortTitle: Split string into words language: javascript tags: [string] cover: sea-view-2 excerpt: Learn how to split a string into words, using the `Intl.Segmenter` API. listed: true dateModified: 2024-01-24 --- <baseline-support featureId="intl-segmenter"> </baseline-s...
unknown
unknown
--- title: Split a JavaScript string into words shortTitle: Split string into words language: javascript tags: [string] cover: sea-view-2 excerpt: Learn how to split a string into words, using the `Intl.Segmenter` API. listed: true dateModified: 2024-01-24 --- <baseline-support featureId="intl-segmenter"> </baseline-s...
--- title: Split a JavaScript string into words shortTitle: Split string into words language: javascript tags: [string] cover: sea-view-2 excerpt: Learn how to split a string into words, using the `Intl.Segmenter` API. listed: true dateModified: 2024-01-24 --- <baseline-support featureId="intl-segmenter"> </baseline-s...
code_snippets
a68b4d9d-978c-402e-af49-ba86f82c781f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-to-words.md
unknown
c3a5abe3-1939-42ec-b6aa-372fee1791bc
1
SemanticChunker@1.0.0
35ac4272f882cc9f1f830bca580fdf2b0366416766f5ee059a98a1ed54670131
> [!NOTE] > > At the time of writing (January, 2024), `Intl.Segmenter` doesn't have perfect support across all browsers. Most notably, it's **not yet supported in Firefox**, although support seems to be just around the corner. Make sure to double check compatibility before using it in production.
unknown
unknown
> [!NOTE] > > At the time of writing (January, 2024), `Intl.Segmenter` doesn't have perfect support across all browsers. Most notably, it's **not yet supported in Firefox**, although support seems to be just around the corner. Make sure to double check compatibility before using it in production.
> [!NOTE] > > At the time of writing (January, 2024), `Intl.Segmenter` doesn't have perfect support across all browsers. Most notably, it's **not yet supported in Firefox**, although support seems to be just around the corner. Make sure to double check compatibility before using it in production.
code_snippets
2298847d-c242-4cd0-a303-e948ba11a367
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-to-slug.md
unknown
c34f46d8-e3ce-4429-a6be-680ccfbec01d
0
SemanticChunker@1.0.0
32292104085f21692bb776727a3e206e97b766cb50f2aad091619f429c0e48fd
--- title: Convert a string to a SEO-friendly slug with JavaScript shortTitle: String to slug language: javascript tags: [string,regexp] cover: collab-desk-2 excerpt: Learn how to easily convert any string to a SEO-friendly slug, using regular expressions. listed: true dateModified: 2024-02-05 --- **SEO** is important...
unknown
unknown
--- title: Convert a string to a SEO-friendly slug with JavaScript shortTitle: String to slug language: javascript tags: [string,regexp] cover: collab-desk-2 excerpt: Learn how to easily convert any string to a SEO-friendly slug, using regular expressions. listed: true dateModified: 2024-02-05 --- **SEO** is important...
--- title: Convert a string to a SEO-friendly slug with JavaScript shortTitle: String to slug language: javascript tags: [string,regexp] cover: collab-desk-2 excerpt: Learn how to easily convert any string to a SEO-friendly slug, using regular expressions. listed: true dateModified: 2024-02-05 --- **SEO** is important...
code_snippets
61cca43b-061f-48b0-a6a4-abf127f8f348
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-to-boolean.md
unknown
d3a8b1a7-5662-4144-ae8a-4ede3f8a26d3
0
SemanticChunker@1.0.0
e52db6434c303765a6816375f1f79a1765ed713a7039d9e5de45d63849df2a4d
--- title: Convert a string to a boolean shortTitle: String to boolean language: javascript tags: [string,boolean,type] cover: two-cities excerpt: Have you ever tried to convert the string representation of a boolean to an actual boolean value? Here's a simple way to do it. listed: true dateModified: 2022-09-14 --- So...
unknown
unknown
--- title: Convert a string to a boolean shortTitle: String to boolean language: javascript tags: [string,boolean,type] cover: two-cities excerpt: Have you ever tried to convert the string representation of a boolean to an actual boolean value? Here's a simple way to do it. listed: true dateModified: 2022-09-14 --- So...
--- title: Convert a string to a boolean shortTitle: String to boolean language: javascript tags: [string,boolean,type] cover: two-cities excerpt: Have you ever tried to convert the string representation of a boolean to an actual boolean value? Here's a simple way to do it. listed: true dateModified: 2022-09-14 --- So...
code_snippets
f645aa55-73f8-496a-833b-76e9a4dc7bc2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sum-powers-in-range.md
unknown
2ba6b051-3cb6-4026-9fd7-48b78f818532
0
SemanticChunker@1.0.0
33a6d495a6c3345755f702d9cad6caed03906c6c2ed43352f897914e99c3e76c
--- title: Sum of powers in range language: javascript tags: [math] cover: boat-port excerpt: s the sum of the powers of all the numbers from `start` to `end` (both inclusive). listed: true dateModified: 2024-08-16 --- Calculating the **sum of the powers** of all the numbers from `start` to `end` (both inclusive) can ...
unknown
unknown
--- title: Sum of powers in range language: javascript tags: [math] cover: boat-port excerpt: s the sum of the powers of all the numbers from `start` to `end` (both inclusive). listed: true dateModified: 2024-08-16 --- Calculating the **sum of the powers** of all the numbers from `start` to `end` (both inclusive) can ...
--- title: Sum of powers in range language: javascript tags: [math] cover: boat-port excerpt: s the sum of the powers of all the numbers from `start` to `end` (both inclusive). listed: true dateModified: 2024-08-16 --- Calculating the **sum of the powers** of all the numbers from `start` to `end` (both inclusive) can ...
code_snippets
428549e3-390e-49ab-91e6-b50faf6df0cc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-starts-or-ends-with-substring.md
unknown
2618c35b-3913-474a-b5f0-0eec9bf5f765
2
SemanticChunker@1.0.0
16aee256e7627b663a517240cfc69a8b68cd828d9d31c004c71f69ec06ff6599
[Check if a string starts with a substring of another string > Check if a string ends with a substring of another string] ## Check if a string ends with a substring of another string We can use the same approach to check if a string ends with a substring of another string. The only difference is that we need to use `...
unknown
unknown
[Check if a string starts with a substring of another string > Check if a string ends with a substring of another string] ## Check if a string ends with a substring of another string We can use the same approach to check if a string ends with a substring of another string. The only difference is that we need to use `...
[Check if a string starts with a substring of another string > Check if a string ends with a substring of another string] ## Check if a string ends with a substring of another string We can use the same approach to check if a string ends with a substring of another string. The only difference is that we need to use `...
code_snippets
43394627-5878-4c8a-b873-b3139e58d0f7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-starts-or-ends-with-substring.md
unknown
2618c35b-3913-474a-b5f0-0eec9bf5f765
0
SemanticChunker@1.0.0
9d8264441fad58d0decb21bade5926688eff1733b167b8ac20db3dd660dfcbf8
--- title: How can I check if a string starts or ends with a substring of another string using JavaScript? shortTitle: Starts or ends with substring language: javascript tags: [string] cover: boutique-home-office-4 excerpt: Test if a string's start or end partially matches another string. listed: true dateModified: 202...
unknown
unknown
--- title: How can I check if a string starts or ends with a substring of another string using JavaScript? shortTitle: Starts or ends with substring language: javascript tags: [string] cover: boutique-home-office-4 excerpt: Test if a string's start or end partially matches another string. listed: true dateModified: 202...
--- title: How can I check if a string starts or ends with a substring of another string using JavaScript? shortTitle: Starts or ends with substring language: javascript tags: [string] cover: boutique-home-office-4 excerpt: Test if a string's start or end partially matches another string. listed: true dateModified: 202...
code_snippets
cc35683a-a589-42dc-9a6e-0da131d81748
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/string-starts-or-ends-with-substring.md
unknown
2618c35b-3913-474a-b5f0-0eec9bf5f765
1
SemanticChunker@1.0.0
9d40abfa75a713ebccf499c13f34cd7d71033b5742a596de310f0f537b42aaf3
[Check if a string starts with a substring of another string] ## Check if a string starts with a substring of another string `String.prototype.startsWith()` allows us to easily check if a string **starts with a given substring**. Unfortunately, in the case of this problem, this is insufficient by itself. Instead, we ...
unknown
unknown
[Check if a string starts with a substring of another string] ## Check if a string starts with a substring of another string `String.prototype.startsWith()` allows us to easily check if a string **starts with a given substring**. Unfortunately, in the case of this problem, this is insufficient by itself. Instead, we ...
[Check if a string starts with a substring of another string] ## Check if a string starts with a substring of another string `String.prototype.startsWith()` allows us to easily check if a string **starts with a given substring**. Unfortunately, in the case of this problem, this is insufficient by itself. Instead, we ...
code_snippets
19aec0b4-7a08-4789-b0b9-eae5f059d86d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-elements-by-condition-from-array-start-or-end.md
unknown
e2f5fbaf-d083-4c7e-959e-072fcc4c844c
0
SemanticChunker@1.0.0
30aed0ce87069dc391dea6eff22fe8a02e573bd0b5def2067088c7bb01f5badb
--- title: Get elements from the start or end of a JavaScript array by condition shortTitle: Conditionally get array elements from start or end language: javascript tags: [array] cover: sunset-textured-beach excerpt: Learn how to get elements from the start or end of a JavaScript array by condition, using `Array.protot...
unknown
unknown
--- title: Get elements from the start or end of a JavaScript array by condition shortTitle: Conditionally get array elements from start or end language: javascript tags: [array] cover: sunset-textured-beach excerpt: Learn how to get elements from the start or end of a JavaScript array by condition, using `Array.protot...
--- title: Get elements from the start or end of a JavaScript array by condition shortTitle: Conditionally get array elements from start or end language: javascript tags: [array] cover: sunset-textured-beach excerpt: Learn how to get elements from the start or end of a JavaScript array by condition, using `Array.protot...
code_snippets
bed66590-07c1-4a4f-9569-6a71696cf349
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-elements-by-condition-from-array-start-or-end.md
unknown
e2f5fbaf-d083-4c7e-959e-072fcc4c844c
1
SemanticChunker@1.0.0
1de9ee397a52a0c30df63004ebf34e7f01af226a5167bfc9af5740c8c043fda3
[Get elements from the start of the array while condition is met] ## Get elements from the start of the array while condition is met Modern JavaScript is full of useful array methods, which help us avoid writing `for...of` loops, which I personally find to be a bit old-fashioned. At the core of the problem we want to...
unknown
unknown
[Get elements from the start of the array while condition is met] ## Get elements from the start of the array while condition is met Modern JavaScript is full of useful array methods, which help us avoid writing `for...of` loops, which I personally find to be a bit old-fashioned. At the core of the problem we want to...
[Get elements from the start of the array while condition is met] ## Get elements from the start of the array while condition is met Modern JavaScript is full of useful array methods, which help us avoid writing `for...of` loops, which I personally find to be a bit old-fashioned. At the core of the problem we want to...
code_snippets
f922d239-8b92-4538-8430-0284d9bfbb3e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-elements-by-condition-from-array-start-or-end.md
unknown
e2f5fbaf-d083-4c7e-959e-072fcc4c844c
2
SemanticChunker@1.0.0
fcb5ca337da88f0586edc7164bd194f6ace24abee6952c802606fa525eca7d56
[Get elements from the start of the array while condition is met > Get elements from the end of the array while condition is met] ## Get elements from the end of the array while condition is met Getting elements from the end of the array is pretty similar. To find the index, we'll have to use `Array.prototype.findLas...
unknown
unknown
[Get elements from the start of the array while condition is met > Get elements from the end of the array while condition is met] ## Get elements from the end of the array while condition is met Getting elements from the end of the array is pretty similar. To find the index, we'll have to use `Array.prototype.findLas...
[Get elements from the start of the array while condition is met > Get elements from the end of the array while condition is met] ## Get elements from the end of the array while condition is met Getting elements from the end of the array is pretty similar. To find the index, we'll have to use `Array.prototype.findLas...
code_snippets
125e2714-4e21-4045-af0e-a33fa89d2a4c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-n-elements-from-array-start-or-end.md
unknown
3166f395-23d3-4ec7-a9a9-44e4c1919afb
2
SemanticChunker@1.0.0
693a4944791c99c02af4e52f6433aab46f61a41eec8b937f25859243042ac8fb
[Get the first N elements of an array > Get the last N elements of an array] ## Get the last N elements of an array Getting the **last N elements** of an array is pretty similar. Passing a negative index to `Array.prototype.slice()` is all that's necessary to make this work. ```js const takeRight = (arr, n = 1) => a...
unknown
unknown
[Get the first N elements of an array > Get the last N elements of an array] ## Get the last N elements of an array Getting the **last N elements** of an array is pretty similar. Passing a negative index to `Array.prototype.slice()` is all that's necessary to make this work. ```js const takeRight = (arr, n = 1) => a...
[Get the first N elements of an array > Get the last N elements of an array] ## Get the last N elements of an array Getting the **last N elements** of an array is pretty similar. Passing a negative index to `Array.prototype.slice()` is all that's necessary to make this work. ```js const takeRight = (arr, n = 1) => a...
code_snippets
1bc116f5-5a3e-499b-9094-be9e0fa176e4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-n-elements-from-array-start-or-end.md
unknown
3166f395-23d3-4ec7-a9a9-44e4c1919afb
1
SemanticChunker@1.0.0
f758348484aaae18a04987e2fe8fa4f45896d4a89f3a80b67766cf246c10e32b
[Get the first N elements of an array] ## Get the first N elements of an array Starting simple, you might want to get the **first N elements** of an array. Using `Array.prototype.slice()` you can easily achieve this by passing `0` as the starting index and `n` as the ending index. ```js const take = (arr, n = 1) => ...
unknown
unknown
[Get the first N elements of an array] ## Get the first N elements of an array Starting simple, you might want to get the **first N elements** of an array. Using `Array.prototype.slice()` you can easily achieve this by passing `0` as the starting index and `n` as the ending index. ```js const take = (arr, n = 1) => ...
[Get the first N elements of an array] ## Get the first N elements of an array Starting simple, you might want to get the **first N elements** of an array. Using `Array.prototype.slice()` you can easily achieve this by passing `0` as the starting index and `n` as the ending index. ```js const take = (arr, n = 1) => ...
code_snippets
57294f36-5ad5-4aaf-91bc-18f7968a1f39
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/take-n-elements-from-array-start-or-end.md
unknown
3166f395-23d3-4ec7-a9a9-44e4c1919afb
0
SemanticChunker@1.0.0
951ddca3147d94d8617b6e8c116df22d87a6db136b7548933a2b2b47a4431d24
--- title: Get N elements from the start or end of a JavaScript array shortTitle: Get N array elements from start or end language: javascript tags: [array] cover: interior-7 excerpt: Learn how to get the first or last N elements of a JavaScript array, using `Array.prototype.slice()`. listed: true dateModified: 2023-07-...
unknown
unknown
--- title: Get N elements from the start or end of a JavaScript array shortTitle: Get N array elements from start or end language: javascript tags: [array] cover: interior-7 excerpt: Learn how to get the first or last N elements of a JavaScript array, using `Array.prototype.slice()`. listed: true dateModified: 2023-07-...
--- title: Get N elements from the start or end of a JavaScript array shortTitle: Get N array elements from start or end language: javascript tags: [array] cover: interior-7 excerpt: Learn how to get the first or last N elements of a JavaScript array, using `Array.prototype.slice()`. listed: true dateModified: 2023-07-...
code_snippets
0106969f-811e-4998-a43a-9c6018dc846f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/sync-async.md
unknown
9f214531-f60c-48c9-adcc-6ce6a53e5fc9
0
SemanticChunker@1.0.0
4db59b2e6dc1b143846d770e9bf8cbb72a41398f5e6998582a017db0b6715939
--- title: What is the difference between synchronous and asynchronous code in JavaScript? shortTitle: Synchronous vs asynchronous code language: javascript tags: [function,promises] cover: pineapple-on-green excerpt: Understanding the differences between synchronous and asynchronous code is a crucial piece of knowledg...
unknown
unknown
--- title: What is the difference between synchronous and asynchronous code in JavaScript? shortTitle: Synchronous vs asynchronous code language: javascript tags: [function,promises] cover: pineapple-on-green excerpt: Understanding the differences between synchronous and asynchronous code is a crucial piece of knowledg...
--- title: What is the difference between synchronous and asynchronous code in JavaScript? shortTitle: Synchronous vs asynchronous code language: javascript tags: [function,promises] cover: pineapple-on-green excerpt: Understanding the differences between synchronous and asynchronous code is a crucial piece of knowledg...
code_snippets
2fe3efa1-8bc0-4fd6-97bf-60455b8728d5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/ternary-operator.md
unknown
0ef3f12d-b6b8-41eb-bd98-c60906c14813
0
SemanticChunker@1.0.0
000720a06170cf10c2edfa22eb4273ea3e39029ab8d98fcbfd05920ead5336fb
--- title: What is the ternary operator and how do I use it? shortTitle: Ternary operation introduction language: javascript tags: [condition] cover: red-succulent excerpt: Learn everything you need to know about the conditional (ternary) operator and how to use it in JavaScript. listed: true dateModified: 2021-06-12 -...
unknown
unknown
--- title: What is the ternary operator and how do I use it? shortTitle: Ternary operation introduction language: javascript tags: [condition] cover: red-succulent excerpt: Learn everything you need to know about the conditional (ternary) operator and how to use it in JavaScript. listed: true dateModified: 2021-06-12 -...
--- title: What is the ternary operator and how do I use it? shortTitle: Ternary operation introduction language: javascript tags: [condition] cover: red-succulent excerpt: Learn everything you need to know about the conditional (ternary) operator and how to use it in JavaScript. listed: true dateModified: 2021-06-12 -...
code_snippets
cac0a82a-cf56-4341-8ebe-f5934a6ef846
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/ternary-operator.md
unknown
0ef3f12d-b6b8-41eb-bd98-c60906c14813
1
SemanticChunker@1.0.0
fd11594ff623deb9cce6ab9a32bb151412a5d72a771092d9d88d83b24240317d
Finally, you might be wondering why it's called the "ternary" operator. The word "ternary" is based on the [n-ary word setup](https://en.wikipedia.org/wiki/Arity) and means an operator with three operands (condition, expression to execute if truthy, expression to execute if falsy).
unknown
unknown
Finally, you might be wondering why it's called the "ternary" operator. The word "ternary" is based on the [n-ary word setup](https://en.wikipedia.org/wiki/Arity) and means an operator with three operands (condition, expression to execute if truthy, expression to execute if falsy).
Finally, you might be wondering why it's called the "ternary" operator. The word "ternary" is based on the [n-ary word setup](https://en.wikipedia.org/wiki/Arity) and means an operator with three operands (condition, expression to execute if truthy, expression to execute if falsy).
code_snippets
a3e860cd-6dff-40ba-8de9-e7fe7f18e631
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/switch-object.md
unknown
bb3b9bc1-c8f6-42b9-ace7-f4e9f74a9c96
2
SemanticChunker@1.0.0
06437e68138dbe5acb74c1523d3ae2e681f33eaa8e176d1909e2c0cb4d2c3dcd
```js const switchFn = (lookupObject, defaultCase = '_default') => expression => (lookupObject[expression] || lookupObject[defaultCase])(); const knownFruit = () => console.log('Known fruit'); const unknownFruit = () => console.log('Unknown fruit'); const logFruit = { 'apples': knownFruit, 'oranges': knownFruit, ...
unknown
unknown
```js const switchFn = (lookupObject, defaultCase = '_default') => expression => (lookupObject[expression] || lookupObject[defaultCase])(); const knownFruit = () => console.log('Known fruit'); const unknownFruit = () => console.log('Unknown fruit'); const logFruit = { 'apples': knownFruit, 'oranges': knownFruit, ...
```js const switchFn = (lookupObject, defaultCase = '_default') => expression => (lookupObject[expression] || lookupObject[defaultCase])(); const knownFruit = () => console.log('Known fruit'); const unknownFruit = () => console.log('Unknown fruit'); const logFruit = { 'apples': knownFruit, 'oranges': knownFruit, ...
code_snippets
c539714c-2cd5-42bb-81af-e062c711e39c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/switch-object.md
unknown
bb3b9bc1-c8f6-42b9-ace7-f4e9f74a9c96
0
SemanticChunker@1.0.0
a7b75efa178bcae7966ea5dad5f69b57f0d40e7de7372a731877ee852b6331ce
--- title: Replacing JavaScript switch statement with object literals shortTitle: Switch with object literals language: javascript tags: [object] cover: rocky-lake excerpt: JavaScript's `switch` statement often feels hard to remember and a little bit out of place. Maybe it's time to use object literals, instead. listed...
unknown
unknown
--- title: Replacing JavaScript switch statement with object literals shortTitle: Switch with object literals language: javascript tags: [object] cover: rocky-lake excerpt: JavaScript's `switch` statement often feels hard to remember and a little bit out of place. Maybe it's time to use object literals, instead. listed...
--- title: Replacing JavaScript switch statement with object literals shortTitle: Switch with object literals language: javascript tags: [object] cover: rocky-lake excerpt: JavaScript's `switch` statement often feels hard to remember and a little bit out of place. Maybe it's time to use object literals, instead. listed...
code_snippets
f4de5072-477e-4b33-9737-648dfb7d4d8e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/switch-object.md
unknown
bb3b9bc1-c8f6-42b9-ace7-f4e9f74a9c96
1
SemanticChunker@1.0.0
53a3c2fea0969d65495830caeb01a41c9cb1fbe26e4bcabd658310d8c528fde2
```js let fruit = 'strawberries'; switch (fruit) { case 'apples': console.log('Apples'); break; case 'oranges': console.log('Oranges'); break; default: console.log('Unknown fruit'); } // Logs: 'Unknown fruit' const logFruit = { 'apples': () => console.log('Apples'), 'oranges': () => console.log('Oranges'), ...
unknown
unknown
```js let fruit = 'strawberries'; switch (fruit) { case 'apples': console.log('Apples'); break; case 'oranges': console.log('Oranges'); break; default: console.log('Unknown fruit'); } // Logs: 'Unknown fruit' const logFruit = { 'apples': () => console.log('Apples'), 'oranges': () => console.log('Oranges'), ...
```js let fruit = 'strawberries'; switch (fruit) { case 'apples': console.log('Apples'); break; case 'oranges': console.log('Oranges'); break; default: console.log('Unknown fruit'); } // Logs: 'Unknown fruit' const logFruit = { 'apples': () => console.log('Apples'), 'oranges': () => console.log('Oranges'), ...
code_snippets
523681e1-0b03-49ed-982a-491901b77f25
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/swap-two-variables.md
unknown
c70e2bde-3a8e-4c0d-927c-569ccc565c6b
0
SemanticChunker@1.0.0
32e1b1ec1653009ccb5cfd5857674bf28a105ba19b409764ebac811a9cf586b4
--- title: How to swap two variables in JavaScript shortTitle: Swap two variables language: javascript tags: [variables] cover: mountain-lake-2 excerpt: Learn how to swap the values of two variables in JavaScript using a single line of ES6 code. listed: true dateModified: 2021-06-12 --- In the past, swapping the value...
unknown
unknown
--- title: How to swap two variables in JavaScript shortTitle: Swap two variables language: javascript tags: [variables] cover: mountain-lake-2 excerpt: Learn how to swap the values of two variables in JavaScript using a single line of ES6 code. listed: true dateModified: 2021-06-12 --- In the past, swapping the value...
--- title: How to swap two variables in JavaScript shortTitle: Swap two variables language: javascript tags: [variables] cover: mountain-lake-2 excerpt: Learn how to swap the values of two variables in JavaScript using a single line of ES6 code. listed: true dateModified: 2021-06-12 --- In the past, swapping the value...
code_snippets
fa711e4a-f771-4dcd-a192-ddf9a54a3966
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/swap-case.md
unknown
55f5af24-38db-45eb-9abe-766f7d1d7854
0
SemanticChunker@1.0.0
5ee643febb003a84779ea050e67f49dc82c234e56d828046ed2c298545cc1aac
--- title: Swapcase a JavaScript string shortTitle: Swapcase string language: javascript tags: [string] cover: mountain-lake-2 excerpt: Learn how to create a string with uppercase characters converted to lowercase and vice versa. listed: true dateModified: 2024-02-10 --- A fun little exercise I've seen in many beginne...
unknown
unknown
--- title: Swapcase a JavaScript string shortTitle: Swapcase string language: javascript tags: [string] cover: mountain-lake-2 excerpt: Learn how to create a string with uppercase characters converted to lowercase and vice versa. listed: true dateModified: 2024-02-10 --- A fun little exercise I've seen in many beginne...
--- title: Swapcase a JavaScript string shortTitle: Swapcase string language: javascript tags: [string] cover: mountain-lake-2 excerpt: Learn how to create a string with uppercase characters converted to lowercase and vice versa. listed: true dateModified: 2024-02-10 --- A fun little exercise I've seen in many beginne...
code_snippets
0a8d854c-e51c-4e39-8a96-ab25da77c34e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
3
SemanticChunker@1.0.0
04012454d2f8a84b94582ba0547e774b95e8b694d82ab8e40dc831bbc0ca2cb0
[Refactoring process > Unnecessary options objects] ### Unnecessary options objects Some of my intermediate abstractions were using **options objects**. Upon closer inspection, those weren't really necessary. Let's look at the example of groups: ```js title="src/group.js" import { Segment, toSegments, joinSegments }...
unknown
unknown
[Refactoring process > Unnecessary options objects] ### Unnecessary options objects Some of my intermediate abstractions were using **options objects**. Upon closer inspection, those weren't really necessary. Let's look at the example of groups: ```js title="src/group.js" import { Segment, toSegments, joinSegments }...
[Refactoring process > Unnecessary options objects] ### Unnecessary options objects Some of my intermediate abstractions were using **options objects**. Upon closer inspection, those weren't really necessary. Let's look at the example of groups: ```js title="src/group.js" import { Segment, toSegments, joinSegments }...
code_snippets
3a26ba8b-3e07-4500-9f40-f50768b73b51
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
11
SemanticChunker@1.0.0
3448a64dbd4f384f68d4d8114e37370d83c8b9a8535c221f4388dfa8b3e14947
[Refactoring process > Minified bundle] ### Minified bundle As promised, I'd like to release the **minified code** of the library. Let's update our Vite configuration to produce two builds - one raw and one minified: ```js title="vite.config.js" import { dirname, resolve } from 'node:path'; import { fileURLToPath } ...
unknown
unknown
[Refactoring process > Minified bundle] ### Minified bundle As promised, I'd like to release the **minified code** of the library. Let's update our Vite configuration to produce two builds - one raw and one minified: ```js title="vite.config.js" import { dirname, resolve } from 'node:path'; import { fileURLToPath } ...
[Refactoring process > Minified bundle] ### Minified bundle As promised, I'd like to release the **minified code** of the library. Let's update our Vite configuration to produce two builds - one raw and one minified: ```js title="vite.config.js" import { dirname, resolve } from 'node:path'; import { fileURLToPath } ...
code_snippets
3b664b17-97b7-47f1-82e3-e18dcd81a3f6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
7
SemanticChunker@1.0.0
d2fa3dfb7724db02d1b4fe942b6bd9515ff1c95b60b7e30acc6a591eb9bcc0d6
[Refactoring process > Extracting common patterns] ### Extracting common patterns There's another **commonality** between the creation utilities: they all join a bunch of expressions together, then wrap them in a prefix and/or suffix. We can extract this pattern into a [**higher-order function**](/js/s/higher-order-f...
unknown
unknown
[Refactoring process > Extracting common patterns] ### Extracting common patterns There's another **commonality** between the creation utilities: they all join a bunch of expressions together, then wrap them in a prefix and/or suffix. We can extract this pattern into a [**higher-order function**](/js/s/higher-order-f...
[Refactoring process > Extracting common patterns] ### Extracting common patterns There's another **commonality** between the creation utilities: they all join a bunch of expressions together, then wrap them in a prefix and/or suffix. We can extract this pattern into a [**higher-order function**](/js/s/higher-order-f...
code_snippets
3c7ecdc3-5f81-4a94-a8e0-f2c2bb0a185e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
4
SemanticChunker@1.0.0
ad14cc26a8d2cacc27fdfdff798e7661b01e7bf084d3dafdc45def0aef375eb9
[Refactoring process > Unnecessary options objects] const toQuantifier = (expressions, suffix) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = (...expressions) => toQuantifier(expressions, '?'); export const zeroOrOneLazy = (...expressions) => toQuantifier(expressions...
unknown
unknown
[Refactoring process > Unnecessary options objects] const toQuantifier = (expressions, suffix) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = (...expressions) => toQuantifier(expressions, '?'); export const zeroOrOneLazy = (...expressions) => toQuantifier(expressions...
[Refactoring process > Unnecessary options objects] const toQuantifier = (expressions, suffix) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = (...expressions) => toQuantifier(expressions, '?'); export const zeroOrOneLazy = (...expressions) => toQuantifier(expressions...
code_snippets
533b082f-8089-4ee6-9db4-06f73c3c7ff1
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
12
SemanticChunker@1.0.0
cf7ff57debbcab58558bd7d60f23269ebe0f1ea021c78b225865a242a1673d02
[Refactoring goals > Conclusion] ## Conclusion After a long journey, we've finally arrived at the end of this series. We've seen how TDD can help us design a user-centric API, implement it, bundle it with Vite and, finally, refactor it without worrying about breaking things. I hope you've enjoyed the series as much ...
unknown
unknown
[Refactoring goals > Conclusion] ## Conclusion After a long journey, we've finally arrived at the end of this series. We've seen how TDD can help us design a user-centric API, implement it, bundle it with Vite and, finally, refactor it without worrying about breaking things. I hope you've enjoyed the series as much ...
[Refactoring goals > Conclusion] ## Conclusion After a long journey, we've finally arrived at the end of this series. We've seen how TDD can help us design a user-centric API, implement it, bundle it with Vite and, finally, refactor it without worrying about breaking things. I hope you've enjoyed the series as much ...
code_snippets
5a231eea-4e49-4640-87f4-40d6f6969109
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
9
SemanticChunker@1.0.0
e4a1350ff488fea5e53cb162d04ec83b4b609845625538b936c1898a63926ebf
[Refactoring process > Removing redundancy] export const toCharacterSet = expression => { if (Array.isArray(expression) && expression.length === 2) return toSegments('', '', '-')(...expression); return toSegments()(expression); }; export const anythingFrom = toSegments('[', ']', '|', toCharacterSet); export const ...
unknown
unknown
[Refactoring process > Removing redundancy] export const toCharacterSet = expression => { if (Array.isArray(expression) && expression.length === 2) return toSegments('', '', '-')(...expression); return toSegments()(expression); }; export const anythingFrom = toSegments('[', ']', '|', toCharacterSet); export const ...
[Refactoring process > Removing redundancy] export const toCharacterSet = expression => { if (Array.isArray(expression) && expression.length === 2) return toSegments('', '', '-')(...expression); return toSegments()(expression); }; export const anythingFrom = toSegments('[', ']', '|', toCharacterSet); export const ...
code_snippets
61736a43-da3b-4087-8291-afdd93ad96a0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
8
SemanticChunker@1.0.0
e33cf74082de4cc0d3eee7cc5fd168875246283d07490c12a889cb01ecc0b3b0
[Refactoring process > Removing redundancy] ### Removing redundancy At this point, the creation utilities serve little to **no purpose**. We can **inline** them into the functions that call them and save a few more lines: ```js title="src/group.js" import { wrapSegments } from './segment.js'; export const captureGr...
unknown
unknown
[Refactoring process > Removing redundancy] ### Removing redundancy At this point, the creation utilities serve little to **no purpose**. We can **inline** them into the functions that call them and save a few more lines: ```js title="src/group.js" import { wrapSegments } from './segment.js'; export const captureGr...
[Refactoring process > Removing redundancy] ### Removing redundancy At this point, the creation utilities serve little to **no purpose**. We can **inline** them into the functions that call them and save a few more lines: ```js title="src/group.js" import { wrapSegments } from './segment.js'; export const captureGr...
code_snippets
74a35bcf-2858-40f7-8dd8-dff69bc03a54
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
10
SemanticChunker@1.0.0
0054f42ce046667e15fdaa2fc402d0ffbab09f28db66a7f560ca57038ac9afa1
[Refactoring process > Removing redundancy] ``` And that's pretty much all I could think of to refactor. Let's see how we did! ## Results It's definitely easy to see that the code is significantly shorter. I don't really think we sacrificed too much readability, either. If anything, you now need to read through and...
unknown
unknown
[Refactoring process > Removing redundancy] ``` And that's pretty much all I could think of to refactor. Let's see how we did! ## Results It's definitely easy to see that the code is significantly shorter. I don't really think we sacrificed too much readability, either. If anything, you now need to read through and...
[Refactoring process > Removing redundancy] ``` And that's pretty much all I could think of to refactor. Let's see how we did! ## Results It's definitely easy to see that the code is significantly shorter. I don't really think we sacrificed too much readability, either. If anything, you now need to read through and...
code_snippets
80c84bf2-270a-4126-a468-d0cbba78fabc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
0
SemanticChunker@1.0.0
c7e97161d8a9ced918a789df2794566069ab0558d6b2d1da1454d0ff8ea2dc4e
--- title: Using Test-Driven Development to refactor a JavaScript project shortTitle: Refactoring a codebase language: javascript tags: [webdev,regexp,function] cover: succulent-11 excerpt: In the last installment of the series, we'll refactor our codebase to reduce bundle size and complexity, while making it more main...
unknown
unknown
--- title: Using Test-Driven Development to refactor a JavaScript project shortTitle: Refactoring a codebase language: javascript tags: [webdev,regexp,function] cover: succulent-11 excerpt: In the last installment of the series, we'll refactor our codebase to reduce bundle size and complexity, while making it more main...
--- title: Using Test-Driven Development to refactor a JavaScript project shortTitle: Refactoring a codebase language: javascript tags: [webdev,regexp,function] cover: succulent-11 excerpt: In the last installment of the series, we'll refactor our codebase to reduce bundle size and complexity, while making it more main...
code_snippets
d1fc4c2e-8e26-4e82-8e5e-d17caf0e7bd3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
1
SemanticChunker@1.0.0
3c9ae797394c68692030d22da222ea0cc62f92b8ab42acb8a0938a05a6018824
[Refactoring goals] ## Refactoring goals The main goals of this refactoring are threefold: reduce **complexity**, make the code **less error-prone**, and make the code **more maintainable**. As a health metric, we'll be aiming to keep **readability** at about the same level. We'll also be leaning quite heavily on the...
unknown
unknown
[Refactoring goals] ## Refactoring goals The main goals of this refactoring are threefold: reduce **complexity**, make the code **less error-prone**, and make the code **more maintainable**. As a health metric, we'll be aiming to keep **readability** at about the same level. We'll also be leaning quite heavily on the...
[Refactoring goals] ## Refactoring goals The main goals of this refactoring are threefold: reduce **complexity**, make the code **less error-prone**, and make the code **more maintainable**. As a health metric, we'll be aiming to keep **readability** at about the same level. We'll also be leaning quite heavily on the...
code_snippets
d6744861-e7e3-4aee-98ec-b4912e8c77c4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
5
SemanticChunker@1.0.0
790484f37cecfda6069adccb3e9ccab665cfc8f1978bee1eccd334fd694c30b4
[Refactoring process > Merging functions] ### Merging functions At this point, `joinSegments` is only ever called in tandem with `toSegments`. It stands to reason that these two functions, simple as they are, could be **merged into a single function**. Let's do that: ```js title="src/segment.js" export const joinSeg...
unknown
unknown
[Refactoring process > Merging functions] ### Merging functions At this point, `joinSegments` is only ever called in tandem with `toSegments`. It stands to reason that these two functions, simple as they are, could be **merged into a single function**. Let's do that: ```js title="src/segment.js" export const joinSeg...
[Refactoring process > Merging functions] ### Merging functions At this point, `joinSegments` is only ever called in tandem with `toSegments`. It stands to reason that these two functions, simple as they are, could be **merged into a single function**. Let's do that: ```js title="src/segment.js" export const joinSeg...
code_snippets
db6d4a6d-3810-4a98-8f56-68ad0d03bd69
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
2
SemanticChunker@1.0.0
8cdd6dd5cf46082d2b62b0647e21396db6d361cf1f8badba67a51d2d1c3432e6
[Refactoring goals > Refactoring process] ## Refactoring process Like I said, I started by taking a long hard look at the code. Where could one spot complexity that wasn't really necessary? What patterns could be extracted into abstractions? > [!NOTE] > > Some details of the refactoring process have been omitted for...
unknown
unknown
[Refactoring goals > Refactoring process] ## Refactoring process Like I said, I started by taking a long hard look at the code. Where could one spot complexity that wasn't really necessary? What patterns could be extracted into abstractions? > [!NOTE] > > Some details of the refactoring process have been omitted for...
[Refactoring goals > Refactoring process] ## Refactoring process Like I said, I started by taking a long hard look at the code. Where could one spot complexity that wasn't really necessary? What patterns could be extracted into abstractions? > [!NOTE] > > Some details of the refactoring process have been omitted for...
code_snippets
f505ec2a-ab0e-4e05-a108-56431f125719
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-codebase-refactoring.md
unknown
4bab9125-b967-41ed-86b0-b05cfe80572c
6
SemanticChunker@1.0.0
fd2d8924752c97ee392a650ea3c4428614929a7091d053158dcdc1aa81be5f1b
[Refactoring process > Merging functions] ```js title="src/quantifiers.js" import { Segment } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = suffix => (...expressions) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = toQuantifier...
unknown
unknown
[Refactoring process > Merging functions] ```js title="src/quantifiers.js" import { Segment } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = suffix => (...expressions) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = toQuantifier...
[Refactoring process > Merging functions] ```js title="src/quantifiers.js" import { Segment } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = suffix => (...expressions) => new Segment(`${nonCaptureGroup(...expressions).source}${suffix}`); export const zeroOrOne = toQuantifier...
code_snippets
7678c4eb-c810-4fee-ad6c-ddffa3de0436
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/superset-subset-of-array.md
unknown
d86897ec-9e2c-4cbd-9577-b6c3d2826f6a
0
SemanticChunker@1.0.0
bc0a63bd6a25d9c1570614ae25630b3f70c5f0d737815704f08ceb49e465050e
--- title: How can I check if an array is a superset of another array in JavaScript? shortTitle: Superset language: javascript tags: [array] cover: waves-from-above-2 excerpt: Check if an iterable is a superset of another one, excluding duplicate values. listed: true dateModified: 2024-01-01 --- A **superset** is a se...
unknown
unknown
--- title: How can I check if an array is a superset of another array in JavaScript? shortTitle: Superset language: javascript tags: [array] cover: waves-from-above-2 excerpt: Check if an iterable is a superset of another one, excluding duplicate values. listed: true dateModified: 2024-01-01 --- A **superset** is a se...
--- title: How can I check if an array is a superset of another array in JavaScript? shortTitle: Superset language: javascript tags: [array] cover: waves-from-above-2 excerpt: Check if an iterable is a superset of another one, excluding duplicate values. listed: true dateModified: 2024-01-01 --- A **superset** is a se...
code_snippets
1a488894-d9de-405b-9859-da855a3e4f4b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
21
SemanticChunker@1.0.0
ce31e95f876eb4ba3ffcc9c8f477115012525668465244b5ec4bfef2c6a867b4
[API design recap > Conclusion] ## Conclusion Phew! That was quite a long journey, but I think the library is now ready for use. Using TDD and a carefully designed API before starting out, the library took shape easily and quickly. The resulting bundle is small and the code is easy to read and understand. Next time, ...
unknown
unknown
[API design recap > Conclusion] ## Conclusion Phew! That was quite a long journey, but I think the library is now ready for use. Using TDD and a carefully designed API before starting out, the library took shape easily and quickly. The resulting bundle is small and the code is easy to read and understand. Next time, ...
[API design recap > Conclusion] ## Conclusion Phew! That was quite a long journey, but I think the library is now ready for use. Using TDD and a carefully designed API before starting out, the library took shape easily and quickly. The resulting bundle is small and the code is easy to read and understand. Next time, ...
code_snippets
21cbbbb7-6ff8-4b4d-b6e6-577463a368c3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
3
SemanticChunker@1.0.0
c19759cdd3528f56fb96de5688842797476a0b427b4332645fef2f9ba54c1f39
[API implementation > Regular expression patterns] ### Regular expression patterns My initial approach hinged on creating a pattern class that could be used to build regular expressions. This approach assumed that any pattern should be possible to test on its own (thus making TDD more feasible). Therefore, I started ...
unknown
unknown
[API implementation > Regular expression patterns] ### Regular expression patterns My initial approach hinged on creating a pattern class that could be used to build regular expressions. This approach assumed that any pattern should be possible to test on its own (thus making TDD more feasible). Therefore, I started ...
[API implementation > Regular expression patterns] ### Regular expression patterns My initial approach hinged on creating a pattern class that could be used to build regular expressions. This approach assumed that any pattern should be possible to test on its own (thus making TDD more feasible). Therefore, I started ...
code_snippets
2e24e88e-0934-4e32-a8df-75766f496ae1
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
20
SemanticChunker@1.0.0
d87de34cf60f4bde69255451cb41c5a83c0cc2fb4304ff853c9faa52ed433cd5
[Exports > Publishing to npm] ### Publishing to npm Finally, we can **publish our package to npm**. We'll need to specify a few things in our `package.json` first to make sure the right files are included and the package is importable as an ES module: ```json title="package.json" { "name": "readex", "type": "modul...
unknown
unknown
[Exports > Publishing to npm] ### Publishing to npm Finally, we can **publish our package to npm**. We'll need to specify a few things in our `package.json` first to make sure the right files are included and the package is importable as an ES module: ```json title="package.json" { "name": "readex", "type": "modul...
[Exports > Publishing to npm] ### Publishing to npm Finally, we can **publish our package to npm**. We'll need to specify a few things in our `package.json` first to make sure the right files are included and the package is importable as an ES module: ```json title="package.json" { "name": "readex", "type": "modul...
code_snippets
3457f0d1-ac6a-4c08-976e-598ec1f1e544
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
0
SemanticChunker@1.0.0
a30cec90db5228a30a0a1d1d5db686d1432619e34fa35055eb71d4a9e1ce0a04
--- title: Implementing a library for readable regular expressions in JavaScript shortTitle: Implementing a RegEx library language: javascript tags: [webdev,regexp,testing] cover: succulent-7 excerpt: Having set up our environment and designed the API, it's time to implement the RegExp library we've been planning, usin...
unknown
unknown
--- title: Implementing a library for readable regular expressions in JavaScript shortTitle: Implementing a RegEx library language: javascript tags: [webdev,regexp,testing] cover: succulent-7 excerpt: Having set up our environment and designed the API, it's time to implement the RegExp library we've been planning, usin...
--- title: Implementing a library for readable regular expressions in JavaScript shortTitle: Implementing a RegEx library language: javascript tags: [webdev,regexp,testing] cover: succulent-7 excerpt: Having set up our environment and designed the API, it's time to implement the RegExp library we've been planning, usin...
code_snippets
3bbb4f75-b2f3-44df-b50a-1e85ae8c8649
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
6
SemanticChunker@1.0.0
fc8c0b1d670b525a2574b4c692935dea085d5f6ac41dc23631ef236ddf437a9d
[Regular expression patterns > Reusable utilities] #### Reusable utilities After building a `toSegment` function, I realized I needed a way to **join segments**, too. I also seemed to need a way to map an array of patterns to segments. ```js title="spec/segment.test.js" import { describe, it, expect } from 'vitest';...
unknown
unknown
[Regular expression patterns > Reusable utilities] #### Reusable utilities After building a `toSegment` function, I realized I needed a way to **join segments**, too. I also seemed to need a way to map an array of patterns to segments. ```js title="spec/segment.test.js" import { describe, it, expect } from 'vitest';...
[Regular expression patterns > Reusable utilities] #### Reusable utilities After building a `toSegment` function, I realized I needed a way to **join segments**, too. I also seemed to need a way to map an array of patterns to segments. ```js title="spec/segment.test.js" import { describe, it, expect } from 'vitest';...
code_snippets
49937a85-a755-4def-858e-2b05ec31e319
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
19
SemanticChunker@1.0.0
983ac2ca9b08ed3fc1649d507f14584c15f7b2430df82aa5f3b9d869daf9cb76
[Exports > Building the code] ### Building the code We'll also add a `build` **script** to our `package.json` before we can bundle our code: ```json title="package.json" { "scripts": { "build": "vite build" } } ``` Then, we can finally run the `build` script: ```shell npm run build ``` This results in the fol...
unknown
unknown
[Exports > Building the code] ### Building the code We'll also add a `build` **script** to our `package.json` before we can bundle our code: ```json title="package.json" { "scripts": { "build": "vite build" } } ``` Then, we can finally run the `build` script: ```shell npm run build ``` This results in the fol...
[Exports > Building the code] ### Building the code We'll also add a `build` **script** to our `package.json` before we can bundle our code: ```json title="package.json" { "scripts": { "build": "vite build" } } ``` Then, we can finally run the `build` script: ```shell npm run build ``` This results in the fol...
code_snippets
49d5e96b-ad67-4347-8eed-c2e37254fa30
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
16
SemanticChunker@1.0.0
3c9f264afd8edf50cd777e87a5f2625802f93c7e2fe97bfc50bd27d96515257b
[API implementation > Lookarounds] After implementing the main function, I went ahead and updated all the test cases to replace the `toRegExp` function with `readEx`. This way, I could make sure that the final implementation worked as expected. I also wrote a bunch of [integration tests](https://github.com/Chalarangel...
unknown
unknown
[API implementation > Lookarounds] After implementing the main function, I went ahead and updated all the test cases to replace the `toRegExp` function with `readEx`. This way, I could make sure that the final implementation worked as expected. I also wrote a bunch of [integration tests](https://github.com/Chalarangel...
[API implementation > Lookarounds] After implementing the main function, I went ahead and updated all the test cases to replace the `toRegExp` function with `readEx`. This way, I could make sure that the final implementation worked as expected. I also wrote a bunch of [integration tests](https://github.com/Chalarangel...
code_snippets
6748af94-481b-4cb4-9e1d-400f6bc2d58f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
15
SemanticChunker@1.0.0
b09626ef811989ee0c75525bbd94bcbca3947acb7fd15d69368598a6c5996764
[API implementation > Lookarounds] To make this happen, I settled on a `toCharacterSet` utility function, which would handle the conversion of range patterns to `Segment` objects. From that point onward, it was just a matter of building the `anythingFrom` and `anythingBut` functions. ```js title="src/characterSet.js"...
unknown
unknown
[API implementation > Lookarounds] To make this happen, I settled on a `toCharacterSet` utility function, which would handle the conversion of range patterns to `Segment` objects. From that point onward, it was just a matter of building the `anythingFrom` and `anythingBut` functions. ```js title="src/characterSet.js"...
[API implementation > Lookarounds] To make this happen, I settled on a `toCharacterSet` utility function, which would handle the conversion of range patterns to `Segment` objects. From that point onward, it was just a matter of building the `anythingFrom` and `anythingBut` functions. ```js title="src/characterSet.js"...
code_snippets
8e4e0e73-5740-4f86-abb1-be34990b5b74
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
2
SemanticChunker@1.0.0
d1557ba5ff3ca0c6f3f2ba4bdd19e20388fe4783e7f4a43881c5c543dc3d3df2
[API design recap > API implementation] ## API implementation For the API implementation, I'll once again focus on the **decision-making** part of the process. The implementation is either trivial or too complex, depending on your skill level and experience. I'll try to explain the reasoning behind the decisions I ma...
unknown
unknown
[API design recap > API implementation] ## API implementation For the API implementation, I'll once again focus on the **decision-making** part of the process. The implementation is either trivial or too complex, depending on your skill level and experience. I'll try to explain the reasoning behind the decisions I ma...
[API design recap > API implementation] ## API implementation For the API implementation, I'll once again focus on the **decision-making** part of the process. The implementation is either trivial or too complex, depending on your skill level and experience. I'll try to explain the reasoning behind the decisions I ma...
code_snippets
9424771c-de12-4c33-86f4-72648902349d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
1
SemanticChunker@1.0.0
d86569467af2ac96f7939db5e71f323e63ed7d585d8d856eb2aaa234841e2f2f
[API design recap] ## API design recap Let's quickly recap the decisions we've made in terms of the project and the API so far. The project itself is a **simplified, readable and reusable API** on top of the regular expression <dfn title="A domain-specific language (DSL) is a computer language specialized to a partic...
unknown
unknown
[API design recap] ## API design recap Let's quickly recap the decisions we've made in terms of the project and the API so far. The project itself is a **simplified, readable and reusable API** on top of the regular expression <dfn title="A domain-specific language (DSL) is a computer language specialized to a partic...
[API design recap] ## API design recap Let's quickly recap the decisions we've made in terms of the project and the API so far. The project itself is a **simplified, readable and reusable API** on top of the regular expression <dfn title="A domain-specific language (DSL) is a computer language specialized to a partic...
code_snippets
9794128f-c0b9-4872-a29f-8eed64269343
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
12
SemanticChunker@1.0.0
a0bb04c5833361f2c2b3118078cbe6caab5d5faf6f0b52b08f36688339e8b48c
[API implementation > Lookarounds] ``` > [!NOTE] > > Tests are omitted here, for brevity, as they're not too different from the ones for groups. ### Quantifiers The meat of the implementation seemed to be quantifiers. After all, they're the most common building blocks. Tests were a blessing here, especially the one...
unknown
unknown
[API implementation > Lookarounds] ``` > [!NOTE] > > Tests are omitted here, for brevity, as they're not too different from the ones for groups. ### Quantifiers The meat of the implementation seemed to be quantifiers. After all, they're the most common building blocks. Tests were a blessing here, especially the one...
[API implementation > Lookarounds] ``` > [!NOTE] > > Tests are omitted here, for brevity, as they're not too different from the ones for groups. ### Quantifiers The meat of the implementation seemed to be quantifiers. After all, they're the most common building blocks. Tests were a blessing here, especially the one...
code_snippets
9ebc7073-1ba8-45f1-afe1-d415254e9069
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
11
SemanticChunker@1.0.0
5b39aafa0983899241a0a9eb5c0e13b18e78bc2c90bd5e0bdc2f3da4d404475a
[API implementation > Lookarounds] ### Lookarounds @[Quick refresher](/js/s/6-regexp-tricks#lookaheads) Lookaheads and lookbehinds followed a very similar pattern. I wrote some tests, implemented a reusable creation utility, and created the necessary building blocks. The only point of note here is the use of the `co...
unknown
unknown
[API implementation > Lookarounds] ### Lookarounds @[Quick refresher](/js/s/6-regexp-tricks#lookaheads) Lookaheads and lookbehinds followed a very similar pattern. I wrote some tests, implemented a reusable creation utility, and created the necessary building blocks. The only point of note here is the use of the `co...
[API implementation > Lookarounds] ### Lookarounds @[Quick refresher](/js/s/6-regexp-tricks#lookaheads) Lookaheads and lookbehinds followed a very similar pattern. I wrote some tests, implemented a reusable creation utility, and created the necessary building blocks. The only point of note here is the use of the `co...
code_snippets
a26df976-48a4-4846-92d3-0f8f24664689
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
10
SemanticChunker@1.0.0
40bb11b7137d30d123dd940c647475f3be9687ba1a382ba5cb24917e4340a0bf
[API implementation > Groups] ``` Apart from passing all tests, I wanted to make sure there's a **shared group creation utility**, which I'll call `toGroup`. This made sure that I didn't repeat myself too much. ```js title="src/group.js" import { Segment, toSegments, joinSegments } from './segment.js'; const toGrou...
unknown
unknown
[API implementation > Groups] ``` Apart from passing all tests, I wanted to make sure there's a **shared group creation utility**, which I'll call `toGroup`. This made sure that I didn't repeat myself too much. ```js title="src/group.js" import { Segment, toSegments, joinSegments } from './segment.js'; const toGrou...
[API implementation > Groups] ``` Apart from passing all tests, I wanted to make sure there's a **shared group creation utility**, which I'll call `toGroup`. This made sure that I didn't repeat myself too much. ```js title="src/group.js" import { Segment, toSegments, joinSegments } from './segment.js'; const toGrou...
code_snippets
ba4d4a1f-712f-4ab4-b4f4-0fb13b8b658e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
9
SemanticChunker@1.0.0
eed35222fbdaf959ae554493049ef04968b5dd137769cb3f0c4766b5d3d30c9f
[API implementation > Groups] ### Groups Groups are the next logical step, as they'll allow us to write more complex patterns (hint: we need the non-capturing group in several places). ```js title="spec/groups.test.js" import { describe, it, expect } from 'vitest'; import './matchers.js'; // Temporary test setup, u...
unknown
unknown
[API implementation > Groups] ### Groups Groups are the next logical step, as they'll allow us to write more complex patterns (hint: we need the non-capturing group in several places). ```js title="spec/groups.test.js" import { describe, it, expect } from 'vitest'; import './matchers.js'; // Temporary test setup, u...
[API implementation > Groups] ### Groups Groups are the next logical step, as they'll allow us to write more complex patterns (hint: we need the non-capturing group in several places). ```js title="spec/groups.test.js" import { describe, it, expect } from 'vitest'; import './matchers.js'; // Temporary test setup, u...
code_snippets
bb718c8d-abd4-450b-8a24-14aeccfa3cd8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
5
SemanticChunker@1.0.0
9105a647cff7f644cbc08ac65866c610c0460439a1f5046531decb89d6f67c57
[API implementation > Regular expression patterns] ``` > [!TIP] > > I've covered [escaping special characters in regulars expressions](/js/s/escape-reg-exp/) in the past. ```js title="src/segment.js" import { sanitize } from './sanitize.js'; //... export const toSegment = expression => { if (expression instanceof...
unknown
unknown
[API implementation > Regular expression patterns] ``` > [!TIP] > > I've covered [escaping special characters in regulars expressions](/js/s/escape-reg-exp/) in the past. ```js title="src/segment.js" import { sanitize } from './sanitize.js'; //... export const toSegment = expression => { if (expression instanceof...
[API implementation > Regular expression patterns] ``` > [!TIP] > > I've covered [escaping special characters in regulars expressions](/js/s/escape-reg-exp/) in the past. ```js title="src/segment.js" import { sanitize } from './sanitize.js'; //... export const toSegment = expression => { if (expression instanceof...
code_snippets
be2660a0-217e-4740-b5dc-042b57da7a5c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
14
SemanticChunker@1.0.0
e77711c2f2e13e1331ec64431b8940e1245ff2b1f954c60042041ab32ffbc722
[API implementation > Lookarounds] ``` ### Character sets Ranges and character sets are the last building blocks I wanted to implement. As these functions can accept **range patterns**, we need to make sure, these work as expected, hence a few more test cases to be sure. ```js title="spec/characterSets.test.js" imp...
unknown
unknown
[API implementation > Lookarounds] ``` ### Character sets Ranges and character sets are the last building blocks I wanted to implement. As these functions can accept **range patterns**, we need to make sure, these work as expected, hence a few more test cases to be sure. ```js title="spec/characterSets.test.js" imp...
[API implementation > Lookarounds] ``` ### Character sets Ranges and character sets are the last building blocks I wanted to implement. As these functions can accept **range patterns**, we need to make sure, these work as expected, hence a few more test cases to be sure. ```js title="spec/characterSets.test.js" imp...
code_snippets
d0797203-9690-4275-9a5e-31eb885dc45b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
8
SemanticChunker@1.0.0
3fd4066f7727515eb60db54b3d42a3f84468de65dac2d1ca2010c35f63b88fdf
[API implementation > Backreferences] ### Backreferences Let's also get backreferences out of the way, as they're another trivial piece of code to write, even if using them feels like a more advanced technique. ```js title="spec/backReference.test.js" import { describe, it, expect } from 'vitest'; // Temporary test...
unknown
unknown
[API implementation > Backreferences] ### Backreferences Let's also get backreferences out of the way, as they're another trivial piece of code to write, even if using them feels like a more advanced technique. ```js title="spec/backReference.test.js" import { describe, it, expect } from 'vitest'; // Temporary test...
[API implementation > Backreferences] ### Backreferences Let's also get backreferences out of the way, as they're another trivial piece of code to write, even if using them feels like a more advanced technique. ```js title="spec/backReference.test.js" import { describe, it, expect } from 'vitest'; // Temporary test...
code_snippets
e2a6d0b0-9258-4dff-b5d6-ed3c7fbafe23
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
17
SemanticChunker@1.0.0
5ae005d32bc967575fe32990dfca89d6b79b3d4016d0afe0ce7531003afc90eb
[API design recap > Exports] ## Exports Finally, I exported all the building blocks and the main function from the `index.js` file. This way, I could bundle everything up in a nice neat package. ```js title="src/index.js" export * from './readEx.js'; export * from './backReference.js'; export * from './group.js'; ex...
unknown
unknown
[API design recap > Exports] ## Exports Finally, I exported all the building blocks and the main function from the `index.js` file. This way, I could bundle everything up in a nice neat package. ```js title="src/index.js" export * from './readEx.js'; export * from './backReference.js'; export * from './group.js'; ex...
[API design recap > Exports] ## Exports Finally, I exported all the building blocks and the main function from the `index.js` file. This way, I could bundle everything up in a nice neat package. ```js title="src/index.js" export * from './readEx.js'; export * from './backReference.js'; export * from './group.js'; ex...
code_snippets
ea158c81-3f98-4e05-8105-32df2417d578
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
7
SemanticChunker@1.0.0
4fe2dc1dca475269e705ff70227e75ff1bfad7e6735268e3aab0dc12ec6fefe1
[Regular expression patterns > Reusable utilities] ``` This simple, albeit a little inelegant solution, fixed my tests and allowed me to move on to the next part of the implementation. With a `joinSegments` function in place, I could start building **reusable building blocks for patterns**. ## Reusable abstractions ...
unknown
unknown
[Regular expression patterns > Reusable utilities] ``` This simple, albeit a little inelegant solution, fixed my tests and allowed me to move on to the next part of the implementation. With a `joinSegments` function in place, I could start building **reusable building blocks for patterns**. ## Reusable abstractions ...
[Regular expression patterns > Reusable utilities] ``` This simple, albeit a little inelegant solution, fixed my tests and allowed me to move on to the next part of the implementation. With a `joinSegments` function in place, I could start building **reusable building blocks for patterns**. ## Reusable abstractions ...
code_snippets
ef3aa25a-fab6-4894-ae85-49553815cd68
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
4
SemanticChunker@1.0.0
49d91c6a0b88990a3f6b1bf532c7ceb56788a10d825111efae9273069dae1e7e
[API implementation > Regular expression patterns] it('should work with a string', () => { expect(new Segment('abc')).toMatch('abc'); }); it('should work with another segment', () => { expect(new Segment(new Segment('abc'))).toMatch('abc'); }); }); ``` #### Sanitization & conversion One core thing I had to de...
unknown
unknown
[API implementation > Regular expression patterns] it('should work with a string', () => { expect(new Segment('abc')).toMatch('abc'); }); it('should work with another segment', () => { expect(new Segment(new Segment('abc'))).toMatch('abc'); }); }); ``` #### Sanitization & conversion One core thing I had to de...
[API implementation > Regular expression patterns] it('should work with a string', () => { expect(new Segment('abc')).toMatch('abc'); }); it('should work with another segment', () => { expect(new Segment(new Segment('abc'))).toMatch('abc'); }); }); ``` #### Sanitization & conversion One core thing I had to de...
code_snippets
f26d5bdd-a54d-4045-8fc3-e567b0ba1a1c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
18
SemanticChunker@1.0.0
1c7943fbe945c8422e4f6ac363d1b6f37113df3dba962e9f57c56594c7f14ca9
[API design recap > Exports] I've based this configuration off of [Vite's library mode](https://vite.dev/guide/build.html#library-mode) documentation. The `lib` object specifies the entry point, the library name, the output file name, and the format. We're using ES modules for compatibility with modern browsers and No...
unknown
unknown
[API design recap > Exports] I've based this configuration off of [Vite's library mode](https://vite.dev/guide/build.html#library-mode) documentation. The `lib` object specifies the entry point, the library name, the output file name, and the format. We're using ES modules for compatibility with modern browsers and No...
[API design recap > Exports] I've based this configuration off of [Vite's library mode](https://vite.dev/guide/build.html#library-mode) documentation. The `lib` object specifies the entry point, the library name, the output file name, and the format. We're using ES modules for compatibility with modern browsers and No...
code_snippets
f8401e6d-9f2a-4eb9-8317-bc69eeed0133
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tdd-library-implementation-with-vite-vitest.md
unknown
c06e374a-e736-4004-b016-cc7814c1e44e
13
SemanticChunker@1.0.0
f7d6a641670c896927177770bf1021e84820ebdcce913016c960fba88b601fb1
[API implementation > Lookarounds] ```js title="src/quantifiers.js" import { Segment, toSegments } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = (expressions, { suffix, lazy } = {}) => { const expression = nonCaptureGroup(...toSegments(...expressions)).source; return new Se...
unknown
unknown
[API implementation > Lookarounds] ```js title="src/quantifiers.js" import { Segment, toSegments } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = (expressions, { suffix, lazy } = {}) => { const expression = nonCaptureGroup(...toSegments(...expressions)).source; return new Se...
[API implementation > Lookarounds] ```js title="src/quantifiers.js" import { Segment, toSegments } from './segment.js'; import { nonCaptureGroup } from './group.js'; const toQuantifier = (expressions, { suffix, lazy } = {}) => { const expression = nonCaptureGroup(...toSegments(...expressions)).source; return new Se...
code_snippets
150dad45-beca-4370-a560-b018732ba831
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/to-roman-numeral.md
unknown
1df15a14-74e2-4a8e-b465-2301dc0e56da
0
SemanticChunker@1.0.0
daba569e0fa19e2b8369d7c60e978b12e1d1d05c9a96e876c1528d1ffb7429c2
--- title: Convert an integer to a roman numeral in JavaScript shortTitle: Integer to roman numeral language: javascript tags: [number] cover: ancient-greek-building excerpt: Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky. listed: true dateModified:...
unknown
unknown
--- title: Convert an integer to a roman numeral in JavaScript shortTitle: Integer to roman numeral language: javascript tags: [number] cover: ancient-greek-building excerpt: Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky. listed: true dateModified:...
--- title: Convert an integer to a roman numeral in JavaScript shortTitle: Integer to roman numeral language: javascript tags: [number] cover: ancient-greek-building excerpt: Roman numerals are often used for stylistic reasons, but converting an integer to a roman numeral can be a bit tricky. listed: true dateModified:...
code_snippets
0a510a5d-448e-48f4-8f2d-66cfd7200a96
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
5
SemanticChunker@1.0.0
6a57a8c9a73af40f15315ec2e7460ca1811a17d7f65b454377901f75727ea637
[Map object keys > Transform object keys using a function] ## Transform object keys using a function Subsequently, you might want to completely transform the keys of an object using a function. In that case, you can apply a function against an **accumulator** and each key in the object (from left to right) using `Obj...
unknown
unknown
[Map object keys > Transform object keys using a function] ## Transform object keys using a function Subsequently, you might want to completely transform the keys of an object using a function. In that case, you can apply a function against an **accumulator** and each key in the object (from left to right) using `Obj...
[Map object keys > Transform object keys using a function] ## Transform object keys using a function Subsequently, you might want to completely transform the keys of an object using a function. In that case, you can apply a function against an **accumulator** and each key in the object (from left to right) using `Obj...
code_snippets
4c32ea5b-2bec-488e-995b-a7417b4b109f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
2
SemanticChunker@1.0.0
e7c81ccdb9c4a6a39dfc11a45ef8b42d3f0d2581fed755457cd800a007976642
[Map object keys > Deep map object keys] ### Deep map object keys The previous snippet only works for the keys at the **first level** of the object. In order to transform nested keys, you'll have to use **recursion**. Again, using `Object.keys()` to iterate over the object's keys, you can use `Array.prototype.reduce...
unknown
unknown
[Map object keys > Deep map object keys] ### Deep map object keys The previous snippet only works for the keys at the **first level** of the object. In order to transform nested keys, you'll have to use **recursion**. Again, using `Object.keys()` to iterate over the object's keys, you can use `Array.prototype.reduce...
[Map object keys > Deep map object keys] ### Deep map object keys The previous snippet only works for the keys at the **first level** of the object. In order to transform nested keys, you'll have to use **recursion**. Again, using `Object.keys()` to iterate over the object's keys, you can use `Array.prototype.reduce...
code_snippets
6a68c9ce-e321-4707-aaa4-5f985f4cc3f3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
1
SemanticChunker@1.0.0
b00a4bed2256a7fe5b51ca70634e41f3707b25e59563d5556edd2b57f266eb2f
[Map object keys] ## Map object keys Given an object and a function, you can generate a new object by mapping the keys of the original object using the provided function. In order to do so, you can use `Object.keys()` to iterate over the object's keys and `Array.prototype.reduce()` to create a new object with the sa...
unknown
unknown
[Map object keys] ## Map object keys Given an object and a function, you can generate a new object by mapping the keys of the original object using the provided function. In order to do so, you can use `Object.keys()` to iterate over the object's keys and `Array.prototype.reduce()` to create a new object with the sa...
[Map object keys] ## Map object keys Given an object and a function, you can generate a new object by mapping the keys of the original object using the provided function. In order to do so, you can use `Object.keys()` to iterate over the object's keys and `Array.prototype.reduce()` to create a new object with the sa...
code_snippets
83c5d158-3d44-4786-9efb-0a59de3e83ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
3
SemanticChunker@1.0.0
28890384c94cb80ada828d7a5057f765b546ae4494585c46fd016c139bfe24a7
[Map object keys > Rename object keys] ## Rename object keys one of the simplest transformations is **renaming the keys** of an object. You can use `Object.keys()` in combination with `Array.prototype.reduce()` and the spread operator (`...`) to get the object's keys and rename them according to a given **dictionary*...
unknown
unknown
[Map object keys > Rename object keys] ## Rename object keys one of the simplest transformations is **renaming the keys** of an object. You can use `Object.keys()` in combination with `Array.prototype.reduce()` and the spread operator (`...`) to get the object's keys and rename them according to a given **dictionary*...
[Map object keys > Rename object keys] ## Rename object keys one of the simplest transformations is **renaming the keys** of an object. You can use `Object.keys()` in combination with `Array.prototype.reduce()` and the spread operator (`...`) to get the object's keys and rename them according to a given **dictionary*...
code_snippets
f64c58ef-d2a9-407e-908f-dd46b4d0b81a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
4
SemanticChunker@1.0.0
bda7337de8a5ef29938da4494413433bc2d0da460f667148c8a534c409403030
[Map object keys > Symbolize object keys] ## Symbolize object keys **Symbols** are often underused in JavaScript, but they can be very useful for creating unique keys. In order to symbolize the keys of an object, you can use `Object.keys()` to get the keys of the object and `Array.prototype.reduce()` to create a new ...
unknown
unknown
[Map object keys > Symbolize object keys] ## Symbolize object keys **Symbols** are often underused in JavaScript, but they can be very useful for creating unique keys. In order to symbolize the keys of an object, you can use `Object.keys()` to get the keys of the object and `Array.prototype.reduce()` to create a new ...
[Map object keys > Symbolize object keys] ## Symbolize object keys **Symbols** are often underused in JavaScript, but they can be very useful for creating unique keys. In order to symbolize the keys of an object, you can use `Object.keys()` to get the keys of the object and `Array.prototype.reduce()` to create a new ...
code_snippets
ff8d53d5-7ed4-4f3c-b9e6-6e8e919e369c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/transform-object-keys.md
unknown
be79d1a8-673c-488e-9e99-ce9673953104
0
SemanticChunker@1.0.0
4a17eb664fa2970b1f8229c5ca7aee34565c5b0b68839393ce2bffbdde5dc101
--- title: Transform the keys of a JavaScript object shortTitle: Transform object keys language: javascript tags: [object, recursion] cover: symmetry-cloudy-mountain excerpt: Learn how to perform various transformations on the keys of a JavaScript object. listed: true dateModified: 2024-02-19 --- JavaScript objects ar...
unknown
unknown
--- title: Transform the keys of a JavaScript object shortTitle: Transform object keys language: javascript tags: [object, recursion] cover: symmetry-cloudy-mountain excerpt: Learn how to perform various transformations on the keys of a JavaScript object. listed: true dateModified: 2024-02-19 --- JavaScript objects ar...
--- title: Transform the keys of a JavaScript object shortTitle: Transform object keys language: javascript tags: [object, recursion] cover: symmetry-cloudy-mountain excerpt: Learn how to perform various transformations on the keys of a JavaScript object. listed: true dateModified: 2024-02-19 --- JavaScript objects ar...
code_snippets
19ba3c60-5892-4360-874d-cad6c82b3a43
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/toggle-array-element.md
unknown
c9ad08ec-64c3-42dd-9ad7-24c36e6c0ba3
2
SemanticChunker@1.0.0
1da0fa9ee76c31a42d78741d3fd9e24f3546b37e37aed2c561956a52853cd550
[Remove or append an element in an array of primitives > Remove or append an element in an array of objects] ## Remove or append an element in an array of objects When working with arrays of objects, you can use a similar approach. However, you'll need to provide a **comparison function** to determine if the object a...
unknown
unknown
[Remove or append an element in an array of primitives > Remove or append an element in an array of objects] ## Remove or append an element in an array of objects When working with arrays of objects, you can use a similar approach. However, you'll need to provide a **comparison function** to determine if the object a...
[Remove or append an element in an array of primitives > Remove or append an element in an array of objects] ## Remove or append an element in an array of objects When working with arrays of objects, you can use a similar approach. However, you'll need to provide a **comparison function** to determine if the object a...
code_snippets
a22dac43-a023-4f1d-a427-f08f9564240b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/toggle-array-element.md
unknown
c9ad08ec-64c3-42dd-9ad7-24c36e6c0ba3
0
SemanticChunker@1.0.0
0d1acb9487333d7819d1adfed5554cc00d0f4f54a7316095ae53fe78c82f3ef0
--- title: Toggle element in a JavaScript array shortTitle: Toggle array element language: javascript tags: [array] cover: digital-nomad-7 excerpt: Remove an element from an array if it's included in the array, or push it to the array if it isn't. listed: true dateModified: 2024-03-23 --- I've often found myself needi...
unknown
unknown
--- title: Toggle element in a JavaScript array shortTitle: Toggle array element language: javascript tags: [array] cover: digital-nomad-7 excerpt: Remove an element from an array if it's included in the array, or push it to the array if it isn't. listed: true dateModified: 2024-03-23 --- I've often found myself needi...
--- title: Toggle element in a JavaScript array shortTitle: Toggle array element language: javascript tags: [array] cover: digital-nomad-7 excerpt: Remove an element from an array if it's included in the array, or push it to the array if it isn't. listed: true dateModified: 2024-03-23 --- I've often found myself needi...
code_snippets
ffed55bb-8332-4226-87d8-b9c70247570b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/toggle-array-element.md
unknown
c9ad08ec-64c3-42dd-9ad7-24c36e6c0ba3
1
SemanticChunker@1.0.0
549c84d79114eeca467016ba38a58d56e6878c0fb7378789a772e0aad7cebe51
[Remove or append an element in an array of primitives] ## Remove or append an element in an array of primitives Using `Array.prototype.includes()`, you can **check if the element is already in the array**. If it is, you can use `Array.prototype.filter()` to **remove** it. If it's not, you can use the spread operator...
unknown
unknown
[Remove or append an element in an array of primitives] ## Remove or append an element in an array of primitives Using `Array.prototype.includes()`, you can **check if the element is already in the array**. If it is, you can use `Array.prototype.filter()` to **remove** it. If it's not, you can use the spread operator...
[Remove or append an element in an array of primitives] ## Remove or append an element in an array of primitives Using `Array.prototype.includes()`, you can **check if the element is already in the array**. If it is, you can use `Array.prototype.filter()` to **remove** it. If it's not, you can use the spread operator...
code_snippets
0fd7f035-ce2d-4308-bc3f-1ebfe313e996
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/timeout-interval-delay.md
unknown
8689d379-082a-4b45-87fe-c6db85e7f07c
0
SemanticChunker@1.0.0
70d02beb50f811b3b9eebe8f9b7c89f725f185cfc9bcc499d6f1af76f42ceed6
--- title: How delays work in JavaScript timing functions shortTitle: Delays in JavaScript timing functions language: javascript tags: [browser,timeout] cover: river-house-lights excerpt: Did you know that the delay of `setTimeout()` and `setInterval()` is merely a suggestion? listed: true dateModified: 2022-10-26 --- ...
unknown
unknown
--- title: How delays work in JavaScript timing functions shortTitle: Delays in JavaScript timing functions language: javascript tags: [browser,timeout] cover: river-house-lights excerpt: Did you know that the delay of `setTimeout()` and `setInterval()` is merely a suggestion? listed: true dateModified: 2022-10-26 --- ...
--- title: How delays work in JavaScript timing functions shortTitle: Delays in JavaScript timing functions language: javascript tags: [browser,timeout] cover: river-house-lights excerpt: Did you know that the delay of `setTimeout()` and `setInterval()` is merely a suggestion? listed: true dateModified: 2022-10-26 --- ...
code_snippets
3d5f34b2-321e-4876-897c-b65b5ef06afd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/timeout-interval-delay.md
unknown
8689d379-082a-4b45-87fe-c6db85e7f07c
2
SemanticChunker@1.0.0
8457f6edfec0ee8ff7d897e96b4fbcc30cdc4e25e3d2a6158a1b76cb713589ca
[Delays are not exact > Browser factors] ## Browser factors Apart from engine-related delays, there are a few other factors that play a role in the actual delay of a task. Briefly, these are: - Browsers **throttle nested timeouts and intervals** with a delay of at least 4ms, but this can vary depending on the browse...
unknown
unknown
[Delays are not exact > Browser factors] ## Browser factors Apart from engine-related delays, there are a few other factors that play a role in the actual delay of a task. Briefly, these are: - Browsers **throttle nested timeouts and intervals** with a delay of at least 4ms, but this can vary depending on the browse...
[Delays are not exact > Browser factors] ## Browser factors Apart from engine-related delays, there are a few other factors that play a role in the actual delay of a task. Briefly, these are: - Browsers **throttle nested timeouts and intervals** with a delay of at least 4ms, but this can vary depending on the browse...
code_snippets
e767bf52-57ff-40bf-a124-3305be0d58b6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/timeout-interval-delay.md
unknown
8689d379-082a-4b45-87fe-c6db85e7f07c
1
SemanticChunker@1.0.0
4c9ee6cc4417a3fb41c1e85729096e5d5c3f20f028c953cd2874448051c500a2
[Delays are not exact] ## Delays are not exact I went into detail about how JavaScript engines execute code in [the Event Loop explanation](/js/s/event-loop-explained), but let me recap here. As JavaScript is single-threaded, tasks are queued to be executed in a loop. Thus, `setTimeout()` and `setInterval()` are task...
unknown
unknown
[Delays are not exact] ## Delays are not exact I went into detail about how JavaScript engines execute code in [the Event Loop explanation](/js/s/event-loop-explained), but let me recap here. As JavaScript is single-threaded, tasks are queued to be executed in a loop. Thus, `setTimeout()` and `setInterval()` are task...
[Delays are not exact] ## Delays are not exact I went into detail about how JavaScript engines execute code in [the Event Loop explanation](/js/s/event-loop-explained), but let me recap here. As JavaScript is single-threaded, tasks are queued to be executed in a loop. Thus, `setTimeout()` and `setInterval()` are task...
code_snippets
441b3bab-ebd7-4dc3-8fdd-10875d5e6772
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/throttle-function.md
unknown
42f31c3e-a794-4650-8252-a9c9504cb5d1
0
SemanticChunker@1.0.0
a9954fd58ae49bce24af5e6ddb090bef57c2f441b1d3810f1e8fc3534f4755c0
--- title: Throttle a JavaScript function shortTitle: Throttle function language: javascript tags: [function] cover: beach-overview excerpt: Create a throttled function that only invokes the provided function at most once per the specified interval. listed: true dateModified: 2024-07-23 --- **Throttling** is a techniq...
unknown
unknown
--- title: Throttle a JavaScript function shortTitle: Throttle function language: javascript tags: [function] cover: beach-overview excerpt: Create a throttled function that only invokes the provided function at most once per the specified interval. listed: true dateModified: 2024-07-23 --- **Throttling** is a techniq...
--- title: Throttle a JavaScript function shortTitle: Throttle function language: javascript tags: [function] cover: beach-overview excerpt: Create a throttled function that only invokes the provided function at most once per the specified interval. listed: true dateModified: 2024-07-23 --- **Throttling** is a techniq...
code_snippets
70b59f5c-e5ae-49f0-a112-3f60652485b3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/throttle-function.md
unknown
42f31c3e-a794-4650-8252-a9c9504cb5d1
1
SemanticChunker@1.0.0
56091001b1dacd1f17fa606da7d78691bfdde6b0d0b35c798c8159cb9cf00ba1
```js const throttle = (fn, wait) => { let inThrottle, lastFn, lastTime; return function() { const context = this, args = arguments; if (!inThrottle) { fn.apply(context, args); lastTime = Date.now(); inThrottle = true; } else { clearTimeout(lastFn); lastFn = setTimeout(function() { if (Date.now() - lastTim...
unknown
unknown
```js const throttle = (fn, wait) => { let inThrottle, lastFn, lastTime; return function() { const context = this, args = arguments; if (!inThrottle) { fn.apply(context, args); lastTime = Date.now(); inThrottle = true; } else { clearTimeout(lastFn); lastFn = setTimeout(function() { if (Date.now() - lastTim...
```js const throttle = (fn, wait) => { let inThrottle, lastFn, lastTime; return function() { const context = this, args = arguments; if (!inThrottle) { fn.apply(context, args); lastTime = Date.now(); inThrottle = true; } else { clearTimeout(lastFn); lastFn = setTimeout(function() { if (Date.now() - lastTim...
code_snippets
17a2dcc8-05ee-4471-9096-fb1585f7481f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/the-case-for-trailing-commas.md
unknown
1be0c201-2d9b-4b9d-b83c-49010879d7b2
0
SemanticChunker@1.0.0
3165461c28c0aaf4717d0ab24106620bc30bef0248ba10f12d1cf09dbdd52310
--- title: The case for trailing commas in JavaScript shortTitle: Trailing commas in JavaScript language: javascript tags: [webdev] cover: contemporary-desk excerpt: Trailing commas are not without controversy. Here's why I think you should use them. listed: true dateModified: 2023-03-12 --- JavaScript's syntactic fea...
unknown
unknown
--- title: The case for trailing commas in JavaScript shortTitle: Trailing commas in JavaScript language: javascript tags: [webdev] cover: contemporary-desk excerpt: Trailing commas are not without controversy. Here's why I think you should use them. listed: true dateModified: 2023-03-12 --- JavaScript's syntactic fea...
--- title: The case for trailing commas in JavaScript shortTitle: Trailing commas in JavaScript language: javascript tags: [webdev] cover: contemporary-desk excerpt: Trailing commas are not without controversy. Here's why I think you should use them. listed: true dateModified: 2023-03-12 --- JavaScript's syntactic fea...
code_snippets
c0ff7778-5465-4d8a-9dd8-0602ad772170
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/the-case-for-trailing-commas.md
unknown
1be0c201-2d9b-4b9d-b83c-49010879d7b2
1
SemanticChunker@1.0.0
b41b207614ef74f1fb0240fb429bc68d06f874d12b4eac0ed67236bc497fd63c
None of these scenarios are uncommon, as you are well aware. Even more so, these start becoming a little more annoying when you factor in **version control**. A single property addition will require two lines to be altered. This can make diffs harder to read and review, and can also cause merge conflicts more often tha...
unknown
unknown
None of these scenarios are uncommon, as you are well aware. Even more so, these start becoming a little more annoying when you factor in **version control**. A single property addition will require two lines to be altered. This can make diffs harder to read and review, and can also cause merge conflicts more often tha...
None of these scenarios are uncommon, as you are well aware. Even more so, these start becoming a little more annoying when you factor in **version control**. A single property addition will require two lines to be altered. This can make diffs harder to read and review, and can also cause merge conflicts more often tha...
code_snippets
12b73fa8-0121-4b7d-b267-b31a8200502c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
2
SemanticChunker@1.0.0
72ecd3ac3551514dc9b9da1e7af919e60125247d94e6c3a5f1704b4d5940bd36
[Tokenization > Stopword removal] ## Stopword removal **Stopwords** are common words that are often filtered out before or after processing of natural language data. These words are usually not relevant for search tasks and can be safely removed. Lists of stopwords are readily available online, but for simplicity, we...
unknown
unknown
[Tokenization > Stopword removal] ## Stopword removal **Stopwords** are common words that are often filtered out before or after processing of natural language data. These words are usually not relevant for search tasks and can be safely removed. Lists of stopwords are readily available online, but for simplicity, we...
[Tokenization > Stopword removal] ## Stopword removal **Stopwords** are common words that are often filtered out before or after processing of natural language data. These words are usually not relevant for search tasks and can be safely removed. Lists of stopwords are readily available online, but for simplicity, we...
code_snippets
51952c24-e24e-4cf6-bbee-9df2af3860ad
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
8
SemanticChunker@1.0.0
f0221ff2980cf66e9fcf44eed7bb23215562991e7c144e6dc5e1f2d0b0e57bad
[Tokenization > Conclusion] ## Conclusion That's all for the time being. We've stitched together all the pieces of a simple, yet powerful and performant search algorithm. It's definitely not as powerful as a full-fledged search engine, but it's a good starting point for understanding how search works under the hood a...
unknown
unknown
[Tokenization > Conclusion] ## Conclusion That's all for the time being. We've stitched together all the pieces of a simple, yet powerful and performant search algorithm. It's definitely not as powerful as a full-fledged search engine, but it's a good starting point for understanding how search works under the hood a...
[Tokenization > Conclusion] ## Conclusion That's all for the time being. We've stitched together all the pieces of a simple, yet powerful and performant search algorithm. It's definitely not as powerful as a full-fledged search engine, but it's a good starting point for understanding how search works under the hood a...
code_snippets
8dce3791-4eb9-4b32-bbad-7f48a85ae7df
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
5
SemanticChunker@1.0.0
4968b275ff497c3cb77c89a540860e25e2c52086874e006cd70f189f190389bc
[Tokenization > TF-IDF] ```js const documents = []; const vocabulary = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { vocabulary.set(term, (vocabulary.get(term) || 0) + 1); }); }; const calculateTF = (term, documentIndex) => { ...
unknown
unknown
[Tokenization > TF-IDF] ```js const documents = []; const vocabulary = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { vocabulary.set(term, (vocabulary.get(term) || 0) + 1); }); }; const calculateTF = (term, documentIndex) => { ...
[Tokenization > TF-IDF] ```js const documents = []; const vocabulary = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { vocabulary.set(term, (vocabulary.get(term) || 0) + 1); }); }; const calculateTF = (term, documentIndex) => { ...
code_snippets
9a88c182-5fc6-45d4-82f8-45f2fa5cf354
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
1
SemanticChunker@1.0.0
78a462bdc6f9bc059ea478c12cd9a85dff75664d0ed0964fa76d98564b45b662
[Tokenization] ## Tokenization Before we begin, let's establish a simple **tokenization** strategy. As we're only concerned with plaintext documents, we can use a **regular expression** to split the text into words. ```js const tokenize = str => str .split(/[^a-z0-9\-']+/i) .filter(tkn => !tkn.length < 2) .map(t...
unknown
unknown
[Tokenization] ## Tokenization Before we begin, let's establish a simple **tokenization** strategy. As we're only concerned with plaintext documents, we can use a **regular expression** to split the text into words. ```js const tokenize = str => str .split(/[^a-z0-9\-']+/i) .filter(tkn => !tkn.length < 2) .map(t...
[Tokenization] ## Tokenization Before we begin, let's establish a simple **tokenization** strategy. As we're only concerned with plaintext documents, we can use a **regular expression** to split the text into words. ```js const tokenize = str => str .split(/[^a-z0-9\-']+/i) .filter(tkn => !tkn.length < 2) .map(t...
code_snippets
ad5611dc-50ba-4fd6-9e76-7b43b421a7fd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
0
SemanticChunker@1.0.0
91dbad080e5cbe95d6286d0dddcc2ea6a5bf6182247e0c0553efc97d62b1d851
--- title: Implementing search in JavaScript, using TF-IDF and an inverted index shortTitle: TF-IDF and inverted index search language: javascript tags: [algorithm,string,regexp] cover: typewriter excerpt: Building on top of the Porter stemmer, we'll explore how to use TF-IDF and an inverted index to implement a search...
unknown
unknown
--- title: Implementing search in JavaScript, using TF-IDF and an inverted index shortTitle: TF-IDF and inverted index search language: javascript tags: [algorithm,string,regexp] cover: typewriter excerpt: Building on top of the Porter stemmer, we'll explore how to use TF-IDF and an inverted index to implement a search...
--- title: Implementing search in JavaScript, using TF-IDF and an inverted index shortTitle: TF-IDF and inverted index search language: javascript tags: [algorithm,string,regexp] cover: typewriter excerpt: Building on top of the Porter stemmer, we'll explore how to use TF-IDF and an inverted index to implement a search...
code_snippets
b584c487-fd1d-4014-9ac4-eef19eb4ca86
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
4
SemanticChunker@1.0.0
84390cd29d923a690e57919133b59733b786e4091bc84fd65826bc628723fa9a
[Tokenization > TF-IDF] ## TF-IDF TF-IDF refers to the **term frequency-inverse document frequency**. It is a measurement that is intended to reflect **how important a word is to a document in a collection or corpus**. The TF-IDF value increases **proportionally** to the number of times a word appears in the document...
unknown
unknown
[Tokenization > TF-IDF] ## TF-IDF TF-IDF refers to the **term frequency-inverse document frequency**. It is a measurement that is intended to reflect **how important a word is to a document in a collection or corpus**. The TF-IDF value increases **proportionally** to the number of times a word appears in the document...
[Tokenization > TF-IDF] ## TF-IDF TF-IDF refers to the **term frequency-inverse document frequency**. It is a measurement that is intended to reflect **how important a word is to a document in a collection or corpus**. The TF-IDF value increases **proportionally** to the number of times a word appears in the document...
code_snippets
de351258-05b3-426e-acc9-dc8a3a1f2502
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
7
SemanticChunker@1.0.0
4d84a969838bcea746e2c00e9b9a6dd0e472850565dd4efecf6e8a417b90ea41
[Tokenization > Inverted index] ```js const documents = []; const invertedIndex = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { if (!invertedIndex.has(term)) invertedIndex.set(term, new Map()); const docMap = invertedIndex.get...
unknown
unknown
[Tokenization > Inverted index] ```js const documents = []; const invertedIndex = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { if (!invertedIndex.has(term)) invertedIndex.set(term, new Map()); const docMap = invertedIndex.get...
[Tokenization > Inverted index] ```js const documents = []; const invertedIndex = new Map(); const addDocument = document => { const terms = parseDocument(document); documents.push(terms); terms.forEach(term => { if (!invertedIndex.has(term)) invertedIndex.set(term, new Map()); const docMap = invertedIndex.get...
code_snippets
e6c0b838-0c96-4361-b4f7-2ddad189922d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
3
SemanticChunker@1.0.0
290a7328d73705949e07d4498e17104e3e2c029501f3aa47db856d2e962dfec8
[Tokenization > Arbitrary search] ## Arbitrary search Having a basic understanding of these steps, we can use the Porter stemmer to stem the words and perform a search. We'll use the Porter stemmer from the previous article and search for the word 'jump'. ```js // Assuming the `porterStemmer` function is available i...
unknown
unknown
[Tokenization > Arbitrary search] ## Arbitrary search Having a basic understanding of these steps, we can use the Porter stemmer to stem the words and perform a search. We'll use the Porter stemmer from the previous article and search for the word 'jump'. ```js // Assuming the `porterStemmer` function is available i...
[Tokenization > Arbitrary search] ## Arbitrary search Having a basic understanding of these steps, we can use the Porter stemmer to stem the words and perform a search. We'll use the Porter stemmer from the previous article and search for the word 'jump'. ```js // Assuming the `porterStemmer` function is available i...
code_snippets
f2fa3e9e-a69b-4b29-a3d6-6683f7be18c7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/tf-idf-inverted-index.md
unknown
82eb0946-bdf4-4fba-8c87-ea2ab420170f
6
SemanticChunker@1.0.0
b94100cb1fbe606766ab18c8effb94273c90ea2a1fedeca680790457fbd9eefa
[Tokenization > Inverted index] ## Inverted index The TF-IDF implementation is already a significant improvement over the previous search method. However, it can still be slow for large collections of documents. To speed up the search process, we can use an **inverted index**. An inverted index is a data structure t...
unknown
unknown
[Tokenization > Inverted index] ## Inverted index The TF-IDF implementation is already a significant improvement over the previous search method. However, it can still be slow for large collections of documents. To speed up the search process, we can use an **inverted index**. An inverted index is a data structure t...
[Tokenization > Inverted index] ## Inverted index The TF-IDF implementation is already a significant improvement over the previous search method. However, it can still be slow for large collections of documents. To speed up the search process, we can use an **inverted index**. An inverted index is a data structure t...
code_snippets
6da4ac9d-5f03-4059-b698-8379ffe4a832
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
0
SemanticChunker@1.0.0
15ccc372fd93a06aa8770c814fa595b51ec42626d27560f3a9ff5aea2463b18b
--- title: How are HTMLElement.innerText and Node.textContent different? shortTitle: Differences between innerText and textContent language: javascript tags: [browser] cover: dark-city excerpt: While these two properties are very similar, there are some key differences that you should be aware of. listed: true dateModi...
unknown
unknown
--- title: How are HTMLElement.innerText and Node.textContent different? shortTitle: Differences between innerText and textContent language: javascript tags: [browser] cover: dark-city excerpt: While these two properties are very similar, there are some key differences that you should be aware of. listed: true dateModi...
--- title: How are HTMLElement.innerText and Node.textContent different? shortTitle: Differences between innerText and textContent language: javascript tags: [browser] cover: dark-city excerpt: While these two properties are very similar, there are some key differences that you should be aware of. listed: true dateModi...
code_snippets
85ad006c-62c7-4664-a4ac-77c8d156f70f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
1
SemanticChunker@1.0.0
05aa6ac59c3b4729013c7f10ae73cce99ef2e1625ac9d80a8bd374629a0b60d9
[Similarities] ## Similarities I think it's helpful to identify the similarities of these two properties before diving into the differences. This will also clarify how they're used in most cases. Suppose you have an HTML element, containing some text: ```html <p id="greeting">Hi there! My name is <strong>Bubbles</s...
unknown
unknown
[Similarities] ## Similarities I think it's helpful to identify the similarities of these two properties before diving into the differences. This will also clarify how they're used in most cases. Suppose you have an HTML element, containing some text: ```html <p id="greeting">Hi there! My name is <strong>Bubbles</s...
[Similarities] ## Similarities I think it's helpful to identify the similarities of these two properties before diving into the differences. This will also clarify how they're used in most cases. Suppose you have an HTML element, containing some text: ```html <p id="greeting">Hi there! My name is <strong>Bubbles</s...
code_snippets
8a2c6a88-4cb9-4729-b0f7-3b792e9289de
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
5
SemanticChunker@1.0.0
b38662539336ba57b62c1b3658572ee502b7b97664107a08675ef8b00d7d160c
[Similarities > Conclusion] ## Conclusion `HTMLElement.innerText` and `Node.textContent` are two very similar properties that can be used to access and manipulate the text content of an element. However, they differ in some important ways, and you should be aware of these differences to choose the one that best suits...
unknown
unknown
[Similarities > Conclusion] ## Conclusion `HTMLElement.innerText` and `Node.textContent` are two very similar properties that can be used to access and manipulate the text content of an element. However, they differ in some important ways, and you should be aware of these differences to choose the one that best suits...
[Similarities > Conclusion] ## Conclusion `HTMLElement.innerText` and `Node.textContent` are two very similar properties that can be used to access and manipulate the text content of an element. However, they differ in some important ways, and you should be aware of these differences to choose the one that best suits...
code_snippets
9386bdec-0e7a-4ab2-9253-8fd35856bf13
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
3
SemanticChunker@1.0.0
47c74c82773cb5bfce0e5e8b6aeea011620202e332c6a945cffc7f7b17619967
[Similarities > Differences] The final point I want to make is that `HTMLElement.innerText` applies **text transformations** to the element's content. In this case, the `<strong>` element is transformed to uppercase, so the output of `HTMLElement.innerText` reflects this. On the other hand, `Node.textContent` returns...
unknown
unknown
[Similarities > Differences] The final point I want to make is that `HTMLElement.innerText` applies **text transformations** to the element's content. In this case, the `<strong>` element is transformed to uppercase, so the output of `HTMLElement.innerText` reflects this. On the other hand, `Node.textContent` returns...
[Similarities > Differences] The final point I want to make is that `HTMLElement.innerText` applies **text transformations** to the element's content. In this case, the `<strong>` element is transformed to uppercase, so the output of `HTMLElement.innerText` reflects this. On the other hand, `Node.textContent` returns...
code_snippets
981705bb-77e4-4813-8300-c7a15fcaf760
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
2
SemanticChunker@1.0.0
e1dfd3d2823861cb2b849235dfa030c80cf6446f5205fffed4cac7374c5bc861
[Similarities > Differences] ## Differences So far, these two properties appear to do the exact same thing. In fact, they both offer some convenient features that make them very useful. However, they start to exhibit some differences when the element's content is a little more complex. Take the following HTML elemen...
unknown
unknown
[Similarities > Differences] ## Differences So far, these two properties appear to do the exact same thing. In fact, they both offer some convenient features that make them very useful. However, they start to exhibit some differences when the element's content is a little more complex. Take the following HTML elemen...
[Similarities > Differences] ## Differences So far, these two properties appear to do the exact same thing. In fact, they both offer some convenient features that make them very useful. However, they start to exhibit some differences when the element's content is a little more complex. Take the following HTML elemen...
code_snippets
dc8d0845-5250-46df-8a81-48b45379c6ff
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/textcontent-or-innertext.md
unknown
84a36276-db84-4279-b470-195e13fb85c3
4
SemanticChunker@1.0.0
769e3cf2bda4b59a7eae65b1987883b38d83d930e1cb759a537e6723671533b5
[Similarities > Performance] ## Performance But, wait! There's more! While `HTMLElement.innerText` seems like the sensible choice, it comes with a performance caveat. In order to figure out what the browser renders, CSS has to be considered, triggering a [reflow](https://developer.mozilla.org/en-US/docs/Glossary/Refl...
unknown
unknown
[Similarities > Performance] ## Performance But, wait! There's more! While `HTMLElement.innerText` seems like the sensible choice, it comes with a performance caveat. In order to figure out what the browser renders, CSS has to be considered, triggering a [reflow](https://developer.mozilla.org/en-US/docs/Glossary/Refl...
[Similarities > Performance] ## Performance But, wait! There's more! While `HTMLElement.innerText` seems like the sensible choice, it comes with a performance caveat. In order to figure out what the browser renders, CSS has to be considered, triggering a [reflow](https://developer.mozilla.org/en-US/docs/Glossary/Refl...
code_snippets