-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Alwatr/feat/flat-string
feat(flat-string): add new package for simplifies the complex C structures that are part of a combined JavaScript string
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Flat String | ||
|
||
This function simplifies the complex C structures that are part of a combined JavaScript string. | ||
|
||
If you're frequently combining strings and then using that combined string somewhere else, you might discover that running your string through `flatString` significantly enhances performance. | ||
|
||
In simpler terms, `flatString` is a function that optimizes the way strings are stored in memory in JavaScript. When you concatenate strings, JavaScript internally creates a complex structure to save memory. However, when you need to use this string, for example, to write it to a file or send it over the network, this complex structure needs to be flattened, which can take time. By using `flatString`, you flatten the string right after concatenation, making the subsequent use of the string faster. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@alwatr/flat-string", | ||
"version": "1.0.0", | ||
"description": "The `flat-string` function Flattens the underlying C structures of a concatenated JavaScript string.", | ||
"keywords": [ | ||
"string", | ||
"flat", | ||
"optimize", | ||
"concat", | ||
"concatenation", | ||
"util", | ||
"typescript", | ||
"esm", | ||
"alwatr" | ||
], | ||
"main": "main.js", | ||
"type": "module", | ||
"types": "main.d.ts", | ||
"author": "S. Ali Mihandoost <[email protected]>", | ||
"license": "MIT", | ||
"files": [ | ||
"**/*.{d.ts.map,d.ts,js.map,js,html,md}" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Alwatr/nanolib", | ||
"directory": "packages/flat-string" | ||
}, | ||
"homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/flat-string#readme", | ||
"bugs": { | ||
"url": "https://github.com/Alwatr/nanolib/issues" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* This function simplifies the complex C structures that are part of a combined JavaScript string. | ||
* | ||
* @param str The string to flatten. | ||
* @returns The flattened string. | ||
* @example | ||
* ```typescript | ||
* flatString(myStr); | ||
* ``` | ||
*/ | ||
export const flatString = (str: string): string => { | ||
// @ts-expect-error because it alters wrong compilation errors. | ||
str | 0; | ||
return str; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "@alwatr/tsconfig-base", | ||
"compilerOptions": { | ||
"composite": true, | ||
"tsBuildInfoFile": ".tsbuildinfo", | ||
"rootDir": "src", | ||
"outDir": "." | ||
}, | ||
|
||
"include": ["src/**/*.ts"], | ||
"exclude": [], | ||
"references": [] | ||
} |