🦘 - PouchDB is a pocket-sized database.
Installations
npm install pouchdb-collate
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.11.1
NPM Version
10.7.0
Score
99.6
Supply Chain
99.5
Quality
83.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (98.81%)
Shell (0.68%)
HTML (0.51%)
Developer
Download Statistics
Total Downloads
15,647,728
Last Day
2,196
Last Week
30,686
Last Month
188,763
Last Year
2,324,456
GitHub Statistics
16,988 Stars
5,206 Commits
1,467 Forks
270 Watching
1,555 Branches
377 Contributors
Package Meta Information
Latest Version
9.0.0
Package Id
pouchdb-collate@9.0.0
Unpacked Size
35.27 kB
Size
9.00 kB
File Count
5
NPM Version
10.7.0
Node Version
20.11.1
Publised On
21 Jun 2024
Total Downloads
Cumulative downloads
Total Downloads
15,647,728
Last day
-69.7%
2,196
Compared to previous day
Last week
-27.6%
30,686
Compared to previous week
Last month
-14.5%
188,763
Compared to previous month
Last year
-15.2%
2,324,456
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
PouchDB Collate
Collation functions for PouchDB map/reduce. Used by PouchDB map/reduce to maintain consistent CouchDB collation ordering.
The PouchDB Collate API is not exposed by PouchDB itself, but if you'd like to use it in your own projects, it's pretty small, and it has a few functions you may find useful.
Usage
1npm install pouchdb-collate
1var pouchCollate = require('pouchdb-collate');
Warning: semver-free zone!
This package is conceptually an internal API used by PouchDB or its plugins. It does not follow semantic versioning (semver), and rather its version is pegged to PouchDB's. Use exact versions when installing, e.g. with --save-exact
.
Source
PouchDB and its sub-packages are distributed as a monorepo.
For a full list of packages, see the GitHub source.
API
toIndexableString(obj)
This is probably the most useful function in PouchDB Collate. It converts any object to a serialized string that maintains proper CouchDB collation ordering in both PouchDB and CouchDB (ignoring some subtleties with ICU string ordering in CouchDB vs. ASCII string ordering in PouchDB).
So for example, if you want to sort your documents by many properties in an array, you can do e.g.:
1var pouchCollate = require('pouchdb-collate'); 2var myDoc = { 3 firstName: 'Scrooge', 4 lastName: 'McDuck', 5 age: 67, 6 male: true 7}; 8// sort by age, then gender, then last name, then first name 9myDoc._id = pouchCollate.toIndexableString( 10 [myDoc.age, myDoc.male, mydoc.lastName, mydoc.firstName]);
The doc ID will be:
1'5323256.70000000000000017764\u000021\u00004McDuck\u00004Scrooge\u0000\u0000'
Which is of course totally not human-readable, but it'll sort everything correctly (floats, booleans, ints – you name it). If you need a human-readable doc ID, check out the DocURI project.
Warning! If you are syncing or storing docs in CouchDB, then you will need to modify these doc IDs, due to a bug in how Chrome parses URLs, which causes problems in the replicator when it tries to GET
docs at those URLs.
In short, you will need to replace all the \u0000
characters with some other separator. Assuming you're storing text data and not binary data, \u0001
should be fine:
1pouchCollate.toIndexableString([/* ... */]) 2 .replace(/\u0000/g, '\u0001');
parseIndexableString(str)
Same as the above, but in reverse. Given an indexable string, it'll give you back a structured object.
For instance:
1var pouchCollate = require('pouchdb-collate'); 2 3// [ 67, true, 'McDuck', 'Scrooge' ] 4pouchCollate.parseIndexableString( 5 '5323256.70000000000000017764\u000021\u00004McDuck\u00004Scrooge\u0000\u0000')
collate(obj1, obj2)
Give it two objects, and it'll return a number comparing them. For example:
1pouchCollate.collate('foo', 'bar'); // 1 2pouchCollate.collate('bar', 'foo'); // -1 3pouchCollate.collate('foo', 'foo'); // 0
Of course it sorts more than just strings - any valid JavaScript object is sortable.
normalizeKey(obj)
You shouldn't need to use this, but this function will normalize the object and return what CouchDB would expect - e.g. undefined
becomes null
, and Date
s become date.toJSON()
. It's basically what you would get if you called:
1JSON.parse(JSON.stringify(obj));
but a bit faster.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
15 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
all changesets reviewed
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: Apache License 2.0: LICENSE:0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:21
- Warn: no topLevel permission defined: .github/workflows/docs.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
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:129: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:172: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:212: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:251: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:84: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/docs.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/docs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/docs.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/pouchdb/pouchdb/docs.yml/master?enable=pin
- Info: 0 out of 9 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 9.0.0 not signed: https://api.github.com/repos/pouchdb/pouchdb/releases/161701446
- Warn: release artifact 8.0.1 not signed: https://api.github.com/repos/pouchdb/pouchdb/releases/91872018
- Warn: release artifact 8.0.0 not signed: https://api.github.com/repos/pouchdb/pouchdb/releases/86152678
- Warn: release artifact 7.3.1 not signed: https://api.github.com/repos/pouchdb/pouchdb/releases/82805630
- Warn: release artifact 7.3.0 not signed: https://api.github.com/repos/pouchdb/pouchdb/releases/64433152
- Warn: release artifact 9.0.0 does not have provenance: https://api.github.com/repos/pouchdb/pouchdb/releases/161701446
- Warn: release artifact 8.0.1 does not have provenance: https://api.github.com/repos/pouchdb/pouchdb/releases/91872018
- Warn: release artifact 8.0.0 does not have provenance: https://api.github.com/repos/pouchdb/pouchdb/releases/86152678
- Warn: release artifact 7.3.1 does not have provenance: https://api.github.com/repos/pouchdb/pouchdb/releases/82805630
- Warn: release artifact 7.3.0 does not have provenance: https://api.github.com/repos/pouchdb/pouchdb/releases/64433152
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
45 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-2rxp-v6pw-ch6m
- Warn: Project is vulnerable to: GHSA-4xqq-m2hx-25v8
- Warn: Project is vulnerable to: GHSA-5866-49gr-22v4
- Warn: Project is vulnerable to: GHSA-r55c-59qm-vjw6
- Warn: Project is vulnerable to: GHSA-vmwr-mc7x-5vc3
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-jc84-3g44-wf2q
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-9qj9-36jm-prpv
- Warn: Project is vulnerable to: GHSA-wrvr-8mpx-r7pp
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- 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-3fx5-fwvr-xrjg
- Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-7mc5-chhp-fmc3
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-x6fg-f45m-jf5q
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgqf-hwc5-hh37
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
Score
4.4
/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