4.6.69 • Published 11 months ago

@hishprorg/ab-ipsa-qui v4.6.69

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@hishprorg/ab-ipsa-qui

Deterministic JSON.stringify() - a faster version of @substack's json-stable-strigify without jsonify.

You can also pass in a custom comparison function.

Build Status Coverage Status

example

var stringify = require('@hishprorg/ab-ipsa-qui');
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
console.log(stringify(obj));

output:

{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}

methods

var stringify = require('@hishprorg/ab-ipsa-qui')

var str = stringify(obj, opts)

Return a deterministic stringified string str from the object obj.

options

cmp

If opts is given, you can supply an opts.cmp to have a custom comparison function for object keys. Your function opts.cmp is called with these parameters:

opts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue })

For example, to sort on the object key names in reverse order you could write:

var stringify = require('@hishprorg/ab-ipsa-qui');

var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
var s = stringify(obj, function (a, b) {
    return a.key < b.key ? 1 : -1;
});
console.log(s);

which results in the output string:

{"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}

Or if you wanted to sort on the object values in reverse order, you could write:

var stringify = require('@hishprorg/ab-ipsa-qui');

var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 };
var s = stringify(obj, function (a, b) {
    return a.value < b.value ? 1 : -1;
});
console.log(s);

which outputs:

{"d":6,"c":5,"b":[{"z":3,"y":2,"x":1},9],"a":10}

cycles

Pass true in opts.cycles to stringify circular property as __cycle__ - the result will not be a valid JSON string in this case.

TypeError will be thrown in case of circular object without this option.

install

With npm do:

npm install @hishprorg/ab-ipsa-qui

benchmark

To run benchmark (requires Node.js 6+):

node benchmark

Results:

@hishprorg/ab-ipsa-qui x 17,189 ops/sec ±1.43% (83 runs sampled)
json-stable-stringify x 13,634 ops/sec ±1.39% (85 runs sampled)
fast-stable-stringify x 20,212 ops/sec ±1.20% (84 runs sampled)
faster-stable-stringify x 15,549 ops/sec ±1.12% (84 runs sampled)
The fastest is fast-stable-stringify

Enterprise support

@hishprorg/ab-ipsa-qui package is a part of Tidelift enterprise subscription - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.

Security contact

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.

license

MIT

fullwidtheast-asian-widthhashwarningtypedarrayajaxrandomelbgenericsreversed$.extendnpmmanagerbrowserjwtview.gitignorepoint-freeflatMapfast-copyString.prototype.matchAllgetterautoscalingkinesisES2021typedinObservablessuperstructnested cssforkreact-hook-formsymbolshotreverseECMAScriptcommandroutinglintflagreact-componentshimintrinsicredux-toolkitauthenticationmonorepodomwidthcallboundasciiqsreadiedeepclonewalkoutputstylesheetWeakSetsameValueZeromulti-packagebyteLengtheslint-pluginbcryptmodulesdescriptorignoreremovepinoencryptionaccessorsortqueueMicrotaskinvariantexit-codeserializecomputed-typestoReversedtelephonesigtermES8schemaprototypeidlenativeguidlesscssxtermsafecss-in-jsvaluesSymbol.toStringTagcolorsanimationRxpushfullreduxerrorfixed-widthmakeuser-streamsruleslibphonenumberaws6to5validationUnderscoreequalECMAScript 5Object.defineProperty256structuredClonekeystoobjectcolumnsconstmkdirstylesWeakMapprocessimmerframerpropertiesterminalreadablestreambabelWebSocketimmutablequerystringtypeofglobal this valuetransportoptimizersignalsbyteOffsetawesomesaucegetPrototypeOfECMAScript 2015json-schema-validationcommand-linekoreanassertionindicatorspecESnextECMAScript 2018jshintmatchAllfull-widthshamutileventstostringtagcopymobileCSSStyleDeclarationassertsworkflowparsingbootstrap cssreactnopeglobalsArray.prototype.filterboundless mixinsUint8ArraybufferFloat32ArrayamazonutilseventEmitterclitoolsidentifiersstylingstatusBigInt64ArrayenderrgbprotobufapigetOwnPropertyDescriptordiransibannershebangstringifiersetterassigndayjspyyamlReactiveExtensionsspinnersclassesarktypestyleguidefunctionswritablesymlinksReflect.getPrototypeOfapollofindfantasy-landjsonschemaregular expressionbootstrap lessfunction.lengthECMAScript 2023corestarterharmonymatchglobal objectconfigurableregexes2016optioncryptdirectorywriteES2020Streamspolyfillworkspace:*characterl10ncloudtrailtypedataviewbusyES3channelarraysArray.prototype.findLast-0subprocessmatchessigintURLSearchParamsrfc4122Object.islivebddObject.valueseseslintconfigfromjQueryiteratorsettingschineseObservablerfc9562promisegetfetchbuffersWebSocketsconsumeoptimistprettystreamArray.prototype.flatMapcssnumberomitjsdifflogvariables in csswindowenvironmentschromeismkdirpminimalcurldotenvenvpopmotionsyntaxES2019traversefastifyairbnbObjectsequencedatastructuretermbundlermake dirJSON-SchemaajvmruyupcheckECMAScript 3deletedeepmetadatafsYAMLMicrosoftcontainsobja11ywafzodxhrfputilityform-validationES5PromisearraybufferrapidsidespeedRegExp#flagseventDispatcherSymbolECMAScript 2019textString.prototype.trimendpointirqUint32Arrayauthlessfast-cloneweakmapponyfillequalitydeep-copyjoiautoprefixeres7validatortrimsetstyleflatcreateopensslRegExp.prototype.flagssnsSystem.globalclassnameformargvassertcss variablebindreducerprefixglobalsqsmapreducegroupByhasOwnPropertyserializationoffsetmixinsargumentECMAScript 2022loadinges2015cjkcloudsearchperformanttestweaksetES6binaryvalueextendpositivevarsbinredactimportexportschemeartconfiguuidECMAScript 6shrinkwrapinspecthttpselectroncolourdependenciesqueuefast-deep-copyes-abstractflagstimetakezxIteratores8replaycolumncompareESpropertyargsmergeTypeBoxgdprformatRxJSfindLasttypedarraysfigletgradients css3Object.keyscryptoquerysomepackage managernegative zeroruntime
4.6.69

11 months ago

4.6.68

11 months ago

4.6.67

11 months ago

4.5.67

11 months ago

4.5.66

11 months ago

4.5.65

11 months ago

4.4.65

11 months ago

4.4.64

11 months ago

4.4.63

11 months ago

4.4.62

11 months ago

4.4.61

11 months ago

4.4.60

11 months ago

4.4.59

11 months ago

4.4.58

11 months ago

4.4.57

11 months ago

4.4.56

11 months ago

3.4.56

12 months ago

3.4.55

12 months ago

3.4.54

12 months ago

3.4.53

12 months ago

3.4.52

12 months ago

3.4.51

12 months ago

3.4.50

12 months ago

3.4.49

12 months ago

3.4.48

12 months ago

3.4.47

12 months ago

3.4.46

12 months ago

3.4.45

12 months ago

3.4.44

12 months ago

3.4.43

12 months ago

3.3.43

12 months ago

3.3.42

12 months ago

3.3.41

12 months ago

3.3.40

12 months ago

3.3.39

12 months ago

3.3.38

12 months ago

3.3.37

1 year ago

3.3.36

1 year ago

3.2.36

1 year ago

3.2.35

1 year ago

3.2.34

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

2.2.20

1 year ago

2.2.19

1 year ago

2.2.18

1 year ago

2.2.17

1 year ago

2.2.16

1 year ago

2.2.15

1 year ago

2.2.14

1 year ago

2.2.13

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago