Comparing version 0.3.0 to 0.4.0
34
index.js
@@ -6,34 +6,4 @@ /* | ||
*/ | ||
var Gearbox = require('./lib/gearbox').Gearbox; | ||
var Queue = require('./lib/queue').Queue; | ||
var gearbox = exports.gearbox = function(options) { | ||
var box = new Gearbox(options); | ||
box.load({dirname: __dirname + '/lib/tasks'}); | ||
return box; | ||
}; | ||
exports.queue = function(options) { | ||
options = options || {}; | ||
options.gearbox = options.gearbox || gearbox(); | ||
return new Queue(options); | ||
}; | ||
var tasks = [ | ||
'./lib/tasks/concat', | ||
'./lib/tasks/load', | ||
'./lib/tasks/tasks', | ||
'./lib/tasks/core', | ||
'./lib/tasks/write' | ||
]; | ||
tasks.forEach(function(task) { | ||
var mod = require(task), | ||
name; | ||
for (name in mod) { | ||
exports[name] = mod[name]; | ||
} | ||
}); | ||
exports.Registry = require('./lib/registry').Registry; | ||
exports.Queue = require('./lib/queue').Queue; | ||
exports.Blob = require('./lib/blob').Blob; |
/* | ||
* Blob | ||
* | ||
* Loosely based on W3C Blob: | ||
* http://www.w3.org/TR/FileAPI/#dfn-Blob | ||
* https://developer.mozilla.org/en/DOM/Blob | ||
* | ||
* @param parts {Array} Create new Blob from array consisting of Strings/Blobs. | ||
* Copyright (c) 2011-2012, Yahoo! Inc. All rights reserved. | ||
* Copyrights licensed under the New BSD License. | ||
* See the accompanying LICENSE file for terms. | ||
*/ | ||
var Blob = exports.Blob = function Blob(parts, properties) { | ||
parts = parts || []; | ||
properties = properties || {}; | ||
(function(exports) { | ||
/* | ||
* Blob | ||
* | ||
* Loosely based on W3C Blob: | ||
* http://www.w3.org/TR/FileAPI/#dfn-Blob | ||
* https://developer.mozilla.org/en/DOM/Blob | ||
* | ||
* @param parts {String|Blob|Array} Create new Blob from String/Blob or Array of String/Blob. | ||
*/ | ||
var Blob = exports.Blob = function Blob(parts, properties) { | ||
if (parts === undefined) { | ||
parts = []; | ||
} else { | ||
if (!Array.isArray(parts)) { | ||
parts = [parts]; | ||
} | ||
} | ||
this._content = ''; | ||
this._properties = {}; | ||
properties = properties || {}; | ||
var self = this; | ||
parts.forEach(function(part) { | ||
self._content += part; | ||
var content = '', | ||
props = {}; | ||
parts.forEach(function(part) { | ||
content += part; | ||
var attr; | ||
if (typeof part === 'object') { | ||
for (attr in part) { | ||
props[attr] = part[attr]; | ||
} | ||
} | ||
}); | ||
var attr; | ||
if (typeof part === 'object') { | ||
for (attr in part) { | ||
self._properties[attr] = part[attr]; | ||
} | ||
for (attr in properties) { | ||
props[attr] = properties[attr]; | ||
} | ||
}); | ||
var attr; | ||
for (attr in properties) { | ||
this._properties[attr] = properties[attr]; | ||
} | ||
Object.defineProperty(this, '_content', {get: function() { | ||
return content; | ||
}}); | ||
Object.defineProperty(this, 'properties', {get: function() { | ||
return self._properties; | ||
}}); | ||
}; | ||
Object.defineProperty(this, 'properties', {get: function() { | ||
return props; | ||
}}); | ||
}; | ||
Blob.prototype.create = function(parts, properties) { | ||
return new Blob(parts, properties); | ||
}; | ||
Blob.prototype.create = function(parts, properties) { | ||
return new Blob(parts, properties); | ||
}; | ||
Blob.prototype.toString = function() { | ||
return this._content; | ||
}; | ||
Blob.prototype.toString = function() { | ||
return this._content; | ||
}; | ||
})(typeof exports === 'undefined' ? this.gear || (this.gear = {}) : exports); |
138
lib/queue.js
@@ -6,85 +6,79 @@ /* | ||
*/ | ||
var async = require('async'), | ||
Gearbox = require('./gearbox').Gearbox, | ||
Blob = require('./blob').Blob; | ||
(function(exports) { | ||
if (typeof require !== 'undefined') { | ||
var async = require('async'), | ||
Registry = require('./registry').Registry, | ||
Blob = require('./blob').Blob; | ||
} | ||
/* | ||
* Queue | ||
*/ | ||
var Queue = exports.Queue = function Queue(options) { | ||
var self = this; | ||
options = options || {}; | ||
this._registry = options.registry || new Registry({dirname: __dirname + '/tasks'}); | ||
this._queue = [ | ||
function(callback) { | ||
callback(null, []); | ||
} | ||
]; | ||
/* | ||
* Queue | ||
*/ | ||
var Queue = exports.Queue = function Queue(options) { | ||
var self = this; | ||
options = options || {}; | ||
this._gearbox = options.gearbox || new Gearbox(); | ||
this._queue = [ | ||
function(callback) { | ||
callback(null, []); | ||
} | ||
]; | ||
// Add registry tasks | ||
this._registry.tasks.forEach(function(name) { | ||
self[name] = self.task.bind(self, name); | ||
}); | ||
}; | ||
// Add gearbox tasks | ||
this._gearbox.tasks.forEach(function(name) { | ||
self[name] = self.task.bind(self, name); | ||
}); | ||
}; | ||
Queue.prototype._log = function(message) { | ||
console.log(message); | ||
}; | ||
Queue.prototype._log = function(message) { | ||
console.log(message); | ||
}; | ||
Queue.prototype._dispatch = function(name, options, blobs, done) { | ||
var task = this._registry.task(name); | ||
Queue.prototype._dispatch = function(name, options, blobs, done) { | ||
var task = this._gearbox.task(name); | ||
// Deep freeze blobs | ||
blobs.forEach(function(o) { | ||
Object.freeze(o); | ||
for (var prop in o) { | ||
if (!o.hasOwnProperty(prop) || typeof o !== "object" || Object.isFrozen(o)) continue; | ||
freeze(o[prop]); | ||
} | ||
return o; | ||
}); | ||
// Task type determines how blobs are processed | ||
switch (task.type) { | ||
case 'append': // Add blobs to queue | ||
if (options === undefined) { | ||
options = []; | ||
} else { | ||
if (!Array.isArray(options)) { | ||
options = [options]; | ||
// Task type determines how blobs are processed | ||
switch (task.type) { | ||
case 'append': // Add blobs to queue | ||
if (options === undefined) { | ||
options = []; | ||
} else { | ||
if (!Array.isArray(options)) { | ||
options = [options]; | ||
} | ||
} | ||
} | ||
async.map(options, task.bind(this), function(err, results) { | ||
done(err, blobs.concat(results)); | ||
}); | ||
break; | ||
async.map(options, task.bind(this), function(err, results) { | ||
done(err, blobs.concat(results)); | ||
}); | ||
break; | ||
case 'iterate': // Task can look at all blobs at once | ||
task.call(this, options, blobs, done); | ||
break; | ||
case 'iterate': // Task can look at all blobs at once | ||
task.call(this, options, blobs, done); | ||
break; | ||
case 'reduce': // Reduce blobs operating on a per task basis | ||
async.reduce(blobs, new Blob(), task.bind(this, options), function(err, results) { | ||
done(err, [results]); | ||
}); | ||
break; | ||
case 'reduce': // Reduce blobs operating on a per task basis | ||
async.reduce(blobs, new Blob(), task.bind(this, options), function(err, results) { | ||
done(err, [results]); | ||
}); | ||
break; | ||
case 'slice': // Select up to options.length blobs | ||
async.map(blobs.slice(0, Array.isArray(options) ? options.length : 1), task.bind(this, options), done); | ||
break; | ||
case 'slice': // Select up to options.length blobs | ||
async.map(blobs.slice(0, Array.isArray(options) ? options.length : 1), task.bind(this, options), done); | ||
break; | ||
default: // Transform blob on a per task basis | ||
async.map(blobs, task.bind(this, options), done); | ||
break; | ||
} | ||
}; | ||
default: // Transform blob on a per task basis | ||
async.map(blobs, task.bind(this, options), done); | ||
break; | ||
} | ||
}; | ||
Queue.prototype.task = function(name, options) { | ||
this._queue.push(this._dispatch.bind(this, name, options)); | ||
return this; | ||
}; | ||
Queue.prototype.task = function(name, options) { | ||
this._queue.push(this._dispatch.bind(this, name, options)); | ||
return this; | ||
}; | ||
Queue.prototype.run = function(callback) { | ||
async.waterfall(this._queue, callback); | ||
}; | ||
Queue.prototype.run = function(callback) { | ||
async.waterfall(this._queue, callback); | ||
}; | ||
})(typeof exports === 'undefined' ? this.gear || (this.gear = {}) : exports); |
@@ -6,15 +6,17 @@ /* | ||
*/ | ||
/** | ||
* Concatenates blobs. | ||
* | ||
* @param options {Object} Concat options. | ||
* @param options.callback {Function} Callback on each blob. | ||
* @param blobs {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var concat = exports.concat = function concat(options, prev, blob, done) { | ||
options = options || {}; | ||
done(null, blob.create([prev, options.callback ? options.callback(blob) : blob])); | ||
}; | ||
concat.type = 'reduce'; | ||
(function(exports) { | ||
/** | ||
* Concatenates blobs. | ||
* | ||
* @param options {Object} Concat options. | ||
* @param options.callback {Function} Callback on each blob. | ||
* @param blobs {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var concat = exports.concat = function concat(options, prev, blob, done) { | ||
options = options || {}; | ||
done(null, blob.create([prev, options.callback ? options.callback(blob) : blob])); | ||
}; | ||
concat.type = 'reduce'; | ||
concat.browser = true; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
@@ -6,44 +6,49 @@ /* | ||
*/ | ||
/** | ||
* Gets a blob. | ||
* | ||
* @param index {Integer} Index of blobs. | ||
* @param blobs {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var get = exports.get = function get(index, blobs, done) { | ||
done(null, blobs.slice(index, index + 1)); | ||
}; | ||
get.type = 'iterate'; | ||
(function(exports) { | ||
/** | ||
* Gets a blob. | ||
* | ||
* @param index {Integer} Index of blobs. | ||
* @param blobs {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var get = exports.get = function get(index, blobs, done) { | ||
done(null, blobs.slice(index, index + 1)); | ||
}; | ||
get.type = 'iterate'; | ||
get.browser = true; | ||
/** | ||
* Log a string. | ||
* | ||
* @param string {String} String to log. | ||
* @param blob {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var log = exports.log = function log(string, blobs, done) { | ||
this._log(string); | ||
done(null, blobs); | ||
}; | ||
log.type = 'iterate'; | ||
/** | ||
* Log a string. | ||
* | ||
* @param string {String} String to log. | ||
* @param blob {Array} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var log = exports.log = function log(string, blobs, done) { | ||
this._log(string); | ||
done(null, blobs); | ||
}; | ||
log.type = 'iterate'; | ||
log.browser = true; | ||
/** | ||
* Inspects blobs. | ||
* | ||
* @param options {Object} Ignored. | ||
* @param blob {Object} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var inspect = exports.inspect = function inspect(options, blobs, done) { | ||
var self = this; | ||
this._log('INSPECT: ' + blobs.length + (blobs.length > 1 ? ' blobs' : ' blob')); | ||
/** | ||
* Inspects blobs. | ||
* | ||
* @param options {Object} Ignored. | ||
* @param blob {Object} Incoming blobs. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var inspect = exports.inspect = function inspect(options, blobs, done) { | ||
var self = this; | ||
this._log('INSPECT: ' + blobs.length + (blobs.length > 1 ? ' blobs' : ' blob')); | ||
blobs.forEach(function(blob, index) { | ||
self._log(blob); | ||
}); | ||
blobs.forEach(function(blob, index) { | ||
self._log(blob.toString()); | ||
}); | ||
done(null, blobs); | ||
}; | ||
inspect.type = 'iterate'; | ||
done(null, blobs); | ||
}; | ||
inspect.type = 'iterate'; | ||
inspect.browser = true; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
@@ -6,22 +6,26 @@ /* | ||
*/ | ||
var fs = require('fs'), | ||
Blob = require('../blob').Blob; | ||
(function(exports) { | ||
if (typeof require !== 'undefined') { | ||
var fs = require('fs'), | ||
Blob = require('../blob').Blob; | ||
} | ||
/** | ||
* Loads blobs from different sources. | ||
* TODO: Add more sources i.e. (url). | ||
* | ||
* @param options {Object} File options or filename. | ||
* @param options.file {Object} Filename to load. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var load = exports.load = function load(options, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
/** | ||
* Loads blobs from different sources. | ||
* TODO: Add more sources i.e. (url). | ||
* | ||
* @param options {Object} File options or filename. | ||
* @param options.file {Object} Filename to load. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var load = exports.load = function load(options, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
if (options.file) { | ||
fs.readFile(options.file, function(err, data) { | ||
done(err, new Blob([data], {name: options.file})); | ||
}); | ||
} | ||
}; | ||
load.type = 'append'; | ||
if (options.file) { | ||
fs.readFile(options.file, function(err, data) { | ||
done(err, new Blob(data, {name: options.file})); | ||
}); | ||
} | ||
}; | ||
load.type = 'append'; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
@@ -6,40 +6,44 @@ /* | ||
*/ | ||
var async = require('async'); | ||
(function(exports) { | ||
if (typeof require !== 'undefined') { | ||
var async = require('async'); | ||
} | ||
/** | ||
* Advanced flow execution. | ||
* | ||
* @param workflow {String} TODO. | ||
* @param blob {Object} Incoming blob. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var tasks = exports.tasks = function tasks(workflow, blobs, done) { | ||
var item, | ||
requires, | ||
fn, | ||
auto = {}, | ||
self = this; | ||
/** | ||
* Advanced flow execution. | ||
* | ||
* @param workflow {String} TODO. | ||
* @param blob {Object} Incoming blob. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var tasks = exports.tasks = function tasks(workflow, blobs, done) { | ||
var item, | ||
requires, | ||
fn, | ||
auto = {}, | ||
self = this; | ||
function task(name, options, requires) { | ||
return function(callback, result) { | ||
var new_blobs = requires.length ? [] : blobs; | ||
result = result || []; | ||
function task(name, options, requires) { | ||
return function(callback, result) { | ||
var new_blobs = requires.length ? [] : blobs; | ||
result = result || []; | ||
// Concat dependency blobs in order of requires array | ||
requires.forEach(function(item) { | ||
new_blobs = new_blobs.concat(result[item]); | ||
}); | ||
// Concat dependency blobs in order of requires array | ||
requires.forEach(function(item) { | ||
new_blobs = new_blobs.concat(result[item]); | ||
}); | ||
self._dispatch(name, options, new_blobs, callback); | ||
}; | ||
} | ||
self._dispatch(name, options, new_blobs, callback); | ||
}; | ||
} | ||
for (item in workflow) { | ||
requires = workflow[item].requires; | ||
fn = task(workflow[item].task, workflow[item].options, requires || []); | ||
auto[item] = requires ? requires.concat(fn) : fn; | ||
} | ||
async.auto(auto, done); | ||
}; | ||
tasks.type = 'iterate'; | ||
for (item in workflow) { | ||
requires = workflow[item].requires; | ||
fn = task(workflow[item].task, workflow[item].options, requires || []); | ||
auto[item] = requires ? requires.concat(fn) : fn; | ||
} | ||
async.auto(auto, done); | ||
}; | ||
tasks.type = 'iterate'; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
@@ -6,48 +6,52 @@ /* | ||
*/ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
mkdirp = require('mkdirp').mkdirp, | ||
Crypto = require('crypto'); | ||
/** | ||
* Write the blob to disk with an optional checksum in the filename. | ||
* | ||
* @param options {Object} Write options or filename. | ||
* @param options.file {String} Filename to write. | ||
* @param blob {Object} Incoming blob. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var write = exports.write = function write(options, blob, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
var dirname = path.resolve(path.dirname(options.file)), | ||
checksum; | ||
function writeFile(name, b) { | ||
fs.writeFile(name, blob.toString(), function(err) { | ||
done(err, blob.create([blob], {name: name})); | ||
}); | ||
(function(exports) { | ||
if (typeof require !== 'undefined') { | ||
var fs = require('fs'), | ||
path = require('path'), | ||
mkdirp = require('mkdirp').mkdirp, | ||
Crypto = require('crypto'); | ||
} | ||
/** | ||
* Write the blob to disk with an optional checksum in the filename. | ||
* | ||
* @param options {Object} Write options or filename. | ||
* @param options.file {String} Filename to write. | ||
* @param blob {Object} Incoming blob. | ||
* @param done {Function} Callback on task completion. | ||
*/ | ||
var write = exports.write = function write(options, blob, done) { | ||
options = (typeof options === 'string') ? {file: options} : options; | ||
if (options.file.indexOf('{checksum}') > -1) { // Replace {checksum} with md5 string | ||
checksum = Crypto.createHash('md5'); | ||
checksum.update(blob.toString()); | ||
options.file = options.file.replace('{checksum}', checksum.digest('hex')); | ||
} | ||
var dirname = path.resolve(path.dirname(options.file)), | ||
checksum; | ||
path.exists(dirname, function(exists) { | ||
if (!exists) { | ||
mkdirp(dirname, '0755', function(err) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
writeFile(options.file, blob); | ||
} | ||
function writeFile(name, b) { | ||
fs.writeFile(name, blob.toString(), function(err) { | ||
done(err, blob.create(blob, {name: name})); | ||
}); | ||
} | ||
else { | ||
writeFile(options.file, blob); | ||
if (options.file.indexOf('{checksum}') > -1) { // Replace {checksum} with md5 string | ||
checksum = Crypto.createHash('md5'); | ||
checksum.update(blob.toString()); | ||
options.file = options.file.replace('{checksum}', checksum.digest('hex')); | ||
} | ||
}); | ||
}; | ||
write.type = 'slice'; | ||
path.exists(dirname, function(exists) { | ||
if (!exists) { | ||
mkdirp(dirname, '0755', function(err) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
writeFile(options.file, blob); | ||
} | ||
}); | ||
} | ||
else { | ||
writeFile(options.file, blob); | ||
} | ||
}); | ||
}; | ||
write.type = 'slice'; | ||
})(typeof exports === 'undefined' ? this.tasks || (this.tasks = {}) : exports); |
{ | ||
"name": "gear", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Gear.js - Task-based build system.", | ||
@@ -5,0 +5,0 @@ "author": "Stephen Murphy <stephen@hypernaut.com>", |
@@ -28,3 +28,3 @@ # Gear.js | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.load('foo.js') | ||
@@ -40,3 +40,3 @@ .log('read foo.js') | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.load(['foo.js', {file: 'bar.js'}, 'baz.js']) | ||
@@ -52,3 +52,3 @@ .log('read foo.js') | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.load('foo.js') | ||
@@ -69,7 +69,7 @@ .log('Complex Task') | ||
* [queue](#Core.queue) | ||
* [Queue](#Core.Queue) | ||
* [Queue.task](#Core.Queue.task) | ||
* [Queue.run](#Core.Queue.run) | ||
* [gearbox](#Core.gearbox) | ||
* [Gearbox.load](#Core.Gearbox.load) | ||
* [Registry](#Core.Registry) | ||
* [Registry.load](#Core.Registry.load) | ||
@@ -92,10 +92,10 @@ ### [Core Tasks](#Tasks) | ||
<a name="Core.queue" /> | ||
### queue(options) | ||
<a name="Core.Queue" /> | ||
### Queue(options) | ||
Creates a new Queue instance. | ||
Queue constructor. | ||
__Arguments__ | ||
* options.gearbox - Gearbox loaded with available tasks. | ||
* options.registry - Registry loaded with available tasks. | ||
@@ -105,3 +105,3 @@ __Example__ | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.log('test') | ||
@@ -116,7 +116,7 @@ .run(); | ||
Helper method to run the specified task. Preferred task execution style is to call the task directly i.e. `.inspect` instead of `.task('inspect')`. | ||
Helper method to run the specified task. Preferred task execution style is to call the task directly i.e. `inspect()` instead of `task('inspect')`. | ||
__Arguments__ | ||
* name - Name of task in gearbox. | ||
* name - Name of task in registry. | ||
@@ -126,3 +126,3 @@ __Example__ | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.task('log', 'Hello, world!') | ||
@@ -146,3 +146,3 @@ .run(); | ||
```javascript | ||
gear.queue() | ||
new gear.Queue() | ||
.log('test') | ||
@@ -154,6 +154,6 @@ .run(); | ||
<a name="Core.gearbox" /> | ||
### gearbox() | ||
<a name="Core.Registry" /> | ||
### Registry() | ||
Creates a new Gearbox instance. Gearboxes contain all available tasks. | ||
Creates a new Registry instance. Registries contain available tasks. | ||
@@ -167,3 +167,3 @@ __Arguments__ | ||
```javascript | ||
gear.gearbox(); | ||
gear.Registry(); | ||
``` | ||
@@ -173,4 +173,4 @@ | ||
<a name="Core.Gearbox.load" /> | ||
### Gearbox.load(options) | ||
<a name="Core.Registry.load" /> | ||
### Registry.load(options) | ||
@@ -188,3 +188,3 @@ Load tasks from NPM, directory, or file. | ||
```javascript | ||
gear.gearbox().load({dirname: 'foo'}); | ||
gear.Registry().load({dirname: 'foo'}); | ||
``` | ||
@@ -326,7 +326,7 @@ | ||
__Example__ | ||
``` | ||
```javascript | ||
// example.js | ||
// Example task replaces each blob with a string. | ||
// Example task creates new blob containing `string` | ||
exports.example = function(string, blob, done) { | ||
done(null, {body: string}); | ||
done(null, blob.create(string)); // blob.create() is equivalent to new Blob() | ||
}; | ||
@@ -338,3 +338,3 @@ ``` | ||
```javascript | ||
gear.queue({gearbox: gear.gearbox({filename: 'example.js'})}) | ||
new gear.Queue({registry: new gear.Registry({filename: 'example.js'})}) | ||
.example('EXAMPLE') | ||
@@ -341,0 +341,0 @@ .run(); |
@@ -5,4 +5,4 @@ var should = require('should'), | ||
fixtures = { | ||
prev: new Blob(['abc']), | ||
cur: new Blob(['def']) | ||
prev: new Blob('abc'), | ||
cur: new Blob('def') | ||
}; | ||
@@ -9,0 +9,0 @@ |
@@ -13,3 +13,3 @@ var should = require('should'), | ||
it('should handle append tasks', function(done) { | ||
gear.queue() | ||
new gear.Queue() | ||
.load(fixtures.files) | ||
@@ -24,3 +24,3 @@ .load(fixtures.file) | ||
it('should handle tasks called with array options', function(done) { | ||
gear.queue() | ||
new gear.Queue() | ||
.load(fixtures.files) | ||
@@ -34,3 +34,3 @@ .concat() | ||
it('should execute chained tasks', function(done) { | ||
gear.queue() | ||
new gear.Queue() | ||
.load(fixtures.file) | ||
@@ -44,3 +44,3 @@ .concat() | ||
it('should handle errors', function(done) { | ||
gear.queue() | ||
new gear.Queue() | ||
.load(fixtures.missing_file) | ||
@@ -57,3 +57,3 @@ .concat() | ||
it('should run empty queues', function(done) { | ||
gear.queue() | ||
new gear.Queue() | ||
.run(function(err, results) { | ||
@@ -60,0 +60,0 @@ done(err); |
@@ -11,5 +11,5 @@ var should = require('should'), | ||
describe('gear.queue()', function() { | ||
describe('Queue()', function() { | ||
it('should wrap task correctly', function() { | ||
gear.queue().tasks({ | ||
new gear.Queue().tasks({ | ||
read_files: {task: 'load', options: fixtures.files}, | ||
@@ -27,3 +27,3 @@ concat_files: {requires: ['read_files'], task: 'concat'}, | ||
it('should handle err', function(done) { | ||
var queue = gear.queue(); | ||
var queue = new gear.Queue(); | ||
@@ -39,3 +39,3 @@ tasks.call(queue, { | ||
it('should execute complex tasks', function(done) { | ||
var queue = gear.queue(); | ||
var queue = new gear.Queue(); | ||
@@ -42,0 +42,0 @@ tasks.call(queue, { |
@@ -10,3 +10,3 @@ var path = require('path'), | ||
checksum_replaced: 'testing/write_900150983cd24fb0d6963f7d28e17f72.txt', | ||
blob: new Blob(['abc']) | ||
blob: new Blob('abc') | ||
}; | ||
@@ -13,0 +13,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
30293
29
594