Gathering detailed insights and metrics for stringz
Gathering detailed insights and metrics for stringz
Gathering detailed insights and metrics for stringz
Gathering detailed insights and metrics for stringz
💯 Super fast unicode-aware string manipulation Javascript library
npm install stringz
Typescript
Module System
Node Version
NPM Version
99.6
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
Total
24,905,499
Last Day
29,097
Last Week
320,750
Last Month
1,292,895
Last Year
11,295,821
239 Stars
136 Commits
12 Forks
5 Watching
13 Branches
9 Contributors
Updated on 21 Oct 2024
Minified
Minified + Gzipped
TypeScript (93.1%)
JavaScript (6.9%)
Cumulative downloads
Total Downloads
Last day
-1%
29,097
Compared to previous day
Last week
6.8%
320,750
Compared to previous week
Last month
7.3%
1,292,895
Compared to previous month
Last year
68.7%
11,295,821
Compared to previous year
1
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.
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');
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" |
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, '????????'); // "????????????????????????????????"
function length(str)
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to return the length for |
1length('Iñtërnâtiônàlizætiøn☃????'); // 22
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 |
1substring('Emojis ???????? are ???? poison. ????s are bad.', 7, 14); // "???????? are ????"
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 |
1substr('A.C. Milan ????????⚽️', 5, 7); // "Milan ????????"
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 |
1indexOf('Emojis ???????? are ???? poison. ????s are bad.', 'are'); // 9 2indexOf('Emojis ???????? are ???? poison. ????s are bad.', 'are', 10); // 26
function toArray(str)
Param | Type | Default | Description |
---|---|---|---|
str | String | none | String to convert to array |
1toArray('????????????????'); // ['????????', '????', '????']
1$ npm test
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
This software is released under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/5 approved changesets -- score normalized to 4
Reason
1 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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
44 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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