New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asset-pipe-common

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-pipe-common - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

15

lib/common.js

@@ -70,2 +70,17 @@ "use strict";

/**
* Creates a hash out of a String or Buffer
*
* @param {String|Buffer} source Source to make hash out of
*
* @returns {String} a hash
*/
module.exports.hasher = (source) => {
const hasher = crypto.createHash('sha1');
return hasher.update(source, Buffer.isBuffer(source) ? null : 'utf8').digest('hex');
};
/**
* Constructs a temporary filename

@@ -72,0 +87,0 @@ *

2

package.json
{
"name": "asset-pipe-common",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"author": {

@@ -5,0 +5,0 @@ "name": "Trygve Lie",

@@ -35,5 +35,28 @@ "use strict";

hasher.on('finish', () => {
console.log(hasher.hash);
// console.log(hasher.hash);
t.end();
});
});
tap.test('hasher() - hash a String - should match given hash', (t) => {
t.equal(lib.hasher('abc'), 'a9993e364706816aba3e25717850c26c9cd0d89d');
t.equal(lib.hasher('abce'), '0a431a7631cabf6b11b984a943127b5e0aa9d687');
t.end();
});
tap.test('hasher() - hash a Buffer - should match given hash', (t) => {
t.equal(lib.hasher(new Buffer('abc')), 'a9993e364706816aba3e25717850c26c9cd0d89d');
t.equal(lib.hasher(new Buffer('abc').toString()), 'a9993e364706816aba3e25717850c26c9cd0d89d');
t.equal(lib.hasher(new Buffer('abce')), '0a431a7631cabf6b11b984a943127b5e0aa9d687');
t.equal(lib.hasher(new Buffer('abce').toString()), '0a431a7631cabf6b11b984a943127b5e0aa9d687');
t.end();
});
tap.test('hasher() - source contains hexadecimal escape sequence - should match given hash', (t) => {
t.equal(lib.hasher('ab\xff'), 'ba5142a8207bd61baddf325088732e71cbfe8eb6');
t.equal(lib.hasher(new Buffer('ab\xff')), 'ba5142a8207bd61baddf325088732e71cbfe8eb6');
t.equal(lib.hasher(new Buffer('ab\xff').toString()), 'ba5142a8207bd61baddf325088732e71cbfe8eb6');
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc