3.5.71 • Published 11 months ago

@hishprorg/dolorem-ab-eum v3.5.71

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

@hishprorg/dolorem-ab-eum Version Badge

github actions coverage License Downloads

npm badge

deterministic version of JSON.stringify() so you can get a consistent hash from stringified results

You can also pass in a custom comparison function.

example

const stringify = require('@hishprorg/dolorem-ab-eum');

const 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

const stringify = require('@hishprorg/dolorem-ab-eum')

const 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 }, { get(key): value })

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

const stringify = require('@hishprorg/dolorem-ab-eum');

const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 },7], a: 3 };

const s = stringify(obj, function (a, b) {
	return b.key.localeCompare(a.key);
});

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:

const stringify = require('@hishprorg/dolorem-ab-eum');

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

const 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}

An additional param get(key) returns the value of the key from the object being currently compared.

space

If you specify opts.space, it will indent the output for pretty-printing. Valid values are strings (e.g. {space: \t}) or a number of spaces ({space: 3}).

For example:

const obj = { b: 1, a: { foo: 'bar', and: [1, 2, 3] } };

const s = stringify(obj, { space: '  ' });

console.log(s);

which outputs:

{
  "a": {
    "and": [
      1,
      2,
      3
    ],
    "foo": "bar"
  },
  "b": 1
}

replacer

The replacer parameter is a function opts.replacer(key, value) that behaves the same as the replacer from the core JSON object.

install

With npm do:

npm install @hishprorg/dolorem-ab-eum

license

MIT

streamsUint8ClampedArraynpmless csselectroncomputed-typessortCSSfast-deep-copyES2022globalThisdeleteweaksetmodulescloudwatchfnmatchargumentes2015requestdotenvflattenArray.prototype.containsformesshebangecmascriptequaljson-schemapackage.jsonignoremkdirsnested csssymbolnegativefilegradients css3quotepolyfillcommandInt8Arraypyyamlpromiseequalityeslintconfigsuperagentwalkcharacterdescriptionvariables in cssfetch3downtimeutilitycontainsplugindeep-copyslotstarterexitgetoptes2018sqsrfc4122mkdiraccessorqueueMicrotaskerrorenvironmentdayjsawesomesaucenumberregular expressionECMAScript 2017uuidutilskeysoutputES2015cloudfrontReactiveXprettysuperstructbinaryparsercloudformationenumerablejapanesebundlerhookformschemeflattc39importexportvestspringpatchtypescriptstatusgradients cssECMAScript 2022ES2017extrawidthbootstrap csswindowperformantsyntaxkeyless compilerES2021apiarraysforEachreadArray.prototype.flat@@toStringTagfast-cloneinvariantbabelpropertiesYAMLopensslcss lessmatchObject.valuesSymbol.toStringTagtestingsubprocessvarlinkES2023sigtermwindowsdataviewObservableregexpSymbolawscss variableECMAScript 2015getwriteproxylibphonenumberHyBijsxFloat64ArrayES5inbinES6resolveURLeventslanguagetakeObject.fromEntriescryptominimalperformanceless mixinssigintsetImmediatecertificatesdeterministicio-tsfile systemMapspinnerfunction.lengthtypanionharmonytraverseomitserializationArray.prototype.flatMapform-validationbusytranspilerapidpipewaapiES3mkdirpreadableprotocol-bufferseventEmitterstatelesssequencebyteOffsetrequirereversehooksECMAScript 6clia11yfpscurlsafechinesedependency managerdescriptorsWebSocketchildargvflag-0es8isroutettyrgbtestcss-in-jselmdataViewsidetrimLeftfindLastIndexES2020tslibponyfillwritableaccessibilityTypedArrayviewRegExp#flags256query6to5functionjestexecfilemonorepoconstimmeremites5acornES8east-asian-widthuser-streamsspinnerstoStringTagserializernopejsdomPromiseinspectroute53jQueryshimwhichexecutebddreact-componentasyncSystem.globaleslintpluginreplayhashpostcssconfigurabledragprivate dataconcatgesturesES7global objectstylesstringprunefluxselfdom-testing-libraryguidlruyupquerystringassertioncallbindlazycoerciblecloneimportuploadrobustjavascriptdatagroupelasticachewgetredux-toolkitthreeECMAScript 3kinesisgdprdefinewhatwgcolorslockfilecommand-lineiteratesettertesterpicomatchcircularenvironmentstoArrayajaxmulti-packagefast-copypinopropertyredactregularArrayBuffer#slicefastECMAScript 2020class-validatornameloadbalancingtrimEndjoiworkflowtyped arrayreactlengthBigInt64ArraybuffersObject.isswfletsymlinksreverseddefinePropertymake diroperating-systeminternal slotsyntaxerrormruhardlinksi18noptimizerdirprotostablecodesisConcatSpreadablexhrpackagescolorObject.getPrototypeOftrimfast-deep-clonezodinstallercheckinternalECMAScriptgetPrototypeOfECMAScript 2016chromeUnderscorejsonqueuetypesafepopmotioneslint-pluginglobargsartbrowserlistarrayoffsetcryptcompile lessjson-schema-validatorvpcclassnamestreamstringifytoolsmatchAlljsdiffcjktoolkitsameValueZeroreal-timelintes2017ansicoredomReflect.getPrototypeOfiterationbeanstalkhelperinputvariablesgetOwnPropertyDescriptorfrompostcss-pluginfunctionsfindLastprototypelinuxdynamodbnamesmergeramdamobileestreecollection.es6globalmakees6collectionsettingschannelBigUint64ArraycloudtrailtypeofutilitiesESnextRxJSparsecolourreduceObject.keyslistenersloadingtypestelephonefantasy-landdifffullTypeScriptdeepcopydropArrayproppusharraybufferchaiidentifiersWebSocketsreadablestreamreduxl10nUint16ArrayclassesseteslintexpressJSONweakmapcolumnspositivefunctionalautoprefixerkoreanreducerhttpscreateerror-handlingapolloenderconsoleexit-codegenericslesscompilertranspilerforkshrinkwrapvisualintrinsichasconcatMaptrimRightdatastructureurlCSSStyleDeclarationparsingWeakMapes-shim APIscheme-validationsignalswarningencryptiontextgetterfsec2speedArray.prototype.flattenRxrandomremovefindes7nodeebscall-boundclassnamesnativevalidatorhigher-orderzxcachedeep-clonestringifieroncemodulearktypeObjectvalidasciiformatwaitpreprocessorhttpshellloggingtransportmapconfigcore-js[[Prototype]]termjshintutilajvcssserializefilterObservablesfastcopyprocesscommandereventDispatchermixinshasOwnPropertyiteratorworkertypehot
3.5.71

11 months ago

3.5.70

11 months ago

3.5.69

11 months ago

3.5.68

11 months ago

3.5.67

11 months ago

3.5.66

11 months ago

3.5.65

11 months ago

3.5.64

11 months ago

3.5.63

11 months ago

3.5.62

11 months ago

3.5.61

11 months ago

3.5.60

11 months ago

3.5.59

11 months ago

3.5.58

11 months ago

3.5.57

11 months ago

3.5.56

11 months ago

3.5.55

12 months ago

3.5.54

12 months ago

3.5.53

12 months ago

3.5.52

12 months ago

3.5.51

12 months ago

3.5.50

12 months ago

3.5.49

12 months ago

3.5.48

12 months ago

3.5.47

12 months ago

3.5.46

12 months ago

3.5.45

12 months ago

3.5.44

12 months ago

3.5.43

12 months ago

3.5.42

12 months ago

3.5.41

12 months ago

3.5.40

12 months ago

3.4.40

12 months ago

3.4.39

12 months ago

3.4.38

12 months ago

2.4.38

12 months ago

2.4.37

1 year ago

2.4.36

1 year ago

2.4.35

1 year ago

1.4.35

1 year ago

1.4.34

1 year ago

1.4.33

1 year ago

1.4.32

1 year ago

1.4.31

1 year ago

1.4.30

1 year ago

1.4.29

1 year ago

1.4.28

1 year ago

1.4.27

1 year ago

1.4.26

1 year ago

1.4.25

1 year ago

1.4.24

1 year ago

1.4.23

1 year ago

1.4.22

1 year ago

1.4.21

1 year ago

1.4.20

1 year ago

1.4.19

1 year ago

1.4.18

1 year ago

1.4.17

1 year ago

1.4.16

1 year ago

1.4.15

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.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.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago