Socket
Socket
Sign inDemoInstall

busta

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

20

lib/busta.js

@@ -5,3 +5,5 @@ var fs = require('fs');

var noop = function(){};
/**

@@ -13,3 +15,4 @@ * @param {String} file File to bust.

* - noprefix: Do not use a filename prefix.
* - encoding: Used by hasher. Defaults to utf8
* - encoding: Used by hasher. Defaults to `utf8`
* - hash: Hash algorithm or function. Default is `md5`
* @params {Function} callback(err, obj) where obj is a literal with info on the fingerprinted file.

@@ -23,3 +26,3 @@ * @returns {undefined}

? arguments[1]
: function(){};
: noop;
config = {};

@@ -34,3 +37,4 @@ }

var hash = hasher(contents.toString(config.encoding));
var fileString = contents.toString(config.encoding)
var hash = hasher(fileString, config.hash);
var newfilename = createNewFilename(config, hash);

@@ -49,3 +53,2 @@

});
};

@@ -65,2 +68,3 @@

config.encoding = config.encoding || 'utf8';
config.hash = config.hash || 'md5';
};

@@ -71,8 +75,12 @@

* @param {String} str
* @param {String|Function} algo
* @returns {String} 32 char md5 hash
* @api private
*/
function hasher(str) {
function hasher(str, algorithm) {
if (typeof algorithm === 'function') {
return algorithm(str);
}
return crypto
.createHash('md5')
.createHash(algorithm)
.update(str)

@@ -79,0 +87,0 @@ .digest('hex');

{
"name": "busta"
, "version": "0.1.0"
, "version": "0.1.1"
, "description": "Util to fingerprint asset filenames."

@@ -18,3 +18,3 @@ , "readmeFilename": "README.md"

, "dependencies": {
"commander": "1.1.1"
"commander": "~1.1.1"
}

@@ -27,2 +27,5 @@ , "devDependencies": {

}
, "scripts": {
"test": "mocha"
}
}

@@ -27,13 +27,15 @@ Busta

- __filename__ ```String``` File to fingerprint/bust.
- __options__ ```Object``` *optional*
- __outdir__ ```String``` : Directory to create new file in. Default is same as the original file.
- __prefix__ ```String``` : String to prepend filename with. Default is base of original file.
- __noprefix__ ```Boolean``` : If true filename will not be prepended with prefix. Default is ```false```.
- __encoding__ ```String``` : Used with hasher. Default is ```"utf8"```.
- __callback(err, newfile)__ ```Function``` Where ```newfile``` has the following properties:
- ```name``` Fingerprinted filename.
- ```absolute``` Absolute path.
- ```dir``` Directory of file.
- ```fingerprint```
- __filename__ `String` File to fingerprint/bust.
- __options__ `Object` *optional*
- __outdir__ `String` : Directory to create new file in. Default is same as the original file.
- __prefix__ `String` : String to prepend filename with. Default is base of original file.
- __noprefix__ `Boolean` : If true filename will not be prepended with prefix. Default is `false`.
- __encoding__ `String` : Used with hasher. Default is `"utf8"`.
- __hash__ `String|Function` : Used with hasher. Default is `"md5"`. If value is a function,
the function will be passed the file contents and it must return a string.
- __callback(err, newfile)__ `Function` Where `newfile` has the following properties:
- `name` Fingerprinted filename.
- `absolute` Absolute path.
- `dir` Directory of file.
- `fingerprint`

@@ -64,11 +66,12 @@ ```js

Options:
Options:
-h, --help output usage information
-V, --version output the version number
-f, --file <file> file to bust - required
-o, --outdir <outdir> directory to write new file to
-p, --prefix <prefix> filename prefix - default is base name of file
-n, --noprefix do not use a file prefix
-e, --encoding <encoding> encoding used by hasher - defaults to utf8
-h, --help output usage information
-V, --version output the version number
-f, --file <file> file to bust - required
-o, --outdir <outdir> directory to write new file to
-p, --prefix <prefix> filename prefix - default is base name of file
-n, --noprefix do not use a file prefix
-e, --encoding <encoding> encoding used by hasher - default is utf8
-H, --hash <hash> hash algorithm - default is md5
```

@@ -75,0 +78,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc