Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ before_install:
- export "PATH=./node_modules/.bin:$PATH"
install: npm install
script:
- gulp lint
- gulp dist
- gulp test karma
- npm run lint
- npm run test
- npm run prepublish
after_success:
- gulp coveralls

2 changes: 1 addition & 1 deletion dist/object_hash.js

Large diffs are not rendered by default.

4,763 changes: 0 additions & 4,763 deletions dist/object_hash_test.js

This file was deleted.

29 changes: 0 additions & 29 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

var gulp = require('gulp');
var jshint = require('gulp-jshint');
var exec = require('gulp-exec');
var stylish = require('jshint-stylish');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var coveralls = require('gulp-coveralls');
var istanbul = require('gulp-istanbul');
var mocha = require('gulp-mocha');
Expand Down Expand Up @@ -46,30 +41,6 @@ function lint(src){
.pipe(jshint.reporter(stylish));
}

gulp.task('dist', function(){
return Promise.all([
gulp.src([paths.index])
.pipe(browserify({
insertGlobals : true,
debug: true,
standalone: 'objectHash'
}))
// Hack: See https://github.com/puleos/object-hash/issues/71.
// It's probably better to replace gulp-browserify altogether instead.
.pipe(replace(/_global.crypto/g, 'false'))
.pipe(rename('object_hash.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist')),
gulp.src([paths.tests])
// Hack: browserify seems to not support async-await.
// It's probably better to replace gulp-browserify altogether instead.
.pipe(replace(/async function/g, 'function'))
.pipe(browserify())
.pipe(rename('object_hash_test.js'))
.pipe(gulp.dest('./dist'))
]);
});

gulp.task('pre-test', function() {
return preTest([paths.index]);
});
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var crypto = require('crypto');
var getHashes = require('crypto').getHashes;
var createHash = require('crypto').createHash;

/**
* Exported function
Expand Down Expand Up @@ -54,7 +55,7 @@ exports.keysMD5 = function(object){
};

// Internals
var hashes = crypto.getHashes ? crypto.getHashes().slice() : ['sha1', 'md5'];
var hashes = getHashes ? getHashes().slice() : ['sha1', 'md5'];
hashes.push('passthrough');
var encodings = ['buffer', 'hex', 'binary', 'base64'];

Expand Down Expand Up @@ -117,7 +118,7 @@ function hash(object, options) {
var hashingStream;

if (options.algorithm !== 'passthrough') {
hashingStream = crypto.createHash(options.algorithm);
hashingStream = createHash(options.algorithm);
} else {
hashingStream = new PassThrough();
}
Expand Down
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"url": "https://github.com/puleos/object-hash/issues"
},
"scripts": {
"test": "node ./node_modules/.bin/mocha test",
"prepublish": "gulp dist"
"lint": "gulp lint",
"test": "gulp test",
"prepublish": "rollup -c"
},
"author": "Scott Puleo <[email protected]>",
"files": [
Expand All @@ -27,23 +28,19 @@
],
"license": "MIT",
"devDependencies": {
"browserify": "^16.2.3",
"gulp": "^4.0.0",
"gulp-browserify": "^0.5.1",
"gulp-coveralls": "^0.1.4",
"gulp-exec": "^3.0.1",
"gulp-istanbul": "^1.1.3",
"gulp-jshint": "^2.0.0",
"gulp-mocha": "^5.0.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^1.0.0",
"gulp-uglify": "^3.0.0",
"jshint": "^2.8.0",
"jshint-stylish": "^2.1.0",
"karma": "^4.2.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"mocha": "^6.2.0"
"mocha": "^6.2.0",
"rollup": "^2.6.0",
"rollup-plugin-uglify": "^6.0.4"
},
"engines": {
"node": ">= 6"
Expand Down
11 changes: 11 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { uglify } from "rollup-plugin-uglify";

export default {
input: 'index.js',
output: {
file: 'dist/object_hash.js',
format: 'umd',
compact: true,
},
plugins: [uglify()]
};