Installations
npm install @ndelangen/flatted
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
8.11.3
NPM Version
5.6.0
Score
71.7
Supply Chain
83.1
Quality
75
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (66.3%)
PHP (19.39%)
Python (13.38%)
HTML (0.93%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
WebReflection
Download Statistics
Total Downloads
666
Last Day
3
Last Week
93
Last Month
133
Last Year
187
GitHub Statistics
ISC License
1,063 Stars
137 Commits
49 Forks
10 Watchers
4 Branches
10 Contributors
Updated on Feb 20, 2025
Package Meta Information
Latest Version
1.0.3
Package Id
@ndelangen/flatted@1.0.3
Unpacked Size
42.04 kB
Size
16.09 kB
File Count
9
NPM Version
5.6.0
Node Version
8.11.3
Total Downloads
Cumulative downloads
Total Downloads
666
Last Day
-88.5%
3
Compared to previous day
Last Week
210%
93
Compared to previous week
Last Month
1,230%
133
Compared to previous month
Last Year
42.7%
187
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
6
flatted
A super light (0.5K) and fast circular JSON parser, directly from the creator of CircularJSON.
Usable via CDN or as regular module.
1// ESM 2import {parse, stringify} from 'flatted/esm'; 3 4// CJS 5const {parse, stringify} = require('flatted/cjs'); 6 7const a = [{}]; 8a[0].a = a; 9a.push(a); 10 11stringify(a); // [["1","0"],{"a":"0"}]
New in V1: Exact same JSON API
- Added a reviver parameter to
.parse(string, reviver)
and revive your own objects. - Added a replacer and a
space
parameter to.stringify(object, replacer, space)
for feature parity with JSON signature.
Compatibility
All ECMAScript engines compatible with Map
, Set
, Object.keys
, and Array.prototype.reduce
will work, even if polyfilled.
How does it work ?
While stringifying, all Objects, including Arrays, and strings, are flattened out and replaced as unique index. *
Once parsed, all indexes will be replaced through the flattened collection.
*
represented as string to avoid conflicts with numbers
1// logic example 2var a = [{one: 1}, {two: '2'}]; 3a[0].a = a; 4// a is the main object, will be at index '0' 5// {one: 1} is the second object, index '1' 6// {two: '2'} the third, in '2', and it has a string 7// which will be found at index '3' 8 9Flatted.stringify(a); 10// [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"] 11// a[one,two] {one: 1, a} {two: '2'} '2'

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
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: ISC License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/WebReflection/flatted/node.js.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/WebReflection/flatted/node.js.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/WebReflection/flatted/node.js.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/WebReflection/flatted/publish.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/WebReflection/flatted/publish.yml/main?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
2 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/publish.yml:12
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Info: no jobLevel write permissions found
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 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Score
3.8
/10
Last Scanned on 2025-02-17
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