💯 Super fast unicode-aware string manipulation Javascript library
Installations
npm install stringz
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.14.1
NPM Version
6.13.4
Score
99.6
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (93.1%)
JavaScript (6.9%)
Developer
sallar
Download Statistics
Total Downloads
25,712,479
Last Day
33,595
Last Week
291,121
Last Month
1,347,634
Last Year
11,772,771
GitHub Statistics
239 Stars
136 Commits
12 Forks
5 Watching
13 Branches
9 Contributors
Package Meta Information
Latest Version
2.1.0
Package Id
stringz@2.1.0
Size
5.76 kB
NPM Version
6.13.4
Node Version
12.14.1
Publised On
21 Feb 2020
Total Downloads
Cumulative downloads
Total Downloads
25,712,479
Last day
-37.3%
33,595
Compared to previous day
Last week
-10.5%
291,121
Compared to previous week
Last month
7.9%
1,347,634
Compared to previous month
Last year
73%
11,772,771
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Stringz
A really small, performant, unicode-aware library for working with Strings in Node.js.
Javascript has a serious problem with unicode. Even ES6 can’t solve the problem
entirely since some characters like the new colored emojis are three bytes
instead of two bytes. Sometimes even more! "????????".length
returns 4
which is
totally wrong (hint: it should be 1!). ES6's Array.from
tried to solve this,
but that even fails: Array.from("????????")
returns ["????", "????"]
which is
incorrect. This library tries to tackle all these problems with a mega RegExp.
Read More Here.
Features
- Unicode-aware string manipulation tools
- High performance
Install
1$ npm install stringz --save
And import it in your awesome node app:
1// ES2015+ 2import * as stringz from 'stringz'; // OR: 3import { limit, substring, length, substr } from 'stringz';
1// CommonJS 2const stringz = require('stringz'); // OR: 3const { limit, substr } = require('stringz');
Usage
Limit String to Width
function limit(str[, limit[, padStr[, padPosition]]])
Param | Type | Default | Description |
---|---|---|---|
str | String | none | The string to be limited |
limit | Number | 16 | Desired string length |
padStr | String | "#" | Character to pad the output with |
padPosition | String | "right" | Pad position: "right" or "left" |
Examples
1// Truncate: 2limit('Life’s like a box of chocolates.', 20); // "Life's like a box of" 3 4// Pad: 5limit('Everybody loves emojis!', 26, '????'); // "Everybody loves emojis!????????????" 6limit('What are you looking at?', 30, '+', 'left'); // "++++++What are you looking at?" 7 8// Unicode Aware: 9limit('????????????', 2); // "????????" 10limit('????????????????', 4, '????????'); // "????????????????????????????????"
String Length
function length(str)
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to return the length for |
Examples
1length('Iñtërnâtiônàlizætiøn☃????'); // 22
Substring
function substring(str, start[, end])
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to be devided |
start | Number | none | Start position |
end | Number | End of string | End position |
Examples
1substring('Emojis ???????? are ???? poison. ????s are bad.', 7, 14); // "???????? are ????"
Substr
function substr(str[, start[, length]])
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to be devided |
start | Number | Start of string | Start position |
length | Number | String length minus start parameter | Length of result |
Examples
1substr('A.C. Milan ????????⚽️', 5, 7); // "Milan ????????"
IndexOf
function indexOf(str[, searchStr[, position]])
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to get index |
searchStr | String | none | String to be searched |
position | Number | 0 | Start of searching |
Examples
1indexOf('Emojis ???????? are ???? poison. ????s are bad.', 'are'); // 9 2indexOf('Emojis ???????? are ???? poison. ????s are bad.', 'are', 10); // 26
ToArray
function toArray(str)
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to convert to array |
Examples
1toArray('????????????????'); // ['????????', '????', '????']
Test
1$ npm test
Benchmark
This library scores high in a length benchmark (it's intended usage) and should be fast for most use case.
Stringz .length (accurate) x 861,039 ops/sec ±1.57% (84 runs sampled)
Lodash .toArray (accurate) x 795,108 ops/sec ±2.13% (82 runs sampled)
Emoji Aware .split (inaccurate) x 2,269 ops/sec ±1.38% (85 runs sampled)
Spliddit .length (inaccurate) x 487,718 ops/sec ±2.21% (83 runs sampled)
UTF8 Length (inaccurate) x 232,918 ops/sec ±1.02% (87 runs sampled)
Fastest is Stringz .length
To run benchmarks yourself:
1$ cd ./benchmark 2$ npm install 3$ node run.js
Changelog
License
This software is released under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 2/5 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 29 are checked with a SAST tool
Reason
44 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-xp63-6vf5-xf3v
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-6fw4-hr69-g3rv
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-3f95-r44v-8mrg
- Warn: Project is vulnerable to: GHSA-28xr-mwxg-3qc8
- Warn: Project is vulnerable to: GHSA-9p95-fxvg-qgq2
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.3
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More