Gathering detailed insights and metrics for object-hash-import
Gathering detailed insights and metrics for object-hash-import
Gathering detailed insights and metrics for object-hash-import
Gathering detailed insights and metrics for object-hash-import
@womorg/ea-laborum-magnam
> Safely flatten a nested JavaScript object.
@diotoborg/temporibus-neque-quasi
[![github actions][actions-image]][actions-url] [![travis-ci](https://travis-ci.org/import-js/@diotoborg/temporibus-neque-quasi.svg?branch=main)](https://travis-ci.org/import-js/@diotoborg/temporibus-neque-quasi) [![coverage][codecov-image]][codecov-url]
@taktikorg/vero-eligendi
<!-- markdownlint-disable MD024 MD034 MD033 -->
@teamteanpm2024/odit-animi-velit
> Safely flatten a nested JavaScript object.
npm install object-hash-import
Typescript
Module System
Min. Node Version
Node Version
NPM Version
60.8
Supply Chain
94.4
Quality
74.8
Maintenance
100
Vulnerability
100
License
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
199
Last Day
1
Last Week
3
Last Month
7
Last Year
43
Minified
Minified + Gzipped
Latest Version
2.2.0
Package Id
object-hash-import@2.2.0
Unpacked Size
9.72 kB
Size
4.24 kB
File Count
7
NPM Version
8.11.0
Node Version
16.15.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
200%
3
Compared to previous week
Last month
600%
7
Compared to previous month
Last year
-24.6%
43
Compared to previous year
2
A version of object-hash
that supports import
instead of require
1npm install object-hash-import
Generate hashes from objects and values in node and the browser. Uses node.js crypto module for hashing. Supports SHA1 and many others (depending on the platform) as well as custom streams (e.g. CRC32).
1var hash = require('object-hash'); 2 3hash({foo: 'bar'}) // => '67b69634f9880a282c14a0f0cb7ba20cf5d677e9' 4hash([1, 2, 2.718, 3.14159]) // => '136b9b88375971dff9f1af09d7356e3e04281951'
Starting with version 1.1.8
(released April 2017), new versions will consider
the exact returned hash part of the API contract, i.e. changes that will affect
hash values will be considered semver-major
. Previous versions may violate
that expectation.
For more information, see this discussion.
Generate a hash from any object or type. Defaults to sha1 with hex encoding.
algorithm
hash algo to be used: 'sha1', 'md5', 'passthrough'. default: sha1
crypto.getHashes()
. Note that the default of SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.passthrough
algorith, which will return the information that would otherwise have been hashed.excludeValues
{true|false} hash object keys, values ignored. default: falseencoding
hash encoding, supports 'buffer', 'hex', 'binary', 'base64'. default: hexignoreUnknown
{true|*false} ignore unknown object types. default: falsereplacer
optional function that replaces values before hashing. default: accept all valuesrespectFunctionProperties
{true|false} Whether properties on functions are considered when hashing. default: truerespectFunctionNames
{true|false} consider name
property of functions for hashing. default: truerespectType
{true|false} Whether special type attributes (.prototype
, .__proto__
, .constructor
)
are hashed. default: trueunorderedArrays
{true|false} Sort all arrays before hashing. Note that this affects all collections,
i.e. including typed arrays, Sets, Maps, etc. default: falseunorderedSets
{true|false} Sort Set
and Map
instances before hashing, i.e. make
hash(new Set([1, 2])) == hash(new Set([2, 1]))
return true
. default: trueunorderedObjects
{true|false} Sort objects before hashing, i.e. make hash({ x: 1, y: 2 }) === hash({ y: 2, x: 1 })
. default: trueexcludeKeys
optional function for excluding specific key(s) from hashing, if true is returned then exclude from hash. default: include all keysHash using the sha1 algorithm.
Note that SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'sha1'})
Hash object keys using the sha1 algorithm, values ignored.
Sugar method, equivalent to hash(value, {excludeValues: true})
Hash using the md5 algorithm.
Note that the MD5 algorithm is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'md5'})
Hash object keys using the md5 algorithm, values ignored.
Note that the MD5 algorithm is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'md5', excludeValues: true})
Write the information that would otherwise have been hashed to a stream, e.g.:
1hash.writeToStream({foo: 'bar', a: 42}, {respectType: false}, process.stdout)
2// => e.g. 'object:a:number:42foo:string:bar'
node:
1npm install object-hash
browser: /dist/object_hash.js
1<script src="object_hash.js" type="text/javascript"></script> 2 3<script> 4 var hash = objectHash.sha1({foo:'bar'}); 5 6 console.log(hash); // e003c89cdf35cdf46d8239b4692436364b7259f9 7</script>
1var hash = require('object-hash'); 2 3var peter = { name: 'Peter', stapler: false, friends: ['Joanna', 'Michael', 'Samir'] }; 4var michael = { name: 'Michael', stapler: false, friends: ['Peter', 'Samir'] }; 5var bob = { name: 'Bob', stapler: true, friends: [] }; 6 7/*** 8 * sha1 hex encoding (default) 9 */ 10hash(peter); 11// 14fa461bf4b98155e82adc86532938553b4d33a9 12hash(michael); 13// 4b2b30e27699979ce46714253bc2213010db039c 14hash(bob); 15// 38d96106bc8ef3d8bd369b99bb6972702c9826d5 16 17/*** 18 * hash object keys, values ignored 19 */ 20hash(peter, { excludeValues: true }); 21// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 22hash(michael, { excludeValues: true }); 23// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 24hash.keys(bob); 25// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 26 27/*** 28 * hash object, ignore specific key(s) 29 */ 30hash(peter, { excludeKeys: function(key) { 31 if ( key === 'friends') { 32 return true; 33 } 34 return false; 35 } 36}); 37// 66b7d7e64871aa9fda1bdc8e88a28df797648d80 38 39/*** 40 * md5 base64 encoding 41 */ 42hash(peter, { algorithm: 'md5', encoding: 'base64' }); 43// 6rkWaaDiG3NynWw4svGH7g== 44hash(michael, { algorithm: 'md5', encoding: 'base64' }); 45// djXaWpuWVJeOF8Sb6SFFNg== 46hash(bob, { algorithm: 'md5', encoding: 'base64' }); 47// lFzkw/IJ8/12jZI0rQeS3w==
IE <= 8 and Opera <= 11 support dropped in version 0.3.0. If you require legacy browser support you must either use an ES5 shim or use version 0.2.5 of this module.
1git clone https://github.com/puleos/object-hash
If you want to stand this up in a docker container, you should take at look
at the project.
gulp watch
(default) watch files, test and lint on change/addgulp test
unit testsgulp karma
browser unit testsgulp lint
jshintgulp dist
create browser version in /distMIT
Only Node.js versions >= 6.0.0
are being tested in CI now.
No other breaking changes were introduced.
No vulnerabilities found.
No security vulnerabilities found.