Skip to content

Stringify anything in a predictable manner, i.e. two objects with equal keys in different order gets the same result

Notifications You must be signed in to change notification settings

joakimbeng/to-predictable-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

to-predictable-string

NPM version js-xo-style

Stringify anything in a predictable manner, i.e. two objects with equal keys in different order gets the same result

Useful if you want to generate a hash from an object.

Installation

Install to-predictable-string using npm:

npm install --save to-predictable-string

Usage

Module usage

var toPredictableString = require('to-predictable-string');

toPredictableString({my: 'data', prop1: {prop2: /regexp/, prop3: ['a', 'r', 'r', 'a', 'y']}});
// "{my:data,prop1:{prop2:/regexp/,prop3:[a,r,r,a,y]}}"

API

toPredictableString(val)

Name Type Description
val Mixed The data to generate a string from

Returns: String, the generated string.

License

MIT

About

Stringify anything in a predictable manner, i.e. two objects with equal keys in different order gets the same result

Resources

Stars

Watchers

Forks

Packages

No packages published