diff --git a/build/build.js b/build/build.js index 9bfce65..ddb30ab 100644 --- a/build/build.js +++ b/build/build.js @@ -3,14 +3,14 @@ module.exports = function(grunt) { var async = require('async'), fs = require('fs'); - var version = grunt.config.get("pasteup.version"); + var version = grunt.config.get("pasteup.version").toString(); function buildDocumentationPages(cb) { var template = grunt.file.read('build/templates/default.html'); async.forEach(fs.readdirSync('docs'), function(name, cb) { var ft = grunt.file.read('docs/' + name, 'utf8'); - var f = grunt.template.process(ft.toString(), {'pasteupVersion': version}); - var output = grunt.template.process(template, {'name':name, 'code':ft, 'pasteupVersion': version}); + var f = grunt.template.process(ft.toString(), { data: {'pasteupVersion': version} }); + var output = grunt.template.process(template, { data: {'name':name, 'code':ft, 'pasteupVersion': version} }); grunt.file.write('build/deployable_artefact/' + name, output); cb(); }, function() { @@ -30,7 +30,7 @@ module.exports = function(grunt) { cb(); }, function() { // Render modules into template. - var output = grunt.template.process(template, {'modules': modules, 'pasteupVersion': version}); + var output = grunt.template.process(template, { data: {'modules': modules, 'pasteupVersion': version} }); grunt.file.write('build/deployable_artefact/modules.html', output); cb(); }); @@ -42,7 +42,7 @@ module.exports = function(grunt) { // Get each module and create its own page in the docs. async.forEach(fs.readdirSync('html/module'), function(name, cb) { var module = grunt.file.read('html/module/' + name, 'utf8'); - var output = grunt.template.process(template, {'name': name, 'code': module, 'pasteupVersion': version}); + var output = grunt.template.process(template, { data: {'name': name, 'code': module, 'pasteupVersion': version} }); grunt.file.write('build/deployable_artefact/modules/' + name, output); cb(); }, function() { diff --git a/build/deploy.js b/build/deploy.js index 363e140..e56a63e 100755 --- a/build/deploy.js +++ b/build/deploy.js @@ -90,9 +90,9 @@ function deploy(command, callback) { Returns the most recent version number in /version */ function getVersionNumber() { - var f = fs.readFileSync(__dirname + '/../versions', 'utf8'); + var f = fs.readFileSync(__dirname + '/../component.json', 'utf8'); var data = JSON.parse(f.toString()); - return data['versions'].pop(); + return data['version']; } function getFarFutureExpiryDate() { diff --git a/build/templates/default.html b/build/templates/default.html index d105ae6..0fd44e5 100644 --- a/build/templates/default.html +++ b/build/templates/default.html @@ -78,7 +78,7 @@ - + \ No newline at end of file diff --git a/build/templates/library.html b/build/templates/library.html index d652a7a..ba80dd5 100644 --- a/build/templates/library.html +++ b/build/templates/library.html @@ -106,7 +106,7 @@

<%= module.name %>

- + \ No newline at end of file diff --git a/build/templates/module.html b/build/templates/module.html index 28b5583..94b9c69 100644 --- a/build/templates/module.html +++ b/build/templates/module.html @@ -52,7 +52,7 @@ - + \ No newline at end of file diff --git a/docs/javascript.html b/docs/javascript.html index e609c8f..f1be33e 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -6,8 +6,8 @@

Standard libraries

RequireJs

diff --git a/node_modules/grunt-contrib-copy/docs/examples.md b/node_modules/grunt-contrib-copy/docs/examples.md deleted file mode 100644 index 33ea4a3..0000000 --- a/node_modules/grunt-contrib-copy/docs/examples.md +++ /dev/null @@ -1,13 +0,0 @@ -```js -copy: { - dist: { - files: { - "path/to/directory/": "path/to/source/*", // includes files in dir - "path/to/directory/": "path/to/source/**", // includes files in dir and subdirs - "path/to/project-<%= pkg.version %>/": "path/to/source/**", // variables in destination - "path/to/directory/": ["path/to/sources/*.js", "path/to/more/*.js"], // include JS files in two diff dirs - "path/to/filename.ext": "path/to/source.ext" - } - } -} -``` \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/docs/options.md b/node_modules/grunt-contrib-copy/docs/options.md deleted file mode 100644 index 6947a1b..0000000 --- a/node_modules/grunt-contrib-copy/docs/options.md +++ /dev/null @@ -1,48 +0,0 @@ -##### files ```object``` - -This defines what files this task will copy and should contain key:value pairs. - -The key (destination) should be an unique path (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)). - -As of v0.3.0, when copying to a directory you must add a trailing slash to the destination due to added support of single file copy. - -##### options ```object``` - -This controls how this task operates and should contain key:value pairs, see options below. - -#### Options - -##### basePath ```string``` - -This option adjusts the folder structure when copied to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern. - -##### flatten ```boolean``` - -This option performs a flat copy that dumps all the files into the root of the destination directory, overwriting files if they exist. - -##### processName ```function``` - -This option accepts a function that adjusts the filename of the copied file. Function is passed filename and should return a string. - -``` javascript -options: { - processName: function(filename) { - if (filename == "test.jpg") { - filename = "newname.jpg"; - } - return filename; - } -} -``` - -##### processContent ```function``` - -This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied. - -##### processContentExclude ```string``` - -This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed. - -##### minimatch ```object``` - -These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options) \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/grunt.js b/node_modules/grunt-contrib-copy/grunt.js deleted file mode 100644 index c28d870..0000000 --- a/node_modules/grunt-contrib-copy/grunt.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * grunt-contrib-copy - * http://gruntjs.com/ - * - * Copyright (c) 2012 Chris Talkington, contributors - * Licensed under the MIT license. - * https://github.com/gruntjs/grunt-contrib-copy/blob/master/LICENSE-MIT - */ - -module.exports = function(grunt) { - 'use strict'; - - // Project configuration. - grunt.initConfig({ - test_vars: { - name: 'grunt-contrib-copy', - version: '0.1.0' - }, - - lint: { - all: ['grunt.js', 'tasks/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Before generating any new files, remove any previously-created files. - clean: { - test: ['tmp'] - }, - - // Configuration to be run (and then tested). - copy: { - test: { - files: { - 'tmp/copy_test_files/': ['test/fixtures/*'], - 'tmp/copy_test_v<%= test_vars.version %>/': ['test/fixtures/**'] - } - }, - - flatten: { - options: { - flatten: true - }, - files: { - 'tmp/copy_test_flatten/': ['test/fixtures/**'] - } - }, - - minimatch: { - options: { - minimatch: { - dot: true - } - }, - files: { - 'tmp/copy_minimatch/': ['test/fixtures/*'] - } - }, - - single: { - files: { - 'tmp/single.js': ['test/fixtures/test.js'] - } - } - }, - - // Unit tests. - nodeunit: { - tasks: ['test/*_test.js'] - } - }); - - // Actually load this plugin's task(s). - grunt.loadTasks('tasks'); - - // The clean plugin helps in testing. - grunt.loadNpmTasks('grunt-contrib-clean'); - - // Whenever the 'test' task is run, first clean the 'tmp' dir, then run this - // plugin's task(s), then test the result. - grunt.renameTask('test', 'nodeunit'); - grunt.registerTask('test', 'clean copy nodeunit'); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.gitattributes b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.npmignore b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.npmignore deleted file mode 100644 index 5cb6bfd..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -npm-debug.log -tmp \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.travis.yml b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.travis.yml deleted file mode 100644 index baa0031..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.8 diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/AUTHORS b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/AUTHORS deleted file mode 100644 index 5de1a92..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Tyler Kellen (http://goingslowly.com/) -Chris Talkington (http://christalkington.com/) -Larry Davis (http://lazd.net/) -Sindre Sorhus (http://sindresorhus.com) diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/CHANGELOG b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/CHANGELOG deleted file mode 100644 index 3350622..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/CHANGELOG +++ /dev/null @@ -1,20 +0,0 @@ -v0.3.1: - date: 2012-10-29 - changes: - - Tweaked findBasePath to handle single dot differently. - - Start testing with Travis. - - Docs cleanup. -v0.3.0: - date: 2012-09-24 - changes: - - Added findBasePath, buildIndividualDest, isIndividualDest, optsToArgs. - - Refactored tests. - - Automatically parse templates in options. -v0.2.1: - date: 2012-09-14 - changes: - - Added non-destuctive namespace declarations. -v0.2.0: - date: 2012-09-10 - changes: - - Refactored from grunt-contrib into individual repo. \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/LICENSE-MIT b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/LICENSE-MIT deleted file mode 100644 index 358b067..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 Tyler Kellen, contributors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/README.md b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/README.md deleted file mode 100644 index 8ece0e9..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib) - -> Common functionality shared across grunt-contrib tasks. - -The purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks. - -**These APIs should be considered highly unstable. Depend on them at your own risk!** - -_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._ - -### Helper Functions - -#### buildIndividualDest(dest, srcFile, basePath, flatten) - -This helper is used to build a destination filepath for tasks supporting individual compiling. - -#### findBasePath(srcFiles) - -This helper is used to take an array of filepaths and find the common base directory. - -#### getNamespaceDeclaration(ns) - -This helper is used to build JS namespace declarations. - -#### isIndividualDest(dest) - -This helper is used to detect if a destination filepath triggers individual compiling. - -#### normalizeMultiTaskFiles(data, target) - -This helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does. - -#### options(data, defaults) - -This helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release. - -Contrib tasks are in the process of being updated to check for the new helper first. - -#### optsToArgs(options) - -Convert an object to an array of CLI arguments, which can be used with `child_process.spawn()`. - -```js -// Example -{ - fooBar: 'a', // ['--foo-bar', 'a'] - fooBar: 1, // ['--foo-bar', '1'] - fooBar: true, // ['--foo-bar'] - fooBar: false, // - fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b'] -} -``` - --- - -*Lib submitted by [Tyler Kellen](https://goingslowly.com/).* \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/grunt.js b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/grunt.js deleted file mode 100644 index 12dbdbe..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/grunt.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -module.exports = function(grunt) { - 'use strict'; - - grunt.initConfig({ - test_vars: { - source: 'source/' - }, - - test_task: { - options: { - param: 'task', - param2: 'task', - template: '<%= test_vars.source %>', - data: { - template: ['<%= test_vars.source %>'] - } - }, - target: { - options: { - param: 'target' - } - } - }, - - lint: { - all: ['grunt.js', 'lib/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Unit tests. - test: { - tasks: ['test/*_test.js'] - } - }); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/lib/contrib.js b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/lib/contrib.js deleted file mode 100644 index 7bea6eb..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/lib/contrib.js +++ /dev/null @@ -1,200 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -exports.init = function(grunt) { - 'use strict'; - - var exports = {}; - - // TODO: ditch this when grunt v0.4 is released - grunt.util = grunt.util || grunt.utils; - - var path = require('path'); - - // TODO: remove if/when we officially drop node <= 0.7.9 - path.sep = path.sep || path.normalize('/'); - - exports.buildIndividualDest = function(dest, srcFile, basePath, flatten) { - dest = path.normalize(dest); - srcFile = path.normalize(srcFile); - - var newDest = path.dirname(dest); - var newName = path.basename(srcFile, path.extname(srcFile)) + path.extname(dest); - var relative = path.dirname(srcFile); - - if (flatten) { - relative = ''; - } else if (basePath && basePath.length >= 1) { - relative = grunt.util._(relative).strRight(basePath).trim(path.sep); - } - - // make paths outside grunts working dir relative - relative = relative.replace(/\.\.(\/|\\)/g, ''); - - return path.join(newDest, relative, newName); - }; - - exports.findBasePath = function(srcFiles, basePath) { - if (grunt.util.kindOf(basePath) === 'string' && basePath.length >= 1) { - return grunt.util._(path.normalize(basePath)).trim(path.sep); - } - - var foundPath; - var basePaths = []; - var dirName; - - srcFiles.forEach(function(srcFile) { - srcFile = path.normalize(srcFile); - dirName = path.dirname(srcFile); - - basePaths.push(dirName.split(path.sep)); - }); - - basePaths = grunt.util._.intersection.apply([], basePaths); - - foundPath = path.join.apply(path, basePaths); - - if (foundPath === '.') { - foundPath = ''; - } - - return foundPath; - }; - - exports.getNamespaceDeclaration = function(ns) { - var output = []; - var curPath = 'this'; - if (ns !== 'this') { - var nsParts = ns.split('.'); - nsParts.forEach(function(curPart, index) { - if (curPart !== 'this') { - curPath += '[' + JSON.stringify(curPart) + ']'; - output.push(curPath + ' = ' + curPath + ' || {};'); - } - }); - } - - return { - namespace: curPath, - declaration: output.join('\n') - }; - }; - - exports.isIndividualDest = function(dest) { - if (grunt.util._.startsWith(path.basename(dest), '*')) { - return true; - } else { - return false; - } - }; - - // TODO: ditch this when grunt v0.4 is released - // Temporary helper for normalizing files object - exports.normalizeMultiTaskFiles = function(data, target) { - var prop, obj; - var files = []; - if (grunt.util.kindOf(data) === 'object') { - if ('src' in data || 'dest' in data) { - obj = {}; - if ('src' in data) { obj.src = data.src; } - if ('dest' in data) { obj.dest = data.dest; } - files.push(obj); - } else if (grunt.util.kindOf(data.files) === 'object') { - for (prop in data.files) { - files.push({src: data.files[prop], dest: prop}); - } - } else if (Array.isArray(data.files)) { - data.files.forEach(function(obj) { - var prop; - if ('src' in obj || 'dest' in obj) { - files.push(obj); - } else { - for (prop in obj) { - files.push({src: obj[prop], dest: prop}); - } - } - }); - } - } else { - files.push({src: data, dest: target}); - } - - // Process each normalized file object as a template. - files.forEach(function(obj) { - // Process src as a template (recursively, if necessary). - if ('src' in obj) { - obj.src = grunt.util.recurse(obj.src, function(src) { - if (typeof src !== 'string') { return src; } - return grunt.template.process(src); - }); - } - if ('dest' in obj) { - // Process dest as a template. - obj.dest = grunt.template.process(obj.dest); - } - }); - - return files; - }; - - // Helper for consistent options key access across contrib tasks. - exports.options = function(data, defaults) { - var global_target = data.target ? grunt.config(['options', data.name, data.target]) : null; - var global_task = grunt.config(['options', data.name]); - - if (global_task || global_target) { - grunt.fail.warn('root level [options] key will be unsupported in grunt v0.4. please consider using task and target options.'); - } - - var target = data.target ? grunt.config([data.name, data.target, 'options']) : null; - var task = grunt.config([data.name, 'options']); - - var options = grunt.util._.defaults({}, target, task, global_target, global_task, defaults); - - return grunt.util.recurse(options, function(value) { - if (typeof value !== 'string') { return value; } - - return grunt.template.process(value); - }); - }; - - // Convert an object to an array of CLI arguments - exports.optsToArgs = function(options) { - var args = []; - - Object.keys(options).forEach(function(flag) { - var val = options[flag]; - - flag = flag.replace(/[A-Z]/g, function(match) { - return '-' + match.toLowerCase(); - }); - - if (val === true) { - args.push('--' + flag); - } - - if (grunt.util._.isString(val)) { - args.push('--' + flag, val); - } - - if (grunt.util._.isNumber(val)) { - args.push('--' + flag, '' + val); - } - - if (grunt.util._.isArray(val)) { - val.forEach(function(arrVal) { - args.push('--' + flag, arrVal); - }); - } - }); - - return args; - }; - - return exports; -}; diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/package.json b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/package.json deleted file mode 100644 index 4d112b0..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "grunt-lib-contrib", - "description": "Common functionality shared across grunt-contrib tasks.", - "version": "0.3.1", - "homepage": "http://github.com/gruntjs/grunt-lib-contrib", - "author": { - "name": "Grunt Team", - "url": "http://gruntjs.com/" - }, - "repository": { - "type": "git", - "url": "git://github.com/gruntjs/grunt-lib-contrib.git" - }, - "bugs": { - "url": "https://github.com/gruntjs/grunt-lib-contrib/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/gruntjs/grunt-lib-contrib/blob/master/LICENSE-MIT" - } - ], - "engines": { - "node": ">= 0.6.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "grunt": "~0.3.15" - }, - "main": "lib/contrib", - "contributors": [ - { - "name": "Tyler Kellen", - "url": "http://goingslowly.com/" - }, - { - "name": "Chris Talkington", - "url": "http://christalkington.com/" - }, - { - "name": "Larry Davis", - "url": "http://lazd.net/" - }, - { - "name": "Sindre Sorhus", - "url": "http://sindresorhus.com" - } - ], - "readme": "# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib)\n\n> Common functionality shared across grunt-contrib tasks.\n\nThe purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks.\n\n**These APIs should be considered highly unstable. Depend on them at your own risk!**\n\n_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._\n\n### Helper Functions\n\n#### buildIndividualDest(dest, srcFile, basePath, flatten)\n\nThis helper is used to build a destination filepath for tasks supporting individual compiling.\n\n#### findBasePath(srcFiles)\n\nThis helper is used to take an array of filepaths and find the common base directory.\n\n#### getNamespaceDeclaration(ns)\n\nThis helper is used to build JS namespace declarations.\n\n#### isIndividualDest(dest)\n\nThis helper is used to detect if a destination filepath triggers individual compiling.\n\n#### normalizeMultiTaskFiles(data, target)\n\nThis helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does.\n\n#### options(data, defaults)\n\nThis helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release.\n\nContrib tasks are in the process of being updated to check for the new helper first.\n\n#### optsToArgs(options)\n\nConvert an object to an array of CLI arguments, which can be used with `child_process.spawn()`.\n\n```js\n// Example\n{\n fooBar: 'a', // ['--foo-bar', 'a']\n fooBar: 1, // ['--foo-bar', '1']\n fooBar: true, // ['--foo-bar']\n fooBar: false, //\n fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b']\n}\n```\n\n--\n\n*Lib submitted by [Tyler Kellen](https://goingslowly.com/).*", - "readmeFilename": "README.md", - "_id": "grunt-lib-contrib@0.3.1", - "_from": "grunt-lib-contrib@~0.3.0" -} diff --git a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/test/lib_test.js b/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/test/lib_test.js deleted file mode 100644 index d362b2a..0000000 --- a/node_modules/grunt-contrib-copy/node_modules/grunt-lib-contrib/test/lib_test.js +++ /dev/null @@ -1,127 +0,0 @@ -var grunt = require('grunt'); -var helper = require('../lib/contrib.js').init(grunt); - -exports.lib = { - findBasePath: function(test) { - 'use strict'; - var path = require('path'); - - test.expect(3); - - var actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'dir1/dir2/dir3/dir4/file.ext']); - var expected = path.normalize('dir1/dir2'); - test.equal(expected, actual, 'should detect basePath from array of filepaths.'); - - actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'file.ext'], 'dir1'); - expected = 'dir1'; - test.equal(expected, actual, 'should default to passed basePath if valid'); - - actual = helper.findBasePath(['.dir1/dir2', '.dir1/dir2/another.ext', '.dir1/dir2/dir3/dir4/file.ext', 'file.ext']); - expected = ''; - test.equal(expected, actual, 'should return empty string if foundPath is a single dot (helps with dotfiles)'); - - test.done(); - }, - getNamespaceDeclaration: function(test) { - 'use strict'; - - test.expect(10); - - // Both test should result in this[JST] - var expected = { - namespace: 'this["JST"]', - declaration: 'this["JST"] = this["JST"] || {};' - }; - - var actual = helper.getNamespaceDeclaration("this.JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - actual = helper.getNamespaceDeclaration("JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Templates should be declared globally if this provided - expected = { - namespace: "this", - declaration: "" - }; - - actual = helper.getNamespaceDeclaration("this"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Nested namespace declaration - expected = { - namespace: 'this["GUI"]["Templates"]["Main"]', - declaration: 'this["GUI"] = this["GUI"] || {};\n' + - 'this["GUI"]["Templates"] = this["GUI"]["Templates"] || {};\n' + - 'this["GUI"]["Templates"]["Main"] = this["GUI"]["Templates"]["Main"] || {};' - }; - - actual = helper.getNamespaceDeclaration("GUI.Templates.Main"); - test.equal(expected.namespace, actual.namespace, 'namespace incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration incorrect'); - - // Namespace that contains square brackets - expected = { - namespace: 'this["main"]["[test]"]["[test2]"]', - declaration: 'this["main"] = this["main"] || {};\n' + - 'this["main"]["[test]"] = this["main"]["[test]"] || {};\n' + - 'this["main"]["[test]"]["[test2]"] = this["main"]["[test]"]["[test2]"] || {};' - }; - - actual = helper.getNamespaceDeclaration("main.[test].[test2]"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - test.done(); - }, - options: function(test) { - 'use strict'; - - test.expect(5); - - var options = helper.options({name: 'test_task', target: 'target'}, {required: 'default'}); - - var actual = options.param; - var expected = 'target'; - test.equal(expected, actual, 'should allow target options key to override task'); - - actual = options.param2; - expected = 'task'; - test.equal(expected, actual, 'should set default task options that can be overriden by target options'); - - actual = options.required; - expected = 'default'; - test.equal(expected, actual, 'should allow task to define default values'); - - actual = options.template; - expected = 'source/'; - test.equal(expected, actual, 'should automatically process template vars'); - - actual = options.data.template; - expected = 'source/'; - test.equal(expected, actual, 'should process template vars recursively'); - - test.done(); - }, - optsToArgs: function(test) { - 'use strict'; - - test.expect(1); - - var fixture = { - key: 'a', - key2: 1, - key3: true, - key4: false, - key5: ['a', 'b'] - }; - var expected = ['--key', 'a', '--key2', '1', '--key3', '--key5', 'a', '--key5', 'b' ].toString(); - var actual = helper.optsToArgs(fixture).toString(); - test.equal(expected, actual, 'should convert object to array of CLI arguments'); - - test.done(); - } -}; diff --git a/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/.hidden b/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/.hidden deleted file mode 100644 index a112b59..0000000 --- a/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/.hidden +++ /dev/null @@ -1 +0,0 @@ -#This is a hidden file!!! \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/test.js b/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/test.js deleted file mode 100644 index 68bec77..0000000 --- a/node_modules/grunt-contrib-copy/test/expected/copy_minimatch/test.js +++ /dev/null @@ -1 +0,0 @@ -$(document).ready(function(){}); \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/folder_two/two.js b/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/folder_two/two.js deleted file mode 100644 index 57ec08e..0000000 --- a/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/folder_two/two.js +++ /dev/null @@ -1 +0,0 @@ -$(document).ready(function(){jQuery}); \ No newline at end of file diff --git a/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/test.js b/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/test.js deleted file mode 100644 index 68bec77..0000000 --- a/node_modules/grunt-contrib-copy/test/expected/copy_test_v0.1.0/test.js +++ /dev/null @@ -1 +0,0 @@ -$(document).ready(function(){}); \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/docs/examples.md b/node_modules/grunt-contrib-less/docs/examples.md deleted file mode 100644 index ed2aff6..0000000 --- a/node_modules/grunt-contrib-less/docs/examples.md +++ /dev/null @@ -1,21 +0,0 @@ -```js -less: { - development: { - options: { - paths: ["assets/css"] - }, - files: { - "path/to/result.css": "path/to/source.less" - } - }, - production: { - options: { - paths: ["assets/css"], - yuicompress: true - }, - files: { - "path/to/result.css": "path/to/source.less" - } - } -} -``` \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/docs/options.md b/node_modules/grunt-contrib-less/docs/options.md deleted file mode 100644 index 462e769..0000000 --- a/node_modules/grunt-contrib-less/docs/options.md +++ /dev/null @@ -1,25 +0,0 @@ -##### files ```object``` - -This defines what files this task will process and should contain key:value pairs. - -The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)). - -As of v0.3.0, you can use *.{ext} as your destination filename to individually compile each file to the destination directory. Otherwise, when the source contains an array of multiple filepaths, the contents are concatenated in the order passed. - -##### options ```object``` - -This controls how this task (and its helpers) operate and should contain key:value pairs, see options below. - -#### Options - -##### paths ```string|array``` - -This specifies directories to scan for @import directives when parsing. Default value is the directory of the source, which is probably what you want. - -##### compress ```boolean``` - -If set to `true`, the generated CSS will be minified. - -##### yuicompress ```boolean``` - -If set to `true`, the generated CSS will be minified with [YUI Compressor's CSS minifier](http://developer.yahoo.com/yui/compressor/css.html). diff --git a/node_modules/grunt-contrib-less/grunt.js b/node_modules/grunt-contrib-less/grunt.js deleted file mode 100644 index 287c576..0000000 --- a/node_modules/grunt-contrib-less/grunt.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * grunt-contrib-less - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -module.exports = function(grunt) { - 'use strict'; - - // Project configuration. - grunt.initConfig({ - lint: { - all: ['grunt.js', 'tasks/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Before generating any new files, remove any previously-created files. - clean: { - test: ['tmp'] - }, - - // Configuration to be run (and then tested). - less: { - compile: { - options: { - paths: ['test/fixtures/include'] - }, - files: { - 'tmp/less.css': ['test/fixtures/style.less'], - 'tmp/concat.css': ['test/fixtures/style.less', 'test/fixtures/style2.less'], - 'tmp/individual/*.css': ['test/fixtures/style*.less', 'test/fixtures/level2/*.less'] - } - }, - compress: { - options: { - paths: ['test/fixtures/include'], - compress: true - }, - files: { - 'tmp/compress.css': ['test/fixtures/style.less'] - } - }, - flatten: { - files: { - 'tmp/individual_flatten/*.css': ['test/fixtures/style*.less', 'test/fixtures/level2/*.less'] - }, - options: { - flatten: true, - paths: ['test/fixtures/include'] - }, - }, - nopaths: { - files: { - 'tmp/nopaths.css': ['test/fixtures/nopaths.less'], - } - }, - yuicompress: { - options: { - paths: ['test/fixtures/include'], - yuicompress: true - }, - files: { - 'tmp/yuicompress.css': ['test/fixtures/style.less'] - } - } - }, - - // Unit tests. - nodeunit: { - tasks: ['test/*_test.js'] - } - }); - - // Actually load this plugin's task(s). - grunt.loadTasks('tasks'); - - // The clean plugin helps in testing. - grunt.loadNpmTasks('grunt-contrib-clean'); - - // Whenever the "test" task is run, first clean the "tmp" dir, then run this - // plugin's task(s), then test the result. - grunt.renameTask('test', 'nodeunit'); - grunt.registerTask('test', 'clean less nodeunit'); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.gitattributes b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.npmignore b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.npmignore deleted file mode 100644 index 5cb6bfd..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -npm-debug.log -tmp \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.travis.yml b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.travis.yml deleted file mode 100644 index baa0031..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.8 diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/AUTHORS b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/AUTHORS deleted file mode 100644 index 5de1a92..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Tyler Kellen (http://goingslowly.com/) -Chris Talkington (http://christalkington.com/) -Larry Davis (http://lazd.net/) -Sindre Sorhus (http://sindresorhus.com) diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/CHANGELOG b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/CHANGELOG deleted file mode 100644 index 3350622..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/CHANGELOG +++ /dev/null @@ -1,20 +0,0 @@ -v0.3.1: - date: 2012-10-29 - changes: - - Tweaked findBasePath to handle single dot differently. - - Start testing with Travis. - - Docs cleanup. -v0.3.0: - date: 2012-09-24 - changes: - - Added findBasePath, buildIndividualDest, isIndividualDest, optsToArgs. - - Refactored tests. - - Automatically parse templates in options. -v0.2.1: - date: 2012-09-14 - changes: - - Added non-destuctive namespace declarations. -v0.2.0: - date: 2012-09-10 - changes: - - Refactored from grunt-contrib into individual repo. \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/LICENSE-MIT b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/LICENSE-MIT deleted file mode 100644 index 358b067..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 Tyler Kellen, contributors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/README.md b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/README.md deleted file mode 100644 index 8ece0e9..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib) - -> Common functionality shared across grunt-contrib tasks. - -The purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks. - -**These APIs should be considered highly unstable. Depend on them at your own risk!** - -_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._ - -### Helper Functions - -#### buildIndividualDest(dest, srcFile, basePath, flatten) - -This helper is used to build a destination filepath for tasks supporting individual compiling. - -#### findBasePath(srcFiles) - -This helper is used to take an array of filepaths and find the common base directory. - -#### getNamespaceDeclaration(ns) - -This helper is used to build JS namespace declarations. - -#### isIndividualDest(dest) - -This helper is used to detect if a destination filepath triggers individual compiling. - -#### normalizeMultiTaskFiles(data, target) - -This helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does. - -#### options(data, defaults) - -This helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release. - -Contrib tasks are in the process of being updated to check for the new helper first. - -#### optsToArgs(options) - -Convert an object to an array of CLI arguments, which can be used with `child_process.spawn()`. - -```js -// Example -{ - fooBar: 'a', // ['--foo-bar', 'a'] - fooBar: 1, // ['--foo-bar', '1'] - fooBar: true, // ['--foo-bar'] - fooBar: false, // - fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b'] -} -``` - --- - -*Lib submitted by [Tyler Kellen](https://goingslowly.com/).* \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/grunt.js b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/grunt.js deleted file mode 100644 index 12dbdbe..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/grunt.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -module.exports = function(grunt) { - 'use strict'; - - grunt.initConfig({ - test_vars: { - source: 'source/' - }, - - test_task: { - options: { - param: 'task', - param2: 'task', - template: '<%= test_vars.source %>', - data: { - template: ['<%= test_vars.source %>'] - } - }, - target: { - options: { - param: 'target' - } - } - }, - - lint: { - all: ['grunt.js', 'lib/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Unit tests. - test: { - tasks: ['test/*_test.js'] - } - }); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; \ No newline at end of file diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/lib/contrib.js b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/lib/contrib.js deleted file mode 100644 index 7bea6eb..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/lib/contrib.js +++ /dev/null @@ -1,200 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -exports.init = function(grunt) { - 'use strict'; - - var exports = {}; - - // TODO: ditch this when grunt v0.4 is released - grunt.util = grunt.util || grunt.utils; - - var path = require('path'); - - // TODO: remove if/when we officially drop node <= 0.7.9 - path.sep = path.sep || path.normalize('/'); - - exports.buildIndividualDest = function(dest, srcFile, basePath, flatten) { - dest = path.normalize(dest); - srcFile = path.normalize(srcFile); - - var newDest = path.dirname(dest); - var newName = path.basename(srcFile, path.extname(srcFile)) + path.extname(dest); - var relative = path.dirname(srcFile); - - if (flatten) { - relative = ''; - } else if (basePath && basePath.length >= 1) { - relative = grunt.util._(relative).strRight(basePath).trim(path.sep); - } - - // make paths outside grunts working dir relative - relative = relative.replace(/\.\.(\/|\\)/g, ''); - - return path.join(newDest, relative, newName); - }; - - exports.findBasePath = function(srcFiles, basePath) { - if (grunt.util.kindOf(basePath) === 'string' && basePath.length >= 1) { - return grunt.util._(path.normalize(basePath)).trim(path.sep); - } - - var foundPath; - var basePaths = []; - var dirName; - - srcFiles.forEach(function(srcFile) { - srcFile = path.normalize(srcFile); - dirName = path.dirname(srcFile); - - basePaths.push(dirName.split(path.sep)); - }); - - basePaths = grunt.util._.intersection.apply([], basePaths); - - foundPath = path.join.apply(path, basePaths); - - if (foundPath === '.') { - foundPath = ''; - } - - return foundPath; - }; - - exports.getNamespaceDeclaration = function(ns) { - var output = []; - var curPath = 'this'; - if (ns !== 'this') { - var nsParts = ns.split('.'); - nsParts.forEach(function(curPart, index) { - if (curPart !== 'this') { - curPath += '[' + JSON.stringify(curPart) + ']'; - output.push(curPath + ' = ' + curPath + ' || {};'); - } - }); - } - - return { - namespace: curPath, - declaration: output.join('\n') - }; - }; - - exports.isIndividualDest = function(dest) { - if (grunt.util._.startsWith(path.basename(dest), '*')) { - return true; - } else { - return false; - } - }; - - // TODO: ditch this when grunt v0.4 is released - // Temporary helper for normalizing files object - exports.normalizeMultiTaskFiles = function(data, target) { - var prop, obj; - var files = []; - if (grunt.util.kindOf(data) === 'object') { - if ('src' in data || 'dest' in data) { - obj = {}; - if ('src' in data) { obj.src = data.src; } - if ('dest' in data) { obj.dest = data.dest; } - files.push(obj); - } else if (grunt.util.kindOf(data.files) === 'object') { - for (prop in data.files) { - files.push({src: data.files[prop], dest: prop}); - } - } else if (Array.isArray(data.files)) { - data.files.forEach(function(obj) { - var prop; - if ('src' in obj || 'dest' in obj) { - files.push(obj); - } else { - for (prop in obj) { - files.push({src: obj[prop], dest: prop}); - } - } - }); - } - } else { - files.push({src: data, dest: target}); - } - - // Process each normalized file object as a template. - files.forEach(function(obj) { - // Process src as a template (recursively, if necessary). - if ('src' in obj) { - obj.src = grunt.util.recurse(obj.src, function(src) { - if (typeof src !== 'string') { return src; } - return grunt.template.process(src); - }); - } - if ('dest' in obj) { - // Process dest as a template. - obj.dest = grunt.template.process(obj.dest); - } - }); - - return files; - }; - - // Helper for consistent options key access across contrib tasks. - exports.options = function(data, defaults) { - var global_target = data.target ? grunt.config(['options', data.name, data.target]) : null; - var global_task = grunt.config(['options', data.name]); - - if (global_task || global_target) { - grunt.fail.warn('root level [options] key will be unsupported in grunt v0.4. please consider using task and target options.'); - } - - var target = data.target ? grunt.config([data.name, data.target, 'options']) : null; - var task = grunt.config([data.name, 'options']); - - var options = grunt.util._.defaults({}, target, task, global_target, global_task, defaults); - - return grunt.util.recurse(options, function(value) { - if (typeof value !== 'string') { return value; } - - return grunt.template.process(value); - }); - }; - - // Convert an object to an array of CLI arguments - exports.optsToArgs = function(options) { - var args = []; - - Object.keys(options).forEach(function(flag) { - var val = options[flag]; - - flag = flag.replace(/[A-Z]/g, function(match) { - return '-' + match.toLowerCase(); - }); - - if (val === true) { - args.push('--' + flag); - } - - if (grunt.util._.isString(val)) { - args.push('--' + flag, val); - } - - if (grunt.util._.isNumber(val)) { - args.push('--' + flag, '' + val); - } - - if (grunt.util._.isArray(val)) { - val.forEach(function(arrVal) { - args.push('--' + flag, arrVal); - }); - } - }); - - return args; - }; - - return exports; -}; diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/package.json b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/package.json deleted file mode 100644 index 4d112b0..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "grunt-lib-contrib", - "description": "Common functionality shared across grunt-contrib tasks.", - "version": "0.3.1", - "homepage": "http://github.com/gruntjs/grunt-lib-contrib", - "author": { - "name": "Grunt Team", - "url": "http://gruntjs.com/" - }, - "repository": { - "type": "git", - "url": "git://github.com/gruntjs/grunt-lib-contrib.git" - }, - "bugs": { - "url": "https://github.com/gruntjs/grunt-lib-contrib/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/gruntjs/grunt-lib-contrib/blob/master/LICENSE-MIT" - } - ], - "engines": { - "node": ">= 0.6.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "grunt": "~0.3.15" - }, - "main": "lib/contrib", - "contributors": [ - { - "name": "Tyler Kellen", - "url": "http://goingslowly.com/" - }, - { - "name": "Chris Talkington", - "url": "http://christalkington.com/" - }, - { - "name": "Larry Davis", - "url": "http://lazd.net/" - }, - { - "name": "Sindre Sorhus", - "url": "http://sindresorhus.com" - } - ], - "readme": "# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib)\n\n> Common functionality shared across grunt-contrib tasks.\n\nThe purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks.\n\n**These APIs should be considered highly unstable. Depend on them at your own risk!**\n\n_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._\n\n### Helper Functions\n\n#### buildIndividualDest(dest, srcFile, basePath, flatten)\n\nThis helper is used to build a destination filepath for tasks supporting individual compiling.\n\n#### findBasePath(srcFiles)\n\nThis helper is used to take an array of filepaths and find the common base directory.\n\n#### getNamespaceDeclaration(ns)\n\nThis helper is used to build JS namespace declarations.\n\n#### isIndividualDest(dest)\n\nThis helper is used to detect if a destination filepath triggers individual compiling.\n\n#### normalizeMultiTaskFiles(data, target)\n\nThis helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does.\n\n#### options(data, defaults)\n\nThis helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release.\n\nContrib tasks are in the process of being updated to check for the new helper first.\n\n#### optsToArgs(options)\n\nConvert an object to an array of CLI arguments, which can be used with `child_process.spawn()`.\n\n```js\n// Example\n{\n fooBar: 'a', // ['--foo-bar', 'a']\n fooBar: 1, // ['--foo-bar', '1']\n fooBar: true, // ['--foo-bar']\n fooBar: false, //\n fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b']\n}\n```\n\n--\n\n*Lib submitted by [Tyler Kellen](https://goingslowly.com/).*", - "readmeFilename": "README.md", - "_id": "grunt-lib-contrib@0.3.1", - "_from": "grunt-lib-contrib@~0.3.0" -} diff --git a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/test/lib_test.js b/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/test/lib_test.js deleted file mode 100644 index d362b2a..0000000 --- a/node_modules/grunt-contrib-less/node_modules/grunt-lib-contrib/test/lib_test.js +++ /dev/null @@ -1,127 +0,0 @@ -var grunt = require('grunt'); -var helper = require('../lib/contrib.js').init(grunt); - -exports.lib = { - findBasePath: function(test) { - 'use strict'; - var path = require('path'); - - test.expect(3); - - var actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'dir1/dir2/dir3/dir4/file.ext']); - var expected = path.normalize('dir1/dir2'); - test.equal(expected, actual, 'should detect basePath from array of filepaths.'); - - actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'file.ext'], 'dir1'); - expected = 'dir1'; - test.equal(expected, actual, 'should default to passed basePath if valid'); - - actual = helper.findBasePath(['.dir1/dir2', '.dir1/dir2/another.ext', '.dir1/dir2/dir3/dir4/file.ext', 'file.ext']); - expected = ''; - test.equal(expected, actual, 'should return empty string if foundPath is a single dot (helps with dotfiles)'); - - test.done(); - }, - getNamespaceDeclaration: function(test) { - 'use strict'; - - test.expect(10); - - // Both test should result in this[JST] - var expected = { - namespace: 'this["JST"]', - declaration: 'this["JST"] = this["JST"] || {};' - }; - - var actual = helper.getNamespaceDeclaration("this.JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - actual = helper.getNamespaceDeclaration("JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Templates should be declared globally if this provided - expected = { - namespace: "this", - declaration: "" - }; - - actual = helper.getNamespaceDeclaration("this"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Nested namespace declaration - expected = { - namespace: 'this["GUI"]["Templates"]["Main"]', - declaration: 'this["GUI"] = this["GUI"] || {};\n' + - 'this["GUI"]["Templates"] = this["GUI"]["Templates"] || {};\n' + - 'this["GUI"]["Templates"]["Main"] = this["GUI"]["Templates"]["Main"] || {};' - }; - - actual = helper.getNamespaceDeclaration("GUI.Templates.Main"); - test.equal(expected.namespace, actual.namespace, 'namespace incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration incorrect'); - - // Namespace that contains square brackets - expected = { - namespace: 'this["main"]["[test]"]["[test2]"]', - declaration: 'this["main"] = this["main"] || {};\n' + - 'this["main"]["[test]"] = this["main"]["[test]"] || {};\n' + - 'this["main"]["[test]"]["[test2]"] = this["main"]["[test]"]["[test2]"] || {};' - }; - - actual = helper.getNamespaceDeclaration("main.[test].[test2]"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - test.done(); - }, - options: function(test) { - 'use strict'; - - test.expect(5); - - var options = helper.options({name: 'test_task', target: 'target'}, {required: 'default'}); - - var actual = options.param; - var expected = 'target'; - test.equal(expected, actual, 'should allow target options key to override task'); - - actual = options.param2; - expected = 'task'; - test.equal(expected, actual, 'should set default task options that can be overriden by target options'); - - actual = options.required; - expected = 'default'; - test.equal(expected, actual, 'should allow task to define default values'); - - actual = options.template; - expected = 'source/'; - test.equal(expected, actual, 'should automatically process template vars'); - - actual = options.data.template; - expected = 'source/'; - test.equal(expected, actual, 'should process template vars recursively'); - - test.done(); - }, - optsToArgs: function(test) { - 'use strict'; - - test.expect(1); - - var fixture = { - key: 'a', - key2: 1, - key3: true, - key4: false, - key5: ['a', 'b'] - }; - var expected = ['--key', 'a', '--key2', '1', '--key3', '--key5', 'a', '--key5', 'b' ].toString(); - var actual = helper.optsToArgs(fixture).toString(); - test.equal(expected, actual, 'should convert object to array of CLI arguments'); - - test.done(); - } -}; diff --git a/node_modules/grunt-contrib-requirejs/docs/examples.md b/node_modules/grunt-contrib-requirejs/docs/examples.md deleted file mode 100644 index c25704b..0000000 --- a/node_modules/grunt-contrib-requirejs/docs/examples.md +++ /dev/null @@ -1,11 +0,0 @@ -```js -requirejs: { - compile: { - options: { - baseUrl: "path/to/base", - mainConfigFile: "path/to/config.js", - out: "path/to/optimized.js" - } - } -} -``` \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/docs/options.md b/node_modules/grunt-contrib-requirejs/docs/options.md deleted file mode 100644 index a48e61f..0000000 --- a/node_modules/grunt-contrib-requirejs/docs/options.md +++ /dev/null @@ -1,7 +0,0 @@ -##### options ```object``` - -This controls how this task (and its helpers) operate and should contain key:value pairs, see options below. - -#### Options - -For a full list of possible options, [see the r.js example build file](https://github.com/jrburke/r.js/blob/master/build/example.build.js). \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/grunt.js b/node_modules/grunt-contrib-requirejs/grunt.js deleted file mode 100644 index 7440f8d..0000000 --- a/node_modules/grunt-contrib-requirejs/grunt.js +++ /dev/null @@ -1,77 +0,0 @@ -/* - * grunt-contrib-requirejs - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -module.exports = function(grunt) { - 'use strict'; - - // Project configuration. - grunt.initConfig({ - lint: { - all: ['grunt.js', 'tasks/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Before generating any new files, remove any previously-created files. - clean: { - test: ['tmp'] - }, - - // Configuration to be run (and then tested). - requirejs: { - compile: { - options: { - baseUrl: 'test/fixtures', - name: 'project', - out: 'tmp/requirejs.js' - } - }, - template: { - options: { - baseUrl: 'test/fixtures', - name: 'project', - out: 'tmp/requirejs-template.js' - } - } - }, - - // Unit tests. - nodeunit: { - tasks: ['test/*_test.js'] - } - }); - - // Actually load this plugin's task(s). - grunt.loadTasks('tasks'); - - // The clean plugin helps in testing. - grunt.loadNpmTasks('grunt-contrib-clean'); - - // Whenever the 'test' task is run, first clean the 'tmp' dir, then run this - // plugin's task(s), then test the result. - grunt.renameTask('test', 'nodeunit'); - grunt.registerTask('test', 'clean requirejs nodeunit'); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.gitattributes b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.gitattributes deleted file mode 100644 index 176a458..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.npmignore b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.npmignore deleted file mode 100644 index 5cb6bfd..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -npm-debug.log -tmp \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.travis.yml b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.travis.yml deleted file mode 100644 index baa0031..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.8 diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/AUTHORS b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/AUTHORS deleted file mode 100644 index 5de1a92..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Tyler Kellen (http://goingslowly.com/) -Chris Talkington (http://christalkington.com/) -Larry Davis (http://lazd.net/) -Sindre Sorhus (http://sindresorhus.com) diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/CHANGELOG b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/CHANGELOG deleted file mode 100644 index 3350622..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/CHANGELOG +++ /dev/null @@ -1,20 +0,0 @@ -v0.3.1: - date: 2012-10-29 - changes: - - Tweaked findBasePath to handle single dot differently. - - Start testing with Travis. - - Docs cleanup. -v0.3.0: - date: 2012-09-24 - changes: - - Added findBasePath, buildIndividualDest, isIndividualDest, optsToArgs. - - Refactored tests. - - Automatically parse templates in options. -v0.2.1: - date: 2012-09-14 - changes: - - Added non-destuctive namespace declarations. -v0.2.0: - date: 2012-09-10 - changes: - - Refactored from grunt-contrib into individual repo. \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/LICENSE-MIT b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/LICENSE-MIT deleted file mode 100644 index 358b067..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 Tyler Kellen, contributors - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/README.md b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/README.md deleted file mode 100644 index 8ece0e9..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib) - -> Common functionality shared across grunt-contrib tasks. - -The purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks. - -**These APIs should be considered highly unstable. Depend on them at your own risk!** - -_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._ - -### Helper Functions - -#### buildIndividualDest(dest, srcFile, basePath, flatten) - -This helper is used to build a destination filepath for tasks supporting individual compiling. - -#### findBasePath(srcFiles) - -This helper is used to take an array of filepaths and find the common base directory. - -#### getNamespaceDeclaration(ns) - -This helper is used to build JS namespace declarations. - -#### isIndividualDest(dest) - -This helper is used to detect if a destination filepath triggers individual compiling. - -#### normalizeMultiTaskFiles(data, target) - -This helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does. - -#### options(data, defaults) - -This helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release. - -Contrib tasks are in the process of being updated to check for the new helper first. - -#### optsToArgs(options) - -Convert an object to an array of CLI arguments, which can be used with `child_process.spawn()`. - -```js -// Example -{ - fooBar: 'a', // ['--foo-bar', 'a'] - fooBar: 1, // ['--foo-bar', '1'] - fooBar: true, // ['--foo-bar'] - fooBar: false, // - fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b'] -} -``` - --- - -*Lib submitted by [Tyler Kellen](https://goingslowly.com/).* \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/grunt.js b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/grunt.js deleted file mode 100644 index 12dbdbe..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/grunt.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -module.exports = function(grunt) { - 'use strict'; - - grunt.initConfig({ - test_vars: { - source: 'source/' - }, - - test_task: { - options: { - param: 'task', - param2: 'task', - template: '<%= test_vars.source %>', - data: { - template: ['<%= test_vars.source %>'] - } - }, - target: { - options: { - param: 'target' - } - } - }, - - lint: { - all: ['grunt.js', 'lib/*.js', ''] - }, - - jshint: { - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - undef: true, - boss: true, - eqnull: true, - node: true, - es5: true - } - }, - - // Unit tests. - test: { - tasks: ['test/*_test.js'] - } - }); - - // By default, lint and run all tests. - grunt.registerTask('default', 'lint test'); -}; \ No newline at end of file diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/lib/contrib.js b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/lib/contrib.js deleted file mode 100644 index 7bea6eb..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/lib/contrib.js +++ /dev/null @@ -1,200 +0,0 @@ -/* - * grunt-lib-contrib - * http://gruntjs.com/ - * - * Copyright (c) 2012 Tyler Kellen, contributors - * Licensed under the MIT license. - */ - -exports.init = function(grunt) { - 'use strict'; - - var exports = {}; - - // TODO: ditch this when grunt v0.4 is released - grunt.util = grunt.util || grunt.utils; - - var path = require('path'); - - // TODO: remove if/when we officially drop node <= 0.7.9 - path.sep = path.sep || path.normalize('/'); - - exports.buildIndividualDest = function(dest, srcFile, basePath, flatten) { - dest = path.normalize(dest); - srcFile = path.normalize(srcFile); - - var newDest = path.dirname(dest); - var newName = path.basename(srcFile, path.extname(srcFile)) + path.extname(dest); - var relative = path.dirname(srcFile); - - if (flatten) { - relative = ''; - } else if (basePath && basePath.length >= 1) { - relative = grunt.util._(relative).strRight(basePath).trim(path.sep); - } - - // make paths outside grunts working dir relative - relative = relative.replace(/\.\.(\/|\\)/g, ''); - - return path.join(newDest, relative, newName); - }; - - exports.findBasePath = function(srcFiles, basePath) { - if (grunt.util.kindOf(basePath) === 'string' && basePath.length >= 1) { - return grunt.util._(path.normalize(basePath)).trim(path.sep); - } - - var foundPath; - var basePaths = []; - var dirName; - - srcFiles.forEach(function(srcFile) { - srcFile = path.normalize(srcFile); - dirName = path.dirname(srcFile); - - basePaths.push(dirName.split(path.sep)); - }); - - basePaths = grunt.util._.intersection.apply([], basePaths); - - foundPath = path.join.apply(path, basePaths); - - if (foundPath === '.') { - foundPath = ''; - } - - return foundPath; - }; - - exports.getNamespaceDeclaration = function(ns) { - var output = []; - var curPath = 'this'; - if (ns !== 'this') { - var nsParts = ns.split('.'); - nsParts.forEach(function(curPart, index) { - if (curPart !== 'this') { - curPath += '[' + JSON.stringify(curPart) + ']'; - output.push(curPath + ' = ' + curPath + ' || {};'); - } - }); - } - - return { - namespace: curPath, - declaration: output.join('\n') - }; - }; - - exports.isIndividualDest = function(dest) { - if (grunt.util._.startsWith(path.basename(dest), '*')) { - return true; - } else { - return false; - } - }; - - // TODO: ditch this when grunt v0.4 is released - // Temporary helper for normalizing files object - exports.normalizeMultiTaskFiles = function(data, target) { - var prop, obj; - var files = []; - if (grunt.util.kindOf(data) === 'object') { - if ('src' in data || 'dest' in data) { - obj = {}; - if ('src' in data) { obj.src = data.src; } - if ('dest' in data) { obj.dest = data.dest; } - files.push(obj); - } else if (grunt.util.kindOf(data.files) === 'object') { - for (prop in data.files) { - files.push({src: data.files[prop], dest: prop}); - } - } else if (Array.isArray(data.files)) { - data.files.forEach(function(obj) { - var prop; - if ('src' in obj || 'dest' in obj) { - files.push(obj); - } else { - for (prop in obj) { - files.push({src: obj[prop], dest: prop}); - } - } - }); - } - } else { - files.push({src: data, dest: target}); - } - - // Process each normalized file object as a template. - files.forEach(function(obj) { - // Process src as a template (recursively, if necessary). - if ('src' in obj) { - obj.src = grunt.util.recurse(obj.src, function(src) { - if (typeof src !== 'string') { return src; } - return grunt.template.process(src); - }); - } - if ('dest' in obj) { - // Process dest as a template. - obj.dest = grunt.template.process(obj.dest); - } - }); - - return files; - }; - - // Helper for consistent options key access across contrib tasks. - exports.options = function(data, defaults) { - var global_target = data.target ? grunt.config(['options', data.name, data.target]) : null; - var global_task = grunt.config(['options', data.name]); - - if (global_task || global_target) { - grunt.fail.warn('root level [options] key will be unsupported in grunt v0.4. please consider using task and target options.'); - } - - var target = data.target ? grunt.config([data.name, data.target, 'options']) : null; - var task = grunt.config([data.name, 'options']); - - var options = grunt.util._.defaults({}, target, task, global_target, global_task, defaults); - - return grunt.util.recurse(options, function(value) { - if (typeof value !== 'string') { return value; } - - return grunt.template.process(value); - }); - }; - - // Convert an object to an array of CLI arguments - exports.optsToArgs = function(options) { - var args = []; - - Object.keys(options).forEach(function(flag) { - var val = options[flag]; - - flag = flag.replace(/[A-Z]/g, function(match) { - return '-' + match.toLowerCase(); - }); - - if (val === true) { - args.push('--' + flag); - } - - if (grunt.util._.isString(val)) { - args.push('--' + flag, val); - } - - if (grunt.util._.isNumber(val)) { - args.push('--' + flag, '' + val); - } - - if (grunt.util._.isArray(val)) { - val.forEach(function(arrVal) { - args.push('--' + flag, arrVal); - }); - } - }); - - return args; - }; - - return exports; -}; diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/package.json b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/package.json deleted file mode 100644 index 4d112b0..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "grunt-lib-contrib", - "description": "Common functionality shared across grunt-contrib tasks.", - "version": "0.3.1", - "homepage": "http://github.com/gruntjs/grunt-lib-contrib", - "author": { - "name": "Grunt Team", - "url": "http://gruntjs.com/" - }, - "repository": { - "type": "git", - "url": "git://github.com/gruntjs/grunt-lib-contrib.git" - }, - "bugs": { - "url": "https://github.com/gruntjs/grunt-lib-contrib/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/gruntjs/grunt-lib-contrib/blob/master/LICENSE-MIT" - } - ], - "engines": { - "node": ">= 0.6.0" - }, - "scripts": { - "test": "grunt test" - }, - "devDependencies": { - "grunt": "~0.3.15" - }, - "main": "lib/contrib", - "contributors": [ - { - "name": "Tyler Kellen", - "url": "http://goingslowly.com/" - }, - { - "name": "Chris Talkington", - "url": "http://christalkington.com/" - }, - { - "name": "Larry Davis", - "url": "http://lazd.net/" - }, - { - "name": "Sindre Sorhus", - "url": "http://sindresorhus.com" - } - ], - "readme": "# grunt-lib-contrib [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-lib-contrib.png?branch=master)](http://travis-ci.org/gruntjs/grunt-lib-contrib)\n\n> Common functionality shared across grunt-contrib tasks.\n\nThe purpose of grunt-lib-contrib is to explore solutions to common problems task writers encounter, and to ease the upgrade path for contrib tasks.\n\n**These APIs should be considered highly unstable. Depend on them at your own risk!**\n\n_Over time, some of the functionality provided here may be incorporated directly into grunt for mainstream use. Until then, you may require `grunt-lib-contrib` as a dependency in your projects, but be very careful to specify an exact version number instead of a range, as backwards-incompatible changes are likely to be introduced._\n\n### Helper Functions\n\n#### buildIndividualDest(dest, srcFile, basePath, flatten)\n\nThis helper is used to build a destination filepath for tasks supporting individual compiling.\n\n#### findBasePath(srcFiles)\n\nThis helper is used to take an array of filepaths and find the common base directory.\n\n#### getNamespaceDeclaration(ns)\n\nThis helper is used to build JS namespace declarations.\n\n#### isIndividualDest(dest)\n\nThis helper is used to detect if a destination filepath triggers individual compiling.\n\n#### normalizeMultiTaskFiles(data, target)\n\nThis helper is a (temporary) shim to handle multi-task `files` object in the same way grunt v0.4 does.\n\n#### options(data, defaults)\n\nThis helper is on its way out as grunt v0.4 adds an options helper to the task api. This new helper only supports task and target options (no root level options key) so you should start adjusting your tasks now to be ready for the v0.4 release.\n\nContrib tasks are in the process of being updated to check for the new helper first.\n\n#### optsToArgs(options)\n\nConvert an object to an array of CLI arguments, which can be used with `child_process.spawn()`.\n\n```js\n// Example\n{\n fooBar: 'a', // ['--foo-bar', 'a']\n fooBar: 1, // ['--foo-bar', '1']\n fooBar: true, // ['--foo-bar']\n fooBar: false, //\n fooBar: ['a', 'b'] // ['--foo-bar', 'a', '--foo-bar', 'b']\n}\n```\n\n--\n\n*Lib submitted by [Tyler Kellen](https://goingslowly.com/).*", - "readmeFilename": "README.md", - "_id": "grunt-lib-contrib@0.3.1", - "_from": "grunt-lib-contrib@~0.3.0" -} diff --git a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/test/lib_test.js b/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/test/lib_test.js deleted file mode 100644 index d362b2a..0000000 --- a/node_modules/grunt-contrib-requirejs/node_modules/grunt-lib-contrib/test/lib_test.js +++ /dev/null @@ -1,127 +0,0 @@ -var grunt = require('grunt'); -var helper = require('../lib/contrib.js').init(grunt); - -exports.lib = { - findBasePath: function(test) { - 'use strict'; - var path = require('path'); - - test.expect(3); - - var actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'dir1/dir2/dir3/dir4/file.ext']); - var expected = path.normalize('dir1/dir2'); - test.equal(expected, actual, 'should detect basePath from array of filepaths.'); - - actual = helper.findBasePath(['dir1/dir2/dir3/file.ext', 'dir1/dir2/another.ext', 'file.ext'], 'dir1'); - expected = 'dir1'; - test.equal(expected, actual, 'should default to passed basePath if valid'); - - actual = helper.findBasePath(['.dir1/dir2', '.dir1/dir2/another.ext', '.dir1/dir2/dir3/dir4/file.ext', 'file.ext']); - expected = ''; - test.equal(expected, actual, 'should return empty string if foundPath is a single dot (helps with dotfiles)'); - - test.done(); - }, - getNamespaceDeclaration: function(test) { - 'use strict'; - - test.expect(10); - - // Both test should result in this[JST] - var expected = { - namespace: 'this["JST"]', - declaration: 'this["JST"] = this["JST"] || {};' - }; - - var actual = helper.getNamespaceDeclaration("this.JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - actual = helper.getNamespaceDeclaration("JST"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Templates should be declared globally if this provided - expected = { - namespace: "this", - declaration: "" - }; - - actual = helper.getNamespaceDeclaration("this"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - // Nested namespace declaration - expected = { - namespace: 'this["GUI"]["Templates"]["Main"]', - declaration: 'this["GUI"] = this["GUI"] || {};\n' + - 'this["GUI"]["Templates"] = this["GUI"]["Templates"] || {};\n' + - 'this["GUI"]["Templates"]["Main"] = this["GUI"]["Templates"]["Main"] || {};' - }; - - actual = helper.getNamespaceDeclaration("GUI.Templates.Main"); - test.equal(expected.namespace, actual.namespace, 'namespace incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration incorrect'); - - // Namespace that contains square brackets - expected = { - namespace: 'this["main"]["[test]"]["[test2]"]', - declaration: 'this["main"] = this["main"] || {};\n' + - 'this["main"]["[test]"] = this["main"]["[test]"] || {};\n' + - 'this["main"]["[test]"]["[test2]"] = this["main"]["[test]"]["[test2]"] || {};' - }; - - actual = helper.getNamespaceDeclaration("main.[test].[test2]"); - test.equal(expected.namespace, actual.namespace, 'namespace with square brackets incorrect'); - test.equal(expected.declaration, actual.declaration, 'namespace declaration with square brackets incorrect'); - - test.done(); - }, - options: function(test) { - 'use strict'; - - test.expect(5); - - var options = helper.options({name: 'test_task', target: 'target'}, {required: 'default'}); - - var actual = options.param; - var expected = 'target'; - test.equal(expected, actual, 'should allow target options key to override task'); - - actual = options.param2; - expected = 'task'; - test.equal(expected, actual, 'should set default task options that can be overriden by target options'); - - actual = options.required; - expected = 'default'; - test.equal(expected, actual, 'should allow task to define default values'); - - actual = options.template; - expected = 'source/'; - test.equal(expected, actual, 'should automatically process template vars'); - - actual = options.data.template; - expected = 'source/'; - test.equal(expected, actual, 'should process template vars recursively'); - - test.done(); - }, - optsToArgs: function(test) { - 'use strict'; - - test.expect(1); - - var fixture = { - key: 'a', - key2: 1, - key3: true, - key4: false, - key5: ['a', 'b'] - }; - var expected = ['--key', 'a', '--key2', '1', '--key3', '--key5', 'a', '--key5', 'b' ].toString(); - var actual = helper.optsToArgs(fixture).toString(); - test.equal(expected, actual, 'should convert object to array of CLI arguments'); - - test.done(); - } -}; diff --git a/node_modules/grunt-contrib-watch/docs/watch-faqs.md b/node_modules/grunt-contrib-watch/docs/watch-faqs.md deleted file mode 100644 index 6297a84..0000000 --- a/node_modules/grunt-contrib-watch/docs/watch-faqs.md +++ /dev/null @@ -1,4 +0,0 @@ -# FAQs - -## How do I fix the error `EMFILE: Too many opened files.`? -This is because of your system's max opened file limit. For OSX the default is very low (256). Increase your limit with `ulimit -n 10480`, the number being the new max limit. If you're still running into issues then consider setting the option `forceWatchMethod: 'old'` to use the older and slower stat polling watch method. diff --git a/node_modules/grunt-contrib-watch/docs/watch-overview.md b/node_modules/grunt-contrib-watch/docs/watch-overview.md deleted file mode 100644 index 0103366..0000000 --- a/node_modules/grunt-contrib-watch/docs/watch-overview.md +++ /dev/null @@ -1,3 +0,0 @@ -# Overview - -Inside your `Gruntfile.js` file, add a section named `watch`. This section specifies the files to watch, tasks to run when an event occurs and the options used. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/.bin/lodash b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/.bin/lodash deleted file mode 120000 index 24deae2..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/.bin/lodash +++ /dev/null @@ -1 +0,0 @@ -../lodash/build.js \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.gitmodules b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.gitmodules deleted file mode 100644 index a9aae98..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "deps/nodeunit"] - path = deps/nodeunit - url = git://github.com/caolan/nodeunit.git -[submodule "deps/UglifyJS"] - path = deps/UglifyJS - url = https://github.com/mishoo/UglifyJS.git -[submodule "deps/nodelint"] - path = deps/nodelint - url = https://github.com/tav/nodelint.git diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.npmignore b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.npmignore deleted file mode 100644 index 9bdfc97..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -deps -dist -test -nodelint.cfg \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/LICENSE deleted file mode 100644 index b7f9d50..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010 Caolan McMahon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/Makefile b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/Makefile deleted file mode 100644 index bad647c..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -PACKAGE = asyncjs -NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node) -CWD := $(shell pwd) -NODEUNIT = $(CWD)/node_modules/nodeunit/bin/nodeunit -UGLIFY = $(CWD)/node_modules/uglify-js/bin/uglifyjs -NODELINT = $(CWD)/node_modules/nodelint/nodelint - -BUILDDIR = dist - -all: clean test build - -build: $(wildcard lib/*.js) - mkdir -p $(BUILDDIR) - $(UGLIFY) lib/async.js > $(BUILDDIR)/async.min.js - -test: - $(NODEUNIT) test - -clean: - rm -rf $(BUILDDIR) - -lint: - $(NODELINT) --config nodelint.cfg lib/async.js - -.PHONY: test build all diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/README.md deleted file mode 100644 index 1bbbc47..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/README.md +++ /dev/null @@ -1,1021 +0,0 @@ -# Async.js - -Async is a utility module which provides straight-forward, powerful functions -for working with asynchronous JavaScript. Although originally designed for -use with [node.js](http://nodejs.org), it can also be used directly in the -browser. - -Async provides around 20 functions that include the usual 'functional' -suspects (map, reduce, filter, forEach…) as well as some common patterns -for asynchronous control flow (parallel, series, waterfall…). All these -functions assume you follow the node.js convention of providing a single -callback as the last argument of your async function. - - -## Quick Examples - - async.map(['file1','file2','file3'], fs.stat, function(err, results){ - // results is now an array of stats for each file - }); - - async.filter(['file1','file2','file3'], path.exists, function(results){ - // results now equals an array of the existing files - }); - - async.parallel([ - function(){ ... }, - function(){ ... } - ], callback); - - async.series([ - function(){ ... }, - function(){ ... } - ]); - -There are many more functions available so take a look at the docs below for a -full list. This module aims to be comprehensive, so if you feel anything is -missing please create a GitHub issue for it. - - -## Download - -Releases are available for download from -[GitHub](http://github.com/caolan/async/downloads). -Alternatively, you can install using Node Package Manager (npm): - - npm install async - - -__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 17.5kb Uncompressed - -__Production:__ [async.min.js](https://github.com/caolan/async/raw/master/dist/async.min.js) - 1.7kb Packed and Gzipped - - -## In the Browser - -So far its been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage: - - - - - -## Documentation - -### Collections - -* [forEach](#forEach) -* [map](#map) -* [filter](#filter) -* [reject](#reject) -* [reduce](#reduce) -* [detect](#detect) -* [sortBy](#sortBy) -* [some](#some) -* [every](#every) -* [concat](#concat) - -### Control Flow - -* [series](#series) -* [parallel](#parallel) -* [whilst](#whilst) -* [until](#until) -* [waterfall](#waterfall) -* [queue](#queue) -* [auto](#auto) -* [iterator](#iterator) -* [apply](#apply) -* [nextTick](#nextTick) - -### Utils - -* [memoize](#memoize) -* [unmemoize](#unmemoize) -* [log](#log) -* [dir](#dir) -* [noConflict](#noConflict) - - -## Collections - - -### forEach(arr, iterator, callback) - -Applies an iterator function to each item in an array, in parallel. -The iterator is called with an item from the list and a callback for when it -has finished. If the iterator passes an error to this callback, the main -callback for the forEach function is immediately called with the error. - -Note, that since this function applies the iterator to each item in parallel -there is no guarantee that the iterator functions will complete in order. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A function to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(err) - A callback which is called after all the iterator functions - have finished, or an error has occurred. - -__Example__ - - // assuming openFiles is an array of file names and saveFile is a function - // to save the modified contents of that file: - - async.forEach(openFiles, saveFile, function(err){ - // if any of the saves produced an error, err would equal that error - }); - ---------------------------------------- - - -### forEachSeries(arr, iterator, callback) - -The same as forEach only the iterator is applied to each item in the array in -series. The next iterator is only called once the current one has completed -processing. This means the iterator functions will complete in order. - - ---------------------------------------- - - -### forEachLimit(arr, limit, iterator, callback) - -The same as forEach only the iterator is applied to batches of items in the -array, in series. The next batch of iterators is only called once the current -one has completed processing. - -__Arguments__ - -* arr - An array to iterate over. -* limit - How many items should be in each batch. -* iterator(item, callback) - A function to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(err) - A callback which is called after all the iterator functions - have finished, or an error has occurred. - -__Example__ - - // Assume documents is an array of JSON objects and requestApi is a - // function that interacts with a rate-limited REST api. - - async.forEachLimit(documents, 20, requestApi, function(err){ - // if any of the saves produced an error, err would equal that error - }); ---------------------------------------- - - -### map(arr, iterator, callback) - -Produces a new array of values by mapping each value in the given array through -the iterator function. The iterator is called with an item from the array and a -callback for when it has finished processing. The callback takes 2 arguments, -an error and the transformed item from the array. If the iterator passes an -error to this callback, the main callback for the map function is immediately -called with the error. - -Note, that since this function applies the iterator to each item in parallel -there is no guarantee that the iterator functions will complete in order, however -the results array will be in the same order as the original array. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A function to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed - with an error (which can be null) and a transformed item. -* callback(err, results) - A callback which is called after all the iterator - functions have finished, or an error has occurred. Results is an array of the - transformed items from the original array. - -__Example__ - - async.map(['file1','file2','file3'], fs.stat, function(err, results){ - // results is now an array of stats for each file - }); - ---------------------------------------- - - -### mapSeries(arr, iterator, callback) - -The same as map only the iterator is applied to each item in the array in -series. The next iterator is only called once the current one has completed -processing. The results array will be in the same order as the original. - - ---------------------------------------- - - -### filter(arr, iterator, callback) - -__Alias:__ select - -Returns a new array of all the values which pass an async truth test. -_The callback for each iterator call only accepts a single argument of true or -false, it does not accept an error argument first!_ This is in-line with the -way node libraries work with truth tests like path.exists. This operation is -performed in parallel, but the results array will be in the same order as the -original. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A truth test to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(results) - A callback which is called after all the iterator - functions have finished. - -__Example__ - - async.filter(['file1','file2','file3'], path.exists, function(results){ - // results now equals an array of the existing files - }); - ---------------------------------------- - - -### filterSeries(arr, iterator, callback) - -__alias:__ selectSeries - -The same as filter only the iterator is applied to each item in the array in -series. The next iterator is only called once the current one has completed -processing. The results array will be in the same order as the original. - ---------------------------------------- - - -### reject(arr, iterator, callback) - -The opposite of filter. Removes values that pass an async truth test. - ---------------------------------------- - - -### rejectSeries(arr, iterator, callback) - -The same as filter, only the iterator is applied to each item in the array -in series. - - ---------------------------------------- - - -### reduce(arr, memo, iterator, callback) - -__aliases:__ inject, foldl - -Reduces a list of values into a single value using an async iterator to return -each successive step. Memo is the initial state of the reduction. This -function only operates in series. For performance reasons, it may make sense to -split a call to this function into a parallel map, then use the normal -Array.prototype.reduce on the results. This function is for situations where -each step in the reduction needs to be async, if you can get the data before -reducing it then its probably a good idea to do so. - -__Arguments__ - -* arr - An array to iterate over. -* memo - The initial state of the reduction. -* iterator(memo, item, callback) - A function applied to each item in the - array to produce the next step in the reduction. The iterator is passed a - callback which accepts an optional error as its first argument, and the state - of the reduction as the second. If an error is passed to the callback, the - reduction is stopped and the main callback is immediately called with the - error. -* callback(err, result) - A callback which is called after all the iterator - functions have finished. Result is the reduced value. - -__Example__ - - async.reduce([1,2,3], 0, function(memo, item, callback){ - // pointless async: - process.nextTick(function(){ - callback(null, memo + item) - }); - }, function(err, result){ - // result is now equal to the last value of memo, which is 6 - }); - ---------------------------------------- - - -### reduceRight(arr, memo, iterator, callback) - -__Alias:__ foldr - -Same as reduce, only operates on the items in the array in reverse order. - - ---------------------------------------- - - -### detect(arr, iterator, callback) - -Returns the first value in a list that passes an async truth test. The -iterator is applied in parallel, meaning the first iterator to return true will -fire the detect callback with that result. That means the result might not be -the first item in the original array (in terms of order) that passes the test. - -If order within the original array is important then look at detectSeries. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A truth test to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(result) - A callback which is called as soon as any iterator returns - true, or after all the iterator functions have finished. Result will be - the first item in the array that passes the truth test (iterator) or the - value undefined if none passed. - -__Example__ - - async.detect(['file1','file2','file3'], path.exists, function(result){ - // result now equals the first file in the list that exists - }); - ---------------------------------------- - - -### detectSeries(arr, iterator, callback) - -The same as detect, only the iterator is applied to each item in the array -in series. This means the result is always the first in the original array (in -terms of array order) that passes the truth test. - - ---------------------------------------- - - -### sortBy(arr, iterator, callback) - -Sorts a list by the results of running each value through an async iterator. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A function to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed - with an error (which can be null) and a value to use as the sort criteria. -* callback(err, results) - A callback which is called after all the iterator - functions have finished, or an error has occurred. Results is the items from - the original array sorted by the values returned by the iterator calls. - -__Example__ - - async.sortBy(['file1','file2','file3'], function(file, callback){ - fs.stat(file, function(err, stats){ - callback(err, stats.mtime); - }); - }, function(err, results){ - // results is now the original array of files sorted by - // modified date - }); - - ---------------------------------------- - - -### some(arr, iterator, callback) - -__Alias:__ any - -Returns true if at least one element in the array satisfies an async test. -_The callback for each iterator call only accepts a single argument of true or -false, it does not accept an error argument first!_ This is in-line with the -way node libraries work with truth tests like path.exists. Once any iterator -call returns true, the main callback is immediately called. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A truth test to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(result) - A callback which is called as soon as any iterator returns - true, or after all the iterator functions have finished. Result will be - either true or false depending on the values of the async tests. - -__Example__ - - async.some(['file1','file2','file3'], path.exists, function(result){ - // if result is true then at least one of the files exists - }); - ---------------------------------------- - - -### every(arr, iterator, callback) - -__Alias:__ all - -Returns true if every element in the array satisfies an async test. -_The callback for each iterator call only accepts a single argument of true or -false, it does not accept an error argument first!_ This is in-line with the -way node libraries work with truth tests like path.exists. - -__Arguments__ - -* arr - An array to iterate over. -* iterator(item, callback) - A truth test to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed. -* callback(result) - A callback which is called after all the iterator - functions have finished. Result will be either true or false depending on - the values of the async tests. - -__Example__ - - async.every(['file1','file2','file3'], path.exists, function(result){ - // if result is true then every file exists - }); - ---------------------------------------- - - -### concat(arr, iterator, callback) - -Applies an iterator to each item in a list, concatenating the results. Returns the -concatenated list. The iterators are called in parallel, and the results are -concatenated as they return. There is no guarantee that the results array will -be returned in the original order of the arguments passed to the iterator function. - -__Arguments__ - -* arr - An array to iterate over -* iterator(item, callback) - A function to apply to each item in the array. - The iterator is passed a callback which must be called once it has completed - with an error (which can be null) and an array of results. -* callback(err, results) - A callback which is called after all the iterator - functions have finished, or an error has occurred. Results is an array containing - the concatenated results of the iterator function. - -__Example__ - - async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){ - // files is now a list of filenames that exist in the 3 directories - }); - ---------------------------------------- - - -### concatSeries(arr, iterator, callback) - -Same as async.concat, but executes in series instead of parallel. - - -## Control Flow - - -### series(tasks, [callback]) - -Run an array of functions in series, each one running once the previous -function has completed. If any functions in the series pass an error to its -callback, no more functions are run and the callback for the series is -immediately called with the value of the error. Once the tasks have completed, -the results are passed to the final callback as an array. - -It is also possible to use an object instead of an array. Each property will be -run as a function and the results will be passed to the final callback as an object -instead of an array. This can be a more readable way of handling results from -async.series. - - -__Arguments__ - -* tasks - An array or object containing functions to run, each function is passed - a callback it must call on completion. -* callback(err, results) - An optional callback to run once all the functions - have completed. This function gets an array of all the arguments passed to - the callbacks used in the array. - -__Example__ - - async.series([ - function(callback){ - // do some stuff ... - callback(null, 'one'); - }, - function(callback){ - // do some more stuff ... - callback(null, 'two'); - }, - ], - // optional callback - function(err, results){ - // results is now equal to ['one', 'two'] - }); - - - // an example using an object instead of an array - async.series({ - one: function(callback){ - setTimeout(function(){ - callback(null, 1); - }, 200); - }, - two: function(callback){ - setTimeout(function(){ - callback(null, 2); - }, 100); - }, - }, - function(err, results) { - // results is now equal to: {one: 1, two: 2} - }); - - ---------------------------------------- - - -### parallel(tasks, [callback]) - -Run an array of functions in parallel, without waiting until the previous -function has completed. If any of the functions pass an error to its -callback, the main callback is immediately called with the value of the error. -Once the tasks have completed, the results are passed to the final callback as an -array. - -It is also possible to use an object instead of an array. Each property will be -run as a function and the results will be passed to the final callback as an object -instead of an array. This can be a more readable way of handling results from -async.parallel. - - -__Arguments__ - -* tasks - An array or object containing functions to run, each function is passed a - callback it must call on completion. -* callback(err, results) - An optional callback to run once all the functions - have completed. This function gets an array of all the arguments passed to - the callbacks used in the array. - -__Example__ - - async.parallel([ - function(callback){ - setTimeout(function(){ - callback(null, 'one'); - }, 200); - }, - function(callback){ - setTimeout(function(){ - callback(null, 'two'); - }, 100); - }, - ], - // optional callback - function(err, results){ - // the results array will equal ['one','two'] even though - // the second function had a shorter timeout. - }); - - - // an example using an object instead of an array - async.parallel({ - one: function(callback){ - setTimeout(function(){ - callback(null, 1); - }, 200); - }, - two: function(callback){ - setTimeout(function(){ - callback(null, 2); - }, 100); - }, - }, - function(err, results) { - // results is now equals to: {one: 1, two: 2} - }); - - ---------------------------------------- - - -### whilst(test, fn, callback) - -Repeatedly call fn, while test returns true. Calls the callback when stopped, -or an error occurs. - -__Arguments__ - -* test() - synchronous truth test to perform before each execution of fn. -* fn(callback) - A function to call each time the test passes. The function is - passed a callback which must be called once it has completed with an optional - error as the first argument. -* callback(err) - A callback which is called after the test fails and repeated - execution of fn has stopped. - -__Example__ - - var count = 0; - - async.whilst( - function () { return count < 5; }, - function (callback) { - count++; - setTimeout(callback, 1000); - }, - function (err) { - // 5 seconds have passed - } - ); - - ---------------------------------------- - - -### until(test, fn, callback) - -Repeatedly call fn, until test returns true. Calls the callback when stopped, -or an error occurs. - -The inverse of async.whilst. - - ---------------------------------------- - - -### waterfall(tasks, [callback]) - -Runs an array of functions in series, each passing their results to the next in -the array. However, if any of the functions pass an error to the callback, the -next function is not executed and the main callback is immediately called with -the error. - -__Arguments__ - -* tasks - An array of functions to run, each function is passed a callback it - must call on completion. -* callback(err, [results]) - An optional callback to run once all the functions - have completed. This will be passed the results of the last task's callback. - - - -__Example__ - - async.waterfall([ - function(callback){ - callback(null, 'one', 'two'); - }, - function(arg1, arg2, callback){ - callback(null, 'three'); - }, - function(arg1, callback){ - // arg1 now equals 'three' - callback(null, 'done'); - } - ], function (err, result) { - // result now equals 'done' - }); - - ---------------------------------------- - - -### queue(worker, concurrency) - -Creates a queue object with the specified concurrency. Tasks added to the -queue will be processed in parallel (up to the concurrency limit). If all -workers are in progress, the task is queued until one is available. Once -a worker has completed a task, the task's callback is called. - -__Arguments__ - -* worker(task, callback) - An asynchronous function for processing a queued - task. -* concurrency - An integer for determining how many worker functions should be - run in parallel. - -__Queue objects__ - -The queue object returned by this function has the following properties and -methods: - -* length() - a function returning the number of items waiting to be processed. -* concurrency - an integer for determining how many worker functions should be - run in parallel. This property can be changed after a queue is created to - alter the concurrency on-the-fly. -* push(task, [callback]) - add a new task to the queue, the callback is called - once the worker has finished processing the task. - instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list. -* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued -* empty - a callback that is called when the last item from the queue is given to a worker -* drain - a callback that is called when the last item from the queue has returned from the worker - -__Example__ - - // create a queue object with concurrency 2 - - var q = async.queue(function (task, callback) { - console.log('hello ' + task.name); - callback(); - }, 2); - - - // assign a callback - q.drain = function() { - console.log('all items have been processed'); - } - - // add some items to the queue - - q.push({name: 'foo'}, function (err) { - console.log('finished processing foo'); - }); - q.push({name: 'bar'}, function (err) { - console.log('finished processing bar'); - }); - - // add some items to the queue (batch-wise) - - q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) { - console.log('finished processing bar'); - }); - - ---------------------------------------- - - -### auto(tasks, [callback]) - -Determines the best order for running functions based on their requirements. -Each function can optionally depend on other functions being completed first, -and each function is run as soon as its requirements are satisfied. If any of -the functions pass an error to their callback, that function will not complete -(so any other functions depending on it will not run) and the main callback -will be called immediately with the error. Functions also receive an object -containing the results of functions which have completed so far. - -__Arguments__ - -* tasks - An object literal containing named functions or an array of - requirements, with the function itself the last item in the array. The key - used for each function or array is used when specifying requirements. The - syntax is easier to understand by looking at the example. -* callback(err, results) - An optional callback which is called when all the - tasks have been completed. The callback will receive an error as an argument - if any tasks pass an error to their callback. If all tasks complete - successfully, it will receive an object containing their results. - -__Example__ - - async.auto({ - get_data: function(callback){ - // async code to get some data - }, - make_folder: function(callback){ - // async code to create a directory to store a file in - // this is run at the same time as getting the data - }, - write_file: ['get_data', 'make_folder', function(callback){ - // once there is some data and the directory exists, - // write the data to a file in the directory - callback(null, filename); - }], - email_link: ['write_file', function(callback, results){ - // once the file is written let's email a link to it... - // results.write_file contains the filename returned by write_file. - }] - }); - -This is a fairly trivial example, but to do this using the basic parallel and -series functions would look like this: - - async.parallel([ - function(callback){ - // async code to get some data - }, - function(callback){ - // async code to create a directory to store a file in - // this is run at the same time as getting the data - } - ], - function(results){ - async.series([ - function(callback){ - // once there is some data and the directory exists, - // write the data to a file in the directory - }, - email_link: function(callback){ - // once the file is written let's email a link to it... - } - ]); - }); - -For a complicated series of async tasks using the auto function makes adding -new tasks much easier and makes the code more readable. - - ---------------------------------------- - - -### iterator(tasks) - -Creates an iterator function which calls the next function in the array, -returning a continuation to call the next one after that. Its also possible to -'peek' the next iterator by doing iterator.next(). - -This function is used internally by the async module but can be useful when -you want to manually control the flow of functions in series. - -__Arguments__ - -* tasks - An array of functions to run, each function is passed a callback it - must call on completion. - -__Example__ - - var iterator = async.iterator([ - function(){ sys.p('one'); }, - function(){ sys.p('two'); }, - function(){ sys.p('three'); } - ]); - - node> var iterator2 = iterator(); - 'one' - node> var iterator3 = iterator2(); - 'two' - node> iterator3(); - 'three' - node> var nextfn = iterator2.next(); - node> nextfn(); - 'three' - - ---------------------------------------- - - -### apply(function, arguments..) - -Creates a continuation function with some arguments already applied, a useful -shorthand when combined with other control flow functions. Any arguments -passed to the returned function are added to the arguments originally passed -to apply. - -__Arguments__ - -* function - The function you want to eventually apply all arguments to. -* arguments... - Any number of arguments to automatically apply when the - continuation is called. - -__Example__ - - // using apply - - async.parallel([ - async.apply(fs.writeFile, 'testfile1', 'test1'), - async.apply(fs.writeFile, 'testfile2', 'test2'), - ]); - - - // the same process without using apply - - async.parallel([ - function(callback){ - fs.writeFile('testfile1', 'test1', callback); - }, - function(callback){ - fs.writeFile('testfile2', 'test2', callback); - }, - ]); - -It's possible to pass any number of additional arguments when calling the -continuation: - - node> var fn = async.apply(sys.puts, 'one'); - node> fn('two', 'three'); - one - two - three - ---------------------------------------- - - -### nextTick(callback) - -Calls the callback on a later loop around the event loop. In node.js this just -calls process.nextTick, in the browser it falls back to setTimeout(callback, 0), -which means other higher priority events may precede the execution of the callback. - -This is used internally for browser-compatibility purposes. - -__Arguments__ - -* callback - The function to call on a later loop around the event loop. - -__Example__ - - var call_order = []; - async.nextTick(function(){ - call_order.push('two'); - // call_order now equals ['one','two] - }); - call_order.push('one') - - -## Utils - - -### memoize(fn, [hasher]) - -Caches the results of an async function. When creating a hash to store function -results against, the callback is omitted from the hash and an optional hash -function can be used. - -__Arguments__ - -* fn - the function you to proxy and cache results from. -* hasher - an optional function for generating a custom hash for storing - results, it has all the arguments applied to it apart from the callback, and - must be synchronous. - -__Example__ - - var slow_fn = function (name, callback) { - // do something - callback(null, result); - }; - var fn = async.memoize(slow_fn); - - // fn can now be used as if it were slow_fn - fn('some name', function () { - // callback - }); - - -### unmemoize(fn) - -Undoes a memoized function, reverting it to the original, unmemoized -form. Comes handy in tests. - -__Arguments__ - -* fn - the memoized function - - -### log(function, arguments) - -Logs the result of an async function to the console. Only works in node.js or -in browsers that support console.log and console.error (such as FF and Chrome). -If multiple arguments are returned from the async function, console.log is -called on each argument in order. - -__Arguments__ - -* function - The function you want to eventually apply all arguments to. -* arguments... - Any number of arguments to apply to the function. - -__Example__ - - var hello = function(name, callback){ - setTimeout(function(){ - callback(null, 'hello ' + name); - }, 1000); - }; - - node> async.log(hello, 'world'); - 'hello world' - - ---------------------------------------- - - -### dir(function, arguments) - -Logs the result of an async function to the console using console.dir to -display the properties of the resulting object. Only works in node.js or -in browsers that support console.dir and console.error (such as FF and Chrome). -If multiple arguments are returned from the async function, console.dir is -called on each argument in order. - -__Arguments__ - -* function - The function you want to eventually apply all arguments to. -* arguments... - Any number of arguments to apply to the function. - -__Example__ - - var hello = function(name, callback){ - setTimeout(function(){ - callback(null, {hello: name}); - }, 1000); - }; - - node> async.dir(hello, 'world'); - {hello: 'world'} - - ---------------------------------------- - - -### noConflict() - -Changes the value of async back to its original value, returning a reference to the -async object. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/index.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/index.js deleted file mode 100644 index 8e23845..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// This file is just added for convenience so this repository can be -// directly checked out into a project's deps folder -module.exports = require('./lib/async'); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/lib/async.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/lib/async.js deleted file mode 100644 index 7cc4f5e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/lib/async.js +++ /dev/null @@ -1,692 +0,0 @@ -/*global setTimeout: false, console: false */ -(function () { - - var async = {}; - - // global on the server, window in the browser - var root = this, - previous_async = root.async; - - if (typeof module !== 'undefined' && module.exports) { - module.exports = async; - } - else { - root.async = async; - } - - async.noConflict = function () { - root.async = previous_async; - return async; - }; - - //// cross-browser compatiblity functions //// - - var _forEach = function (arr, iterator) { - if (arr.forEach) { - return arr.forEach(iterator); - } - for (var i = 0; i < arr.length; i += 1) { - iterator(arr[i], i, arr); - } - }; - - var _map = function (arr, iterator) { - if (arr.map) { - return arr.map(iterator); - } - var results = []; - _forEach(arr, function (x, i, a) { - results.push(iterator(x, i, a)); - }); - return results; - }; - - var _reduce = function (arr, iterator, memo) { - if (arr.reduce) { - return arr.reduce(iterator, memo); - } - _forEach(arr, function (x, i, a) { - memo = iterator(memo, x, i, a); - }); - return memo; - }; - - var _keys = function (obj) { - if (Object.keys) { - return Object.keys(obj); - } - var keys = []; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - keys.push(k); - } - } - return keys; - }; - - //// exported async module functions //// - - //// nextTick implementation with browser-compatible fallback //// - if (typeof process === 'undefined' || !(process.nextTick)) { - async.nextTick = function (fn) { - setTimeout(fn, 0); - }; - } - else { - async.nextTick = process.nextTick; - } - - async.forEach = function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length) { - return callback(); - } - var completed = 0; - _forEach(arr, function (x) { - iterator(x, function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed === arr.length) { - callback(null); - } - } - }); - }); - }; - - async.forEachSeries = function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length) { - return callback(); - } - var completed = 0; - var iterate = function () { - iterator(arr[completed], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed === arr.length) { - callback(null); - } - else { - iterate(); - } - } - }); - }; - iterate(); - }; - - async.forEachLimit = function (arr, limit, iterator, callback) { - callback = callback || function () {}; - if (!arr.length || limit <= 0) { - return callback(); - } - var completed = 0; - var started = 0; - var running = 0; - - (function replenish () { - if (completed === arr.length) { - return callback(); - } - - while (running < limit && started < arr.length) { - started += 1; - running += 1; - iterator(arr[started - 1], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - running -= 1; - if (completed === arr.length) { - callback(); - } - else { - replenish(); - } - } - }); - } - })(); - }; - - - var doParallel = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.forEach].concat(args)); - }; - }; - var doSeries = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.forEachSeries].concat(args)); - }; - }; - - - var _asyncMap = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (err, v) { - results[x.index] = v; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - }; - async.map = doParallel(_asyncMap); - async.mapSeries = doSeries(_asyncMap); - - - // reduce only has a series version, as doing reduce in parallel won't - // work in many situations. - async.reduce = function (arr, memo, iterator, callback) { - async.forEachSeries(arr, function (x, callback) { - iterator(memo, x, function (err, v) { - memo = v; - callback(err); - }); - }, function (err) { - callback(err, memo); - }); - }; - // inject alias - async.inject = async.reduce; - // foldl alias - async.foldl = async.reduce; - - async.reduceRight = function (arr, memo, iterator, callback) { - var reversed = _map(arr, function (x) { - return x; - }).reverse(); - async.reduce(reversed, memo, iterator, callback); - }; - // foldr alias - async.foldr = async.reduceRight; - - var _filter = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.filter = doParallel(_filter); - async.filterSeries = doSeries(_filter); - // select alias - async.select = async.filter; - async.selectSeries = async.filterSeries; - - var _reject = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (!v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.reject = doParallel(_reject); - async.rejectSeries = doSeries(_reject); - - var _detect = function (eachfn, arr, iterator, main_callback) { - eachfn(arr, function (x, callback) { - iterator(x, function (result) { - if (result) { - main_callback(x); - main_callback = function () {}; - } - else { - callback(); - } - }); - }, function (err) { - main_callback(); - }); - }; - async.detect = doParallel(_detect); - async.detectSeries = doSeries(_detect); - - async.some = function (arr, iterator, main_callback) { - async.forEach(arr, function (x, callback) { - iterator(x, function (v) { - if (v) { - main_callback(true); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(false); - }); - }; - // any alias - async.any = async.some; - - async.every = function (arr, iterator, main_callback) { - async.forEach(arr, function (x, callback) { - iterator(x, function (v) { - if (!v) { - main_callback(false); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(true); - }); - }; - // all alias - async.all = async.every; - - async.sortBy = function (arr, iterator, callback) { - async.map(arr, function (x, callback) { - iterator(x, function (err, criteria) { - if (err) { - callback(err); - } - else { - callback(null, {value: x, criteria: criteria}); - } - }); - }, function (err, results) { - if (err) { - return callback(err); - } - else { - var fn = function (left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }; - callback(null, _map(results.sort(fn), function (x) { - return x.value; - })); - } - }); - }; - - async.auto = function (tasks, callback) { - callback = callback || function () {}; - var keys = _keys(tasks); - if (!keys.length) { - return callback(null); - } - - var results = {}; - - var listeners = []; - var addListener = function (fn) { - listeners.unshift(fn); - }; - var removeListener = function (fn) { - for (var i = 0; i < listeners.length; i += 1) { - if (listeners[i] === fn) { - listeners.splice(i, 1); - return; - } - } - }; - var taskComplete = function () { - _forEach(listeners.slice(0), function (fn) { - fn(); - }); - }; - - addListener(function () { - if (_keys(results).length === keys.length) { - callback(null, results); - callback = function () {}; - } - }); - - _forEach(keys, function (k) { - var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; - var taskCallback = function (err) { - if (err) { - callback(err); - // stop subsequent errors hitting callback multiple times - callback = function () {}; - } - else { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - taskComplete(); - } - }; - var requires = task.slice(0, Math.abs(task.length - 1)) || []; - var ready = function () { - return _reduce(requires, function (a, x) { - return (a && results.hasOwnProperty(x)); - }, true) && !results.hasOwnProperty(k); - }; - if (ready()) { - task[task.length - 1](taskCallback, results); - } - else { - var listener = function () { - if (ready()) { - removeListener(listener); - task[task.length - 1](taskCallback, results); - } - }; - addListener(listener); - } - }); - }; - - async.waterfall = function (tasks, callback) { - callback = callback || function () {}; - if (!tasks.length) { - return callback(); - } - var wrapIterator = function (iterator) { - return function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - var args = Array.prototype.slice.call(arguments, 1); - var next = iterator.next(); - if (next) { - args.push(wrapIterator(next)); - } - else { - args.push(callback); - } - async.nextTick(function () { - iterator.apply(null, args); - }); - } - }; - }; - wrapIterator(async.iterator(tasks))(); - }; - - async.parallel = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.map(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - async.forEach(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.series = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.mapSeries(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - async.forEachSeries(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.iterator = function (tasks) { - var makeCallback = function (index) { - var fn = function () { - if (tasks.length) { - tasks[index].apply(null, arguments); - } - return fn.next(); - }; - fn.next = function () { - return (index < tasks.length - 1) ? makeCallback(index + 1): null; - }; - return fn; - }; - return makeCallback(0); - }; - - async.apply = function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - return function () { - return fn.apply( - null, args.concat(Array.prototype.slice.call(arguments)) - ); - }; - }; - - var _concat = function (eachfn, arr, fn, callback) { - var r = []; - eachfn(arr, function (x, cb) { - fn(x, function (err, y) { - r = r.concat(y || []); - cb(err); - }); - }, function (err) { - callback(err, r); - }); - }; - async.concat = doParallel(_concat); - async.concatSeries = doSeries(_concat); - - async.whilst = function (test, iterator, callback) { - if (test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.whilst(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.until = function (test, iterator, callback) { - if (!test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.until(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.queue = function (worker, concurrency) { - var workers = 0; - var q = { - tasks: [], - concurrency: concurrency, - saturated: null, - empty: null, - drain: null, - push: function (data, callback) { - if(data.constructor !== Array) { - data = [data]; - } - _forEach(data, function(task) { - q.tasks.push({ - data: task, - callback: typeof callback === 'function' ? callback : null - }); - if (q.saturated && q.tasks.length == concurrency) { - q.saturated(); - } - async.nextTick(q.process); - }); - }, - process: function () { - if (workers < q.concurrency && q.tasks.length) { - var task = q.tasks.shift(); - if(q.empty && q.tasks.length == 0) q.empty(); - workers += 1; - worker(task.data, function () { - workers -= 1; - if (task.callback) { - task.callback.apply(task, arguments); - } - if(q.drain && q.tasks.length + workers == 0) q.drain(); - q.process(); - }); - } - }, - length: function () { - return q.tasks.length; - }, - running: function () { - return workers; - } - }; - return q; - }; - - var _console_fn = function (name) { - return function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - fn.apply(null, args.concat([function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (typeof console !== 'undefined') { - if (err) { - if (console.error) { - console.error(err); - } - } - else if (console[name]) { - _forEach(args, function (x) { - console[name](x); - }); - } - } - }])); - }; - }; - async.log = _console_fn('log'); - async.dir = _console_fn('dir'); - /*async.info = _console_fn('info'); - async.warn = _console_fn('warn'); - async.error = _console_fn('error');*/ - - async.memoize = function (fn, hasher) { - var memo = {}; - var queues = {}; - hasher = hasher || function (x) { - return x; - }; - var memoized = function () { - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - var key = hasher.apply(null, args); - if (key in memo) { - callback.apply(null, memo[key]); - } - else if (key in queues) { - queues[key].push(callback); - } - else { - queues[key] = [callback]; - fn.apply(null, args.concat([function () { - memo[key] = arguments; - var q = queues[key]; - delete queues[key]; - for (var i = 0, l = q.length; i < l; i++) { - q[i].apply(null, arguments); - } - }])); - } - }; - memoized.unmemoized = fn; - return memoized; - }; - - async.unmemoize = function (fn) { - return function () { - return (fn.unmemoized || fn).apply(null, arguments); - }; - }; - -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/package.json b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/package.json deleted file mode 100644 index 4f74950..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/async/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "async", - "description": "Higher-order functions and common patterns for asynchronous code", - "main": "./index", - "author": { - "name": "Caolan McMahon" - }, - "version": "0.1.22", - "repository": { - "type": "git", - "url": "http://github.com/caolan/async.git" - }, - "bugs": { - "url": "http://github.com/caolan/async/issues" - }, - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/caolan/async/raw/master/LICENSE" - } - ], - "devDependencies": { - "nodeunit": ">0.0.0", - "uglify-js": "1.2.x", - "nodelint": ">0.0.0" - }, - "readme": "# Async.js\n\nAsync is a utility module which provides straight-forward, powerful functions\nfor working with asynchronous JavaScript. Although originally designed for\nuse with [node.js](http://nodejs.org), it can also be used directly in the\nbrowser.\n\nAsync provides around 20 functions that include the usual 'functional'\nsuspects (map, reduce, filter, forEach…) as well as some common patterns\nfor asynchronous control flow (parallel, series, waterfall…). All these\nfunctions assume you follow the node.js convention of providing a single\ncallback as the last argument of your async function.\n\n\n## Quick Examples\n\n async.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n });\n\n async.filter(['file1','file2','file3'], path.exists, function(results){\n // results now equals an array of the existing files\n });\n\n async.parallel([\n function(){ ... },\n function(){ ... }\n ], callback);\n\n async.series([\n function(){ ... },\n function(){ ... }\n ]);\n\nThere are many more functions available so take a look at the docs below for a\nfull list. This module aims to be comprehensive, so if you feel anything is\nmissing please create a GitHub issue for it.\n\n\n## Download\n\nReleases are available for download from\n[GitHub](http://github.com/caolan/async/downloads).\nAlternatively, you can install using Node Package Manager (npm):\n\n npm install async\n\n\n__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 17.5kb Uncompressed\n\n__Production:__ [async.min.js](https://github.com/caolan/async/raw/master/dist/async.min.js) - 1.7kb Packed and Gzipped\n\n\n## In the Browser\n\nSo far its been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:\n\n \n \n\n\n## Documentation\n\n### Collections\n\n* [forEach](#forEach)\n* [map](#map)\n* [filter](#filter)\n* [reject](#reject)\n* [reduce](#reduce)\n* [detect](#detect)\n* [sortBy](#sortBy)\n* [some](#some)\n* [every](#every)\n* [concat](#concat)\n\n### Control Flow\n\n* [series](#series)\n* [parallel](#parallel)\n* [whilst](#whilst)\n* [until](#until)\n* [waterfall](#waterfall)\n* [queue](#queue)\n* [auto](#auto)\n* [iterator](#iterator)\n* [apply](#apply)\n* [nextTick](#nextTick)\n\n### Utils\n\n* [memoize](#memoize)\n* [unmemoize](#unmemoize)\n* [log](#log)\n* [dir](#dir)\n* [noConflict](#noConflict)\n\n\n## Collections\n\n\n### forEach(arr, iterator, callback)\n\nApplies an iterator function to each item in an array, in parallel.\nThe iterator is called with an item from the list and a callback for when it\nhas finished. If the iterator passes an error to this callback, the main\ncallback for the forEach function is immediately called with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator functions will complete in order.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(err) - A callback which is called after all the iterator functions\n have finished, or an error has occurred.\n\n__Example__\n\n // assuming openFiles is an array of file names and saveFile is a function\n // to save the modified contents of that file:\n\n async.forEach(openFiles, saveFile, function(err){\n // if any of the saves produced an error, err would equal that error\n });\n\n---------------------------------------\n\n\n### forEachSeries(arr, iterator, callback)\n\nThe same as forEach only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. This means the iterator functions will complete in order.\n\n\n---------------------------------------\n\n\n### forEachLimit(arr, limit, iterator, callback)\n\nThe same as forEach only the iterator is applied to batches of items in the\narray, in series. The next batch of iterators is only called once the current\none has completed processing.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* limit - How many items should be in each batch.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(err) - A callback which is called after all the iterator functions\n have finished, or an error has occurred.\n\n__Example__\n\n // Assume documents is an array of JSON objects and requestApi is a\n // function that interacts with a rate-limited REST api.\n\n async.forEachLimit(documents, 20, requestApi, function(err){\n // if any of the saves produced an error, err would equal that error\n });\n---------------------------------------\n\n\n### map(arr, iterator, callback)\n\nProduces a new array of values by mapping each value in the given array through\nthe iterator function. The iterator is called with an item from the array and a\ncallback for when it has finished processing. The callback takes 2 arguments, \nan error and the transformed item from the array. If the iterator passes an\nerror to this callback, the main callback for the map function is immediately\ncalled with the error.\n\nNote, that since this function applies the iterator to each item in parallel\nthere is no guarantee that the iterator functions will complete in order, however\nthe results array will be in the same order as the original array.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and a transformed item.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array of the\n transformed items from the original array.\n\n__Example__\n\n async.map(['file1','file2','file3'], fs.stat, function(err, results){\n // results is now an array of stats for each file\n });\n\n---------------------------------------\n\n\n### mapSeries(arr, iterator, callback)\n\nThe same as map only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n\n---------------------------------------\n\n\n### filter(arr, iterator, callback)\n\n__Alias:__ select\n\nReturns a new array of all the values which pass an async truth test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists. This operation is\nperformed in parallel, but the results array will be in the same order as the\noriginal.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(results) - A callback which is called after all the iterator\n functions have finished.\n\n__Example__\n\n async.filter(['file1','file2','file3'], path.exists, function(results){\n // results now equals an array of the existing files\n });\n\n---------------------------------------\n\n\n### filterSeries(arr, iterator, callback)\n\n__alias:__ selectSeries\n\nThe same as filter only the iterator is applied to each item in the array in\nseries. The next iterator is only called once the current one has completed\nprocessing. The results array will be in the same order as the original.\n\n---------------------------------------\n\n\n### reject(arr, iterator, callback)\n\nThe opposite of filter. Removes values that pass an async truth test.\n\n---------------------------------------\n\n\n### rejectSeries(arr, iterator, callback)\n\nThe same as filter, only the iterator is applied to each item in the array\nin series.\n\n\n---------------------------------------\n\n\n### reduce(arr, memo, iterator, callback)\n\n__aliases:__ inject, foldl\n\nReduces a list of values into a single value using an async iterator to return\neach successive step. Memo is the initial state of the reduction. This\nfunction only operates in series. For performance reasons, it may make sense to\nsplit a call to this function into a parallel map, then use the normal\nArray.prototype.reduce on the results. This function is for situations where\neach step in the reduction needs to be async, if you can get the data before\nreducing it then its probably a good idea to do so.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* memo - The initial state of the reduction.\n* iterator(memo, item, callback) - A function applied to each item in the\n array to produce the next step in the reduction. The iterator is passed a\n callback which accepts an optional error as its first argument, and the state\n of the reduction as the second. If an error is passed to the callback, the\n reduction is stopped and the main callback is immediately called with the\n error.\n* callback(err, result) - A callback which is called after all the iterator\n functions have finished. Result is the reduced value.\n\n__Example__\n\n async.reduce([1,2,3], 0, function(memo, item, callback){\n // pointless async:\n process.nextTick(function(){\n callback(null, memo + item)\n });\n }, function(err, result){\n // result is now equal to the last value of memo, which is 6\n });\n\n---------------------------------------\n\n\n### reduceRight(arr, memo, iterator, callback)\n\n__Alias:__ foldr\n\nSame as reduce, only operates on the items in the array in reverse order.\n\n\n---------------------------------------\n\n\n### detect(arr, iterator, callback)\n\nReturns the first value in a list that passes an async truth test. The\niterator is applied in parallel, meaning the first iterator to return true will\nfire the detect callback with that result. That means the result might not be\nthe first item in the original array (in terms of order) that passes the test.\n\nIf order within the original array is important then look at detectSeries.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n the first item in the array that passes the truth test (iterator) or the\n value undefined if none passed.\n\n__Example__\n\n async.detect(['file1','file2','file3'], path.exists, function(result){\n // result now equals the first file in the list that exists\n });\n\n---------------------------------------\n\n\n### detectSeries(arr, iterator, callback)\n\nThe same as detect, only the iterator is applied to each item in the array\nin series. This means the result is always the first in the original array (in\nterms of array order) that passes the truth test.\n\n\n---------------------------------------\n\n\n### sortBy(arr, iterator, callback)\n\nSorts a list by the results of running each value through an async iterator.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and a value to use as the sort criteria.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is the items from\n the original array sorted by the values returned by the iterator calls.\n\n__Example__\n\n async.sortBy(['file1','file2','file3'], function(file, callback){\n fs.stat(file, function(err, stats){\n callback(err, stats.mtime);\n });\n }, function(err, results){\n // results is now the original array of files sorted by\n // modified date\n });\n\n\n---------------------------------------\n\n\n### some(arr, iterator, callback)\n\n__Alias:__ any\n\nReturns true if at least one element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists. Once any iterator\ncall returns true, the main callback is immediately called.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called as soon as any iterator returns\n true, or after all the iterator functions have finished. Result will be\n either true or false depending on the values of the async tests.\n\n__Example__\n\n async.some(['file1','file2','file3'], path.exists, function(result){\n // if result is true then at least one of the files exists\n });\n\n---------------------------------------\n\n\n### every(arr, iterator, callback)\n\n__Alias:__ all\n\nReturns true if every element in the array satisfies an async test.\n_The callback for each iterator call only accepts a single argument of true or\nfalse, it does not accept an error argument first!_ This is in-line with the\nway node libraries work with truth tests like path.exists.\n\n__Arguments__\n\n* arr - An array to iterate over.\n* iterator(item, callback) - A truth test to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed.\n* callback(result) - A callback which is called after all the iterator\n functions have finished. Result will be either true or false depending on\n the values of the async tests.\n\n__Example__\n\n async.every(['file1','file2','file3'], path.exists, function(result){\n // if result is true then every file exists\n });\n\n---------------------------------------\n\n\n### concat(arr, iterator, callback)\n\nApplies an iterator to each item in a list, concatenating the results. Returns the\nconcatenated list. The iterators are called in parallel, and the results are\nconcatenated as they return. There is no guarantee that the results array will\nbe returned in the original order of the arguments passed to the iterator function.\n\n__Arguments__\n\n* arr - An array to iterate over\n* iterator(item, callback) - A function to apply to each item in the array.\n The iterator is passed a callback which must be called once it has completed\n with an error (which can be null) and an array of results.\n* callback(err, results) - A callback which is called after all the iterator\n functions have finished, or an error has occurred. Results is an array containing\n the concatenated results of the iterator function.\n\n__Example__\n\n async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){\n // files is now a list of filenames that exist in the 3 directories\n });\n\n---------------------------------------\n\n\n### concatSeries(arr, iterator, callback)\n\nSame as async.concat, but executes in series instead of parallel.\n\n\n## Control Flow\n\n\n### series(tasks, [callback])\n\nRun an array of functions in series, each one running once the previous\nfunction has completed. If any functions in the series pass an error to its\ncallback, no more functions are run and the callback for the series is\nimmediately called with the value of the error. Once the tasks have completed,\nthe results are passed to the final callback as an array.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.series.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed\n a callback it must call on completion.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets an array of all the arguments passed to\n the callbacks used in the array.\n\n__Example__\n\n async.series([\n function(callback){\n // do some stuff ...\n callback(null, 'one');\n },\n function(callback){\n // do some more stuff ...\n callback(null, 'two');\n },\n ],\n // optional callback\n function(err, results){\n // results is now equal to ['one', 'two']\n });\n\n\n // an example using an object instead of an array\n async.series({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n },\n },\n function(err, results) {\n // results is now equal to: {one: 1, two: 2}\n });\n\n\n---------------------------------------\n\n\n### parallel(tasks, [callback])\n\nRun an array of functions in parallel, without waiting until the previous\nfunction has completed. If any of the functions pass an error to its\ncallback, the main callback is immediately called with the value of the error.\nOnce the tasks have completed, the results are passed to the final callback as an\narray.\n\nIt is also possible to use an object instead of an array. Each property will be\nrun as a function and the results will be passed to the final callback as an object\ninstead of an array. This can be a more readable way of handling results from\nasync.parallel.\n\n\n__Arguments__\n\n* tasks - An array or object containing functions to run, each function is passed a\n callback it must call on completion.\n* callback(err, results) - An optional callback to run once all the functions\n have completed. This function gets an array of all the arguments passed to\n the callbacks used in the array.\n\n__Example__\n\n async.parallel([\n function(callback){\n setTimeout(function(){\n callback(null, 'one');\n }, 200);\n },\n function(callback){\n setTimeout(function(){\n callback(null, 'two');\n }, 100);\n },\n ],\n // optional callback\n function(err, results){\n // the results array will equal ['one','two'] even though\n // the second function had a shorter timeout.\n });\n\n\n // an example using an object instead of an array\n async.parallel({\n one: function(callback){\n setTimeout(function(){\n callback(null, 1);\n }, 200);\n },\n two: function(callback){\n setTimeout(function(){\n callback(null, 2);\n }, 100);\n },\n },\n function(err, results) {\n // results is now equals to: {one: 1, two: 2}\n });\n\n\n---------------------------------------\n\n\n### whilst(test, fn, callback)\n\nRepeatedly call fn, while test returns true. Calls the callback when stopped,\nor an error occurs.\n\n__Arguments__\n\n* test() - synchronous truth test to perform before each execution of fn.\n* fn(callback) - A function to call each time the test passes. The function is\n passed a callback which must be called once it has completed with an optional\n error as the first argument.\n* callback(err) - A callback which is called after the test fails and repeated\n execution of fn has stopped.\n\n__Example__\n\n var count = 0;\n\n async.whilst(\n function () { return count < 5; },\n function (callback) {\n count++;\n setTimeout(callback, 1000);\n },\n function (err) {\n // 5 seconds have passed\n }\n );\n\n\n---------------------------------------\n\n\n### until(test, fn, callback)\n\nRepeatedly call fn, until test returns true. Calls the callback when stopped,\nor an error occurs.\n\nThe inverse of async.whilst.\n\n\n---------------------------------------\n\n\n### waterfall(tasks, [callback])\n\nRuns an array of functions in series, each passing their results to the next in\nthe array. However, if any of the functions pass an error to the callback, the\nnext function is not executed and the main callback is immediately called with\nthe error.\n\n__Arguments__\n\n* tasks - An array of functions to run, each function is passed a callback it\n must call on completion.\n* callback(err, [results]) - An optional callback to run once all the functions\n have completed. This will be passed the results of the last task's callback.\n\n\n\n__Example__\n\n async.waterfall([\n function(callback){\n callback(null, 'one', 'two');\n },\n function(arg1, arg2, callback){\n callback(null, 'three');\n },\n function(arg1, callback){\n // arg1 now equals 'three'\n callback(null, 'done');\n }\n ], function (err, result) {\n // result now equals 'done' \n });\n\n\n---------------------------------------\n\n\n### queue(worker, concurrency)\n\nCreates a queue object with the specified concurrency. Tasks added to the\nqueue will be processed in parallel (up to the concurrency limit). If all\nworkers are in progress, the task is queued until one is available. Once\na worker has completed a task, the task's callback is called.\n\n__Arguments__\n\n* worker(task, callback) - An asynchronous function for processing a queued\n task.\n* concurrency - An integer for determining how many worker functions should be\n run in parallel.\n\n__Queue objects__\n\nThe queue object returned by this function has the following properties and\nmethods:\n\n* length() - a function returning the number of items waiting to be processed.\n* concurrency - an integer for determining how many worker functions should be\n run in parallel. This property can be changed after a queue is created to\n alter the concurrency on-the-fly.\n* push(task, [callback]) - add a new task to the queue, the callback is called\n once the worker has finished processing the task.\n instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.\n* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued\n* empty - a callback that is called when the last item from the queue is given to a worker\n* drain - a callback that is called when the last item from the queue has returned from the worker\n\n__Example__\n\n // create a queue object with concurrency 2\n\n var q = async.queue(function (task, callback) {\n console.log('hello ' + task.name);\n callback();\n }, 2);\n\n\n // assign a callback\n q.drain = function() {\n console.log('all items have been processed');\n }\n\n // add some items to the queue\n\n q.push({name: 'foo'}, function (err) {\n console.log('finished processing foo');\n });\n q.push({name: 'bar'}, function (err) {\n console.log('finished processing bar');\n });\n\n // add some items to the queue (batch-wise)\n\n q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {\n console.log('finished processing bar');\n });\n\n\n---------------------------------------\n\n\n### auto(tasks, [callback])\n\nDetermines the best order for running functions based on their requirements.\nEach function can optionally depend on other functions being completed first,\nand each function is run as soon as its requirements are satisfied. If any of\nthe functions pass an error to their callback, that function will not complete\n(so any other functions depending on it will not run) and the main callback\nwill be called immediately with the error. Functions also receive an object\ncontaining the results of functions which have completed so far.\n\n__Arguments__\n\n* tasks - An object literal containing named functions or an array of\n requirements, with the function itself the last item in the array. The key\n used for each function or array is used when specifying requirements. The\n syntax is easier to understand by looking at the example.\n* callback(err, results) - An optional callback which is called when all the\n tasks have been completed. The callback will receive an error as an argument\n if any tasks pass an error to their callback. If all tasks complete\n successfully, it will receive an object containing their results.\n\n__Example__\n\n async.auto({\n get_data: function(callback){\n // async code to get some data\n },\n make_folder: function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n },\n write_file: ['get_data', 'make_folder', function(callback){\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n callback(null, filename);\n }],\n email_link: ['write_file', function(callback, results){\n // once the file is written let's email a link to it...\n // results.write_file contains the filename returned by write_file.\n }]\n });\n\nThis is a fairly trivial example, but to do this using the basic parallel and\nseries functions would look like this:\n\n async.parallel([\n function(callback){\n // async code to get some data\n },\n function(callback){\n // async code to create a directory to store a file in\n // this is run at the same time as getting the data\n }\n ],\n function(results){\n async.series([\n function(callback){\n // once there is some data and the directory exists,\n // write the data to a file in the directory\n },\n email_link: function(callback){\n // once the file is written let's email a link to it...\n }\n ]);\n });\n\nFor a complicated series of async tasks using the auto function makes adding\nnew tasks much easier and makes the code more readable.\n\n\n---------------------------------------\n\n\n### iterator(tasks)\n\nCreates an iterator function which calls the next function in the array,\nreturning a continuation to call the next one after that. Its also possible to\n'peek' the next iterator by doing iterator.next().\n\nThis function is used internally by the async module but can be useful when\nyou want to manually control the flow of functions in series.\n\n__Arguments__\n\n* tasks - An array of functions to run, each function is passed a callback it\n must call on completion.\n\n__Example__\n\n var iterator = async.iterator([\n function(){ sys.p('one'); },\n function(){ sys.p('two'); },\n function(){ sys.p('three'); }\n ]);\n\n node> var iterator2 = iterator();\n 'one'\n node> var iterator3 = iterator2();\n 'two'\n node> iterator3();\n 'three'\n node> var nextfn = iterator2.next();\n node> nextfn();\n 'three'\n\n\n---------------------------------------\n\n\n### apply(function, arguments..)\n\nCreates a continuation function with some arguments already applied, a useful\nshorthand when combined with other control flow functions. Any arguments\npassed to the returned function are added to the arguments originally passed\nto apply.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to automatically apply when the\n continuation is called.\n\n__Example__\n\n // using apply\n\n async.parallel([\n async.apply(fs.writeFile, 'testfile1', 'test1'),\n async.apply(fs.writeFile, 'testfile2', 'test2'),\n ]);\n\n\n // the same process without using apply\n\n async.parallel([\n function(callback){\n fs.writeFile('testfile1', 'test1', callback);\n },\n function(callback){\n fs.writeFile('testfile2', 'test2', callback);\n },\n ]);\n\nIt's possible to pass any number of additional arguments when calling the\ncontinuation:\n\n node> var fn = async.apply(sys.puts, 'one');\n node> fn('two', 'three');\n one\n two\n three\n\n---------------------------------------\n\n\n### nextTick(callback)\n\nCalls the callback on a later loop around the event loop. In node.js this just\ncalls process.nextTick, in the browser it falls back to setTimeout(callback, 0),\nwhich means other higher priority events may precede the execution of the callback.\n\nThis is used internally for browser-compatibility purposes.\n\n__Arguments__\n\n* callback - The function to call on a later loop around the event loop.\n\n__Example__\n\n var call_order = [];\n async.nextTick(function(){\n call_order.push('two');\n // call_order now equals ['one','two]\n });\n call_order.push('one')\n\n\n## Utils\n\n\n### memoize(fn, [hasher])\n\nCaches the results of an async function. When creating a hash to store function\nresults against, the callback is omitted from the hash and an optional hash\nfunction can be used.\n\n__Arguments__\n\n* fn - the function you to proxy and cache results from.\n* hasher - an optional function for generating a custom hash for storing\n results, it has all the arguments applied to it apart from the callback, and\n must be synchronous.\n\n__Example__\n\n var slow_fn = function (name, callback) {\n // do something\n callback(null, result);\n };\n var fn = async.memoize(slow_fn);\n\n // fn can now be used as if it were slow_fn\n fn('some name', function () {\n // callback\n });\n\n\n### unmemoize(fn)\n\nUndoes a memoized function, reverting it to the original, unmemoized\nform. Comes handy in tests.\n\n__Arguments__\n\n* fn - the memoized function\n\n\n### log(function, arguments)\n\nLogs the result of an async function to the console. Only works in node.js or\nin browsers that support console.log and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.log is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n var hello = function(name, callback){\n setTimeout(function(){\n callback(null, 'hello ' + name);\n }, 1000);\n };\n\n node> async.log(hello, 'world');\n 'hello world'\n\n\n---------------------------------------\n\n\n### dir(function, arguments)\n\nLogs the result of an async function to the console using console.dir to\ndisplay the properties of the resulting object. Only works in node.js or\nin browsers that support console.dir and console.error (such as FF and Chrome).\nIf multiple arguments are returned from the async function, console.dir is\ncalled on each argument in order.\n\n__Arguments__\n\n* function - The function you want to eventually apply all arguments to.\n* arguments... - Any number of arguments to apply to the function.\n\n__Example__\n\n var hello = function(name, callback){\n setTimeout(function(){\n callback(null, {hello: name});\n }, 1000);\n };\n\n node> async.dir(hello, 'world');\n {hello: 'world'}\n\n\n---------------------------------------\n\n\n### noConflict()\n\nChanges the value of async back to its original value, returning a reference to the\nasync object.\n", - "readmeFilename": "README.md", - "_id": "async@0.1.22", - "_from": "async@~0.1.22" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.npmignore b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.npmignore deleted file mode 100644 index 2af4b71..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -.*.swp -test/a/ diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.travis.yml b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.travis.yml deleted file mode 100644 index baa0031..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - 0.8 diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/LICENSE deleted file mode 100644 index 0c44ae7..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) Isaac Z. Schlueter ("Author") -All rights reserved. - -The BSD License - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/README.md deleted file mode 100644 index 6e27df6..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/README.md +++ /dev/null @@ -1,233 +0,0 @@ -# Glob - -This is a glob implementation in JavaScript. It uses the `minimatch` -library to do its matching. - -## Attention: node-glob users! - -The API has changed dramatically between 2.x and 3.x. This library is -now 100% JavaScript, and the integer flags have been replaced with an -options object. - -Also, there's an event emitter class, proper tests, and all the other -things you've come to expect from node modules. - -And best of all, no compilation! - -## Usage - -```javascript -var glob = require("glob") - -// options is optional -glob("**/*.js", options, function (er, files) { - // files is an array of filenames. - // If the `nonull` option is set, and nothing - // was found, then files is ["**/*.js"] - // er is an error object or null. -}) -``` - -## Features - -Please see the [minimatch -documentation](https://github.com/isaacs/minimatch) for more details. - -Supports these glob features: - -* Brace Expansion -* Extended glob matching -* "Globstar" `**` matching - -See: - -* `man sh` -* `man bash` -* `man 3 fnmatch` -* `man 5 gitignore` -* [minimatch documentation](https://github.com/isaacs/minimatch) - -## glob(pattern, [options], cb) - -* `pattern` {String} Pattern to be matched -* `options` {Object} -* `cb` {Function} - * `err` {Error | null} - * `matches` {Array} filenames found matching the pattern - -Perform an asynchronous glob search. - -## glob.sync(pattern, [options] - -* `pattern` {String} Pattern to be matched -* `options` {Object} -* return: {Array} filenames found matching the pattern - -Perform a synchronous glob search. - -## Class: glob.Glob - -Create a Glob object by instanting the `glob.Glob` class. - -```javascript -var Glob = require("glob").Glob -var mg = new Glob(pattern, options, cb) -``` - -It's an EventEmitter, and starts walking the filesystem to find matches -immediately. - -### new glob.Glob(pattern, [options], [cb]) - -* `pattern` {String} pattern to search for -* `options` {Object} -* `cb` {Function} Called when an error occurs, or matches are found - * `err` {Error | null} - * `matches` {Array} filenames found matching the pattern - -Note that if the `sync` flag is set in the options, then matches will -be immediately available on the `g.found` member. - -### Properties - -* `minimatch` The minimatch object that the glob uses. -* `options` The options object passed in. -* `error` The error encountered. When an error is encountered, the - glob object is in an undefined state, and should be discarded. -* `aborted` Boolean which is set to true when calling `abort()`. There - is no way at this time to continue a glob search after aborting, but - you can re-use the statCache to avoid having to duplicate syscalls. - -### Events - -* `end` When the matching is finished, this is emitted with all the - matches found. If the `nonull` option is set, and no match was found, - then the `matches` list contains the original pattern. The matches - are sorted, unless the `nosort` flag is set. -* `match` Every time a match is found, this is emitted with the matched. -* `error` Emitted when an unexpected error is encountered, or whenever - any fs error occurs if `options.strict` is set. -* `abort` When `abort()` is called, this event is raised. - -### Methods - -* `abort` Stop the search. - -### Options - -All the options that can be passed to Minimatch can also be passed to -Glob to change pattern matching behavior. Also, some have been added, -or have glob-specific ramifications. - -All options are false by default, unless otherwise noted. - -All options are added to the glob object, as well. - -* `cwd` The current working directory in which to search. Defaults - to `process.cwd()`. -* `root` The place where patterns starting with `/` will be mounted - onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix - systems, and `C:\` or some such on Windows.) -* `nomount` By default, a pattern starting with a forward-slash will be - "mounted" onto the root setting, so that a valid filesystem path is - returned. Set this flag to disable that behavior. -* `mark` Add a `/` character to directory matches. Note that this - requires additional stat calls. -* `nosort` Don't sort the results. -* `stat` Set to true to stat *all* results. This reduces performance - somewhat, and is completely unnecessary, unless `readdir` is presumed - to be an untrustworthy indicator of file existence. It will cause - ELOOP to be triggered one level sooner in the case of cyclical - symbolic links. -* `silent` When an unusual error is encountered - when attempting to read a directory, a warning will be printed to - stderr. Set the `silent` option to true to suppress these warnings. -* `strict` When an unusual error is encountered - when attempting to read a directory, the process will just continue on - in search of other matches. Set the `strict` option to raise an error - in these cases. -* `statCache` A cache of results of filesystem information, to prevent - unnecessary stat calls. While it should not normally be necessary to - set this, you may pass the statCache from one glob() call to the - options object of another, if you know that the filesystem will not - change between calls. (See "Race Conditions" below.) -* `sync` Perform a synchronous glob search. -* `nounique` In some cases, brace-expanded patterns can result in the - same file showing up multiple times in the result set. By default, - this implementation prevents duplicates in the result set. - Set this flag to disable that behavior. -* `nonull` Set to never return an empty set, instead returning a set - containing the pattern itself. This is the default in glob(3). -* `nocase` Perform a case-insensitive match. Note that case-insensitive - filesystems will sometimes result in glob returning results that are - case-insensitively matched anyway, since readdir and stat will not - raise an error. -* `debug` Set to enable debug logging in minimatch and glob. -* `globDebug` Set to enable debug logging in glob, but not minimatch. - -## Comparisons to other fnmatch/glob implementations - -While strict compliance with the existing standards is a worthwhile -goal, some discrepancies exist between node-glob and other -implementations, and are intentional. - -If the pattern starts with a `!` character, then it is negated. Set the -`nonegate` flag to suppress this behavior, and treat leading `!` -characters normally. This is perhaps relevant if you wish to start the -pattern with a negative extglob pattern like `!(a|B)`. Multiple `!` -characters at the start of a pattern will negate the pattern multiple -times. - -If a pattern starts with `#`, then it is treated as a comment, and -will not match anything. Use `\#` to match a literal `#` at the -start of a line, or set the `nocomment` flag to suppress this behavior. - -The double-star character `**` is supported by default, unless the -`noglobstar` flag is set. This is supported in the manner of bsdglob -and bash 4.1, where `**` only has special significance if it is the only -thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but -`a/**b` will not. **Note that this is different from the way that `**` is -handled by ruby's `Dir` class.** - -If an escaped pattern has no matches, and the `nonull` flag is set, -then glob returns the pattern as-provided, rather than -interpreting the character escapes. For example, -`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than -`"*a?"`. This is akin to setting the `nullglob` option in bash, except -that it does not resolve escaped pattern characters. - -If brace expansion is not disabled, then it is performed before any -other interpretation of the glob pattern. Thus, a pattern like -`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded -**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are -checked for validity. Since those two are valid, matching proceeds. - -## Windows - -**Please only use forward-slashes in glob expressions.** - -Though windows uses either `/` or `\` as its path separator, only `/` -characters are used by this glob implementation. You must use -forward-slashes **only** in glob expressions. Back-slashes will always -be interpreted as escape characters, not path separators. - -Results from absolute patterns such as `/foo/*` are mounted onto the -root setting using `path.join`. On windows, this will by default result -in `/foo/*` matching `C:\foo\bar.txt`. - -## Race Conditions - -Glob searching, by its very nature, is susceptible to race conditions, -since it relies on directory walking and such. - -As a result, it is possible that a file that exists when glob looks for -it may have been deleted or modified by the time it returns the result. - -As part of its internal implementation, this program caches all stat -and readdir calls that it makes, in order to cut down on system -overhead. However, this also makes it even more susceptible to races, -especially if the statCache object is reused between glob calls. - -Users are thus advised not to use a glob result as a -guarantee of filesystem state in the face of rapid changes. -For the vast majority of operations, this is never a problem. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/g.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/g.js deleted file mode 100644 index be122df..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/g.js +++ /dev/null @@ -1,9 +0,0 @@ -var Glob = require("../").Glob - -var pattern = "test/a/**/[cg]/../[cg]" -console.log(pattern) - -var mg = new Glob(pattern, {mark: true, sync:true}, function (er, matches) { - console.log("matches", matches) -}) -console.log("after") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/usr-local.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/usr-local.js deleted file mode 100644 index 327a425..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/examples/usr-local.js +++ /dev/null @@ -1,9 +0,0 @@ -var Glob = require("../").Glob - -var pattern = "{./*/*,/*,/usr/local/*}" -console.log(pattern) - -var mg = new Glob(pattern, {mark: true}, function (er, matches) { - console.log("matches", matches) -}) -console.log("after") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/glob.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/glob.js deleted file mode 100644 index 10c87bc..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/glob.js +++ /dev/null @@ -1,604 +0,0 @@ -// Approach: -// -// 1. Get the minimatch set -// 2. For each pattern in the set, PROCESS(pattern) -// 3. Store matches per-set, then uniq them -// -// PROCESS(pattern) -// Get the first [n] items from pattern that are all strings -// Join these together. This is PREFIX. -// If there is no more remaining, then stat(PREFIX) and -// add to matches if it succeeds. END. -// readdir(PREFIX) as ENTRIES -// If fails, END -// If pattern[n] is GLOBSTAR -// // handle the case where the globstar match is empty -// // by pruning it out, and testing the resulting pattern -// PROCESS(pattern[0..n] + pattern[n+1 .. $]) -// // handle other cases. -// for ENTRY in ENTRIES (not dotfiles) -// // attach globstar + tail onto the entry -// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $]) -// -// else // not globstar -// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) -// Test ENTRY against pattern[n+1] -// If fails, continue -// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) -// -// Caveat: -// Cache all stats and readdirs results to minimize syscall. Since all -// we ever care about is existence and directory-ness, we can just keep -// `true` for files, and [children,...] for directories, or `false` for -// things that don't exist. - - - -module.exports = glob - -var fs = require("graceful-fs") -, minimatch = require("minimatch") -, Minimatch = minimatch.Minimatch -, inherits = require("inherits") -, EE = require("events").EventEmitter -, path = require("path") -, isDir = {} -, assert = require("assert").ok - -function glob (pattern, options, cb) { - if (typeof options === "function") cb = options, options = {} - if (!options) options = {} - - if (typeof options === "number") { - deprecated() - return - } - - var g = new Glob(pattern, options, cb) - return g.sync ? g.found : g -} - -glob.fnmatch = deprecated - -function deprecated () { - throw new Error("glob's interface has changed. Please see the docs.") -} - -glob.sync = globSync -function globSync (pattern, options) { - if (typeof options === "number") { - deprecated() - return - } - - options = options || {} - options.sync = true - return glob(pattern, options) -} - - -glob.Glob = Glob -inherits(Glob, EE) -function Glob (pattern, options, cb) { - if (!(this instanceof Glob)) { - return new Glob(pattern, options, cb) - } - - if (typeof cb === "function") { - this.on("error", cb) - this.on("end", function (matches) { - // console.error("cb with matches", matches) - cb(null, matches) - }) - } - - options = options || {} - - this.EOF = {} - this._emitQueue = [] - - this.maxDepth = options.maxDepth || 1000 - this.maxLength = options.maxLength || Infinity - this.statCache = options.statCache || {} - - this.changedCwd = false - var cwd = process.cwd() - if (!options.hasOwnProperty("cwd")) this.cwd = cwd - else { - this.cwd = options.cwd - this.changedCwd = path.resolve(options.cwd) !== cwd - } - - this.root = options.root || path.resolve(this.cwd, "/") - this.root = path.resolve(this.root) - - this.nomount = !!options.nomount - - if (!pattern) { - throw new Error("must provide pattern") - } - - // base-matching: just use globstar for that. - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar") - } - pattern = "**/" + pattern - } - - this.dot = !!options.dot - this.mark = !!options.mark - this.sync = !!options.sync - this.nounique = !!options.nounique - this.nonull = !!options.nonull - this.nosort = !!options.nosort - this.nocase = !!options.nocase - this.stat = !!options.stat - this.debug = !!options.debug || !!options.globDebug - this.silent = !!options.silent - - var mm = this.minimatch = new Minimatch(pattern, options) - this.options = mm.options - pattern = this.pattern = mm.pattern - - this.error = null - this.aborted = false - - EE.call(this) - - // process each pattern in the minimatch set - var n = this.minimatch.set.length - - // The matches are stored as {: true,...} so that - // duplicates are automagically pruned. - // Later, we do an Object.keys() on these. - // Keep them as a list so we can fill in when nonull is set. - this.matches = new Array(n) - - this.minimatch.set.forEach(iterator.bind(this)) - function iterator (pattern, i, set) { - this._process(pattern, 0, i, function (er) { - if (er) this.emit("error", er) - if (-- n <= 0) this._finish() - }) - } -} - -Glob.prototype._finish = function () { - assert(this instanceof Glob) - - var nou = this.nounique - , all = nou ? [] : {} - - for (var i = 0, l = this.matches.length; i < l; i ++) { - var matches = this.matches[i] - if (this.debug) console.error("matches[%d] =", i, matches) - // do like the shell, and spit out the literal glob - if (!matches) { - if (this.nonull) { - var literal = this.minimatch.globSet[i] - if (nou) all.push(literal) - else all[literal] = true - } - } else { - // had matches - var m = Object.keys(matches) - if (nou) all.push.apply(all, m) - else m.forEach(function (m) { - all[m] = true - }) - } - } - - if (!nou) all = Object.keys(all) - - if (!this.nosort) { - all = all.sort(this.nocase ? alphasorti : alphasort) - } - - if (this.mark) { - // at *some* point we statted all of these - all = all.map(function (m) { - var sc = this.statCache[m] - if (!sc) - return m - var isDir = (Array.isArray(sc) || sc === 2) - if (isDir && m.slice(-1) !== "/") { - return m + "/" - } - if (!isDir && m.slice(-1) === "/") { - return m.replace(/\/+$/, "") - } - return m - }, this) - } - - if (this.debug) console.error("emitting end", all) - - this.EOF = this.found = all - this.emitMatch(this.EOF) -} - -function alphasorti (a, b) { - a = a.toLowerCase() - b = b.toLowerCase() - return alphasort(a, b) -} - -function alphasort (a, b) { - return a > b ? 1 : a < b ? -1 : 0 -} - -Glob.prototype.abort = function () { - this.aborted = true - this.emit("abort") -} - -Glob.prototype.pause = function () { - if (this.paused) return - if (this.sync) - this.emit("error", new Error("Can't pause/resume sync glob")) - this.paused = true - this.emit("pause") -} - -Glob.prototype.resume = function () { - if (!this.paused) return - if (this.sync) - this.emit("error", new Error("Can't pause/resume sync glob")) - this.paused = false - this.emit("resume") - this._processEmitQueue() - //process.nextTick(this.emit.bind(this, "resume")) -} - -Glob.prototype.emitMatch = function (m) { - this._emitQueue.push(m) - this._processEmitQueue() -} - -Glob.prototype._processEmitQueue = function (m) { - while (!this._processingEmitQueue && - !this.paused) { - this._processingEmitQueue = true - var m = this._emitQueue.shift() - if (!m) { - this._processingEmitQueue = false - break - } - if (this.debug) { - console.error('emit!', m === this.EOF ? "end" : "match") - } - this.emit(m === this.EOF ? "end" : "match", m) - this._processingEmitQueue = false - } -} - -Glob.prototype._process = function (pattern, depth, index, cb_) { - assert(this instanceof Glob) - - var cb = function cb (er, res) { - assert(this instanceof Glob) - if (this.paused) { - if (!this._processQueue) { - this._processQueue = [] - this.once("resume", function () { - var q = this._processQueue - this._processQueue = null - q.forEach(function (cb) { cb() }) - }) - } - this._processQueue.push(cb_.bind(this, er, res)) - } else { - cb_.call(this, er, res) - } - }.bind(this) - - if (this.aborted) return cb() - - if (depth > this.maxDepth) return cb() - - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === "string") { - n ++ - } - // now n is the index of the first one that is *not* a string. - - // see if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - prefix = pattern.join("/") - this._stat(prefix, function (exists, isDir) { - // either it's there, or it isn't. - // nothing more to do, either way. - if (exists) { - if (prefix.charAt(0) === "/" && !this.nomount) { - prefix = path.join(this.root, prefix) - } - this.matches[index] = this.matches[index] || {} - this.matches[index][prefix] = true - this.emitMatch(prefix) - } - return cb() - }) - return - - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break - - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's "absolute" like /foo/bar, - // or "relative" like "../baz" - prefix = pattern.slice(0, n) - prefix = prefix.join("/") - break - } - - // get the list of entries. - var read - if (prefix === null) read = "." - else if (isAbsolute(prefix)) { - read = prefix = path.resolve("/", prefix) - if (this.debug) console.error('absolute: ', prefix, this.root, pattern) - } else read = prefix - - if (this.debug) console.error('readdir(%j)', read, this.cwd, this.root) - return this._readdir(read, function (er, entries) { - if (er) { - // not a directory! - // this means that, whatever else comes after this, it can never match - return cb() - } - - // globstar is special - if (pattern[n] === minimatch.GLOBSTAR) { - // test without the globstar, and with every child both below - // and replacing the globstar. - var s = [ pattern.slice(0, n).concat(pattern.slice(n + 1)) ] - entries.forEach(function (e) { - if (e.charAt(0) === "." && !this.dot) return - // instead of the globstar - s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1))) - // below the globstar - s.push(pattern.slice(0, n).concat(e).concat(pattern.slice(n))) - }, this) - - // now asyncForEach over this - var l = s.length - , errState = null - s.forEach(function (gsPattern) { - this._process(gsPattern, depth + 1, index, function (er) { - if (errState) return - if (er) return cb(errState = er) - if (--l <= 0) return cb() - }) - }, this) - - return - } - - // not a globstar - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = pattern[n] - if (typeof pn === "string") { - var found = entries.indexOf(pn) !== -1 - entries = found ? entries[pn] : [] - } else { - var rawGlob = pattern[n]._glob - , dotOk = this.dot || rawGlob.charAt(0) === "." - - entries = entries.filter(function (e) { - return (e.charAt(0) !== "." || dotOk) && - (typeof pattern[n] === "string" && e === pattern[n] || - e.match(pattern[n])) - }) - } - - // If n === pattern.length - 1, then there's no need for the extra stat - // *unless* the user has specified "mark" or "stat" explicitly. - // We know that they exist, since the readdir returned them. - if (n === pattern.length - 1 && - !this.mark && - !this.stat) { - entries.forEach(function (e) { - if (prefix) { - if (prefix !== "/") e = prefix + "/" + e - else e = prefix + e - } - if (e.charAt(0) === "/" && !this.nomount) { - e = path.join(this.root, e) - } - - this.matches[index] = this.matches[index] || {} - this.matches[index][e] = true - this.emitMatch(e) - }, this) - return cb.call(this) - } - - - // now test all the remaining entries as stand-ins for that part - // of the pattern. - var l = entries.length - , errState = null - if (l === 0) return cb() // no matches possible - entries.forEach(function (e) { - var p = pattern.slice(0, n).concat(e).concat(pattern.slice(n + 1)) - this._process(p, depth + 1, index, function (er) { - if (errState) return - if (er) return cb(errState = er) - if (--l === 0) return cb.call(this) - }) - }, this) - }) - -} - -Glob.prototype._stat = function (f, cb) { - assert(this instanceof Glob) - var abs = f - if (f.charAt(0) === "/") { - abs = path.join(this.root, f) - } else if (this.changedCwd) { - abs = path.resolve(this.cwd, f) - } - if (this.debug) console.error('stat', [this.cwd, f, '=', abs]) - if (f.length > this.maxLength) { - var er = new Error("Path name too long") - er.code = "ENAMETOOLONG" - er.path = f - return this._afterStat(f, abs, cb, er) - } - - if (this.statCache.hasOwnProperty(f)) { - var exists = this.statCache[f] - , isDir = exists && (Array.isArray(exists) || exists === 2) - if (this.sync) return cb.call(this, !!exists, isDir) - return process.nextTick(cb.bind(this, !!exists, isDir)) - } - - if (this.sync) { - var er, stat - try { - stat = fs.statSync(abs) - } catch (e) { - er = e - } - this._afterStat(f, abs, cb, er, stat) - } else { - fs.stat(abs, this._afterStat.bind(this, f, abs, cb)) - } -} - -Glob.prototype._afterStat = function (f, abs, cb, er, stat) { - var exists - assert(this instanceof Glob) - if (er || !stat) { - exists = false - } else { - exists = stat.isDirectory() ? 2 : 1 - } - this.statCache[f] = this.statCache[f] || exists - cb.call(this, !!exists, exists === 2) -} - -Glob.prototype._readdir = function (f, cb) { - assert(this instanceof Glob) - var abs = f - if (f.charAt(0) === "/") { - abs = path.join(this.root, f) - } else if (isAbsolute(f)) { - abs = f - } else if (this.changedCwd) { - abs = path.resolve(this.cwd, f) - } - - if (this.debug) console.error('readdir', [this.cwd, f, abs]) - if (f.length > this.maxLength) { - var er = new Error("Path name too long") - er.code = "ENAMETOOLONG" - er.path = f - return this._afterReaddir(f, abs, cb, er) - } - - if (this.statCache.hasOwnProperty(f)) { - var c = this.statCache[f] - if (Array.isArray(c)) { - if (this.sync) return cb.call(this, null, c) - return process.nextTick(cb.bind(this, null, c)) - } - - if (!c || c === 1) { - // either ENOENT or ENOTDIR - var code = c ? "ENOTDIR" : "ENOENT" - , er = new Error((c ? "Not a directory" : "Not found") + ": " + f) - er.path = f - er.code = code - if (this.debug) console.error(f, er) - if (this.sync) return cb.call(this, er) - return process.nextTick(cb.bind(this, er)) - } - - // at this point, c === 2, meaning it's a dir, but we haven't - // had to read it yet, or c === true, meaning it's *something* - // but we don't have any idea what. Need to read it, either way. - } - - if (this.sync) { - var er, entries - try { - entries = fs.readdirSync(abs) - } catch (e) { - er = e - } - return this._afterReaddir(f, abs, cb, er, entries) - } - - fs.readdir(abs, this._afterReaddir.bind(this, f, abs, cb)) -} - -Glob.prototype._afterReaddir = function (f, abs, cb, er, entries) { - assert(this instanceof Glob) - if (entries && !er) { - this.statCache[f] = entries - // if we haven't asked to stat everything for suresies, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. This also gets us one step - // further into ELOOP territory. - if (!this.mark && !this.stat) { - entries.forEach(function (e) { - if (f === "/") e = f + e - else e = f + "/" + e - this.statCache[e] = true - }, this) - } - - return cb.call(this, er, entries) - } - - // now handle errors, and cache the information - if (er) switch (er.code) { - case "ENOTDIR": // totally normal. means it *does* exist. - this.statCache[f] = 1 - return cb.call(this, er) - case "ENOENT": // not terribly unusual - case "ELOOP": - case "ENAMETOOLONG": - case "UNKNOWN": - this.statCache[f] = false - return cb.call(this, er) - default: // some unusual error. Treat as failure. - this.statCache[f] = false - if (this.strict) this.emit("error", er) - if (!this.silent) console.error("glob error", er) - return cb.call(this, er) - } -} - -var isAbsolute = process.platform === "win32" ? absWin : absUnix - -function absWin (p) { - if (absUnix(p)) return true - // pull off the device/UNC bit from a windows path. - // from node's lib/path.js - var splitDeviceRe = - /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?/ - , result = splitDeviceRe.exec(p) - , device = result[1] || '' - , isUnc = device && device.charAt(1) !== ':' - , isAbsolute = !!result[2] || isUnc // UNC paths are always absolute - - return isAbsolute -} - -function absUnix (p) { - return p.charAt(0) === "/" || p === "" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/.npmignore b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/.npmignore deleted file mode 100644 index c2658d7..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/README.md deleted file mode 100644 index 7d2e681..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Just like node's `fs` module, but it does an incremental back-off when -EMFILE is encountered. - -Useful in asynchronous situations where one needs to try to open lots -and lots of files. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/graceful-fs.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/graceful-fs.js deleted file mode 100644 index be9951e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/graceful-fs.js +++ /dev/null @@ -1,312 +0,0 @@ -// this keeps a queue of opened file descriptors, and will make -// fs operations wait until some have closed before trying to open more. - -var fs = require("fs") - -// there is such a thing as TOO graceful. -if (fs.open === gracefulOpen) return - -var queue = [] - , constants = require("constants") - -exports = module.exports = fs -fs._curOpen = 0 - -fs.MIN_MAX_OPEN = 64 -fs.MAX_OPEN = 1024 - -var originalOpen = fs.open - , originalOpenSync = fs.openSync - , originalClose = fs.close - , originalCloseSync = fs.closeSync - - -// prevent EMFILE errors -function OpenReq (path, flags, mode, cb) { - this.path = path - this.flags = flags - this.mode = mode - this.cb = cb -} - -function noop () {} - -fs.open = gracefulOpen - -function gracefulOpen (path, flags, mode, cb) { - if (typeof mode === "function") cb = mode, mode = null - if (typeof cb !== "function") cb = noop - - if (fs._curOpen >= fs.MAX_OPEN) { - queue.push(new OpenReq(path, flags, mode, cb)) - setTimeout(flush) - return - } - open(path, flags, mode, function (er, fd) { - if (er && er.code === "EMFILE" && fs._curOpen > fs.MIN_MAX_OPEN) { - // that was too many. reduce max, get back in queue. - // this should only happen once in a great while, and only - // if the ulimit -n is set lower than 1024. - fs.MAX_OPEN = fs._curOpen - 1 - return fs.open(path, flags, mode, cb) - } - cb(er, fd) - }) -} - -function open (path, flags, mode, cb) { - cb = cb || noop - fs._curOpen ++ - originalOpen.call(fs, path, flags, mode, function (er, fd) { - if (er) onclose() - cb(er, fd) - }) -} - -fs.openSync = function (path, flags, mode) { - var ret - ret = originalOpenSync.call(fs, path, flags, mode) - fs._curOpen ++ - return ret -} - -function onclose () { - fs._curOpen -- - flush() -} - -function flush () { - while (fs._curOpen < fs.MAX_OPEN) { - var req = queue.shift() - if (!req) return - open(req.path, req.flags || "r", req.mode || 0777, req.cb) - } -} - -fs.close = function (fd, cb) { - cb = cb || noop - originalClose.call(fs, fd, function (er) { - onclose() - cb(er) - }) -} - -fs.closeSync = function (fd) { - onclose() - return originalCloseSync.call(fs, fd) -} - - -// (re-)implement some things that are known busted or missing. - -var constants = require("constants") - -// lchmod, broken prior to 0.6.2 -// back-port the fix here. -if (constants.hasOwnProperty('O_SYMLINK') && - process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { - fs.lchmod = function (path, mode, callback) { - callback = callback || noop - fs.open( path - , constants.O_WRONLY | constants.O_SYMLINK - , mode - , function (err, fd) { - if (err) { - callback(err) - return - } - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - fs.fchmod(fd, mode, function (err) { - fs.close(fd, function(err2) { - callback(err || err2) - }) - }) - }) - } - - fs.lchmodSync = function (path, mode) { - var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) - - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - var err, err2 - try { - var ret = fs.fchmodSync(fd, mode) - } catch (er) { - err = er - } - try { - fs.closeSync(fd) - } catch (er) { - err2 = er - } - if (err || err2) throw (err || err2) - return ret - } -} - - -// lutimes implementation, or no-op -if (!fs.lutimes) { - if (constants.hasOwnProperty("O_SYMLINK")) { - fs.lutimes = function (path, at, mt, cb) { - fs.open(path, constants.O_SYMLINK, function (er, fd) { - cb = cb || noop - if (er) return cb(er) - fs.futimes(fd, at, mt, function (er) { - fs.close(fd, function (er2) { - return cb(er || er2) - }) - }) - }) - } - - fs.lutimesSync = function (path, at, mt) { - var fd = fs.openSync(path, constants.O_SYMLINK) - , err - , err2 - , ret - - try { - var ret = fs.futimesSync(fd, at, mt) - } catch (er) { - err = er - } - try { - fs.closeSync(fd) - } catch (er) { - err2 = er - } - if (err || err2) throw (err || err2) - return ret - } - - } else if (fs.utimensat && constants.hasOwnProperty("AT_SYMLINK_NOFOLLOW")) { - // maybe utimensat will be bound soonish? - fs.lutimes = function (path, at, mt, cb) { - fs.utimensat(path, at, mt, constants.AT_SYMLINK_NOFOLLOW, cb) - } - - fs.lutimesSync = function (path, at, mt) { - return fs.utimensatSync(path, at, mt, constants.AT_SYMLINK_NOFOLLOW) - } - - } else { - fs.lutimes = function (_a, _b, _c, cb) { process.nextTick(cb) } - fs.lutimesSync = function () {} - } -} - - -// https://github.com/isaacs/node-graceful-fs/issues/4 -// Chown should not fail on einval or eperm if non-root. - -fs.chown = chownFix(fs.chown) -fs.fchown = chownFix(fs.fchown) -fs.lchown = chownFix(fs.lchown) - -fs.chownSync = chownFixSync(fs.chownSync) -fs.fchownSync = chownFixSync(fs.fchownSync) -fs.lchownSync = chownFixSync(fs.lchownSync) - -function chownFix (orig) { - if (!orig) return orig - return function (target, uid, gid, cb) { - return orig.call(fs, target, uid, gid, function (er, res) { - if (chownErOk(er)) er = null - cb(er, res) - }) - } -} - -function chownFixSync (orig) { - if (!orig) return orig - return function (target, uid, gid) { - try { - return orig.call(fs, target, uid, gid) - } catch (er) { - if (!chownErOk(er)) throw er - } - } -} - -function chownErOk (er) { - // if there's no getuid, or if getuid() is something other than 0, - // and the error is EINVAL or EPERM, then just ignore it. - // This specific case is a silent failure in cp, install, tar, - // and most other unix tools that manage permissions. - // When running as root, or if other types of errors are encountered, - // then it's strict. - if (!er || (!process.getuid || process.getuid() !== 0) - && (er.code === "EINVAL" || er.code === "EPERM")) return true -} - - -// if lchmod/lchown do not exist, then make them no-ops -if (!fs.lchmod) { - fs.lchmod = function (path, mode, cb) { - process.nextTick(cb) - } - fs.lchmodSync = function () {} -} -if (!fs.lchown) { - fs.lchown = function (path, uid, gid, cb) { - process.nextTick(cb) - } - fs.lchownSync = function () {} -} - - - -// on Windows, A/V software can lock the directory, causing this -// to fail with an EACCES or EPERM if the directory contains newly -// created files. Try again on failure, for up to 1 second. -if (process.platform === "win32") { - var rename_ = fs.rename - fs.rename = function rename (from, to, cb) { - var start = Date.now() - rename_(from, to, function CB (er) { - if (er - && (er.code === "EACCES" || er.code === "EPERM") - && Date.now() - start < 1000) { - return rename_(from, to, CB) - } - cb(er) - }) - } -} - - -// if read() returns EAGAIN, then just try it again. -var read = fs.read -fs.read = function (fd, buffer, offset, length, position, callback_) { - var callback - if (callback_ && typeof callback_ === 'function') { - var eagCounter = 0 - callback = function (er, _, __) { - if (er && er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - return read.call(fs, fd, buffer, offset, length, position, callback) - } - callback_.apply(this, arguments) - } - } - return read.call(fs, fd, buffer, offset, length, position, callback) -} - -var readSync = fs.readSync -fs.readSync = function (fd, buffer, offset, length, position) { - var eagCounter = 0 - while (true) { - try { - return readSync.call(fs, fd, buffer, offset, length, position) - } catch (er) { - if (er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - continue - } - throw er - } - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/package.json b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/package.json deleted file mode 100644 index 9ac2815..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me" - }, - "name": "graceful-fs", - "description": "fs monkey-patching to avoid EMFILE and other problems", - "version": "1.1.14", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-graceful-fs.git" - }, - "main": "graceful-fs.js", - "engines": { - "node": ">=0.4.0" - }, - "directories": { - "test": "test" - }, - "scripts": { - "test": "tap test/*.js" - }, - "keywords": [ - "fs", - "EMFILE", - "error", - "handling", - "monkeypatch" - ], - "license": "BSD", - "readme": "Just like node's `fs` module, but it does an incremental back-off when\nEMFILE is encountered.\n\nUseful in asynchronous situations where one needs to try to open lots\nand lots of files.\n", - "readmeFilename": "README.md", - "_id": "graceful-fs@1.1.14", - "_from": "graceful-fs@~1.1.2" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/test/open.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/test/open.js deleted file mode 100644 index d05f880..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/graceful-fs/test/open.js +++ /dev/null @@ -1,41 +0,0 @@ -var test = require('tap').test -var fs = require('../graceful-fs.js') - -test('open an existing file works', function (t) { - var start = fs._curOpen - var fd = fs.openSync(__filename, 'r') - t.equal(fs._curOpen, start + 1) - fs.closeSync(fd) - t.equal(fs._curOpen, start) - fs.open(__filename, 'r', function (er, fd) { - if (er) throw er - t.equal(fs._curOpen, start + 1) - fs.close(fd, function (er) { - if (er) throw er - t.equal(fs._curOpen, start) - t.end() - }) - }) -}) - -test('open a non-existing file throws', function (t) { - var start = fs._curOpen - var er - try { - var fd = fs.openSync('this file does not exist', 'r') - } catch (x) { - er = x - } - t.ok(er, 'should throw') - t.notOk(fd, 'should not get an fd') - t.equal(er.code, 'ENOENT') - t.equal(fs._curOpen, start) - - fs.open('neither does this file', 'r', function (er, fd) { - t.ok(er, 'should throw') - t.notOk(fd, 'should not get an fd') - t.equal(er.code, 'ENOENT') - t.equal(fs._curOpen, start) - t.end() - }) -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/README.md deleted file mode 100644 index b2beaed..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/README.md +++ /dev/null @@ -1,51 +0,0 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/inherits.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/inherits.js deleted file mode 100644 index 061b396..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/inherits.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/package.json b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/package.json deleted file mode 100644 index ada6137..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/node_modules/inherits/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "inherits", - "description": "A tiny simple way to do classic inheritance in js", - "version": "1.0.0", - "keywords": [ - "inheritance", - "class", - "klass", - "oop", - "object-oriented" - ], - "main": "./inherits.js", - "repository": { - "type": "git", - "url": "https://github.com/isaacs/inherits" - }, - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "readme": "A dead simple way to do inheritance in JS.\n\n var inherits = require(\"inherits\")\n\n function Animal () {\n this.alive = true\n }\n Animal.prototype.say = function (what) {\n console.log(what)\n }\n\n inherits(Dog, Animal)\n function Dog () {\n Dog.super.apply(this)\n }\n Dog.prototype.sniff = function () {\n this.say(\"sniff sniff\")\n }\n Dog.prototype.bark = function () {\n this.say(\"woof woof\")\n }\n\n inherits(Chihuahua, Dog)\n function Chihuahua () {\n Chihuahua.super.apply(this)\n }\n Chihuahua.prototype.bark = function () {\n this.say(\"yip yip\")\n }\n\n // also works\n function Cat () {\n Cat.super.apply(this)\n }\n Cat.prototype.hiss = function () {\n this.say(\"CHSKKSS!!\")\n }\n inherits(Cat, Animal, {\n meow: function () { this.say(\"miao miao\") }\n })\n Cat.prototype.purr = function () {\n this.say(\"purr purr\")\n }\n\n\n var c = new Chihuahua\n assert(c instanceof Chihuahua)\n assert(c instanceof Dog)\n assert(c instanceof Animal)\n\nThe actual function is laughably small. 10-lines small.\n", - "readmeFilename": "README.md", - "_id": "inherits@1.0.0", - "_from": "inherits@1" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/package.json b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/package.json deleted file mode 100644 index c65a9c9..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "name": "glob", - "description": "a little globber", - "version": "3.1.14", - "repository": { - "type": "git", - "url": "git://github.com/isaacs/node-glob.git" - }, - "main": "glob.js", - "engines": { - "node": "*" - }, - "dependencies": { - "minimatch": "0.2", - "graceful-fs": "~1.1.2", - "inherits": "1" - }, - "devDependencies": { - "tap": "~0.3", - "mkdirp": "0", - "rimraf": "1" - }, - "scripts": { - "test": "tap test/*.js" - }, - "license": "BSD", - "readme": "# Glob\n\nThis is a glob implementation in JavaScript. It uses the `minimatch`\nlibrary to do its matching.\n\n## Attention: node-glob users!\n\nThe API has changed dramatically between 2.x and 3.x. This library is\nnow 100% JavaScript, and the integer flags have been replaced with an\noptions object.\n\nAlso, there's an event emitter class, proper tests, and all the other\nthings you've come to expect from node modules.\n\nAnd best of all, no compilation!\n\n## Usage\n\n```javascript\nvar glob = require(\"glob\")\n\n// options is optional\nglob(\"**/*.js\", options, function (er, files) {\n // files is an array of filenames.\n // If the `nonull` option is set, and nothing\n // was found, then files is [\"**/*.js\"]\n // er is an error object or null.\n})\n```\n\n## Features\n\nPlease see the [minimatch\ndocumentation](https://github.com/isaacs/minimatch) for more details.\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n* [minimatch documentation](https://github.com/isaacs/minimatch)\n\n## glob(pattern, [options], cb)\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* `cb` {Function}\n * `err` {Error | null}\n * `matches` {Array} filenames found matching the pattern\n\nPerform an asynchronous glob search.\n\n## glob.sync(pattern, [options]\n\n* `pattern` {String} Pattern to be matched\n* `options` {Object}\n* return: {Array} filenames found matching the pattern\n\nPerform a synchronous glob search.\n\n## Class: glob.Glob\n\nCreate a Glob object by instanting the `glob.Glob` class.\n\n```javascript\nvar Glob = require(\"glob\").Glob\nvar mg = new Glob(pattern, options, cb)\n```\n\nIt's an EventEmitter, and starts walking the filesystem to find matches\nimmediately.\n\n### new glob.Glob(pattern, [options], [cb])\n\n* `pattern` {String} pattern to search for\n* `options` {Object}\n* `cb` {Function} Called when an error occurs, or matches are found\n * `err` {Error | null}\n * `matches` {Array} filenames found matching the pattern\n\nNote that if the `sync` flag is set in the options, then matches will\nbe immediately available on the `g.found` member.\n\n### Properties\n\n* `minimatch` The minimatch object that the glob uses.\n* `options` The options object passed in.\n* `error` The error encountered. When an error is encountered, the\n glob object is in an undefined state, and should be discarded.\n* `aborted` Boolean which is set to true when calling `abort()`. There\n is no way at this time to continue a glob search after aborting, but\n you can re-use the statCache to avoid having to duplicate syscalls.\n\n### Events\n\n* `end` When the matching is finished, this is emitted with all the\n matches found. If the `nonull` option is set, and no match was found,\n then the `matches` list contains the original pattern. The matches\n are sorted, unless the `nosort` flag is set.\n* `match` Every time a match is found, this is emitted with the matched.\n* `error` Emitted when an unexpected error is encountered, or whenever\n any fs error occurs if `options.strict` is set.\n* `abort` When `abort()` is called, this event is raised.\n\n### Methods\n\n* `abort` Stop the search.\n\n### Options\n\nAll the options that can be passed to Minimatch can also be passed to\nGlob to change pattern matching behavior. Also, some have been added,\nor have glob-specific ramifications.\n\nAll options are false by default, unless otherwise noted.\n\nAll options are added to the glob object, as well.\n\n* `cwd` The current working directory in which to search. Defaults\n to `process.cwd()`.\n* `root` The place where patterns starting with `/` will be mounted\n onto. Defaults to `path.resolve(options.cwd, \"/\")` (`/` on Unix\n systems, and `C:\\` or some such on Windows.)\n* `nomount` By default, a pattern starting with a forward-slash will be\n \"mounted\" onto the root setting, so that a valid filesystem path is\n returned. Set this flag to disable that behavior.\n* `mark` Add a `/` character to directory matches. Note that this\n requires additional stat calls.\n* `nosort` Don't sort the results.\n* `stat` Set to true to stat *all* results. This reduces performance\n somewhat, and is completely unnecessary, unless `readdir` is presumed\n to be an untrustworthy indicator of file existence. It will cause\n ELOOP to be triggered one level sooner in the case of cyclical\n symbolic links.\n* `silent` When an unusual error is encountered\n when attempting to read a directory, a warning will be printed to\n stderr. Set the `silent` option to true to suppress these warnings.\n* `strict` When an unusual error is encountered\n when attempting to read a directory, the process will just continue on\n in search of other matches. Set the `strict` option to raise an error\n in these cases.\n* `statCache` A cache of results of filesystem information, to prevent\n unnecessary stat calls. While it should not normally be necessary to\n set this, you may pass the statCache from one glob() call to the\n options object of another, if you know that the filesystem will not\n change between calls. (See \"Race Conditions\" below.)\n* `sync` Perform a synchronous glob search.\n* `nounique` In some cases, brace-expanded patterns can result in the\n same file showing up multiple times in the result set. By default,\n this implementation prevents duplicates in the result set.\n Set this flag to disable that behavior.\n* `nonull` Set to never return an empty set, instead returning a set\n containing the pattern itself. This is the default in glob(3).\n* `nocase` Perform a case-insensitive match. Note that case-insensitive\n filesystems will sometimes result in glob returning results that are\n case-insensitively matched anyway, since readdir and stat will not\n raise an error.\n* `debug` Set to enable debug logging in minimatch and glob.\n* `globDebug` Set to enable debug logging in glob, but not minimatch.\n\n## Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between node-glob and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not. **Note that this is different from the way that `**` is\nhandled by ruby's `Dir` class.**\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen glob returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`glob.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n## Windows\n\n**Please only use forward-slashes in glob expressions.**\n\nThough windows uses either `/` or `\\` as its path separator, only `/`\ncharacters are used by this glob implementation. You must use\nforward-slashes **only** in glob expressions. Back-slashes will always\nbe interpreted as escape characters, not path separators.\n\nResults from absolute patterns such as `/foo/*` are mounted onto the\nroot setting using `path.join`. On windows, this will by default result\nin `/foo/*` matching `C:\\foo\\bar.txt`.\n\n## Race Conditions\n\nGlob searching, by its very nature, is susceptible to race conditions,\nsince it relies on directory walking and such.\n\nAs a result, it is possible that a file that exists when glob looks for\nit may have been deleted or modified by the time it returns the result.\n\nAs part of its internal implementation, this program caches all stat\nand readdir calls that it makes, in order to cut down on system\noverhead. However, this also makes it even more susceptible to races,\nespecially if the statCache object is reused between glob calls.\n\nUsers are thus advised not to use a glob result as a\nguarantee of filesystem state in the face of rapid changes.\nFor the vast majority of operations, this is never a problem.\n", - "readmeFilename": "README.md", - "_id": "glob@3.1.14", - "_from": "glob@~3.1.14" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/00-setup.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/00-setup.js deleted file mode 100644 index 2b60643..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/00-setup.js +++ /dev/null @@ -1,61 +0,0 @@ -// just a little pre-run script to set up the fixtures. -// zz-finish cleans it up - -var mkdirp = require("mkdirp") -var path = require("path") -var i = 0 -var tap = require("tap") -var fs = require("fs") -var rimraf = require("rimraf") - -var files = -[ "a/.abcdef/x/y/z/a" -, "a/abcdef/g/h" -, "a/abcfed/g/h" -, "a/b/c/d" -, "a/bc/e/f" -, "a/c/d/c/b" -, "a/cb/e/f" -] - -var symlinkTo = path.resolve(__dirname, "a/symlink/a/b/c") -var symlinkFrom = "../.." - -files = files.map(function (f) { - return path.resolve(__dirname, f) -}) - -tap.test("remove fixtures", function (t) { - rimraf(path.resolve(__dirname, "a"), function (er) { - t.ifError(er, "remove fixtures") - t.end() - }) -}) - -files.forEach(function (f) { - tap.test(f, function (t) { - var d = path.dirname(f) - mkdirp(d, 0755, function (er) { - if (er) { - t.fail(er) - return t.bailout() - } - fs.writeFile(f, "i like tests", function (er) { - t.ifError(er, "make file") - t.end() - }) - }) - }) -}) - -tap.test("symlinky", function (t) { - var d = path.dirname(symlinkTo) - console.error("mkdirp", d) - mkdirp(d, 0755, function (er) { - t.ifError(er) - fs.symlink(symlinkFrom, symlinkTo, function (er) { - t.ifError(er, "make symlink") - t.end() - }) - }) -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/bash-comparison.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/bash-comparison.js deleted file mode 100644 index a052ae8..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/bash-comparison.js +++ /dev/null @@ -1,118 +0,0 @@ -// basic test -// show that it does the same thing by default as the shell. -var tap = require("tap") -, child_process = require("child_process") - -// put more patterns here. -, globs = - ["test/a/*/+(c|g)/./d" - ,"test/a/**/[cg]/../[cg]" - ,"test/a/{b,c,d,e,f}/**/g" - ,"test/a/b/**" - ,"test/**/g" - ,"test/a/abc{fed,def}/g/h" - ,"test/a/abc{fed/g,def}/**/" - ,"test/a/abc{fed/g,def}/**///**/" - ,"test/**/a/**/" - ,"test/+(a|b|c)/a{/,bc*}/**" - ,"test/*/*/*/f" - ,"test/**/f" - ,"test/a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**" - ,"{./*/*,/usr/local/*}" - ,"{/*,*}" // evil owl face! how you taunt me! - ] -, glob = require("../") -, path = require("path") - -// run from the root of the project -// this is usually where you're at anyway, but be sure. -process.chdir(path.resolve(__dirname, "..")) - -function alphasort (a, b) { - a = a.toLowerCase() - b = b.toLowerCase() - return a > b ? 1 : a < b ? -1 : 0 -} - -globs.forEach(function (pattern) { - var echoOutput - tap.test(pattern, function (t) { - var bashPattern = pattern - , cmd = "shopt -s globstar && " + - "shopt -s extglob && " + - "shopt -s nullglob && " + - // "shopt >&2; " + - "eval \'for i in " + bashPattern + "; do echo $i; done\'" - , cp = child_process.spawn("bash", ["-c",cmd]) - , out = [] - , globResult - cp.stdout.on("data", function (c) { - out.push(c) - }) - cp.stderr.on("data", function (c) { - process.stderr.write(c) - }) - cp.on("close", function () { - echoOutput = flatten(out) - if (!echoOutput) echoOutput = [] - else { - echoOutput = echoOutput.split(/\r*\n/).map(function (m) { - // Bash is a oddly inconsistent with slashes in the - // the results. This implementation is a bit more - // normalized. Account for this in the test results. - return m.replace(/\/+/g, "/").replace(/\/$/, "") - }).sort(alphasort).reduce(function (set, f) { - if (f !== set[set.length - 1]) set.push(f) - return set - }, []).sort(alphasort) - } - next() - }) - - glob(pattern, function (er, matches) { - // sort and unpark, just to match the shell results - matches = matches.map(function (m) { - return m.replace(/\/+/g, "/").replace(/\/$/, "") - }).sort(alphasort).reduce(function (set, f) { - if (f !== set[set.length - 1]) set.push(f) - return set - }, []).sort(alphasort) - - t.ifError(er, pattern + " should not error") - globResult = matches - next() - }) - - function next () { - if (!echoOutput || !globResult) return - - t.deepEqual(globResult, echoOutput, "should match shell") - t.end() - } - }) - - tap.test(pattern + " sync", function (t) { - var matches = glob.sync(pattern).map(function (m) { - return m.replace(/\/+/g, "/").replace(/\/$/, "") - }).sort(alphasort).reduce(function (set, f) { - if (f !== set[set.length - 1]) set.push(f) - return set - }, []).sort(alphasort) - - t.deepEqual(matches, echoOutput, "should match shell") - t.end() - }) -}) - -function flatten (chunks) { - var s = 0 - chunks.forEach(function (c) { s += c.length }) - var out = new Buffer(s) - s = 0 - chunks.forEach(function (c) { - c.copy(out, s) - s += c.length - }) - - return out.toString().trim() -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/cwd-test.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/cwd-test.js deleted file mode 100644 index 352c27e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/cwd-test.js +++ /dev/null @@ -1,55 +0,0 @@ -var tap = require("tap") - -var origCwd = process.cwd() -process.chdir(__dirname) - -tap.test("changing cwd and searching for **/d", function (t) { - var glob = require('../') - var path = require('path') - t.test('.', function (t) { - glob('**/d', function (er, matches) { - t.ifError(er) - t.like(matches, [ 'a/b/c/d', 'a/c/d' ]) - t.end() - }) - }) - - t.test('a', function (t) { - glob('**/d', {cwd:path.resolve('a')}, function (er, matches) { - t.ifError(er) - t.like(matches, [ 'b/c/d', 'c/d' ]) - t.end() - }) - }) - - t.test('a/b', function (t) { - glob('**/d', {cwd:path.resolve('a/b')}, function (er, matches) { - t.ifError(er) - t.like(matches, [ 'c/d' ]) - t.end() - }) - }) - - t.test('a/b/', function (t) { - glob('**/d', {cwd:path.resolve('a/b/')}, function (er, matches) { - t.ifError(er) - t.like(matches, [ 'c/d' ]) - t.end() - }) - }) - - t.test('.', function (t) { - glob('**/d', {cwd: process.cwd()}, function (er, matches) { - t.ifError(er) - t.like(matches, [ 'a/b/c/d', 'a/c/d' ]) - t.end() - }) - }) - - t.test('cd -', function (t) { - process.chdir(origCwd) - t.end() - }) - - t.end() -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/mark.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/mark.js deleted file mode 100644 index fda66f8..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/mark.js +++ /dev/null @@ -1,63 +0,0 @@ -var test = require("tap").test -var glob = require('../') -process.chdir(__dirname) - -test("mark, no / on pattern", function (t) { - glob("a/*", {mark: true}, function (er, results) { - if (er) - throw er - t.same(results, [ 'a/abcdef/', - 'a/abcfed/', - 'a/b/', - 'a/bc/', - 'a/c/', - 'a/cb/', - 'a/symlink/' ]) - t.end() - }) -}) - -test("mark=false, no / on pattern", function (t) { - glob("a/*", function (er, results) { - if (er) - throw er - t.same(results, [ 'a/abcdef', - 'a/abcfed', - 'a/b', - 'a/bc', - 'a/c', - 'a/cb', - 'a/symlink' ]) - t.end() - }) -}) - -test("mark=true, / on pattern", function (t) { - glob("a/*/", {mark: true}, function (er, results) { - if (er) - throw er - t.same(results, [ 'a/abcdef/', - 'a/abcfed/', - 'a/b/', - 'a/bc/', - 'a/c/', - 'a/cb/', - 'a/symlink/' ]) - t.end() - }) -}) - -test("mark=false, / on pattern", function (t) { - glob("a/*/", function (er, results) { - if (er) - throw er - t.same(results, [ 'a/abcdef/', - 'a/abcfed/', - 'a/b/', - 'a/bc/', - 'a/c/', - 'a/cb/', - 'a/symlink/' ]) - t.end() - }) -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/pause-resume.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/pause-resume.js deleted file mode 100644 index c848ed2..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/pause-resume.js +++ /dev/null @@ -1,106 +0,0 @@ -// show that no match events happen while paused. -var tap = require("tap") -, child_process = require("child_process") -// just some gnarly pattern with lots of matches -, pattern = "test/a/!(symlink)/**" -, glob = require("../") -, Glob = glob.Glob -, path = require("path") - -// run from the root of the project -// this is usually where you're at anyway, but be sure. -process.chdir(path.resolve(__dirname, "..")) - -function alphasort (a, b) { - a = a.toLowerCase() - b = b.toLowerCase() - return a > b ? 1 : a < b ? -1 : 0 -} - -function cleanResults (m) { - // normalize discrepancies in ordering, duplication, - // and ending slashes. - return m.map(function (m) { - return m.replace(/\/+/g, "/").replace(/\/$/, "") - }).sort(alphasort).reduce(function (set, f) { - if (f !== set[set.length - 1]) set.push(f) - return set - }, []).sort(alphasort) -} - -function flatten (chunks) { - var s = 0 - chunks.forEach(function (c) { s += c.length }) - var out = new Buffer(s) - s = 0 - chunks.forEach(function (c) { - c.copy(out, s) - s += c.length - }) - - return out.toString().trim() -} -var bashResults -tap.test("get bash output", function (t) { - var bashPattern = pattern - , cmd = "shopt -s globstar && " + - "shopt -s extglob && " + - "shopt -s nullglob && " + - // "shopt >&2; " + - "eval \'for i in " + bashPattern + "; do echo $i; done\'" - , cp = child_process.spawn("bash", ["-c",cmd]) - , out = [] - , globResult - cp.stdout.on("data", function (c) { - out.push(c) - }) - cp.stderr.on("data", function (c) { - process.stderr.write(c) - }) - cp.on("close", function () { - bashResults = flatten(out) - if (!bashResults) return t.fail("Didn't get results from bash") - else { - bashResults = cleanResults(bashResults.split(/\r*\n/)) - } - t.ok(bashResults.length, "got some results") - t.end() - }) -}) - -var globResults = [] -tap.test("use a Glob object, and pause/resume it", function (t) { - var g = new Glob(pattern) - , paused = false - , res = [] - - g.on("pause", function () { - console.error("pause") - }) - - g.on("resume", function () { - console.error("resume") - }) - - g.on("match", function (m) { - t.notOk(g.paused, "must not be paused") - globResults.push(m) - g.pause() - t.ok(g.paused, "must be paused") - setTimeout(g.resume.bind(g), 10) - }) - - g.on("end", function (matches) { - t.pass("reached glob end") - globResults = cleanResults(globResults) - matches = cleanResults(matches) - t.deepEqual(matches, globResults, - "end event matches should be the same as match events") - - t.deepEqual(matches, bashResults, - "glob matches should be the same as bash results") - - t.end() - }) -}) - diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root-nomount.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root-nomount.js deleted file mode 100644 index 3ac5979..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root-nomount.js +++ /dev/null @@ -1,39 +0,0 @@ -var tap = require("tap") - -var origCwd = process.cwd() -process.chdir(__dirname) - -tap.test("changing root and searching for /b*/**", function (t) { - var glob = require('../') - var path = require('path') - t.test('.', function (t) { - glob('/b*/**', { globDebug: true, root: '.', nomount: true }, function (er, matches) { - t.ifError(er) - t.like(matches, []) - t.end() - }) - }) - - t.test('a', function (t) { - glob('/b*/**', { globDebug: true, root: path.resolve('a'), nomount: true }, function (er, matches) { - t.ifError(er) - t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ]) - t.end() - }) - }) - - t.test('root=a, cwd=a/b', function (t) { - glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b'), nomount: true }, function (er, matches) { - t.ifError(er) - t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ]) - t.end() - }) - }) - - t.test('cd -', function (t) { - process.chdir(origCwd) - t.end() - }) - - t.end() -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root.js deleted file mode 100644 index 5ccdd0e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/root.js +++ /dev/null @@ -1,43 +0,0 @@ -var tap = require("tap") - -var origCwd = process.cwd() -process.chdir(__dirname) - -tap.test("changing root and searching for /b*/**", function (t) { - var glob = require('../') - var path = require('path') - t.test('.', function (t) { - glob('/b*/**', { globDebug: true, root: '.' }, function (er, matches) { - t.ifError(er) - t.like(matches, []) - t.end() - }) - }) - - t.test('a', function (t) { - glob('/b*/**', { globDebug: true, root: path.resolve('a') }, function (er, matches) { - t.ifError(er) - t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) { - return path.join(path.resolve('a'), m) - })) - t.end() - }) - }) - - t.test('root=a, cwd=a/b', function (t) { - glob('/b*/**', { globDebug: true, root: 'a', cwd: path.resolve('a/b') }, function (er, matches) { - t.ifError(er) - t.like(matches, [ '/b', '/b/c', '/b/c/d', '/bc', '/bc/e', '/bc/e/f' ].map(function (m) { - return path.join(path.resolve('a'), m) - })) - t.end() - }) - }) - - t.test('cd -', function (t) { - process.chdir(origCwd) - t.end() - }) - - t.end() -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/zz-cleanup.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/zz-cleanup.js deleted file mode 100644 index e085f0f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/glob/test/zz-cleanup.js +++ /dev/null @@ -1,11 +0,0 @@ -// remove the fixtures -var tap = require("tap") -, rimraf = require("rimraf") -, path = require("path") - -tap.test("cleanup fixtures", function (t) { - rimraf(path.resolve(__dirname, "a"), function (er) { - t.ifError(er, "removed") - t.end() - }) -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/LICENSE.txt b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/LICENSE.txt deleted file mode 100644 index b194ad1..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/LICENSE.txt +++ /dev/null @@ -1,22 +0,0 @@ -Copyright 2012 John-David Dalton -Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, -DocumentCloud Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/README.md deleted file mode 100644 index d404834..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/README.md +++ /dev/null @@ -1,264 +0,0 @@ -# Lo-Dash v0.10.0 -[![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) - -A drop-in replacement[*](https://github.com/bestiejs/lodash/wiki/Drop-in-Disclaimer) for Underscore.js, from the devs behind [jsPerf.com](http://jsperf.com), delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), and [additional features](http://lodash.com/#features). - -Lo-Dash’s performance is gained by avoiding slower native methods, instead opting for simplified non-ES5 compliant methods optimized for common usage, and by leveraging function compilation to reduce the number of overall function calls. - -## Download - - * [Development build](https://raw.github.com/bestiejs/lodash/v0.10.0/lodash.js) - * [Production build](https://raw.github.com/bestiejs/lodash/v0.10.0/lodash.min.js) - * [Underscore build](https://raw.github.com/bestiejs/lodash/v0.10.0/lodash.underscore.min.js) tailored for projects already using Underscore - * CDN copies of ≤ v0.10.0’s [Production](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.min.js), [Underscore](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.underscore.min.js), and [Development](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/0.10.0/lodash.js) builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/) - * For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need - -## Dive in - -We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/benchmarks), and [unit tests](http://lodash.com/tests). - -Create your own benchmarks at [jsPerf](http://jsperf.com), or [search](http://jsperf.com/search?q=lodash) for existing ones. - -For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). - -## Screencasts - -For more information check out these screencasts over Lo-Dash: - - * [Introducing Lo-Dash](https://vimeo.com/44154599) - * [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601) - * [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600) - * [Unit testing in Lo-Dash](https://vimeo.com/45865290) - * [Lo-Dash’s approach to native method use](https://vimeo.com/48576012) - * [CascadiaJS: Lo-Dash for a better utility belt](http://www.youtube.com/watch?v=dpPy4f_SeEk) - -## Features - - * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) - * [_.clone](http://lodash.com/docs#clone) supports *“deep”* cloning - * [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument - * [_.forEach](http://lodash.com/docs#forEach) is chainable and supports exiting iteration early - * [_.forIn](http://lodash.com/docs#forIn) for iterating over an object’s own and inherited properties - * [_.forOwn](http://lodash.com/docs#forOwn) for iterating over an object’s own properties - * [_.isPlainObject](http://lodash.com/docs#isPlainObject) checks if values are created by the `Object` constructor - * [_.bindKey](http://lodash.com/docs#bindKey) for binding [*“lazy”* defined](http://michaux.ca/articles/lazy-function-definition-pattern) methods - * [_.merge](http://lodash.com/docs#merge) for a *“deep”* [_.extend](http://lodash.com/docs#extend) - * [_.partial](http://lodash.com/docs#partial) for partial application without `this` binding - * [_.pick](http://lodash.com/docs#pick) and [_.omit](http://lodash.com/docs#omit) accepts `callback` and `thisArg` arguments - * [_.template](http://lodash.com/docs#template) supports [ES6 delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6) and utilizes [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) for easier debugging - * [_.contains](http://lodash.com/docs#contains), [_.size](http://lodash.com/docs#size), [_.toArray](http://lodash.com/docs#toArray), - [and more…](http://lodash.com/docs "_.countBy, _.every, _.filter, _.find, _.forEach, _.groupBy, _.invoke, _.map, _.max, _.min, _.pluck, _.reduce, _.reduceRight, _.reject, _.shuffle, _.some, _.sortBy, _.where") accept strings - -## Support - -Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~16, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.14, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. - -## Custom builds - -Custom builds make it easy to create lightweight versions of Lo-Dash containing only the methods you need. -To top it off, we handle all method dependency and alias mapping for you. - - * Backbone builds, with only methods required by Backbone, may be created using the `backbone` modifier argument. -```bash -lodash backbone -``` - - * CSP builds, supporting default [Content Security Policy](http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html) restrictions, may be created using the `csp` modifier argument. - The `csp` modifier is an alais of the `mobile` modifier. Chrome extensions will require [sandboxing](http://developer.chrome.com/trunk/extensions/sandboxingEval.html) or the use of either the `csp`, `mobile`, or `underscore` build. -```bash -lodash csp -``` - - * Legacy builds, tailored for older browsers without [ES5 support](http://es5.github.com/), may be created using the `legacy` modifier argument. -```bash -lodash legacy -``` - - * Mobile builds, with IE < 9 bug fixes and method compilation removed, may be created using the `mobile` modifier argument. -```bash -lodash mobile -``` - - * Strict builds, with `_.bindAll`, `_.defaults`, and `_.extend` in [strict mode](http://es5.github.com/#C), may be created using the `strict` modifier argument. -```bash -lodash strict -``` - - * Underscore builds, tailored for projects already using Underscore, may be created using the `underscore` modifier argument. -```bash -lodash underscore -``` - -Custom builds may be created using the following commands: - - * Use the `category` argument to pass comma separated categories of methods to include in the build.
- Valid categories (case-insensitive) are *“arrays”*, *“chaining”*, *“collections”*, *“functions”*, *“objects”*, and *“utilities”*. -```bash -lodash category=collections,functions -lodash category="collections, functions" -``` - - * Use the `exports` argument to pass comma separated names of ways to export the `LoDash` function.
- Valid exports are *“amd”*, *“commonjs”*, *“global”*, *“node”*, and *“none”*. -```bash -lodash exports=amd,commonjs,node -lodash exports="amd, commonjs, node" -``` - - * Use the `iife` argument to specify code to replace the immediately-invoked function expression that wraps Lo-Dash. -```bash -lodash iife="!function(window,undefined){%output%}(this)" -``` - - * Use the `include` argument to pass comma separated method/category names to include in the build. -```bash -lodash include=each,filter,map -lodash include="each, filter, map" -``` - - * Use the `minus` argument to pass comma separated method/category names to remove from those included in the build. -```bash -lodash underscore minus=result,shuffle -lodash underscore minus="result, shuffle" -``` - - * Use the `plus` argument to pass comma separated method/category names to add to those included in the build. -```bash -lodash backbone plus=random,template -lodash backbone plus="random, template" -``` - - * Use the `template` argument to pass the file path pattern used to match template files to precompile. -```bash -lodash template="./*.jst" -``` - - * Use the `settings` argument to pass the template settings used when precompiling templates. -```bash -lodash settings="{interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/g}" -``` - - * Use the `moduleId` argument to specify the AMD module ID of Lo-Dash, which defaults to “lodash”, used by precompiled templates. -```bash -lodash moduleId="underscore" -``` - -All arguments, except `legacy` with `csp` or `mobile`, may be combined.
-Unless specified by `-o` or `--output`, all files created are saved to the current working directory. - -The following options are also supported: - - * `-c`, `--stdout`     Write output to standard output - * `-d`, `--debug`       Write only the debug output - * `-h`, `--help`         Display help information - * `-m`, `--minify`     Write only the minified output - * `-o`, `--output`     Write output to a given path/filename - * `-s`, `--silent`     Skip status updates normally logged to the console - * `-V`, `--version`   Output current version of Lo-Dash - -The `lodash` command-line utility is available when Lo-Dash is installed as a global package (i.e. `npm install -g lodash`). - -## Installation and usage - -In browsers: - -```html - -``` - -Using [`npm`](http://npmjs.org/): - -```bash -npm install lodash - -npm install -g lodash -npm link lodash -``` - -To avoid potential issues, update `npm` before installing Lo-Dash: - -```bash -npm install npm -g -``` - -In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): - -```js -var _ = require('lodash'); -``` - -**Note:** If Lo-Dash is installed globally, [run `npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it. - -In [RingoJS v0.7.0-](http://ringojs.org/): - -```js -var _ = require('lodash')._; -``` - -In [Rhino](http://www.mozilla.org/rhino/): - -```js -load('lodash.js'); -``` - -In an AMD loader like [RequireJS](http://requirejs.org/): - -```js -require({ - 'paths': { - 'underscore': 'path/to/lodash' - } -}, -['underscore'], function(_) { - console.log(_.VERSION); -}); -``` - -## Resolved Underscore.js issues - - * Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L590-L596)] - * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L603-L627)] - * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L140-L146)] - * `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L792-L797)] - * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L873-L885)] - * `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L966-L968)] - * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L1367-L1370)] - -## Release Notes - -### v0.10.0 - -#### Compatibility Warnings #### - - * Aligned `_.defaults` and `_.extend` with ES6 [Object.assign](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.2.3.15) - * Renamed `_.lateBind` to `_.bindKey` - -#### Changes #### - - * Added the build commands used to custom build copyright/license headers - * Added `_.assign` - * Ensured the `underscore` build of `_.find` returns the first, not last, matched value - * Ensured `_defaults`, `_.extends`, and `_.merge` works with `_.reduce` - * Made Lo-Dash’s `npm` package installation work with more system configurations - * Made `_.extend` an alias of `_.assign` - * Optimized `_.contains`, `_.defaults`, `_.extend`, and `_.filter` - * Restricted `_.where` to iterate only own properties of the `source` object - * Updated `backbone` build Lo-Dash method dependencies - -The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog). - -## BestieJS - -Lo-Dash is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. - -## Author - -* [John-David Dalton](http://allyoucanleet.com/) - [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") - -## Contributors - -* [Kit Cambridge](http://kitcambridge.github.com/) - [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") -* [Mathias Bynens](http://mathiasbynens.be/) - [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build.js deleted file mode 100755 index 23f060b..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build.js +++ /dev/null @@ -1,1835 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** Load modules */ - var fs = require('fs'), - path = require('path'), - vm = require('vm'), - minify = require(path.join(__dirname, 'build', 'minify.js')), - _ = require(path.join(__dirname, 'lodash.js')); - - /** The current working directory */ - var cwd = process.cwd(); - - /** Used for array method references */ - var arrayRef = []; - - /** Shortcut used to push arrays of values to an array */ - var push = arrayRef.push; - - /** Shortcut used to convert array-like objects to arrays */ - var slice = arrayRef.slice; - - /** Shortcut to the `stdout` object */ - var stdout = process.stdout; - - /** Used to associate aliases with their real names */ - var aliasToRealMap = { - 'all': 'every', - 'any': 'some', - 'collect': 'map', - 'detect': 'find', - 'drop': 'rest', - 'each': 'forEach', - 'extend': 'assign', - 'foldl': 'reduce', - 'foldr': 'reduceRight', - 'head': 'first', - 'include': 'contains', - 'inject': 'reduce', - 'methods': 'functions', - 'select': 'filter', - 'tail': 'rest', - 'take': 'first', - 'unique': 'uniq' - }; - - /** Used to associate real names with their aliases */ - var realToAliasMap = { - 'assign': ['extend'], - 'contains': ['include'], - 'every': ['all'], - 'filter': ['select'], - 'find': ['detect'], - 'first': ['head', 'take'], - 'forEach': ['each'], - 'functions': ['methods'], - 'map': ['collect'], - 'reduce': ['foldl', 'inject'], - 'reduceRight': ['foldr'], - 'rest': ['drop', 'tail'], - 'some': ['any'], - 'uniq': ['unique'] - }; - - /** Used to track function dependencies */ - var dependencyMap = { - 'after': [], - 'assign': ['isArguments'], - 'bind': ['isFunction', 'isObject'], - 'bindAll': ['bind', 'functions'], - 'bindKey': ['isFunction', 'isObject'], - 'chain': ['mixin'], - 'clone': ['assign', 'forEach', 'forOwn', 'isArguments', 'isObject', 'isPlainObject'], - 'compact': [], - 'compose': [], - 'contains': ['forEach', 'indexOf', 'isString'], - 'countBy': ['forEach'], - 'debounce': [], - 'defaults': ['isArguments'], - 'defer': [], - 'delay': [], - 'difference': ['indexOf'], - 'escape': [], - 'every': ['forEach', 'isArray'], - 'filter': ['forEach', 'isArray'], - 'find': ['forEach'], - 'first': [], - 'flatten': ['isArray'], - 'forEach': ['identity', 'isString'], - 'forIn': ['identity', 'isArguments'], - 'forOwn': ['identity', 'isArguments'], - 'functions': ['forIn', 'isFunction'], - 'groupBy': ['forEach'], - 'has': [], - 'identity': [], - 'indexOf': ['sortedIndex'], - 'initial': [], - 'intersection': ['filter', 'indexOf'], - 'invert': ['forOwn'], - 'invoke': ['forEach'], - 'isArguments': [], - 'isArray': [], - 'isBoolean': [], - 'isDate': [], - 'isElement': [], - 'isEmpty': ['forOwn', 'isArguments', 'isFunction'], - 'isEqual': ['isArguments', 'isFunction'], - 'isFinite': [], - 'isFunction': [], - 'isNaN': [], - 'isNull': [], - 'isNumber': [], - 'isObject': [], - 'isPlainObject': ['forIn', 'isArguments', 'isFunction'], - 'isRegExp': [], - 'isString': [], - 'isUndefined': [], - 'keys': ['forOwn', 'isArguments', 'isObject'], - 'last': [], - 'lastIndexOf': [], - 'map': ['forEach', 'isArray'], - 'max': ['forEach', 'isArray', 'isString'], - 'memoize': [], - 'merge': ['forOwn', 'isArray', 'isPlainObject'], - 'min': ['forEach', 'isArray', 'isString'], - 'mixin': ['forEach', 'functions'], - 'noConflict': [], - 'object': [], - 'omit': ['forIn', 'indexOf'], - 'once': [], - 'pairs': ['forOwn'], - 'partial': ['isFunction', 'isObject'], - 'pick': ['forIn'], - 'pluck': ['forEach'], - 'random': [], - 'range': [], - 'reduce': ['forEach'], - 'reduceRight': ['forEach', 'isString', 'keys'], - 'reject': ['filter'], - 'rest': [], - 'result': ['isFunction'], - 'shuffle': ['forEach'], - 'size': ['keys'], - 'some': ['forEach', 'isArray'], - 'sortBy': ['forEach'], - 'sortedIndex': ['identity'], - 'tap': ['mixin'], - 'template': ['escape'], - 'throttle': [], - 'times': [], - 'toArray': ['values'], - 'unescape': [], - 'union': ['uniq'], - 'uniq': ['identity', 'indexOf'], - 'uniqueId': [], - 'value': ['mixin'], - 'values': ['forOwn'], - 'where': ['filter', 'keys'], - 'without': ['indexOf'], - 'wrap': [], - 'zip': ['max', 'pluck'] - }; - - /** Used to inline `iteratorTemplate` */ - var iteratorOptions = [ - 'args', - 'arrayLoop', - 'bottom', - 'firstArg', - 'hasDontEnumBug', - 'isKeysFast', - 'objectLoop', - 'noArgsEnum', - 'noCharByIndex', - 'shadowed', - 'top', - 'useHas', - 'useStrict' - ]; - - /** List of all Lo-Dash methods */ - var allMethods = _.keys(dependencyMap); - - /** List of Backbone's Lo-Dash dependencies */ - var backboneDependencies = [ - 'bind', - 'bindAll', - 'chain', - 'clone', - 'contains', - 'countBy', - 'defaults', - 'escape', - 'every', - 'extend', - 'filter', - 'find', - 'first', - 'forEach', - 'groupBy', - 'has', - 'indexOf', - 'initial', - 'invoke', - 'isArray', - 'isEmpty', - 'isEqual', - 'isFunction', - 'isObject', - 'isRegExp', - 'isString', - 'keys', - 'last', - 'lastIndexOf', - 'map', - 'max', - 'min', - 'mixin', - 'pick', - 'reduce', - 'reduceRight', - 'reject', - 'rest', - 'result', - 'shuffle', - 'size', - 'some', - 'sortBy', - 'sortedIndex', - 'toArray', - 'uniqueId', - 'value', - 'without' - ]; - - /** List of methods used by Underscore */ - var underscoreMethods = _.without.apply(_, [allMethods].concat([ - 'bindKey', - 'forIn', - 'forOwn', - 'isPlainObject', - 'merge', - 'partial' - ])); - - /** List of ways to export the `lodash` function */ - var exportsAll = [ - 'amd', - 'commonjs', - 'global', - 'node' - ]; - - /*--------------------------------------------------------------------------*/ - - /** - * Adds the given build `commands` to the copyright/license header of `source`. - * - * @private - * @param {String} source The source to process. - * @param {Array} [commands=[]] An array of commands. - * @returns {String} Returns the modified source. - */ - function addCommandsToHeader(source, commands) { - return source.replace(/(\/\*!\n)( \*)?( *Lo-Dash [0-9.]+)(.*)/, function() { - // convert unmatched groups to empty strings - var parts = _.map(slice.call(arguments, 1), function(part) { - return part || ''; - }); - - // remove `node path/to/build.js` from `commands` - if (commands[0] == 'node') { - commands.splice(0, 2); - } - // add quotes to commands with spaces or equals signs - commands = _.map(commands, function(command) { - var separator = (command.match(/[= ]/) || [''])[0]; - if (separator) { - var pair = command.split(separator); - command = pair[0] + separator + '"' + pair[1] + '"'; - } - return command; - }); - // add build commands to copyright/license header - return ( - parts[0] + parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' + - parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' - ); - }); - } - - /** - * Compiles template files matched by the given file path `pattern` into a - * single source, extending `_.templates` with precompiled templates named after - * each template file's basename. - * - * @private - * @param {String} [pattern='/*.jst'] The file path pattern. - * @param {Object} options The options object. - * @returns {String} Returns the compiled source. - */ - function buildTemplate(pattern, options) { - pattern || (pattern = path.join(cwd, '*.jst')); - - var directory = path.dirname(pattern); - - var source = [ - ';(function(window) {', - " var freeExports = typeof exports == 'object' && exports &&", - " (typeof global == 'object' && global && global == global.global && (window = global), exports);", - '', - ' var templates = {},', - ' _ = window._;', - '' - ]; - - // convert to a regexp - pattern = RegExp( - path.basename(pattern) - .replace(/[.+?^=!:${}()|[\]\/\\]/g, '\\$&') - .replace(/\*/g, '.*?') + '$' - ); - - fs.readdirSync(directory).forEach(function(filename) { - var filePath = path.join(directory, filename); - if (pattern.test(filename)) { - var text = fs.readFileSync(filePath, 'utf8'), - precompiled = getFunctionSource(_.template(text, null, options)), - prop = filename.replace(/\..*$/, ''); - - source.push(" templates['" + prop.replace(/'/g, "\\'") + "'] = " + precompiled + ';', ''); - } - }); - - source.push( - " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {", - " define(['" + options.moduleId + "'], function(lodash) {", - ' lodash.templates = lodash.extend(lodash.templates || {}, templates);', - ' });', - " } else if (freeExports) {", - " if (typeof module == 'object' && module && module.exports == freeExports) {", - ' (module.exports = templates).templates = templates;', - ' } else {', - ' freeExports.templates = templates;', - ' }', - ' } else if (_) {', - ' _.templates = _.extend(_.templates || {}, templates);', - ' }', - '}(this));' - ); - - return source.join('\n'); - } - - /** - * Removes unnecessary comments, whitespace, and pseudo private properties. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the modified source. - */ - function cleanupSource(source) { - return source - // remove pseudo private properties - .replace(/(?:(?:\s*\/\/.*)*\s*lodash\._[^=]+=.+\n)+/g, '\n') - // remove lines with just whitespace and semicolons - .replace(/^ *;\n/gm, '') - // consolidate consecutive horizontal rule comment separators - .replace(/(?:\s*\/\*-+\*\/\s*){2,}/g, function(separators) { - return separators.match(/^\s*/)[0] + separators.slice(separators.lastIndexOf('/*')); - }); - } - - /** - * Writes the help message to standard output. - * - * @private - */ - function displayHelp() { - console.log([ - '', - ' Commands:', - '', - ' lodash backbone Build with only methods required by Backbone', - ' lodash csp Build supporting default Content Security Policy restrictions', - ' lodash legacy Build tailored for older browsers without ES5 support', - ' lodash mobile Build with IE < 9 bug fixes & method compilation removed', - ' lodash strict Build with `_.assign`, `_.bindAll`, & `_.defaults` in strict mode', - ' lodash underscore Build tailored for projects already using Underscore', - ' lodash include=... Comma separated method/category names to include in the build', - ' lodash minus=... Comma separated method/category names to remove from those included in the build', - ' lodash plus=... Comma separated method/category names to add to those included in the build', - ' lodash category=... Comma separated categories of methods to include in the build (case-insensitive)', - ' (i.e. “arrays”, “chaining”, “collections”, “functions”, “objects”, and “utilities”)', - ' lodash exports=... Comma separated names of ways to export the `lodash` function', - ' (i.e. “amd”, “commonjs”, “global”, “node”, and “none”)', - ' lodash iife=... Code to replace the immediately-invoked function expression that wraps Lo-Dash', - ' (e.g. `lodash iife="!function(window,undefined){%output%}(this)"`)', - '', - ' lodash template=... File path pattern used to match template files to precompile', - ' (e.g. `lodash template=./*.jst`)', - ' lodash settings=... Template settings used when precompiling templates', - ' (e.g. `lodash settings="{interpolate:/\\\\{\\\\{([\\\\s\\\\S]+?)\\\\}\\\\}/g}"`)', - ' lodash moduleId=... The AMD module ID of Lo-Dash, which defaults to “lodash”, used by precompiled templates', - '', - ' All arguments, except `legacy` with `csp` or `mobile`, may be combined.', - ' Unless specified by `-o` or `--output`, all files created are saved to the current working directory.', - '', - ' Options:', - '', - ' -c, --stdout Write output to standard output', - ' -d, --debug Write only the debug output', - ' -h, --help Display help information', - ' -m, --minify Write only the minified output', - ' -o, --output Write output to a given path/filename', - ' -s, --silent Skip status updates normally logged to the console', - ' -V, --version Output current version of Lo-Dash', - '' - ].join('\n')); - } - - /** - * Gets the aliases associated with a given function name. - * - * @private - * @param {String} methodName The name of the method to get aliases for. - * @returns {Array} Returns an array of aliases. - */ - function getAliases(methodName) { - return realToAliasMap[methodName] || []; - } - - /** - * Gets the Lo-Dash method assignments snippet from `source`. - * - * @private - * @param {String} source The source to inspect. - * @returns {String} Returns the method assignments snippet. - */ - function getMethodAssignments(source) { - return (source.match(/lodash\.VERSION *= *[\s\S]+?\/\*-+\*\/\n/) || [''])[0]; - } - - /** - * Gets an array of depenants for a method by a given name. - * - * @private - * @param {String} methodName The name of the method to query. - * @returns {Array} Returns an array of method dependants. - */ - function getDependants(methodName) { - // iterate over the `dependencyMap`, adding the names of methods that - // have `methodName` as a dependency - return _.reduce(dependencyMap, function(result, dependencies, otherName) { - if (_.contains(dependencies, methodName)) { - result.push(otherName); - } - return result; - }, []); - } - - /** - * Gets an array of dependencies for a given method name. If passed an array - * of dependencies it will return an array containing the given dependencies - * plus any additional detected sub-dependencies. - * - * @private - * @param {Array|String} methodName A single method name or array of - * dependencies to query. - * @returns {Array} Returns an array of method dependencies. - */ - function getDependencies(methodName) { - var dependencies = Array.isArray(methodName) ? methodName : dependencyMap[methodName]; - if (!dependencies) { - return []; - } - // recursively accumulate the dependencies of the `methodName` function, and - // the dependencies of its dependencies, and so on. - return _.uniq(dependencies.reduce(function(result, otherName) { - result.push.apply(result, getDependencies(otherName).concat(otherName)); - return result; - }, [])); - } - - /** - * Gets the formatted source of the given function. - * - * @private - * @param {Function} func The function to process. - * @returns {String} Returns the formatted source. - */ - function getFunctionSource(func) { - var source = func.source || (func + ''); - - // format leading whitespace - return source.replace(/\n(?:.*)/g, function(match, index) { - match = match.slice(1); - return ( - match == '}' && source.indexOf('}', index + 2) == -1 ? '\n ' : '\n ' - ) + match; - }); - } - - /** - * Gets the `_.isArguments` fallback from `source`. - * - * @private - * @param {String} source The source to inspect. - * @returns {String} Returns the `isArguments` fallback. - */ - function getIsArgumentsFallback(source) { - return (source.match(/(?:\s*\/\/.*)*\n( *)if *\(noArgsClass\)[\s\S]+?};\n\1}/) || [''])[0]; - } - - /** - * Gets the `_.isFunction` fallback from `source`. - * - * @private - * @param {String} source The source to inspect. - * @returns {String} Returns the `isFunction` fallback. - */ - function getIsFunctionFallback(source) { - return (source.match(/(?:\s*\/\/.*)*\n( *)if *\(isFunction\(\/x\/[\s\S]+?};\n\1}/) || [''])[0]; - } - - /** - * Gets the names of methods in `source` belonging to the given `category`. - * - * @private - * @param {String} source The source to inspect. - * @param {String} category The category to filter by. - * @returns {Array} Returns a new array of method names belonging to the given category. - */ - function getMethodsByCategory(source, category) { - return allMethods.filter(function(methodName) { - return category && RegExp('@category ' + category + '\\b').test(matchFunction(source, methodName)); - }); - } - - /** - * Gets the real name, not alias, of a given method name. - * - * @private - * @param {String} methodName The name of the method to resolve. - * @returns {String} Returns the real method name. - */ - function getRealName(methodName) { - return aliasToRealMap[methodName] || methodName; - } - - /** - * Determines if all functions of the given names have been removed from `source`. - * - * @private - * @param {String} source The source to inspect. - * @param {String} [funcName1, funcName2, ...] The names of functions to check. - * @returns {Boolean} Returns `true` if all functions have been removed, else `false`. - */ - function isRemoved(source) { - return slice.call(arguments, 1).every(function(funcName) { - return !matchFunction(source, funcName); - }); - } - - /** - * Searches `source` for a `funcName` function declaration, expression, or - * assignment and returns the matched snippet. - * - * @private - * @param {String} source The source to inspect. - * @param {String} funcName The name of the function to match. - * @returns {String} Returns the matched function snippet. - */ - function matchFunction(source, funcName) { - var result = source.match(RegExp( - // match multi-line comment block (could be on a single line) - '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/\\n)?' + - // begin non-capturing group - '(?:' + - // match a function declaration - '( *)function ' + funcName + '\\b[\\s\\S]+?\\n\\1}|' + - // match a variable declaration with `createIterator` - ' +var ' + funcName + ' *=.*?createIterator\\((?:{|[a-zA-Z])[\\s\\S]+?\\);|' + - // match a variable declaration with function expression - '( *)var ' + funcName + ' *=.*?function[\\s\\S]+?\\n\\2};' + - // end non-capturing group - ')\\n' - )); - - return result ? result[0] : ''; - } - - /** - * Converts a comma separated options string into an array. - * - * @private - * @param {String} value The option to convert. - * @returns {Array} Returns the new converted array. - */ - function optionToArray(value) { - return value.match(/\w+=(.*)$/)[1].split(/, */); - } - - /** - * Converts a comma separated options string into an array containing - * only real method names. - * - * @private - * @param {String} source The source to inspect. - * @param {String} value The option to convert. - * @returns {Array} Returns the new converted array. - */ - function optionToMethodsArray(source, value) { - var methodNames = optionToArray(value); - - // convert categories to method names - methodNames.forEach(function(category) { - push.apply(methodNames, getMethodsByCategory(source, category)); - }); - - // convert aliases to real method names - methodNames = methodNames.map(getRealName); - - // remove nonexistent and duplicate method names - return _.uniq(_.intersection(allMethods, methodNames)); - } - - /** - * Removes the all references to `refName` from `createIterator` in `source`. - * - * @private - * @param {String} source The source to process. - * @param {String} refName The name of the reference to remove. - * @returns {String} Returns the modified source. - */ - function removeFromCreateIterator(source, refName) { - var snippet = matchFunction(source, 'createIterator'); - if (snippet) { - // clip the snippet at the `factory` assignment - snippet = snippet.match(/Function\([\s\S]+$/)[0]; - var modified = snippet.replace(RegExp('\\b' + refName + '\\b,? *', 'g'), ''); - source = source.replace(snippet, modified); - } - return source; - } - - /** - * Removes the `funcName` function declaration, expression, or assignment and - * associated code from `source`. - * - * @private - * @param {String} source The source to process. - * @param {String} funcName The name of the function to remove. - * @returns {String} Returns the source with the function removed. - */ - function removeFunction(source, funcName) { - var modified, - snippet = matchFunction(source, funcName); - - // remove function - if (snippet) { - source = source.replace(snippet, ''); - } - // grab the method assignments snippet - snippet = getMethodAssignments(source); - - // remove assignment and aliases - modified = getAliases(funcName).concat(funcName).reduce(function(result, otherName) { - return result.replace(RegExp('(?:\\n *//.*\\s*)* *lodash\\.' + otherName + ' *= *.+\\n'), ''); - }, snippet); - - // replace with the modified snippet - source = source.replace(snippet, modified); - - return removeFromCreateIterator(source, funcName); - } - - /** - * Removes the `_.isArguments` fallback from `source`. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the source with the `isArguments` fallback removed. - */ - function removeIsArgumentsFallback(source) { - return source.replace(getIsArgumentsFallback(source), ''); - } - - /** - * Removes the `_.isFunction` fallback from `source`. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the source with the `isFunction` fallback removed. - */ - function removeIsFunctionFallback(source) { - return source.replace(getIsFunctionFallback(source), ''); - } - - /** - * Removes the `Object.keys` object iteration optimization from `source`. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the modified source. - */ - function removeKeysOptimization(source) { - return removeVar(source, 'isKeysFast') - // remove optimized branch in `iteratorTemplate` - .replace(/(?: *\/\/.*\n)* *'( *)<% *if *\(isKeysFast[\s\S]+?'\1<% *} *else *\{ *%>.+\n([\s\S]+?) *'\1<% *} *%>.+/, "'\\n' +\n$2") - // remove data object property assignment in `createIterator` - .replace(/ *'isKeysFast':.+\n/, ''); - } - - /** - * Removes all `noArgsClass` references from `source`. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the modified source. - */ - function removeNoArgsClass(source) { - return removeVar(source, 'noArgsClass') - // remove `noArgsClass` from `_.clone` and `_.isEqual` - .replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, '') - // remove `noArgsClass` from `_.isEqual` - .replace(/if *\(noArgsClass[^}]+?}\n/, '\n'); - } - - /** - * Removes all `noNodeClass` references from `source`. - * - * @private - * @param {String} source The source to process. - * @returns {String} Returns the modified source. - */ - function removeNoNodeClass(source) { - return source - // remove `noNodeClass` assignment - .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var noNodeClass[\s\S]+?catch[^}]+}\n/, '') - // remove `noNodeClass` from `isPlainObject` - .replace(/\(!noNodeClass *\|\|[\s\S]+?\)\) *&&/, '') - // remove `noNodeClass` from `_.isEqual` - .replace(/ *\|\| *\(noNodeClass *&&[\s\S]+?\)\)\)/, ''); - } - - /** - * Removes a given variable from `source`. - * - * @private - * @param {String} source The source to process. - * @param {String} varName The name of the variable to remove. - * @returns {String} Returns the source with the variable removed. - */ - function removeVar(source, varName) { - // simplify `cloneableClasses` - if (varName == 'cloneableClasses') { - source = source.replace(/(var cloneableClasses *=)[\s\S]+?(true;\n)/, '$1$2'); - } - // simplify `hasObjectSpliceBug` - if (varName == 'hasObjectSpliceBug') { - source = source.replace(/(var hasObjectSpliceBug *=)[^;]+/, '$1false'); - } - source = source.replace(RegExp( - // match multi-line comment block - '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' + - // match a variable declaration that's not part of a declaration list - '( *)var ' + varName + ' *= *(?:.+?(?:;|&&\\n[^;]+;)|(?:\\w+\\(|{)[\\s\\S]+?\\n\\1.+?;)\\n|' + - // match a variable in a declaration list - '\\n +' + varName + ' *=.+?,' - ), ''); - - // remove a varaible at the start of a variable declaration list - source = source.replace(RegExp('(var +)' + varName + ' *=.+?,\\s+'), '$1'); - - // remove a variable at the end of a variable declaration list - source = source.replace(RegExp(',\\s*' + varName + ' *=.+?;'), ';'); - - // remove variable reference from `cloneableClasses` assignments - source = source.replace(RegExp('cloneableClasses\\[' + varName + '\\] *= *(?:false|true)?', 'g'), ''); - - return removeFromCreateIterator(source, varName); - } - - /** - * Searches `source` for a `varName` variable declaration and replaces its - * assigned value with `varValue`. - * - * @private - * @param {String} source The source to inspect. - * @param {String} varName The name of the variable to replace. - * @returns {String} Returns the source with the variable replaced. - */ - function replaceVar(source, varName, varValue) { - // replace a variable that's not part of a declaration list - var result = source.replace(RegExp( - '(( *)var ' + varName + ' *= *)' + - '(?:.+?;|(?:Function\\(.+?|.*?[^,])\\n[\\s\\S]+?\\n\\2.+?;)\\n' - ), '$1' + varValue + ';\n'); - - if (source == result) { - // replace a varaible at the start or middle of a declaration list - result = source.replace(RegExp('((?:var|\\n) +' + varName + ' *=).+?,'), '$1 ' + varValue + ','); - } - if (source == result) { - // replace a variable at the end of a variable declaration list - result = source.replace(RegExp('(,\\s*' + varName + ' *=).+?;'), '$1 ' + varValue + ';'); - } - return result; - } - - /** - * Hard-codes the `useStrict` template option value for `iteratorTemplate`. - * - * @private - * @param {String} source The source to process. - * @param {Boolean} value The value to set. - * @returns {String} Returns the modified source. - */ - function setUseStrictOption(source, value) { - // inject "use strict" - if (value) { - source = source.replace(/^[\s\S]*?function[^{]+{/, "$&\n 'use strict';"); - } - // replace `useStrict` branch in `value` with hard-coded option - return source.replace(/(?: *\/\/.*\n)*(\s*)' *<%.+?useStrict.+/, value ? "$1'\\'use strict\\';\\n' +" : ''); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a debug and/or minified build, executing the `callback` for each. - * The `callback` is invoked with two arguments; (filePath, outputSource). - * - * Note: For a list of commands see `displayHelp()` or run `lodash --help`. - * - * @param {Array} [options=[]] An array of commands. - * @param {Function} callback The function called per build. - */ - function build(options, callback) { - options || (options = []); - - // the debug version of `source` - var debugSource; - - // used to report invalid command-line arguments - var invalidArgs = _.reject(options.slice(options[0] == 'node' ? 2 : 0), function(value, index, options) { - if (/^(?:-o|--output)$/.test(options[index - 1]) || - /^(?:category|exclude|exports|iife|include|moduleId|minus|plus|settings|template)=.*$/i.test(value)) { - return true; - } - return [ - 'backbone', - 'csp', - 'legacy', - 'mobile', - 'strict', - 'underscore', - '-c', '--stdout', - '-d', '--debug', - '-h', '--help', - '-m', '--minify', - '-o', '--output', - '-s', '--silent', - '-V', '--version' - ].indexOf(value) > -1; - }); - - // report invalid arguments - if (invalidArgs.length) { - console.log( - '\n' + - 'Invalid argument' + (invalidArgs.length > 1 ? 's' : '') + - ' passed: ' + invalidArgs.join(', ') - ); - displayHelp(); - return; - } - - // display help message - if (_.find(options, function(arg) { - return /^(?:-h|--help)$/.test(arg); - })) { - displayHelp(); - return; - } - - // display `lodash.VERSION` - if (_.find(options, function(arg) { - return /^(?:-V|--version)$/.test(arg); - })) { - console.log(_.VERSION); - return; - } - - /*------------------------------------------------------------------------*/ - - // backup `dependencyMap` to restore later - var dependencyBackup = _.clone(dependencyMap, true); - - // used to specify a custom IIFE to wrap Lo-Dash - var iife = options.reduce(function(result, value) { - var match = value.match(/iife=(.*)/); - return match ? match[1] : result; - }, null); - - // flag used to specify a Backbone build - var isBackbone = options.indexOf('backbone') > -1; - - // flag used to specify a Content Security Policy build - var isCSP = options.indexOf('csp') > -1 || options.indexOf('CSP') > -1; - - // flag used to specify only creating the debug build - var isDebug = options.indexOf('-d') > -1 || options.indexOf('--debug') > -1; - - // flag used to specify a legacy build - var isLegacy = options.indexOf('legacy') > -1; - - // flag used to specify an Underscore build - var isUnderscore = options.indexOf('underscore') > -1; - - // flag used to specify only creating the minified build - var isMinify = !isDebug && options.indexOf('-m') > -1 || options.indexOf('--minify')> -1; - - // flag used to specify a mobile build - var isMobile = !isLegacy && (isCSP || isUnderscore || options.indexOf('mobile') > -1); - - // flag used to specify writing output to standard output - var isStdOut = options.indexOf('-c') > -1 || options.indexOf('--stdout') > -1; - - // flag used to specify skipping status updates normally logged to the console - var isSilent = isStdOut || options.indexOf('-s') > -1 || options.indexOf('--silent') > -1; - - // flag used to specify `_.assign`, `_.bindAll`, and `_.defaults` are - // constructed using the "use strict" directive - var isStrict = options.indexOf('strict') > -1; - - // used to specify the ways to export the `lodash` function - var exportsOptions = options.reduce(function(result, value) { - return /exports/.test(value) ? optionToArray(value).sort() : result; - }, isUnderscore - ? ['commonjs', 'global', 'node'] - : exportsAll.slice() - ); - - // used to specify the AMD module ID of Lo-Dash used by precompiled templates - var moduleId = options.reduce(function(result, value) { - var match = value.match(/moduleId=(.*)/); - return match ? match[1] : result; - }, 'lodash'); - - // used to specify the output path for builds - var outputPath = options.reduce(function(result, value, index) { - if (/-o|--output/.test(value)) { - result = options[index + 1]; - result = path.join(fs.realpathSync(path.dirname(result)), path.basename(result)); - } - return result; - }, ''); - - // used to match external template files to precompile - var templatePattern = options.reduce(function(result, value) { - var match = value.match(/template=(.+)$/); - return match - ? path.join(fs.realpathSync(path.dirname(match[1])), path.basename(match[1])) - : result; - }, ''); - - // used when precompiling template files - var templateSettings = options.reduce(function(result, value) { - var match = value.match(/settings=(.+)$/); - return match - ? Function('return {' + match[1].replace(/^{|}$/g, '') + '}')() - : result; - }, _.assign(_.clone(_.templateSettings), { - 'moduleId': moduleId - })); - - // flag used to specify a template build - var isTemplate = !!templatePattern; - - // the lodash.js source - var source = fs.readFileSync(path.join(__dirname, 'lodash.js'), 'utf8'); - - // flag used to specify replacing Lo-Dash's `_.clone` with Underscore's - var useUnderscoreClone = isUnderscore; - - // flags used to specify exposing Lo-Dash methods in an Underscore build - var exposeAssign = !isUnderscore, - exposeForIn = !isUnderscore, - exposeForOwn = !isUnderscore, - exposeIsPlainObject = !isUnderscore; - - /*------------------------------------------------------------------------*/ - - // names of methods to include in the build - var buildMethods = !isTemplate && (function() { - var result; - - var minusMethods = options.reduce(function(accumulator, value) { - return /exclude|minus/.test(value) - ? _.union(accumulator, optionToMethodsArray(source, value)) - : accumulator; - }, []); - - var plusMethods = options.reduce(function(accumulator, value) { - return /plus/.test(value) - ? _.union(accumulator, optionToMethodsArray(source, value)) - : accumulator; - }, []); - - // add method names explicitly - options.some(function(value) { - return /include/.test(value) && - (result = getDependencies(optionToMethodsArray(source, value))); - }); - - // include Lo-Dash's methods if explicitly requested - if (isUnderscore && result) { - exposeAssign = result.indexOf('assign') > -1; - exposeForIn = result.indexOf('forIn') > -1; - exposeForOwn = result.indexOf('forOwn') > -1; - exposeIsPlainObject = result.indexOf('isPlainObject') > -1; - useUnderscoreClone = result.indexOf('clone') < 0; - } - // update dependencies - if (isMobile) { - dependencyMap.reduceRight = ['forEach', 'keys']; - } - if (isUnderscore) { - dependencyMap.contains = ['forEach', 'indexOf']; - dependencyMap.isEqual = ['isArray', 'isFunction']; - dependencyMap.isEmpty = ['isArray', 'isString']; - dependencyMap.max = ['forEach', 'isArray']; - dependencyMap.min = ['forEach', 'isArray']; - dependencyMap.pick = []; - dependencyMap.template = ['defaults', 'escape']; - - if (useUnderscoreClone) { - dependencyMap.clone = ['assign', 'isArray']; - } - } - // add method names required by Backbone and Underscore builds - if (isBackbone && !result) { - result = getDependencies(backboneDependencies); - } - if (isUnderscore && !result) { - result = getDependencies(underscoreMethods); - } - - // add method names by category - options.some(function(value) { - if (!/category/.test(value)) { - return false; - } - // resolve method names belonging to each category (case-insensitive) - var methodNames = optionToArray(value).reduce(function(accumulator, category) { - var capitalized = category[0].toUpperCase() + category.toLowerCase().slice(1); - return accumulator.concat(getMethodsByCategory(source, capitalized)); - }, []); - - return (result = _.union(result || [], getDependencies(methodNames))); - }); - - if (!result) { - result = allMethods.slice(); - } - if (plusMethods.length) { - result = _.union(result, getDependencies(plusMethods)); - } - if (minusMethods.length) { - result = _.without.apply(_, [result].concat(minusMethods, getDependants(result))); - } - return result; - }()); - - /*------------------------------------------------------------------------*/ - - // load customized Lo-Dash module - var lodash = !isTemplate && (function() { - var context = vm.createContext({ - 'clearTimeout': clearTimeout, - 'console': console, - 'setTimeout': setTimeout - }); - - source = setUseStrictOption(source, isStrict); - - if (isLegacy) { - _.each(['getPrototypeOf', 'isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { - source = replaceVar(source, varName, 'false'); - }); - - source = replaceVar(source, 'noArgsClass', 'true'); - source = removeKeysOptimization(source); - } - else if (isUnderscore) { - // remove unneeded variables - source = removeVar(source, 'cloneableClasses'); - - // remove large array optimizations - source = removeFunction(source, 'cachedContains'); - source = removeVar(source, 'largeArraySize'); - - // replace `_.clone` - if (useUnderscoreClone) { - source = source.replace(/^( *)function clone[\s\S]+?\n\1}/m, [ - ' function clone(value) {', - ' return value && objectTypes[typeof value]', - ' ? (isArray(value) ? slice.call(value) : assign({}, value))', - ' : value', - ' }' - ].join('\n')); - } - - // replace `_.contains` - source = source.replace(/^( *)function contains[\s\S]+?\n\1}/m, [ - ' function contains(collection, target) {', - ' var length = collection ? collection.length : 0,', - ' result = false;', - " if (typeof length == 'number') {", - ' result = indexOf(collection, target) > -1;', - ' } else {', - ' forEach(collection, function(value) {', - ' return (result = value === target) && indicatorObject;', - ' });', - ' }', - ' return result;', - ' }' - ].join('\n')); - - // replace `_.difference` - source = source.replace(/^( *)function difference[\s\S]+?\n\1}/m, [ - ' function difference(array) {', - ' var index = -1,', - ' length = array.length,', - ' flattened = concat.apply(arrayRef, arguments),', - ' result = [];', - '', - ' while (++index < length) {', - ' var value = array[index]', - ' if (indexOf(flattened, value, length) < 0) {', - ' result.push(value);', - ' }', - ' }', - ' return result', - ' }' - ].join('\n')); - - // replace `_.assign` - source = source.replace(/^( *)var assign *= *createIterator[\s\S]+?\);/m, [ - ' function assign(object) {', - ' if (!object) {', - ' return object;', - ' }', - ' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {', - ' var iteratee = arguments[argsIndex];', - ' if (iteratee) {', - ' for (var key in iteratee) {', - ' object[key] = iteratee[key];', - ' }', - ' }', - ' }', - ' return object;', - ' }' - ].join('\n')); - - // replace `_.defaults` - source = source.replace(/^( *)var defaults *= *createIterator[\s\S]+?\);/m, [ - ' function defaults(object) {', - ' if (!object) {', - ' return object;', - ' }', - ' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {', - ' var iteratee = arguments[argsIndex];', - ' if (iteratee) {', - ' for (var key in iteratee) {', - ' if (object[key] == null) {', - ' object[key] = iteratee[key];', - ' }', - ' }', - ' }', - ' }', - ' return object;', - ' }' - ].join('\n')); - - // replace `_.intersection` - source = source.replace(/^( *)function intersection[\s\S]+?\n\1}/m, [ - ' function intersection(array) {', - ' var args = arguments,', - ' argsLength = args.length,', - ' result = [];', - '', - ' forEach(array, function(value) {', - ' if (indexOf(result, value) < 0) {', - ' var length = argsLength;', - ' while (--length) {', - ' if (indexOf(args[length], value) < 0) {', - ' return;', - ' }', - ' }', - ' result.push(value);', - ' }', - ' });', - ' return result;', - ' }' - ].join('\n')); - - // replace `_.isEmpty` - source = source.replace(/^( *)function isEmpty[\s\S]+?\n\1}/m, [ - ' function isEmpty(value) {', - ' if (!value) {', - ' return true;', - ' }', - ' if (isArray(value) || isString(value)) {', - ' return !value.length;', - ' }', - ' for (var key in value) {', - ' if (hasOwnProperty.call(value, key)) {', - ' return false;', - ' }', - ' }', - ' return true;', - ' }' - ].join('\n')); - - // replace `_.isFinite` - source = source.replace(/^( *)function isFinite[\s\S]+?\n\1}/m, [ - ' function isFinite(value) {', - ' return nativeIsFinite(value) && toString.call(value) == numberClass;', - ' }' - ].join('\n')); - - // replace `_.omit` - source = source.replace(/^( *)function omit[\s\S]+?\n\1}/m, [ - ' function omit(object) {', - ' var props = concat.apply(arrayRef, arguments),', - ' result = {};', - '', - ' forIn(object, function(value, key) {', - ' if (indexOf(props, key, 1) < 0) {', - ' result[key] = value;', - ' }', - ' });', - ' return result;', - ' }' - ].join('\n')); - - // replace `_.pick` - source = source.replace(/^( *)function pick[\s\S]+?\n\1}/m, [ - ' function pick(object) {', - ' var index = 0,', - ' props = concat.apply(arrayRef, arguments),', - ' length = props.length,', - ' result = {};', - '', - ' while (++index < length) {', - ' var prop = props[index];', - ' if (prop in object) {', - ' result[prop] = object[prop];', - ' }', - ' }', - ' return result;', - ' }' - ].join('\n')); - - // replace `_.template` - source = source.replace(/^( *)function template[\s\S]+?\n\1}/m, function() { - return [ - ' function template(text, data, options) {', - " text || (text = '');", - ' options = defaults({}, options, lodash.templateSettings);', - '', - ' var index = 0,', - ' source = "__p += \'",', - ' variable = options.variable;', - '', - ' var reDelimiters = RegExp(', - " (options.escape || reNoMatch).source + '|' +", - " (options.interpolate || reNoMatch).source + '|' +", - " (options.evaluate || reNoMatch).source + '|$'", - " , 'g');", - '', - ' text.replace(reDelimiters, function(match, escapeValue, interpolateValue, evaluateValue, offset) {', - ' source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar);', - ' source +=', - ' escapeValue ? "\' +\\n_.escape(" + escapeValue + ") +\\n\'" :', - ' evaluateValue ? "\';\\n" + evaluateValue + ";\\n__p += \'" :', - ' interpolateValue ? "\' +\\n((__t = (" + interpolateValue + ")) == null ? \'\' : __t) +\\n\'" : \'\';', - '', - ' index = offset + match.length;', - ' });', - '', - ' source += "\';\\n";', - ' if (!variable) {', - " variable = 'obj';", - " source = 'with (' + variable + ' || {}) {\\n' + source + '\\n}\\n';", - ' }', - " source = 'function(' + variable + ') {\\n' +", - " 'var __t, __p = \\'\\', __j = Array.prototype.join;\\n' +", - " 'function print() { __p += __j.call(arguments, \\'\\') }\\n' +", - ' source +', - " 'return __p\\n}';", - '', - ' try {', - " var result = Function('_', 'return ' + source)(lodash);", - ' } catch(e) {', - ' e.source = source;', - ' throw e;', - ' }', - ' if (data) {', - ' return result(data);', - ' }', - ' result.source = source;', - ' return result;', - ' }' - ].join('\n'); - }); - - // replace `_.uniq` - source = source.replace(/^( *)function uniq[\s\S]+?\n\1}/m, [ - ' function uniq(array, isSorted, callback, thisArg) {', - ' var index = -1,', - ' length = array ? array.length : 0,', - ' result = [],', - ' seen = result;', - '', - ' if (callback) {', - ' seen = [];', - ' callback = createCallback(callback, thisArg);', - ' }', - ' while (++index < length) {', - ' var value = array[index],', - ' computed = callback ? callback(value, index, array) : value;', - '', - ' if (isSorted', - ' ? !index || seen[seen.length - 1] !== computed', - ' : indexOf(seen, computed) < 0', - ' ) {', - ' if (callback) {', - ' seen.push(computed);', - ' }', - ' result.push(value);', - ' }', - ' }', - ' return result;', - ' }' - ].join('\n')); - - // replace `_.without` - source = source.replace(/^( *)function without[\s\S]+?\n\1}/m, [ - ' function without(array) {', - ' var index = -1,', - ' length = array.length,', - ' result = [];', - '', - ' while (++index < length) {', - ' var value = array[index]', - ' if (indexOf(arguments, value, 1) < 0) {', - ' result.push(value);', - ' }', - ' }', - ' return result', - ' }' - ].join('\n')); - - // remove unneeded template related variables - source = removeVar(source, 'reComplexDelimiter'); - source = removeVar(source, 'reEmptyStringLeading'); - source = removeVar(source, 'reEmptyStringMiddle'); - source = removeVar(source, 'reEmptyStringTrailing'); - source = removeVar(source, 'reInsertVariable'); - - // remove `arguments` object check from `_.isEqual` - source = source.replace(/ *\|\| *className *== *argsClass/, ''); - - // simplify DOM node check from `_.isEqual` - source = source.replace(/(if *\(className *!= *objectClass).+?noNodeClass[\s\S]+?{/, '$1) {'); - - // remove conditional `charCodeCallback` use from `_.max` and `_.min` - source = source.replace(/!callback *&& *isString\(collection\)[\s\S]+?: */g, ''); - - // remove unused features from `createBound` - if (buildMethods.indexOf('partial') == -1) { - source = source.replace(matchFunction(source, 'createBound'), function(match) { - return match - .replace(/(function createBound\([^{]+{)[\s\S]+?(\n *function bound)/, '$1$2') - .replace(/thisBinding *=[^}]+}/, 'thisBinding = thisArg;\n'); - }); - } - } - if (isMobile) { - source = replaceVar(source, 'isKeysFast', 'false'); - source = removeKeysOptimization(source); - - // remove `prototype` [[Enumerable]] fix from `_.keys` - source = source.replace(/(?:\s*\/\/.*)*(\s*return *).+?propertyIsEnumerable[\s\S]+?: */, '$1'); - - // remove `prototype` [[Enumerable]] fix from `iteratorTemplate` - source = source - .replace(/(?: *\/\/.*\n)* *' *(?:<% *)?if *\(!hasDontEnumBug *(?:&&|\))[\s\S]+?<% *} *(?:%>|').+/g, '') - .replace(/!hasDontEnumBug *\|\|/g, ''); - } - vm.runInContext(source, context); - return context._; - }()); - - /*------------------------------------------------------------------------*/ - - if (isTemplate) { - source = buildTemplate(templatePattern, templateSettings); - } - else { - // simplify template snippets by removing unnecessary brackets - source = source.replace( - RegExp("{(\\\\n' *\\+\\s*.*?\\+\\n\\s*' *)}(?:\\\\n)?' *([,\\n])", 'g'), "$1'$2" - ); - - source = source.replace( - RegExp("{(\\\\n' *\\+\\s*.*?\\+\\n\\s*' *)}(?:\\\\n)?' *\\+", 'g'), "$1;\\n'+" - ); - - // remove methods from the build - allMethods.forEach(function(otherName) { - if (!_.contains(buildMethods, otherName)) { - source = removeFunction(source, otherName); - } - }); - - // remove `isArguments` fallback before `isArguments` is transformed by - // other parts of the build process - if (isRemoved(source, 'isArguments')) { - source = removeIsArgumentsFallback(source); - } - - /*----------------------------------------------------------------------*/ - - if (isLegacy) { - _.each(['isBindFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { - source = removeVar(source, varName); - }); - - _.each(['bind', 'isArray'], function(methodName) { - var snippet = matchFunction(source, methodName), - modified = snippet; - - // remove native `Function#bind` branch in `_.bind` - if (methodName == 'bind') { - modified = modified.replace(/(?:\s*\/\/.*)*\s*return isBindFast[^:]+:\s*/, 'return '); - } - // remove native `Array.isArray` branch in `_.isArray` - else { - modified = modified.replace(/nativeIsArray * \|\|/, ''); - } - source = source.replace(snippet, modified); - }); - - // replace `_.keys` with `shimKeys` - if (!isRemoved(source, 'keys')) { - source = source.replace( - matchFunction(source, 'keys').replace(/[\s\S]+?var keys *= */, ''), - matchFunction(source, 'shimKeys').replace(/[\s\S]+?function shimKeys/, 'function').replace(/}\n$/, '};\n') - ); - - source = removeFunction(source, 'shimKeys'); - } - // replace `_.isArguments` with fallback - if (!isRemoved(source, 'isArguments')) { - source = source.replace( - matchFunction(source, 'isArguments').replace(/[\s\S]+?function isArguments/, ''), - getIsArgumentsFallback(source).match(/isArguments *= *function([\s\S]+?) *};/)[1] + ' }\n' - ); - - source = removeIsArgumentsFallback(source); - } - - source = removeVar(source, 'reNative'); - source = removeFromCreateIterator(source, 'nativeKeys'); - } - - /*----------------------------------------------------------------------*/ - - if (isMobile) { - // inline all functions defined with `createIterator` - _.functions(lodash).forEach(function(methodName) { - var reFunc = RegExp('(\\bvar ' + methodName + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'); - - // skip if not defined with `createIterator` - if (!reFunc.test(source)) { - return; - } - // extract, format, and inject the compiled function's source code - source = source.replace(reFunc, '$1' + getFunctionSource(lodash[methodName]) + ';\n'); - }); - - if (isUnderscore) { - // remove `_.assign`, `_.forIn`, `_.forOwn`, and `_.isPlainObject` assignments - (function() { - var snippet = getMethodAssignments(source), - modified = snippet; - - if (!exposeAssign) { - modified = modified.replace(/(?:\n *\/\/.*\s*)* *lodash\.assign *= *.+\n/, ''); - } - if (!exposeForIn) { - modified = modified.replace(/(?:\n *\/\/.*\s*)* *lodash\.forIn *= *.+\n/, ''); - } - if (!exposeForOwn) { - modified = modified.replace(/(?:\n *\/\/.*\s*)* *lodash\.forOwn *= *.+\n/, ''); - } - if (!exposeIsPlainObject) { - modified = modified.replace(/(?:\n *\/\/.*\s*)* *lodash\.isPlainObject *= *.+\n/, ''); - } - source = source.replace(snippet, modified); - }()); - - // replace `isArguments` and its fallback - (function() { - var snippet = matchFunction(source, 'isArguments') - .replace(/function isArguments/, 'lodash.isArguments = function'); - - source = removeFunction(source, 'isArguments'); - - source = source.replace(getIsArgumentsFallback(source), function(match) { - return snippet + '\n' + match - .replace(/\bisArguments\b/g, 'lodash.$&') - .replace(/\bnoArgsClass\b/g, '!lodash.isArguments(arguments)'); - }); - }()); - - // remove chainability from `_.forEach` - source = source.replace(matchFunction(source, 'forEach'), function(match) { - return match.replace(/return result([};\s]+)$/, '$1'); - }); - - // unexpose "exit early" feature from `_.forEach`, `_.forIn`, and `_.forOwn` - _.each(['forEach', 'forIn', 'forOwn'], function(methodName) { - source = source.replace(matchFunction(source, methodName), function(match) { - return match.replace(/=== *false\)/g, '=== indicatorObject)'); - }); - }); - - // modify `_.every`, `_.find`, and `_.some` to use the private `indicatorObject` - source = source.replace(matchFunction(source, 'every'), function(match) { - return match.replace(/\(result *= *(.+?)\);/, '!(result = $1) && indicatorObject;'); - }); - - source = source.replace(matchFunction(source, 'find'), function(match) { - return match.replace(/return false/, 'return indicatorObject'); - }); - - source = source.replace(matchFunction(source, 'some'), function(match) { - return match.replace(/!\(result *= *(.+?)\);/, '(result = $1) && indicatorObject;'); - }); - } - else { - source = removeIsArgumentsFallback(source); - source = removeVar(source, 'hasObjectSpliceBug'); - - // remove `hasObjectSpliceBug` fix from the mutator Array functions mixin - source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?\n\1}/, ''); - } - - // remove `thisArg` from unexposed `forIn` and `forOwn` - _.each([ - { 'methodName': 'forIn', 'flag': exposeForIn }, - { 'methodName': 'forOwn', 'flag': exposeForOwn } - ], function(data) { - if (!data.flag) { - source = source.replace(matchFunction(source, data.methodName), function(match) { - return match.replace(/(callback), *thisArg/g, '$1'); - }); - } - }); - - // remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` declarations and assignments - source = source - .replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, '') - .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum).+\n/g, ''); - - // remove `iteratesOwnLast` from `isPlainObject` - source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(iteratesOwnLast[\s\S]+?\n\1}/, ''); - - // remove JScript [[DontEnum]] fix from `_.isEqual` - source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasDontEnumBug[\s\S]+?\n\1}/, ''); - - // remove `noArraySliceOnStrings` from `_.toArray` - source = source.replace(/noArraySliceOnStrings *\?[^:]+: *([^)]+)/g, '$1'); - - // remove `noCharByIndex` from `_.reduceRight` - source = source.replace(/}\s*else if *\(noCharByIndex[^}]+/, ''); - - source = removeVar(source, 'extendIteratorOptions'); - source = removeVar(source, 'iteratorTemplate'); - source = removeVar(source, 'noArraySliceOnStrings'); - source = removeVar(source, 'noCharByIndex'); - source = removeNoArgsClass(source); - source = removeNoNodeClass(source); - } - else { - // inline `iteratorTemplate` template - source = source.replace(/(( *)var iteratorTemplate *= *)[\s\S]+?\n\2.+?;\n/, (function() { - var snippet = getFunctionSource(lodash._iteratorTemplate); - - // prepend data object references to property names to avoid having to - // use a with-statement - iteratorOptions.forEach(function(property) { - snippet = snippet.replace(RegExp('([^\\w.])\\b' + property + '\\b', 'g'), '$1obj.' + property); - }); - - // remove unnecessary code - snippet = snippet - .replace(/var __t.+/, "var __p = '';") - .replace(/function print[^}]+}/, '') - .replace(/'(?:\\n|\s)+'/g, "''") - .replace(/__p *\+= *' *';/g, '') - .replace(/(__p *\+= *)' *' *\+/g, '$1') - .replace(/(\{) *;|; *(\})/g, '$1$2') - .replace(/\(\(__t *= *\( *([^)]+) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)'); - - // remove the with-statement - snippet = snippet.replace(/ *with *\(.+?\) *{/, '\n').replace(/}([^}]*}[^}]*$)/, '$1'); - - // minor cleanup - snippet = snippet - .replace(/obj *\|\| *\(obj *= *\{}\);/, '') - .replace(/var __p = '';\s*__p \+=/, 'var __p ='); - - // remove comments, including sourceURLs - snippet = snippet.replace(/\s*\/\/.*(?:\n|$)/g, ''); - - return '$1' + snippet + ';\n'; - }())); - } - } - - /*------------------------------------------------------------------------*/ - - // customize Lo-Dash's IIFE - (function() { - if (typeof iife == 'string') { - var token = '%output%', - index = iife.indexOf(token); - - source = source.match(/\/\*![\s\S]+?\*\/\n/) + - iife.slice(0, index) + - source.replace(/^[\s\S]+?\(function[^{]+?{|}\(this\)\)[;\s]*$/g, '') + - iife.slice(index + token.length); - } - }()); - - /*------------------------------------------------------------------------*/ - - // customize Lo-Dash's export bootstrap - (function() { - var isAMD = exportsOptions.indexOf('amd') > -1, - isCommonJS = exportsOptions.indexOf('commonjs') > -1, - isGlobal = exportsOptions.indexOf('global') > -1, - isNode = exportsOptions.indexOf('node') > -1; - - if (!isAMD) { - source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +define[\s\S]+?else /, '$1'); - } - if (!isNode) { - source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +module[\s\S]+?else *{([\s\S]+?\n)\1}\n/, '$1$2'); - } - if (!isCommonJS) { - source = source.replace(/(?: *\/\/.*\n)*(?:( *)else *{)?\s*freeExports\.\w+ *=[\s\S]+?(?:\n\1})?\n/, ''); - } - if (!isGlobal) { - source = source.replace(/(?:( *)(})? *else(?: *if *\(_\))? *{)?(?:\s*\/\/.*)*\s*(?:window\._|_\.templates) *=[\s\S]+?(?:\n\1})?\n/g, '$1$2\n'); - } - // remove `if (freeExports) {...}` if it's empty - if (isAMD && isGlobal) { - source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}\n/, ''); - } else { - source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}(?:\s*else *{([\s\S]+?) *})?\n/, '$1\n'); - } - - if ((source.match(/\bfreeExports\b/g) || []).length < 2) { - source = removeVar(source, 'freeExports'); - } - }()); - - /*------------------------------------------------------------------------*/ - - if (isTemplate) { - debugSource = source; - } - else { - // modify/remove references to removed methods/variables - if (isRemoved(source, 'invert')) { - source = replaceVar(source, 'htmlUnescapes', "{'&':'&','<':'<','>':'>','"':'\"',''':\"'\"}"); - } - if (isRemoved(source, 'isArguments')) { - source = replaceVar(source, 'noArgsClass', 'false'); - } - if (isRemoved(source, 'isFunction')) { - source = removeIsFunctionFallback(source); - } - if (isRemoved(source, 'mixin')) { - // remove `lodash.prototype` additions - source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\)[\s\S]+?\/\*-+\*\//, ''); - source = removeVar(source, 'hasObjectSpliceBug'); - } - - // remove pseudo private properties - source = source.replace(/(?:(?:\s*\/\/.*)*\s*lodash\._[^=]+=.+\n)+/g, '\n'); - - // assign debug source before further modifications that rely on the minifier - // to remove unused variables and other dead code - debugSource = source; - - // remove associated functions, variables, and code snippets that the minifier may miss - if (isRemoved(source, 'clone')) { - source = removeVar(source, 'cloneableClasses'); - } - if (isRemoved(source, 'isArray')) { - source = removeVar(source, 'nativeIsArray'); - } - if (isRemoved(source, 'isPlainObject')) { - source = removeVar(source, 'getPrototypeOf'); - } - if (isRemoved(source, 'keys')) { - source = removeFunction(source, 'shimKeys'); - } - if (isRemoved(source, 'template')) { - // remove `templateSettings` assignment - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, ''); - } - if (isRemoved(source, 'toArray')) { - source = removeVar(source, 'noArraySliceOnStrings'); - } - if (isRemoved(source, 'clone', 'isArguments', 'isEmpty', 'isEqual')) { - source = removeNoArgsClass(source); - } - if (isRemoved(source, 'isEqual', 'isPlainObject')) { - source = removeNoNodeClass(source); - } - if ((source.match(/\bcreateIterator\b/g) || []).length < 2) { - source = removeFunction(source, 'createIterator'); - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var noArgsEnum;|.+?noArgsEnum *=.+/g, ''); - } - if (isRemoved(source, 'createIterator', 'bind')) { - source = removeVar(source, 'isBindFast'); - source = removeVar(source, 'nativeBind'); - } - if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'isPlainObject', 'keys')) { - source = removeVar(source, 'reNative'); - } - if (isRemoved(source, 'createIterator', 'isEqual')) { - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, ''); - } - if (isRemoved(source, 'createIterator', 'isPlainObject')) { - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, ''); - } - if (isRemoved(source, 'createIterator', 'keys')) { - source = removeVar(source, 'nativeKeys'); - source = removeKeysOptimization(source); - } - if (!source.match(/var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum)\b/g)) { - // remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` assignments - source = source.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, ''); - } - } - - /*------------------------------------------------------------------------*/ - - // used to specify creating a custom build - var isCustom = isBackbone || isLegacy || isMobile || isStrict || isUnderscore || - /(?:category|exclude|exports|iife|include|minus|plus)=/.test(options) || - !_.isEqual(exportsOptions, exportsAll); - - // used as the basename of the output path - var basename = outputPath - ? path.basename(outputPath, '.js') - : 'lodash' + (isTemplate ? '.template' : isCustom ? '.custom' : ''); - - // restore `dependencyMap` - dependencyMap = dependencyBackup; - - // output debug build - if (!isMinify && (isCustom || isDebug || isTemplate)) { - if (isCustom) { - debugSource = addCommandsToHeader(debugSource, options); - } - if (isDebug && isStdOut) { - stdout.write(debugSource); - callback(debugSource); - } else if (!isStdOut) { - callback(debugSource, (isDebug && outputPath) || path.join(cwd, basename + '.js')); - } - } - // begin the minification process - if (!isDebug) { - outputPath || (outputPath = path.join(cwd, basename + '.min.js')); - - minify(source, { - 'isSilent': isSilent, - 'isTemplate': isTemplate, - 'outputPath': outputPath, - 'onComplete': function(source) { - // inject "use strict" directive - if (isStrict) { - source = source.replace(/^([\s\S]*?function[^{]+{)([^'"])/, '$1"use strict";$2'); - } - if (isCustom) { - source = addCommandsToHeader(source, options); - } - if (isStdOut) { - stdout.write(source); - callback(source); - } else { - callback(source, outputPath); - } - } - }); - } - } - - /*--------------------------------------------------------------------------*/ - - // expose `build` - if (module != require.main) { - module.exports = build; - } - else { - // or invoked directly - build(process.argv, function(source, filePath) { - filePath && fs.writeFileSync(filePath, source, 'utf8'); - }); - } -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/minify.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/minify.js deleted file mode 100755 index 8bc9f7a..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/minify.js +++ /dev/null @@ -1,438 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** The Node filesystem, path, `zlib`, and child process modules */ - var fs = require('fs'), - gzip = require('zlib').gzip, - path = require('path'), - spawn = require('child_process').spawn; - - /** The path of the directory that is the base of the repository */ - var basePath = fs.realpathSync(path.join(__dirname, '..')); - - /** The path of the directory where the Closure Compiler is located */ - var closurePath = path.join(basePath, 'vendor', 'closure-compiler', 'compiler.jar'); - - /** Load other modules */ - var preprocess = require('./pre-compile.js'), - postprocess = require('./post-compile.js'), - uglifyJS = require('../vendor/uglifyjs/uglify-js.js'); - - /** The Closure Compiler command-line options */ - var closureOptions = ['--warning_level=QUIET']; - - /** The Closure Compiler optimization modes */ - var optimizationModes = { - 'simple': 'SIMPLE_OPTIMIZATIONS', - 'advanced': 'ADVANCED_OPTIMIZATIONS' - }; - - /** Reassign `existsSync` for older versions of Node */ - fs.existsSync || (fs.existsSync = path.existsSync); - - /*--------------------------------------------------------------------------*/ - - /** - * Minifies a given Lo-Dash `source` and invokes the `options.onComplete` - * callback when finished. The `onComplete` callback is invoked with one - * argument; (outputSource). - * - * @param {Array|String} [source=''] The source to minify or array of commands. - * -o, --output - Write output to a given path/filename. - * -s, --silent - Skip status updates normally logged to the console. - * -t, --template - Applies template specific minifier options. - * - * @param {Object} [options={}] The options object. - * outputPath - Write output to a given path/filename. - * isSilent - Skip status updates normally logged to the console. - * isTemplate - Applies template specific minifier options. - * onComplete - The function called once minification has finished. - */ - function minify(source, options) { - source || (source = ''); - options || (options = {}); - - // juggle arguments - if (Array.isArray(source)) { - // convert commands to an options object - options = source; - - var filePath = options[options.length - 1], - isSilent = options.indexOf('-s') > -1 || options.indexOf('--silent') > -1, - isTemplate = options.indexOf('-t') > -1 || options.indexOf('--template') > -1, - outputPath = path.join(path.dirname(filePath), path.basename(filePath, '.js') + '.min.js'); - - outputPath = options.reduce(function(result, value, index) { - if (/-o|--output/.test(value)) { - result = options[index + 1]; - result = path.join(fs.realpathSync(path.dirname(result)), path.basename(result)); - } - return result; - }, outputPath); - - options = { - 'isSilent': isSilent, - 'isTemplate': isTemplate, - 'outputPath': outputPath - }; - - source = fs.readFileSync(filePath, 'utf8'); - } - new Minify(source, options); - } - - /** - * The Minify constructor used to keep state of each `minify` invocation. - * - * @private - * @constructor - * @param {String} source The source to minify. - * @param {Object} options The options object. - * outputPath - Write output to a given path/filename. - * isSilent - Skip status updates normally logged to the console. - * isTemplate - Applies template specific minifier options. - * onComplete - The function called once minification has finished. - */ - function Minify(source, options) { - // juggle arguments - if (typeof source == 'object' && source) { - options = source || options; - source = options.source || ''; - } - this.compiled = { 'simple': {}, 'advanced': {} }; - this.hybrid = { 'simple': {}, 'advanced': {} }; - this.uglified = {}; - - this.isSilent = !!options.isSilent; - this.isTemplate = !!options.isTemplate; - this.outputPath = options.outputPath; - - source = preprocess(source, options); - this.source = source; - - this.onComplete = options.onComplete || function(source) { - fs.writeFileSync(this.outputPath, source, 'utf8'); - }; - - // begin the minification process - closureCompile.call(this, source, 'simple', onClosureSimpleCompile.bind(this)); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Compresses a `source` string using the Closure Compiler. Yields the - * minified result, and any exceptions encountered, to a `callback` function. - * - * @private - * @param {String} source The JavaScript source to minify. - * @param {String} mode The optimization mode. - * @param {Function} callback The function called once the process has completed. - */ - function closureCompile(source, mode, callback) { - // use simple optimizations when minifying template files - var options = closureOptions.slice(); - options.push('--compilation_level=' + optimizationModes[this.isTemplate ? 'simple' : mode]); - - // the standard error stream, standard output stream, and the Closure Compiler process - var error = '', - output = '', - compiler = spawn('java', ['-jar', closurePath].concat(options)); - - if (!this.isSilent) { - console.log('Compressing ' + path.basename(this.outputPath, '.js') + ' using the Closure Compiler (' + mode + ')...'); - } - compiler.stdout.on('data', function(data) { - // append the data to the output stream - output += data; - }); - - compiler.stderr.on('data', function(data) { - // append the error message to the error stream - error += data; - }); - - compiler.on('exit', function(status) { - // `status` contains the process exit code - var exception = null; - if (status) { - exception = new Error(error); - exception.status = status; - } - callback(exception, output); - }); - - // proxy the standard input to the Closure Compiler - compiler.stdin.end(source); - } - - /** - * Compresses a `source` string using UglifyJS. Yields the result to a - * `callback` function. This function is synchronous; the `callback` is used - * for symmetry. - * - * @private - * @param {String} source The JavaScript source to minify. - * @param {String} label The label to log. - * @param {Function} callback The function called once the process has completed. - */ - function uglify(source, label, callback) { - var exception, - result, - ugly = uglifyJS.uglify; - - if (!this.isSilent) { - console.log('Compressing ' + path.basename(this.outputPath, '.js') + ' using ' + label + '...'); - } - try { - result = ugly.gen_code( - // enable unsafe transformations - ugly.ast_squeeze_more( - ugly.ast_squeeze( - // munge variable and function names, excluding the special `define` - // function exposed by AMD loaders - ugly.ast_mangle(uglifyJS.parser.parse(source), { - 'except': ['define'] - } - ))), { - 'ascii_only': true - }); - } catch(e) { - exception = e; - } - // lines are restricted to 500 characters for consistency with the Closure Compiler - callback(exception, result && ugly.split_lines(result, 500)); - } - - /*--------------------------------------------------------------------------*/ - - /** - * The Closure Compiler callback for simple optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} result The resulting minified source. - */ - function onClosureSimpleCompile(exception, result) { - if (exception) { - throw exception; - } - result = postprocess(result); - this.compiled.simple.source = result; - gzip(result, onClosureSimpleGzip.bind(this)); - } - - /** - * The Closure Compiler `gzip` callback for simple optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {Buffer} result The resulting gzipped source. - */ - function onClosureSimpleGzip(exception, result) { - if (exception) { - throw exception; - } - if (!this.isSilent) { - console.log('Done. Size: %d bytes.', result.length); - } - this.compiled.simple.gzip = result; - - // next, compile the source using advanced optimizations - closureCompile.call(this, this.source, 'advanced', onClosureAdvancedCompile.bind(this)); - } - - /** - * The Closure Compiler callback for advanced optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} result The resulting minified source. - */ - function onClosureAdvancedCompile(exception, result) { - if (exception) { - throw exception; - } - result = postprocess(result); - this.compiled.advanced.source = result; - gzip(result, onClosureAdvancedGzip.bind(this)); - } - - /** - * The Closure Compiler `gzip` callback for advanced optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {Buffer} result The resulting gzipped source. - */ - function onClosureAdvancedGzip(exception, result) { - if (exception) { - throw exception; - } - if (!this.isSilent) { - console.log('Done. Size: %d bytes.', result.length); - } - this.compiled.advanced.gzip = result; - - // next, minify the source using only UglifyJS - uglify.call(this, this.source, 'UglifyJS', onUglify.bind(this)); - } - - /** - * The UglifyJS callback. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} result The resulting minified source. - */ - function onUglify(exception, result) { - if (exception) { - throw exception; - } - result = postprocess(result); - this.uglified.source = result; - gzip(result, onUglifyGzip.bind(this)); - } - - /** - * The UglifyJS `gzip` callback. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {Buffer} result The resulting gzipped source. - */ - function onUglifyGzip(exception, result) { - if (exception) { - throw exception; - } - if (!this.isSilent) { - console.log('Done. Size: %d bytes.', result.length); - } - this.uglified.gzip = result; - - // next, minify the already Closure Compiler simple optimized source using UglifyJS - uglify.call(this, this.compiled.simple.source, 'hybrid (simple)', onSimpleHybrid.bind(this)); - } - - /** - * The hybrid callback for simple optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} result The resulting minified source. - */ - function onSimpleHybrid(exception, result) { - if (exception) { - throw exception; - } - result = postprocess(result); - this.hybrid.simple.source = result; - gzip(result, onSimpleHybridGzip.bind(this)); - } - - /** - * The hybrid `gzip` callback for simple optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {Buffer} result The resulting gzipped source. - */ - function onSimpleHybridGzip(exception, result) { - if (exception) { - throw exception; - } - if (!this.isSilent) { - console.log('Done. Size: %d bytes.', result.length); - } - this.hybrid.simple.gzip = result; - - // next, minify the already Closure Compiler advance optimized source using UglifyJS - uglify.call(this, this.compiled.advanced.source, 'hybrid (advanced)', onAdvancedHybrid.bind(this)); - } - - /** - * The hybrid callback for advanced optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {String} result The resulting minified source. - */ - function onAdvancedHybrid(exception, result) { - if (exception) { - throw exception; - } - result = postprocess(result); - this.hybrid.advanced.source = result; - gzip(result, onAdvancedHybridGzip.bind(this)); - } - - /** - * The hybrid `gzip` callback for advanced optimizations. - * - * @private - * @param {Object|Undefined} exception The error object. - * @param {Buffer} result The resulting gzipped source. - */ - function onAdvancedHybridGzip(exception, result) { - if (exception) { - throw exception; - } - if (!this.isSilent) { - console.log('Done. Size: %d bytes.', result.length); - } - this.hybrid.advanced.gzip = result; - - // finish by choosing the smallest compressed file - onComplete.call(this); - } - - /** - * The callback executed after the source is minified and gzipped. - * - * @private - */ - function onComplete() { - var compiledSimple = this.compiled.simple, - compiledAdvanced = this.compiled.advanced, - uglified = this.uglified, - hybridSimple = this.hybrid.simple, - hybridAdvanced = this.hybrid.advanced; - - // select the smallest gzipped file and use its minified counterpart as the - // official minified release (ties go to the Closure Compiler) - var min = Math.min( - compiledSimple.gzip.length, - compiledAdvanced.gzip.length, - uglified.gzip.length, - hybridSimple.gzip.length, - hybridAdvanced.gzip.length - ); - - // pass the minified source to the "onComplete" callback - [compiledSimple, compiledAdvanced, uglified, hybridSimple, hybridAdvanced].some(function(data) { - if (data.gzip.length == min) { - this.onComplete(data.source); - } - }, this); - } - - /*--------------------------------------------------------------------------*/ - - // expose `minify` - if (module != require.main) { - module.exports = minify; - } - else { - // read the Lo-Dash source file from the first argument if the script - // was invoked directly (e.g. `node minify.js source.js`) and write to - // `.min.js` - (function() { - var options = process.argv; - if (options.length < 3) { - return; - } - minify(options); - }()); - } -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-compile.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-compile.js deleted file mode 100644 index 002ab58..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-compile.js +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** The Node filesystem module */ - var fs = require('fs'); - - /** The minimal license/copyright template */ - var licenseTemplate = { - 'lodash': - '/*!\n' + - ' Lo-Dash @VERSION lodash.com/license\n' + - ' Underscore.js 1.4.2 underscorejs.org/LICENSE\n' + - '*/', - 'underscore': - '/*! Underscore.js @VERSION underscorejs.org/LICENSE */' - }; - - /*--------------------------------------------------------------------------*/ - - /** - * Post-process a given minified Lo-Dash `source`, preparing it for - * deployment. - * - * @param {String} source The source to process. - * @returns {String} Returns the processed source. - */ - function postprocess(source) { - // move vars exposed by the Closure Compiler into the IIFE - source = source.replace(/^((?:(['"])use strict\2;)?(?:var (?:[a-z]+=(?:!0|!1|null)[,;])+)?)([\s\S]*?function[^)]+\){)/, '$3$1'); - - // correct overly aggressive Closure Compiler advanced optimizations - source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}'); - - // unescape properties (i.e. foo["bar"] => foo.bar) - source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) { - return /\W/.test(right) ? match : (left + '.' + right); - }); - - // correct AMD module definition for AMD build optimizers - source = source.replace(/("function")\s*==\s*(typeof define)\s*&&\s*\(?\s*("object")\s*==\s*(typeof define\.amd)\s*&&\s*(define\.amd)\s*\)?/, '$2==$1&&$4==$3&&$5'); - - // add trailing semicolon - if (source) { - source = source.replace(/[\s;]*$/, ';'); - } - // exit early if version snippet isn't found - var snippet = /VERSION\s*[=:]\s*([\'"])(.*?)\1/.exec(source); - if (!snippet) { - return source; - } - // add copyright/license header - return licenseTemplate[/call\(this\);?$/.test(source) ? 'underscore' : 'lodash'] - .replace('@VERSION', snippet[2]) + '\n;' + source; - } - - /*--------------------------------------------------------------------------*/ - - // expose `postprocess` - if (module != require.main) { - module.exports = postprocess; - } - else { - // read the Lo-Dash source file from the first argument if the script - // was invoked directly (e.g. `node post-compile.js source.js`) and write to - // the same file - (function() { - var options = process.argv; - if (options.length < 3) { - return; - } - var filePath = options[options.length - 1], - source = fs.readFileSync(filePath, 'utf8'); - - fs.writeFileSync(filePath, postprocess(source), 'utf8'); - }()); - } -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-install.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-install.js deleted file mode 100644 index 8b59aff..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/post-install.js +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** Load Node modules */ - var exec = require('child_process').exec, - fs = require('fs'), - https = require('https'), - path = require('path'), - tar = require('../vendor/tar/tar.js'), - zlib = require('zlib'); - - /** The path of the directory that is the base of the repository */ - var basePath = fs.realpathSync(path.join(__dirname, '..')); - - /** The path of the `vendor` directory */ - var vendorPath = path.join(basePath, 'vendor'); - - /** The Git object ID of `closure-compiler.tar.gz` */ - var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; - - /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '7ecae09d413eb48dd5785fe877f24e60ac3bbcef'; - - /** The media type for raw blob data */ - var mediaType = 'application/vnd.github.v3.raw'; - - /** Reassign `existsSync` for older versions of Node */ - fs.existsSync || (fs.existsSync = path.existsSync); - - /** Used to reference parts of the blob href */ - var location = (function() { - var host = 'api.github.com', - origin = 'https://api.github.com', - pathname = '/repos/bestiejs/lodash/git/blobs'; - - return { - 'host': host, - 'href': host + origin + pathname, - 'origin': origin, - 'pathname': pathname - }; - }()); - - /*--------------------------------------------------------------------------*/ - - /** - * Fetches a required `.tar.gz` dependency with the given Git object ID from - * the Lo-Dash repo on GitHub. The object ID may be obtained by running - * `git hash-object path/to/dependency.tar.gz`. - * - * @private - * @param {Object} options The options object. - * id - The Git object ID of the `.tar.gz` file. - * onComplete - The function, invoked with one argument (exception), - * called once the extraction has finished. - * path - The path of the extraction directory. - * title - The dependency's title used in status updates logged to the console. - */ - function getDependency(options) { - options || (options = {}); - - var id = options.id, - onComplete = options.onComplete, - path = options.path, - title = options.title; - - function callback(exception) { - if (exception) { - console.error([ - 'There was a problem installing ' + title + '. To manually install, run:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + id + " | tar xvz -C '" + path + "'" - ].join('\n')); - } - onComplete(exception); - } - - console.log('Downloading ' + title + '...'); - - https.get({ - 'host': location.host, - 'path': location.pathname + '/' + id, - 'headers': { - // By default, all GitHub blob API endpoints return a JSON document - // containing Base64-encoded blob data. Overriding the `Accept` header - // with the GitHub raw media type returns the blob data directly. - // See http://developer.github.com/v3/media/. - 'Accept': mediaType - } - }, function(response) { - var decompressor = zlib.createUnzip(), - parser = new tar.Extract({ 'path': path }); - - decompressor.on('error', callback) - parser.on('end', callback).on('error', callback); - response.pipe(decompressor).pipe(parser); - }) - .on('error', callback); - } - - /*--------------------------------------------------------------------------*/ - - exec('npm -g root', function(exception, stdout) { - if (!exception) { - try { - var root = stdout.trim(), - isGlobal = fs.existsSync(root) && path.resolve(basePath, '..') == fs.realpathSync(root); - } catch(e) { - exception = e; - } - } - if (exception) { - console.error([ - 'Oops! There was a problem detecting the install mode. If you’re installing the', - 'Lo-Dash command-line executable (via `npm install -g lodash`), you’ll need to', - 'manually install UglifyJS and the Closure Compiler by running:', - '', - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", - "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", - '', - 'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url - ].join('\n')); - - console.error(exception); - } - if (!isGlobal) { - return; - } - // download the Closure Compiler - getDependency({ - 'title': 'the Closure Compiler', - 'id': closureId, - 'path': vendorPath, - 'onComplete': function() { - // download UglifyJS - getDependency({ - 'title': 'UglifyJS', - 'id': uglifyId, - 'path': vendorPath, - 'onComplete': function() { - process.exit(); - } - }); - } - }); - }); -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/pre-compile.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/pre-compile.js deleted file mode 100644 index 2d56e4c..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/build/pre-compile.js +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/bin/env node -;(function() { - 'use strict'; - - /** The Node filesystem module */ - var fs = require('fs'); - - /** Used to minify variables embedded in compiled strings */ - var compiledVars = [ - 'argsIndex', - 'argsLength', - 'callback', - 'collection', - 'createCallback', - 'ctor', - 'guard', - 'hasOwnProperty', - 'index', - 'isArguments', - 'isString', - 'iteratee', - 'length', - 'nativeKeys', - 'object', - 'objectTypes', - 'ownIndex', - 'ownProps', - 'propertyIsEnumerable', - 'result', - 'skipProto', - 'source', - 'thisArg', - 'value' - ]; - - /** Used to minify `compileIterator` option properties */ - var iteratorOptions = [ - 'args', - 'arrayLoop', - 'bottom', - 'firstArg', - 'hasDontEnumBug', - 'isKeysFast', - 'objectLoop', - 'noArgsEnum', - 'noCharByIndex', - 'shadowed', - 'top', - 'useHas', - 'useStrict' - ]; - - /** Used to minify variables and string values to a single character */ - var minNames = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); - minNames.push.apply(minNames, minNames.map(function(value) { - return value + value; - })); - - /** Used to protect the specified properties from getting minified */ - var propWhitelist = [ - '_', - '__chain__', - '__wrapped__', - 'after', - 'all', - 'amd', - 'any', - 'assign', - 'attachEvent', - 'bind', - 'bindAll', - 'bindKey', - 'chain', - 'clone', - 'collect', - 'compact', - 'compose', - 'contains', - 'countBy', - 'criteria', - 'debounce', - 'defaults', - 'defer', - 'delay', - 'detect', - 'difference', - 'drop', - 'each', - 'environment', - 'escape', - 'evaluate', - 'every', - 'exports', - 'extend', - 'filter', - 'find', - 'first', - 'flatten', - 'foldl', - 'foldr', - 'forEach', - 'forIn', - 'forOwn', - 'functions', - 'global', - 'groupBy', - 'has', - 'head', - 'identity', - 'include', - 'index', - 'indexOf', - 'initial', - 'inject', - 'interpolate', - 'intersection', - 'invert', - 'invoke', - 'isArguments', - 'isArray', - 'isBoolean', - 'isDate', - 'isElement', - 'isEmpty', - 'isEqual', - 'isEqual', - 'isFinite', - 'isFinite', - 'isFunction', - 'isNaN', - 'isNull', - 'isNumber', - 'isObject', - 'isPlainObject', - 'isRegExp', - 'isString', - 'isUndefined', - 'keys', - 'last', - 'lastIndexOf', - 'map', - 'max', - 'memoize', - 'merge', - 'methods', - 'min', - 'mixin', - 'noConflict', - 'object', - 'omit', - 'once', - 'opera', - 'pairs', - 'partial', - 'pick', - 'pluck', - 'random', - 'range', - 'reduce', - 'reduceRight', - 'reject', - 'rest', - 'result', - 'select', - 'shuffle', - 'size', - 'some', - 'sortBy', - 'sortedIndex', - 'source', - 'tail', - 'take', - 'tap', - 'template', - 'templateSettings', - 'throttle', - 'times', - 'toArray', - 'unescape', - 'union', - 'uniq', - 'unique', - 'uniqueId', - 'value', - 'values', - 'variable', - 'VERSION', - 'where', - 'without', - 'wrap', - 'zip', - - // properties used by underscore.js - '_chain', - '_wrapped' - ]; - - /*--------------------------------------------------------------------------*/ - - /** - * Pre-process a given Lo-Dash `source`, preparing it for minification. - * - * @param {String} [source=''] The source to process. - * @param {Object} [options={}] The options object. - * @returns {String} Returns the processed source. - */ - function preprocess(source, options) { - source || (source = ''); - options || (options = {}); - - // remove unrecognized JSDoc tags so the Closure Compiler won't complain - source = source.replace(/@(?:alias|category)\b.*/g, ''); - - if (options.isTemplate) { - return source; - } - - // remove copyright/license header to add later in post-compile.js - source = source.replace(/\/\*![\s\S]+?\*\//, ''); - - // add brackets to whitelisted properties so the Closure Compiler won't mung them - // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export - source = source.replace(RegExp('\\.(' + propWhitelist.join('|') + ')\\b', 'g'), "['$1']"); - - // remove brackets from `_.escape()` in `_.template` - source = source.replace(/__e *= *_\['escape']/g, '__e=_.escape'); - - // remove brackets from `_.escape()` in underscore.js `_.template` - source = source.replace(/_\['escape'\]\(__t'/g, '_.escape(__t'); - - // remove brackets from `collection.indexOf` in `_.contains` - source = source.replace("collection['indexOf'](target)", 'collection.indexOf(target)'); - - // remove brackets from `result[length].value` in `_.sortBy` - source = source.replace("result[length]['value']", 'result[length].value'); - - // remove whitespace from string literals - source = source.replace(/'(?:(?=(\\?))\1.)*?'/g, function(string) { - // avoids removing the '\n' of the `stringEscapes` object - return string.replace(/\[object |delete |else |function | in |return\s+[\w']|throw |typeof |use strict|var |@ |'\\n'|\\\\n|\\n|\s+/g, function(match) { - return match == false || match == '\\n' ? '' : match; - }); - }); - - // add newline to `+"__p+='"` in underscore.js `_.template` - source = source.replace(/\+"__p\+='"/g, '+"\\n__p+=\'"'); - - // remove whitespace from `_.template` related regexes - source = source.replace(/(?:reEmptyString\w+|reInsertVariable) *=.+/g, function(match) { - return match.replace(/ |\\n/g, ''); - }); - - // remove newline from double-quoted strings in `_.template` - source = source - .replace('"\';\\n__with ("', '"\';__with("') - .replace('"\\n}__\\n__p += \'"', '"}____p+=\'"') - .replace('"__p = \'"', '"__p=\'"') - .replace('"\';\\n"', '"\';"') - .replace("') {\\n'", "'){'") - - // remove `useSourceURL` variable - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *try *\{(?:\s*\/\/.*)*\n *var useSourceURL[\s\S]+?catch[^}]+}\n/, ''); - - // remove debug sourceURL use in `_.template` - source = source.replace(/(?:\s*\/\/.*\n)* *var sourceURL[^;]+;|\+ *sourceURL/g, ''); - - // minify internal properties used by 'compareAscending' and `_.sortBy` - (function() { - var properties = ['criteria', 'index', 'value'], - snippets = source.match(/( +)function (?:compareAscending|sortBy)\b[\s\S]+?\n\1}/g); - - if (!snippets) { - return; - } - snippets.forEach(function(snippet) { - var modified = snippet; - - // minify properties - properties.forEach(function(property, index) { - var reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'), - reDotProp = RegExp('\\.' + property + '\\b', 'g'), - rePropColon = RegExp("([^?\\s])\\s*([\"'])?\\b" + property + "\\2 *:", 'g'); - - modified = modified - .replace(reBracketProp, "['" + minNames[index] + "']") - .replace(reDotProp, "['" + minNames[index] + "']") - .replace(rePropColon, "$1'" + minNames[index] + "':"); - }); - - // replace with modified snippet - source = source.replace(snippet, modified); - }); - }()); - - // minify all compilable snippets - var snippets = source.match( - RegExp([ - // match the `iteratorTemplate` - '( +)var iteratorTemplate\\b[\\s\\S]+?\\n\\1}', - // match methods created by `createIterator` calls - 'createIterator\\((?:{|[a-zA-Z]+)[\\s\\S]+?\\);\\n', - // match variables storing `createIterator` options - '( +)var [a-zA-Z]+IteratorOptions\\b[\\s\\S]+?\\n\\2}', - // match the the `createIterator` function - '( +)function createIterator\\b[\\s\\S]+?\\n\\3}' - ].join('|'), 'g') - ); - - // exit early if no compilable snippets - if (!snippets) { - return source; - } - - snippets.forEach(function(snippet, index) { - var isCreateIterator = /function createIterator\b/.test(snippet), - isIteratorTemplate = /var iteratorTemplate\b/.test(snippet), - modified = snippet; - - // add brackets to whitelisted properties so the Closure Compiler won't mung them - modified = modified.replace(RegExp('\\.(' + iteratorOptions.join('|') + ')\\b', 'g'), "['$1']"); - - if (isCreateIterator) { - // replace with modified snippet early and clip snippet to the `factory` - // call so other arguments aren't minified - source = source.replace(snippet, modified); - snippet = modified = modified.replace(/factory\([\s\S]+$/, ''); - } - - // minify snippet variables / arguments - compiledVars.forEach(function(variable, index) { - // ensure properties in compiled strings aren't minified - modified = modified.replace(RegExp('([^.]\\b)' + variable + '\\b(?!\' *[\\]:])', 'g'), '$1' + minNames[index]); - - // correct `typeof x == 'object'` - if (variable == 'object') { - modified = modified.replace(RegExp("(typeof [^']+')" + minNames[index] + "'", 'g'), "$1object'"); - } - }); - - // minify `createIterator` option property names - iteratorOptions.forEach(function(property, index) { - if (isIteratorTemplate) { - // minify property names as interpolated template variables - modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]); - } - else { - // minify property name strings - modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'"); - // minify property names in accessors - if (isCreateIterator) { - modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minNames[index]); - } - } - }); - - // replace with modified snippet - source = source.replace(snippet, modified); - }); - - return source; - } - - /*--------------------------------------------------------------------------*/ - - // expose `preprocess` - if (module != require.main) { - module.exports = preprocess; - } - else { - // read the Lo-Dash source file from the first argument if the script - // was invoked directly (e.g. `node pre-compile.js source.js`) and write to - // the same file - (function() { - var options = process.argv; - if (options.length < 3) { - return; - } - var filePath = options[options.length - 1], - isTemplate = options.indexOf('-t') > -1 || options.indexOf('--template') > -1, - source = fs.readFileSync(filePath, 'utf8'); - - fs.writeFileSync(filePath, preprocess(source, { - 'isTemplate': isTemplate - }), 'utf8'); - }()); - } -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/doc/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/doc/README.md deleted file mode 100644 index 5b299a0..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/doc/README.md +++ /dev/null @@ -1,3099 +0,0 @@ -# Lo-Dash v0.10.0 - - - - - - -##
`Arrays` -* [`_.compact`](#_compactarray) -* [`_.difference`](#_differencearray--array1-array2-) -* [`_.drop`](#_restarray--n1) -* [`_.first`](#_firstarray--n) -* [`_.flatten`](#_flattenarray-shallow) -* [`_.head`](#_firstarray--n) -* [`_.indexOf`](#_indexofarray-value--fromindex0) -* [`_.initial`](#_initialarray--n1) -* [`_.intersection`](#_intersectionarray1-array2-) -* [`_.last`](#_lastarray--n) -* [`_.lastIndexOf`](#_lastindexofarray-value--fromindexarraylength-1) -* [`_.object`](#_objectkeys--values) -* [`_.range`](#_rangestart0-end--step1) -* [`_.rest`](#_restarray--n1) -* [`_.sortedIndex`](#_sortedindexarray-value--callbackidentityproperty-thisarg) -* [`_.tail`](#_restarray--n1) -* [`_.take`](#_firstarray--n) -* [`_.union`](#_unionarray1-array2-) -* [`_.uniq`](#_uniqarray--issortedfalse-callbackidentity-thisarg) -* [`_.unique`](#_uniqarray--issortedfalse-callbackidentity-thisarg) -* [`_.without`](#_withoutarray--value1-value2-) -* [`_.zip`](#_ziparray1-array2-) - - - - - - -## `Chaining` -* [`_`](#_value) -* [`_.chain`](#_chainvalue) -* [`_.tap`](#_tapvalue-interceptor) -* [`_.prototype.chain`](#_prototypechain) -* [`_.prototype.value`](#_prototypevalue) - - - - - - -## `Collections` -* [`_.all`](#_everycollection--callbackidentity-thisarg) -* [`_.any`](#_somecollection--callbackidentity-thisarg) -* [`_.collect`](#_mapcollection--callbackidentity-thisarg) -* [`_.contains`](#_containscollection-target--fromindex0) -* [`_.countBy`](#_countbycollection-callbackproperty--thisarg) -* [`_.detect`](#_findcollection-callback--thisarg) -* [`_.each`](#_foreachcollection-callback--thisarg) -* [`_.every`](#_everycollection--callbackidentity-thisarg) -* [`_.filter`](#_filtercollection--callbackidentity-thisarg) -* [`_.find`](#_findcollection-callback--thisarg) -* [`_.foldl`](#_reducecollection-callback--accumulator-thisarg) -* [`_.foldr`](#_reducerightcollection-callback--accumulator-thisarg) -* [`_.forEach`](#_foreachcollection-callback--thisarg) -* [`_.groupBy`](#_groupbycollection-callbackproperty--thisarg) -* [`_.include`](#_containscollection-target--fromindex0) -* [`_.inject`](#_reducecollection-callback--accumulator-thisarg) -* [`_.invoke`](#_invokecollection-methodname--arg1-arg2-) -* [`_.map`](#_mapcollection--callbackidentity-thisarg) -* [`_.max`](#_maxcollection--callback-thisarg) -* [`_.min`](#_mincollection--callback-thisarg) -* [`_.pluck`](#_pluckcollection-property) -* [`_.reduce`](#_reducecollection-callback--accumulator-thisarg) -* [`_.reduceRight`](#_reducerightcollection-callback--accumulator-thisarg) -* [`_.reject`](#_rejectcollection--callbackidentity-thisarg) -* [`_.select`](#_filtercollection--callbackidentity-thisarg) -* [`_.shuffle`](#_shufflecollection) -* [`_.size`](#_sizecollection) -* [`_.some`](#_somecollection--callbackidentity-thisarg) -* [`_.sortBy`](#_sortbycollection-callbackproperty--thisarg) -* [`_.toArray`](#_toarraycollection) -* [`_.where`](#_wherecollection-properties) - - - - - - -## `Functions` -* [`_.after`](#_aftern-func) -* [`_.bind`](#_bindfunc--thisarg-arg1-arg2-) -* [`_.bindAll`](#_bindallobject--methodname1-methodname2-) -* [`_.bindKey`](#_bindkeyobject-key--arg1-arg2-) -* [`_.compose`](#_composefunc1-func2-) -* [`_.debounce`](#_debouncefunc-wait-immediate) -* [`_.defer`](#_deferfunc--arg1-arg2-) -* [`_.delay`](#_delayfunc-wait--arg1-arg2-) -* [`_.memoize`](#_memoizefunc--resolver) -* [`_.once`](#_oncefunc) -* [`_.partial`](#_partialfunc--arg1-arg2-) -* [`_.throttle`](#_throttlefunc-wait) -* [`_.wrap`](#_wrapvalue-wrapper) - - - - - - -## `Objects` -* [`_.assign`](#_assignobject--source1-source2-) -* [`_.clone`](#_clonevalue-deep) -* [`_.defaults`](#_defaultsobject--default1-default2-) -* [`_.extend`](#_assignobject--source1-source2-) -* [`_.forIn`](#_forinobject-callback--thisarg) -* [`_.forOwn`](#_forownobject-callback--thisarg) -* [`_.functions`](#_functionsobject) -* [`_.has`](#_hasobject-property) -* [`_.invert`](#_invertobject) -* [`_.isArguments`](#_isargumentsvalue) -* [`_.isArray`](#_isarrayvalue) -* [`_.isBoolean`](#_isbooleanvalue) -* [`_.isDate`](#_isdatevalue) -* [`_.isElement`](#_iselementvalue) -* [`_.isEmpty`](#_isemptyvalue) -* [`_.isEqual`](#_isequala-b) -* [`_.isFinite`](#_isfinitevalue) -* [`_.isFunction`](#_isfunctionvalue) -* [`_.isNaN`](#_isnanvalue) -* [`_.isNull`](#_isnullvalue) -* [`_.isNumber`](#_isnumbervalue) -* [`_.isObject`](#_isobjectvalue) -* [`_.isPlainObject`](#_isplainobjectvalue) -* [`_.isRegExp`](#_isregexpvalue) -* [`_.isString`](#_isstringvalue) -* [`_.isUndefined`](#_isundefinedvalue) -* [`_.keys`](#_keysobject) -* [`_.merge`](#_mergeobject--source1-source2-) -* [`_.methods`](#_functionsobject) -* [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg) -* [`_.pairs`](#_pairsobject) -* [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg) -* [`_.values`](#_valuesobject) - - - - - - -## `Utilities` -* [`_.escape`](#_escapestring) -* [`_.identity`](#_identityvalue) -* [`_.mixin`](#_mixinobject) -* [`_.noConflict`](#_noconflict) -* [`_.random`](#_randommin0-max1) -* [`_.result`](#_resultobject-property) -* [`_.template`](#_templatetext-data-options) -* [`_.times`](#_timesn-callback--thisarg) -* [`_.unescape`](#_unescapestring) -* [`_.uniqueId`](#_uniqueidprefix) - - - - - - -## `Properties` -* [`_.VERSION`](#_version) -* [`_.templateSettings`](#_templatesettings) -* [`_.templateSettings.escape`](#_templatesettingsescape) -* [`_.templateSettings.evaluate`](#_templatesettingsevaluate) -* [`_.templateSettings.interpolate`](#_templatesettingsinterpolate) -* [`_.templateSettings.variable`](#_templatesettingsvariable) - - - - - - - - - - - - -## `“Arrays” Methods` - - - -### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2576 "View in source") [Ⓣ][1] - -Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. - -#### Arguments -1. `array` *(Array)*: The array to compact. - -#### Returns -*(Array)*: Returns a new filtered array. - -#### Example -```js -_.compact([0, 1, false, 2, '', 3]); -// => [1, 2, 3] -``` - -* * * - - - - - - -### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2606 "View in source") [Ⓣ][1] - -Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. - -#### Arguments -1. `array` *(Array)*: The array to process. -2. `[array1, array2, ...]` *(Array)*: Arrays to check. - -#### Returns -*(Array)*: Returns a new array of `array` elements not present in the other arrays. - -#### Example -```js -_.difference([1, 2, 3, 4, 5], [5, 2, 10]); -// => [1, 3, 4] -``` - -* * * - - - - - - -### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2641 "View in source") [Ⓣ][1] - -Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. - -#### Aliases -*head, take* - -#### Arguments -1. `array` *(Array)*: The array to query. -2. `[n]` *(Number)*: The number of elements to return. - -#### Returns -*(Mixed)*: Returns the first element or an array of the first `n` elements of `array`. - -#### Example -```js -_.first([5, 4, 3, 2, 1]); -// => 5 -``` - -* * * - - - - - - -### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2665 "View in source") [Ⓣ][1] - -Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. - -#### Arguments -1. `array` *(Array)*: The array to compact. -2. `shallow` *(Boolean)*: A flag to indicate only flattening a single level. - -#### Returns -*(Array)*: Returns a new flattened array. - -#### Example -```js -_.flatten([1, [2], [3, [[4]]]]); -// => [1, 2, 3, 4]; - -_.flatten([1, [2], [3, [[4]]]], true); -// => [1, 2, 3, [[4]]]; -``` - -* * * - - - - - - -### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2707 "View in source") [Ⓣ][1] - -Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. - -#### Arguments -1. `array` *(Array)*: The array to search. -2. `value` *(Mixed)*: The value to search for. -3. `[fromIndex=0]` *(Boolean|Number)*: The index to search from or `true` to perform a binary search on a sorted `array`. - -#### Returns -*(Number)*: Returns the index of the matched value or `-1`. - -#### Example -```js -_.indexOf([1, 2, 3, 1, 2, 3], 2); -// => 1 - -_.indexOf([1, 2, 3, 1, 2, 3], 2, 3); -// => 4 - -_.indexOf([1, 1, 2, 2, 3, 3], 2, true); -// => 2 -``` - -* * * - - - - - - -### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2742 "View in source") [Ⓣ][1] - -Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. - -#### Arguments -1. `array` *(Array)*: The array to query. -2. `[n=1]` *(Number)*: The number of elements to exclude. - -#### Returns -*(Array)*: Returns all but the last element or `n` elements of `array`. - -#### Example -```js -_.initial([3, 2, 1]); -// => [3, 2] -``` - -* * * - - - - - - -### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2763 "View in source") [Ⓣ][1] - -Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. - -#### Arguments -1. `[array1, array2, ...]` *(Array)*: Arrays to process. - -#### Returns -*(Array)*: Returns a new array of unique elements, in order, that are present in **all** of the arrays. - -#### Example -```js -_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); -// => [1, 2] -``` - -* * * - - - - - - -### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2801 "View in source") [Ⓣ][1] - -Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. - -#### Arguments -1. `array` *(Array)*: The array to query. -2. `[n]` *(Number)*: The number of elements to return. - -#### Returns -*(Mixed)*: Returns the last element or an array of the last `n` elements of `array`. - -#### Example -```js -_.last([3, 2, 1]); -// => 1 -``` - -* * * - - - - - - -### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] - -Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. - -#### Arguments -1. `array` *(Array)*: The array to search. -2. `value` *(Mixed)*: The value to search for. -3. `[fromIndex=array.length-1]` *(Number)*: The index to search from. - -#### Returns -*(Number)*: Returns the index of the matched value or `-1`. - -#### Example -```js -_.lastIndexOf([1, 2, 3, 1, 2, 3], 2); -// => 4 - -_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -// => 1 -``` - -* * * - - - - - - -### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2858 "View in source") [Ⓣ][1] - -Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. - -#### Arguments -1. `keys` *(Array)*: The array of keys. -2. `[values=[]]` *(Array)*: The array of values. - -#### Returns -*(Object)*: Returns an object composed of the given keys and corresponding values. - -#### Example -```js -_.object(['moe', 'larry', 'curly'], [30, 40, 50]); -// => { 'moe': 30, 'larry': 40, 'curly': 50 } -``` - -* * * - - - - - - -### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2903 "View in source") [Ⓣ][1] - -Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. - -#### Arguments -1. `[start=0]` *(Number)*: The start of the range. -2. `end` *(Number)*: The end of the range. -3. `[step=1]` *(Number)*: The value to increment or descrement by. - -#### Returns -*(Array)*: Returns a new range array. - -#### Example -```js -_.range(10); -// => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - -_.range(1, 11); -// => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - -_.range(0, 30, 5); -// => [0, 5, 10, 15, 20, 25] - -_.range(0, -10, -1); -// => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] - -_.range(0); -// => [] -``` - -* * * - - - - - - -### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2942 "View in source") [Ⓣ][1] - -The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. - -#### Aliases -*drop, tail* - -#### Arguments -1. `array` *(Array)*: The array to query. -2. `[n=1]` *(Number)*: The number of elements to exclude. - -#### Returns -*(Array)*: Returns all but the first value or `n` values of `array`. - -#### Example -```js -_.rest([3, 2, 1]); -// => [2, 1] -``` - -* * * - - - - - - -### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2988 "View in source") [Ⓣ][1] - -Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. - -#### Arguments -1. `array` *(Array)*: The array to iterate over. -2. `value` *(Mixed)*: The value to evaluate. -3. `[callback=identity|property]` *(Function|String)*: The function called per iteration or property name to order by. -4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Number)*: Returns the index at which the value should be inserted into `array`. - -#### Example -```js -_.sortedIndex([20, 30, 50], 40); -// => 2 - -_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); -// => 2 - -var dict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } -}; - -_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return dict.wordToNumber[word]; -}); -// => 2 - -_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return this.wordToNumber[word]; -}, dict); -// => 2 -``` - -* * * - - - - - - -### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3019 "View in source") [Ⓣ][1] - -Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. - -#### Arguments -1. `[array1, array2, ...]` *(Array)*: Arrays to process. - -#### Returns -*(Array)*: Returns a new array of unique values, in order, that are present in one or more of the arrays. - -#### Example -```js -_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); -// => [1, 2, 3, 101, 10] -``` - -* * * - - - - - - -### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3053 "View in source") [Ⓣ][1] - -Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. - -#### Aliases -*unique* - -#### Arguments -1. `array` *(Array)*: The array to process. -2. `[isSorted=false]` *(Boolean)*: A flag to indicate that the `array` is already sorted. -3. `[callback=identity]` *(Function)*: The function called per iteration. -4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array)*: Returns a duplicate-value-free array. - -#### Example -```js -_.uniq([1, 2, 1, 3, 1]); -// => [1, 2, 3] - -_.uniq([1, 1, 2, 2, 3], true); -// => [1, 2, 3] - -_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); -// => [1, 2, 3] - -_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); -// => [1, 2, 3] -``` - -* * * - - - - - - -### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3111 "View in source") [Ⓣ][1] - -Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. - -#### Arguments -1. `array` *(Array)*: The array to filter. -2. `[value1, value2, ...]` *(Mixed)*: Values to remove. - -#### Returns -*(Array)*: Returns a new filtered array. - -#### Example -```js -_.without([1, 2, 1, 0, 3, 1, 4], 0, 1); -// => [2, 3, 4] -``` - -* * * - - - - - - -### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3142 "View in source") [Ⓣ][1] - -Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. - -#### Arguments -1. `[array1, array2, ...]` *(Array)*: Arrays to process. - -#### Returns -*(Array)*: Returns a new array of grouped elements. - -#### Example -```js -_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); -// => [['moe', 30, true], ['larry', 40, false], ['curly', 50, false]] -``` - -* * * - - - - - - - - - -## `“Chaining” Methods` - - - -### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L242 "View in source") [Ⓣ][1] - -The `lodash` function. - -#### Arguments -1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. - -#### Returns -*(Object)*: Returns a `lodash` instance. - -* * * - - - - - - -### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4008 "View in source") [Ⓣ][1] - -Wraps the value in a `lodash` wrapper object. - -#### Arguments -1. `value` *(Mixed)*: The value to wrap. - -#### Returns -*(Object)*: Returns the wrapper object. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -var youngest = _.chain(stooges) - .sortBy(function(stooge) { return stooge.age; }) - .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - .first() - .value(); -// => 'moe is 40' -``` - -* * * - - - - - - -### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4035 "View in source") [Ⓣ][1] - -Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. - -#### Arguments -1. `value` *(Mixed)*: The value to pass to `interceptor`. -2. `interceptor` *(Function)*: The function to invoke. - -#### Returns -*(Mixed)*: Returns `value`. - -#### Example -```js -_.chain([1, 2, 3, 200]) - .filter(function(num) { return num % 2 == 0; }) - .tap(alert) - .map(function(num) { return num * num }) - .value(); -// => // [2, 200] (alerted) -// => [4, 40000] -``` - -* * * - - - - - - -### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4053 "View in source") [Ⓣ][1] - -Enables method chaining on the wrapper object. - -#### Returns -*(Mixed)*: Returns the wrapper object. - -#### Example -```js -_([1, 2, 3]).value(); -// => [1, 2, 3] -``` - -* * * - - - - - - -### `_.prototype.value()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4070 "View in source") [Ⓣ][1] - -Extracts the wrapped value. - -#### Returns -*(Mixed)*: Returns the wrapped value. - -#### Example -```js -_([1, 2, 3]).value(); -// => [1, 2, 3] -``` - -* * * - - - - - - - - - -## `“Collections” Methods` - - - -### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1844 "View in source") [Ⓣ][1] - -Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. - -#### Aliases -*include* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `target` *(Mixed)*: The value to check for. -3. `[fromIndex=0]` *(Number)*: The index to search from. - -#### Returns -*(Boolean)*: Returns `true` if the `target` element is found, else `false`. - -#### Example -```js -_.contains([1, 2, 3], 1); -// => true - -_.contains([1, 2, 3], 1, 2); -// => false - -_.contains({ 'name': 'moe', 'age': 40 }, 'moe'); -// => true - -_.contains('curly', 'ur'); -// => true -``` - -* * * - - - - - - -### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1891 "View in source") [Ⓣ][1] - -Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback|property` *(Function|String)*: The function called per iteration or property name to count by. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns the composed aggregate object. - -#### Example -```js -_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -// => { '4': 1, '6': 2 } - -_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -// => { '4': 1, '6': 2 } - -_.countBy(['one', 'two', 'three'], 'length'); -// => { '3': 2, '5': 1 } -``` - -* * * - - - - - - -### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1920 "View in source") [Ⓣ][1] - -Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. - -#### Aliases -*all* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Boolean)*: Returns `true` if all elements pass the callback check, else `false`. - -#### Example -```js -_.every([true, 1, null, 'yes'], Boolean); -// => false -``` - -* * * - - - - - - -### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1959 "View in source") [Ⓣ][1] - -Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. - -#### Aliases -*select* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array)*: Returns a new array of elements that passed the callback check. - -#### Example -```js -var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -// => [2, 4, 6] -``` - -* * * - - - - - - -### `_.find(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2003 "View in source") [Ⓣ][1] - -Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. - -#### Aliases -*detect* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Mixed)*: Returns the element that passed the callback check, else `undefined`. - -#### Example -```js -var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -// => 2 -``` - -* * * - - - - - - -### `_.forEach(collection, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2037 "View in source") [Ⓣ][1] - -Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. - -#### Aliases -*each* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array, Object, String)*: Returns `collection`. - -#### Example -```js -_([1, 2, 3]).forEach(alert).join(','); -// => alerts each number and returns '1,2,3' - -_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); -// => alerts each number (order is not guaranteed) -``` - -* * * - - - - - - -### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2065 "View in source") [Ⓣ][1] - -Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback|property` *(Function|String)*: The function called per iteration or property name to group by. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns the composed aggregate object. - -#### Example -```js -_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -// => { '4': [4.2], '6': [6.1, 6.4] } - -_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -// => { '4': [4.2], '6': [6.1, 6.4] } - -_.groupBy(['one', 'two', 'three'], 'length'); -// => { '3': ['one', 'two'], '5': ['three'] } -``` - -* * * - - - - - - -### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2097 "View in source") [Ⓣ][1] - -Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `methodName` *(Function|String)*: The name of the method to invoke or the function invoked per iteration. -3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the method with. - -#### Returns -*(Array)*: Returns a new array of the results of each invoked method. - -#### Example -```js -_.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); -// => [[1, 5, 7], [1, 2, 3]] - -_.invoke([123, 456], String.prototype.split, ''); -// => [['1', '2', '3'], ['4', '5', '6']] -``` - -* * * - - - - - - -### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2129 "View in source") [Ⓣ][1] - -Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. - -#### Aliases -*collect* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array)*: Returns a new array of the results of each `callback` execution. - -#### Example -```js -_.map([1, 2, 3], function(num) { return num * 3; }); -// => [3, 6, 9] - -_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -// => [3, 6, 9] (order is not guaranteed) -``` - -* * * - - - - - - -### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2171 "View in source") [Ⓣ][1] - -Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Mixed)*: Returns the maximum value. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -_.max(stooges, function(stooge) { return stooge.age; }); -// => { 'name': 'curly', 'age': 60 }; -``` - -* * * - - - - - - -### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2217 "View in source") [Ⓣ][1] - -Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Mixed)*: Returns the minimum value. - -#### Example -```js -_.min([10, 5, 100, 2, 1000]); -// => 2 -``` - -* * * - - - - - - -### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2266 "View in source") [Ⓣ][1] - -Retrieves the value of a specified property from all elements in the `collection`. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `property` *(String)*: The property to pluck. - -#### Returns -*(Array)*: Returns a new array of property values. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -_.pluck(stooges, 'name'); -// => ['moe', 'larry', 'curly'] -``` - -* * * - - - - - - -### `_.reduce(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2294 "View in source") [Ⓣ][1] - -Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. - -#### Aliases -*foldl, inject* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. -4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Mixed)*: Returns the accumulated value. - -#### Example -```js -var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); -// => 6 -``` - -* * * - - - - - - -### `_.reduceRight(collection, callback [, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2323 "View in source") [Ⓣ][1] - -The right-associative version of `_.reduce`. - -#### Aliases -*foldr* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[accumulator]` *(Mixed)*: Initial value of the accumulator. -4. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Mixed)*: Returns the accumulated value. - -#### Example -```js -var list = [[0, 1], [2, 3], [4, 5]]; -var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); -// => [4, 5, 2, 3, 0, 1] -``` - -* * * - - - - - - -### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2360 "View in source") [Ⓣ][1] - -The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array)*: Returns a new array of elements that did **not** pass the callback check. - -#### Example -```js -var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -// => [1, 3, 5] -``` - -* * * - - - - - - -### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] - -Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to shuffle. - -#### Returns -*(Array)*: Returns a new shuffled collection. - -#### Example -```js -_.shuffle([1, 2, 3, 4, 5, 6]); -// => [4, 1, 6, 3, 5, 2] -``` - -* * * - - - - - - -### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2413 "View in source") [Ⓣ][1] - -Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to inspect. - -#### Returns -*(Number)*: Returns `collection.length` or number of own enumerable properties. - -#### Example -```js -_.size([1, 2]); -// => 2 - -_.size({ 'one': 1, 'two': 2, 'three': 3 }); -// => 3 - -_.size('curly'); -// => 5 -``` - -* * * - - - - - - -### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2438 "View in source") [Ⓣ][1] - -Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. - -#### Aliases -*any* - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[callback=identity]` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Boolean)*: Returns `true` if any element passes the callback check, else `false`. - -#### Example -```js -_.some([null, 0, 'yes', false], Boolean); -// => true -``` - -* * * - - - - - - -### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2484 "View in source") [Ⓣ][1] - -Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `callback|property` *(Function|String)*: The function called per iteration or property name to sort by. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Array)*: Returns a new array of sorted elements. - -#### Example -```js -_.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); -// => [3, 1, 2] - -_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); -// => [3, 1, 2] - -_.sortBy(['larry', 'brendan', 'moe'], 'length'); -// => ['moe', 'larry', 'brendan'] -``` - -* * * - - - - - - -### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2516 "View in source") [Ⓣ][1] - -Converts the `collection`, to an array. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to convert. - -#### Returns -*(Array)*: Returns the new converted array. - -#### Example -```js -(function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); -// => [2, 3, 4] -``` - -* * * - - - - - - -### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2546 "View in source") [Ⓣ][1] - -Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. - -#### Arguments -1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `properties` *(Object)*: The object of property values to filter by. - -#### Returns -*(Array)*: Returns a new array of elements that contain the given `properties`. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -_.where(stooges, { 'age': 40 }); -// => [{ 'name': 'moe', 'age': 40 }] -``` - -* * * - - - - - - - - - -## `“Functions” Methods` - - - -### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3175 "View in source") [Ⓣ][1] - -Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. - -#### Arguments -1. `n` *(Number)*: The number of times the function must be called before it is executed. -2. `func` *(Function)*: The function to restrict. - -#### Returns -*(Function)*: Returns the new restricted function. - -#### Example -```js -var renderNotes = _.after(notes.length, render); -_.forEach(notes, function(note) { - note.asyncSave({ 'success': renderNotes }); -}); -// `renderNotes` is run once, after all notes have saved -``` - -* * * - - - - - - -### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3208 "View in source") [Ⓣ][1] - -Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. - -#### Arguments -1. `func` *(Function)*: The function to bind. -2. `[thisArg]` *(Mixed)*: The `this` binding of `func`. -3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. - -#### Returns -*(Function)*: Returns the new bound function. - -#### Example -```js -var func = function(greeting) { - return greeting + ' ' + this.name; -}; - -func = _.bind(func, { 'name': 'moe' }, 'hi'); -func(); -// => 'hi moe' -``` - -* * * - - - - - - -### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3238 "View in source") [Ⓣ][1] - -Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. - -#### Arguments -1. `object` *(Object)*: The object to bind and assign the bound methods to. -2. `[methodName1, methodName2, ...]` *(String)*: Method names on the object to bind. - -#### Returns -*(Object)*: Returns `object`. - -#### Example -```js -var buttonView = { - 'label': 'lodash', - 'onClick': function() { alert('clicked: ' + this.label); } -}; - -_.bindAll(buttonView); -jQuery('#lodash_button').on('click', buttonView.onClick); -// => When the button is clicked, `this.label` will have the correct value -``` - -* * * - - - - - - -### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] - -Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. - -#### Arguments -1. `object` *(Object)*: The object the method belongs to. -2. `key` *(String)*: The key of the method. -3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. - -#### Returns -*(Function)*: Returns the new bound function. - -#### Example -```js -var object = { - 'name': 'moe', - 'greet': function(greeting) { - return greeting + ' ' + this.name; - } -}; - -var func = _.bindKey(object, 'greet', 'hi'); -func(); -// => 'hi moe' - -object.greet = function(greeting) { - return greeting + ', ' + this.name + '!'; -}; - -func(); -// => 'hi, moe!' -``` - -* * * - - - - - - -### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] - -Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. - -#### Arguments -1. `[func1, func2, ...]` *(Function)*: Functions to compose. - -#### Returns -*(Function)*: Returns the new composed function. - -#### Example -```js -var greet = function(name) { return 'hi: ' + name; }; -var exclaim = function(statement) { return statement + '!'; }; -var welcome = _.compose(exclaim, greet); -welcome('moe'); -// => 'hi: moe!' -``` - -* * * - - - - - - -### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3340 "View in source") [Ⓣ][1] - -Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. - -#### Arguments -1. `func` *(Function)*: The function to debounce. -2. `wait` *(Number)*: The number of milliseconds to delay. -3. `immediate` *(Boolean)*: A flag to indicate execution is on the leading edge of the timeout. - -#### Returns -*(Function)*: Returns the new debounced function. - -#### Example -```js -var lazyLayout = _.debounce(calculateLayout, 300); -jQuery(window).on('resize', lazyLayout); -``` - -* * * - - - - - - -### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3404 "View in source") [Ⓣ][1] - -Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. - -#### Arguments -1. `func` *(Function)*: The function to defer. -2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. - -#### Returns -*(Number)*: Returns the `setTimeout` timeout id. - -#### Example -```js -_.defer(function() { alert('deferred'); }); -// returns from the function before `alert` is called -``` - -* * * - - - - - - -### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] - -Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. - -#### Arguments -1. `func` *(Function)*: The function to delay. -2. `wait` *(Number)*: The number of milliseconds to delay execution. -3. `[arg1, arg2, ...]` *(Mixed)*: Arguments to invoke the function with. - -#### Returns -*(Number)*: Returns the `setTimeout` timeout id. - -#### Example -```js -var log = _.bind(console.log, console); -_.delay(log, 1000, 'logged later'); -// => 'logged later' (Appears after one second.) -``` - -* * * - - - - - - -### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3428 "View in source") [Ⓣ][1] - -Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. - -#### Arguments -1. `func` *(Function)*: The function to have its output memoized. -2. `[resolver]` *(Function)*: A function used to resolve the cache key. - -#### Returns -*(Function)*: Returns the new memoizing function. - -#### Example -```js -var fibonacci = _.memoize(function(n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); -}); -``` - -* * * - - - - - - -### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3455 "View in source") [Ⓣ][1] - -Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. - -#### Arguments -1. `func` *(Function)*: The function to restrict. - -#### Returns -*(Function)*: Returns the new restricted function. - -#### Example -```js -var initialize = _.once(createApplication); -initialize(); -initialize(); -// Application is only created once. -``` - -* * * - - - - - - -### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] - -Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. - -#### Arguments -1. `func` *(Function)*: The function to partially apply arguments to. -2. `[arg1, arg2, ...]` *(Mixed)*: Arguments to be partially applied. - -#### Returns -*(Function)*: Returns the new partially applied function. - -#### Example -```js -var greet = function(greeting, name) { return greeting + ': ' + name; }; -var hi = _.partial(greet, 'hi'); -hi('moe'); -// => 'hi: moe' -``` - -* * * - - - - - - -### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3512 "View in source") [Ⓣ][1] - -Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. - -#### Arguments -1. `func` *(Function)*: The function to throttle. -2. `wait` *(Number)*: The number of milliseconds to throttle executions to. - -#### Returns -*(Function)*: Returns the new throttled function. - -#### Example -```js -var throttled = _.throttle(updatePosition, 100); -jQuery(window).on('scroll', throttled); -``` - -* * * - - - - - - -### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3564 "View in source") [Ⓣ][1] - -Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. - -#### Arguments -1. `value` *(Mixed)*: The value to wrap. -2. `wrapper` *(Function)*: The wrapper function. - -#### Returns -*(Function)*: Returns the new function. - -#### Example -```js -var hello = function(name) { return 'hello ' + name; }; -hello = _.wrap(hello, function(func) { - return 'before, ' + func('moe') + ', after'; -}); -hello(); -// => 'before, hello moe, after' -``` - -* * * - - - - - - - - - -## `“Objects” Methods` - - - -### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L719 "View in source") [Ⓣ][1] - -Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. - -#### Aliases -*extend* - -#### Arguments -1. `object` *(Object)*: The destination object. -2. `[source1, source2, ...]` *(Object)*: The source objects. - -#### Returns -*(Object)*: Returns the destination object. - -#### Example -```js -_.assign({ 'name': 'moe' }, { 'age': 40 }); -// => { 'name': 'moe', 'age': 40 } -``` - -* * * - - - - - - -### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L917 "View in source") [Ⓣ][1] - -Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned otherwise they will be assigned by reference. Functions, DOM nodes, `arguments` objects, and objects created by constructors other than `Object` are **not** cloned. - -#### Arguments -1. `value` *(Mixed)*: The value to clone. -2. `deep` *(Boolean)*: A flag to indicate a deep clone. - -#### Returns -*(Mixed)*: Returns the cloned `value`. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -_.clone({ 'name': 'moe' }); -// => { 'name': 'moe' } - -var shallow = _.clone(stooges); -shallow[0] === stooges[0]; -// => true - -var deep = _.clone(stooges, true); -shallow[0] === stooges[0]; -// => false -``` - -* * * - - - - - - -### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1000 "View in source") [Ⓣ][1] - -Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. - -#### Arguments -1. `object` *(Object)*: The destination object. -2. `[default1, default2, ...]` *(Object)*: The default objects. - -#### Returns -*(Object)*: Returns the destination object. - -#### Example -```js -var iceCream = { 'flavor': 'chocolate' }; -_.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); -// => { 'flavor': 'chocolate', 'sprinkles': 'rainbow' } -``` - -* * * - - - - - - -### `_.forIn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L775 "View in source") [Ⓣ][1] - -Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. - -#### Arguments -1. `object` *(Object)*: The object to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns `object`. - -#### Example -```js -function Dog(name) { - this.name = name; -} - -Dog.prototype.bark = function() { - alert('Woof, woof!'); -}; - -_.forIn(new Dog('Dagny'), function(value, key) { - alert(key); -}); -// => alerts 'name' and 'bark' (order is not guaranteed) -``` - -* * * - - - - - - -### `_.forOwn(object, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L799 "View in source") [Ⓣ][1] - -Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. - -#### Arguments -1. `object` *(Object)*: The object to iterate over. -2. `callback` *(Function)*: The function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns `object`. - -#### Example -```js -_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - alert(key); -}); -// => alerts '0', '1', and 'length' (order is not guaranteed) -``` - -* * * - - - - - - -### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1019 "View in source") [Ⓣ][1] - -Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. - -#### Aliases -*methods* - -#### Arguments -1. `object` *(Object)*: The object to inspect. - -#### Returns -*(Array)*: Returns a new array of property names that have function values. - -#### Example -```js -_.functions(_); -// => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...] -``` - -* * * - - - - - - -### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1044 "View in source") [Ⓣ][1] - -Checks if the specified object `property` exists and is a direct property, instead of an inherited property. - -#### Arguments -1. `object` *(Object)*: The object to check. -2. `property` *(String)*: The property to check for. - -#### Returns -*(Boolean)*: Returns `true` if key is a direct property, else `false`. - -#### Example -```js -_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); -// => true -``` - -* * * - - - - - - -### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1061 "View in source") [Ⓣ][1] - -Creates an object composed of the inverted keys and values of the given `object`. - -#### Arguments -1. `object` *(Object)*: The object to invert. - -#### Returns -*(Object)*: Returns the created inverted object. - -#### Example -```js -_.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); -// => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed) -``` - -* * * - - - - - - -### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L737 "View in source") [Ⓣ][1] - -Checks if `value` is an `arguments` object. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is an `arguments` object, else `false`. - -#### Example -```js -(function() { return _.isArguments(arguments); })(1, 2, 3); -// => true - -_.isArguments([1, 2, 3]); -// => false -``` - -* * * - - - - - - -### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1085 "View in source") [Ⓣ][1] - -Checks if `value` is an array. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is an array, else `false`. - -#### Example -```js -(function() { return _.isArray(arguments); })(); -// => false - -_.isArray([1, 2, 3]); -// => true -``` - -* * * - - - - - - -### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1102 "View in source") [Ⓣ][1] - -Checks if `value` is a boolean *(`true` or `false`)* value. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a boolean value, else `false`. - -#### Example -```js -_.isBoolean(null); -// => false -``` - -* * * - - - - - - -### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1119 "View in source") [Ⓣ][1] - -Checks if `value` is a date. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a date, else `false`. - -#### Example -```js -_.isDate(new Date); -// => true -``` - -* * * - - - - - - -### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1136 "View in source") [Ⓣ][1] - -Checks if `value` is a DOM element. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a DOM element, else `false`. - -#### Example -```js -_.isElement(document.body); -// => true -``` - -* * * - - - - - - -### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1161 "View in source") [Ⓣ][1] - -Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". - -#### Arguments -1. `value` *(Array|Object|String)*: The value to inspect. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is empty, else `false`. - -#### Example -```js -_.isEmpty([1, 2, 3]); -// => false - -_.isEmpty({}); -// => true - -_.isEmpty(''); -// => true -``` - -* * * - - - - - - -### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1203 "View in source") [Ⓣ][1] - -Performs a deep comparison between two values to determine if they are equivalent to each other. - -#### Arguments -1. `a` *(Mixed)*: The value to compare. -2. `b` *(Mixed)*: The other value to compare. - -#### Returns -*(Boolean)*: Returns `true` if the values are equvalent, else `false`. - -#### Example -```js -var moe = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; -var clone = { 'name': 'moe', 'luckyNumbers': [13, 27, 34] }; - -moe == clone; -// => false - -_.isEqual(moe, clone); -// => true -``` - -* * * - - - - - - -### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1365 "View in source") [Ⓣ][1] - -Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a finite number, else `false`. - -#### Example -```js -_.isFinite(-101); -// => true - -_.isFinite('10'); -// => true - -_.isFinite(true); -// => false - -_.isFinite(''); -// => false - -_.isFinite(Infinity); -// => false -``` - -* * * - - - - - - -### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1382 "View in source") [Ⓣ][1] - -Checks if `value` is a function. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a function, else `false`. - -#### Example -```js -_.isFunction(_); -// => true -``` - -* * * - - - - - - -### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1446 "View in source") [Ⓣ][1] - -Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return true for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is `NaN`, else `false`. - -#### Example -```js -_.isNaN(NaN); -// => true - -_.isNaN(new Number(NaN)); -// => true - -isNaN(undefined); -// => true - -_.isNaN(undefined); -// => false -``` - -* * * - - - - - - -### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1469 "View in source") [Ⓣ][1] - -Checks if `value` is `null`. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is `null`, else `false`. - -#### Example -```js -_.isNull(null); -// => true - -_.isNull(undefined); -// => false -``` - -* * * - - - - - - -### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1486 "View in source") [Ⓣ][1] - -Checks if `value` is a number. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a number, else `false`. - -#### Example -```js -_.isNumber(8.4 * 5); -// => true -``` - -* * * - - - - - - -### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1412 "View in source") [Ⓣ][1] - -Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is an object, else `false`. - -#### Example -```js -_.isObject({}); -// => true - -_.isObject([1, 2, 3]); -// => true - -_.isObject(1); -// => false -``` - -* * * - - - - - - -### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1514 "View in source") [Ⓣ][1] - -Checks if a given `value` is an object created by the `Object` constructor. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if `value` is a plain object, else `false`. - -#### Example -```js -function Stooge(name, age) { - this.name = name; - this.age = age; -} - -_.isPlainObject(new Stooge('moe', 40)); -// => false - -_.isPlainObject([1, 2, 3]); -// => false - -_.isPlainObject({ 'name': 'moe', 'age': 40 }); -// => true -``` - -* * * - - - - - - -### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1539 "View in source") [Ⓣ][1] - -Checks if `value` is a regular expression. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a regular expression, else `false`. - -#### Example -```js -_.isRegExp(/moe/); -// => true -``` - -* * * - - - - - - -### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1556 "View in source") [Ⓣ][1] - -Checks if `value` is a string. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is a string, else `false`. - -#### Example -```js -_.isString('moe'); -// => true -``` - -* * * - - - - - - -### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1574 "View in source") [Ⓣ][1] - -Checks if `value` is `undefined`. - -#### Arguments -1. `value` *(Mixed)*: The value to check. - -#### Returns -*(Boolean)*: Returns `true` if the `value` is `undefined`, else `false`. - -#### Example -```js -_.isUndefined(void 0); -// => true -``` - -* * * - - - - - - -### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1591 "View in source") [Ⓣ][1] - -Creates an array composed of the own enumerable property names of `object`. - -#### Arguments -1. `object` *(Object)*: The object to inspect. - -#### Returns -*(Array)*: Returns a new array of property names. - -#### Example -```js -_.keys({ 'one': 1, 'two': 2, 'three': 3 }); -// => ['one', 'two', 'three'] (order is not guaranteed) -``` - -* * * - - - - - - -### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1629 "View in source") [Ⓣ][1] - -Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. - -#### Arguments -1. `object` *(Object)*: The destination object. -2. `[source1, source2, ...]` *(Object)*: The source objects. - -#### Returns -*(Object)*: Returns the destination object. - -#### Example -```js -var stooges = [ - { 'name': 'moe' }, - { 'name': 'larry' } -]; - -var ages = [ - { 'age': 40 }, - { 'age': 50 } -]; - -_.merge(stooges, ages); -// => [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] -``` - -* * * - - - - - - -### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1703 "View in source") [Ⓣ][1] - -Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. - -#### Arguments -1. `object` *(Object)*: The source object. -2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to omit or the function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns an object without the omitted properties. - -#### Example -```js -_.omit({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'userid'); -// => { 'name': 'moe', 'age': 40 } - -_.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { - return key.charAt(0) == '_'; -}); -// => { 'name': 'moe' } -``` - -* * * - - - - - - -### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1737 "View in source") [Ⓣ][1] - -Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. - -#### Arguments -1. `object` *(Object)*: The object to inspect. - -#### Returns -*(Array)*: Returns new array of key-value pairs. - -#### Example -```js -_.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); -// => [['moe', 30], ['larry', 40], ['curly', 50]] (order is not guaranteed) -``` - -* * * - - - - - - -### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1770 "View in source") [Ⓣ][1] - -Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. - -#### Arguments -1. `object` *(Object)*: The source object. -2. `callback|[prop1, prop2, ...]` *(Function|String)*: The properties to pick or the function called per iteration. -3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. - -#### Returns -*(Object)*: Returns an object composed of the picked properties. - -#### Example -```js -_.pick({ 'name': 'moe', 'age': 40, 'userid': 'moe1' }, 'name', 'age'); -// => { 'name': 'moe', 'age': 40 } - -_.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(value, key) { - return key.charAt(0) != '_'; -}); -// => { 'name': 'moe' } -``` - -* * * - - - - - - -### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1807 "View in source") [Ⓣ][1] - -Creates an array composed of the own enumerable property values of `object`. - -#### Arguments -1. `object` *(Object)*: The object to inspect. - -#### Returns -*(Array)*: Returns a new array of property values. - -#### Example -```js -_.values({ 'one': 1, 'two': 2, 'three': 3 }); -// => [1, 2, 3] -``` - -* * * - - - - - - - - - -## `“Utilities” Methods` - - - -### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3588 "View in source") [Ⓣ][1] - -Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. - -#### Arguments -1. `string` *(String)*: The string to escape. - -#### Returns -*(String)*: Returns the escaped string. - -#### Example -```js -_.escape('Moe, Larry & Curly'); -// => "Moe, Larry & Curly" -``` - -* * * - - - - - - -### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3608 "View in source") [Ⓣ][1] - -This function returns the first argument passed to it. Note: It is used throughout Lo-Dash as a default callback. - -#### Arguments -1. `value` *(Mixed)*: Any value. - -#### Returns -*(Mixed)*: Returns `value`. - -#### Example -```js -var moe = { 'name': 'moe' }; -moe === _.identity(moe); -// => true -``` - -* * * - - - - - - -### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3634 "View in source") [Ⓣ][1] - -Adds functions properties of `object` to the `lodash` function and chainable wrapper. - -#### Arguments -1. `object` *(Object)*: The object of function properties to add to `lodash`. - -#### Example -```js -_.mixin({ - 'capitalize': function(string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } -}); - -_.capitalize('larry'); -// => 'Larry' - -_('curly').capitalize(); -// => 'Curly' -``` - -* * * - - - - - - -### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3664 "View in source") [Ⓣ][1] - -Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. - -#### Returns -*(Function)*: Returns the `lodash` function. - -#### Example -```js -var lodash = _.noConflict(); -``` - -* * * - - - - - - -### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3687 "View in source") [Ⓣ][1] - -Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. - -#### Arguments -1. `[min=0]` *(Number)*: The minimum possible value. -2. `[max=1]` *(Number)*: The maximum possible value. - -#### Returns -*(Number)*: Returns a random number. - -#### Example -```js -_.random(0, 5); -// => a number between 1 and 5 - -_.random(5); -// => also a number between 1 and 5 -``` - -* * * - - - - - - -### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3726 "View in source") [Ⓣ][1] - -Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. - -#### Arguments -1. `object` *(Object)*: The object to inspect. -2. `property` *(String)*: The property to get the value of. - -#### Returns -*(Mixed)*: Returns the resolved value. - -#### Example -```js -var object = { - 'cheese': 'crumpets', - 'stuff': function() { - return 'nonsense'; - } -}; - -_.result(object, 'cheese'); -// => 'crumpets' - -_.result(object, 'stuff'); -// => 'nonsense' -``` - -* * * - - - - - - -### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3811 "View in source") [Ⓣ][1] - -A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html - -#### Arguments -1. `text` *(String)*: The template text. -2. `data` *(Obect)*: The data object used to populate the text. -3. `options` *(Object)*: The options object. escape - The "escape" delimiter regexp. evaluate - The "evaluate" delimiter regexp. interpolate - The "interpolate" delimiter regexp. sourceURL - The sourceURL of the template's compiled source. variable - The data object variable name. - -#### Returns -*(Function, String)*: Returns a compiled function when no `data` object is given, else it returns the interpolated text. - -#### Example -```js -// using a compiled template -var compiled = _.template('hello <%= name %>'); -compiled({ 'name': 'moe' }); -// => 'hello moe' - -var list = '<% _.forEach(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; -_.template(list, { 'people': ['moe', 'larry', 'curly'] }); -// => '
  • moe
  • larry
  • curly
  • ' - -// using the "escape" delimiter to escape HTML in data property values -_.template('<%- value %>', { 'value': '\n```\n\nUsing [`npm`](http://npmjs.org/):\n\n```bash\nnpm install lodash\n\nnpm install -g lodash\nnpm link lodash\n```\n\nTo avoid potential issues, update `npm` before installing Lo-Dash:\n\n```bash\nnpm install npm -g\n```\n\nIn [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/):\n\n```js\nvar _ = require('lodash');\n```\n\n**Note:** If Lo-Dash is installed globally, [run `npm link lodash`](http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/) in your project’s root directory before requiring it.\n\nIn [RingoJS v0.7.0-](http://ringojs.org/):\n\n```js\nvar _ = require('lodash')._;\n```\n\nIn [Rhino](http://www.mozilla.org/rhino/):\n\n```js\nload('lodash.js');\n```\n\nIn an AMD loader like [RequireJS](http://requirejs.org/):\n\n```js\nrequire({\n 'paths': {\n 'underscore': 'path/to/lodash'\n }\n},\n['underscore'], function(_) {\n console.log(_.VERSION);\n});\n```\n\n## Resolved Underscore.js issues\n\n * Allow iteration of objects with a `length` property [[#799](https://github.com/documentcloud/underscore/pull/799), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L590-L596)]\n * Fix cross-browser object iteration bugs [[#60](https://github.com/documentcloud/underscore/issues/60), [#376](https://github.com/documentcloud/underscore/issues/376), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L603-L627)]\n * Methods should work on pages with incorrectly shimmed native methods [[#7](https://github.com/documentcloud/underscore/issues/7), [#742](https://github.com/documentcloud/underscore/issues/742), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L140-L146)]\n * `_.isEmpty` should support jQuery/MooTools DOM query collections [[#690](https://github.com/documentcloud/underscore/pull/690), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L792-L797)]\n * `_.isObject` should avoid V8 bug [#2291](http://code.google.com/p/v8/issues/detail?id=2291) [[#605](https://github.com/documentcloud/underscore/issues/605), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L873-L885)]\n * `_.keys` should work with `arguments` objects cross-browser [[#396](https://github.com/documentcloud/underscore/issues/396), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L966-L968)]\n * `_.range` should coerce arguments to numbers [[#634](https://github.com/documentcloud/underscore/issues/634), [#683](https://github.com/documentcloud/underscore/issues/683), [test](https://github.com/bestiejs/lodash/blob/v0.10.0/test/test.js#L1367-L1370)]\n\n## Release Notes\n\n### v0.10.0\n\n#### Compatibility Warnings ####\n\n * Aligned `_.defaults` and `_.extend` with ES6 [Object.assign](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.2.3.15)\n * Renamed `_.lateBind` to `_.bindKey`\n\n#### Changes ####\n\n * Added the build commands used to custom build copyright/license headers\n * Added `_.assign`\n * Ensured the `underscore` build of `_.find` returns the first, not last, matched value\n * Ensured `_defaults`, `_.extends`, and `_.merge` works with `_.reduce`\n * Made Lo-Dash’s `npm` package installation work with more system configurations\n * Made `_.extend` an alias of `_.assign`\n * Optimized `_.contains`, `_.defaults`, `_.extend`, and `_.filter`\n * Restricted `_.where` to iterate only own properties of the `source` object\n * Updated `backbone` build Lo-Dash method dependencies\n\nThe full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog).\n\n## BestieJS\n\nLo-Dash is part of the BestieJS *“Best in Class”* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.\n\n## Author\n\n* [John-David Dalton](http://allyoucanleet.com/)\n [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton \"Follow @jdalton on Twitter\")\n\n## Contributors\n\n* [Kit Cambridge](http://kitcambridge.github.com/)\n [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge \"Follow @kitcambridge on Twitter\")\n* [Mathias Bynens](http://mathiasbynens.be/)\n [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias \"Follow @mathias on Twitter\")\n", - "readmeFilename": "README.md", - "_id": "lodash@0.10.0", - "_from": "lodash@~0.10.0" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/perf/perf.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/perf/perf.js deleted file mode 100644 index e0d4efd..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/perf/perf.js +++ /dev/null @@ -1,1780 +0,0 @@ -(function(window) { - - /** Use a single load function */ - var load = typeof require == 'function' ? require : window.load; - - /** Load Benchmark.js */ - var Benchmark = - window.Benchmark || ( - Benchmark = load('../vendor/benchmark.js/benchmark.js') || window.Benchmark, - Benchmark.Benchmark || Benchmark - ); - - /** Load Lo-Dash */ - var lodash = - window.lodash || ( - lodash = load('../lodash.js') || window._, - lodash = lodash._ || lodash, - lodash.noConflict() - ); - - /** Load Underscore */ - var _ = - window._ || ( - _ = load('../vendor/underscore/underscore.js') || window._, - _._ || _ - ); - - /** Used to access the Firebug Lite panel (set by `run`) */ - var fbPanel; - - /** Used to score performance */ - var score = { 'a': 0, 'b': 0 }; - - /** Used to queue benchmark suites */ - var suites = []; - - /** The `ui` object */ - var ui = window.ui || {}; - - /** The Lo-Dash build basename */ - var buildName = basename(ui.buildPath || 'lodash', '.js'); - - /** The other library basename */ - var otherName = basename(ui.otherPath || 'underscore', '.js'); - - /** Add `console.log()` support for Narwhal and RingoJS */ - window.console || (window.console = { 'log': window.print }); - - /** Expose functions to the global object */ - window._ = _; - window.Benchmark = Benchmark; - window.lodash = lodash; - - /*--------------------------------------------------------------------------*/ - - /** - * Gets the basename of the given `filePath`. If the file `extension` is passed, - * it will be removed from the basename. - * - * @private - * @param {String} path The file path to inspect. - * @param {String} extension The extension to remove. - * @returns {String} Returns the basename. - */ - function basename(filePath, extension) { - var result = (filePath || '').split(/[\\/]/).pop(); - return arguments.length < 2 - ? result - : result.replace(RegExp(extension.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&') + '$'), ''); - } - - /** - * Gets the Hz, i.e. operations per second, of `bench` adjusted for the - * margin of error. - * - * @private - * @param {Object} bench The benchmark object. - * @returns {Number} Returns the adjusted Hz. - */ - function getHz(bench) { - return 1 / (bench.stats.mean + bench.stats.moe); - } - - /** - * Logs text to the console. - * - * @private - * @param {String} text The text to log. - */ - function log(text) { - console.log(text + ''); - if (fbPanel) { - // scroll the Firebug Lite panel down - fbPanel.scrollTop = fbPanel.scrollHeight; - } - } - - /** - * Runs all benchmark suites. - * - * @private (@public in the browser) - */ - function run() { - fbPanel = (fbPanel = window.document && document.getElementById('FirebugUI')) && - (fbPanel = (fbPanel = fbPanel.contentWindow || fbPanel.contentDocument).document || fbPanel) && - fbPanel.getElementById('fbPanel1'); - - log('\nSit back and relax, this may take a while.'); - suites[0].run(); - } - - /*--------------------------------------------------------------------------*/ - - lodash.extend(Benchmark.Suite.options, { - 'onStart': function() { - log('\n' + this.name + ':'); - }, - 'onCycle': function(event) { - log(event.target); - }, - 'onComplete': function() { - var formatNumber = Benchmark.formatNumber, - fastest = this.filter('fastest'), - fastestHz = getHz(fastest[0]), - slowest = this.filter('slowest'), - slowestHz = getHz(slowest[0]), - aHz = getHz(this[0]), - bHz = getHz(this[1]); - - if (fastest.length > 1) { - log('It\'s too close to call.'); - aHz = bHz = slowestHz; - } - else { - var percent = ((fastestHz / slowestHz) - 1) * 100; - - log( - fastest[0].name + ' is ' + - formatNumber(percent < 1 ? percent.toFixed(2) : Math.round(percent)) + - '% faster.' - ); - } - // add score adjusted for margin of error - score.a += aHz; - score.b += bHz; - - // remove current suite from queue - suites.shift(); - - if (suites.length) { - // run next suite - suites[0].run(); - } - else { - var fastestTotalHz = Math.max(score.a, score.b), - slowestTotalHz = Math.min(score.a, score.b), - totalPercent = formatNumber(Math.round(((fastestTotalHz / slowestTotalHz) - 1) * 100)), - totalX = fastestTotalHz / slowestTotalHz, - message = 'is ' + totalPercent + '% ' + (totalX == 1 ? '' : '(' + formatNumber(totalX.toFixed(2)) + 'x) ') + 'faster than'; - - // report results - if (score.a >= score.b) { - log('\n' + buildName + ' ' + message + ' ' + otherName + '.'); - } else { - log('\n' + otherName + ' ' + message + ' ' + buildName + '.'); - } - } - } - }); - - /*--------------------------------------------------------------------------*/ - - lodash.extend(Benchmark.options, { - 'async': true, - 'setup': '\ - var window = Function("return this || global")(),\ - _ = window._,\ - lodash = window.lodash,\ - belt = this.name == "Lo-Dash" ? lodash : _;\ - \ - var index,\ - date = new Date,\ - limit = 20,\ - regexp = /x/,\ - object = {},\ - objects = Array(limit),\ - numbers = Array(limit),\ - fourNumbers = [5, 25, 10, 30],\ - nestedNumbers = [1, [2], [3, [[4]]]],\ - twoNumbers = [12, 21];\ - \ - for (index = 0; index < limit; index++) {\ - numbers[index] = index;\ - object["key" + index] = index;\ - objects[index] = { "num": index };\ - }\ - \ - if (typeof bind != "undefined") {\ - var contextObject = { "name": "moe" },\ - ctor = function() {};\ - \ - var func = function(greeting, punctuation) {\ - return greeting + ", " + this.name + (punctuation || ".");\ - };\ - \ - var lodashBoundNormal = lodash.bind(func, contextObject),\ - lodashBoundCtor = lodash.bind(ctor, contextObject),\ - lodashBoundPartial = lodash.bind(func, contextObject, "hi");\ - \ - var _boundNormal = _.bind(func, contextObject),\ - _boundCtor = _.bind(ctor, contextObject),\ - _boundPartial = _.bind(func, contextObject, "hi");\ - }\ - \ - if (typeof bindAll != "undefined") {\ - var bindAllObjects = Array(this.count),\ - funcNames = belt.functions(lodash);\ - \ - // potentially expensive\n\ - for (index = 0; index < this.count; index++) {\ - bindAllObjects[index] = belt.reduce(funcNames, function(object, funcName) {\ - object[funcName] = lodash[funcName];\ - return object;\ - }, {});\ - }\ - }\ - if (typeof compact != "undefined") {\ - var uncompacted = numbers.slice();\ - uncompacted[2] = false;\ - uncompacted[6] = null;\ - uncompacted[18] = "";\ - }\ - \ - if (typeof countBy != "undefined" || typeof omit != "undefined") {\ - var wordToNumber = {\ - "one": 1,\ - "two": 2,\ - "three": 3,\ - "four": 4,\ - "five": 5,\ - "six": 6,\ - "seven": 7,\ - "eight": 8,\ - "nine": 9,\ - "ten": 10,\ - "eleven": 11,\ - "twelve": 12,\ - "thirteen": 13,\ - "fourteen": 14,\ - "fifteen": 15,\ - "sixteen": 16,\ - "seventeen": 17,\ - "eighteen": 18,\ - "nineteen": 19,\ - "twenty": 20,\ - "twenty-one": 21,\ - "twenty-two": 22,\ - "twenty-three": 23,\ - "twenty-four": 24,\ - "twenty-five": 25,\ - "twenty-six": 26,\ - "twenty-seven": 27,\ - "twenty-eight": 28,\ - "twenty-nine": 29,\ - "thirty": 30,\ - "thirty-one": 31,\ - "thirty-two": 32,\ - "thirty-three": 33,\ - "thirty-four": 34,\ - "thirty-five": 35,\ - "thirty-six": 36,\ - "thirty-seven": 37,\ - "thirty-eight": 38,\ - "thirty-nine": 39,\ - "forty": 40\ - };\ - \ - var words = belt.keys(wordToNumber).slice(0, limit);\ - }\ - \ - if (typeof isEqual != "undefined") {\ - var objectOfPrimitives = {\ - "boolean": true,\ - "number": 1,\ - "string": "a"\ - };\ - \ - var objectOfObjects = {\ - "boolean": new Boolean(true),\ - "number": new Number(1),\ - "string": new String("a")\ - };\ - \ - var object2 = {},\ - objects2 = Array(limit),\ - numbers2 = Array(limit),\ - nestedNumbers2 = [1, [2], [3, [[4]]]];\ - \ - for (index = 0; index < limit; index++) {\ - numbers2[index] = index;\ - object2["key" + index] = index;\ - objects2[index] = { "num": index };\ - }\ - }\ - \ - if (typeof multiArrays != "undefined") {\ - var twentyFiveValues = Array(25),\ - twentyFiveValues2 = Array(25),\ - fiftyValues = Array(50),\ - seventyFiveValues = Array(75),\ - seventyFiveValues2 = Array(75),\ - lowerChars = "abcdefghijklmnopqrstuvwxyz".split(""),\ - upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");\ - \ - for (index = 0; index < 75; index++) {\ - if (index < 26) {\ - if (index < 20) {\ - twentyFiveValues[index] = lowerChars[index];\ - twentyFiveValues2[index] = upperChars[index];\ - }\ - else if (index < 25) {\ - twentyFiveValues[index] =\ - twentyFiveValues2[index] = index;\ - }\ - fiftyValues[index] =\ - seventyFiveValues[index] = lowerChars[index];\ - seventyFiveValues2[index] = upperChars[index];\ - }\ - else {\ - if (index < 50) {\ - fiftyValues[index] = index;\ - }\ - seventyFiveValues[index] = index;\ - seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);\ - }\ - }\ - }\ - \ - if (typeof template != "undefined") {\ - var tplData = {\ - "header1": "Header1",\ - "header2": "Header2",\ - "header3": "Header3",\ - "header4": "Header4",\ - "header5": "Header5",\ - "header6": "Header6",\ - "list": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]\ - };\ - \ - var tplBase =\ - "
    " +\ - "

    <%= header1 %>

    " +\ - "

    <%= header2 %>

    " +\ - "

    <%= header3 %>

    " +\ - "

    <%= header4 %>

    " +\ - "
    <%= header5 %>
    " +\ - "
    <%= header6 %>
    ";\ - \ - var tpl =\ - tplBase +\ - "
      " +\ - "
    • <%= list[0] %>
    • " +\ - "
    • <%= list[1] %>
    • " +\ - "
    • <%= list[2] %>
    • " +\ - "
    • <%= list[3] %>
    • " +\ - "
    • <%= list[4] %>
    • " +\ - "
    • <%= list[5] %>
    • " +\ - "
    • <%= list[6] %>
    • " +\ - "
    • <%= list[7] %>
    • " +\ - "
    • <%= list[8] %>
    • " +\ - "
    • <%= list[9] %>
    • " +\ - "
    " +\ - "
    ";\ - \ - var tplWithEvaluate =\ - tplBase +\ - "
      " +\ - "<% for (var index = 0, length = list.length; index < length; index++) { %>" +\ - "
    • <%= list[index] %>
    • " +\ - "<% } %>" +\ - "
    " +\ - "
    ";\ - \ - var tplBaseVerbose =\ - "
    " +\ - "

    <%= data.header1 %>

    " +\ - "

    <%= data.header2 %>

    " +\ - "

    <%= data.header3 %>

    " +\ - "

    <%= data.header4 %>

    " +\ - "
    <%= data.header5 %>
    " +\ - "
    <%= data.header6 %>
    ";\ - \ - var tplVerbose =\ - tplBaseVerbose +\ - "" +\ - "
    ";\ - \ - var tplVerboseWithEvaluate =\ - tplBaseVerbose +\ - "" +\ - "";\ - \ - var settingsObject = { "variable": "data" };\ - \ - var lodashTpl = lodash.template(tpl),\ - lodashTplWithEvaluate = lodash.template(tplWithEvaluate),\ - lodashTplVerbose = lodash.template(tplVerbose, null, settingsObject),\ - lodashTplVerboseWithEvaluate = lodash.template(tplVerboseWithEvaluate, null, settingsObject);\ - \ - var _tpl = _.template(tpl),\ - _tplWithEvaluate = _.template(tplWithEvaluate),\ - _tplVerbose = _.template(tplVerbose, null, settingsObject),\ - _tplVerboseWithEvaluate = _.template(tplVerboseWithEvaluate, null, settingsObject);\ - }' - }); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.bind` (uses native `Function#bind` if available and inferred fast)') - .add(buildName, { - 'fn': 'lodash.bind(func, { "name": "moe" }, "hi")', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_.bind(func, { "name": "moe" }, "hi")', - 'teardown': 'function bind(){}' - }) - ); - - suites.push( - Benchmark.Suite('bound call') - .add(buildName, { - 'fn': 'lodashBoundNormal()', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundNormal()', - 'teardown': 'function bind(){}' - }) - ); - - suites.push( - Benchmark.Suite('bound call with arguments') - .add(buildName, { - 'fn': 'lodashBoundNormal("hi", "!")', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundNormal("hi", "!")', - 'teardown': 'function bind(){}' - }) - ); - - suites.push( - Benchmark.Suite('bound and partially applied call (uses native `Function#bind` if available)') - .add(buildName, { - 'fn': 'lodashBoundPartial()', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundPartial()', - 'teardown': 'function bind(){}' - }) - ); - - suites.push( - Benchmark.Suite('bound and partially applied call with arguments (uses native `Function#bind` if available)') - .add(buildName, { - 'fn': 'lodashBoundPartial("!")', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundPartial("!")', - 'teardown': 'function bind(){}' - }) - ); - - suites.push( - Benchmark.Suite('bound and called in a `new` expression, i.e. `new bound` (edge case)') - .add(buildName, { - 'fn': 'new lodashBoundCtor()', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': 'new _boundCtor()', - 'teardown': 'function bind(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.bindAll` iterating arguments') - .add(buildName, { - 'fn': 'lodash.bindAll.apply(lodash, [bindAllObjects.pop()].concat(funcNames))', - 'teardown': 'function bindAll(){}' - }) - .add(otherName, { - 'fn': '_.bindAll.apply(_, [bindAllObjects.pop()].concat(funcNames))', - 'teardown': 'function bindAll(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.bindAll` iterating the `object`') - .add(buildName, { - 'fn': 'lodash.bindAll(bindAllObjects.pop())', - 'teardown': 'function bindAll(){}' - }) - .add(otherName, { - 'fn': '_.bindAll(bindAllObjects.pop())', - 'teardown': 'function bindAll(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.clone` with an object') - .add(buildName, '\ - lodash.clone(object)' - ) - .add(otherName, '\ - _.clone(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.compact`') - .add(buildName, { - 'fn': 'lodash.compact(uncompacted)', - 'teardown': 'function compact(){}' - }) - .add(otherName, { - 'fn': '_.compact(uncompacted)', - 'teardown': 'function compact(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.contains` iterating an array') - .add(buildName, '\ - lodash.contains(numbers, 19)' - ) - .add(otherName, '\ - _.contains(numbers, 19)' - ) - ); - - suites.push( - Benchmark.Suite('`_.contains` iterating an object') - .add(buildName, '\ - lodash.contains(object, 19)' - ) - .add(otherName, '\ - _.contains(object, 19)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.countBy` with `callback` iterating an array') - .add(buildName, '\ - lodash.countBy(numbers, function(num) { return num >> 1; })' - ) - .add(otherName, '\ - _.countBy(numbers, function(num) { return num >> 1; })' - ) - ); - - suites.push( - Benchmark.Suite('`_.countBy` with `property` name iterating an array') - .add(buildName, { - 'fn': 'lodash.countBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '_.countBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.countBy` with `callback` iterating an object') - .add(buildName, { - 'fn': 'lodash.countBy(wordToNumber, function(num) { return num >> 1; })', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '_.countBy(wordToNumber, function(num) { return num >> 1; })', - 'teardown': 'function countBy(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.defaults`') - .add(buildName, '\ - lodash.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)' - ) - .add(otherName, '\ - _.defaults({ "key2": 2, "key6": 6, "key18": 18 }, object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.difference`') - .add(buildName, '\ - lodash.difference(numbers, fourNumbers, twoNumbers)' - ) - .add(otherName, '\ - _.difference(numbers, fourNumbers, twoNumbers)' - ) - ); - - suites.push( - Benchmark.Suite('`_.difference` iterating 25 elements') - .add(buildName, { - 'fn': 'lodash.difference(twentyFiveValues, twentyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.difference(twentyFiveValues, twentyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.difference` iterating 50 and 75 elements') - .add(buildName, { - 'fn': 'lodash.difference(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.difference(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.difference` iterating 75 elements') - .add(buildName, { - 'fn': 'lodash.difference(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.difference(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.each` iterating an array') - .add(buildName, '\ - var result = [];\ - lodash.each(numbers, function(num) {\ - result.push(num * 2);\ - })' - ) - .add(otherName, '\ - var result = [];\ - _.each(numbers, function(num) {\ - result.push(num * 2);\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.each` iterating an array with `thisArg` (slow path)') - .add(buildName, '\ - var result = [];\ - lodash.each(numbers, function(num, index) {\ - result.push(num + this["key" + index]);\ - }, object)' - ) - .add(otherName, '\ - var result = [];\ - _.each(numbers, function(num, index) {\ - result.push(num + this["key" + index]);\ - }, object)' - ) - ); - - suites.push( - Benchmark.Suite('`_.each` iterating an object') - .add(buildName, '\ - var result = [];\ - lodash.each(object, function(num) {\ - result.push(num * 2);\ - })' - ) - .add(otherName, '\ - var result = [];\ - _.each(object, function(num) {\ - result.push(num * 2);\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.every` iterating an array') - .add(buildName, '\ - lodash.every(numbers, function(num) {\ - return num + "";\ - })' - ) - .add(otherName, '\ - _.every(numbers, function(num) {\ - return num + "";\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.every` iterating an object') - .add(buildName, '\ - lodash.every(object, function(num) {\ - return num + "";\ - })' - ) - .add(otherName, '\ - _.every(object, function(num) {\ - return num + "";\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.extend`') - .add(buildName, '\ - lodash.extend({}, object)' - ) - .add(otherName, '\ - _.extend({}, object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.filter` iterating an array') - .add(buildName, '\ - lodash.filter(numbers, function(num) {\ - return num % 2;\ - })' - ) - .add(otherName, '\ - _.filter(numbers, function(num) {\ - return num % 2;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.filter` iterating an array with `thisArg` (slow path)') - .add(buildName, '\ - lodash.filter(numbers, function(num, index) {\ - return this["key" + index] % 2;\ - }, object)' - ) - .add(otherName, '\ - _.filter(numbers, function(num, index) {\ - return this["key" + index] % 2;\ - }, object)' - ) - ); - - suites.push( - Benchmark.Suite('`_.filter` iterating an object') - .add(buildName, '\ - lodash.filter(object, function(num) {\ - return num % 2\ - })' - ) - .add(otherName, '\ - _.filter(object, function(num) {\ - return num % 2\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.find` iterating an array') - .add(buildName, '\ - lodash.find(numbers, function(num) {\ - return num === 19;\ - })' - ) - .add(otherName, '\ - _.find(numbers, function(num) {\ - return num === 19;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.find` iterating an object') - .add(buildName, '\ - lodash.find(object, function(value, key) {\ - return /\D9$/.test(key);\ - })' - ) - .add(otherName, '\ - _.find(object, function(value, key) {\ - return /\D9$/.test(key);\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.flatten`') - .add(buildName, '\ - lodash.flatten(nestedNumbers)' - ) - .add(otherName, '\ - _.flatten(nestedNumbers)' - ) - ); - - suites.push( - Benchmark.Suite('`_.flatten` with `shallow`') - .add(buildName, '\ - lodash.flatten(nestedNumbers, true)' - ) - .add(otherName, '\ - _.flatten(nestedNumbers, true)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.functions`') - .add(buildName, '\ - lodash.functions(lodash)' - ) - .add(otherName, '\ - _.functions(lodash)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.groupBy` with `callback` iterating an array') - .add(buildName, '\ - lodash.groupBy(numbers, function(num) { return num >> 1; })' - ) - .add(otherName, '\ - _.groupBy(numbers, function(num) { return num >> 1; })' - ) - ); - - suites.push( - Benchmark.Suite('`_.groupBy` with `property` name iterating an array') - .add(buildName, { - 'fn': 'lodash.groupBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '_.groupBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.groupBy` with `callback` iterating an object') - .add(buildName, { - 'fn': 'lodash.groupBy(wordToNumber, function(num) { return num >> 1; })', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '_.groupBy(wordToNumber, function(num) { return num >> 1; })', - 'teardown': 'function countBy(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.indexOf`') - .add(buildName, '\ - lodash.indexOf(numbers, 9)' - ) - .add(otherName, '\ - _.indexOf(numbers, 9)' - ) - ); - - suites.push( - Benchmark.Suite('`_.indexOf` with `isSorted`') - .add(buildName, '\ - lodash.indexOf(numbers, 19, true)' - ) - .add(otherName, '\ - _.indexOf(numbers, 19, true)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.intersection`') - .add(buildName, '\ - lodash.intersection(numbers, fourNumbers, twoNumbers)' - ) - .add(otherName, '\ - _.intersection(numbers, fourNumbers, twoNumbers)' - ) - ); - - suites.push( - Benchmark.Suite('`_.intersection` iterating 25 elements') - .add(buildName, { - 'fn': 'lodash.intersection(twentyFiveValues, twentyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.intersection(twentyFiveValues, twentyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.intersection` iterating 50 and 75 elements') - .add(buildName, { - 'fn': 'lodash.intersection(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.intersection(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.intersection` iterating 75 elements') - .add(buildName, { - 'fn': 'lodash.intersection(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.intersection(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.invert`') - .add(buildName, '\ - lodash.invert(object)' - ) - .add(otherName, '\ - _.invert(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.invoke` iterating an array') - .add(buildName, '\ - lodash.invoke(numbers, "toFixed", "2")' - ) - .add(otherName, '\ - _.invoke(numbers, "toFixed", "2")' - ) - ); - - suites.push( - Benchmark.Suite('`_.invoke` with a function for `methodName` iterating an array') - .add(buildName, '\ - lodash.invoke(numbers, String.prototype.split, "")' - ) - .add(otherName, '\ - _.invoke(numbers, String.prototype.split, "")' - ) - ); - - suites.push( - Benchmark.Suite('`_.invoke` iterating an object') - .add(buildName, '\ - lodash.invoke(object, "toFixed", "2")' - ) - .add(otherName, '\ - _.invoke(object, "toFixed", "2")' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.isEqual` comparing primitives and objects (edge case)') - .add(buildName, { - 'fn': 'lodash.isEqual(objectOfPrimitives, objectOfObjects)', - 'teardown': 'function isEqual(){}' - }) - .add(otherName, { - 'fn': '_.isEqual(objectOfPrimitives, objectOfObjects)', - 'teardown': 'function isEqual(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.isEqual` comparing arrays') - .add(buildName, { - 'fn': 'lodash.isEqual(numbers, numbers2)', - 'teardown': 'function isEqual(){}' - }) - .add(otherName, { - 'fn': '_.isEqual(numbers, numbers2)', - 'teardown': 'function isEqual(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.isEqual` comparing nested arrays') - .add(buildName, { - 'fn': 'lodash.isEqual(nestedNumbers, nestedNumbers2)', - 'teardown': 'function isEqual(){}' - }) - .add(otherName, { - 'fn': '_.isEqual(nestedNumbers, nestedNumbers2)', - 'teardown': 'function isEqual(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.isEqual` comparing arrays of objects') - .add(buildName, { - 'fn': 'lodash.isEqual(objects, objects2)', - 'teardown': 'function isEqual(){}' - }) - .add(otherName, { - 'fn': '_.isEqual(objects, objects2)', - 'teardown': 'function isEqual(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.isEqual` comparing objects') - .add(buildName, { - 'fn': 'lodash.isEqual(object, object2)', - 'teardown': 'function isEqual(){}' - }) - .add(otherName, { - 'fn': '_.isEqual(object, object2)', - 'teardown': 'function isEqual(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isRegExp`') - .add(buildName, '\ - lodash.isArguments(arguments);\ - lodash.isArguments(object);\ - lodash.isDate(date);\ - lodash.isDate(object);\ - lodash.isFunction(lodash);\ - lodash.isFunction(object);\ - lodash.isNumber(1);\ - lodash.isNumber(object);\ - lodash.isRegExp(regexp);\ - lodash.isRegExp(object);' - ) - .add(otherName, '\ - _.isArguments(arguments);\ - _.isArguments(object);\ - _.isDate(date);\ - _.isDate(object);\ - _.isFunction(_);\ - _.isFunction(object);\ - _.isNumber(1);\ - _.isNumber(object);\ - _.isRegExp(regexp);\ - _.isRegExp(object);' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.keys` (uses native `Object.keys` if available)') - .add(buildName, '\ - lodash.keys(object)' - ) - .add(otherName, '\ - _.keys(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.lastIndexOf`') - .add(buildName, '\ - lodash.lastIndexOf(numbers, 9)' - ) - .add(otherName, '\ - _.lastIndexOf(numbers, 9)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.map` iterating an array') - .add(buildName, '\ - lodash.map(objects, function(value) {\ - return value.num;\ - })' - ) - .add(otherName, '\ - _.map(objects, function(value) {\ - return value.num;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.map` with `thisArg` iterating an array (slow path)') - .add(buildName, '\ - lodash.map(objects, function(value, index) {\ - return this["key" + index] + value.num;\ - }, object)' - ) - .add(otherName, '\ - _.map(objects, function(value, index) {\ - return this["key" + index] + value.num;\ - }, object)' - ) - ); - - suites.push( - Benchmark.Suite('`_.map` iterating an object') - .add(buildName, '\ - lodash.map(object, function(value) {\ - return value;\ - })' - ) - .add(otherName, '\ - _.map(object, function(value) {\ - return value;\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.max`') - .add(buildName, '\ - lodash.max(numbers)' - ) - .add(otherName, '\ - _.max(numbers)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.min`') - .add(buildName, '\ - lodash.min(numbers)' - ) - .add(otherName, '\ - _.min(numbers)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.omit` iterating 20 properties, omitting 2 keys') - .add(buildName, '\ - lodash.omit(object, "key6", "key13")' - ) - .add(otherName, '\ - _.omit(object, "key6", "key13")' - ) - ); - - suites.push( - Benchmark.Suite('`_.omit` iterating 40 properties, omitting 20 keys') - .add(buildName, { - 'fn': 'lodash.omit(wordToNumber, words)', - 'teardown': 'function omit(){}' - }) - .add(otherName, { - 'fn': 'result = _.omit(wordToNumber, words)', - 'teardown': 'function omit(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.pairs`') - .add(buildName, '\ - lodash.pairs(object)' - ) - .add(otherName, '\ - _.pairs(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.pick`') - .add(buildName, '\ - lodash.pick(object, "key6", "key13")' - ) - .add(otherName, '\ - _.pick(object, "key6", "key13")' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.pluck`') - .add(buildName, '\ - lodash.pluck(objects, "num")' - ) - .add(otherName, '\ - _.pluck(objects, "num")' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.reduce` iterating an array') - .add(buildName, '\ - lodash.reduce(numbers, function(result, value, index) {\ - result[index] = value;\ - return result;\ - }, {});' - ) - .add(otherName, '\ - _.reduce(numbers, function(result, value, index) {\ - result[index] = value;\ - return result;\ - }, {});' - ) - ); - - suites.push( - Benchmark.Suite('`_.reduce` iterating an object') - .add(buildName, '\ - lodash.reduce(object, function(result, value, key) {\ - result.push([key, value]);\ - return result;\ - }, []);' - ) - .add(otherName, '\ - _.reduce(object, function(result, value, key) {\ - result.push([key, value]);\ - return result;\ - }, []);' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.reduceRight` iterating an array') - .add(buildName, '\ - lodash.reduceRight(numbers, function(result, value, index) {\ - result[index] = value;\ - return result;\ - }, {});' - ) - .add(otherName, '\ - _.reduceRight(numbers, function(result, value, index) {\ - result[index] = value;\ - return result;\ - }, {});' - ) - ); - - suites.push( - Benchmark.Suite('`_.reduceRight` iterating an object') - .add(buildName, '\ - lodash.reduceRight(object, function(result, value, key) {\ - result.push([key, value]);\ - return result;\ - }, []);' - ) - .add(otherName, '\ - _.reduceRight(object, function(result, value, key) {\ - result.push([key, value]);\ - return result;\ - }, []);' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.reject` iterating an array') - .add(buildName, '\ - lodash.reject(numbers, function(num) {\ - return num % 2;\ - })' - ) - .add(otherName, '\ - _.reject(numbers, function(num) {\ - return num % 2;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.reject` iterating an array with `thisArg` (slow path)') - .add(buildName, '\ - lodash.reject(numbers, function(num, index) {\ - return this["key" + index] % 2;\ - }, object)' - ) - .add(otherName, '\ - _.reject(numbers, function(num, index) {\ - return this["key" + index] % 2;\ - }, object)' - ) - ); - - suites.push( - Benchmark.Suite('`_.reject` iterating an object') - .add(buildName, '\ - lodash.reject(object, function(num) {\ - return num % 2\ - })' - ) - .add(otherName, '\ - _.reject(object, function(num) {\ - return num % 2\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.shuffle`') - .add(buildName, '\ - lodash.shuffle(numbers)' - ) - .add(otherName, '\ - _.shuffle(numbers)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.size` with an object') - .add(buildName, '\ - lodash.size(object)' - ) - .add(otherName, '\ - _.size(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.some` iterating an array') - .add(buildName, '\ - lodash.some(numbers, function(num) {\ - return num == 19;\ - })' - ) - .add(otherName, '\ - _.some(numbers, function(num) {\ - return num == 19;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.some` iterating an object') - .add(buildName, '\ - lodash.some(object, function(num) {\ - return num == 19;\ - })' - ) - .add(otherName, '\ - _.some(object, function(num) {\ - return num == 19;\ - })' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.sortBy` with `callback`') - .add(buildName, '\ - lodash.sortBy(numbers, function(num) { return Math.sin(num); })' - ) - .add(otherName, '\ - _.sortBy(numbers, function(num) { return Math.sin(num); })' - ) - ); - - suites.push( - Benchmark.Suite('`_.sortBy` with `callback` and `thisArg` (slow path)') - .add(buildName, '\ - lodash.sortBy(numbers, function(num) { return this.sin(num); }, Math)' - ) - .add(otherName, '\ - _.sortBy(numbers, function(num) { return this.sin(num); }, Math)' - ) - ); - - suites.push( - Benchmark.Suite('`_.sortBy` with `property` name') - .add(buildName, { - 'fn': 'lodash.sortBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '_.sortBy(words, "length")', - 'teardown': 'function countBy(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.sortedIndex`') - .add(buildName, '\ - lodash.sortedIndex(numbers, 25)' - ) - .add(otherName, '\ - _.sortedIndex(numbers, 25)' - ) - ); - - suites.push( - Benchmark.Suite('`_.sortedIndex` with `callback`') - .add(buildName, { - 'fn': '\ - lodash.sortedIndex(words, "twenty-five", function(value) {\ - return wordToNumber[value];\ - })', - 'teardown': 'function countBy(){}' - }) - .add(otherName, { - 'fn': '\ - _.sortedIndex(words, "twenty-five", function(value) {\ - return wordToNumber[value];\ - })', - 'teardown': 'function countBy(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.template` without "evaluate" delimiters (slow path)') - .add(buildName, { - 'fn': 'lodash.template(tpl, tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_.template(tpl, tplData)', - 'teardown': 'function template(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.template` with "evaluate" delimiters (slow path)') - .add(buildName, { - 'fn': 'lodash.template(tplWithEvaluate, tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_.template(tplWithEvaluate, tplData)', - 'teardown': 'function template(){}' - }) - ); - - suites.push( - Benchmark.Suite('compiled template without "evaluate" delimiters') - .add(buildName, { - 'fn': 'lodashTpl(tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_tpl(tplData)', - 'teardown': 'function template(){}' - }) - ); - - suites.push( - Benchmark.Suite('compiled template with "evaluate" delimiters') - .add(buildName, { - 'fn': 'lodashTplWithEvaluate(tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_tplWithEvaluate(tplData)', - 'teardown': 'function template(){}' - }) - ); - - suites.push( - Benchmark.Suite('compiled template without a with-statement or "evaluate" delimiters') - .add(buildName, { - 'fn': 'lodashTplVerbose(tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_tplVerbose(tplData)', - 'teardown': 'function template(){}' - }) - ); - - suites.push( - Benchmark.Suite('compiled template without a with-statement using "evaluate" delimiters') - .add(buildName, { - 'fn': 'lodashTplVerboseWithEvaluate(tplData)', - 'teardown': 'function template(){}' - }) - .add(otherName, { - 'fn': '_tplVerboseWithEvaluate(tplData)', - 'teardown': 'function template(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.times`') - .add(buildName, '\ - var result = [];\ - lodash.times(limit, function(n) { result.push(n); })' - ) - .add(otherName, '\ - var result = [];\ - _.times(limit, function(n) { result.push(n); })' - ) - ); - - suites.push( - Benchmark.Suite('`_.times` with `thisArg`') - .add(buildName, '\ - var result = [];\ - lodash.times(limit, function(n) { result.push(this.sin(n)); }, Math)' - ) - .add(otherName, '\ - var result = [];\ - _.times(limit, function(n) { result.push(this.sin(n)); }, Math)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.toArray` with an array') - .add(buildName, '\ - lodash.toArray(numbers)' - ) - .add(otherName, '\ - _.toArray(numbers)' - ) - ); - - suites.push( - Benchmark.Suite('`_.toArray` with an object') - .add(buildName, '\ - lodash.toArray(object)' - ) - .add(otherName, '\ - _.toArray(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.union`') - .add(buildName, '\ - lodash.union(numbers, fourNumbers, twoNumbers)' - ) - .add(otherName, '\ - _.union(numbers, fourNumbers, twoNumbers)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.uniq`') - .add(buildName, '\ - lodash.uniq(numbers.concat(fourNumbers, twoNumbers))' - ) - .add(otherName, '\ - _.uniq(numbers.concat(fourNumbers, twoNumbers))' - ) - ); - - suites.push( - Benchmark.Suite('`_.uniq` with `callback`') - .add(buildName, '\ - lodash.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ - return num % 2;\ - });' - ) - .add(otherName, '\ - _.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ - return num % 2;\ - })' - ) - ); - - suites.push( - Benchmark.Suite('`_.uniq` iterating an array of 50 elements') - .add(buildName, { - 'fn': 'lodash.uniq(twentyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.uniq(twentyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.uniq` iterating an array of 75 elements') - .add(buildName, { - 'fn': 'lodash.uniq(fiftyValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.uniq(fiftyValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.uniq` iterating an array of 100 elements') - .add(buildName, { - 'fn': 'lodash.uniq(seventyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.uniq(seventyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.values`') - .add(buildName, '\ - lodash.values(object)' - ) - .add(otherName, '\ - _.values(object)' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.where`') - .add(buildName, '\ - lodash.where(objects, { "num": 9 });' - ) - .add(otherName, '\ - _.where(objects, { "num": 9 });' - ) - ); - - /*--------------------------------------------------------------------------*/ - - suites.push( - Benchmark.Suite('`_.without`') - .add(buildName, '\ - lodash.without(numbers, 9, 12, 14, 15)' - ) - .add(otherName, '\ - _.without(numbers, 9, 12, 14, 15)' - ) - ); - - suites.push( - Benchmark.Suite('`_.without` iterating an array of 25 elements') - .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.without` iterating an array of 75 and 50 elements') - .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [seventyFiveValues2].concat(fiftyValues));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.without.apply(_, [seventyFiveValues2].concat(fiftyValues));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.without` iterating an array of 75 elements') - .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - - if (Benchmark.platform + '') { - log(Benchmark.platform); - } - - // in the browser, expose `run` to be called later - if (window.document) { - window.run = run; - } else { - run(); - } -}(typeof global == 'object' && global || this)); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/a.jst b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/a.jst deleted file mode 100644 index a2a8b6e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/a.jst +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/b.jst b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/b.jst deleted file mode 100644 index cad081d..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/b.jst +++ /dev/null @@ -1 +0,0 @@ -<% print("Hello " + epithet); %>. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/c.jst b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/c.jst deleted file mode 100644 index f926799..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/c.jst +++ /dev/null @@ -1 +0,0 @@ -Hello ${ name }! \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/d.tpl b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/d.tpl deleted file mode 100644 index c7a43bc..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/template/d.tpl +++ /dev/null @@ -1 +0,0 @@ -Hello {{ name }}! \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test-build.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test-build.js deleted file mode 100644 index 8fb3706..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test-build.js +++ /dev/null @@ -1,1083 +0,0 @@ -#!/usr/bin/env node -;(function(undefined) { - 'use strict'; - - /** Load modules */ - var fs = require('fs'), - path = require('path'), - vm = require('vm'), - build = require('../build.js'), - minify = require('../build/minify'), - _ = require('../lodash.js'); - - /** The unit testing framework */ - var QUnit = global.QUnit = require('../vendor/qunit/qunit/qunit.js'); - require('../vendor/qunit-clib/qunit-clib.js'); - - /** Used to associate aliases with their real names */ - var aliasToRealMap = { - 'all': 'every', - 'any': 'some', - 'collect': 'map', - 'detect': 'find', - 'drop': 'rest', - 'each': 'forEach', - 'extend': 'assign', - 'foldl': 'reduce', - 'foldr': 'reduceRight', - 'head': 'first', - 'include': 'contains', - 'inject': 'reduce', - 'methods': 'functions', - 'select': 'filter', - 'tail': 'rest', - 'take': 'first', - 'unique': 'uniq' - }; - - /** Used to associate real names with their aliases */ - var realToAliasMap = { - 'assign': ['extend'], - 'contains': ['include'], - 'every': ['all'], - 'filter': ['select'], - 'find': ['detect'], - 'first': ['head', 'take'], - 'forEach': ['each'], - 'functions': ['methods'], - 'map': ['collect'], - 'reduce': ['foldl', 'inject'], - 'reduceRight': ['foldr'], - 'rest': ['drop', 'tail'], - 'some': ['any'], - 'uniq': ['unique'] - }; - - /** List of all Lo-Dash methods */ - var allMethods = _.functions(_).filter(function(methodName) { - return !/^_/.test(methodName); - }); - - /** List of "Arrays" category methods */ - var arraysMethods = [ - 'compact', - 'difference', - 'drop', - 'first', - 'flatten', - 'head', - 'indexOf', - 'initial', - 'intersection', - 'last', - 'lastIndexOf', - 'object', - 'range', - 'rest', - 'sortedIndex', - 'tail', - 'take', - 'union', - 'uniq', - 'unique', - 'without', - 'zip' - ]; - - /** List of "Chaining" category methods */ - var chainingMethods = [ - 'chain', - 'mixin', - 'tap', - 'value' - ]; - - /** List of "Collections" category methods */ - var collectionsMethods = [ - 'all', - 'any', - 'collect', - 'contains', - 'countBy', - 'detect', - 'each', - 'every', - 'filter', - 'find', - 'foldl', - 'foldr', - 'forEach', - 'groupBy', - 'include', - 'inject', - 'invoke', - 'map', - 'max', - 'min', - 'pluck', - 'reduce', - 'reduceRight', - 'reject', - 'select', - 'shuffle', - 'size', - 'some', - 'sortBy', - 'toArray', - 'where' - ]; - - /** List of "Functions" category methods */ - var functionsMethods = [ - 'after', - 'bind', - 'bindAll', - 'bindKey', - 'compose', - 'debounce', - 'defer', - 'delay', - 'memoize', - 'once', - 'partial', - 'throttle', - 'wrap' - ]; - - /** List of "Objects" category methods */ - var objectsMethods = [ - 'assign', - 'clone', - 'defaults', - 'extend', - 'forIn', - 'forOwn', - 'functions', - 'has', - 'invert', - 'isArguments', - 'isArray', - 'isBoolean', - 'isDate', - 'isElement', - 'isEmpty', - 'isEqual', - 'isFinite', - 'isFunction', - 'isNaN', - 'isNull', - 'isNumber', - 'isObject', - 'isPlainObject', - 'isRegExp', - 'isString', - 'isUndefined', - 'keys', - 'methods', - 'merge', - 'omit', - 'pairs', - 'pick', - 'values' - ]; - - /** List of "Utilities" category methods */ - var utilityMethods = [ - 'escape', - 'identity', - 'noConflict', - 'random', - 'result', - 'template', - 'times', - 'unescape', - 'uniqueId' - ]; - - /** List of Backbone's Lo-Dash dependencies */ - var backboneDependencies = [ - 'bind', - 'bindAll', - 'chain', - 'clone', - 'contains', - 'countBy', - 'defaults', - 'escape', - 'every', - 'extend', - 'filter', - 'find', - 'first', - 'forEach', - 'groupBy', - 'has', - 'indexOf', - 'initial', - 'invoke', - 'isArray', - 'isEmpty', - 'isEqual', - 'isFunction', - 'isObject', - 'isRegExp', - 'isString', - 'keys', - 'last', - 'lastIndexOf', - 'map', - 'max', - 'min', - 'mixin', - 'pick', - 'reduce', - 'reduceRight', - 'reject', - 'rest', - 'result', - 'shuffle', - 'size', - 'some', - 'sortBy', - 'sortedIndex', - 'toArray', - 'uniqueId', - 'value', - 'without' - ]; - - /** List of methods used by Underscore */ - var underscoreMethods = _.without.apply(_, [allMethods].concat([ - 'bindKey', - 'forIn', - 'forOwn', - 'isPlainObject', - 'merge', - 'partial' - ])); - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a context object to use with `vm.runInContext`. - * - * @private - * @returns {Object} Returns a new context object. - */ - function createContext() { - return vm.createContext({ - 'clearTimeout': clearTimeout, - 'setTimeout': setTimeout - }); - } - - /** - * Expands a list of method names to include real and alias names. - * - * @private - * @param {Array} methodNames The array of method names to expand. - * @returns {Array} Returns a new array of expanded method names. - */ - function expandMethodNames(methodNames) { - return methodNames.reduce(function(result, methodName) { - var realName = getRealName(methodName); - result.push.apply(result, [realName].concat(getAliases(realName))); - return result; - }, []); - } - - /** - * Gets the aliases associated with a given function name. - * - * @private - * @param {String} funcName The name of the function to get aliases for. - * @returns {Array} Returns an array of aliases. - */ - function getAliases(funcName) { - return realToAliasMap[funcName] || []; - } - - /** - * Gets the names of methods belonging to the given `category`. - * - * @private - * @param {String} category The category to filter by. - * @returns {Array} Returns a new array of method names belonging to the given category. - */ - function getMethodsByCategory(category) { - switch (category) { - case 'Arrays': - return arraysMethods.slice(); - case 'Chaining': - return chainingMethods.slice(); - case 'Collections': - return collectionsMethods.slice(); - case 'Functions': - return functionsMethods.slice(); - case 'Objects': - return objectsMethods.slice(); - case 'Utilities': - return utilityMethods.slice(); - } - return []; - } - - /** - * Gets the real name, not alias, of a given function name. - * - * @private - * @param {String} funcName The name of the function to resolve. - * @returns {String} Returns the real name. - */ - function getRealName(funcName) { - return aliasToRealMap[funcName] || funcName; - } - - /** - * Tests if a given method on the `lodash` object can be called successfully. - * - * @private - * @param {Object} lodash The built Lo-Dash object. - * @param {String} methodName The name of the Lo-Dash method to test. - * @param {String} message The unit test message. - */ - function testMethod(lodash, methodName, message) { - var pass = true, - array = [['a', 1], ['b', 2], ['c', 3]], - object = { 'a': 1, 'b': 2, 'c': 3 }, - noop = function() {}, - string = 'abc', - func = lodash[methodName]; - - try { - if (arraysMethods.indexOf(methodName) > -1) { - if (/(?:indexOf|sortedIndex|without)$/i.test(methodName)) { - func(array, string); - } else if (/^(?:difference|intersection|union|uniq|zip)/.test(methodName)) { - func(array, array); - } else if (methodName == 'range') { - func(2, 4); - } else { - func(array); - } - } - else if (chainingMethods.indexOf(methodName) > -1) { - if (methodName == 'chain') { - lodash.chain(array); - lodash(array).chain(); - } - else if (methodName == 'mixin') { - lodash.mixin({}); - } - else { - lodash(array)[methodName](noop); - } - } - else if (collectionsMethods.indexOf(methodName) > -1) { - if (/^(?:count|group|sort)By$/.test(methodName)) { - func(array, noop); - func(array, string); - func(object, noop); - func(object, string); - } - else if (/^(?:size|toArray)$/.test(methodName)) { - func(array); - func(object); - } - else if (methodName == 'invoke') { - func(array, 'slice'); - func(object, 'toFixed'); - } - else if (methodName == 'where') { - func(array, object); - func(object, object); - } - else { - func(array, noop, object); - func(object, noop, object); - } - } - else if (functionsMethods.indexOf(methodName) > -1) { - if (methodName == 'after') { - func(1, noop); - } else if (methodName == 'bindAll') { - func({ 'noop': noop }); - } else if (methodName == 'bindKey') { - func(lodash, 'identity', array, string); - } else if (/^(?:bind|partial)$/.test(methodName)) { - func(noop, object, array, string); - } else if (/^(?:compose|memoize|wrap)$/.test(methodName)) { - func(noop, noop); - } else if (/^(?:debounce|throttle)$/.test(methodName)) { - func(noop, 100); - } else { - func(noop); - } - } - else if (objectsMethods.indexOf(methodName) > -1) { - if (methodName == 'clone') { - func(object); - func(object, true); - } - else if (/^(?:defaults|extend|merge)$/.test(methodName)) { - func({}, object); - } else if (/^(?:forIn|forOwn)$/.test(methodName)) { - func(object, noop); - } else if (/^(?:omit|pick)$/.test(methodName)) { - func(object, 'b'); - } else if (methodName == 'has') { - func(object, string); - } else { - func(object); - } - } - else if (utilityMethods.indexOf(methodName) > -1) { - if (methodName == 'result') { - func(object, 'b'); - } else if (methodName == 'times') { - func(2, noop, object); - } else { - func(string, object); - } - } - } - catch(e) { - console.log(e); - pass = false; - } - equal(pass, true, '_.' + methodName + ': ' + message); - } - - /*--------------------------------------------------------------------------*/ - - QUnit.module('minified AMD snippet'); - - (function() { - var start = _.once(QUnit.start); - - asyncTest('`lodash`', function() { - build(['-s'], function(source, filePath) { - // used by r.js build optimizer - var defineHasRegExp = /typeof\s+define\s*==(=)?\s*['"]function['"]\s*&&\s*typeof\s+define\.amd\s*==(=)?\s*['"]object['"]\s*&&\s*define\.amd/g, - basename = path.basename(filePath, '.js'); - - ok(!!defineHasRegExp.exec(source), basename); - start(); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('template builds'); - - (function() { - var templatePath = __dirname + '/template'; - - asyncTest('`lodash template=*.jst`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'template=' + templatePath + '/*.jst'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - var data = { - 'a': { 'people': ['moe', 'larry', 'curly'] }, - 'b': { 'epithet': 'stooge' }, - 'c': { 'name': 'ES6' } - }; - - context._ = _; - vm.runInContext(source, context); - var templates = context._.templates; - - equal(templates.a(data.a).replace(/[\r\n]+/g, ''), '', basename); - equal(templates.b(data.b), 'Hello stooge.', basename); - equal(templates.c(data.c), 'Hello ES6!', basename); - delete _.templates; - start(); - }); - }); - - ['', 'moduleId=underscore'].forEach(function(command) { - asyncTest('`lodash template=*.jst` exports=amd' + (command ? ' ' + command : ''), function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'template=' + templatePath + '/*.jst', 'exports=amd'].concat(command || []), function(source, filePath) { - var moduleId, - basename = path.basename(filePath, '.js'), - context = createContext(), - pass = false; - - (context.define = function(requires, factory) { - factory(_); - var templates = _.templates; - moduleId = requires + ''; - pass = 'a' in templates && 'b' in templates; - }) - .amd = {}; - - vm.runInContext(source, context); - - equal(moduleId, command ? 'underscore' : 'lodash'); - ok(pass, basename); - delete _.templates; - start(); - }); - }); - }); - - asyncTest('`lodash settings=...`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - var data = { - 'd': { 'name': 'Mustache' } - }; - - context._ = _; - vm.runInContext(source, context); - var templates = context._.templates; - - equal(templates.d(data.d), 'Hello Mustache!', basename); - start(); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('independent builds'); - - (function() { - asyncTest('debug only', function() { - var start = _.once(QUnit.start); - build(['-d', '-s'], function(source, filePath) { - equal(path.basename(filePath, '.js'), 'lodash'); - start(); - }); - }); - - asyncTest('debug custom', function() { - var start = _.once(QUnit.start); - build(['-d', '-s', 'backbone'], function(source, filePath) { - equal(path.basename(filePath, '.js'), 'lodash.custom'); - start(); - }); - }); - - asyncTest('minified only', function() { - var start = _.once(QUnit.start); - build(['-m', '-s'], function(source, filePath) { - equal(path.basename(filePath, '.js'), 'lodash.min'); - start(); - }); - }); - - asyncTest('minified custom', function() { - var start = _.once(QUnit.start); - build(['-m', '-s', 'backbone'], function(source, filePath) { - equal(path.basename(filePath, '.js'), 'lodash.custom.min'); - start(); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('strict modifier'); - - (function() { - var object = Object.freeze({ - 'a': _.identity, - 'b': null - }); - - ['non-strict', 'strict'].forEach(function(strictMode, index) { - asyncTest(strictMode + ' should ' + (index ? 'error': 'silently fail') + ' attempting to overwrite read-only properties', function() { - var commands = ['-s', 'include=bindAll,defaults,extend'], - start = _.after(2, _.once(QUnit.start)); - - if (index) { - commands.push('strict'); - } - build(commands, function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - vm.runInContext(source, context); - var lodash = context._; - - var actual = _.every([ - function() { lodash.bindAll(object); }, - function() { lodash.extend(object, { 'a': 1 }); }, - function() { lodash.defaults(object, { 'b': 2 }); } - ], function(fn) { - var pass = !index; - try { - fn(); - } catch(e) { - pass = !!index; - } - return pass; - }); - - equal(actual, true, basename); - start(); - }); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('underscore modifier'); - - (function() { - asyncTest('modified methods should work correctly', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'underscore'], function(source, filePath) { - var last, - array = [{ 'a': 1, 'b': 2 }, { 'a': 2, 'b': 2 }], - basename = path.basename(filePath, '.js'), - context = createContext(); - - vm.runInContext(source, context); - var lodash = context._; - - var object = { 'fn': lodash.bind(function(foo) { return foo + this.bar; }, { 'bar': 1 }, 1) }; - equal(object.fn(), 2, '_.bind: ' + basename); - - ok(lodash.clone(array, true)[0] === array[0], '_.clone should be shallow: ' + basename); - equal(lodash.contains({ 'a': 1, 'b': 2 }, 1), true, '_.contains should work with objects: ' + basename); - equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename); - equal(lodash.every([true, false, true]), false, '_.every: ' + basename); - - function Foo() {} - Foo.prototype = { 'a': 1 }; - - deepEqual(lodash.defaults({}, new Foo), Foo.prototype, '_.defaults should assign inherited `source` properties: ' + basename); - deepEqual(lodash.extend({}, new Foo), Foo.prototype, '_.extend should assign inherited `source` properties: ' + basename); - - actual = lodash.find(array, function(value) { - return 'a' in value; - }); - - equal(actual, _.first(array), '_.find: ' + basename); - - actual = lodash.forEach(array, function(value) { - last = value; - return false; - }); - - equal(last, _.last(array), '_.forEach should not exit early: ' + basename); - equal(actual, undefined, '_.forEach should return `undefined`: ' + basename); - - object = { 'length': 0, 'splice': Array.prototype.splice }; - equal(lodash.isEmpty(object), false, '_.isEmpty should return `false` for jQuery/MooTools DOM query collections: ' + basename); - - equal(lodash.isFinite('2'), false, '_.isFinite should return `false` for numeric string values: ' + basename); - equal(lodash.max('abc'), -Infinity, '_.max should return `-Infinity` for strings: ' + basename); - equal(lodash.min('abc'), Infinity, '_.min should return `Infinity` for strings: ' + basename); - - // avoid issues comparing objects with `deepEqual` - object = { 'a': 1, 'b': 2, 'c': 3 }; - var actual = lodash.omit(object, function(value) { return value == 3; }); - deepEqual(_.keys(actual).sort(), ['a', 'b', 'c'], '_.omit should not accept a `callback`: ' + basename); - - actual = lodash.pick(object, function(value) { return value != 3; }); - deepEqual(_.keys(actual), [], '_.pick should not accept a `callback`: ' + basename); - - equal(lodash.some([false, true, false]), true, '_.some: ' + basename); - equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename); - - start(); - }); - }); - - asyncTest('should not have any Lo-Dash-only methods', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'underscore'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - vm.runInContext(source, context); - var lodash = context._; - - _.each([ - 'assign', - 'bindKey', - 'forIn', - 'forOwn', - 'isPlainObject', - 'merge', - 'partial' - ], function(methodName) { - equal(lodash[methodName], undefined, '_.' + methodName + ' should not exist: ' + basename); - }); - - start(); - }); - }); - - asyncTest('`lodash underscore include=partial`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'underscore', 'include=partial'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - vm.runInContext(source, context); - var lodash = context._; - - equal(lodash.partial(_.identity, 2)(), 2, '_.partial: ' + basename); - start(); - }); - }); - - asyncTest('`lodash underscore plus=clone`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'underscore', 'plus=clone'], function(source, filePath) { - var array = [{ 'value': 1 }], - basename = path.basename(filePath, '.js'), - context = createContext(); - - vm.runInContext(source, context); - var lodash = context._, - clone = lodash.clone(array, true); - - deepEqual(array, clone, basename); - notEqual(array, clone, basename); - start(); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('exports command'); - - (function() { - var commands = [ - 'exports=amd', - 'exports=commonjs', - 'exports=global', - 'exports=node', - 'exports=none' - ]; - - commands.forEach(function(command, index) { - asyncTest('`lodash ' + command +'`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', command], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(), - pass = false; - - switch(index) { - case 0: - context.define = function(fn) { - pass = true; - context._ = fn(); - }; - context.define.amd = {}; - vm.runInContext(source, context); - ok(pass, basename); - break; - - case 1: - context.exports = {}; - vm.runInContext(source, context); - ok(context._ === undefined, basename); - ok(_.isFunction(context.exports._), basename) - break; - - case 2: - vm.runInContext(source, context); - ok(_.isFunction(context._), basename); - break; - - case 3: - context.exports = {}; - context.module = { 'exports': context.exports }; - vm.runInContext(source, context); - ok(context._ === undefined, basename); - ok(_.isFunction(context.module.exports), basename); - break; - - case 4: - vm.runInContext(source, context); - ok(context._ === undefined, basename); - } - start(); - }); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('iife command'); - - (function() { - var commands = [ - 'iife=this["lodash"]=(function(window,undefined){%output%;return lodash}(this))', - 'iife=define(function(window,undefined){return function(){%output%;return lodash}}(this));' - ]; - - commands.forEach(function(command) { - asyncTest('`lodash ' + command +'`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'exports=none', command], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - context.define = function(func) { - context.lodash = func(); - }; - - try { - vm.runInContext(source, context); - } catch(e) { - console.log(e); - } - - var lodash = context.lodash || {}; - ok(_.isString(lodash.VERSION), basename); - start(); - }); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('output options'); - - (function() { - ['-o a.js', '--output a.js'].forEach(function(command, index) { - asyncTest('`lodash ' + command +'`', function() { - var start = _.once(QUnit.start); - - build(['-s'].concat(command.split(' ')), function(source, filePath) { - equal(path.basename(filePath, '.js'), 'a', command); - start(); - }); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('stdout options'); - - (function() { - ['-c', '--stdout'].forEach(function(command, index) { - asyncTest('`lodash ' + command +'`', function() { - var written, - start = _.once(QUnit.start), - write = process.stdout.write; - - process.stdout.write = function(string) { - written = string; - }; - - build([command, 'exports=', 'include='], function(source) { - process.stdout.write = write; - equal(written, source); - equal(arguments.length, 1); - start(); - }); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('minify underscore'); - - (function() { - asyncTest('`node minify underscore.js`', function() { - var source = fs.readFileSync(path.join(__dirname, '..', 'vendor', 'underscore', 'underscore.js'), 'utf8'), - start = _.once(QUnit.start); - - minify(source, { - 'isSilent': true, - 'workingName': 'underscore.min', - 'onComplete': function(result) { - var context = createContext(); - - try { - vm.runInContext(result, context); - } catch(e) { - console.log(e); - } - - var underscore = context._ || {}; - ok(_.isString(underscore.VERSION)); - ok(!/Lo-Dash/.test(result) && result.match(/\n/g).length < source.match(/\n/g).length); - start(); - } - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('mobile build'); - - (function() { - asyncTest('`lodash mobile`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['-s', 'mobile'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); - - try { - vm.runInContext(source, context); - } catch(e) { - console.log(e); - } - - var array = [1, 2, 3], - object1 = [{ 'a': 1 }], - object2 = [{ 'b': 2 }], - object3 = [{ 'a': 1, 'b': 2 }], - circular1 = { 'a': 1 }, - circular2 = { 'a': 1 }, - lodash = context._; - - circular1.b = circular1; - circular2.b = circular2; - - deepEqual(lodash.merge(object1, object2), object3, basename); - deepEqual(lodash.sortBy([3, 2, 1], _.identity), array, basename); - equal(lodash.isEqual(circular1, circular2), true, basename); - - var actual = lodash.clone(circular1, true); - ok(actual != circular1 && actual.b == actual, basename); - start(); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('lodash build'); - - (function() { - var commands = [ - 'backbone', - 'csp', - 'legacy', - 'mobile', - 'strict', - 'underscore', - 'category=arrays', - 'category=chaining', - 'category=collections', - 'category=functions', - 'category=objects', - 'category=utilities', - 'exclude=union,uniq,zip', - 'include=each,filter,map', - 'include=once plus=bind,Chaining', - 'category=collections,functions', - 'underscore backbone', - 'backbone legacy category=utilities minus=first,last', - 'underscore include=debounce,throttle plus=after minus=throttle', - 'underscore mobile strict category=functions exports=amd,global plus=pick,uniq', - ] - .concat( - allMethods.map(function(methodName) { - return 'include=' + methodName; - }) - ); - - commands.forEach(function(command) { - asyncTest('`lodash ' + command +'`', function() { - var start = _.after(2, _.once(QUnit.start)); - - build(['--silent'].concat(command.split(' ')), function(source, filePath) { - var methodNames, - basename = path.basename(filePath, '.js'), - context = createContext(), - isUnderscore = /underscore/.test(command), - exposeAssign = !isUnderscore; - - try { - vm.runInContext(source, context); - } catch(e) { - console.log(e); - } - // add method names explicitly - if (/include/.test(command)) { - methodNames = command.match(/include=(\S*)/)[1].split(/, */); - } - // add method names required by Backbone and Underscore builds - if (/backbone/.test(command) && !methodNames) { - methodNames = backboneDependencies.slice(); - } - if (isUnderscore) { - if (methodNames) { - exposeAssign = methodNames.indexOf('assign') > -1; - } else { - methodNames = underscoreMethods.slice(); - } - } - // add method names explicitly by category - if (/category/.test(command)) { - // resolve method names belonging to each category (case-insensitive) - methodNames = command.match(/category=(\S*)/)[1].split(/, */).reduce(function(result, category) { - var capitalized = category[0].toUpperCase() + category.toLowerCase().slice(1); - return result.concat(getMethodsByCategory(capitalized)); - }, methodNames || []); - } - // init `methodNames` if it hasn't been inited - if (!methodNames) { - methodNames = allMethods.slice(); - } - if (/plus/.test(command)) { - methodNames = methodNames.concat(command.match(/plus=(\S*)/)[1].split(/, */)); - } - if (/minus/.test(command)) { - methodNames = _.without.apply(_, [methodNames] - .concat(expandMethodNames(command.match(/minus=(\S*)/)[1].split(/, */)))); - } - if (/exclude/.test(command)) { - methodNames = _.without.apply(_, [methodNames] - .concat(expandMethodNames(command.match(/exclude=(\S*)/)[1].split(/, */)))); - } - - // expand aliases and categories to real method names - methodNames = expandMethodNames(methodNames).reduce(function(result, methodName) { - return result.concat(methodName, getMethodsByCategory(methodName)); - }, []); - - // remove nonexistent and duplicate method names - methodNames = _.uniq(_.intersection(allMethods, expandMethodNames(methodNames))); - - if (!exposeAssign) { - methodNames = _.without(methodNames, 'assign'); - } - var lodash = context._ || {}; - methodNames.forEach(function(methodName) { - testMethod(lodash, methodName, basename); - }); - - start(); - }); - }); - }); - }()); - -}()); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test.js deleted file mode 100644 index 6cd20ef..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/test/test.js +++ /dev/null @@ -1,2042 +0,0 @@ -;(function(window, undefined) { - 'use strict'; - - /** Use a single load function */ - var load = typeof require == 'function' ? require : window.load; - - /** The `platform` object to check */ - var platform = - window.platform || - load('../vendor/platform.js/platform.js') || - window.platform; - - /** The unit testing framework */ - var QUnit = - window.QUnit || ( - window.setTimeout || (window.addEventListener = window.setTimeout = / /), - window.QUnit = load('../vendor/qunit/qunit/qunit' + (platform.name == 'Narwhal' ? '-1.8.0' : '') + '.js') || window.QUnit, - load('../vendor/qunit-clib/qunit-clib.js'), - (window.addEventListener || 0).test && delete window.addEventListener, - window.QUnit - ); - - /** The `lodash` function to test */ - var _ = - window._ || ( - _ = load('../lodash.js') || window._, - _._ || _ - ); - - /** Used to pass falsey values to methods */ - var falsey = [ - , - '', - 0, - false, - NaN, - null, - undefined - ]; - - /** Shortcut used to make object properties immutable */ - var freeze = Object.freeze; - - /** Used to set property descriptors */ - var setDescriptor = (function(fn) { - try { - var o = {}; - return fn(o, o, o) && fn; - } catch(e) { } - }(Object.defineProperty)); - - /** Shortcut used to convert array-like objects to arrays */ - var slice = [].slice; - - /** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */ - var shadowed = { - 'constructor': 1, - 'hasOwnProperty': 2, - 'isPrototypeOf': 3, - 'propertyIsEnumerable': 4, - 'toLocaleString': 5, - 'toString': 6, - 'valueOf': 7 - }; - - /** Used to check problem JScript properties too */ - var shadowedKeys = [ - 'constructor', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'toLocaleString', - 'toString', - 'valueOf' - ]; - - /*--------------------------------------------------------------------------*/ - - /** - * Skips a given number of tests with a passing result. - * - * @private - * @param {Number} [count=1] The number of tests to skip. - */ - function skipTest(count) { - count || (count = 1); - while (count--) { - ok(true, 'test skipped'); - } - } - - /*--------------------------------------------------------------------------*/ - - // add object from iframe - (function() { - if (!window.document) { - return; - } - var body = document.body, - iframe = document.createElement('iframe'); - - iframe.frameBorder = iframe.height = iframe.width = 0; - body.appendChild(iframe); - var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; - idoc.write(" -``` - -Optionally, expose Java’s nanosecond timer by adding the `nano` applet to the ``: - -```html - -``` - -Or enable Chrome’s microsecond timer by using the [command line switch](http://peter.sh/experiments/chromium-command-line-switches/#enable-benchmarking): - - --enable-benchmarking - -Via [npm](http://npmjs.org/): - -```bash -npm install benchmark -``` - -In [Node.js](http://nodejs.org/) and [RingoJS v0.8.0+](http://ringojs.org/): - -```js -var Benchmark = require('benchmark'); -``` - -Optionally, use the [microtime module](https://github.com/wadey/node-microtime) by Wade Simmons: - -```bash -npm install microtime -``` - -In [RingoJS v0.7.0-](http://ringojs.org/): - -```js -var Benchmark = require('benchmark').Benchmark; -``` - -In [Rhino](http://www.mozilla.org/rhino/): - -```js -load('benchmark.js'); -``` - -In an AMD loader like [RequireJS](http://requirejs.org/): - -```js -require({ - 'paths': { - 'benchmark': 'path/to/benchmark' - } -}, -['benchmark'], function(Benchmark) { - console.log(Benchmark.version); -}); - -// or with platform.js -// https://github.com/bestiejs/platform.js -require({ - 'paths': { - 'benchmark': 'path/to/benchmark', - 'platform': 'path/to/platform' - } -}, -['benchmark', 'platform'], function(Benchmark, platform) { - Benchmark.platform = platform; - console.log(Benchmark.platform.name); -}); -``` - -Usage example: - -```js -var suite = new Benchmark.Suite; - -// add tests -suite.add('RegExp#test', function() { - /o/.test('Hello World!'); -}) -.add('String#indexOf', function() { - 'Hello World!'.indexOf('o') > -1; -}) -// add listeners -.on('cycle', function(event) { - console.log(String(event.target)); -}) -.on('complete', function() { - console.log('Fastest is ' + this.filter('fastest').pluck('name')); -}) -// run async -.run({ 'async': true }); - -// logs: -// > RegExp#test x 4,161,532 +-0.99% (59 cycles) -// > String#indexOf x 6,139,623 +-1.00% (131 cycles) -// > Fastest is String#indexOf -``` - -## BestieJS - -Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. - -## Authors - -* [Mathias Bynens](http://mathiasbynens.be/) - [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") -* [John-David Dalton](http://allyoucanleet.com/) - [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") - -## Contributors - -* [Kit Cambridge](http://kitcambridge.github.com/) - [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/benchmark.js/benchmark.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/benchmark.js/benchmark.js deleted file mode 100644 index 5b63f8b..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/benchmark.js/benchmark.js +++ /dev/null @@ -1,3954 +0,0 @@ -/*! - * Benchmark.js v1.0.0 - * Copyright 2010-2012 Mathias Bynens - * Based on JSLitmus.js, copyright Robert Kieffer - * Modified by John-David Dalton - * Available under MIT license - */ -;(function(window, undefined) { - 'use strict'; - - /** Used to assign each benchmark an incrimented id */ - var counter = 0; - - /** Detect DOM document object */ - var doc = isHostType(window, 'document') && document; - - /** Detect free variable `define` */ - var freeDefine = typeof define == 'function' && - typeof define.amd == 'object' && define.amd && define; - - /** Detect free variable `exports` */ - var freeExports = typeof exports == 'object' && exports && - (typeof global == 'object' && global && global == global.global && (window = global), exports); - - /** Detect free variable `require` */ - var freeRequire = typeof require == 'function' && require; - - /** Used to crawl all properties regardless of enumerability */ - var getAllKeys = Object.getOwnPropertyNames; - - /** Used to get property descriptors */ - var getDescriptor = Object.getOwnPropertyDescriptor; - - /** Used in case an object doesn't have its own method */ - var hasOwnProperty = {}.hasOwnProperty; - - /** Used to check if an object is extensible */ - var isExtensible = Object.isExtensible || function() { return true; }; - - /** Used to access Wade Simmons' Node microtime module */ - var microtimeObject = req('microtime'); - - /** Used to access the browser's high resolution timer */ - var perfObject = isHostType(window, 'performance') && performance; - - /** Used to call the browser's high resolution timer */ - var perfName = perfObject && ( - perfObject.now && 'now' || - perfObject.webkitNow && 'webkitNow' - ); - - /** Used to access Node's high resolution timer */ - var processObject = isHostType(window, 'process') && process; - - /** Used to check if an own property is enumerable */ - var propertyIsEnumerable = {}.propertyIsEnumerable; - - /** Used to set property descriptors */ - var setDescriptor = Object.defineProperty; - - /** Used to resolve a value's internal [[Class]] */ - var toString = {}.toString; - - /** Used to prevent a `removeChild` memory leak in IE < 9 */ - var trash = doc && doc.createElement('div'); - - /** Used to integrity check compiled tests */ - var uid = 'uid' + (+new Date); - - /** Used to avoid infinite recursion when methods call each other */ - var calledBy = {}; - - /** Used to avoid hz of Infinity */ - var divisors = { - '1': 4096, - '2': 512, - '3': 64, - '4': 8, - '5': 0 - }; - - /** - * T-Distribution two-tailed critical values for 95% confidence - * http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm - */ - var tTable = { - '1': 12.706,'2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447, - '7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179, - '13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101, - '19': 2.093, '20': 2.086, '21': 2.08, '22': 2.074, '23': 2.069, '24': 2.064, - '25': 2.06, '26': 2.056, '27': 2.052, '28': 2.048, '29': 2.045, '30': 2.042, - 'infinity': 1.96 - }; - - /** - * Critical Mann-Whitney U-values for 95% confidence - * http://www.saburchill.com/IBbiology/stats/003.html - */ - var uTable = { - '5': [0, 1, 2], - '6': [1, 2, 3, 5], - '7': [1, 3, 5, 6, 8], - '8': [2, 4, 6, 8, 10, 13], - '9': [2, 4, 7, 10, 12, 15, 17], - '10': [3, 5, 8, 11, 14, 17, 20, 23], - '11': [3, 6, 9, 13, 16, 19, 23, 26, 30], - '12': [4, 7, 11, 14, 18, 22, 26, 29, 33, 37], - '13': [4, 8, 12, 16, 20, 24, 28, 33, 37, 41, 45], - '14': [5, 9, 13, 17, 22, 26, 31, 36, 40, 45, 50, 55], - '15': [5, 10, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64], - '16': [6, 11, 15, 21, 26, 31, 37, 42, 47, 53, 59, 64, 70, 75], - '17': [6, 11, 17, 22, 28, 34, 39, 45, 51, 57, 63, 67, 75, 81, 87], - '18': [7, 12, 18, 24, 30, 36, 42, 48, 55, 61, 67, 74, 80, 86, 93, 99], - '19': [7, 13, 19, 25, 32, 38, 45, 52, 58, 65, 72, 78, 85, 92, 99, 106, 113], - '20': [8, 14, 20, 27, 34, 41, 48, 55, 62, 69, 76, 83, 90, 98, 105, 112, 119, 127], - '21': [8, 15, 22, 29, 36, 43, 50, 58, 65, 73, 80, 88, 96, 103, 111, 119, 126, 134, 142], - '22': [9, 16, 23, 30, 38, 45, 53, 61, 69, 77, 85, 93, 101, 109, 117, 125, 133, 141, 150, 158], - '23': [9, 17, 24, 32, 40, 48, 56, 64, 73, 81, 89, 98, 106, 115, 123, 132, 140, 149, 157, 166, 175], - '24': [10, 17, 25, 33, 42, 50, 59, 67, 76, 85, 94, 102, 111, 120, 129, 138, 147, 156, 165, 174, 183, 192], - '25': [10, 18, 27, 35, 44, 53, 62, 71, 80, 89, 98, 107, 117, 126, 135, 145, 154, 163, 173, 182, 192, 201, 211], - '26': [11, 19, 28, 37, 46, 55, 64, 74, 83, 93, 102, 112, 122, 132, 141, 151, 161, 171, 181, 191, 200, 210, 220, 230], - '27': [11, 20, 29, 38, 48, 57, 67, 77, 87, 97, 107, 118, 125, 138, 147, 158, 168, 178, 188, 199, 209, 219, 230, 240, 250], - '28': [12, 21, 30, 40, 50, 60, 70, 80, 90, 101, 111, 122, 132, 143, 154, 164, 175, 186, 196, 207, 218, 228, 239, 250, 261, 272], - '29': [13, 22, 32, 42, 52, 62, 73, 83, 94, 105, 116, 127, 138, 149, 160, 171, 182, 193, 204, 215, 226, 238, 249, 260, 271, 282, 294], - '30': [13, 23, 33, 43, 54, 65, 76, 87, 98, 109, 120, 131, 143, 154, 166, 177, 189, 200, 212, 223, 235, 247, 258, 270, 282, 293, 305, 317] - }; - - /** - * An object used to flag environments/features. - * - * @static - * @memberOf Benchmark - * @type Object - */ - var support = {}; - - (function() { - - /** - * Detect Adobe AIR. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.air = isClassOf(window.runtime, 'ScriptBridgingProxyObject'); - - /** - * Detect if `arguments` objects have the correct internal [[Class]] value. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.argumentsClass = isClassOf(arguments, 'Arguments'); - - /** - * Detect if in a browser environment. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.browser = doc && isHostType(window, 'navigator'); - - /** - * Detect if strings support accessing characters by index. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.charByIndex = - // IE 8 supports indexes on string literals but not string objects - ('x'[0] + Object('x')[0]) == 'xx'; - - /** - * Detect if strings have indexes as own properties. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.charByOwnIndex = - // Narwhal, Rhino, RingoJS, IE 8, and Opera < 10.52 support indexes on - // strings but don't detect them as own properties - support.charByIndex && hasKey('x', '0'); - - /** - * Detect if Java is enabled/exposed. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.java = isClassOf(window.java, 'JavaPackage'); - - /** - * Detect if the Timers API exists. - * - * @memberOf Benchmark.support - * @type Boolean - */ - support.timeout = isHostType(window, 'setTimeout') && isHostType(window, 'clearTimeout'); - - /** - * Detect if functions support decompilation. - * - * @name decompilation - * @memberOf Benchmark.support - * @type Boolean - */ - try { - // Safari 2.x removes commas in object literals - // from Function#toString results - // http://webk.it/11609 - // Firefox 3.6 and Opera 9.25 strip grouping - // parentheses from Function#toString results - // http://bugzil.la/559438 - support.decompilation = Function( - 'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')' - )()(0).x === '1'; - } catch(e) { - support.decompilation = false; - } - - /** - * Detect ES5+ property descriptor API. - * - * @name descriptors - * @memberOf Benchmark.support - * @type Boolean - */ - try { - var o = {}; - support.descriptors = (setDescriptor(o, o, o), 'value' in getDescriptor(o, o)); - } catch(e) { - support.descriptors = false; - } - - /** - * Detect ES5+ Object.getOwnPropertyNames(). - * - * @name getAllKeys - * @memberOf Benchmark.support - * @type Boolean - */ - try { - support.getAllKeys = /\bvalueOf\b/.test(getAllKeys(Object.prototype)); - } catch(e) { - support.getAllKeys = false; - } - - /** - * Detect if own properties are iterated before inherited properties (all but IE < 9). - * - * @name iteratesOwnLast - * @memberOf Benchmark.support - * @type Boolean - */ - support.iteratesOwnFirst = (function() { - var props = []; - function ctor() { this.x = 1; } - ctor.prototype = { 'y': 1 }; - for (var prop in new ctor) { props.push(prop); } - return props[0] == 'x'; - }()); - - /** - * Detect if a node's [[Class]] is resolvable (all but IE < 9) - * and that the JS engine errors when attempting to coerce an object to a - * string without a `toString` property value of `typeof` "function". - * - * @name nodeClass - * @memberOf Benchmark.support - * @type Boolean - */ - try { - support.nodeClass = ({ 'toString': 0 } + '', toString.call(doc || 0) != '[object Object]'); - } catch(e) { - support.nodeClass = true; - } - }()); - - /** - * Timer object used by `clock()` and `Deferred#resolve`. - * - * @private - * @type Object - */ - var timer = { - - /** - * The timer namespace object or constructor. - * - * @private - * @memberOf timer - * @type Function|Object - */ - 'ns': Date, - - /** - * Starts the deferred timer. - * - * @private - * @memberOf timer - * @param {Object} deferred The deferred instance. - */ - 'start': null, // lazy defined in `clock()` - - /** - * Stops the deferred timer. - * - * @private - * @memberOf timer - * @param {Object} deferred The deferred instance. - */ - 'stop': null // lazy defined in `clock()` - }; - - /** Shortcut for inverse results */ - var noArgumentsClass = !support.argumentsClass, - noCharByIndex = !support.charByIndex, - noCharByOwnIndex = !support.charByOwnIndex; - - /** Math shortcuts */ - var abs = Math.abs, - floor = Math.floor, - log = Math.log, - max = Math.max, - min = Math.min, - pow = Math.pow, - sqrt = Math.sqrt; - - /*--------------------------------------------------------------------------*/ - - /** - * The Benchmark constructor. - * - * @constructor - * @param {String} name A name to identify the benchmark. - * @param {Function|String} fn The test to benchmark. - * @param {Object} [options={}] Options object. - * @example - * - * // basic usage (the `new` operator is optional) - * var bench = new Benchmark(fn); - * - * // or using a name first - * var bench = new Benchmark('foo', fn); - * - * // or with options - * var bench = new Benchmark('foo', fn, { - * - * // displayed by Benchmark#toString if `name` is not available - * 'id': 'xyz', - * - * // called when the benchmark starts running - * 'onStart': onStart, - * - * // called after each run cycle - * 'onCycle': onCycle, - * - * // called when aborted - * 'onAbort': onAbort, - * - * // called when a test errors - * 'onError': onError, - * - * // called when reset - * 'onReset': onReset, - * - * // called when the benchmark completes running - * 'onComplete': onComplete, - * - * // compiled/called before the test loop - * 'setup': setup, - * - * // compiled/called after the test loop - * 'teardown': teardown - * }); - * - * // or name and options - * var bench = new Benchmark('foo', { - * - * // a flag to indicate the benchmark is deferred - * 'defer': true, - * - * // benchmark test function - * 'fn': function(deferred) { - * // call resolve() when the deferred test is finished - * deferred.resolve(); - * } - * }); - * - * // or options only - * var bench = new Benchmark({ - * - * // benchmark name - * 'name': 'foo', - * - * // benchmark test as a string - * 'fn': '[1,2,3,4].sort()' - * }); - * - * // a test's `this` binding is set to the benchmark instance - * var bench = new Benchmark('foo', function() { - * 'My name is '.concat(this.name); // My name is foo - * }); - */ - function Benchmark(name, fn, options) { - var me = this; - - // allow instance creation without the `new` operator - if (me == null || me.constructor != Benchmark) { - return new Benchmark(name, fn, options); - } - // juggle arguments - if (isClassOf(name, 'Object')) { - // 1 argument (options) - options = name; - } - else if (isClassOf(name, 'Function')) { - // 2 arguments (fn, options) - options = fn; - fn = name; - } - else if (isClassOf(fn, 'Object')) { - // 2 arguments (name, options) - options = fn; - fn = null; - me.name = name; - } - else { - // 3 arguments (name, fn [, options]) - me.name = name; - } - setOptions(me, options); - me.id || (me.id = ++counter); - me.fn == null && (me.fn = fn); - me.stats = deepClone(me.stats); - me.times = deepClone(me.times); - } - - /** - * The Deferred constructor. - * - * @constructor - * @memberOf Benchmark - * @param {Object} clone The cloned benchmark instance. - */ - function Deferred(clone) { - var me = this; - if (me == null || me.constructor != Deferred) { - return new Deferred(clone); - } - me.benchmark = clone; - clock(me); - } - - /** - * The Event constructor. - * - * @constructor - * @memberOf Benchmark - * @param {String|Object} type The event type. - */ - function Event(type) { - var me = this; - return (me == null || me.constructor != Event) - ? new Event(type) - : (type instanceof Event) - ? type - : extend(me, { 'timeStamp': +new Date }, typeof type == 'string' ? { 'type': type } : type); - } - - /** - * The Suite constructor. - * - * @constructor - * @memberOf Benchmark - * @param {String} name A name to identify the suite. - * @param {Object} [options={}] Options object. - * @example - * - * // basic usage (the `new` operator is optional) - * var suite = new Benchmark.Suite; - * - * // or using a name first - * var suite = new Benchmark.Suite('foo'); - * - * // or with options - * var suite = new Benchmark.Suite('foo', { - * - * // called when the suite starts running - * 'onStart': onStart, - * - * // called between running benchmarks - * 'onCycle': onCycle, - * - * // called when aborted - * 'onAbort': onAbort, - * - * // called when a test errors - * 'onError': onError, - * - * // called when reset - * 'onReset': onReset, - * - * // called when the suite completes running - * 'onComplete': onComplete - * }); - */ - function Suite(name, options) { - var me = this; - - // allow instance creation without the `new` operator - if (me == null || me.constructor != Suite) { - return new Suite(name, options); - } - // juggle arguments - if (isClassOf(name, 'Object')) { - // 1 argument (options) - options = name; - } else { - // 2 arguments (name [, options]) - me.name = name; - } - setOptions(me, options); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Note: Some array methods have been implemented in plain JavaScript to avoid - * bugs in IE, Opera, Rhino, and Mobile Safari. - * - * IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()` - * functions that fail to remove the last element, `object[0]`, of - * array-like-objects even though the `length` property is set to `0`. - * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()` - * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9. - * - * In Opera < 9.50 and some older/beta Mobile Safari versions using `unshift()` - * generically to augment the `arguments` object will pave the value at index 0 - * without incrimenting the other values's indexes. - * https://github.com/documentcloud/underscore/issues/9 - * - * Rhino and environments it powers, like Narwhal and RingoJS, may have - * buggy Array `concat()`, `reverse()`, `shift()`, `slice()`, `splice()` and - * `unshift()` functions that make sparse arrays non-sparse by assigning the - * undefined indexes a value of undefined. - * https://github.com/mozilla/rhino/commit/702abfed3f8ca043b2636efd31c14ba7552603dd - */ - - /** - * Creates an array containing the elements of the host array followed by the - * elements of each argument in order. - * - * @memberOf Benchmark.Suite - * @returns {Array} The new array. - */ - function concat() { - var value, - j = -1, - length = arguments.length, - result = slice.call(this), - index = result.length; - - while (++j < length) { - value = arguments[j]; - if (isClassOf(value, 'Array')) { - for (var k = 0, l = value.length; k < l; k++, index++) { - if (k in value) { - result[index] = value[k]; - } - } - } else { - result[index++] = value; - } - } - return result; - } - - /** - * Utility function used by `shift()`, `splice()`, and `unshift()`. - * - * @private - * @param {Number} start The index to start inserting elements. - * @param {Number} deleteCount The number of elements to delete from the insert point. - * @param {Array} elements The elements to insert. - * @returns {Array} An array of deleted elements. - */ - function insert(start, deleteCount, elements) { - // `result` should have its length set to the `deleteCount` - // see https://bugs.ecmascript.org/show_bug.cgi?id=332 - var deleteEnd = start + deleteCount, - elementCount = elements ? elements.length : 0, - index = start - 1, - length = start + elementCount, - object = this, - result = Array(deleteCount), - tail = slice.call(object, deleteEnd); - - // delete elements from the array - while (++index < deleteEnd) { - if (index in object) { - result[index - start] = object[index]; - delete object[index]; - } - } - // insert elements - index = start - 1; - while (++index < length) { - object[index] = elements[index - start]; - } - // append tail elements - start = index--; - length = max(0, (object.length >>> 0) - deleteCount + elementCount); - while (++index < length) { - if ((index - start) in tail) { - object[index] = tail[index - start]; - } else if (index in object) { - delete object[index]; - } - } - // delete excess elements - deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0; - while (deleteCount--) { - index = length + deleteCount; - if (index in object) { - delete object[index]; - } - } - object.length = length; - return result; - } - - /** - * Rearrange the host array's elements in reverse order. - * - * @memberOf Benchmark.Suite - * @returns {Array} The reversed array. - */ - function reverse() { - var upperIndex, - value, - index = -1, - object = Object(this), - length = object.length >>> 0, - middle = floor(length / 2); - - if (length > 1) { - while (++index < middle) { - upperIndex = length - index - 1; - value = upperIndex in object ? object[upperIndex] : uid; - if (index in object) { - object[upperIndex] = object[index]; - } else { - delete object[upperIndex]; - } - if (value != uid) { - object[index] = value; - } else { - delete object[index]; - } - } - } - return object; - } - - /** - * Removes the first element of the host array and returns it. - * - * @memberOf Benchmark.Suite - * @returns {Mixed} The first element of the array. - */ - function shift() { - return insert.call(this, 0, 1)[0]; - } - - /** - * Creates an array of the host array's elements from the start index up to, - * but not including, the end index. - * - * @memberOf Benchmark.Suite - * @param {Number} start The starting index. - * @param {Number} end The end index. - * @returns {Array} The new array. - */ - function slice(start, end) { - var index = -1, - object = Object(this), - length = object.length >>> 0, - result = []; - - start = toInteger(start); - start = start < 0 ? max(length + start, 0) : min(start, length); - start--; - end = end == null ? length : toInteger(end); - end = end < 0 ? max(length + end, 0) : min(end, length); - - while ((++index, ++start) < end) { - if (start in object) { - result[index] = object[start]; - } - } - return result; - } - - /** - * Allows removing a range of elements and/or inserting elements into the - * host array. - * - * @memberOf Benchmark.Suite - * @param {Number} start The start index. - * @param {Number} deleteCount The number of elements to delete. - * @param {Mixed} [val1, val2, ...] values to insert at the `start` index. - * @returns {Array} An array of removed elements. - */ - function splice(start, deleteCount) { - var object = Object(this), - length = object.length >>> 0; - - start = toInteger(start); - start = start < 0 ? max(length + start, 0) : min(start, length); - - // support the de-facto SpiderMonkey extension - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice#Parameters - // https://bugs.ecmascript.org/show_bug.cgi?id=429 - deleteCount = arguments.length == 1 - ? length - start - : min(max(toInteger(deleteCount), 0), length - start); - - return insert.call(object, start, deleteCount, slice.call(arguments, 2)); - } - - /** - * Converts the specified `value` to an integer. - * - * @private - * @param {Mixed} value The value to convert. - * @returns {Number} The resulting integer. - */ - function toInteger(value) { - value = +value; - return value === 0 || !isFinite(value) ? value || 0 : value - (value % 1); - } - - /** - * Appends arguments to the host array. - * - * @memberOf Benchmark.Suite - * @returns {Number} The new length. - */ - function unshift() { - var object = Object(this); - insert.call(object, 0, 0, arguments); - return object.length; - } - - /*--------------------------------------------------------------------------*/ - - /** - * A generic `Function#bind` like method. - * - * @private - * @param {Function} fn The function to be bound to `thisArg`. - * @param {Mixed} thisArg The `this` binding for the given function. - * @returns {Function} The bound function. - */ - function bind(fn, thisArg) { - return function() { fn.apply(thisArg, arguments); }; - } - - /** - * Creates a function from the given arguments string and body. - * - * @private - * @param {String} args The comma separated function arguments. - * @param {String} body The function body. - * @returns {Function} The new function. - */ - function createFunction() { - // lazy define - createFunction = function(args, body) { - var result, - anchor = freeDefine ? define.amd : Benchmark, - prop = uid + 'createFunction'; - - runScript((freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '=function(' + args + '){' + body + '}'); - result = anchor[prop]; - delete anchor[prop]; - return result; - }; - // fix JaegerMonkey bug - // http://bugzil.la/639720 - createFunction = support.browser && (createFunction('', 'return"' + uid + '"') || noop)() == uid ? createFunction : Function; - return createFunction.apply(null, arguments); - } - - /** - * Delay the execution of a function based on the benchmark's `delay` property. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} fn The function to execute. - */ - function delay(bench, fn) { - bench._timerId = setTimeout(fn, bench.delay * 1e3); - } - - /** - * Destroys the given element. - * - * @private - * @param {Element} element The element to destroy. - */ - function destroyElement(element) { - trash.appendChild(element); - trash.innerHTML = ''; - } - - /** - * Iterates over an object's properties, executing the `callback` for each. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} callback The function executed per own property. - * @param {Object} options The options object. - * @returns {Object} Returns the object iterated over. - */ - function forProps() { - var forShadowed, - skipSeen, - forArgs = true, - shadowed = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']; - - (function(enumFlag, key) { - // must use a non-native constructor to catch the Safari 2 issue - function Klass() { this.valueOf = 0; }; - Klass.prototype.valueOf = 0; - // check various for-in bugs - for (key in new Klass) { - enumFlag += key == 'valueOf' ? 1 : 0; - } - // check if `arguments` objects have non-enumerable indexes - for (key in arguments) { - key == '0' && (forArgs = false); - } - // Safari 2 iterates over shadowed properties twice - // http://replay.waybackmachine.org/20090428222941/http://tobielangel.com/2007/1/29/for-in-loop-broken-in-safari/ - skipSeen = enumFlag == 2; - // IE < 9 incorrectly makes an object's properties non-enumerable if they have - // the same name as other non-enumerable properties in its prototype chain. - forShadowed = !enumFlag; - }(0)); - - // lazy define - forProps = function(object, callback, options) { - options || (options = {}); - - var result = object; - object = Object(object); - - var ctor, - key, - keys, - skipCtor, - done = !result, - which = options.which, - allFlag = which == 'all', - index = -1, - iteratee = object, - length = object.length, - ownFlag = allFlag || which == 'own', - seen = {}, - skipProto = isClassOf(object, 'Function'), - thisArg = options.bind; - - if (thisArg !== undefined) { - callback = bind(callback, thisArg); - } - // iterate all properties - if (allFlag && support.getAllKeys) { - for (index = 0, keys = getAllKeys(object), length = keys.length; index < length; index++) { - key = keys[index]; - if (callback(object[key], key, object) === false) { - break; - } - } - } - // else iterate only enumerable properties - else { - for (key in object) { - // Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 - // (if the prototype or a property on the prototype has been set) - // incorrectly set a function's `prototype` property [[Enumerable]] value - // to `true`. Because of this we standardize on skipping the `prototype` - // property of functions regardless of their [[Enumerable]] value. - if ((done = - !(skipProto && key == 'prototype') && - !(skipSeen && (hasKey(seen, key) || !(seen[key] = true))) && - (!ownFlag || ownFlag && hasKey(object, key)) && - callback(object[key], key, object) === false)) { - break; - } - } - // in IE < 9 strings don't support accessing characters by index - if (!done && (forArgs && isArguments(object) || - ((noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String') && - (iteratee = noCharByIndex ? object.split('') : object)))) { - while (++index < length) { - if ((done = - callback(iteratee[index], String(index), object) === false)) { - break; - } - } - } - if (!done && forShadowed) { - // Because IE < 9 can't set the `[[Enumerable]]` attribute of an existing - // property and the `constructor` property of a prototype defaults to - // non-enumerable, we manually skip the `constructor` property when we - // think we are iterating over a `prototype` object. - ctor = object.constructor; - skipCtor = ctor && ctor.prototype && ctor.prototype.constructor === ctor; - for (index = 0; index < 7; index++) { - key = shadowed[index]; - if (!(skipCtor && key == 'constructor') && - hasKey(object, key) && - callback(object[key], key, object) === false) { - break; - } - } - } - } - return result; - }; - return forProps.apply(null, arguments); - } - - /** - * Gets the name of the first argument from a function's source. - * - * @private - * @param {Function} fn The function. - * @returns {String} The argument name. - */ - function getFirstArgument(fn) { - return (!hasKey(fn, 'toString') && - (/^[\s(]*function[^(]*\(([^\s,)]+)/.exec(fn) || 0)[1]) || ''; - } - - /** - * Computes the geometric mean (log-average) of a sample. - * See http://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms. - * - * @private - * @param {Array} sample The sample. - * @returns {Number} The geometric mean. - */ - function getGeometricMean(sample) { - return pow(Math.E, reduce(sample, function(sum, x) { - return sum + log(x); - }) / sample.length) || 0; - } - - /** - * Computes the arithmetic mean of a sample. - * - * @private - * @param {Array} sample The sample. - * @returns {Number} The mean. - */ - function getMean(sample) { - return (reduce(sample, function(sum, x) { - return sum + x; - }) / sample.length) || 0; - } - - /** - * Gets the source code of a function. - * - * @private - * @param {Function} fn The function. - * @param {String} altSource A string used when a function's source code is unretrievable. - * @returns {String} The function's source code. - */ - function getSource(fn, altSource) { - var result = altSource; - if (isStringable(fn)) { - result = String(fn); - } else if (support.decompilation) { - // escape the `{` for Firefox 1 - result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1]; - } - // trim string - result = (result || '').replace(/^\s+|\s+$/g, ''); - - // detect strings containing only the "use strict" directive - return /^(?:\/\*+[\w|\W]*?\*\/|\/\/.*?[\n\r\u2028\u2029]|\s)*(["'])use strict\1;?$/.test(result) - ? '' - : result; - } - - /** - * Checks if a value is an `arguments` object. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the value is an `arguments` object, else `false`. - */ - function isArguments() { - // lazy define - isArguments = function(value) { - return toString.call(value) == '[object Arguments]'; - }; - if (noArgumentsClass) { - isArguments = function(value) { - return hasKey(value, 'callee') && - !(propertyIsEnumerable && propertyIsEnumerable.call(value, 'callee')); - }; - } - return isArguments(arguments[0]); - } - - /** - * Checks if an object is of the specified class. - * - * @private - * @param {Mixed} value The value to check. - * @param {String} name The name of the class. - * @returns {Boolean} Returns `true` if the value is of the specified class, else `false`. - */ - function isClassOf(value, name) { - return value != null && toString.call(value) == '[object ' + name + ']'; - } - - /** - * Host objects can return type values that are different from their actual - * data type. The objects we are concerned with usually return non-primitive - * types of object, function, or unknown. - * - * @private - * @param {Mixed} object The owner of the property. - * @param {String} property The property to check. - * @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`. - */ - function isHostType(object, property) { - var type = object != null ? typeof object[property] : 'number'; - return !/^(?:boolean|number|string|undefined)$/.test(type) && - (type == 'object' ? !!object[property] : true); - } - - /** - * Checks if a given `value` is an object created by the `Object` constructor - * assuming objects created by the `Object` constructor have no inherited - * enumerable properties and that there are no `Object.prototype` extensions. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, else `false`. - */ - function isPlainObject(value) { - // avoid non-objects and false positives for `arguments` objects in IE < 9 - var result = false; - if (!(value && typeof value == 'object') || isArguments(value)) { - return result; - } - // IE < 9 presents DOM nodes as `Object` objects except they have `toString` - // methods that are `typeof` "string" and still can coerce nodes to strings. - // Also check that the constructor is `Object` (i.e. `Object instanceof Object`) - var ctor = value.constructor; - if ((support.nodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) && - (!isClassOf(ctor, 'Function') || ctor instanceof ctor)) { - // In most environments an object's own properties are iterated before - // its inherited properties. If the last iterated property is an object's - // own property then there are no inherited enumerable properties. - if (support.iteratesOwnFirst) { - forProps(value, function(subValue, subKey) { - result = subKey; - }); - return result === false || hasKey(value, result); - } - // IE < 9 iterates inherited properties before own properties. If the first - // iterated property is an object's own property then there are no inherited - // enumerable properties. - forProps(value, function(subValue, subKey) { - result = !hasKey(value, subKey); - return false; - }); - return result === false; - } - return result; - } - - /** - * Checks if a value can be safely coerced to a string. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if the value can be coerced, else `false`. - */ - function isStringable(value) { - return hasKey(value, 'toString') || isClassOf(value, 'String'); - } - - /** - * Wraps a function and passes `this` to the original function as the - * first argument. - * - * @private - * @param {Function} fn The function to be wrapped. - * @returns {Function} The new function. - */ - function methodize(fn) { - return function() { - var args = [this]; - args.push.apply(args, arguments); - return fn.apply(null, args); - }; - } - - /** - * A no-operation function. - * - * @private - */ - function noop() { - // no operation performed - } - - /** - * A wrapper around require() to suppress `module missing` errors. - * - * @private - * @param {String} id The module id. - * @returns {Mixed} The exported module or `null`. - */ - function req(id) { - try { - var result = freeExports && freeRequire(id); - } catch(e) { } - return result || null; - } - - /** - * Runs a snippet of JavaScript via script injection. - * - * @private - * @param {String} code The code to run. - */ - function runScript(code) { - var anchor = freeDefine ? define.amd : Benchmark, - script = doc.createElement('script'), - sibling = doc.getElementsByTagName('script')[0], - parent = sibling.parentNode, - prop = uid + 'runScript', - prefix = '(' + (freeDefine ? 'define.amd.' : 'Benchmark.') + prop + '||function(){})();'; - - // Firefox 2.0.0.2 cannot use script injection as intended because it executes - // asynchronously, but that's OK because script injection is only used to avoid - // the previously commented JaegerMonkey bug. - try { - // remove the inserted script *before* running the code to avoid differences - // in the expected script element count/order of the document. - script.appendChild(doc.createTextNode(prefix + code)); - anchor[prop] = function() { destroyElement(script); }; - } catch(e) { - parent = parent.cloneNode(false); - sibling = null; - script.text = code; - } - parent.insertBefore(script, sibling); - delete anchor[prop]; - } - - /** - * A helper function for setting options/event handlers. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} [options={}] Options object. - */ - function setOptions(bench, options) { - options = extend({}, bench.constructor.options, options); - bench.options = forOwn(options, function(value, key) { - if (value != null) { - // add event listeners - if (/^on[A-Z]/.test(key)) { - forEach(key.split(' '), function(key) { - bench.on(key.slice(2).toLowerCase(), value); - }); - } else if (!hasKey(bench, key)) { - bench[key] = deepClone(value); - } - } - }); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Handles cycling/completing the deferred benchmark. - * - * @memberOf Benchmark.Deferred - */ - function resolve() { - var me = this, - clone = me.benchmark, - bench = clone._original; - - if (bench.aborted) { - // cycle() -> clone cycle/complete event -> compute()'s invoked bench.run() cycle/complete - me.teardown(); - clone.running = false; - cycle(me); - } - else if (++me.cycles < clone.count) { - // continue the test loop - if (support.timeout) { - // use setTimeout to avoid a call stack overflow if called recursively - setTimeout(function() { clone.compiled.call(me, timer); }, 0); - } else { - clone.compiled.call(me, timer); - } - } - else { - timer.stop(me); - me.teardown(); - delay(clone, function() { cycle(me); }); - } - } - - /*--------------------------------------------------------------------------*/ - - /** - * A deep clone utility. - * - * @static - * @memberOf Benchmark - * @param {Mixed} value The value to clone. - * @returns {Mixed} The cloned value. - */ - function deepClone(value) { - var accessor, - circular, - clone, - ctor, - descriptor, - extensible, - key, - length, - markerKey, - parent, - result, - source, - subIndex, - data = { 'value': value }, - index = 0, - marked = [], - queue = { 'length': 0 }, - unmarked = []; - - /** - * An easily detectable decorator for cloned values. - */ - function Marker(object) { - this.raw = object; - } - - /** - * The callback used by `forProps()`. - */ - function forPropsCallback(subValue, subKey) { - // exit early to avoid cloning the marker - if (subValue && subValue.constructor == Marker) { - return; - } - // add objects to the queue - if (subValue === Object(subValue)) { - queue[queue.length++] = { 'key': subKey, 'parent': clone, 'source': value }; - } - // assign non-objects - else { - try { - // will throw an error in strict mode if the property is read-only - clone[subKey] = subValue; - } catch(e) { } - } - } - - /** - * Gets an available marker key for the given object. - */ - function getMarkerKey(object) { - // avoid collisions with existing keys - var result = uid; - while (object[result] && object[result].constructor != Marker) { - result += 1; - } - return result; - } - - do { - key = data.key; - parent = data.parent; - source = data.source; - clone = value = source ? source[key] : data.value; - accessor = circular = descriptor = false; - - // create a basic clone to filter out functions, DOM elements, and - // other non `Object` objects - if (value === Object(value)) { - // use custom deep clone function if available - if (isClassOf(value.deepClone, 'Function')) { - clone = value.deepClone(); - } else { - ctor = value.constructor; - switch (toString.call(value)) { - case '[object Array]': - clone = new ctor(value.length); - break; - - case '[object Boolean]': - clone = new ctor(value == true); - break; - - case '[object Date]': - clone = new ctor(+value); - break; - - case '[object Object]': - isPlainObject(value) && (clone = {}); - break; - - case '[object Number]': - case '[object String]': - clone = new ctor(value); - break; - - case '[object RegExp]': - clone = ctor(value.source, - (value.global ? 'g' : '') + - (value.ignoreCase ? 'i' : '') + - (value.multiline ? 'm' : '')); - } - } - // continue clone if `value` doesn't have an accessor descriptor - // http://es5.github.com/#x8.10.1 - if (clone && clone != value && - !(descriptor = source && support.descriptors && getDescriptor(source, key), - accessor = descriptor && (descriptor.get || descriptor.set))) { - // use an existing clone (circular reference) - if ((extensible = isExtensible(value))) { - markerKey = getMarkerKey(value); - if (value[markerKey]) { - circular = clone = value[markerKey].raw; - } - } else { - // for frozen/sealed objects - for (subIndex = 0, length = unmarked.length; subIndex < length; subIndex++) { - data = unmarked[subIndex]; - if (data.object === value) { - circular = clone = data.clone; - break; - } - } - } - if (!circular) { - // mark object to allow quickly detecting circular references and tie it to its clone - if (extensible) { - value[markerKey] = new Marker(clone); - marked.push({ 'key': markerKey, 'object': value }); - } else { - // for frozen/sealed objects - unmarked.push({ 'clone': clone, 'object': value }); - } - // iterate over object properties - forProps(value, forPropsCallback, { 'which': 'all' }); - } - } - } - if (parent) { - // for custom property descriptors - if (accessor || (descriptor && !(descriptor.configurable && descriptor.enumerable && descriptor.writable))) { - if ('value' in descriptor) { - descriptor.value = clone; - } - setDescriptor(parent, key, descriptor); - } - // for default property descriptors - else { - parent[key] = clone; - } - } else { - result = clone; - } - } while ((data = queue[index++])); - - // remove markers - for (index = 0, length = marked.length; index < length; index++) { - data = marked[index]; - delete data.object[data.key]; - } - return result; - } - - /** - * An iteration utility for arrays and objects. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Array|Object} object The object to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array|Object} Returns the object iterated over. - */ - function each(object, callback, thisArg) { - var result = object; - object = Object(object); - - var fn = callback, - index = -1, - length = object.length, - isSnapshot = !!(object.snapshotItem && (length = object.snapshotLength)), - isSplittable = (noCharByIndex || noCharByOwnIndex) && isClassOf(object, 'String'), - isConvertable = isSnapshot || isSplittable || 'item' in object, - origObject = object; - - // in Opera < 10.5 `hasKey(object, 'length')` returns `false` for NodeLists - if (length === length >>> 0) { - if (isConvertable) { - // the third argument of the callback is the original non-array object - callback = function(value, index) { - return fn.call(this, value, index, origObject); - }; - // in IE < 9 strings don't support accessing characters by index - if (isSplittable) { - object = object.split(''); - } else { - object = []; - while (++index < length) { - // in Safari 2 `index in object` is always `false` for NodeLists - object[index] = isSnapshot ? result.snapshotItem(index) : result[index]; - } - } - } - forEach(object, callback, thisArg); - } else { - forOwn(object, callback, thisArg); - } - return result; - } - - /** - * Copies enumerable properties from the source(s) object to the destination object. - * - * @static - * @memberOf Benchmark - * @param {Object} destination The destination object. - * @param {Object} [source={}] The source object. - * @returns {Object} The destination object. - */ - function extend(destination, source) { - // Chrome < 14 incorrectly sets `destination` to `undefined` when we `delete arguments[0]` - // http://code.google.com/p/v8/issues/detail?id=839 - var result = destination; - delete arguments[0]; - - forEach(arguments, function(source) { - forProps(source, function(value, key) { - result[key] = value; - }); - }); - return result; - } - - /** - * A generic `Array#filter` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function|String} callback The function/alias called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} A new array of values that passed callback filter. - * @example - * - * // get odd numbers - * Benchmark.filter([1, 2, 3, 4, 5], function(n) { - * return n % 2; - * }); // -> [1, 3, 5]; - * - * // get fastest benchmarks - * Benchmark.filter(benches, 'fastest'); - * - * // get slowest benchmarks - * Benchmark.filter(benches, 'slowest'); - * - * // get benchmarks that completed without erroring - * Benchmark.filter(benches, 'successful'); - */ - function filter(array, callback, thisArg) { - var result; - - if (callback == 'successful') { - // callback to exclude those that are errored, unrun, or have hz of Infinity - callback = function(bench) { return bench.cycles && isFinite(bench.hz); }; - } - else if (callback == 'fastest' || callback == 'slowest') { - // get successful, sort by period + margin of error, and filter fastest/slowest - result = filter(array, 'successful').sort(function(a, b) { - a = a.stats; b = b.stats; - return (a.mean + a.moe > b.mean + b.moe ? 1 : -1) * (callback == 'fastest' ? 1 : -1); - }); - result = filter(result, function(bench) { - return result[0].compare(bench) == 0; - }); - } - return result || reduce(array, function(result, value, index) { - return callback.call(thisArg, value, index, array) ? (result.push(value), result) : result; - }, []); - } - - /** - * A generic `Array#forEach` like method. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} Returns the array iterated over. - */ - function forEach(array, callback, thisArg) { - var index = -1, - length = (array = Object(array)).length >>> 0; - - if (thisArg !== undefined) { - callback = bind(callback, thisArg); - } - while (++index < length) { - if (index in array && - callback(array[index], index, array) === false) { - break; - } - } - return array; - } - - /** - * Iterates over an object's own properties, executing the `callback` for each. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @static - * @memberOf Benchmark - * @param {Object} object The object to iterate over. - * @param {Function} callback The function executed per own property. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Object} Returns the object iterated over. - */ - function forOwn(object, callback, thisArg) { - return forProps(object, callback, { 'bind': thisArg, 'which': 'own' }); - } - - /** - * Converts a number to a more readable comma-separated string representation. - * - * @static - * @memberOf Benchmark - * @param {Number} number The number to convert. - * @returns {String} The more readable string representation. - */ - function formatNumber(number) { - number = String(number).split('.'); - return number[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ',') + - (number[1] ? '.' + number[1] : ''); - } - - /** - * Checks if an object has the specified key as a direct property. - * - * @static - * @memberOf Benchmark - * @param {Object} object The object to check. - * @param {String} key The key to check for. - * @returns {Boolean} Returns `true` if key is a direct property, else `false`. - */ - function hasKey() { - // lazy define for worst case fallback (not as accurate) - hasKey = function(object, key) { - var parent = object != null && (object.constructor || Object).prototype; - return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]); - }; - // for modern browsers - if (isClassOf(hasOwnProperty, 'Function')) { - hasKey = function(object, key) { - return object != null && hasOwnProperty.call(object, key); - }; - } - // for Safari 2 - else if ({}.__proto__ == Object.prototype) { - hasKey = function(object, key) { - var result = false; - if (object != null) { - object = Object(object); - object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0]; - } - return result; - }; - } - return hasKey.apply(this, arguments); - } - - /** - * A generic `Array#indexOf` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Mixed} value The value to search for. - * @param {Number} [fromIndex=0] The index to start searching from. - * @returns {Number} The index of the matched value or `-1`. - */ - function indexOf(array, value, fromIndex) { - var index = toInteger(fromIndex), - length = (array = Object(array)).length >>> 0; - - index = (index < 0 ? max(0, length + index) : index) - 1; - while (++index < length) { - if (index in array && value === array[index]) { - return index; - } - } - return -1; - } - - /** - * Modify a string by replacing named tokens with matching object property values. - * - * @static - * @memberOf Benchmark - * @param {String} string The string to modify. - * @param {Object} object The template object. - * @returns {String} The modified string. - */ - function interpolate(string, object) { - forOwn(object, function(value, key) { - // escape regexp special characters in `key` - string = string.replace(RegExp('#\\{' + key.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1') + '\\}', 'g'), value); - }); - return string; - } - - /** - * Invokes a method on all items in an array. - * - * @static - * @memberOf Benchmark - * @param {Array} benches Array of benchmarks to iterate over. - * @param {String|Object} name The name of the method to invoke OR options object. - * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. - * @returns {Array} A new array of values returned from each method invoked. - * @example - * - * // invoke `reset` on all benchmarks - * Benchmark.invoke(benches, 'reset'); - * - * // invoke `emit` with arguments - * Benchmark.invoke(benches, 'emit', 'complete', listener); - * - * // invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks - * Benchmark.invoke(benches, { - * - * // invoke the `run` method - * 'name': 'run', - * - * // pass a single argument - * 'args': true, - * - * // treat as queue, removing benchmarks from front of `benches` until empty - * 'queued': true, - * - * // called before any benchmarks have been invoked. - * 'onStart': onStart, - * - * // called between invoking benchmarks - * 'onCycle': onCycle, - * - * // called after all benchmarks have been invoked. - * 'onComplete': onComplete - * }); - */ - function invoke(benches, name) { - var args, - bench, - queued, - index = -1, - eventProps = { 'currentTarget': benches }, - options = { 'onStart': noop, 'onCycle': noop, 'onComplete': noop }, - result = map(benches, function(bench) { return bench; }); - - /** - * Invokes the method of the current object and if synchronous, fetches the next. - */ - function execute() { - var listeners, - async = isAsync(bench); - - if (async) { - // use `getNext` as the first listener - bench.on('complete', getNext); - listeners = bench.events.complete; - listeners.splice(0, 0, listeners.pop()); - } - // execute method - result[index] = isClassOf(bench && bench[name], 'Function') ? bench[name].apply(bench, args) : undefined; - // if synchronous return true until finished - return !async && getNext(); - } - - /** - * Fetches the next bench or executes `onComplete` callback. - */ - function getNext(event) { - var cycleEvent, - last = bench, - async = isAsync(last); - - if (async) { - last.off('complete', getNext); - last.emit('complete'); - } - // emit "cycle" event - eventProps.type = 'cycle'; - eventProps.target = last; - cycleEvent = Event(eventProps); - options.onCycle.call(benches, cycleEvent); - - // choose next benchmark if not exiting early - if (!cycleEvent.aborted && raiseIndex() !== false) { - bench = queued ? benches[0] : result[index]; - if (isAsync(bench)) { - delay(bench, execute); - } - else if (async) { - // resume execution if previously asynchronous but now synchronous - while (execute()) { } - } - else { - // continue synchronous execution - return true; - } - } else { - // emit "complete" event - eventProps.type = 'complete'; - options.onComplete.call(benches, Event(eventProps)); - } - // When used as a listener `event.aborted = true` will cancel the rest of - // the "complete" listeners because they were already called above and when - // used as part of `getNext` the `return false` will exit the execution while-loop. - if (event) { - event.aborted = true; - } else { - return false; - } - } - - /** - * Checks if invoking `Benchmark#run` with asynchronous cycles. - */ - function isAsync(object) { - // avoid using `instanceof` here because of IE memory leak issues with host objects - var async = args[0] && args[0].async; - return Object(object).constructor == Benchmark && name == 'run' && - ((async == null ? object.options.async : async) && support.timeout || object.defer); - } - - /** - * Raises `index` to the next defined index or returns `false`. - */ - function raiseIndex() { - var length = result.length; - if (queued) { - // if queued remove the previous bench and subsequent skipped non-entries - do { - ++index > 0 && shift.call(benches); - } while ((length = benches.length) && !('0' in benches)); - } - else { - while (++index < length && !(index in result)) { } - } - // if we reached the last index then return `false` - return (queued ? length : index < length) ? index : (index = false); - } - - // juggle arguments - if (isClassOf(name, 'String')) { - // 2 arguments (array, name) - args = slice.call(arguments, 2); - } else { - // 2 arguments (array, options) - options = extend(options, name); - name = options.name; - args = isClassOf(args = 'args' in options ? options.args : [], 'Array') ? args : [args]; - queued = options.queued; - } - - // start iterating over the array - if (raiseIndex() !== false) { - // emit "start" event - bench = result[index]; - eventProps.type = 'start'; - eventProps.target = bench; - options.onStart.call(benches, Event(eventProps)); - - // end early if the suite was aborted in an "onStart" listener - if (benches.aborted && benches.constructor == Suite && name == 'run') { - // emit "cycle" event - eventProps.type = 'cycle'; - options.onCycle.call(benches, Event(eventProps)); - // emit "complete" event - eventProps.type = 'complete'; - options.onComplete.call(benches, Event(eventProps)); - } - // else start - else { - if (isAsync(bench)) { - delay(bench, execute); - } else { - while (execute()) { } - } - } - } - return result; - } - - /** - * Creates a string of joined array values or object key-value pairs. - * - * @static - * @memberOf Benchmark - * @param {Array|Object} object The object to operate on. - * @param {String} [separator1=','] The separator used between key-value pairs. - * @param {String} [separator2=': '] The separator used between keys and values. - * @returns {String} The joined result. - */ - function join(object, separator1, separator2) { - var result = [], - length = (object = Object(object)).length, - arrayLike = length === length >>> 0; - - separator2 || (separator2 = ': '); - each(object, function(value, key) { - result.push(arrayLike ? value : key + separator2 + value); - }); - return result.join(separator1 || ','); - } - - /** - * A generic `Array#map` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} thisArg The `this` binding for the callback. - * @returns {Array} A new array of values returned by the callback. - */ - function map(array, callback, thisArg) { - return reduce(array, function(result, value, index) { - result[index] = callback.call(thisArg, value, index, array); - return result; - }, Array(Object(array).length >>> 0)); - } - - /** - * Retrieves the value of a specified property from all items in an array. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {String} property The property to pluck. - * @returns {Array} A new array of property values. - */ - function pluck(array, property) { - return map(array, function(object) { - return object == null ? undefined : object[property]; - }); - } - - /** - * A generic `Array#reduce` like method. - * - * @static - * @memberOf Benchmark - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} accumulator Initial value of the accumulator. - * @returns {Mixed} The accumulator. - */ - function reduce(array, callback, accumulator) { - var noaccum = arguments.length < 3; - forEach(array, function(value, index) { - accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, array); - }); - return accumulator; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Aborts all benchmarks in the suite. - * - * @name abort - * @memberOf Benchmark.Suite - * @returns {Object} The suite instance. - */ - function abortSuite() { - var event, - me = this, - resetting = calledBy.resetSuite; - - if (me.running) { - event = Event('abort'); - me.emit(event); - if (!event.cancelled || resetting) { - // avoid infinite recursion - calledBy.abortSuite = true; - me.reset(); - delete calledBy.abortSuite; - - if (!resetting) { - me.aborted = true; - invoke(me, 'abort'); - } - } - } - return me; - } - - /** - * Adds a test to the benchmark suite. - * - * @memberOf Benchmark.Suite - * @param {String} name A name to identify the benchmark. - * @param {Function|String} fn The test to benchmark. - * @param {Object} [options={}] Options object. - * @returns {Object} The benchmark instance. - * @example - * - * // basic usage - * suite.add(fn); - * - * // or using a name first - * suite.add('foo', fn); - * - * // or with options - * suite.add('foo', fn, { - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - * - * // or name and options - * suite.add('foo', { - * 'fn': fn, - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - * - * // or options only - * suite.add({ - * 'name': 'foo', - * 'fn': fn, - * 'onCycle': onCycle, - * 'onComplete': onComplete - * }); - */ - function add(name, fn, options) { - var me = this, - bench = Benchmark(name, fn, options), - event = Event({ 'type': 'add', 'target': bench }); - - if (me.emit(event), !event.cancelled) { - me.push(bench); - } - return me; - } - - /** - * Creates a new suite with cloned benchmarks. - * - * @name clone - * @memberOf Benchmark.Suite - * @param {Object} options Options object to overwrite cloned options. - * @returns {Object} The new suite instance. - */ - function cloneSuite(options) { - var me = this, - result = new me.constructor(extend({}, me.options, options)); - - // copy own properties - forOwn(me, function(value, key) { - if (!hasKey(result, key)) { - result[key] = value && isClassOf(value.clone, 'Function') - ? value.clone() - : deepClone(value); - } - }); - return result; - } - - /** - * An `Array#filter` like method. - * - * @name filter - * @memberOf Benchmark.Suite - * @param {Function|String} callback The function/alias called per iteration. - * @returns {Object} A new suite of benchmarks that passed callback filter. - */ - function filterSuite(callback) { - var me = this, - result = new me.constructor; - - result.push.apply(result, filter(me, callback)); - return result; - } - - /** - * Resets all benchmarks in the suite. - * - * @name reset - * @memberOf Benchmark.Suite - * @returns {Object} The suite instance. - */ - function resetSuite() { - var event, - me = this, - aborting = calledBy.abortSuite; - - if (me.running && !aborting) { - // no worries, `resetSuite()` is called within `abortSuite()` - calledBy.resetSuite = true; - me.abort(); - delete calledBy.resetSuite; - } - // reset if the state has changed - else if ((me.aborted || me.running) && - (me.emit(event = Event('reset')), !event.cancelled)) { - me.running = false; - if (!aborting) { - invoke(me, 'reset'); - } - } - return me; - } - - /** - * Runs the suite. - * - * @name run - * @memberOf Benchmark.Suite - * @param {Object} [options={}] Options object. - * @returns {Object} The suite instance. - * @example - * - * // basic usage - * suite.run(); - * - * // or with options - * suite.run({ 'async': true, 'queued': true }); - */ - function runSuite(options) { - var me = this; - - me.reset(); - me.running = true; - options || (options = {}); - - invoke(me, { - 'name': 'run', - 'args': options, - 'queued': options.queued, - 'onStart': function(event) { - me.emit(event); - }, - 'onCycle': function(event) { - var bench = event.target; - if (bench.error) { - me.emit({ 'type': 'error', 'target': bench }); - } - me.emit(event); - event.aborted = me.aborted; - }, - 'onComplete': function(event) { - me.score = getGeometricMean(map(me, function(bench) { - return bench.reference / (bench.times.period * 1e6); - })) || 0; - - me.running = false; - me.emit(event); - } - }); - return me; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Executes all registered listeners of the specified event type. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String|Object} type The event type or object. - * @returns {Mixed} Returns the return value of the last listener executed. - */ - function emit(type) { - var listeners, - me = this, - event = Event(type), - events = me.events, - args = (arguments[0] = event, arguments); - - event.currentTarget || (event.currentTarget = me); - event.target || (event.target = me); - delete event.result; - - if (events && (listeners = hasKey(events, event.type) && events[event.type])) { - forEach(listeners.slice(), function(listener) { - if ((event.result = listener.apply(me, args)) === false) { - event.cancelled = true; - } - return !event.aborted; - }); - } - return event.result; - } - - /** - * Returns an array of event listeners for a given type that can be manipulated - * to add or remove listeners. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} type The event type. - * @returns {Array} The listeners array. - */ - function listeners(type) { - var me = this, - events = me.events || (me.events = {}); - - return hasKey(events, type) ? events[type] : (events[type] = []); - } - - /** - * Unregisters a listener for the specified event type(s), - * or unregisters all listeners for the specified event type(s), - * or unregisters all listeners for all event types. - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} [type] The event type. - * @param {Function} [listener] The function to unregister. - * @returns {Object} The benchmark instance. - * @example - * - * // unregister a listener for an event type - * bench.off('cycle', listener); - * - * // unregister a listener for multiple event types - * bench.off('start cycle', listener); - * - * // unregister all listeners for an event type - * bench.off('cycle'); - * - * // unregister all listeners for multiple event types - * bench.off('start cycle complete'); - * - * // unregister all listeners for all event types - * bench.off(); - */ - function off(type, listener) { - var me = this, - events = me.events; - - events && each(type ? type.split(' ') : events, function(listeners, type) { - var index; - if (typeof listeners == 'string') { - type = listeners; - listeners = hasKey(events, type) && events[type]; - } - if (listeners) { - if (listener) { - index = indexOf(listeners, listener); - if (index > -1) { - listeners.splice(index, 1); - } - } else { - listeners.length = 0; - } - } - }); - return me; - } - - /** - * Registers a listener for the specified event type(s). - * - * @memberOf Benchmark, Benchmark.Suite - * @param {String} type The event type. - * @param {Function} listener The function to register. - * @returns {Object} The benchmark instance. - * @example - * - * // register a listener for an event type - * bench.on('cycle', listener); - * - * // register a listener for multiple event types - * bench.on('start cycle', listener); - */ - function on(type, listener) { - var me = this, - events = me.events || (me.events = {}); - - forEach(type.split(' '), function(type) { - (hasKey(events, type) - ? events[type] - : (events[type] = []) - ).push(listener); - }); - return me; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Aborts the benchmark without recording times. - * - * @memberOf Benchmark - * @returns {Object} The benchmark instance. - */ - function abort() { - var event, - me = this, - resetting = calledBy.reset; - - if (me.running) { - event = Event('abort'); - me.emit(event); - if (!event.cancelled || resetting) { - // avoid infinite recursion - calledBy.abort = true; - me.reset(); - delete calledBy.abort; - - if (support.timeout) { - clearTimeout(me._timerId); - delete me._timerId; - } - if (!resetting) { - me.aborted = true; - me.running = false; - } - } - } - return me; - } - - /** - * Creates a new benchmark using the same test and options. - * - * @memberOf Benchmark - * @param {Object} options Options object to overwrite cloned options. - * @returns {Object} The new benchmark instance. - * @example - * - * var bizarro = bench.clone({ - * 'name': 'doppelganger' - * }); - */ - function clone(options) { - var me = this, - result = new me.constructor(extend({}, me, options)); - - // correct the `options` object - result.options = extend({}, me.options, options); - - // copy own custom properties - forOwn(me, function(value, key) { - if (!hasKey(result, key)) { - result[key] = deepClone(value); - } - }); - return result; - } - - /** - * Determines if a benchmark is faster than another. - * - * @memberOf Benchmark - * @param {Object} other The benchmark to compare. - * @returns {Number} Returns `-1` if slower, `1` if faster, and `0` if indeterminate. - */ - function compare(other) { - var critical, - zStat, - me = this, - sample1 = me.stats.sample, - sample2 = other.stats.sample, - size1 = sample1.length, - size2 = sample2.length, - maxSize = max(size1, size2), - minSize = min(size1, size2), - u1 = getU(sample1, sample2), - u2 = getU(sample2, sample1), - u = min(u1, u2); - - function getScore(xA, sampleB) { - return reduce(sampleB, function(total, xB) { - return total + (xB > xA ? 0 : xB < xA ? 1 : 0.5); - }, 0); - } - - function getU(sampleA, sampleB) { - return reduce(sampleA, function(total, xA) { - return total + getScore(xA, sampleB); - }, 0); - } - - function getZ(u) { - return (u - ((size1 * size2) / 2)) / sqrt((size1 * size2 * (size1 + size2 + 1)) / 12); - } - - // exit early if comparing the same benchmark - if (me == other) { - return 0; - } - // reject the null hyphothesis the two samples come from the - // same population (i.e. have the same median) if... - if (size1 + size2 > 30) { - // ...the z-stat is greater than 1.96 or less than -1.96 - // http://www.statisticslectures.com/topics/mannwhitneyu/ - zStat = getZ(u); - return abs(zStat) > 1.96 ? (zStat > 0 ? -1 : 1) : 0; - } - // ...the U value is less than or equal the critical U value - // http://www.geoib.com/mann-whitney-u-test.html - critical = maxSize < 5 || minSize < 3 ? 0 : uTable[maxSize][minSize - 3]; - return u <= critical ? (u == u1 ? 1 : -1) : 0; - } - - /** - * Reset properties and abort if running. - * - * @memberOf Benchmark - * @returns {Object} The benchmark instance. - */ - function reset() { - var data, - event, - me = this, - index = 0, - changes = { 'length': 0 }, - queue = { 'length': 0 }; - - if (me.running && !calledBy.abort) { - // no worries, `reset()` is called within `abort()` - calledBy.reset = true; - me.abort(); - delete calledBy.reset; - } - else { - // a non-recursive solution to check if properties have changed - // http://www.jslab.dk/articles/non.recursive.preorder.traversal.part4 - data = { 'destination': me, 'source': extend({}, me.constructor.prototype, me.options) }; - do { - forOwn(data.source, function(value, key) { - var changed, - destination = data.destination, - currValue = destination[key]; - - if (value && typeof value == 'object') { - if (isClassOf(value, 'Array')) { - // check if an array value has changed to a non-array value - if (!isClassOf(currValue, 'Array')) { - changed = currValue = []; - } - // or has changed its length - if (currValue.length != value.length) { - changed = currValue = currValue.slice(0, value.length); - currValue.length = value.length; - } - } - // check if an object has changed to a non-object value - else if (!currValue || typeof currValue != 'object') { - changed = currValue = {}; - } - // register a changed object - if (changed) { - changes[changes.length++] = { 'destination': destination, 'key': key, 'value': currValue }; - } - queue[queue.length++] = { 'destination': currValue, 'source': value }; - } - // register a changed primitive - else if (value !== currValue && !(value == null || isClassOf(value, 'Function'))) { - changes[changes.length++] = { 'destination': destination, 'key': key, 'value': value }; - } - }); - } - while ((data = queue[index++])); - - // if changed emit the `reset` event and if it isn't cancelled reset the benchmark - if (changes.length && (me.emit(event = Event('reset')), !event.cancelled)) { - forEach(changes, function(data) { - data.destination[data.key] = data.value; - }); - } - } - return me; - } - - /** - * Displays relevant benchmark information when coerced to a string. - * - * @name toString - * @memberOf Benchmark - * @returns {String} A string representation of the benchmark instance. - */ - function toStringBench() { - var me = this, - error = me.error, - hz = me.hz, - id = me.id, - stats = me.stats, - size = stats.sample.length, - pm = support.java ? '+/-' : '\xb1', - result = me.name || (isNaN(id) ? id : ''); - - if (error) { - result += ': ' + join(error); - } else { - result += ' x ' + formatNumber(hz.toFixed(hz < 100 ? 2 : 0)) + ' ops/sec ' + pm + - stats.rme.toFixed(2) + '% (' + size + ' run' + (size == 1 ? '' : 's') + ' sampled)'; - } - return result; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Clocks the time taken to execute a test per cycle (secs). - * - * @private - * @param {Object} bench The benchmark instance. - * @returns {Number} The time taken. - */ - function clock() { - var applet, - options = Benchmark.options, - template = { 'begin': 's$=new n$', 'end': 'r$=(new n$-s$)/1e3', 'uid': uid }, - timers = [{ 'ns': timer.ns, 'res': max(0.0015, getRes('ms')), 'unit': 'ms' }]; - - // lazy define for hi-res timers - clock = function(clone) { - var deferred; - if (clone instanceof Deferred) { - deferred = clone; - clone = deferred.benchmark; - } - - var bench = clone._original, - fn = bench.fn, - fnArg = deferred ? getFirstArgument(fn) || 'deferred' : '', - stringable = isStringable(fn); - - var source = { - 'setup': getSource(bench.setup, preprocess('m$.setup()')), - 'fn': getSource(fn, preprocess('m$.fn(' + fnArg + ')')), - 'fnArg': fnArg, - 'teardown': getSource(bench.teardown, preprocess('m$.teardown()')) - }; - - var count = bench.count = clone.count, - decompilable = support.decompilation || stringable, - id = bench.id, - isEmpty = !(source.fn || stringable), - name = bench.name || (typeof id == 'number' ? '' : id), - ns = timer.ns, - result = 0; - - // init `minTime` if needed - clone.minTime = bench.minTime || (bench.minTime = bench.options.minTime = options.minTime); - - // repair nanosecond timer - // (some Chrome builds erase the `ns` variable after millions of executions) - if (applet) { - try { - ns.nanoTime(); - } catch(e) { - // use non-element to avoid issues with libs that augment them - ns = timer.ns = new applet.Packages.nano; - } - } - - // Compile in setup/teardown functions and the test loop. - // Create a new compiled test, instead of using the cached `bench.compiled`, - // to avoid potential engine optimizations enabled over the life of the test. - var compiled = bench.compiled = createFunction(preprocess('t$'), interpolate( - preprocess(deferred - ? 'var d$=this,#{fnArg}=d$,m$=d$.benchmark._original,f$=m$.fn,su$=m$.setup,td$=m$.teardown;' + - // when `deferred.cycles` is `0` then... - 'if(!d$.cycles){' + - // set `deferred.fn` - 'd$.fn=function(){var #{fnArg}=d$;if(typeof f$=="function"){try{#{fn}\n}catch(e$){f$(d$)}}else{#{fn}\n}};' + - // set `deferred.teardown` - 'd$.teardown=function(){d$.cycles=0;if(typeof td$=="function"){try{#{teardown}\n}catch(e$){td$()}}else{#{teardown}\n}};' + - // execute the benchmark's `setup` - 'if(typeof su$=="function"){try{#{setup}\n}catch(e$){su$()}}else{#{setup}\n};' + - // start timer - 't$.start(d$);' + - // execute `deferred.fn` and return a dummy object - '}d$.fn();return{}' - - : 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count,n$=t$.ns;#{setup}\n#{begin};' + - 'while(i$--){#{fn}\n}#{end};#{teardown}\nreturn{elapsed:r$,uid:"#{uid}"}'), - source - )); - - try { - if (isEmpty) { - // Firefox may remove dead code from Function#toString results - // http://bugzil.la/536085 - throw new Error('The test "' + name + '" is empty. This may be the result of dead code removal.'); - } - else if (!deferred) { - // pretest to determine if compiled code is exits early, usually by a - // rogue `return` statement, by checking for a return object with the uid - bench.count = 1; - compiled = (compiled.call(bench, timer) || {}).uid == uid && compiled; - bench.count = count; - } - } catch(e) { - compiled = null; - clone.error = e || new Error(String(e)); - bench.count = count; - } - // fallback when a test exits early or errors during pretest - if (decompilable && !compiled && !deferred && !isEmpty) { - compiled = createFunction(preprocess('t$'), interpolate( - preprocess( - (clone.error && !stringable - ? 'var r$,s$,m$=this,f$=m$.fn,i$=m$.count' - : 'function f$(){#{fn}\n}var r$,s$,m$=this,i$=m$.count' - ) + - ',n$=t$.ns;#{setup}\n#{begin};m$.f$=f$;while(i$--){m$.f$()}#{end};' + - 'delete m$.f$;#{teardown}\nreturn{elapsed:r$}' - ), - source - )); - - try { - // pretest one more time to check for errors - bench.count = 1; - compiled.call(bench, timer); - bench.compiled = compiled; - bench.count = count; - delete clone.error; - } - catch(e) { - bench.count = count; - if (clone.error) { - compiled = null; - } else { - bench.compiled = compiled; - clone.error = e || new Error(String(e)); - } - } - } - // assign `compiled` to `clone` before calling in case a deferred benchmark - // immediately calls `deferred.resolve()` - clone.compiled = compiled; - // if no errors run the full test loop - if (!clone.error) { - result = compiled.call(deferred || bench, timer).elapsed; - } - return result; - }; - - /*------------------------------------------------------------------------*/ - - /** - * Gets the current timer's minimum resolution (secs). - */ - function getRes(unit) { - var measured, - begin, - count = 30, - divisor = 1e3, - ns = timer.ns, - sample = []; - - // get average smallest measurable time - while (count--) { - if (unit == 'us') { - divisor = 1e6; - if (ns.stop) { - ns.start(); - while (!(measured = ns.microseconds())) { } - } else if (ns[perfName]) { - divisor = 1e3; - measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns); - } else { - begin = ns(); - while (!(measured = ns() - begin)) { } - } - } - else if (unit == 'ns') { - divisor = 1e9; - if (ns.nanoTime) { - begin = ns.nanoTime(); - while (!(measured = ns.nanoTime() - begin)) { } - } else { - begin = (begin = ns())[0] + (begin[1] / divisor); - while (!(measured = ((measured = ns())[0] + (measured[1] / divisor)) - begin)) { } - divisor = 1; - } - } - else { - begin = new ns; - while (!(measured = new ns - begin)) { } - } - // check for broken timers (nanoTime may have issues) - // http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/ - if (measured > 0) { - sample.push(measured); - } else { - sample.push(Infinity); - break; - } - } - // convert to seconds - return getMean(sample) / divisor; - } - - /** - * Replaces all occurrences of `$` with a unique number and - * template tokens with content. - */ - function preprocess(code) { - return interpolate(code, template).replace(/\$/g, /\d+/.exec(uid)); - } - - /*------------------------------------------------------------------------*/ - - // detect nanosecond support from a Java applet - each(doc && doc.applets || [], function(element) { - return !(timer.ns = applet = 'nanoTime' in element && element); - }); - - // check type in case Safari returns an object instead of a number - try { - if (typeof timer.ns.nanoTime() == 'number') { - timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); - } - } catch(e) { } - - // detect Chrome's microsecond timer: - // enable benchmarking via the --enable-benchmarking command - // line switch in at least Chrome 7 to use chrome.Interval - try { - if ((timer.ns = new (window.chrome || window.chromium).Interval)) { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - } catch(e) { } - - // detect `performance.now` microsecond resolution timer - if ((timer.ns = perfName && perfObject)) { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - - // detect Node's nanosecond resolution timer available in Node >= 0.8 - if (processObject && typeof (timer.ns = processObject.hrtime) == 'function') { - timers.push({ 'ns': timer.ns, 'res': getRes('ns'), 'unit': 'ns' }); - } - - // detect Wade Simmons' Node microtime module - if (microtimeObject && typeof (timer.ns = microtimeObject.now) == 'function') { - timers.push({ 'ns': timer.ns, 'res': getRes('us'), 'unit': 'us' }); - } - - // pick timer with highest resolution - timer = reduce(timers, function(timer, other) { - return other.res < timer.res ? other : timer; - }); - - // remove unused applet - if (timer.unit != 'ns' && applet) { - applet = destroyElement(applet); - } - // error if there are no working timers - if (timer.res == Infinity) { - throw new Error('Benchmark.js was unable to find a working timer.'); - } - // use API of chosen timer - if (timer.unit == 'ns') { - if (timer.ns.nanoTime) { - extend(template, { - 'begin': 's$=n$.nanoTime()', - 'end': 'r$=(n$.nanoTime()-s$)/1e9' - }); - } else { - extend(template, { - 'begin': 's$=n$()', - 'end': 'r$=n$(s$);r$=r$[0]+(r$[1]/1e9)' - }); - } - } - else if (timer.unit == 'us') { - if (timer.ns.stop) { - extend(template, { - 'begin': 's$=n$.start()', - 'end': 'r$=n$.microseconds()/1e6' - }); - } else if (perfName) { - extend(template, { - 'begin': 's$=n$.' + perfName + '()', - 'end': 'r$=(n$.' + perfName + '()-s$)/1e3' - }); - } else { - extend(template, { - 'begin': 's$=n$()', - 'end': 'r$=(n$()-s$)/1e6' - }); - } - } - - // define `timer` methods - timer.start = createFunction(preprocess('o$'), - preprocess('var n$=this.ns,#{begin};o$.elapsed=0;o$.timeStamp=s$')); - - timer.stop = createFunction(preprocess('o$'), - preprocess('var n$=this.ns,s$=o$.timeStamp,#{end};o$.elapsed=r$')); - - // resolve time span required to achieve a percent uncertainty of at most 1% - // http://spiff.rit.edu/classes/phys273/uncert/uncert.html - options.minTime || (options.minTime = max(timer.res / 2 / 0.01, 0.05)); - return clock.apply(null, arguments); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Computes stats on benchmark results. - * - * @private - * @param {Object} bench The benchmark instance. - * @param {Object} options The options object. - */ - function compute(bench, options) { - options || (options = {}); - - var async = options.async, - elapsed = 0, - initCount = bench.initCount, - minSamples = bench.minSamples, - queue = [], - sample = bench.stats.sample; - - /** - * Adds a clone to the queue. - */ - function enqueue() { - queue.push(bench.clone({ - '_original': bench, - 'events': { - 'abort': [update], - 'cycle': [update], - 'error': [update], - 'start': [update] - } - })); - } - - /** - * Updates the clone/original benchmarks to keep their data in sync. - */ - function update(event) { - var clone = this, - type = event.type; - - if (bench.running) { - if (type == 'start') { - // Note: `clone.minTime` prop is inited in `clock()` - clone.count = bench.initCount; - } - else { - if (type == 'error') { - bench.error = clone.error; - } - if (type == 'abort') { - bench.abort(); - bench.emit('cycle'); - } else { - event.currentTarget = event.target = bench; - bench.emit(event); - } - } - } else if (bench.aborted) { - // clear abort listeners to avoid triggering bench's abort/cycle again - clone.events.abort.length = 0; - clone.abort(); - } - } - - /** - * Determines if more clones should be queued or if cycling should stop. - */ - function evaluate(event) { - var critical, - df, - mean, - moe, - rme, - sd, - sem, - variance, - clone = event.target, - done = bench.aborted, - now = +new Date, - size = sample.push(clone.times.period), - maxedOut = size >= minSamples && (elapsed += now - clone.times.timeStamp) / 1e3 > bench.maxTime, - times = bench.times, - varOf = function(sum, x) { return sum + pow(x - mean, 2); }; - - // exit early for aborted or unclockable tests - if (done || clone.hz == Infinity) { - maxedOut = !(size = sample.length = queue.length = 0); - } - - if (!done) { - // sample mean (estimate of the population mean) - mean = getMean(sample); - // sample variance (estimate of the population variance) - variance = reduce(sample, varOf, 0) / (size - 1) || 0; - // sample standard deviation (estimate of the population standard deviation) - sd = sqrt(variance); - // standard error of the mean (a.k.a. the standard deviation of the sampling distribution of the sample mean) - sem = sd / sqrt(size); - // degrees of freedom - df = size - 1; - // critical value - critical = tTable[Math.round(df) || 1] || tTable.infinity; - // margin of error - moe = sem * critical; - // relative margin of error - rme = (moe / mean) * 100 || 0; - - extend(bench.stats, { - 'deviation': sd, - 'mean': mean, - 'moe': moe, - 'rme': rme, - 'sem': sem, - 'variance': variance - }); - - // Abort the cycle loop when the minimum sample size has been collected - // and the elapsed time exceeds the maximum time allowed per benchmark. - // We don't count cycle delays toward the max time because delays may be - // increased by browsers that clamp timeouts for inactive tabs. - // https://developer.mozilla.org/en/window.setTimeout#Inactive_tabs - if (maxedOut) { - // reset the `initCount` in case the benchmark is rerun - bench.initCount = initCount; - bench.running = false; - done = true; - times.elapsed = (now - times.timeStamp) / 1e3; - } - if (bench.hz != Infinity) { - bench.hz = 1 / mean; - times.cycle = mean * bench.count; - times.period = mean; - } - } - // if time permits, increase sample size to reduce the margin of error - if (queue.length < 2 && !maxedOut) { - enqueue(); - } - // abort the invoke cycle when done - event.aborted = done; - } - - // init queue and begin - enqueue(); - invoke(queue, { - 'name': 'run', - 'args': { 'async': async }, - 'queued': true, - 'onCycle': evaluate, - 'onComplete': function() { bench.emit('complete'); } - }); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Cycles a benchmark until a run `count` can be established. - * - * @private - * @param {Object} clone The cloned benchmark instance. - * @param {Object} options The options object. - */ - function cycle(clone, options) { - options || (options = {}); - - var deferred; - if (clone instanceof Deferred) { - deferred = clone; - clone = clone.benchmark; - } - - var clocked, - cycles, - divisor, - event, - minTime, - period, - async = options.async, - bench = clone._original, - count = clone.count, - times = clone.times; - - // continue, if not aborted between cycles - if (clone.running) { - // `minTime` is set to `Benchmark.options.minTime` in `clock()` - cycles = ++clone.cycles; - clocked = deferred ? deferred.elapsed : clock(clone); - minTime = clone.minTime; - - if (cycles > bench.cycles) { - bench.cycles = cycles; - } - if (clone.error) { - event = Event('error'); - event.message = clone.error; - clone.emit(event); - if (!event.cancelled) { - clone.abort(); - } - } - } - - // continue, if not errored - if (clone.running) { - // time taken to complete last test cycle - bench.times.cycle = times.cycle = clocked; - // seconds per operation - period = bench.times.period = times.period = clocked / count; - // ops per second - bench.hz = clone.hz = 1 / period; - // avoid working our way up to this next time - bench.initCount = clone.initCount = count; - // do we need to do another cycle? - clone.running = clocked < minTime; - - if (clone.running) { - // tests may clock at `0` when `initCount` is a small number, - // to avoid that we set its count to something a bit higher - if (!clocked && (divisor = divisors[clone.cycles]) != null) { - count = floor(4e6 / divisor); - } - // calculate how many more iterations it will take to achive the `minTime` - if (count <= clone.count) { - count += Math.ceil((minTime - clocked) / period); - } - clone.running = count != Infinity; - } - } - // should we exit early? - event = Event('cycle'); - clone.emit(event); - if (event.aborted) { - clone.abort(); - } - // figure out what to do next - if (clone.running) { - // start a new cycle - clone.count = count; - if (deferred) { - clone.compiled.call(deferred, timer); - } else if (async) { - delay(clone, function() { cycle(clone, options); }); - } else { - cycle(clone); - } - } - else { - // fix TraceMonkey bug associated with clock fallbacks - // http://bugzil.la/509069 - if (support.browser) { - runScript(uid + '=1;delete ' + uid); - } - // done - clone.emit('complete'); - } - } - - /*--------------------------------------------------------------------------*/ - - /** - * Runs the benchmark. - * - * @memberOf Benchmark - * @param {Object} [options={}] Options object. - * @returns {Object} The benchmark instance. - * @example - * - * // basic usage - * bench.run(); - * - * // or with options - * bench.run({ 'async': true }); - */ - function run(options) { - var me = this, - event = Event('start'); - - // set `running` to `false` so `reset()` won't call `abort()` - me.running = false; - me.reset(); - me.running = true; - - me.count = me.initCount; - me.times.timeStamp = +new Date; - me.emit(event); - - if (!event.cancelled) { - options = { 'async': ((options = options && options.async) == null ? me.async : options) && support.timeout }; - - // for clones created within `compute()` - if (me._original) { - if (me.defer) { - Deferred(me); - } else { - cycle(me, options); - } - } - // for original benchmarks - else { - compute(me, options); - } - } - return me; - } - - /*--------------------------------------------------------------------------*/ - - // Firefox 1 erroneously defines variable and argument names of functions on - // the function itself as non-configurable properties with `undefined` values. - // The bugginess continues as the `Benchmark` constructor has an argument - // named `options` and Firefox 1 will not assign a value to `Benchmark.options`, - // making it non-writable in the process, unless it is the first property - // assigned by for-in loop of `extend()`. - extend(Benchmark, { - - /** - * The default options copied by benchmark instances. - * - * @static - * @memberOf Benchmark - * @type Object - */ - 'options': { - - /** - * A flag to indicate that benchmark cycles will execute asynchronously - * by default. - * - * @memberOf Benchmark.options - * @type Boolean - */ - 'async': false, - - /** - * A flag to indicate that the benchmark clock is deferred. - * - * @memberOf Benchmark.options - * @type Boolean - */ - 'defer': false, - - /** - * The delay between test cycles (secs). - * @memberOf Benchmark.options - * @type Number - */ - 'delay': 0.005, - - /** - * Displayed by Benchmark#toString when a `name` is not available - * (auto-generated if absent). - * - * @memberOf Benchmark.options - * @type String - */ - 'id': undefined, - - /** - * The default number of times to execute a test on a benchmark's first cycle. - * - * @memberOf Benchmark.options - * @type Number - */ - 'initCount': 1, - - /** - * The maximum time a benchmark is allowed to run before finishing (secs). - * - * Note: Cycle delays aren't counted toward the maximum time. - * - * @memberOf Benchmark.options - * @type Number - */ - 'maxTime': 5, - - /** - * The minimum sample size required to perform statistical analysis. - * - * @memberOf Benchmark.options - * @type Number - */ - 'minSamples': 5, - - /** - * The time needed to reduce the percent uncertainty of measurement to 1% (secs). - * - * @memberOf Benchmark.options - * @type Number - */ - 'minTime': 0, - - /** - * The name of the benchmark. - * - * @memberOf Benchmark.options - * @type String - */ - 'name': undefined, - - /** - * An event listener called when the benchmark is aborted. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onAbort': undefined, - - /** - * An event listener called when the benchmark completes running. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onComplete': undefined, - - /** - * An event listener called after each run cycle. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onCycle': undefined, - - /** - * An event listener called when a test errors. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onError': undefined, - - /** - * An event listener called when the benchmark is reset. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onReset': undefined, - - /** - * An event listener called when the benchmark starts running. - * - * @memberOf Benchmark.options - * @type Function - */ - 'onStart': undefined, - - /** - * The reference time taken to execute the test once (usecs). - * - * @memberOf Benchmark.options - * @type Number - */ - 'reference': 0 - }, - - /** - * Platform object with properties describing things like browser name, - * version, and operating system. - * - * @static - * @memberOf Benchmark - * @type Object - */ - 'platform': req('platform') || window.platform || { - - /** - * The platform description. - * - * @memberOf Benchmark.platform - * @type String - */ - 'description': window.navigator && navigator.userAgent || null, - - /** - * The name of the browser layout engine. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'layout': null, - - /** - * The name of the product hosting the browser. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'product': null, - - /** - * The name of the browser/environment. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'name': null, - - /** - * The name of the product's manufacturer. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'manufacturer': null, - - /** - * The name of the operating system. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'os': null, - - /** - * The alpha/beta release indicator. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'prerelease': null, - - /** - * The browser/environment version. - * - * @memberOf Benchmark.platform - * @type String|Null - */ - 'version': null, - - /** - * Return platform description when the platform object is coerced to a string. - * - * @memberOf Benchmark.platform - * @type Function - * @returns {String} The platform description. - */ - 'toString': function() { - return this.description || ''; - } - }, - - /** - * The semantic version number. - * - * @static - * @memberOf Benchmark - * @type String - */ - 'version': '1.0.0', - - // an object of environment/feature detection flags - 'support': support, - - // clone objects - 'deepClone': deepClone, - - // iteration utility - 'each': each, - - // augment objects - 'extend': extend, - - // generic Array#filter - 'filter': filter, - - // generic Array#forEach - 'forEach': forEach, - - // generic own property iteration utility - 'forOwn': forOwn, - - // converts a number to a comma-separated string - 'formatNumber': formatNumber, - - // generic Object#hasOwnProperty - // (trigger hasKey's lazy define before assigning it to Benchmark) - 'hasKey': (hasKey(Benchmark, ''), hasKey), - - // generic Array#indexOf - 'indexOf': indexOf, - - // template utility - 'interpolate': interpolate, - - // invokes a method on each item in an array - 'invoke': invoke, - - // generic Array#join for arrays and objects - 'join': join, - - // generic Array#map - 'map': map, - - // retrieves a property value from each item in an array - 'pluck': pluck, - - // generic Array#reduce - 'reduce': reduce - }); - - /*--------------------------------------------------------------------------*/ - - extend(Benchmark.prototype, { - - /** - * The number of times a test was executed. - * - * @memberOf Benchmark - * @type Number - */ - 'count': 0, - - /** - * The number of cycles performed while benchmarking. - * - * @memberOf Benchmark - * @type Number - */ - 'cycles': 0, - - /** - * The number of executions per second. - * - * @memberOf Benchmark - * @type Number - */ - 'hz': 0, - - /** - * The compiled test function. - * - * @memberOf Benchmark - * @type Function|String - */ - 'compiled': undefined, - - /** - * The error object if the test failed. - * - * @memberOf Benchmark - * @type Object - */ - 'error': undefined, - - /** - * The test to benchmark. - * - * @memberOf Benchmark - * @type Function|String - */ - 'fn': undefined, - - /** - * A flag to indicate if the benchmark is aborted. - * - * @memberOf Benchmark - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the benchmark is running. - * - * @memberOf Benchmark - * @type Boolean - */ - 'running': false, - - /** - * Compiled into the test and executed immediately **before** the test loop. - * - * @memberOf Benchmark - * @type Function|String - * @example - * - * // basic usage - * var bench = Benchmark({ - * 'setup': function() { - * var c = this.count, - * element = document.getElementById('container'); - * while (c--) { - * element.appendChild(document.createElement('div')); - * } - * }, - * 'fn': function() { - * element.removeChild(element.lastChild); - * } - * }); - * - * // compiles to something like: - * var c = this.count, - * element = document.getElementById('container'); - * while (c--) { - * element.appendChild(document.createElement('div')); - * } - * var start = new Date; - * while (count--) { - * element.removeChild(element.lastChild); - * } - * var end = new Date - start; - * - * // or using strings - * var bench = Benchmark({ - * 'setup': '\ - * var a = 0;\n\ - * (function() {\n\ - * (function() {\n\ - * (function() {', - * 'fn': 'a += 1;', - * 'teardown': '\ - * }())\n\ - * }())\n\ - * }())' - * }); - * - * // compiles to something like: - * var a = 0; - * (function() { - * (function() { - * (function() { - * var start = new Date; - * while (count--) { - * a += 1; - * } - * var end = new Date - start; - * }()) - * }()) - * }()) - */ - 'setup': noop, - - /** - * Compiled into the test and executed immediately **after** the test loop. - * - * @memberOf Benchmark - * @type Function|String - */ - 'teardown': noop, - - /** - * An object of stats including mean, margin or error, and standard deviation. - * - * @memberOf Benchmark - * @type Object - */ - 'stats': { - - /** - * The margin of error. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'moe': 0, - - /** - * The relative margin of error (expressed as a percentage of the mean). - * - * @memberOf Benchmark#stats - * @type Number - */ - 'rme': 0, - - /** - * The standard error of the mean. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'sem': 0, - - /** - * The sample standard deviation. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'deviation': 0, - - /** - * The sample arithmetic mean. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'mean': 0, - - /** - * The array of sampled periods. - * - * @memberOf Benchmark#stats - * @type Array - */ - 'sample': [], - - /** - * The sample variance. - * - * @memberOf Benchmark#stats - * @type Number - */ - 'variance': 0 - }, - - /** - * An object of timing data including cycle, elapsed, period, start, and stop. - * - * @memberOf Benchmark - * @type Object - */ - 'times': { - - /** - * The time taken to complete the last cycle (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'cycle': 0, - - /** - * The time taken to complete the benchmark (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'elapsed': 0, - - /** - * The time taken to execute the test once (secs). - * - * @memberOf Benchmark#times - * @type Number - */ - 'period': 0, - - /** - * A timestamp of when the benchmark started (ms). - * - * @memberOf Benchmark#times - * @type Number - */ - 'timeStamp': 0 - }, - - // aborts benchmark (does not record times) - 'abort': abort, - - // creates a new benchmark using the same test and options - 'clone': clone, - - // compares benchmark's hertz with another - 'compare': compare, - - // executes listeners - 'emit': emit, - - // get listeners - 'listeners': listeners, - - // unregister listeners - 'off': off, - - // register listeners - 'on': on, - - // reset benchmark properties - 'reset': reset, - - // runs the benchmark - 'run': run, - - // pretty print benchmark info - 'toString': toStringBench - }); - - /*--------------------------------------------------------------------------*/ - - extend(Deferred.prototype, { - - /** - * The deferred benchmark instance. - * - * @memberOf Benchmark.Deferred - * @type Object - */ - 'benchmark': null, - - /** - * The number of deferred cycles performed while benchmarking. - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'cycles': 0, - - /** - * The time taken to complete the deferred benchmark (secs). - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'elapsed': 0, - - /** - * A timestamp of when the deferred benchmark started (ms). - * - * @memberOf Benchmark.Deferred - * @type Number - */ - 'timeStamp': 0, - - // cycles/completes the deferred benchmark - 'resolve': resolve - }); - - /*--------------------------------------------------------------------------*/ - - extend(Event.prototype, { - - /** - * A flag to indicate if the emitters listener iteration is aborted. - * - * @memberOf Benchmark.Event - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the default action is cancelled. - * - * @memberOf Benchmark.Event - * @type Boolean - */ - 'cancelled': false, - - /** - * The object whose listeners are currently being processed. - * - * @memberOf Benchmark.Event - * @type Object - */ - 'currentTarget': undefined, - - /** - * The return value of the last executed listener. - * - * @memberOf Benchmark.Event - * @type Mixed - */ - 'result': undefined, - - /** - * The object to which the event was originally emitted. - * - * @memberOf Benchmark.Event - * @type Object - */ - 'target': undefined, - - /** - * A timestamp of when the event was created (ms). - * - * @memberOf Benchmark.Event - * @type Number - */ - 'timeStamp': 0, - - /** - * The event type. - * - * @memberOf Benchmark.Event - * @type String - */ - 'type': '' - }); - - /*--------------------------------------------------------------------------*/ - - /** - * The default options copied by suite instances. - * - * @static - * @memberOf Benchmark.Suite - * @type Object - */ - Suite.options = { - - /** - * The name of the suite. - * - * @memberOf Benchmark.Suite.options - * @type String - */ - 'name': undefined - }; - - /*--------------------------------------------------------------------------*/ - - extend(Suite.prototype, { - - /** - * The number of benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @type Number - */ - 'length': 0, - - /** - * A score computed using the normalized result of each benchmark in the suite. - * - * @memberOf Benchmark.Suite - * @type Number - */ - 'score': 0, - - /** - * A flag to indicate if the suite is aborted. - * - * @memberOf Benchmark.Suite - * @type Boolean - */ - 'aborted': false, - - /** - * A flag to indicate if the suite is running. - * - * @memberOf Benchmark.Suite - * @type Boolean - */ - 'running': false, - - /** - * An `Array#forEach` like method. - * Callbacks may terminate the loop by explicitly returning `false`. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @returns {Object} The suite iterated over. - */ - 'forEach': methodize(forEach), - - /** - * An `Array#indexOf` like method. - * - * @memberOf Benchmark.Suite - * @param {Mixed} value The value to search for. - * @returns {Number} The index of the matched value or `-1`. - */ - 'indexOf': methodize(indexOf), - - /** - * Invokes a method on all benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @param {String|Object} name The name of the method to invoke OR options object. - * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with. - * @returns {Array} A new array of values returned from each method invoked. - */ - 'invoke': methodize(invoke), - - /** - * Converts the suite of benchmarks to a string. - * - * @memberOf Benchmark.Suite - * @param {String} [separator=','] A string to separate each element of the array. - * @returns {String} The string. - */ - 'join': [].join, - - /** - * An `Array#map` like method. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @returns {Array} A new array of values returned by the callback. - */ - 'map': methodize(map), - - /** - * Retrieves the value of a specified property from all benchmarks in the suite. - * - * @memberOf Benchmark.Suite - * @param {String} property The property to pluck. - * @returns {Array} A new array of property values. - */ - 'pluck': methodize(pluck), - - /** - * Removes the last benchmark from the suite and returns it. - * - * @memberOf Benchmark.Suite - * @returns {Mixed} The removed benchmark. - */ - 'pop': [].pop, - - /** - * Appends benchmarks to the suite. - * - * @memberOf Benchmark.Suite - * @returns {Number} The suite's new length. - */ - 'push': [].push, - - /** - * Sorts the benchmarks of the suite. - * - * @memberOf Benchmark.Suite - * @param {Function} [compareFn=null] A function that defines the sort order. - * @returns {Object} The sorted suite. - */ - 'sort': [].sort, - - /** - * An `Array#reduce` like method. - * - * @memberOf Benchmark.Suite - * @param {Function} callback The function called per iteration. - * @param {Mixed} accumulator Initial value of the accumulator. - * @returns {Mixed} The accumulator. - */ - 'reduce': methodize(reduce), - - // aborts all benchmarks in the suite - 'abort': abortSuite, - - // adds a benchmark to the suite - 'add': add, - - // creates a new suite with cloned benchmarks - 'clone': cloneSuite, - - // executes listeners of a specified type - 'emit': emit, - - // creates a new suite of filtered benchmarks - 'filter': filterSuite, - - // get listeners - 'listeners': listeners, - - // unregister listeners - 'off': off, - - // register listeners - 'on': on, - - // resets all benchmarks in the suite - 'reset': resetSuite, - - // runs all benchmarks in the suite - 'run': runSuite, - - // array methods - 'concat': concat, - - 'reverse': reverse, - - 'shift': shift, - - 'slice': slice, - - 'splice': splice, - - 'unshift': unshift - }); - - /*--------------------------------------------------------------------------*/ - - // expose Deferred, Event and Suite - extend(Benchmark, { - 'Deferred': Deferred, - 'Event': Event, - 'Suite': Suite - }); - - // expose Benchmark - // some AMD build optimizers, like r.js, check for specific condition patterns like the following: - if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // define as an anonymous module so, through path mapping, it can be aliased - define(function() { - return Benchmark; - }); - } - // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports) { - // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = Benchmark).Benchmark = Benchmark; - } - // in Narwhal or RingoJS v0.7.0- - else { - freeExports.Benchmark = Benchmark; - } - } - // in a browser or Rhino - else { - // use square bracket notation so Closure Compiler won't munge `Benchmark` - // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export - window['Benchmark'] = Benchmark; - } - - // trigger clock's lazy define early to avoid a security error - if (support.air) { - clock({ '_original': { 'fn': noop, 'count': 1, 'options': {} } }); - } -}(this)); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/LICENSE.txt b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/LICENSE.txt deleted file mode 100644 index dadad22..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright 2011-2012 John-David Dalton - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/README.md deleted file mode 100644 index c2f1cb6..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# Platform.js v1.0.0 - -A platform detection library that works on nearly all JavaScript platforms1. - -## Disclaimer - -Platform.js is for informational purposes only and **not** intended as a substitution for [feature detection/inference](http://allyoucanleet.com/post/18087210413/feature-testing-costs#screencast2) checks. - -## BestieJS - -Platform.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation. - -## Documentation - -The documentation for Platform.js can be viewed here: [/doc/README.md](https://github.com/bestiejs/platform.js/blob/master/doc/README.md#readme) - -For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap). - -## Support - -Platform.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1-14, IE 6-9, Opera 9.25-12, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. - -## Installation and usage - -In a browser or Adobe AIR: - -```html - -``` - -Via [npm](http://npmjs.org/): - -```bash -npm install platform -``` - -In [Node.js](http://nodejs.org/) and [RingoJS](http://ringojs.org/): - -```js -var platform = require('platform'); -``` - -In [Rhino](http://www.mozilla.org/rhino/): - -```js -load('platform.js'); -``` - -In an AMD loader like [RequireJS](http://requirejs.org/): - -```js -require({ - 'paths': { - 'platform': 'path/to/platform' - } -}, -['platform'], function(platform) { - console.log(platform.name); -}); -``` - -Usage example: - -```js -// on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 64 bit edition -platform.name; // 'IE' -platform.version; // '10.0' -platform.layout; // 'Trident' -platform.os; // 'Windows Server 2008 R2 / 7 x64' -platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) on Windows Server 2008 R2 / 7 x64' - -// or on an iPad -platform.name; // 'Safari' -platform.version; // '5.1' -platform.product; // 'iPad' -platform.manufacturer; // 'Apple' -platform.layout; // 'WebKit' -platform.os; // 'iOS 5.0' -platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)' - -// or parsing a given UA string -var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52'); -info.name; // 'Opera' -info.version; // '11.52' -info.layout; // 'Presto' -info.os; // 'Mac OS X 10.7.2' -info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2' -``` - -## Author - -* [John-David Dalton](http://allyoucanleet.com/) - [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") - -## Contributors - -* [Mathias Bynens](http://mathiasbynens.be/) - [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/platform.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/platform.js deleted file mode 100644 index a63ceab..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/platform.js/platform.js +++ /dev/null @@ -1,996 +0,0 @@ -/*! - * Platform.js v1.0.0 - * Copyright 2010-2012 John-David Dalton - * Available under MIT license - */ -;(function(window) { - 'use strict'; - - /** Backup possible window/global object */ - var oldWin = window; - - /** Detect free variable `exports` */ - var freeExports = typeof exports == 'object' && exports; - - /** Detect free variable `global` */ - var freeGlobal = typeof global == 'object' && global && - (global == global.global ? (window = global) : global); - - /** Opera regexp */ - var reOpera = /Opera/; - - /** Used to resolve a value's internal [[Class]] */ - var toString = {}.toString; - - /** Detect Java environment */ - var java = /Java/.test(getClassOf(window.java)) && window.java; - - /** A character to represent alpha */ - var alpha = java ? 'a' : '\u03b1'; - - /** A character to represent beta */ - var beta = java ? 'b' : '\u03b2'; - - /** Browser document object */ - var doc = window.document || {}; - - /** Used to check for own properties of an object */ - var hasOwnProperty = {}.hasOwnProperty; - - /** Browser navigator object */ - var nav = window.navigator || {}; - - /** - * Detect Opera browser - * http://www.howtocreate.co.uk/operaStuff/operaObject.html - * http://dev.opera.com/articles/view/opera-mini-web-content-authoring-guidelines/#operamini - */ - var opera = window.operamini || window.opera; - - /** Opera [[Class]] */ - var operaClass = reOpera.test(operaClass = getClassOf(opera)) ? operaClass : (opera = null); - - /** Possible global object */ - var thisBinding = this; - - /** Browser user agent string */ - var userAgent = nav.userAgent || ''; - - /*--------------------------------------------------------------------------*/ - - /** - * Capitalizes a string value. - * - * @private - * @param {String} string The string to capitalize. - * @returns {String} The capitalized string. - */ - function capitalize(string) { - string = String(string); - return string.charAt(0).toUpperCase() + string.slice(1); - } - - /** - * An iteration utility for arrays and objects. - * - * @private - * @param {Array|Object} object The object to iterate over. - * @param {Function} callback The function called per iteration. - */ - function each(object, callback) { - var index = -1, - length = object.length; - - if (length == length >>> 0) { - while (++index < length) { - callback(object[index], index, object); - } - } else { - forOwn(object, callback); - } - } - - /** - * Trim and conditionally capitalize string values. - * - * @private - * @param {String} string The string to format. - * @returns {String} The formatted string. - */ - function format(string) { - string = trim(string); - return /^(?:webOS|i(?:OS|P))/.test(string) - ? string - : capitalize(string); - } - - /** - * Iterates over an object's own properties, executing the `callback` for each. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} callback The function executed per own property. - */ - function forOwn(object, callback) { - for (var key in object) { - hasKey(object, key) && callback(object[key], key, object); - } - } - - /** - * Gets the internal [[Class]] of a value. - * - * @private - * @param {Mixed} value The value. - * @returns {String} The [[Class]]. - */ - function getClassOf(value) { - return value == null - ? capitalize(value) - : toString.call(value).slice(8, -1); - } - - /** - * Checks if an object has the specified key as a direct property. - * - * @private - * @param {Object} object The object to check. - * @param {String} key The key to check for. - * @returns {Boolean} Returns `true` if key is a direct property, else `false`. - */ - function hasKey() { - // lazy define for others (not as accurate) - hasKey = function(object, key) { - var parent = object != null && (object.constructor || Object).prototype; - return !!parent && key in Object(object) && !(key in parent && object[key] === parent[key]); - }; - // for modern browsers - if (getClassOf(hasOwnProperty) == 'Function') { - hasKey = function(object, key) { - return object != null && hasOwnProperty.call(object, key); - }; - } - // for Safari 2 - else if ({}.__proto__ == Object.prototype) { - hasKey = function(object, key) { - var result = false; - if (object != null) { - object = Object(object); - object.__proto__ = [object.__proto__, object.__proto__ = null, result = key in object][0]; - } - return result; - }; - } - return hasKey.apply(this, arguments); - } - - /** - * Host objects can return type values that are different from their actual - * data type. The objects we are concerned with usually return non-primitive - * types of object, function, or unknown. - * - * @private - * @param {Mixed} object The owner of the property. - * @param {String} property The property to check. - * @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`. - */ - function isHostType(object, property) { - var type = object != null ? typeof object[property] : 'number'; - return !/^(?:boolean|number|string|undefined)$/.test(type) && - (type == 'object' ? !!object[property] : true); - } - - /** - * Prepares a string for use in a RegExp constructor by making hyphens and - * spaces optional. - * - * @private - * @param {String} string The string to qualify. - * @returns {String} The qualified string. - */ - function qualify(string) { - return String(string).replace(/([ -])(?!$)/g, '$1?'); - } - - /** - * A bare-bones` Array#reduce` like utility function. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - * @param {Mixed} accumulator Initial value of the accumulator. - * @returns {Mixed} The accumulator. - */ - function reduce(array, callback) { - var accumulator = null; - each(array, function(value, index) { - accumulator = callback(accumulator, value, index, array); - }); - return accumulator; - } - - /** - * Removes leading and trailing whitespace from a string. - * - * @private - * @param {String} string The string to trim. - * @returns {String} The trimmed string. - */ - function trim(string) { - return String(string).replace(/^ +| +$/g, ''); - } - - /*--------------------------------------------------------------------------*/ - - /** - * Creates a new platform object. - * - * @memberOf platform - * @param {String} [ua = navigator.userAgent] The user agent string. - * @returns {Object} A platform object. - */ - function parse(ua) { - - ua || (ua = userAgent); - - /** Temporary variable used over the script's lifetime */ - var data; - - /** The CPU architecture */ - var arch = ua; - - /** Platform description array */ - var description = []; - - /** Platform alpha/beta indicator */ - var prerelease = null; - - /** A flag to indicate that environment features should be used to resolve the platform */ - var useFeatures = ua == userAgent; - - /** The browser/environment version */ - var version = useFeatures && opera && typeof opera.version == 'function' && opera.version(); - - /* Detectable layout engines (order is important) */ - var layout = getLayout([ - { 'label': 'WebKit', 'pattern': 'AppleWebKit' }, - 'iCab', - 'Presto', - 'NetFront', - 'Tasman', - 'Trident', - 'KHTML', - 'Gecko' - ]); - - /* Detectable browser names (order is important) */ - var name = getName([ - 'Adobe AIR', - 'Arora', - 'Avant Browser', - 'Camino', - 'Epiphany', - 'Fennec', - 'Flock', - 'Galeon', - 'GreenBrowser', - 'iCab', - 'Iceweasel', - 'Iron', - 'K-Meleon', - 'Konqueror', - 'Lunascape', - 'Maxthon', - 'Midori', - 'Nook Browser', - 'PhantomJS', - 'Raven', - 'Rekonq', - 'RockMelt', - 'SeaMonkey', - { 'label': 'Silk', 'pattern': '(?:Cloud9|Silk-Accelerated)' }, - 'Sleipnir', - 'SlimBrowser', - 'Sunrise', - 'Swiftfox', - 'WebPositive', - 'Opera Mini', - 'Opera', - 'Chrome', - { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' }, - { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' }, - { 'label': 'IE', 'pattern': 'MSIE' }, - 'Safari' - ]); - - /* Detectable products (order is important) */ - var product = getProduct([ - 'BlackBerry', - { 'label': 'Galaxy S', 'pattern': 'GT-I9000' }, - { 'label': 'Galaxy S2', 'pattern': 'GT-I9100' }, - 'Google TV', - 'iPad', - 'iPod', - 'iPhone', - 'Kindle', - { 'label': 'Kindle Fire', 'pattern': '(?:Cloud9|Silk-Accelerated)' }, - 'Nook', - 'PlayBook', - 'PlayStation Vita', - 'TouchPad', - 'Transformer', - 'Xoom' - ]); - - /* Detectable manufacturers */ - var manufacturer = getManufacturer({ - 'Apple': { 'iPad': 1, 'iPhone': 1, 'iPod': 1 }, - 'Amazon': { 'Kindle': 1, 'Kindle Fire': 1 }, - 'Asus': { 'Transformer': 1 }, - 'Barnes & Noble': { 'Nook': 1 }, - 'BlackBerry': { 'PlayBook': 1 }, - 'Google': { 'Google TV': 1 }, - 'HP': { 'TouchPad': 1 }, - 'LG': { }, - 'Motorola': { 'Xoom': 1 }, - 'Nokia': { }, - 'Samsung': { 'Galaxy S': 1, 'Galaxy S2': 1 }, - 'Sony': { 'PlayStation Vita': 1 } - }); - - /* Detectable OSes (order is important) */ - var os = getOS([ - 'Android', - 'CentOS', - 'Debian', - 'Fedora', - 'FreeBSD', - 'Gentoo', - 'Haiku', - 'Kubuntu', - 'Linux Mint', - 'Red Hat', - 'SuSE', - 'Ubuntu', - 'Xubuntu', - 'Cygwin', - 'Symbian OS', - 'hpwOS', - 'webOS ', - 'webOS', - 'Tablet OS', - 'Linux', - 'Mac OS X', - 'Macintosh', - 'Mac', - 'Windows 98;', - 'Windows ' - ]); - - /*------------------------------------------------------------------------*/ - - /** - * Picks the layout engine from an array of guesses. - * - * @private - * @param {Array} guesses An array of guesses. - * @returns {String|Null} The detected layout engine. - */ - function getLayout(guesses) { - return reduce(guesses, function(result, guess) { - return result || RegExp('\\b' + ( - guess.pattern || qualify(guess) - ) + '\\b', 'i').exec(ua) && (guess.label || guess); - }); - } - - /** - * Picks the manufacturer from an array of guesses. - * - * @private - * @param {Array} guesses An array of guesses. - * @returns {String|Null} The detected manufacturer. - */ - function getManufacturer(guesses) { - return reduce(guesses, function(result, value, key) { - // lookup the manufacturer by product or scan the UA for the manufacturer - return result || ( - value[product] || - value[0/*Opera 9.25 fix*/, /^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || - RegExp('\\b' + (key.pattern || qualify(key)) + '(?:\\b|\\w*\\d)', 'i').exec(ua) - ) && (key.label || key); - }); - } - - /** - * Picks the browser name from an array of guesses. - * - * @private - * @param {Array} guesses An array of guesses. - * @returns {String|Null} The detected browser name. - */ - function getName(guesses) { - return reduce(guesses, function(result, guess) { - return result || RegExp('\\b' + ( - guess.pattern || qualify(guess) - ) + '\\b', 'i').exec(ua) && (guess.label || guess); - }); - } - - /** - * Picks the OS name from an array of guesses. - * - * @private - * @param {Array} guesses An array of guesses. - * @returns {String|Null} The detected OS name. - */ - function getOS(guesses) { - return reduce(guesses, function(result, guess) { - var pattern = guess.pattern || qualify(guess); - if (!result && (result = - RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua))) { - // platform tokens defined at - // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx - // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx - data = { - '6.2': '8', - '6.1': 'Server 2008 R2 / 7', - '6.0': 'Server 2008 / Vista', - '5.2': 'Server 2003 / XP 64-bit', - '5.1': 'XP', - '5.01': '2000 SP1', - '5.0': '2000', - '4.0': 'NT', - '4.90': 'ME' - }; - // detect Windows version from platform tokens - if (/^Win/i.test(result) && - (data = data[0/*Opera 9.25 fix*/, /[\d.]+$/.exec(result)])) { - result = 'Windows ' + data; - } - // correct character case and cleanup - result = format(String(result) - .replace(RegExp(pattern, 'i'), guess.label || guess) - .replace(/ ce$/i, ' CE') - .replace(/hpw/i, 'web') - .replace(/Macintosh/, 'Mac OS') - .replace(/_PowerPC/i, ' OS') - .replace(/(OS X) [^ \d]+/i, '$1') - .replace(/\/(\d)/, ' $1') - .replace(/_/g, '.') - .replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, '') - .replace(/x86\.64/gi, 'x86_64') - .split(' on ')[0]); - } - return result; - }); - } - - /** - * Picks the product name from an array of guesses. - * - * @private - * @param {Array} guesses An array of guesses. - * @returns {String|Null} The detected product name. - */ - function getProduct(guesses) { - return reduce(guesses, function(result, guess) { - var pattern = guess.pattern || qualify(guess); - if (!result && (result = - RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || - RegExp('\\b' + pattern + '(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)', 'i').exec(ua) - )) { - // split by forward slash and append product version if needed - if ((result = String(guess.label || result).split('/'))[1] && !/[\d.]+/.test(result[0])) { - result[0] += ' ' + result[1]; - } - // correct character case and cleanup - guess = guess.label || guess; - result = format(result[0] - .replace(RegExp(pattern, 'i'), guess) - .replace(RegExp('; *(?:' + guess + '[_-])?', 'i'), ' ') - .replace(RegExp('(' + guess + ')(\\w)', 'i'), '$1 $2')); - } - return result; - }); - } - - /** - * Resolves the version using an array of UA patterns. - * - * @private - * @param {Array} patterns An array of UA patterns. - * @returns {String|Null} The detected version. - */ - function getVersion(patterns) { - return reduce(patterns, function(result, pattern) { - return result || (RegExp(pattern + - '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null; - }); - } - - /*------------------------------------------------------------------------*/ - - /** - * Returns `platform.description` when the platform object is coerced to a string. - * - * @name toString - * @memberOf platform - * @returns {String} Returns `platform.description` if available, else an empty string. - */ - function toStringPlatform() { - return this.description || ''; - } - - /*------------------------------------------------------------------------*/ - - // convert layout to an array so we can add extra details - layout && (layout = [layout]); - - // detect product names that contain their manufacturer's name - if (manufacturer && !product) { - product = getProduct([manufacturer]); - } - // clean up Google TV - if ((data = /Google TV/.exec(product))) { - product = data[0]; - } - // detect simulators - if (/\bSimulator\b/i.test(ua)) { - product = (product ? product + ' ' : '') + 'Simulator'; - } - // detect iOS - if (/^iP/.test(product)) { - name || (name = 'Safari'); - os = 'iOS' + ((data = / OS ([\d_]+)/i.exec(ua)) - ? ' ' + data[1].replace(/_/g, '.') - : ''); - } - // detect Kubuntu - else if (name == 'Konqueror' && !/buntu/i.test(os)) { - os = 'Kubuntu'; - } - // detect Android browsers - else if (manufacturer && manufacturer != 'Google' && - /Chrome|Vita/.test(name + ';' + product)) { - name = 'Android Browser'; - os = /Android/.test(os) ? os : 'Android'; - } - // detect false positives for Firefox/Safari - else if (!name || (data = !/\bMinefield\b/i.test(ua) && /Firefox|Safari/.exec(name))) { - // escape the `/` for Firefox 1 - if (name && !product && /[\/,]|^[^(]+?\)/.test(ua.slice(ua.indexOf(data + '/') + 8))) { - // clear name of false positives - name = null; - } - // reassign a generic name - if ((data = product || manufacturer || os) && - (product || manufacturer || /Android|Symbian OS|Tablet OS|webOS/.test(os))) { - name = /[a-z]+(?: Hat)?/i.exec(/Android/.test(os) ? os : data) + ' Browser'; - } - } - // detect non-Opera versions (order is important) - if (!version) { - version = getVersion([ - '(?:Cloud9|CriOS|CrMo|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))', - 'Version', - qualify(name), - '(?:Firefox|Minefield|NetFront)' - ]); - } - // detect stubborn layout engines - if (layout == 'iCab' && parseFloat(version) > 3) { - layout = ['WebKit']; - } else if (data = - /Opera/.test(name) && 'Presto' || - /\b(?:Midori|Nook|Safari)\b/i.test(ua) && 'WebKit' || - !layout && /\bMSIE\b/i.test(ua) && (/^Mac/.test(os) ? 'Tasman' : 'Trident')) { - layout = [data]; - } - // leverage environment features - if (useFeatures) { - // detect server-side environments - // Rhino has a global function while others have a global object - if (isHostType(window, 'global')) { - if (java) { - data = java.lang.System; - arch = data.getProperty('os.arch'); - os = os || data.getProperty('os.name') + ' ' + data.getProperty('os.version'); - } - if (typeof exports == 'object' && exports) { - // if `thisBinding` is the [ModuleScope] - if (thisBinding == oldWin && typeof system == 'object' && (data = [system])[0]) { - os || (os = data[0].os || null); - try { - data[1] = require('ringo/engine').version; - version = data[1].join('.'); - name = 'RingoJS'; - } catch(e) { - if (data[0].global == freeGlobal) { - name = 'Narwhal'; - } - } - } else if (typeof process == 'object' && (data = process)) { - name = 'Node.js'; - arch = data.arch; - os = data.platform; - version = /[\d.]+/.exec(data.version)[0]; - } - } else if (getClassOf(window.environment) == 'Environment') { - name = 'Rhino'; - } - } - // detect Adobe AIR - else if (getClassOf(data = window.runtime) == 'ScriptBridgingProxyObject') { - name = 'Adobe AIR'; - os = data.flash.system.Capabilities.os; - } - // detect PhantomJS - else if (getClassOf(data = window.phantom) == 'RuntimeObject') { - name = 'PhantomJS'; - version = (data = data.version || null) && (data.major + '.' + data.minor + '.' + data.patch); - } - // detect IE compatibility modes - else if (typeof doc.documentMode == 'number' && (data = /\bTrident\/(\d+)/i.exec(ua))) { - // we're in compatibility mode when the Trident version + 4 doesn't - // equal the document mode - version = [version, doc.documentMode]; - if ((data = +data[1] + 4) != version[1]) { - description.push('IE ' + version[1] + ' mode'); - layout[1] = ''; - version[1] = data; - } - version = name == 'IE' ? String(version[1].toFixed(1)) : version[0]; - } - os = os && format(os); - } - // detect prerelease phases - if (version && (data = - /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(version) || - /(?:alpha|beta)(?: ?\d)?/i.exec(ua + ';' + (useFeatures && nav.appMinorVersion)) || - /\bMinefield\b/i.test(ua) && 'a')) { - prerelease = /b/i.test(data) ? 'beta' : 'alpha'; - version = version.replace(RegExp(data + '\\+?$'), '') + - (prerelease == 'beta' ? beta : alpha) + (/\d+\+?/.exec(data) || ''); - } - // rename code name "Fennec" - if (name == 'Fennec') { - name = 'Firefox Mobile'; - } - // obscure Maxthon's unreliable version - else if (name == 'Maxthon' && version) { - version = version.replace(/\.[\d.]+/, '.x'); - } - // detect Silk desktop/accelerated modes - else if (name == 'Silk') { - if (!/Mobi/i.test(ua)) { - os = 'Android'; - description.unshift('desktop mode'); - } - if (/Accelerated *= *true/i.test(ua)) { - description.unshift('accelerated'); - } - } - // detect Windows Phone desktop mode - else if (name == 'IE' && (data = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(ua) || 0)[1])) { - name += ' Mobile'; - os = 'Windows Phone OS ' + data + '.x'; - description.unshift('desktop mode'); - } - // add mobile postfix - else if ((name == 'IE' || name && !product && !/Browser|Mobi/.test(name)) && - (os == 'Windows CE' || /Mobi/i.test(ua))) { - name += ' Mobile'; - } - // detect IE platform preview - else if (name == 'IE' && useFeatures && typeof external == 'object' && !external) { - description.unshift('platform preview'); - } - // detect BlackBerry OS version - // http://docs.blackberry.com/en/developers/deliverables/18169/HTTP_headers_sent_by_BB_Browser_1234911_11.jsp - else if (/BlackBerry/.test(product) && (data = - (RegExp(product.replace(/ +/g, ' *') + '/([.\\d]+)', 'i').exec(ua) || 0)[1] || - version)) { - os = 'Device Software ' + data; - version = null; - } - // detect Opera identifying/masking itself as another browser - // http://www.opera.com/support/kb/view/843/ - else if (this != forOwn && ( - (useFeatures && opera) || - (/Opera/.test(name) && /\b(?:MSIE|Firefox)\b/i.test(ua)) || - (name == 'Firefox' && /OS X (?:\d+\.){2,}/.test(os)) || - (name == 'IE' && ( - (os && !/^Win/.test(os) && version > 5.5) || - /Windows XP/.test(os) && version > 8 || - version == 8 && !/Trident/.test(ua) - )) - ) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) { - - // when "indentifying", the UA contains both Opera and the other browser's name - data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : ''); - if (reOpera.test(name)) { - if (/IE/.test(data) && os == 'Mac OS') { - os = null; - } - data = 'identify' + data; - } - // when "masking", the UA contains only the other browser's name - else { - data = 'mask' + data; - if (operaClass) { - name = format(operaClass.replace(/([a-z])([A-Z])/g, '$1 $2')); - } else { - name = 'Opera'; - } - if (/IE/.test(data)) { - os = null; - } - if (!useFeatures) { - version = null; - } - } - layout = ['Presto']; - description.push(data); - } - // detect WebKit Nightly and approximate Chrome/Safari versions - if ((data = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(ua) || 0)[1])) { - // correct build for numeric comparison - // (e.g. "532.5" becomes "532.05") - data = [parseFloat(data.replace(/\.(\d)$/, '.0$1')), data]; - // nightly builds are postfixed with a `+` - if (name == 'Safari' && data[1].slice(-1) == '+') { - name = 'WebKit Nightly'; - prerelease = 'alpha'; - version = data[1].slice(0, -1); - } - // clear incorrect browser versions - else if (version == data[1] || - version == (/\bSafari\/([\d.]+\+?)/i.exec(ua) || 0)[1]) { - version = null; - } - // use the full Chrome version when available - data = [data[0], (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1]]; - - // detect JavaScriptCore - // http://stackoverflow.com/questions/6768474/how-can-i-detect-which-javascript-engine-v8-or-jsc-is-used-at-runtime-in-androi - if (!useFeatures || (/internal|\n/i.test(toString.toString()) && !data[1])) { - layout[1] = 'like Safari'; - data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : '5'); - } else { - layout[1] = 'like Chrome'; - data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : '21'); - } - // add the postfix of ".x" or "+" for approximate versions - layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'); - // obscure version for some Safari 1-2 releases - if (name == 'Safari' && (!version || parseInt(version) > 45)) { - version = data; - } - } - // detect Opera desktop modes - if (name == 'Opera' && (data = /(?:zbov|zvav)$/.exec(os))) { - name += ' '; - description.unshift('desktop mode'); - if (data == 'zvav') { - name += 'Mini'; - version = null; - } else { - name += 'Mobile'; - } - } - // detect Chrome desktop mode - else if (name == 'Safari' && /Chrome/.exec(layout[1])) { - description.unshift('desktop mode'); - name = 'Chrome Mobile'; - version = null; - - if (/Mac OS X/.test(os)) { - manufacturer = 'Apple'; - os = 'iOS 4.3+'; - } else { - os = null; - } - } - // strip incorrect OS versions - if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 && - ua.indexOf('/' + data + '-') > -1) { - os = trim(os.replace(data, '')); - } - // add layout engine - if (layout && !/Avant|Nook/.test(name) && ( - /Browser|Lunascape|Maxthon/.test(name) || - /^(?:Adobe|Arora|Midori|Phantom|Rekonq|Rock|Sleipnir|Web)/.test(name) && layout[1])) { - // don't add layout details to description if they are falsey - (data = layout[layout.length - 1]) && description.push(data); - } - // combine contextual information - if (description.length) { - description = ['(' + description.join('; ') + ')']; - } - // append manufacturer - if (manufacturer && product && product.indexOf(manufacturer) < 0) { - description.push('on ' + manufacturer); - } - // append product - if (product) { - description.push((/^on /.test(description[description.length -1]) ? '' : 'on ') + product); - } - // parse OS into an object - if (os) { - data = / ([\d.+]+)$/.exec(os); - os = { - 'architecture': 32, - 'family': data ? os.replace(data[0], '') : os, - 'version': data ? data[1] : null, - 'toString': function() { - var version = this.version; - return this.family + (version ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : ''); - } - }; - } - // add browser/OS architecture - if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) { - if (os) { - os.architecture = 64; - os.family = os.family.replace(RegExp(' *' + data), ''); - } - if (name && (/WOW64/i.test(ua) || - (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform)))) { - description.unshift('32-bit'); - } - } - - ua || (ua = null); - - /*------------------------------------------------------------------------*/ - - /** - * The platform object. - * - * @name platform - * @type Object - */ - return { - - /** - * The browser/environment version. - * - * @memberOf platform - * @type String|Null - */ - 'version': name && version && (description.unshift(version), version), - - /** - * The name of the browser/environment. - * - * @memberOf platform - * @type String|Null - */ - 'name': name && (description.unshift(name), name), - - /** - * The name of the operating system. - * - * @memberOf platform - * @type Object - */ - 'os': os - ? (name && - !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product)) && - description.push(product ? '(' + os + ')' : 'on ' + os), os) - : { - - /** - * The CPU architecture the OS is built for. - * - * @memberOf platform.os - * @type String|Null - */ - 'architecture': null, - - /** - * The family of the OS. - * - * @memberOf platform.os - * @type String|Null - */ - 'family': null, - - /** - * The version of the OS. - * - * @memberOf platform.os - * @type String|Null - */ - 'version': null, - - /** - * Returns the OS string. - * - * @memberOf platform.os - * @returns {String} The OS string. - */ - 'toString': function() { return 'null'; } - }, - - /** - * The platform description. - * - * @memberOf platform - * @type String|Null - */ - 'description': description.length ? description.join(' ') : ua, - - /** - * The name of the browser layout engine. - * - * @memberOf platform - * @type String|Null - */ - 'layout': layout && layout[0], - - /** - * The name of the product's manufacturer. - * - * @memberOf platform - * @type String|Null - */ - 'manufacturer': manufacturer, - - /** - * The alpha/beta release indicator. - * - * @memberOf platform - * @type String|Null - */ - 'prerelease': prerelease, - - /** - * The name of the product hosting the browser. - * - * @memberOf platform - * @type String|Null - */ - 'product': product, - - /** - * The browser's user agent string. - * - * @memberOf platform - * @type String|Null - */ - 'ua': ua, - - // parses a user agent string into a platform object - 'parse': parse, - - // returns the platform description - 'toString': toStringPlatform - }; - } - - /*--------------------------------------------------------------------------*/ - - // expose platform - // some AMD build optimizers, like r.js, check for specific condition patterns like the following: - if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // define as an anonymous module so, through path mapping, it can be aliased - define(function() { - return parse(); - }); - } - // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports) { - // in Narwhal, Node.js, or RingoJS - forOwn(parse(), function(value, key) { - freeExports[key] = value; - }); - } - // in a browser or Rhino - else { - // use square bracket notation so Closure Compiler won't munge `platform` - // http://code.google.com/closure/compiler/docs/api-tutorial3.html#export - window['platform'] = parse(); - } -}(this)); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/LICENSE.txt b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/LICENSE.txt deleted file mode 100644 index dadad22..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright 2011-2012 John-David Dalton - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/README.md deleted file mode 100644 index b84a21c..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# QUnit CLIB v1.0.0 -## command-line interface boilerplate - -QUnit CLIB helps extend QUnit's CLI support to many common CLI environments. - -## Screenshot - -![QUnit CLIB brings QUnit to your favorite shell.](http://i.imgur.com/jpu9l.png) - -## Support - -QUnit CLIB has been tested in at least Node.js 0.4.8-0.8.6, Narwhal v0.3.2, RingoJS v0.8.0, and Rhino v1.7RC3-RC5. - -## Usage - -```js -(function(window) { - - // use a single load function - var load = typeof require == 'function' ? require : window.load; - - // load QUnit and CLIB if needed - var QUnit = - window.QUnit || ( - window.setTimeout || (window.addEventListener = window.setTimeout = / /), - window.QUnit = load('path/to/qunit.js') || window.QUnit, - load('path/to/qunit-clib.js'), - (window.addEventListener || 0).test && delete window.addEventListener, - window.QUnit - ); - - // explicitly call `QUnit.module()` instead of `module()` - // in case we are in a CLI environment - QUnit.module('A Test Module'); - - test('A Test', function() { - // ... - }); - - // must call `QUnit.start()` if using QUnit < 1.3.0 with Node.js or any - // version of QUnit with Narwhal, Rhino, or RingoJS - if (!window.document) { - QUnit.start(); - } -}(typeof global == 'object' && global || this)); -``` - -## Footnotes - - 1. QUnit v1.3.0 does not work with Narwhal or Ringo < v0.8.0 - - 2. Rhino v1.7RC4 does not support timeout fallbacks `clearTimeout` and `setTimeout` - -## Author - -* [John-David Dalton](http://allyoucanleet.com/) - [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/qunit-clib.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/qunit-clib.js deleted file mode 100644 index 14a3da8..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit-clib/qunit-clib.js +++ /dev/null @@ -1,324 +0,0 @@ -/*! - * QUnit CLI Boilerplate v1.0.0 - * Copyright 2011-2012 John-David Dalton - * Based on a gist by Jörn Zaefferer - * Available under MIT license - */ -;(function(global) { - 'use strict'; - - /** Add `console.log()` support for Narwhal, Rhino, and RingoJS */ - global.console || (global.console = { 'log': global.print }); - - /** Reduce global.QUnit.QUnit -> global.QUnit */ - global.QUnit && (QUnit = QUnit.QUnit || QUnit); - - /*--------------------------------------------------------------------------*/ - - /** Used as a horizontal rule in console output */ - var hr = '----------------------------------------'; - - /** Shortcut used to convert array-like objects to arrays */ - var slice = [].slice; - - /** Used to resolve a value's internal [[Class]] */ - var toString = {}.toString; - - /** Used by timer methods */ - var doneCalled, - timer, - counter = 0, - ids = {}; - - /*--------------------------------------------------------------------------*/ - - /** - * An iteration utility for arrays. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function called per iteration. - */ - function each(array, callback) { - var index = -1, - length = array.length; - - while (++index < length) { - callback(array[index], index, array); - } - } - - /** - * Checks if the specified `value` is a function. - * - * @private - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true` if `value` is a function, else `false`. - */ - function isFunction(value) { - return toString.call(value) == '[object Function]'; - } - - /*--------------------------------------------------------------------------*/ - - /** - * Timeout fallbacks based on the work of Andrea Giammarchi and Weston C. - * https://github.com/WebReflection/wru/blob/master/src/rhinoTimers.js - * http://stackoverflow.com/questions/2261705/how-to-run-a-javascript-function-asynchronously-without-using-settimeout - */ - - /** - * Clears the delay set by `setInterval` or `setTimeout`. - * - * @memberOf global - * @param {Number} id The ID of the timeout to be cleared. - */ - function clearTimer(id) { - if (ids[id]) { - ids[id].cancel(); - timer.purge(); - delete ids[id]; - } - } - - /** - * Schedules timer-based callbacks. - * - * @private - * @param {Function} fn The function to call. - * @oaram {Number} delay The number of milliseconds to delay the `fn` call. - * @param [arg1, arg2, ...] Arguments to invoke `fn` with. - * @param {Boolean} repeated A flag to specify whether `fn` is called repeatedly. - * @returns {Number} The the ID of the timeout. - */ - function schedule(fn, delay, args, repeated) { - // Rhino 1.7RC4 will error assigning `task` below - // https://bugzilla.mozilla.org/show_bug.cgi?id=775566 - var task = ids[++counter] = new JavaAdapter(java.util.TimerTask, { - 'run': function() { - fn.apply(global, args); - } - }); - // support non-functions - if (!isFunction(fn)) { - fn = (function(code) { - code = String(code); - return function() { eval(code); }; - }(fn)); - } - // used by setInterval - if (repeated) { - timer.schedule(task, delay, delay); - } - // used by setTimeout - else { - timer.schedule(task, delay); - } - return counter; - } - - /** - * Executes a code snippet or function repeatedly, with a delay between each call. - * - * @memberOf global - * @param {Function|String} fn The function to call or string to evaluate. - * @oaram {Number} delay The number of milliseconds to delay each `fn` call. - * @param [arg1, arg2, ...] Arguments to invoke `fn` with. - * @returns {Number} The the ID of the timeout. - */ - function setInterval(fn, delay) { - return schedule(fn, delay, slice.call(arguments, 2), true); - } - - /** - * Executes a code snippet or a function after specified delay. - * - * @memberOf global - * @param {Function|String} fn The function to call or string to evaluate. - * @oaram {Number} delay The number of milliseconds to delay the `fn` call. - * @param [arg1, arg2, ...] Arguments to invoke `fn` with. - * @returns {Number} The the ID of the timeout. - */ - function setTimeout(fn, delay) { - return schedule(fn, delay, slice.call(arguments, 2)); - } - - /*--------------------------------------------------------------------------*/ - - /** - * A logging callback triggered when all testing is completed. - * - * @memberOf QUnit - * @param {Object} details An object with properties `failed`, `passed`, - * `runtime`, and `total`. - */ - function done(details) { - // stop `asyncTest()` from erroneously calling `done()` twice in - // environments w/o timeouts - if (doneCalled) { - return; - } - doneCalled = true; - console.log(hr); - console.log(' PASS: ' + details.passed + ' FAIL: ' + details.failed + ' TOTAL: ' + details.total); - console.log(' Finished in ' + details.runtime + ' milliseconds.'); - console.log(hr); - - // exit out of Rhino - try { - quit(); - } catch(e) { } - - // exit out of Node.js - try { - if (details.failed) { - console.error('Error: ' + details.failed + ' of ' + details.total + ' tests failed.'); - process.exit(1); - } else { - process.exit(0); - } - } catch(e) { } - } - - /** - * A logging callback triggered after every assertion. - * - * @memberOf QUnit - * @param {Object} details An object with properties `actual`, `expected`, - * `message`, and `result`. - */ - function log(details) { - var expected = details.expected, - result = details.result, - type = typeof expected != 'undefined' ? 'EQ' : 'OK'; - - var assertion = [ - result ? 'PASS' : 'FAIL', - type, - details.message || 'ok' - ]; - - if (!result && type == 'EQ') { - assertion.push('Expected: ' + expected + ', Actual: ' + details.actual); - } - QUnit.config.testStats.assertions.push(assertion.join(' | ')); - } - - /** - * A logging callback triggered at the start of every test module. - * - * @memberOf QUnit - * @param {Object} details An object with property `name`. - */ - function moduleStart(details) { - console.log(hr); - console.log(details.name); - console.log(hr); - } - - /** - * Converts an object into a string representation. - * - * @memberOf QUnit - * @type Function - * @param {Object} object The object to stringify. - * @returns {String} The result string. - */ - var parseObject = (function() { - var func = QUnit.jsDump.parsers.object; - return function(object) { - // fork to support Rhino's error objects - if (typeof object.rhinoException == 'object') { - return object.name + - ' { message: "' + object.message + - '", fileName: "' + object.fileName + - '", lineNumber: ' + object.lineNumber + ' }'; - } - return func(object); - }; - }()); - - /** - * A logging callback triggered after a test is completed. - * - * @memberOf QUnit - * @param {Object} details An object with properties `failed`, `name`, - * `passed`, and `total`. - */ - function testDone(details) { - var assertions = QUnit.config.testStats.assertions, - testName = details.name; - - if (details.failed > 0) { - console.log(' FAIL - '+ testName); - each(assertions, function(value) { - console.log(' ' + value); - }); - } - else { - console.log(' PASS - ' + testName); - } - assertions.length = 0; - } - - /*--------------------------------------------------------------------------*/ - - /** - * An object used to hold information about the current running test. - * - * @memberOf QUnit.config - * @type Object - */ - QUnit.config.testStats = { - - /** - * An array of test summaries (pipe separated). - * - * @memberOf QUnit.config.testStats - * @type Array - */ - 'assertions': [] - }; - - // add shortcuts to the global - // exclude `module` because some environments have it as a built-in object - each(['asyncTest', 'deepEqual', 'equal', 'equals', 'expect', 'notDeepEqual', - 'notEqual', 'notStrictEqual', 'ok', 'raises', 'same', 'start', 'stop', - 'strictEqual', 'test', 'throws'], function(funcName) { - var func = QUnit[funcName]; - if (func) { - global[funcName] = func; - } - }); - - // expose timer methods to global - try { - timer = new java.util.Timer; - if (!isFunction(global.clearInterval)) { - global.clearInterval = clearTimer; - } - if (!isFunction(global.clearTimeout)) { - global.clearTimeout = clearTimer; - } - if (!isFunction(global.setInterval)) { - global.setInterval = setInterval; - } - if (!isFunction(global.setTimeout)) { - global.setTimeout = setTimeout; - } - } catch(e) { } - - // add callbacks - QUnit.done(done); - QUnit.log(log); - QUnit.moduleStart(moduleStart); - QUnit.testDone(testDone); - - // add wrapped function - QUnit.jsDump.parsers.object = parseObject; - - // must call `QUnit.start()` in the test file if using QUnit < 1.3.0 with - // Node.js or any version of QUnit with Narwhal, Rhino, or RingoJS - QUnit.init(); - -}(typeof global == 'object' && global || this)); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/README.md deleted file mode 100644 index 57ff29e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/README.md +++ /dev/null @@ -1,59 +0,0 @@ -[QUnit](http://qunitjs.com) - A JavaScript Unit Testing framework. -================================ - -QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery -project to test its code and plugins but is capable of testing any generic -JavaScript code (and even capable of testing JavaScript code on the server-side). - -QUnit is especially useful for regression testing: Whenever a bug is reported, -write a test that asserts the existence of that particular bug. Then fix it and -commit both. Every time you work on the code again, run the tests. If the bug -comes up again - a regression - you'll spot it immediately and know how to fix -it, because you know what code you just changed. - -Having good unit test coverage makes safe refactoring easy and cheap. You can -run the tests after each small refactoring step and always know what change -broke something. - -QUnit is similar to other unit testing frameworks like JUnit, but makes use of -the features JavaScript provides and helps with testing code in the browser, e.g. -with its stop/start facilities for testing asynchronous code. - -If you are interested in helping developing QUnit, you are in the right place. -For related discussions, visit the -[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing). - -Planning for a qunitjs.com site and other testing tools related work now happens -on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage). - -Development ------------ - -To submit patches, fork the repository, create a branch for the change. Then implement -the change, run `grunt` to lint and test it, then commit, push and create a pull request. - -Include some background for the change in the commit message and `Fixes #nnn`, referring -to the issue number you're addressing. - -To run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global -grunt binary. For additional grunt tasks, also run `npm install`. - -Releases --------- - -Install git-extras and run `git changelog` to update History.md. -Update qunit/qunit.js|css and package.json to the release version, commit and -tag, update them again to the next version, commit and push commits and tags -(`git push --tags origin master`). - -Put the 'v' in front of the tag, e.g. `v1.8.0`. Clean up the changelog, removing merge commits -or whitespace cleanups. - -To upload to code.jquery.com (replace $version accordingly): - - scp -q qunit/qunit.js jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/qunit/qunit-$version.js - scp -q qunit/qunit.css jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/qunit/qunit-$version.css - -Then update /var/www/html/code.jquery.com/index.html and purge it with: - - curl -s http://code.origin.jquery.com/?reload \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/qunit/qunit.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/qunit/qunit.js deleted file mode 100644 index d4f17b5..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/qunit/qunit/qunit.js +++ /dev/null @@ -1,1977 +0,0 @@ -/** - * QUnit v1.10.0 - A JavaScript Unit Testing Framework - * - * http://qunitjs.com - * - * Copyright 2012 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - */ - -(function( window ) { - -var QUnit, - config, - onErrorFnPrev, - testId = 0, - fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""), - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty, - // Keep a local reference to Date (GH-283) - Date = window.Date, - defined = { - setTimeout: typeof window.setTimeout !== "undefined", - sessionStorage: (function() { - var x = "qunit-test-string"; - try { - sessionStorage.setItem( x, x ); - sessionStorage.removeItem( x ); - return true; - } catch( e ) { - return false; - } - }()) -}; - -function Test( settings ) { - extend( this, settings ); - this.assertions = []; - this.testNumber = ++Test.count; -} - -Test.count = 0; - -Test.prototype = { - init: function() { - var a, b, li, - tests = id( "qunit-tests" ); - - if ( tests ) { - b = document.createElement( "strong" ); - b.innerHTML = this.name; - - // `a` initialized at top of scope - a = document.createElement( "a" ); - a.innerHTML = "Rerun"; - a.href = QUnit.url({ testNumber: this.testNumber }); - - li = document.createElement( "li" ); - li.appendChild( b ); - li.appendChild( a ); - li.className = "running"; - li.id = this.id = "qunit-test-output" + testId++; - - tests.appendChild( li ); - } - }, - setup: function() { - if ( this.module !== config.previousModule ) { - if ( config.previousModule ) { - runLoggingCallbacks( "moduleDone", QUnit, { - name: config.previousModule, - failed: config.moduleStats.bad, - passed: config.moduleStats.all - config.moduleStats.bad, - total: config.moduleStats.all - }); - } - config.previousModule = this.module; - config.moduleStats = { all: 0, bad: 0 }; - runLoggingCallbacks( "moduleStart", QUnit, { - name: this.module - }); - } else if ( config.autorun ) { - runLoggingCallbacks( "moduleStart", QUnit, { - name: this.module - }); - } - - config.current = this; - - this.testEnvironment = extend({ - setup: function() {}, - teardown: function() {} - }, this.moduleTestEnvironment ); - - runLoggingCallbacks( "testStart", QUnit, { - name: this.testName, - module: this.module - }); - - // allow utility functions to access the current test environment - // TODO why?? - QUnit.current_testEnvironment = this.testEnvironment; - - if ( !config.pollution ) { - saveGlobal(); - } - if ( config.notrycatch ) { - this.testEnvironment.setup.call( this.testEnvironment ); - return; - } - try { - this.testEnvironment.setup.call( this.testEnvironment ); - } catch( e ) { - QUnit.pushFailure( "Setup failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) ); - } - }, - run: function() { - config.current = this; - - var running = id( "qunit-testresult" ); - - if ( running ) { - running.innerHTML = "Running:
    " + this.name; - } - - if ( this.async ) { - QUnit.stop(); - } - - if ( config.notrycatch ) { - this.callback.call( this.testEnvironment, QUnit.assert ); - return; - } - - try { - this.callback.call( this.testEnvironment, QUnit.assert ); - } catch( e ) { - QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + e.message, extractStacktrace( e, 0 ) ); - // else next test will carry the responsibility - saveGlobal(); - - // Restart the tests if they're blocking - if ( config.blocking ) { - QUnit.start(); - } - } - }, - teardown: function() { - config.current = this; - if ( config.notrycatch ) { - this.testEnvironment.teardown.call( this.testEnvironment ); - return; - } else { - try { - this.testEnvironment.teardown.call( this.testEnvironment ); - } catch( e ) { - QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) ); - } - } - checkPollution(); - }, - finish: function() { - config.current = this; - if ( config.requireExpects && this.expected == null ) { - QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack ); - } else if ( this.expected != null && this.expected != this.assertions.length ) { - QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack ); - } else if ( this.expected == null && !this.assertions.length ) { - QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack ); - } - - var assertion, a, b, i, li, ol, - test = this, - good = 0, - bad = 0, - tests = id( "qunit-tests" ); - - config.stats.all += this.assertions.length; - config.moduleStats.all += this.assertions.length; - - if ( tests ) { - ol = document.createElement( "ol" ); - - for ( i = 0; i < this.assertions.length; i++ ) { - assertion = this.assertions[i]; - - li = document.createElement( "li" ); - li.className = assertion.result ? "pass" : "fail"; - li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" ); - ol.appendChild( li ); - - if ( assertion.result ) { - good++; - } else { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - - // store result when possible - if ( QUnit.config.reorder && defined.sessionStorage ) { - if ( bad ) { - sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad ); - } else { - sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName ); - } - } - - if ( bad === 0 ) { - ol.style.display = "none"; - } - - // `b` initialized at top of scope - b = document.createElement( "strong" ); - b.innerHTML = this.name + " (" + bad + ", " + good + ", " + this.assertions.length + ")"; - - addEvent(b, "click", function() { - var next = b.nextSibling.nextSibling, - display = next.style.display; - next.style.display = display === "none" ? "block" : "none"; - }); - - addEvent(b, "dblclick", function( e ) { - var target = e && e.target ? e.target : window.event.srcElement; - if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) { - target = target.parentNode; - } - if ( window.location && target.nodeName.toLowerCase() === "strong" ) { - window.location = QUnit.url({ testNumber: test.testNumber }); - } - }); - - // `li` initialized at top of scope - li = id( this.id ); - li.className = bad ? "fail" : "pass"; - li.removeChild( li.firstChild ); - a = li.firstChild; - li.appendChild( b ); - li.appendChild ( a ); - li.appendChild( ol ); - - } else { - for ( i = 0; i < this.assertions.length; i++ ) { - if ( !this.assertions[i].result ) { - bad++; - config.stats.bad++; - config.moduleStats.bad++; - } - } - } - - runLoggingCallbacks( "testDone", QUnit, { - name: this.testName, - module: this.module, - failed: bad, - passed: this.assertions.length - bad, - total: this.assertions.length - }); - - QUnit.reset(); - - config.current = undefined; - }, - - queue: function() { - var bad, - test = this; - - synchronize(function() { - test.init(); - }); - function run() { - // each of these can by async - synchronize(function() { - test.setup(); - }); - synchronize(function() { - test.run(); - }); - synchronize(function() { - test.teardown(); - }); - synchronize(function() { - test.finish(); - }); - } - - // `bad` initialized at top of scope - // defer when previous test run passed, if storage is available - bad = QUnit.config.reorder && defined.sessionStorage && - +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName ); - - if ( bad ) { - run(); - } else { - synchronize( run, true ); - } - } -}; - -// Root QUnit object. -// `QUnit` initialized at top of scope -QUnit = { - - // call on start of module test to prepend name to all tests - module: function( name, testEnvironment ) { - config.currentModule = name; - config.currentModuleTestEnvironment = testEnvironment; - config.modules[name] = true; - }, - - asyncTest: function( testName, expected, callback ) { - if ( arguments.length === 2 ) { - callback = expected; - expected = null; - } - - QUnit.test( testName, expected, callback, true ); - }, - - test: function( testName, expected, callback, async ) { - var test, - name = "" + escapeInnerText( testName ) + ""; - - if ( arguments.length === 2 ) { - callback = expected; - expected = null; - } - - if ( config.currentModule ) { - name = "" + config.currentModule + ": " + name; - } - - test = new Test({ - name: name, - testName: testName, - expected: expected, - async: async, - callback: callback, - module: config.currentModule, - moduleTestEnvironment: config.currentModuleTestEnvironment, - stack: sourceFromStacktrace( 2 ) - }); - - if ( !validTest( test ) ) { - return; - } - - test.queue(); - }, - - // Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. - expect: function( asserts ) { - if (arguments.length === 1) { - config.current.expected = asserts; - } else { - return config.current.expected; - } - }, - - start: function( count ) { - config.semaphore -= count || 1; - // don't start until equal number of stop-calls - if ( config.semaphore > 0 ) { - return; - } - // ignore if start is called more often then stop - if ( config.semaphore < 0 ) { - config.semaphore = 0; - } - // A slight delay, to avoid any current callbacks - if ( defined.setTimeout ) { - window.setTimeout(function() { - if ( config.semaphore > 0 ) { - return; - } - if ( config.timeout ) { - clearTimeout( config.timeout ); - } - - config.blocking = false; - process( true ); - }, 13); - } else { - config.blocking = false; - process( true ); - } - }, - - stop: function( count ) { - config.semaphore += count || 1; - config.blocking = true; - - if ( config.testTimeout && defined.setTimeout ) { - clearTimeout( config.timeout ); - config.timeout = window.setTimeout(function() { - QUnit.ok( false, "Test timed out" ); - config.semaphore = 1; - QUnit.start(); - }, config.testTimeout ); - } - } -}; - -// Asssert helpers -// All of these must call either QUnit.push() or manually do: -// - runLoggingCallbacks( "log", .. ); -// - config.current.assertions.push({ .. }); -QUnit.assert = { - /** - * Asserts rough true-ish result. - * @name ok - * @function - * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); - */ - ok: function( result, msg ) { - if ( !config.current ) { - throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) ); - } - result = !!result; - - var source, - details = { - module: config.current.module, - name: config.current.testName, - result: result, - message: msg - }; - - msg = escapeInnerText( msg || (result ? "okay" : "failed" ) ); - msg = "" + msg + ""; - - if ( !result ) { - source = sourceFromStacktrace( 2 ); - if ( source ) { - details.source = source; - msg += "
    Source:
    " + escapeInnerText( source ) + "
    "; - } - } - runLoggingCallbacks( "log", QUnit, details ); - config.current.assertions.push({ - result: result, - message: msg - }); - }, - - /** - * Assert that the first two arguments are equal, with an optional message. - * Prints out both actual and expected values. - * @name equal - * @function - * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" ); - */ - equal: function( actual, expected, message ) { - QUnit.push( expected == actual, actual, expected, message ); - }, - - /** - * @name notEqual - * @function - */ - notEqual: function( actual, expected, message ) { - QUnit.push( expected != actual, actual, expected, message ); - }, - - /** - * @name deepEqual - * @function - */ - deepEqual: function( actual, expected, message ) { - QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); - }, - - /** - * @name notDeepEqual - * @function - */ - notDeepEqual: function( actual, expected, message ) { - QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message ); - }, - - /** - * @name strictEqual - * @function - */ - strictEqual: function( actual, expected, message ) { - QUnit.push( expected === actual, actual, expected, message ); - }, - - /** - * @name notStrictEqual - * @function - */ - notStrictEqual: function( actual, expected, message ) { - QUnit.push( expected !== actual, actual, expected, message ); - }, - - throws: function( block, expected, message ) { - var actual, - ok = false; - - // 'expected' is optional - if ( typeof expected === "string" ) { - message = expected; - expected = null; - } - - config.current.ignoreGlobalErrors = true; - try { - block.call( config.current.testEnvironment ); - } catch (e) { - actual = e; - } - config.current.ignoreGlobalErrors = false; - - if ( actual ) { - // we don't want to validate thrown error - if ( !expected ) { - ok = true; - // expected is a regexp - } else if ( QUnit.objectType( expected ) === "regexp" ) { - ok = expected.test( actual ); - // expected is a constructor - } else if ( actual instanceof expected ) { - ok = true; - // expected is a validation function which returns true is validation passed - } else if ( expected.call( {}, actual ) === true ) { - ok = true; - } - - QUnit.push( ok, actual, null, message ); - } else { - QUnit.pushFailure( message, null, 'No exception was thrown.' ); - } - } -}; - -/** - * @deprecate since 1.8.0 - * Kept assertion helpers in root for backwards compatibility - */ -extend( QUnit, QUnit.assert ); - -/** - * @deprecated since 1.9.0 - * Kept global "raises()" for backwards compatibility - */ -QUnit.raises = QUnit.assert.throws; - -/** - * @deprecated since 1.0.0, replaced with error pushes since 1.3.0 - * Kept to avoid TypeErrors for undefined methods. - */ -QUnit.equals = function() { - QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ); -}; -QUnit.same = function() { - QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" ); -}; - -// We want access to the constructor's prototype -(function() { - function F() {} - F.prototype = QUnit; - QUnit = new F(); - // Make F QUnit's constructor so that we can add to the prototype later - QUnit.constructor = F; -}()); - -/** - * Config object: Maintain internal state - * Later exposed as QUnit.config - * `config` initialized at top of scope - */ -config = { - // The queue of tests to run - queue: [], - - // block until document ready - blocking: true, - - // when enabled, show only failing tests - // gets persisted through sessionStorage and can be changed in UI via checkbox - hidepassed: false, - - // by default, run previously failed tests first - // very useful in combination with "Hide passed tests" checked - reorder: true, - - // by default, modify document.title when suite is done - altertitle: true, - - // when enabled, all tests must call expect() - requireExpects: false, - - // add checkboxes that are persisted in the query-string - // when enabled, the id is set to `true` as a `QUnit.config` property - urlConfig: [ - { - id: "noglobals", - label: "Check for Globals", - tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings." - }, - { - id: "notrycatch", - label: "No try-catch", - tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings." - } - ], - - // Set of all modules. - modules: {}, - - // logging callback queues - begin: [], - done: [], - log: [], - testStart: [], - testDone: [], - moduleStart: [], - moduleDone: [] -}; - -// Initialize more QUnit.config and QUnit.urlParams -(function() { - var i, - location = window.location || { search: "", protocol: "file:" }, - params = location.search.slice( 1 ).split( "&" ), - length = params.length, - urlParams = {}, - current; - - if ( params[ 0 ] ) { - for ( i = 0; i < length; i++ ) { - current = params[ i ].split( "=" ); - current[ 0 ] = decodeURIComponent( current[ 0 ] ); - // allow just a key to turn on a flag, e.g., test.html?noglobals - current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; - urlParams[ current[ 0 ] ] = current[ 1 ]; - } - } - - QUnit.urlParams = urlParams; - - // String search anywhere in moduleName+testName - config.filter = urlParams.filter; - - // Exact match of the module name - config.module = urlParams.module; - - config.testNumber = parseInt( urlParams.testNumber, 10 ) || null; - - // Figure out if we're running the tests from a server or not - QUnit.isLocal = location.protocol === "file:"; -}()); - -// Export global variables, unless an 'exports' object exists, -// in that case we assume we're in CommonJS (dealt with on the bottom of the script) -if ( typeof exports === "undefined" ) { - extend( window, QUnit ); - - // Expose QUnit object - window.QUnit = QUnit; -} - -// Extend QUnit object, -// these after set here because they should not be exposed as global functions -extend( QUnit, { - config: config, - - // Initialize the configuration options - init: function() { - extend( config, { - stats: { all: 0, bad: 0 }, - moduleStats: { all: 0, bad: 0 }, - started: +new Date(), - updateRate: 1000, - blocking: false, - autostart: true, - autorun: false, - filter: "", - queue: [], - semaphore: 0 - }); - - var tests, banner, result, - qunit = id( "qunit" ); - - if ( qunit ) { - qunit.innerHTML = - "

    " + escapeInnerText( document.title ) + "

    " + - "

    " + - "
    " + - "

    " + - "
      "; - } - - tests = id( "qunit-tests" ); - banner = id( "qunit-banner" ); - result = id( "qunit-testresult" ); - - if ( tests ) { - tests.innerHTML = ""; - } - - if ( banner ) { - banner.className = ""; - } - - if ( result ) { - result.parentNode.removeChild( result ); - } - - if ( tests ) { - result = document.createElement( "p" ); - result.id = "qunit-testresult"; - result.className = "result"; - tests.parentNode.insertBefore( result, tests ); - result.innerHTML = "Running...
       "; - } - }, - - // Resets the test setup. Useful for tests that modify the DOM. - reset: function() { - var fixture = id( "qunit-fixture" ); - if ( fixture ) { - fixture.innerHTML = config.fixture; - } - }, - - // Trigger an event on an element. - // @example triggerEvent( document.body, "click" ); - triggerEvent: function( elem, type, event ) { - if ( document.createEvent ) { - event = document.createEvent( "MouseEvents" ); - event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, - 0, 0, 0, 0, 0, false, false, false, false, 0, null); - - elem.dispatchEvent( event ); - } else if ( elem.fireEvent ) { - elem.fireEvent( "on" + type ); - } - }, - - // Safe object type checking - is: function( type, obj ) { - return QUnit.objectType( obj ) == type; - }, - - objectType: function( obj ) { - if ( typeof obj === "undefined" ) { - return "undefined"; - // consider: typeof null === object - } - if ( obj === null ) { - return "null"; - } - - var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || ""; - - switch ( type ) { - case "Number": - if ( isNaN(obj) ) { - return "nan"; - } - return "number"; - case "String": - case "Boolean": - case "Array": - case "Date": - case "RegExp": - case "Function": - return type.toLowerCase(); - } - if ( typeof obj === "object" ) { - return "object"; - } - return undefined; - }, - - push: function( result, actual, expected, message ) { - if ( !config.current ) { - throw new Error( "assertion outside test context, was " + sourceFromStacktrace() ); - } - - var output, source, - details = { - module: config.current.module, - name: config.current.testName, - result: result, - message: message, - actual: actual, - expected: expected - }; - - message = escapeInnerText( message ) || ( result ? "okay" : "failed" ); - message = "" + message + ""; - output = message; - - if ( !result ) { - expected = escapeInnerText( QUnit.jsDump.parse(expected) ); - actual = escapeInnerText( QUnit.jsDump.parse(actual) ); - output += ""; - - if ( actual != expected ) { - output += ""; - output += ""; - } - - source = sourceFromStacktrace(); - - if ( source ) { - details.source = source; - output += ""; - } - - output += "
      Expected:
      " + expected + "
      Result:
      " + actual + "
      Diff:
      " + QUnit.diff( expected, actual ) + "
      Source:
      " + escapeInnerText( source ) + "
      "; - } - - runLoggingCallbacks( "log", QUnit, details ); - - config.current.assertions.push({ - result: !!result, - message: output - }); - }, - - pushFailure: function( message, source, actual ) { - if ( !config.current ) { - throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) ); - } - - var output, - details = { - module: config.current.module, - name: config.current.testName, - result: false, - message: message - }; - - message = escapeInnerText( message ) || "error"; - message = "" + message + ""; - output = message; - - output += ""; - - if ( actual ) { - output += ""; - } - - if ( source ) { - details.source = source; - output += ""; - } - - output += "
      Result:
      " + escapeInnerText( actual ) + "
      Source:
      " + escapeInnerText( source ) + "
      "; - - runLoggingCallbacks( "log", QUnit, details ); - - config.current.assertions.push({ - result: false, - message: output - }); - }, - - url: function( params ) { - params = extend( extend( {}, QUnit.urlParams ), params ); - var key, - querystring = "?"; - - for ( key in params ) { - if ( !hasOwn.call( params, key ) ) { - continue; - } - querystring += encodeURIComponent( key ) + "=" + - encodeURIComponent( params[ key ] ) + "&"; - } - return window.location.pathname + querystring.slice( 0, -1 ); - }, - - extend: extend, - id: id, - addEvent: addEvent - // load, equiv, jsDump, diff: Attached later -}); - -/** - * @deprecated: Created for backwards compatibility with test runner that set the hook function - * into QUnit.{hook}, instead of invoking it and passing the hook function. - * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here. - * Doing this allows us to tell if the following methods have been overwritten on the actual - * QUnit object. - */ -extend( QUnit.constructor.prototype, { - - // Logging callbacks; all receive a single argument with the listed properties - // run test/logs.html for any related changes - begin: registerLoggingCallback( "begin" ), - - // done: { failed, passed, total, runtime } - done: registerLoggingCallback( "done" ), - - // log: { result, actual, expected, message } - log: registerLoggingCallback( "log" ), - - // testStart: { name } - testStart: registerLoggingCallback( "testStart" ), - - // testDone: { name, failed, passed, total } - testDone: registerLoggingCallback( "testDone" ), - - // moduleStart: { name } - moduleStart: registerLoggingCallback( "moduleStart" ), - - // moduleDone: { name, failed, passed, total } - moduleDone: registerLoggingCallback( "moduleDone" ) -}); - -if ( typeof document === "undefined" || document.readyState === "complete" ) { - config.autorun = true; -} - -QUnit.load = function() { - runLoggingCallbacks( "begin", QUnit, {} ); - - // Initialize the config, saving the execution queue - var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes, moduleFilter, - numModules = 0, - moduleFilterHtml = "", - urlConfigHtml = "", - oldconfig = extend( {}, config ); - - QUnit.init(); - extend(config, oldconfig); - - config.blocking = false; - - len = config.urlConfig.length; - - for ( i = 0; i < len; i++ ) { - val = config.urlConfig[i]; - if ( typeof val === "string" ) { - val = { - id: val, - label: val, - tooltip: "[no tooltip available]" - }; - } - config[ val.id ] = QUnit.urlParams[ val.id ]; - urlConfigHtml += ""; - } - - moduleFilterHtml += ""; - - // `userAgent` initialized at top of scope - userAgent = id( "qunit-userAgent" ); - if ( userAgent ) { - userAgent.innerHTML = navigator.userAgent; - } - - // `banner` initialized at top of scope - banner = id( "qunit-header" ); - if ( banner ) { - banner.innerHTML = "" + banner.innerHTML + " "; - } - - // `toolbar` initialized at top of scope - toolbar = id( "qunit-testrunner-toolbar" ); - if ( toolbar ) { - // `filter` initialized at top of scope - filter = document.createElement( "input" ); - filter.type = "checkbox"; - filter.id = "qunit-filter-pass"; - - addEvent( filter, "click", function() { - var tmp, - ol = document.getElementById( "qunit-tests" ); - - if ( filter.checked ) { - ol.className = ol.className + " hidepass"; - } else { - tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " "; - ol.className = tmp.replace( / hidepass /, " " ); - } - if ( defined.sessionStorage ) { - if (filter.checked) { - sessionStorage.setItem( "qunit-filter-passed-tests", "true" ); - } else { - sessionStorage.removeItem( "qunit-filter-passed-tests" ); - } - } - }); - - if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) { - filter.checked = true; - // `ol` initialized at top of scope - ol = document.getElementById( "qunit-tests" ); - ol.className = ol.className + " hidepass"; - } - toolbar.appendChild( filter ); - - // `label` initialized at top of scope - label = document.createElement( "label" ); - label.setAttribute( "for", "qunit-filter-pass" ); - label.setAttribute( "title", "Only show tests and assertons that fail. Stored in sessionStorage." ); - label.innerHTML = "Hide passed tests"; - toolbar.appendChild( label ); - - urlConfigCheckboxes = document.createElement( 'span' ); - urlConfigCheckboxes.innerHTML = urlConfigHtml; - addEvent( urlConfigCheckboxes, "change", function( event ) { - var params = {}; - params[ event.target.name ] = event.target.checked ? true : undefined; - window.location = QUnit.url( params ); - }); - toolbar.appendChild( urlConfigCheckboxes ); - - if (numModules > 1) { - moduleFilter = document.createElement( 'span' ); - moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' ); - moduleFilter.innerHTML = moduleFilterHtml; - addEvent( moduleFilter, "change", function() { - var selectBox = moduleFilter.getElementsByTagName("select")[0], - selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value); - - window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } ); - }); - toolbar.appendChild(moduleFilter); - } - } - - // `main` initialized at top of scope - main = id( "qunit-fixture" ); - if ( main ) { - config.fixture = main.innerHTML; - } - - if ( config.autostart ) { - QUnit.start(); - } -}; - -addEvent( window, "load", QUnit.load ); - -// `onErrorFnPrev` initialized at top of scope -// Preserve other handlers -onErrorFnPrev = window.onerror; - -// Cover uncaught exceptions -// Returning true will surpress the default browser handler, -// returning false will let it run. -window.onerror = function ( error, filePath, linerNr ) { - var ret = false; - if ( onErrorFnPrev ) { - ret = onErrorFnPrev( error, filePath, linerNr ); - } - - // Treat return value as window.onerror itself does, - // Only do our handling if not surpressed. - if ( ret !== true ) { - if ( QUnit.config.current ) { - if ( QUnit.config.current.ignoreGlobalErrors ) { - return true; - } - QUnit.pushFailure( error, filePath + ":" + linerNr ); - } else { - QUnit.test( "global failure", extend( function() { - QUnit.pushFailure( error, filePath + ":" + linerNr ); - }, { validTest: validTest } ) ); - } - return false; - } - - return ret; -}; - -function done() { - config.autorun = true; - - // Log the last module results - if ( config.currentModule ) { - runLoggingCallbacks( "moduleDone", QUnit, { - name: config.currentModule, - failed: config.moduleStats.bad, - passed: config.moduleStats.all - config.moduleStats.bad, - total: config.moduleStats.all - }); - } - - var i, key, - banner = id( "qunit-banner" ), - tests = id( "qunit-tests" ), - runtime = +new Date() - config.started, - passed = config.stats.all - config.stats.bad, - html = [ - "Tests completed in ", - runtime, - " milliseconds.
      ", - "", - passed, - " tests of ", - config.stats.all, - " passed, ", - config.stats.bad, - " failed." - ].join( "" ); - - if ( banner ) { - banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" ); - } - - if ( tests ) { - id( "qunit-testresult" ).innerHTML = html; - } - - if ( config.altertitle && typeof document !== "undefined" && document.title ) { - // show ✖ for good, ✔ for bad suite result in title - // use escape sequences in case file gets loaded with non-utf-8-charset - document.title = [ - ( config.stats.bad ? "\u2716" : "\u2714" ), - document.title.replace( /^[\u2714\u2716] /i, "" ) - ].join( " " ); - } - - // clear own sessionStorage items if all tests passed - if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) { - // `key` & `i` initialized at top of scope - for ( i = 0; i < sessionStorage.length; i++ ) { - key = sessionStorage.key( i++ ); - if ( key.indexOf( "qunit-test-" ) === 0 ) { - sessionStorage.removeItem( key ); - } - } - } - - // scroll back to top to show results - if ( window.scrollTo ) { - window.scrollTo(0, 0); - } - - runLoggingCallbacks( "done", QUnit, { - failed: config.stats.bad, - passed: passed, - total: config.stats.all, - runtime: runtime - }); -} - -/** @return Boolean: true if this test should be ran */ -function validTest( test ) { - var include, - filter = config.filter && config.filter.toLowerCase(), - module = config.module && config.module.toLowerCase(), - fullName = (test.module + ": " + test.testName).toLowerCase(); - - // Internally-generated tests are always valid - if ( test.callback && test.callback.validTest === validTest ) { - delete test.callback.validTest; - return true; - } - - if ( config.testNumber ) { - return test.testNumber === config.testNumber; - } - - if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) { - return false; - } - - if ( !filter ) { - return true; - } - - include = filter.charAt( 0 ) !== "!"; - if ( !include ) { - filter = filter.slice( 1 ); - } - - // If the filter matches, we need to honour include - if ( fullName.indexOf( filter ) !== -1 ) { - return include; - } - - // Otherwise, do the opposite - return !include; -} - -// so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions) -// Later Safari and IE10 are supposed to support error.stack as well -// See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack -function extractStacktrace( e, offset ) { - offset = offset === undefined ? 3 : offset; - - var stack, include, i, regex; - - if ( e.stacktrace ) { - // Opera - return e.stacktrace.split( "\n" )[ offset + 3 ]; - } else if ( e.stack ) { - // Firefox, Chrome - stack = e.stack.split( "\n" ); - if (/^error$/i.test( stack[0] ) ) { - stack.shift(); - } - if ( fileName ) { - include = []; - for ( i = offset; i < stack.length; i++ ) { - if ( stack[ i ].indexOf( fileName ) != -1 ) { - break; - } - include.push( stack[ i ] ); - } - if ( include.length ) { - return include.join( "\n" ); - } - } - return stack[ offset ]; - } else if ( e.sourceURL ) { - // Safari, PhantomJS - // hopefully one day Safari provides actual stacktraces - // exclude useless self-reference for generated Error objects - if ( /qunit.js$/.test( e.sourceURL ) ) { - return; - } - // for actual exceptions, this is useful - return e.sourceURL + ":" + e.line; - } -} -function sourceFromStacktrace( offset ) { - try { - throw new Error(); - } catch ( e ) { - return extractStacktrace( e, offset ); - } -} - -function escapeInnerText( s ) { - if ( !s ) { - return ""; - } - s = s + ""; - return s.replace( /[\&<>]/g, function( s ) { - switch( s ) { - case "&": return "&"; - case "<": return "<"; - case ">": return ">"; - default: return s; - } - }); -} - -function synchronize( callback, last ) { - config.queue.push( callback ); - - if ( config.autorun && !config.blocking ) { - process( last ); - } -} - -function process( last ) { - function next() { - process( last ); - } - var start = new Date().getTime(); - config.depth = config.depth ? config.depth + 1 : 1; - - while ( config.queue.length && !config.blocking ) { - if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { - config.queue.shift()(); - } else { - window.setTimeout( next, 13 ); - break; - } - } - config.depth--; - if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { - done(); - } -} - -function saveGlobal() { - config.pollution = []; - - if ( config.noglobals ) { - for ( var key in window ) { - // in Opera sometimes DOM element ids show up here, ignore them - if ( !hasOwn.call( window, key ) || /^qunit-test-output/.test( key ) ) { - continue; - } - config.pollution.push( key ); - } - } -} - -function checkPollution( name ) { - var newGlobals, - deletedGlobals, - old = config.pollution; - - saveGlobal(); - - newGlobals = diff( config.pollution, old ); - if ( newGlobals.length > 0 ) { - QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") ); - } - - deletedGlobals = diff( old, config.pollution ); - if ( deletedGlobals.length > 0 ) { - QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") ); - } -} - -// returns a new Array with the elements that are in a but not in b -function diff( a, b ) { - var i, j, - result = a.slice(); - - for ( i = 0; i < result.length; i++ ) { - for ( j = 0; j < b.length; j++ ) { - if ( result[i] === b[j] ) { - result.splice( i, 1 ); - i--; - break; - } - } - } - return result; -} - -function extend( a, b ) { - for ( var prop in b ) { - if ( b[ prop ] === undefined ) { - delete a[ prop ]; - - // Avoid "Member not found" error in IE8 caused by setting window.constructor - } else if ( prop !== "constructor" || a !== window ) { - a[ prop ] = b[ prop ]; - } - } - - return a; -} - -function addEvent( elem, type, fn ) { - if ( elem.addEventListener ) { - elem.addEventListener( type, fn, false ); - } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, fn ); - } else { - fn(); - } -} - -function id( name ) { - return !!( typeof document !== "undefined" && document && document.getElementById ) && - document.getElementById( name ); -} - -function registerLoggingCallback( key ) { - return function( callback ) { - config[key].push( callback ); - }; -} - -// Supports deprecated method of completely overwriting logging callbacks -function runLoggingCallbacks( key, scope, args ) { - //debugger; - var i, callbacks; - if ( QUnit.hasOwnProperty( key ) ) { - QUnit[ key ].call(scope, args ); - } else { - callbacks = config[ key ]; - for ( i = 0; i < callbacks.length; i++ ) { - callbacks[ i ].call( scope, args ); - } - } -} - -// Test for equality any JavaScript type. -// Author: Philippe Rathé -QUnit.equiv = (function() { - - // Call the o related callback with the given arguments. - function bindCallbacks( o, callbacks, args ) { - var prop = QUnit.objectType( o ); - if ( prop ) { - if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) { - return callbacks[ prop ].apply( callbacks, args ); - } else { - return callbacks[ prop ]; // or undefined - } - } - } - - // the real equiv function - var innerEquiv, - // stack to decide between skip/abort functions - callers = [], - // stack to avoiding loops from circular referencing - parents = [], - - getProto = Object.getPrototypeOf || function ( obj ) { - return obj.__proto__; - }, - callbacks = (function () { - - // for string, boolean, number and null - function useStrictEquality( b, a ) { - if ( b instanceof a.constructor || a instanceof b.constructor ) { - // to catch short annotaion VS 'new' annotation of a - // declaration - // e.g. var i = 1; - // var j = new Number(1); - return a == b; - } else { - return a === b; - } - } - - return { - "string": useStrictEquality, - "boolean": useStrictEquality, - "number": useStrictEquality, - "null": useStrictEquality, - "undefined": useStrictEquality, - - "nan": function( b ) { - return isNaN( b ); - }, - - "date": function( b, a ) { - return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf(); - }, - - "regexp": function( b, a ) { - return QUnit.objectType( b ) === "regexp" && - // the regex itself - a.source === b.source && - // and its modifers - a.global === b.global && - // (gmi) ... - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline && - a.sticky === b.sticky; - }, - - // - skip when the property is a method of an instance (OOP) - // - abort otherwise, - // initial === would have catch identical references anyway - "function": function() { - var caller = callers[callers.length - 1]; - return caller !== Object && typeof caller !== "undefined"; - }, - - "array": function( b, a ) { - var i, j, len, loop; - - // b could be an object literal here - if ( QUnit.objectType( b ) !== "array" ) { - return false; - } - - len = a.length; - if ( len !== b.length ) { - // safe and faster - return false; - } - - // track reference to avoid circular references - parents.push( a ); - for ( i = 0; i < len; i++ ) { - loop = false; - for ( j = 0; j < parents.length; j++ ) { - if ( parents[j] === a[i] ) { - loop = true;// dont rewalk array - } - } - if ( !loop && !innerEquiv(a[i], b[i]) ) { - parents.pop(); - return false; - } - } - parents.pop(); - return true; - }, - - "object": function( b, a ) { - var i, j, loop, - // Default to true - eq = true, - aProperties = [], - bProperties = []; - - // comparing constructors is more strict than using - // instanceof - if ( a.constructor !== b.constructor ) { - // Allow objects with no prototype to be equivalent to - // objects with Object as their constructor. - if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) || - ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) { - return false; - } - } - - // stack constructor before traversing properties - callers.push( a.constructor ); - // track reference to avoid circular references - parents.push( a ); - - for ( i in a ) { // be strict: don't ensures hasOwnProperty - // and go deep - loop = false; - for ( j = 0; j < parents.length; j++ ) { - if ( parents[j] === a[i] ) { - // don't go down the same path twice - loop = true; - } - } - aProperties.push(i); // collect a's properties - - if (!loop && !innerEquiv( a[i], b[i] ) ) { - eq = false; - break; - } - } - - callers.pop(); // unstack, we are done - parents.pop(); - - for ( i in b ) { - bProperties.push( i ); // collect b's properties - } - - // Ensures identical properties name - return eq && innerEquiv( aProperties.sort(), bProperties.sort() ); - } - }; - }()); - - innerEquiv = function() { // can take multiple arguments - var args = [].slice.apply( arguments ); - if ( args.length < 2 ) { - return true; // end transition - } - - return (function( a, b ) { - if ( a === b ) { - return true; // catch the most you can - } else if ( a === null || b === null || typeof a === "undefined" || - typeof b === "undefined" || - QUnit.objectType(a) !== QUnit.objectType(b) ) { - return false; // don't lose time with error prone cases - } else { - return bindCallbacks(a, callbacks, [ b, a ]); - } - - // apply transition with (1..n) arguments - }( args[0], args[1] ) && arguments.callee.apply( this, args.splice(1, args.length - 1 )) ); - }; - - return innerEquiv; -}()); - -/** - * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | - * http://flesler.blogspot.com Licensed under BSD - * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008 - * - * @projectDescription Advanced and extensible data dumping for Javascript. - * @version 1.0.0 - * @author Ariel Flesler - * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} - */ -QUnit.jsDump = (function() { - function quote( str ) { - return '"' + str.toString().replace( /"/g, '\\"' ) + '"'; - } - function literal( o ) { - return o + ""; - } - function join( pre, arr, post ) { - var s = jsDump.separator(), - base = jsDump.indent(), - inner = jsDump.indent(1); - if ( arr.join ) { - arr = arr.join( "," + s + inner ); - } - if ( !arr ) { - return pre + post; - } - return [ pre, inner + arr, base + post ].join(s); - } - function array( arr, stack ) { - var i = arr.length, ret = new Array(i); - this.up(); - while ( i-- ) { - ret[i] = this.parse( arr[i] , undefined , stack); - } - this.down(); - return join( "[", ret, "]" ); - } - - var reName = /^function (\w+)/, - jsDump = { - parse: function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance - stack = stack || [ ]; - var inStack, res, - parser = this.parsers[ type || this.typeOf(obj) ]; - - type = typeof parser; - inStack = inArray( obj, stack ); - - if ( inStack != -1 ) { - return "recursion(" + (inStack - stack.length) + ")"; - } - //else - if ( type == "function" ) { - stack.push( obj ); - res = parser.call( this, obj, stack ); - stack.pop(); - return res; - } - // else - return ( type == "string" ) ? parser : this.parsers.error; - }, - typeOf: function( obj ) { - var type; - if ( obj === null ) { - type = "null"; - } else if ( typeof obj === "undefined" ) { - type = "undefined"; - } else if ( QUnit.is( "regexp", obj) ) { - type = "regexp"; - } else if ( QUnit.is( "date", obj) ) { - type = "date"; - } else if ( QUnit.is( "function", obj) ) { - type = "function"; - } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) { - type = "window"; - } else if ( obj.nodeType === 9 ) { - type = "document"; - } else if ( obj.nodeType ) { - type = "node"; - } else if ( - // native arrays - toString.call( obj ) === "[object Array]" || - // NodeList objects - ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) ) - ) { - type = "array"; - } else { - type = typeof obj; - } - return type; - }, - separator: function() { - return this.multiline ? this.HTML ? "
      " : "\n" : this.HTML ? " " : " "; - }, - indent: function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing - if ( !this.multiline ) { - return ""; - } - var chr = this.indentChar; - if ( this.HTML ) { - chr = chr.replace( /\t/g, " " ).replace( / /g, " " ); - } - return new Array( this._depth_ + (extra||0) ).join(chr); - }, - up: function( a ) { - this._depth_ += a || 1; - }, - down: function( a ) { - this._depth_ -= a || 1; - }, - setParser: function( name, parser ) { - this.parsers[name] = parser; - }, - // The next 3 are exposed so you can use them - quote: quote, - literal: literal, - join: join, - // - _depth_: 1, - // This is the list of parsers, to modify them, use jsDump.setParser - parsers: { - window: "[Window]", - document: "[Document]", - error: "[ERROR]", //when no parser is found, shouldn"t happen - unknown: "[Unknown]", - "null": "null", - "undefined": "undefined", - "function": function( fn ) { - var ret = "function", - name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1];//functions never have name in IE - - if ( name ) { - ret += " " + name; - } - ret += "( "; - - ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" ); - return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" ); - }, - array: array, - nodelist: array, - "arguments": array, - object: function( map, stack ) { - var ret = [ ], keys, key, val, i; - QUnit.jsDump.up(); - if ( Object.keys ) { - keys = Object.keys( map ); - } else { - keys = []; - for ( key in map ) { - keys.push( key ); - } - } - keys.sort(); - for ( i = 0; i < keys.length; i++ ) { - key = keys[ i ]; - val = map[ key ]; - ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) ); - } - QUnit.jsDump.down(); - return join( "{", ret, "}" ); - }, - node: function( node ) { - var a, val, - open = QUnit.jsDump.HTML ? "<" : "<", - close = QUnit.jsDump.HTML ? ">" : ">", - tag = node.nodeName.toLowerCase(), - ret = open + tag; - - for ( a in QUnit.jsDump.DOMAttrs ) { - val = node[ QUnit.jsDump.DOMAttrs[a] ]; - if ( val ) { - ret += " " + a + "=" + QUnit.jsDump.parse( val, "attribute" ); - } - } - return ret + close + open + "/" + tag + close; - }, - functionArgs: function( fn ) {//function calls it internally, it's the arguments part of the function - var args, - l = fn.length; - - if ( !l ) { - return ""; - } - - args = new Array(l); - while ( l-- ) { - args[l] = String.fromCharCode(97+l);//97 is 'a' - } - return " " + args.join( ", " ) + " "; - }, - key: quote, //object calls it internally, the key part of an item in a map - functionCode: "[code]", //function calls it internally, it's the content of the function - attribute: quote, //node calls it internally, it's an html attribute value - string: quote, - date: quote, - regexp: literal, //regex - number: literal, - "boolean": literal - }, - DOMAttrs: { - //attributes to dump from nodes, name=>realName - id: "id", - name: "name", - "class": "className" - }, - HTML: false,//if true, entities are escaped ( <, >, \t, space and \n ) - indentChar: " ",//indentation unit - multiline: true //if true, items in a collection, are separated by a \n, else just a space. - }; - - return jsDump; -}()); - -// from Sizzle.js -function getText( elems ) { - var i, elem, - ret = ""; - - for ( i = 0; elems[i]; i++ ) { - elem = elems[i]; - - // Get the text from text nodes and CDATA nodes - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - // Traverse everything else, except comment nodes - } else if ( elem.nodeType !== 8 ) { - ret += getText( elem.childNodes ); - } - } - - return ret; -} - -// from jquery.js -function inArray( elem, array ) { - if ( array.indexOf ) { - return array.indexOf( elem ); - } - - for ( var i = 0, length = array.length; i < length; i++ ) { - if ( array[ i ] === elem ) { - return i; - } - } - - return -1; -} - -/* - * Javascript Diff Algorithm - * By John Resig (http://ejohn.org/) - * Modified by Chu Alan "sprite" - * - * Released under the MIT license. - * - * More Info: - * http://ejohn.org/projects/javascript-diff-algorithm/ - * - * Usage: QUnit.diff(expected, actual) - * - * QUnit.diff( "the quick brown fox jumped over", "the quick fox jumps over" ) == "the quick brown fox jumped jumps over" - */ -QUnit.diff = (function() { - function diff( o, n ) { - var i, - ns = {}, - os = {}; - - for ( i = 0; i < n.length; i++ ) { - if ( ns[ n[i] ] == null ) { - ns[ n[i] ] = { - rows: [], - o: null - }; - } - ns[ n[i] ].rows.push( i ); - } - - for ( i = 0; i < o.length; i++ ) { - if ( os[ o[i] ] == null ) { - os[ o[i] ] = { - rows: [], - n: null - }; - } - os[ o[i] ].rows.push( i ); - } - - for ( i in ns ) { - if ( !hasOwn.call( ns, i ) ) { - continue; - } - if ( ns[i].rows.length == 1 && typeof os[i] != "undefined" && os[i].rows.length == 1 ) { - n[ ns[i].rows[0] ] = { - text: n[ ns[i].rows[0] ], - row: os[i].rows[0] - }; - o[ os[i].rows[0] ] = { - text: o[ os[i].rows[0] ], - row: ns[i].rows[0] - }; - } - } - - for ( i = 0; i < n.length - 1; i++ ) { - if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null && - n[ i + 1 ] == o[ n[i].row + 1 ] ) { - - n[ i + 1 ] = { - text: n[ i + 1 ], - row: n[i].row + 1 - }; - o[ n[i].row + 1 ] = { - text: o[ n[i].row + 1 ], - row: i + 1 - }; - } - } - - for ( i = n.length - 1; i > 0; i-- ) { - if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null && - n[ i - 1 ] == o[ n[i].row - 1 ]) { - - n[ i - 1 ] = { - text: n[ i - 1 ], - row: n[i].row - 1 - }; - o[ n[i].row - 1 ] = { - text: o[ n[i].row - 1 ], - row: i - 1 - }; - } - } - - return { - o: o, - n: n - }; - } - - return function( o, n ) { - o = o.replace( /\s+$/, "" ); - n = n.replace( /\s+$/, "" ); - - var i, pre, - str = "", - out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ), - oSpace = o.match(/\s+/g), - nSpace = n.match(/\s+/g); - - if ( oSpace == null ) { - oSpace = [ " " ]; - } - else { - oSpace.push( " " ); - } - - if ( nSpace == null ) { - nSpace = [ " " ]; - } - else { - nSpace.push( " " ); - } - - if ( out.n.length === 0 ) { - for ( i = 0; i < out.o.length; i++ ) { - str += "" + out.o[i] + oSpace[i] + ""; - } - } - else { - if ( out.n[0].text == null ) { - for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) { - str += "" + out.o[n] + oSpace[n] + ""; - } - } - - for ( i = 0; i < out.n.length; i++ ) { - if (out.n[i].text == null) { - str += "" + out.n[i] + nSpace[i] + ""; - } - else { - // `pre` initialized at top of scope - pre = ""; - - for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) { - pre += "" + out.o[n] + oSpace[n] + ""; - } - str += " " + out.n[i].text + nSpace[i] + pre; - } - } - } - - return str; - }; -}()); - -// for CommonJS enviroments, export everything -if ( typeof exports !== "undefined" ) { - extend(exports, QUnit); -} - -// get at whatever the global object is, like window in browsers -}( (function() {return this;}.call()) )); diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/README.md deleted file mode 100644 index 7cfe3bb..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# node-tar - -Tar for Node.js. - -## Goals of this project - -1. Be able to parse and reasonably extract the contents of any tar file - created by any program that creates tar files, period. - - At least, this includes every version of: - - * bsdtar - * gnutar - * solaris posix tar - * Joerg Schilling's star ("Schilly tar") - -2. Create tar files that can be extracted by any of the following tar - programs: - - * bsdtar/libarchive version 2.6.2 - * gnutar 1.15 and above - * SunOS Posix tar - * Joerg Schilling's star ("Schilly tar") - -3. 100% test coverage. Speed is important. Correctness is slightly - more important. - -4. Create the kind of tar interface that Node users would want to use. - -5. Satisfy npm's needs for a portable tar implementation with a - JavaScript interface. - -6. No excuses. No complaining. No tolerance for failure. - -## But isn't there already a tar.js? - -Yes, there are a few. This one is going to be better, and it will be -fanatically maintained, because npm will depend on it. - -That's why I need to write it from scratch. Creating and extracting -tarballs is such a large part of what npm does, I simply can't have it -be a black box any longer. - -## Didn't you have something already? Where'd it go? - -It's in the "old" folder. It's not functional. Don't use it. - -It was a useful exploration to learn the issues involved, but like most -software of any reasonable complexity, node-tar won't be useful until -it's been written at least 3 times. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/buffer-entry.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/buffer-entry.js deleted file mode 100644 index c7b5a6e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/buffer-entry.js +++ /dev/null @@ -1,30 +0,0 @@ -// just like the Entry class, but it buffers the contents -// -// XXX It would be good to set a maximum BufferEntry filesize, -// since it eats up memory. In normal operation, -// these are only for long filenames or link names, which are -// rarely very big. - -module.exports = BufferEntry - -var inherits = require("../vendor/inherits/inherits.js") - , Entry = require("./entry.js") - -function BufferEntry () { - Entry.apply(this, arguments) - this._buffer = new Buffer(this.props.size) - this._offset = 0 - this.body = "" - this.on("end", function () { - this.body = this._buffer.toString().slice(0, -1) - }) -} - -// collect the bytes as they come in. -BufferEntry.prototype.write = function (c) { - c.copy(this._buffer, this._offset) - this._offset += c.length - Entry.prototype.write.call(this, c) -} - -inherits(BufferEntry, Entry) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry-writer.js deleted file mode 100644 index 9d6a9b7..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry-writer.js +++ /dev/null @@ -1,169 +0,0 @@ -module.exports = EntryWriter - -var tar = require("../tar.js") - , TarHeader = require("./header.js") - , Entry = require("./entry.js") - , inherits = require("../vendor/inherits/inherits.js") - , BlockStream = require("../vendor/block-stream/block-stream.js") - , ExtendedHeaderWriter - , Stream = require("stream").Stream - , EOF = {} - -inherits(EntryWriter, Stream) - -function EntryWriter (props) { - var me = this - - if (!(me instanceof EntryWriter)) { - return new EntryWriter(props) - } - - Stream.apply(this) - - me.writable = true - me.readable = true - - me._stream = new BlockStream(512) - - me._stream.on("data", function (c) { - me.emit("data", c) - }) - - me._stream.on("drain", function () { - me.emit("drain") - }) - - me._stream.on("end", function () { - me.emit("end") - me.emit("close") - }) - - me.props = props - if (props.type === "Directory") { - props.size = 0 - } - props.ustar = "ustar\0" - props.ustarver = "00" - me.path = props.path - - me._buffer = [] - me._didHeader = false - me._meta = false - - me.on("pipe", function () { - me._process() - }) -} - -EntryWriter.prototype.write = function (c) { - // console.error(".. ew write") - if (this._ended) return this.emit("error", new Error("write after end")) - this._buffer.push(c) - this._process() - this._needDrain = this._buffer.length > 0 - return !this._needDrain -} - -EntryWriter.prototype.end = function (c) { - // console.error(".. ew end") - if (c) this._buffer.push(c) - this._buffer.push(EOF) - this._ended = true - this._process() - this._needDrain = this._buffer.length > 0 -} - -EntryWriter.prototype.pause = function () { - // console.error(".. ew pause") - this._paused = true - this.emit("pause") -} - -EntryWriter.prototype.resume = function () { - // console.error(".. ew resume") - this._paused = false - this.emit("resume") - this._process() -} - -EntryWriter.prototype.add = function (entry) { - // console.error(".. ew add") - if (!this.parent) return this.emit("error", new Error("no parent")) - - // make sure that the _header and such is emitted, and clear out - // the _currentEntry link on the parent. - if (!this._ended) this.end() - - return this.parent.add(entry) -} - -EntryWriter.prototype._header = function () { - // console.error(".. ew header") - if (this._didHeader) return - this._didHeader = true - - var headerBlock = TarHeader.encode(this.props) - - if (this.props.needExtended && !this._meta) { - var me = this - - ExtendedHeaderWriter = ExtendedHeaderWriter || - require("./extended-header-writer.js") - - ExtendedHeaderWriter(this.props) - .on("data", function (c) { - me.emit("data", c) - }) - .on("error", function (er) { - me.emit("error", er) - }) - .end() - } - - // console.error(".. .. ew headerBlock emitting") - this.emit("data", headerBlock) - this.emit("header") -} - -EntryWriter.prototype._process = function () { - // console.error(".. .. ew process") - if (!this._didHeader && !this._meta) { - this._header() - } - - if (this._paused || this._processing) { - // console.error(".. .. .. paused=%j, processing=%j", this._paused, this._processing) - return - } - - this._processing = true - - var buf = this._buffer - for (var i = 0; i < buf.length; i ++) { - // console.error(".. .. .. i=%d", i) - - var c = buf[i] - - if (c === EOF) this._stream.end() - else this._stream.write(c) - - if (this._paused) { - // console.error(".. .. .. paused mid-emission") - this._processing = false - if (i < buf.length) { - this._needDrain = true - this._buffer = buf.slice(i + 1) - } - return - } - } - - // console.error(".. .. .. emitted") - this._buffer.length = 0 - this._processing = false - - // console.error(".. .. .. emitting drain") - this.emit("drain") -} - -EntryWriter.prototype.destroy = function () {} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry.js deleted file mode 100644 index 9d5b8bc..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/entry.js +++ /dev/null @@ -1,212 +0,0 @@ -// A passthrough read/write stream that sets its properties -// based on a header, extendedHeader, and globalHeader -// -// Can be either a file system object of some sort, or -// a pax/ustar metadata entry. - -module.exports = Entry - -var TarHeader = require("./header.js") - , tar = require("../tar") - , assert = require("assert").ok - , Stream = require("stream").Stream - , inherits = require("../vendor/inherits/inherits.js") - , fstream = require("../vendor/fstream/fstream.js").Abstract - -function Entry (header, extended, global) { - Stream.call(this) - this.readable = true - this.writable = true - - this._needDrain = false - this._paused = false - this._reading = false - this._ending = false - this._ended = false - this._remaining = 0 - this._queue = [] - this._index = 0 - this._queueLen = 0 - - this._read = this._read.bind(this) - - this.props = {} - this._header = header - this._extended = extended || {} - - // globals can change throughout the course of - // a file parse operation. Freeze it at its current state. - this._global = {} - var me = this - Object.keys(global || {}).forEach(function (g) { - me._global[g] = global[g] - }) - - this._setProps() -} - -inherits(Entry, Stream, -{ write: function (c) { - if (this._ending) this.error("write() after end()", null, true) - if (this._remaining === 0) { - this.error("invalid bytes past eof") - } - - // often we'll get a bunch of \0 at the end of the last write, - // since chunks will always be 512 bytes when reading a tarball. - if (c.length > this._remaining) { - c = c.slice(0, this._remaining) - } - this._remaining -= c.length - - // put it on the stack. - var ql = this._queueLen - this._queue.push(c) - this._queueLen ++ - - this._read() - - // either paused, or buffered - if (this._paused || ql > 0) { - this._needDrain = true - return false - } - - return true - } - -, end: function (c) { - if (c) this.write(c) - this._ending = true - this._read() - } - -, pause: function () { - this._paused = true - this.emit("pause") - } - -, resume: function () { - // console.error(" Tar Entry resume", this.path) - this.emit("resume") - this._paused = false - this._read() - return this._queueLen - this._index > 1 - } - - // This is bound to the instance -, _read: function () { - // console.error(" Tar Entry _read", this.path) - - if (this._paused || this._reading || this._ended) return - - // set this flag so that event handlers don't inadvertently - // get multiple _read() calls running. - this._reading = true - - // have any data to emit? - if (this._index < this._queueLen) { - var chunk = this._queue[this._index ++] - this.emit("data", chunk) - } - - // check if we're drained - if (this._index >= this._queueLen) { - this._queue.length = this._queueLen = this._index = 0 - if (this._needDrain) { - this._needDrain = false - this.emit("drain") - } - if (this._ending) { - this._ended = true - this.emit("end") - } - } - - // if the queue gets too big, then pluck off whatever we can. - // this should be fairly rare. - var mql = this._maxQueueLen - if (this._queueLen > mql && this._index > 0) { - mql = Math.min(this._index, mql) - this._index -= mql - this._queueLen -= mql - this._queue = this._queue.slice(mql) - } - - this._reading = false - } - -, _setProps: function () { - // props = extended->global->header->{} - var header = this._header - , extended = this._extended - , global = this._global - , props = this.props - - // first get the values from the normal header. - var fields = tar.fields - for (var f = 0; fields[f] !== null; f ++) { - var field = fields[f] - , val = header[field] - if (typeof val !== "undefined") props[field] = val - } - - // next, the global header for this file. - // numeric values, etc, will have already been parsed. - ;[global, extended].forEach(function (p) { - Object.keys(p).forEach(function (f) { - if (typeof p[f] !== "undefined") props[f] = p[f] - }) - }) - - // no nulls allowed in path or linkpath - ;["path", "linkpath"].forEach(function (p) { - if (props.hasOwnProperty(p)) { - props[p] = props[p].split("\0")[0] - } - }) - - - // set date fields to be a proper date - ;["mtime", "ctime", "atime"].forEach(function (p) { - if (props.hasOwnProperty(p)) { - props[p] = new Date(props[p] * 1000) - } - }) - - // set the type so that we know what kind of file to create - var type - switch (tar.types[props.type]) { - case "OldFile": - case "ContiguousFile": - type = "File" - break - - case "GNUDumpDir": - type = "Directory" - break - - case undefined: - type = "Unknown" - break - - case "Link": - case "SymbolicLink": - case "CharacterDevice": - case "BlockDevice": - case "Directory": - case "FIFO": - default: - type = tar.types[props.type] - } - - this.type = type - this.path = props.path - this.size = props.size - - // size is special, since it signals when the file needs to end. - this._remaining = props.size - } -, warn: fstream.warn -, error: fstream.error -}) diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header-writer.js deleted file mode 100644 index 10a7d8f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header-writer.js +++ /dev/null @@ -1,192 +0,0 @@ - -module.exports = ExtendedHeaderWriter - -var inherits = require("../vendor/inherits/inherits.js") - , EntryWriter = require("./entry-writer.js") - -inherits(ExtendedHeaderWriter, EntryWriter) - -var tar = require("../tar.js") - , path = require("path") - , inherits = require("../vendor/inherits/inherits.js") - , TarHeader = require("./header.js") - -// props is the props of the thing we need to write an -// extended header for. -// Don't be shy with it. Just encode everything. -function ExtendedHeaderWriter (props) { - // console.error(">> ehw ctor") - var me = this - - if (!(me instanceof ExtendedHeaderWriter)) { - return new ExtendedHeaderWriter(props) - } - - me.fields = props - - var p = - { path : ("PaxHeader" + path.join("/", props.path || "")) - .replace(/\\/g, "/").substr(0, 100) - , mode : props.mode || 0666 - , uid : props.uid || 0 - , gid : props.gid || 0 - , size : 0 // will be set later - , mtime : props.mtime || Date.now() / 1000 - , type : "x" - , linkpath : "" - , ustar : "ustar\0" - , ustarver : "00" - , uname : props.uname || "" - , gname : props.gname || "" - , devmaj : props.devmaj || 0 - , devmin : props.devmin || 0 - } - - - EntryWriter.call(me, p) - // console.error(">> ehw props", me.props) - me.props = p - - me._meta = true -} - -ExtendedHeaderWriter.prototype.end = function () { - // console.error(">> ehw end") - var me = this - - if (me._ended) return - me._ended = true - - me._encodeFields() - - if (me.props.size === 0) { - // nothing to write! - me._ready = true - me._stream.end() - return - } - - me._stream.write(TarHeader.encode(me.props)) - me.body.forEach(function (l) { - me._stream.write(l) - }) - me._ready = true - - // console.error(">> ehw _process calling end()", me.props) - this._stream.end() -} - -ExtendedHeaderWriter.prototype._encodeFields = function () { - // console.error(">> ehw _encodeFields") - this.body = [] - if (this.fields.prefix) { - this.fields.path = this.fields.prefix + "/" + this.fields.path - this.fields.prefix = "" - } - encodeFields(this.fields, "", this.body, this.fields.noProprietary) - var me = this - this.body.forEach(function (l) { - me.props.size += l.length - }) -} - -function encodeFields (fields, prefix, body, nop) { - // console.error(">> >> ehw encodeFields") - // "%d %s=%s\n", , , - // The length is a decimal number, and includes itself and the \n - // Numeric values are decimal strings. - - Object.keys(fields).forEach(function (k) { - var val = fields[k] - , numeric = tar.numeric[k] - - if (prefix) k = prefix + "." + k - - // already including NODETAR.type, don't need File=true also - if (k === fields.type && val === true) return - - switch (k) { - // don't include anything that's always handled just fine - // in the normal header, or only meaningful in the context - // of nodetar - case "mode": - case "cksum": - case "ustar": - case "ustarver": - case "prefix": - case "basename": - case "dirname": - case "needExtended": - case "block": - case "filter": - return - - case "rdev": - if (val === 0) return - break - - case "nlink": - case "dev": // Truly a hero among men, Creator of Star! - case "ino": // Speak his name with reverent awe! It is: - k = "SCHILY." + k - break - - default: break - } - - if (val && typeof val === "object" && - !Buffer.isBuffer(val)) encodeFields(val, k, body, nop) - else if (val === null || val === undefined) return - else body.push.apply(body, encodeField(k, val, nop)) - }) - - return body -} - -function encodeField (k, v, nop) { - // lowercase keys must be valid, otherwise prefix with - // "NODETAR." - if (k.charAt(0) === k.charAt(0).toLowerCase()) { - var m = k.split(".")[0] - if (!tar.knownExtended[m]) k = "NODETAR." + k - } - - // no proprietary - if (nop && k.charAt(0) !== k.charAt(0).toLowerCase()) { - return [] - } - - if (typeof val === "number") val = val.toString(10) - - var s = new Buffer(" " + k + "=" + v + "\n") - , digits = Math.floor(Math.log(s.length) / Math.log(10)) + 1 - - // console.error("1 s=%j digits=%j s.length=%d", s.toString(), digits, s.length) - - // if adding that many digits will make it go over that length, - // then add one to it. For example, if the string is: - // " foo=bar\n" - // then that's 9 characters. With the "9", that bumps the length - // up to 10. However, this is invalid: - // "10 foo=bar\n" - // but, since that's actually 11 characters, since 10 adds another - // character to the length, and the length includes the number - // itself. In that case, just bump it up again. - if (s.length + digits >= Math.pow(10, digits)) digits += 1 - // console.error("2 s=%j digits=%j s.length=%d", s.toString(), digits, s.length) - - var len = digits + s.length - // console.error("3 s=%j digits=%j s.length=%d len=%d", s.toString(), digits, s.length, len) - var lenBuf = new Buffer("" + len) - if (lenBuf.length + s.length !== len) { - throw new Error("Bad length calculation\n"+ - "len="+len+"\n"+ - "lenBuf="+JSON.stringify(lenBuf.toString())+"\n"+ - "lenBuf.length="+lenBuf.length+"\n"+ - "digits="+digits+"\n"+ - "s="+JSON.stringify(s.toString())+"\n"+ - "s.length="+s.length) - } - - return [lenBuf, s] -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header.js deleted file mode 100644 index 63b79ec..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extended-header.js +++ /dev/null @@ -1,139 +0,0 @@ -// An Entry consisting of: -// -// "%d %s=%s\n", , , -// -// The length is a decimal number, and includes itself and the \n -// \0 does not terminate anything. Only the length terminates the string. -// Numeric values are decimal strings. - -module.exports = ExtendedHeader - -var Entry = require("./entry.js") - , inherits = require("../vendor/inherits/inherits.js") - , tar = require("../tar.js") - , numeric = tar.numeric - , keyTrans = { "SCHILY.dev": "dev" - , "SCHILY.ino": "ino" - , "SCHILY.nlink": "nlink" } - -function ExtendedHeader () { - Entry.apply(this, arguments) - this.on("data", this._parse) - this.fields = {} - this._position = 0 - this._fieldPos = 0 - this._state = SIZE - this._sizeBuf = [] - this._keyBuf = [] - this._valBuf = [] - this._size = -1 - this._key = "" -} - -inherits(ExtendedHeader, Entry, { _parse: parse }) - -var s = 0 - , states = ExtendedHeader.states = {} - , SIZE = states.SIZE = s++ - , KEY = states.KEY = s++ - , VAL = states.VAL = s++ - , ERR = states.ERR = s++ - -Object.keys(states).forEach(function (s) { - states[states[s]] = states[s] -}) - -states[s] = null - -// char code values for comparison -var _0 = "0".charCodeAt(0) - , _9 = "9".charCodeAt(0) - , point = ".".charCodeAt(0) - , a = "a".charCodeAt(0) - , Z = "Z".charCodeAt(0) - , a = "a".charCodeAt(0) - , z = "z".charCodeAt(0) - , space = " ".charCodeAt(0) - , eq = "=".charCodeAt(0) - , cr = "\n".charCodeAt(0) - -function parse (c) { - if (this._state === ERR) return - - for ( var i = 0, l = c.length - ; i < l - ; this._position++, this._fieldPos++, i++) { - // console.error("top of loop, size="+this._size) - - var b = c[i] - - if (this._size >= 0 && this._fieldPos > this._size) { - error(this, "field exceeds length="+this._size) - return - } - - switch (this._state) { - case ERR: return - - case SIZE: - // console.error("parsing size, b=%d, rest=%j", b, c.slice(i).toString()) - if (b === space) { - this._state = KEY - // this._fieldPos = this._sizeBuf.length - this._size = parseInt(new Buffer(this._sizeBuf).toString(), 10) - this._sizeBuf.length = 0 - continue - } - if (b < _0 || b > _9) { - error(this, "expected [" + _0 + ".." + _9 + "], got " + b) - return - } - this._sizeBuf.push(b) - continue - - case KEY: - // can be any char except =, not > size. - if (b === eq) { - this._state = VAL - this._key = new Buffer(this._keyBuf).toString() - if (keyTrans[this._key]) this._key = keyTrans[this._key] - this._keyBuf.length = 0 - continue - } - this._keyBuf.push(b) - continue - - case VAL: - // field must end with cr - if (this._fieldPos === this._size - 1) { - // console.error("finished with "+this._key) - if (b !== cr) { - error(this, "expected \\n at end of field") - return - } - var val = new Buffer(this._valBuf).toString() - if (numeric[this._key]) { - val = parseFloat(val) - } - this.fields[this._key] = val - - this._valBuf.length = 0 - this._state = SIZE - this._size = -1 - this._fieldPos = -1 - continue - } - this._valBuf.push(b) - continue - } - } -} - -function error (me, msg) { - msg = "invalid header: " + msg - + "\nposition=" + me._position - + "\nfield position=" + me._fieldPos - - me.error(msg) - me.state = ERR -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extract.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extract.js deleted file mode 100644 index bffc033..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/extract.js +++ /dev/null @@ -1,78 +0,0 @@ -// give it a tarball and a path, and it'll dump the contents - -module.exports = Extract - -var tar = require("../tar.js") - , fstream = require("../vendor/fstream/fstream.js") - , inherits = require("../vendor/inherits/inherits.js") - , path = require("path") - -function Extract (opts) { - if (!(this instanceof Extract)) return new Extract(opts) - tar.Parse.apply(this) - - // have to dump into a directory - opts.type = "Directory" - opts.Directory = true - - if (typeof opts !== "object") { - opts = { path: opts } - } - - // better to drop in cwd? seems more standard. - opts.path = opts.path || path.resolve("node-tar-extract") - opts.type = "Directory" - opts.Directory = true - - // similar to --strip or --strip-components - opts.strip = +opts.strip - if (!opts.strip || opts.strip <= 0) opts.strip = 0 - - this._fst = fstream.Writer(opts) - - this.pause() - var me = this - - // Hardlinks in tarballs are relative to the root - // of the tarball. So, they need to be resolved against - // the target directory in order to be created properly. - me.on("entry", function (entry) { - // if there's a "strip" argument, then strip off that many - // path components. - if (opts.strip) { - var p = entry.path.split("/").slice(opts.strip).join("/") - entry.path = entry.props.path = p - if (entry.linkpath) { - var lp = entry.linkpath.split("/").slice(opts.strip).join("/") - entry.linkpath = entry.props.linkpath = lp - } - } - if (entry.type !== "Link") return - entry.linkpath = entry.props.linkpath = - path.join(opts.path, path.join("/", entry.props.linkpath)) - }) - - this._fst.on("ready", function () { - me.pipe(me._fst, { end: false }) - me.resume() - }) - - // this._fst.on("end", function () { - // console.error("\nEEEE Extract End", me._fst.path) - // }) - - this._fst.on("close", function () { - // console.error("\nEEEE Extract End", me._fst.path) - me.emit("end") - me.emit("close") - }) -} - -inherits(Extract, tar.Parse) - -Extract.prototype._streamEnd = function () { - var me = this - if (!me._ended) me.error("unexpected eof") - me._fst.end() - // my .end() is coming later. -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/global-header-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/global-header-writer.js deleted file mode 100644 index 99ff257..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/global-header-writer.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = GlobalHeaderWriter - -var ExtendedHeaderWriter = require("./extended-header-writer.js") - , inherits = require("../vendor/inherits/inherits.js") - -inherits(GlobalHeaderWriter, ExtendedHeaderWriter) - -function GlobalHeaderWriter (props) { - if (!(this instanceof GlobalHeaderWriter)) { - return new GlobalHeaderWriter(props) - } - ExtendedHeaderWriter.call(this, props) - this.props.type = "g" -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/header.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/header.js deleted file mode 100644 index 05b237c..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/header.js +++ /dev/null @@ -1,385 +0,0 @@ -// parse a 512-byte header block to a data object, or vice-versa -// If the data won't fit nicely in a simple header, then generate -// the appropriate extended header file, and return that. - -module.exports = TarHeader - -var tar = require("../tar.js") - , fields = tar.fields - , fieldOffs = tar.fieldOffs - , fieldEnds = tar.fieldEnds - , fieldSize = tar.fieldSize - , numeric = tar.numeric - , assert = require("assert").ok - , space = " ".charCodeAt(0) - , slash = "/".charCodeAt(0) - , bslash = process.platform === "win32" ? "\\".charCodeAt(0) : null - -function TarHeader (block) { - if (!(this instanceof TarHeader)) return new TarHeader(block) - if (block) this.decode(block) -} - -TarHeader.prototype = - { decode : decode - , encode: encode - , calcSum: calcSum - , checkSum: checkSum - } - -TarHeader.parseNumeric = parseNumeric -TarHeader.encode = encode -TarHeader.decode = decode - -// note that this will only do the normal ustar header, not any kind -// of extended posix header file. If something doesn't fit comfortably, -// then it will set obj.needExtended = true, and set the block to -// the closest approximation. -function encode (obj) { - if (!obj && !(this instanceof TarHeader)) throw new Error( - "encode must be called on a TarHeader, or supplied an object") - - obj = obj || this - var block = obj.block = new Buffer(512) - - // if the object has a "prefix", then that's actually an extension of - // the path field. - if (obj.prefix) { - // console.error("%% header encoding, got a prefix", obj.prefix) - obj.path = obj.prefix + "/" + obj.path - // console.error("%% header encoding, prefixed path", obj.path) - obj.prefix = "" - } - - obj.needExtended = false - - if (obj.mode) { - if (typeof obj.mode === "string") obj.mode = parseInt(obj.mode, 8) - obj.mode = obj.mode & 0777 - } - - for (var f = 0; fields[f] !== null; f ++) { - var field = fields[f] - , off = fieldOffs[f] - , end = fieldEnds[f] - , ret - - switch (field) { - case "cksum": - // special, done below, after all the others - break - - case "prefix": - // special, this is an extension of the "path" field. - // console.error("%% header encoding, skip prefix later") - break - - case "type": - // convert from long name to a single char. - var type = obj.type || "0" - if (type.length > 1) { - type = tar.types[obj.type] - if (!type) type = "0" - } - writeText(block, off, end, type) - break - - case "path": - // uses the "prefix" field if > 100 bytes, but <= 255 - var pathLen = Buffer.byteLength(obj.path) - , pathFSize = fieldSize[fields.path] - , prefFSize = fieldSize[fields.prefix] - - // paths between 100 and 255 should use the prefix field. - // longer than 255 - if (pathLen > pathFSize && - pathLen <= pathFSize + prefFSize) { - // need to find a slash somewhere in the middle so that - // path and prefix both fit in their respective fields - var searchStart = pathLen - 1 - pathFSize - , searchEnd = prefFSize - , found = false - , pathBuf = new Buffer(obj.path) - - for ( var s = searchStart - ; (s <= searchEnd) - ; s ++ ) { - if (pathBuf[s] === slash || pathBuf[s] === bslash) { - found = s - break - } - } - - if (found !== false) { - prefix = pathBuf.slice(0, found).toString("utf8") - path = pathBuf.slice(found + 1).toString("utf8") - - ret = writeText(block, off, end, path) - off = fieldOffs[fields.prefix] - end = fieldEnds[fields.prefix] - // console.error("%% header writing prefix", off, end, prefix) - ret = writeText(block, off, end, prefix) || ret - break - } - } - - // paths less than 100 chars don't need a prefix - // and paths longer than 255 need an extended header and will fail - // on old implementations no matter what we do here. - // Null out the prefix, and fallthrough to default. - // console.error("%% header writing no prefix") - var poff = fieldOffs[fields.prefix] - , pend = fieldEnds[fields.prefix] - writeText(block, poff, pend, "") - // fallthrough - - // all other fields are numeric or text - default: - ret = numeric[field] - ? writeNumeric(block, off, end, obj[field]) - : writeText(block, off, end, obj[field] || "") - break - } - obj.needExtended = obj.needExtended || ret - } - - var off = fieldOffs[fields.cksum] - , end = fieldEnds[fields.cksum] - - writeNumeric(block, off, end, calcSum.call(this, block)) - - return block -} - -// if it's a negative number, or greater than will fit, -// then use write256. -var MAXNUM = { 12: 077777777777 - , 11: 07777777777 - , 8 : 07777777 - , 7 : 0777777 } -function writeNumeric (block, off, end, num) { - var writeLen = end - off - , maxNum = MAXNUM[writeLen] || 0 - - num = num || 0 - // console.error(" numeric", num) - - if (num instanceof Date || - Object.prototype.toString.call(num) === "[object Date]") { - num = num.getTime() / 1000 - } - - if (num > maxNum || num < 0) { - write256(block, off, end, num) - // need an extended header if negative or too big. - return true - } - - // god, tar is so annoying - // if the string is small enough, you should put a space - // between the octal string and the \0, but if it doesn't - // fit, then don't. - var numStr = Math.floor(num).toString(8) - if (num < MAXNUM[writeLen - 1]) numStr += " " - - // pad with "0" chars - if (numStr.length < writeLen) { - numStr = (new Array(writeLen - numStr.length).join("0")) + numStr - } - - if (numStr.length !== writeLen - 1) { - throw new Error("invalid length: " + JSON.stringify(numStr) + "\n" + - "expected: "+writeLen) - } - block.write(numStr, off, writeLen, "utf8") - block[end - 1] = 0 -} - -function write256 (block, off, end, num) { - var buf = block.slice(off, end) - var positive = num >= 0 - buf[0] = positive ? 0x80 : 0xFF - - // get the number as a base-256 tuple - if (!positive) num *= -1 - var tuple = [] - do { - var n = num % 256 - tuple.push(n) - num = (num - n) / 256 - } while (num) - - var bytes = tuple.length - - var fill = buf.length - bytes - for (var i = 1; i < fill; i ++) { - buf[i] = positive ? 0 : 0xFF - } - - // tuple is a base256 number, with [0] as the *least* significant byte - // if it's negative, then we need to flip all the bits once we hit the - // first non-zero bit. The 2's-complement is (0x100 - n), and the 1's- - // complement is (0xFF - n). - var zero = true - for (i = bytes; i > 0; i --) { - var byte = tuple[bytes - i] - if (positive) buf[fill + i] = byte - else if (zero && byte === 0) buf[fill + i] = 0 - else if (zero) { - zero = false - buf[fill + i] = 0x100 - byte - } else buf[fill + i] = 0xFF - byte - } -} - -function writeText (block, off, end, str) { - // strings are written as utf8, then padded with \0 - var strLen = Buffer.byteLength(str) - , writeLen = Math.min(strLen, end - off) - // non-ascii fields need extended headers - // long fields get truncated - , needExtended = strLen !== str.length || strLen > writeLen - - // write the string, and null-pad - if (writeLen > 0) block.write(str, off, writeLen, "utf8") - for (var i = off + writeLen; i < end; i ++) block[i] = 0 - - return needExtended -} - -function calcSum (block) { - block = block || this.block - assert(Buffer.isBuffer(block) && block.length === 512) - - if (!block) throw new Error("Need block to checksum") - - // now figure out what it would be if the cksum was " " - var sum = 0 - , start = fieldOffs[fields.cksum] - , end = fieldEnds[fields.cksum] - - for (var i = 0; i < fieldOffs[fields.cksum]; i ++) { - sum += block[i] - } - - for (var i = start; i < end; i ++) { - sum += space - } - - for (var i = end; i < 512; i ++) { - sum += block[i] - } - - return sum -} - - -function checkSum (block) { - var sum = calcSum.call(this, block) - block = block || this.block - - var cksum = block.slice(fieldOffs[fields.cksum], fieldEnds[fields.cksum]) - cksum = parseNumeric(cksum) - - return cksum === sum -} - -function decode (block) { - block = block || this.block - assert(Buffer.isBuffer(block) && block.length === 512) - - this.block = block - this.cksumValid = this.checkSum() - - var prefix = null - - // slice off each field. - for (var f = 0; fields[f] !== null; f ++) { - var field = fields[f] - , val = block.slice(fieldOffs[f], fieldEnds[f]) - - switch (field) { - case "ustar": - // if not ustar, then everything after that is just padding. - if (val.toString() !== "ustar\0") { - this.ustar = false - return - } else { - // console.error("ustar:", val, val.toString()) - this.ustar = val.toString() - } - break - - // prefix is special, since it might signal the xstar header - case "prefix": - var atime = parseNumeric(val.slice(131, 131 + 12)) - , ctime = parseNumeric(val.slice(131 + 12, 131 + 12 + 12)) - if ((val[130] === 0 || val[130] === space) && - typeof atime === "number" && - typeof ctime === "number" && - val[131 + 12] === space && - val[131 + 12 + 12] === space) { - this.atime = atime - this.ctime = ctime - val = val.slice(0, 130) - } - prefix = val.toString("utf8").replace(/\0+$/, "") - // console.error("%% header reading prefix", prefix) - break - - // all other fields are null-padding text - // or a number. - default: - if (numeric[field]) { - this[field] = parseNumeric(val) - } else { - this[field] = val.toString("utf8").replace(/\0+$/, "") - } - break - } - } - - // if we got a prefix, then prepend it to the path. - if (prefix) { - this.path = prefix + "/" + this.path - // console.error("%% header got a prefix", this.path) - } -} - -function parse256 (buf) { - // first byte MUST be either 80 or FF - // 80 for positive, FF for 2's comp - var positive - if (buf[0] === 0x80) positive = true - else if (buf[0] === 0xFF) positive = false - else return null - - // build up a base-256 tuple from the least sig to the highest - var zero = false - , tuple = [] - for (var i = buf.length - 1; i > 0; i --) { - var byte = buf[i] - if (positive) tuple.push(byte) - else if (zero && byte === 0) tuple.push(0) - else if (zero) { - zero = false - tuple.push(0x100 - byte) - } else tuple.push(0xFF - byte) - } - - for (var sum = 0, i = 0, l = tuple.length; i < l; i ++) { - sum += tuple[i] * Math.pow(256, i) - } - - return positive ? sum : -1 * sum -} - -function parseNumeric (f) { - if (f[0] & 0x80) return parse256(f) - - var str = f.toString("utf8").split("\0")[0].trim() - , res = parseInt(str, 8) - - return isNaN(res) ? null : res -} - diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/pack.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/pack.js deleted file mode 100644 index 11b11fb..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/pack.js +++ /dev/null @@ -1,226 +0,0 @@ -// pipe in an fstream, and it'll make a tarball. -// key-value pair argument is global extended header props. - -module.exports = Pack - -var EntryWriter = require("./entry-writer.js") - , Stream = require("stream").Stream - , path = require("path") - , inherits = require("../vendor/inherits/inherits.js") - , GlobalHeaderWriter = require("./global-header-writer.js") - , collect = require("../vendor/fstream/fstream.js").collect - , eof = new Buffer(512) - -for (var i = 0; i < 512; i ++) eof[i] = 0 - -inherits(Pack, Stream) - -function Pack (props) { - // console.error("-- p ctor") - var me = this - if (!(me instanceof Pack)) return new Pack(props) - - if (props) me._noProprietary = props.noProprietary - else me._noProprietary = false - - me._global = props - - me.readable = true - me.writable = true - me._buffer = [] - // console.error("-- -- set current to null in ctor") - me._currentEntry = null - me._processing = false - - me._pipeRoot = null - me.on("pipe", function (src) { - if (src.root === me._pipeRoot) return - me._pipeRoot = src - src.on("end", function () { - me._pipeRoot = null - }) - me.add(src) - }) -} - -Pack.prototype.addGlobal = function (props) { - // console.error("-- p addGlobal") - if (this._didGlobal) return - this._didGlobal = true - - var me = this - GlobalHeaderWriter(props) - .on("data", function (c) { - me.emit("data", c) - }) - .end() -} - -Pack.prototype.add = function (stream) { - if (this._global && !this._didGlobal) this.addGlobal(this._global) - - if (this._ended) return this.emit("error", new Error("add after end")) - - collect(stream) - this._buffer.push(stream) - this._process() - this._needDrain = this._buffer.length > 0 - return !this._needDrain -} - -Pack.prototype.pause = function () { - this._paused = true - if (this._currentEntry) this._currentEntry.pause() - this.emit("pause") -} - -Pack.prototype.resume = function () { - this._paused = false - if (this._currentEntry) this._currentEntry.resume() - this.emit("resume") - this._process() -} - -Pack.prototype.end = function () { - this._ended = true - this._buffer.push(eof) - this._process() -} - -Pack.prototype._process = function () { - var me = this - if (me._paused || me._processing) { - return - } - - var entry = me._buffer.shift() - - if (!entry) { - if (me._needDrain) { - me.emit("drain") - } - return - } - - if (entry.ready === false) { - // console.error("-- entry is not ready", entry) - me._buffer.unshift(entry) - entry.on("ready", function () { - // console.error("-- -- ready!", entry) - me._process() - }) - return - } - - me._processing = true - - if (entry === eof) { - // need 2 ending null blocks. - me.emit("data", eof) - me.emit("data", eof) - me.emit("end") - me.emit("close") - return - } - - // Change the path to be relative to the root dir that was - // added to the tarball. - // - // XXX This should be more like how -C works, so you can - // explicitly set a root dir, and also explicitly set a pathname - // in the tarball to use. That way we can skip a lot of extra - // work when resolving symlinks for bundled dependencies in npm. - - var root = path.dirname((entry.root || entry).path) - var wprops = {} - - Object.keys(entry.props).forEach(function (k) { - wprops[k] = entry.props[k] - }) - - if (me._noProprietary) wprops.noProprietary = true - - wprops.path = path.relative(root, entry.path) - - // actually not a matter of opinion or taste. - if (process.platform === "win32") { - wprops.path = wprops.path.replace(/\\/g, "/") - } - - switch (wprops.type) { - // sockets not supported - case "Socket": - return - - case "Directory": - wprops.path += "/" - wprops.size = 0 - break - case "Link": - var lp = path.resolve(path.dirname(entry.path), entry.linkpath) - wprops.linkpath = path.relative(root, lp) || "." - wprops.size = 0 - break - case "SymbolicLink": - var lp = path.resolve(path.dirname(entry.path), entry.linkpath) - wprops.linkpath = path.relative(path.dirname(entry.path), lp) || "." - wprops.size = 0 - break - } - - // console.error("-- new writer", wprops) - // if (!wprops.type) { - // // console.error("-- no type?", entry.constructor.name, entry) - // } - - // console.error("-- -- set current to new writer", wprops.path) - var writer = me._currentEntry = EntryWriter(wprops) - - writer.parent = me - - // writer.on("end", function () { - // // console.error("-- -- writer end", writer.path) - // }) - - writer.on("data", function (c) { - me.emit("data", c) - }) - - writer.on("header", function () { - Buffer.prototype.toJSON = function () { - return this.toString().split(/\0/).join(".") - } - // console.error("-- -- writer header %j", writer.props) - if (writer.props.size === 0) nextEntry() - }) - writer.on("close", nextEntry) - - var ended = false - function nextEntry () { - if (ended) return - ended = true - - // console.error("-- -- writer close", writer.path) - // console.error("-- -- set current to null", wprops.path) - me._currentEntry = null - me._processing = false - me._process() - } - - writer.on("error", function (er) { - // console.error("-- -- writer error", writer.path) - me.emit("error", er) - }) - - // if it's the root, then there's no need to add its entries, - // or data, since they'll be added directly. - if (entry === me._pipeRoot) { - // console.error("-- is the root, don't auto-add") - writer.add = null - } - - entry.pipe(writer) -} - -Pack.prototype.destroy = function () {} -Pack.prototype.write = function () {} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/parse.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/parse.js deleted file mode 100644 index 3f71a92..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/lib/parse.js +++ /dev/null @@ -1,270 +0,0 @@ - -// A writable stream. -// It emits "entry" events, which provide a readable stream that has -// header info attached. - -module.exports = Parse.create = Parse - -var stream = require("stream") - , Stream = stream.Stream - , BlockStream = require("../vendor/block-stream/block-stream.js") - , tar = require("../tar.js") - , TarHeader = require("./header.js") - , Entry = require("./entry.js") - , BufferEntry = require("./buffer-entry.js") - , ExtendedHeader = require("./extended-header.js") - , assert = require("assert").ok - , inherits = require("../vendor/inherits/inherits.js") - , fstream = require("../vendor/fstream/fstream.js") - -// reading a tar is a lot like reading a directory -// However, we're actually not going to run the ctor, -// since it does a stat and various other stuff. -// This inheritance gives us the pause/resume/pipe -// behavior that is desired. -inherits(Parse, fstream.Reader) - -function Parse () { - var me = this - if (!(me instanceof Parse)) return new Parse() - - // doesn't apply fstream.Reader ctor? - // no, becasue we don't want to stat/etc, we just - // want to get the entry/add logic from .pipe() - Stream.apply(me) - - me.writable = true - me.readable = true - me._stream = new BlockStream(512) - me.position = 0 - - me._stream.on("error", function (e) { - me.emit("error", e) - }) - - me._stream.on("data", function (c) { - me._process(c) - }) - - me._stream.on("end", function () { - me._streamEnd() - }) - - me._stream.on("drain", function () { - me.emit("drain") - }) -} - -// overridden in Extract class, since it needs to -// wait for its DirWriter part to finish before -// emitting "end" -Parse.prototype._streamEnd = function () { - var me = this - if (!me._ended) me.error("unexpected eof") - me.emit("end") -} - -// a tar reader is actually a filter, not just a readable stream. -// So, you should pipe a tarball stream into it, and it needs these -// write/end methods to do that. -Parse.prototype.write = function (c) { - if (this._ended) { - // gnutar puts a LOT of nulls at the end. - // you can keep writing these things forever. - // Just ignore them. - for (var i = 0, l = c.length; i > l; i ++) { - if (c[i] !== 0) return this.error("write() after end()") - } - return - } - return this._stream.write(c) -} - -Parse.prototype.end = function (c) { - this._ended = true - return this._stream.end(c) -} - -// don't need to do anything, since we're just -// proxying the data up from the _stream. -// Just need to override the parent's "Not Implemented" -// error-thrower. -Parse.prototype._read = function () {} - -Parse.prototype._process = function (c) { - assert(c && c.length === 512, "block size should be 512") - - // one of three cases. - // 1. A new header - // 2. A part of a file/extended header - // 3. One of two or more EOF null blocks - - if (this._entry) { - var entry = this._entry - entry.write(c) - if (entry._remaining === 0) { - entry.end() - this._entry = null - } - } else { - // either zeroes or a header - var zero = true - for (var i = 0; i < 512 && zero; i ++) { - zero = c[i] === 0 - } - - // eof is *at least* 2 blocks of nulls, and then the end of the - // file. you can put blocks of nulls between entries anywhere, - // so appending one tarball to another is technically valid. - // ending without the eof null blocks is not allowed, however. - if (zero) { - this._ended = this._eofStarted - this._eofStarted = true - } else { - this._ended = this._eofStarted = false - this._startEntry(c) - } - - } - - this.position += 512 -} - -// take a header chunk, start the right kind of entry. -Parse.prototype._startEntry = function (c) { - var header = new TarHeader(c) - , self = this - , entry - , ev - , EntryType - , onend - , meta = false - - if (null === header.size || !header.cksumValid) { - var e = new Error("invalid tar file") - e.header = header - e.tar_file_offset = this.position - e.tar_block = this.position / 512 - this.emit("error", e) - } - - switch (tar.types[header.type]) { - case "File": - case "OldFile": - case "Link": - case "SymbolicLink": - case "CharacterDevice": - case "BlockDevice": - case "Directory": - case "FIFO": - case "ContiguousFile": - case "GNUDumpDir": - // start a file. - // pass in any extended headers - // These ones consumers are typically most interested in. - EntryType = Entry - ev = "entry" - break - - case "GlobalExtendedHeader": - // extended headers that apply to the rest of the tarball - EntryType = ExtendedHeader - onend = function () { - self._global = self._global || {} - Object.keys(entry.fields).forEach(function (k) { - self._global[k] = entry.fields[k] - }) - } - ev = "globalExtendedHeader" - meta = true - break - - case "ExtendedHeader": - case "OldExtendedHeader": - // extended headers that apply to the next entry - EntryType = ExtendedHeader - onend = function () { - self._extended = entry.fields - } - ev = "extendedHeader" - meta = true - break - - case "NextFileHasLongLinkpath": - // set linkpath= in extended header - EntryType = BufferEntry - onend = function () { - self._extended = self._extended || {} - self._extended.linkpath = entry.body - } - ev = "longLinkpath" - meta = true - break - - case "NextFileHasLongPath": - case "OldGnuLongPath": - // set path= in file-extended header - EntryType = BufferEntry - onend = function () { - self._extended = self._extended || {} - self._extended.path = entry.body - } - ev = "longPath" - meta = true - break - - default: - // all the rest we skip, but still set the _entry - // member, so that we can skip over their data appropriately. - // emit an event to say that this is an ignored entry type? - EntryType = Entry - ev = "ignoredEntry" - break - } - - var global, extended - if (meta) { - global = extended = null - } else { - var global = this._global - var extended = this._extended - - // extendedHeader only applies to one entry, so once we start - // an entry, it's over. - this._extended = null - } - entry = new EntryType(header, extended, global) - entry.meta = meta - - // only proxy data events of normal files. - if (!meta) { - entry.on("data", function (c) { - me.emit("data", c) - }) - } - - if (onend) entry.on("end", onend) - - this._entry = entry - var me = this - - entry.on("pause", function () { - me.pause() - }) - - entry.on("resume", function () { - me.resume() - }) - - if (this.listeners("*").length) { - this.emit("*", ev, entry) - } - - this.emit(ev, entry) - - // Zero-byte entry. End immediately. - if (entry.props.size === 0) { - entry.end() - this._entry = null - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/tar.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/tar.js deleted file mode 100644 index b9dbca4..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/tar.js +++ /dev/null @@ -1,172 +0,0 @@ -// field paths that every tar file must have. -// header is padded to 512 bytes. -var f = 0 - , fields = {} - , path = fields.path = f++ - , mode = fields.mode = f++ - , uid = fields.uid = f++ - , gid = fields.gid = f++ - , size = fields.size = f++ - , mtime = fields.mtime = f++ - , cksum = fields.cksum = f++ - , type = fields.type = f++ - , linkpath = fields.linkpath = f++ - , headerSize = 512 - , blockSize = 512 - , fieldSize = [] - -fieldSize[path] = 100 -fieldSize[mode] = 8 -fieldSize[uid] = 8 -fieldSize[gid] = 8 -fieldSize[size] = 12 -fieldSize[mtime] = 12 -fieldSize[cksum] = 8 -fieldSize[type] = 1 -fieldSize[linkpath] = 100 - -// "ustar\0" may introduce another bunch of headers. -// these are optional, and will be nulled out if not present. - -var ustar = fields.ustar = f++ - , ustarver = fields.ustarver = f++ - , uname = fields.uname = f++ - , gname = fields.gname = f++ - , devmaj = fields.devmaj = f++ - , devmin = fields.devmin = f++ - , prefix = fields.prefix = f++ - , fill = fields.fill = f++ - -// terminate fields. -fields[f] = null - -fieldSize[ustar] = 6 -fieldSize[ustarver] = 2 -fieldSize[uname] = 32 -fieldSize[gname] = 32 -fieldSize[devmaj] = 8 -fieldSize[devmin] = 8 -fieldSize[prefix] = 155 -fieldSize[fill] = 12 - -// nb: prefix field may in fact be 130 bytes of prefix, -// a null char, 12 bytes for atime, 12 bytes for ctime. -// -// To recognize this format: -// 1. prefix[130] === ' ' or '\0' -// 2. atime and ctime are octal numeric values -// 3. atime and ctime have ' ' in their last byte - -var fieldEnds = {} - , fieldOffs = {} - , fe = 0 -for (var i = 0; i < f; i ++) { - fieldOffs[i] = fe - fieldEnds[i] = (fe += fieldSize[i]) -} - -// build a translation table of field paths. -Object.keys(fields).forEach(function (f) { - if (fields[f] !== null) fields[fields[f]] = f -}) - -// different values of the 'type' field -// paths match the values of Stats.isX() functions, where appropriate -var types = - { 0: "File" - , "\0": "OldFile" // like 0 - , 1: "Link" - , 2: "SymbolicLink" - , 3: "CharacterDevice" - , 4: "BlockDevice" - , 5: "Directory" - , 6: "FIFO" - , 7: "ContiguousFile" // like 0 - // posix headers - , g: "GlobalExtendedHeader" // k=v for the rest of the archive - , x: "ExtendedHeader" // k=v for the next file - // vendor-specific stuff - , A: "SolarisACL" // skip - , D: "GNUDumpDir" // like 5, but with data, which should be skipped - , I: "Inode" // metadata only, skip - , K: "NextFileHasLongLinkpath" // data = link path of next file - , L: "NextFileHasLongPath" // data = path of next file - , M: "ContinuationFile" // skip - , N: "OldGnuLongPath" // like L - , S: "SparseFile" // skip - , V: "TapeVolumeHeader" // skip - , X: "OldExtendedHeader" // like x - } - -Object.keys(types).forEach(function (t) { - types[types[t]] = types[types[t]] || t -}) - -// values for the mode field -var modes = - { suid: 04000 // set uid on extraction - , sgid: 02000 // set gid on extraction - , svtx: 01000 // set restricted deletion flag on dirs on extraction - , uread: 0400 - , uwrite: 0200 - , uexec: 0100 - , gread: 040 - , gwrite: 020 - , gexec: 010 - , oread: 4 - , owrite: 2 - , oexec: 1 - , all: 07777 - } - -var numeric = - { mode: true - , uid: true - , gid: true - , size: true - , mtime: true - , devmaj: true - , devmin: true - , cksum: true - , atime: true - , ctime: true - , dev: true - , ino: true - , nlink: true - } - -Object.keys(modes).forEach(function (t) { - modes[modes[t]] = modes[modes[t]] || t -}) - -var knownExtended = - { atime: true - , charset: true - , comment: true - , ctime: true - , gid: true - , gname: true - , linkpath: true - , mtime: true - , path: true - , realtime: true - , security: true - , size: true - , uid: true - , uname: true } - - -exports.fields = fields -exports.fieldSize = fieldSize -exports.fieldOffs = fieldOffs -exports.fieldEnds = fieldEnds -exports.types = types -exports.modes = modes -exports.numeric = numeric -exports.headerSize = headerSize -exports.blockSize = blockSize -exports.knownExtended = knownExtended - -exports.Pack = require("./lib/pack.js") -exports.Parse = require("./lib/parse.js") -exports.Extract = require("./lib/extract.js") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE deleted file mode 100644 index 74489e2..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/LICENCE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) Isaac Z. Schlueter -All rights reserved. - -The BSD License - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/README.md deleted file mode 100644 index c16e9c4..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# block-stream - -A stream of blocks. - -Write data into it, and it'll output data in buffer blocks the size you -specify, padding with zeroes if necessary. - -```javascript -var block = new BlockStream(512) -fs.createReadStream("some-file").pipe(block) -block.pipe(fs.createWriteStream("block-file")) -``` - -When `.end()` or `.flush()` is called, it'll pad the block with zeroes. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/block-stream.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/block-stream.js deleted file mode 100644 index af63e5f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/block-stream/block-stream.js +++ /dev/null @@ -1,209 +0,0 @@ -// write data to it, and it'll emit data in 512 byte blocks. -// if you .end() or .flush(), it'll emit whatever it's got, -// padded with nulls to 512 bytes. - -module.exports = BlockStream - -var Stream = require("stream").Stream - , inherits = require("../inherits/inherits.js") - , assert = require("assert").ok - , debug = process.env.DEBUG ? console.error : function () {} - -function BlockStream (size, opt) { - this.writable = this.readable = true - this._opt = opt || {} - this._chunkSize = size || 512 - this._offset = 0 - this._buffer = [] - this._bufferLength = 0 - if (this._opt.nopad) this._zeroes = false - else { - this._zeroes = new Buffer(this._chunkSize) - for (var i = 0; i < this._chunkSize; i ++) { - this._zeroes[i] = 0 - } - } -} - -inherits(BlockStream, Stream) - -BlockStream.prototype.write = function (c) { - // debug(" BS write", c) - if (this._ended) throw new Error("BlockStream: write after end") - if (c && !Buffer.isBuffer(c)) c = new Buffer(c + "") - if (c.length) { - this._buffer.push(c) - this._bufferLength += c.length - } - // debug("pushed onto buffer", this._bufferLength) - if (this._bufferLength >= this._chunkSize) { - if (this._paused) { - // debug(" BS paused, return false, need drain") - this._needDrain = true - return false - } - this._emitChunk() - } - return true -} - -BlockStream.prototype.pause = function () { - // debug(" BS pausing") - this._paused = true -} - -BlockStream.prototype.resume = function () { - // debug(" BS resume") - this._paused = false - return this._emitChunk() -} - -BlockStream.prototype.end = function (chunk) { - // debug("end", chunk) - if (typeof chunk === "function") cb = chunk, chunk = null - if (chunk) this.write(chunk) - this._ended = true - this.flush() -} - -BlockStream.prototype.flush = function () { - this._emitChunk(true) -} - -BlockStream.prototype._emitChunk = function (flush) { - // debug("emitChunk flush=%j emitting=%j paused=%j", flush, this._emitting, this._paused) - - // emit a chunk - if (flush && this._zeroes) { - // debug(" BS push zeroes", this._bufferLength) - // push a chunk of zeroes - var padBytes = (this._bufferLength % this._chunkSize) - if (padBytes !== 0) padBytes = this._chunkSize - padBytes - if (padBytes > 0) { - // debug("padBytes", padBytes, this._zeroes.slice(0, padBytes)) - this._buffer.push(this._zeroes.slice(0, padBytes)) - this._bufferLength += padBytes - // debug(this._buffer[this._buffer.length - 1].length, this._bufferLength) - } - } - - if (this._emitting || this._paused) return - this._emitting = true - - // debug(" BS entering loops") - var bufferIndex = 0 - while (this._bufferLength >= this._chunkSize && - (flush || !this._paused)) { - // debug(" BS data emission loop", this._bufferLength) - - var out - , outOffset = 0 - , outHas = this._chunkSize - - while (outHas > 0 && (flush || !this._paused) ) { - // debug(" BS data inner emit loop", this._bufferLength) - var cur = this._buffer[bufferIndex] - , curHas = cur.length - this._offset - // debug("cur=", cur) - // debug("curHas=%j", curHas) - // If it's not big enough to fill the whole thing, then we'll need - // to copy multiple buffers into one. However, if it is big enough, - // then just slice out the part we want, to save unnecessary copying. - // Also, need to copy if we've already done some copying, since buffers - // can't be joined like cons strings. - if (out || curHas < outHas) { - out = out || new Buffer(this._chunkSize) - cur.copy(out, outOffset, - this._offset, this._offset + Math.min(curHas, outHas)) - } else if (cur.length === outHas && this._offset === 0) { - // shortcut -- cur is exactly long enough, and no offset. - out = cur - } else { - // slice out the piece of cur that we need. - out = cur.slice(this._offset, this._offset + outHas) - } - - if (curHas > outHas) { - // means that the current buffer couldn't be completely output - // update this._offset to reflect how much WAS written - this._offset += outHas - outHas = 0 - } else { - // output the entire current chunk. - // toss it away - outHas -= curHas - outOffset += curHas - bufferIndex ++ - this._offset = 0 - } - } - - this._bufferLength -= this._chunkSize - assert(out.length === this._chunkSize) - // debug("emitting data", out) - // debug(" BS emitting, paused=%j", this._paused, this._bufferLength) - this.emit("data", out) - out = null - } - // debug(" BS out of loops", this._bufferLength) - - // whatever is left, it's not enough to fill up a block, or we're paused - this._buffer = this._buffer.slice(bufferIndex) - if (this._paused) { - // debug(" BS paused, leaving", this._bufferLength) - this._needsDrain = true - this._emitting = false - return - } - - // if flushing, and not using null-padding, then need to emit the last - // chunk(s) sitting in the queue. We know that it's not enough to - // fill up a whole block, because otherwise it would have been emitted - // above, but there may be some offset. - var l = this._buffer.length - if (flush && !this._zeroes && l) { - if (l === 1) { - if (this._offset) { - this.emit("data", this._buffer[0].slice(this._offset)) - } else { - this.emit("data", this._buffer[0]) - } - } else { - var outHas = this._bufferLength - , out = new Buffer(outHas) - , outOffset = 0 - for (var i = 0; i < l; i ++) { - var cur = this._buffer[i] - , curHas = cur.length - this._offset - cur.copy(out, outOffset, this._offset) - this._offset = 0 - outOffset += curHas - this._bufferLength -= curHas - } - this.emit("data", out) - } - // truncate - this._buffer.length = 0 - this._bufferLength = 0 - this._offset = 0 - } - - // now either drained or ended - // debug("either draining, or ended", this._bufferLength, this._ended) - // means that we've flushed out all that we can so far. - if (this._needDrain) { - // debug("emitting drain", this._bufferLength) - this._needDrain = false - this.emit("drain") - } - - if ((this._bufferLength === 0) && this._ended && !this._endEmitted) { - // debug("emitting end", this._bufferLength) - this._endEmitted = true - this.emit("end") - } - - this._emitting = false - - // debug(" BS no longer emitting", flush, this._paused, this._emitting, this._bufferLength, this._chunkSize) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE deleted file mode 100644 index 74489e2..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/LICENCE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) Isaac Z. Schlueter -All rights reserved. - -The BSD License - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/README.md deleted file mode 100644 index 9d8cb77..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/README.md +++ /dev/null @@ -1,76 +0,0 @@ -Like FS streams, but with stat on them, and supporting directories and -symbolic links, as well as normal files. Also, you can use this to set -the stats on a file, even if you don't change its contents, or to create -a symlink, etc. - -So, for example, you can "write" a directory, and it'll call `mkdir`. You -can specify a uid and gid, and it'll call `chown`. You can specify a -`mtime` and `atime`, and it'll call `utimes`. You can call it a symlink -and provide a `linkpath` and it'll call `symlink`. - -Note that it won't automatically resolve symbolic links. So, if you -call `fstream.Reader('/some/symlink')` then you'll get an object -that stats and then ends immediately (since it has no data). To follow -symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow: -true })`. - -There are various checks to make sure that the bytes emitted are the -same as the intended size, if the size is set. - -## Examples - -```javascript -fstream - .Writer({ path: "path/to/file" - , mode: 0755 - , size: 6 - }) - .write("hello\n") - .end() -``` - -This will create the directories if they're missing, and then write -`hello\n` into the file, chmod it to 0755, and assert that 6 bytes have -been written when it's done. - -```javascript -fstream - .Writer({ path: "path/to/file" - , mode: 0755 - , size: 6 - , flags: "a" - }) - .write("hello\n") - .end() -``` - -You can pass flags in, if you want to append to a file. - -```javascript -fstream - .Writer({ path: "path/to/symlink" - , linkpath: "./file" - , SymbolicLink: true - , mode: "0755" // octal strings supported - }) - .end() -``` - -If isSymbolicLink is a function, it'll be called, and if it returns -true, then it'll treat it as a symlink. If it's not a function, then -any truish value will make a symlink, or you can set `type: -'SymbolicLink'`, which does the same thing. - -Note that the linkpath is relative to the symbolic link location, not -the parent dir or cwd. - -```javascript -fstream - .Reader("path/to/dir") - .pipe(fstream.Writer("path/to/other/dir")) -``` - -This will do like `cp -Rp path/to/dir path/to/other/dir`. If the other -dir exists and isn't a directory, then it'll emit an error. It'll also -set the uid, gid, mode, etc. to be identical. In this way, it's more -like `rsync -a` than simply a copy. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/fstream.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/fstream.js deleted file mode 100644 index c66d26f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/fstream.js +++ /dev/null @@ -1,31 +0,0 @@ -exports.Abstract = require("./lib/abstract.js") -exports.Reader = require("./lib/reader.js") -exports.Writer = require("./lib/writer.js") - -exports.File = - { Reader: require("./lib/file-reader.js") - , Writer: require("./lib/file-writer.js") } - -exports.Dir = - { Reader : require("./lib/dir-reader.js") - , Writer : require("./lib/dir-writer.js") } - -exports.Link = - { Reader : require("./lib/link-reader.js") - , Writer : require("./lib/link-writer.js") } - -exports.Proxy = - { Reader : require("./lib/proxy-reader.js") - , Writer : require("./lib/proxy-writer.js") } - -exports.Reader.Dir = exports.DirReader = exports.Dir.Reader -exports.Reader.File = exports.FileReader = exports.File.Reader -exports.Reader.Link = exports.LinkReader = exports.Link.Reader -exports.Reader.Proxy = exports.ProxyReader = exports.Proxy.Reader - -exports.Writer.Dir = exports.DirWriter = exports.Dir.Writer -exports.Writer.File = exports.FileWriter = exports.File.Writer -exports.Writer.Link = exports.LinkWriter = exports.Link.Writer -exports.Writer.Proxy = exports.ProxyWriter = exports.Proxy.Writer - -exports.collect = require("./lib/collect.js") diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/abstract.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/abstract.js deleted file mode 100644 index 6161f3b..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/abstract.js +++ /dev/null @@ -1,85 +0,0 @@ -// the parent class for all fstreams. - -module.exports = Abstract - -var Stream = require("stream").Stream - , inherits = require("../../inherits/inherits.js") - -function Abstract () { - Stream.call(this) -} - -inherits(Abstract, Stream) - -Abstract.prototype.on = function (ev, fn) { - if (ev === "ready" && this.ready) { - process.nextTick(fn.bind(this)) - } else { - Stream.prototype.on.call(this, ev, fn) - } - return this -} - -Abstract.prototype.abort = function () { - this._aborted = true - this.emit("abort") -} - -Abstract.prototype.destroy = function () {} - -Abstract.prototype.warn = function (msg, code) { - var me = this - , er = decorate(msg, code, me) - if (!me.listeners("warn")) { - console.error("%s %s\n" + - "path = %s\n" + - "syscall = %s\n" + - "fstream_type = %s\n" + - "fstream_path = %s\n" + - "fstream_unc_path = %s\n" + - "fstream_class = %s\n" + - "fstream_stack =\n%s\n", - code || "UNKNOWN", - er.stack, - er.path, - er.syscall, - er.fstream_type, - er.fstream_path, - er.fstream_unc_path, - er.fstream_class, - er.fstream_stack.join("\n")) - } else { - me.emit("warn", er) - } -} - -Abstract.prototype.info = function (msg, code) { - this.emit("info", msg, code) -} - -Abstract.prototype.error = function (msg, code, th) { - var er = decorate(msg, code, this) - if (th) throw er - else this.emit("error", er) -} - -function decorate (er, code, me) { - if (!(er instanceof Error)) er = new Error(er) - er.code = er.code || code - er.path = er.path || me.path - er.fstream_type = er.fstream_type || me.type - er.fstream_path = er.fstream_path || me.path - if (me._path !== me.path) { - er.fstream_unc_path = er.fstream_unc_path || me._path - } - if (me.linkpath) { - er.fstream_linkpath = er.fstream_linkpath || me.linkpath - } - er.fstream_class = er.fstream_class || me.constructor.name - er.fstream_stack = er.fstream_stack || - new Error().stack.split(/\n/).slice(3).map(function (s) { - return s.replace(/^ at /, "") - }) - - return er -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/collect.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/collect.js deleted file mode 100644 index a36f780..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/collect.js +++ /dev/null @@ -1,67 +0,0 @@ -module.exports = collect - -function collect (stream) { - if (stream._collected) return - - stream._collected = true - stream.pause() - - stream.on("data", save) - stream.on("end", save) - var buf = [] - function save (b) { - if (typeof b === "string") b = new Buffer(b) - if (Buffer.isBuffer(b) && !b.length) return - buf.push(b) - } - - stream.on("entry", saveEntry) - var entryBuffer = [] - function saveEntry (e) { - collect(e) - entryBuffer.push(e) - } - - stream.on("proxy", proxyPause) - function proxyPause (p) { - p.pause() - } - - - // replace the pipe method with a new version that will - // unlock the buffered stuff. if you just call .pipe() - // without a destination, then it'll re-play the events. - stream.pipe = (function (orig) { return function (dest) { - // console.error(" === open the pipes", dest && dest.path) - - // let the entries flow through one at a time. - // Once they're all done, then we can resume completely. - var e = 0 - ;(function unblockEntry () { - var entry = entryBuffer[e++] - // console.error(" ==== unblock entry", entry && entry.path) - if (!entry) return resume() - entry.on("end", unblockEntry) - if (dest) dest.add(entry) - else stream.emit("entry", entry) - })() - - function resume () { - stream.removeListener("entry", saveEntry) - stream.removeListener("data", save) - stream.removeListener("end", save) - - stream.pipe = orig - if (dest) stream.pipe(dest) - - buf.forEach(function (b) { - if (b) stream.emit("data", b) - else stream.emit("end") - }) - - stream.resume() - } - - return dest - }})(stream.pipe) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-reader.js deleted file mode 100644 index e655b0d..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-reader.js +++ /dev/null @@ -1,250 +0,0 @@ -// A thing that emits "entry" events with Reader objects -// Pausing it causes it to stop emitting entry events, and also -// pauses the current entry if there is one. - -module.exports = DirReader - -var fs = require("../../graceful-fs/graceful-fs.js") - , fstream = require("../fstream.js") - , Reader = fstream.Reader - , inherits = require("../../inherits/inherits.js") - , mkdir = require("../../mkdirp") - , path = require("path") - , Reader = require("./reader.js") - , assert = require("assert").ok - -inherits(DirReader, Reader) - -function DirReader (props) { - var me = this - if (!(me instanceof DirReader)) throw new Error( - "DirReader must be called as constructor.") - - // should already be established as a Directory type - if (props.type !== "Directory" || !props.Directory) { - throw new Error("Non-directory type "+ props.type) - } - - me.entries = null - me._index = -1 - me._paused = false - me._length = -1 - - if (props.sort) { - this.sort = props.sort - } - - Reader.call(this, props) -} - -DirReader.prototype._getEntries = function () { - var me = this - - // race condition. might pause() before calling _getEntries, - // and then resume, and try to get them a second time. - if (me._gotEntries) return - me._gotEntries = true - - fs.readdir(me._path, function (er, entries) { - if (er) return me.error(er) - - me.entries = entries - - me.emit("entries", entries) - if (me._paused) me.once("resume", processEntries) - else processEntries() - - function processEntries () { - me._length = me.entries.length - if (typeof me.sort === "function") { - me.entries = me.entries.sort(me.sort.bind(me)) - } - me._read() - } - }) -} - -// start walking the dir, and emit an "entry" event for each one. -DirReader.prototype._read = function () { - var me = this - - if (!me.entries) return me._getEntries() - - if (me._paused || me._currentEntry || me._aborted) { - // console.error("DR paused=%j, current=%j, aborted=%j", me._paused, !!me._currentEntry, me._aborted) - return - } - - me._index ++ - if (me._index >= me.entries.length) { - if (!me._ended) { - me._ended = true - me.emit("end") - me.emit("close") - } - return - } - - // ok, handle this one, then. - - // save creating a proxy, by stat'ing the thing now. - var p = path.resolve(me._path, me.entries[me._index]) - assert(p !== me._path) - assert(me.entries[me._index]) - - // set this to prevent trying to _read() again in the stat time. - me._currentEntry = p - fs[ me.props.follow ? "stat" : "lstat" ](p, function (er, stat) { - if (er) return me.error(er) - - var who = me._proxy || me - - stat.path = p - stat.basename = path.basename(p) - stat.dirname = path.dirname(p) - var childProps = me.getChildProps.call(who, stat) - childProps.path = p - childProps.basename = path.basename(p) - childProps.dirname = path.dirname(p) - - var entry = Reader(childProps, stat) - - // console.error("DR Entry", p, stat.size) - - me._currentEntry = entry - - // "entry" events are for direct entries in a specific dir. - // "child" events are for any and all children at all levels. - // This nomenclature is not completely final. - - entry.on("pause", function (who) { - if (!me._paused && !entry._disowned) { - me.pause(who) - } - }) - - entry.on("resume", function (who) { - if (me._paused && !entry._disowned) { - me.resume(who) - } - }) - - entry.on("stat", function (props) { - me.emit("_entryStat", entry, props) - if (entry._aborted) return - if (entry._paused) entry.once("resume", function () { - me.emit("entryStat", entry, props) - }) - else me.emit("entryStat", entry, props) - }) - - entry.on("ready", function EMITCHILD () { - // console.error("DR emit child", entry._path) - if (me._paused) { - // console.error(" DR emit child - try again later") - // pause the child, and emit the "entry" event once we drain. - // console.error("DR pausing child entry") - entry.pause(me) - return me.once("resume", EMITCHILD) - } - - // skip over sockets. they can't be piped around properly, - // so there's really no sense even acknowledging them. - // if someone really wants to see them, they can listen to - // the "socket" events. - if (entry.type === "Socket") { - me.emit("socket", entry) - } else { - me.emitEntry(entry) - } - }) - - var ended = false - entry.on("close", onend) - entry.on("disown", onend) - function onend () { - if (ended) return - ended = true - me.emit("childEnd", entry) - me.emit("entryEnd", entry) - me._currentEntry = null - if (!me._paused) { - me._read() - } - } - - // XXX Remove this. Works in node as of 0.6.2 or so. - // Long filenames should not break stuff. - entry.on("error", function (er) { - if (entry._swallowErrors) { - me.warn(er) - entry.emit("end") - entry.emit("close") - } else { - me.emit("error", er) - } - }) - - // proxy up some events. - ; [ "child" - , "childEnd" - , "warn" - ].forEach(function (ev) { - entry.on(ev, me.emit.bind(me, ev)) - }) - }) -} - -DirReader.prototype.disown = function (entry) { - entry.emit("beforeDisown") - entry._disowned = true - entry.parent = entry.root = null - if (entry === this._currentEntry) { - this._currentEntry = null - } - entry.emit("disown") -} - -DirReader.prototype.getChildProps = function (stat) { - return { depth: this.depth + 1 - , root: this.root || this - , parent: this - , follow: this.follow - , filter: this.filter - , sort: this.props.sort - } -} - -DirReader.prototype.pause = function (who) { - var me = this - if (me._paused) return - who = who || me - me._paused = true - if (me._currentEntry && me._currentEntry.pause) { - me._currentEntry.pause(who) - } - me.emit("pause", who) -} - -DirReader.prototype.resume = function (who) { - var me = this - if (!me._paused) return - who = who || me - - me._paused = false - // console.error("DR Emit Resume", me._path) - me.emit("resume", who) - if (me._paused) { - // console.error("DR Re-paused", me._path) - return - } - - if (me._currentEntry) { - if (me._currentEntry.resume) me._currentEntry.resume(who) - } else me._read() -} - -DirReader.prototype.emitEntry = function (entry) { - this.emit("entry", entry) - this.emit("child", entry) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-writer.js deleted file mode 100644 index 71eb358..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/dir-writer.js +++ /dev/null @@ -1,171 +0,0 @@ -// It is expected that, when .add() returns false, the consumer -// of the DirWriter will pause until a "drain" event occurs. Note -// that this is *almost always going to be the case*, unless the -// thing being written is some sort of unsupported type, and thus -// skipped over. - -module.exports = DirWriter - -var fs = require("../../graceful-fs/graceful-fs.js") - , fstream = require("../fstream.js") - , Writer = require("./writer.js") - , inherits = require("../../inherits/inherits.js") - , mkdir = require("../../mkdirp") - , path = require("path") - , collect = require("./collect.js") - -inherits(DirWriter, Writer) - -function DirWriter (props) { - var me = this - if (!(me instanceof DirWriter)) me.error( - "DirWriter must be called as constructor.", null, true) - - // should already be established as a Directory type - if (props.type !== "Directory" || !props.Directory) { - me.error("Non-directory type "+ props.type + " " + - JSON.stringify(props), null, true) - } - - Writer.call(this, props) -} - -DirWriter.prototype._create = function () { - var me = this - mkdir(me._path, Writer.dirmode, function (er) { - if (er) return me.error(er) - // ready to start getting entries! - me.ready = true - me.emit("ready") - me._process() - }) -} - -// a DirWriter has an add(entry) method, but its .write() doesn't -// do anything. Why a no-op rather than a throw? Because this -// leaves open the door for writing directory metadata for -// gnu/solaris style dumpdirs. -DirWriter.prototype.write = function () { - return true -} - -DirWriter.prototype.end = function () { - this._ended = true - this._process() -} - -DirWriter.prototype.add = function (entry) { - var me = this - - // console.error("\tadd", entry._path, "->", me._path) - collect(entry) - if (!me.ready || me._currentEntry) { - me._buffer.push(entry) - return false - } - - // create a new writer, and pipe the incoming entry into it. - if (me._ended) { - return me.error("add after end") - } - - me._buffer.push(entry) - me._process() - - return 0 === this._buffer.length -} - -DirWriter.prototype._process = function () { - var me = this - - // console.error("DW Process p=%j", me._processing, me.basename) - - if (me._processing) return - - var entry = me._buffer.shift() - if (!entry) { - // console.error("DW Drain") - me.emit("drain") - if (me._ended) me._finish() - return - } - - me._processing = true - // console.error("DW Entry", entry._path) - - me.emit("entry", entry) - - // ok, add this entry - // - // don't allow recursive copying - var p = entry - do { - var pp = p._path || p.path - if (pp === me.root._path || pp === me._path || - (pp && pp.indexOf(me._path) === 0)) { - // console.error("DW Exit (recursive)", entry.basename, me._path) - me._processing = false - if (entry._collected) entry.pipe() - return me._process() - } - } while (p = p.parent) - - // console.error("DW not recursive") - - // chop off the entry's root dir, replace with ours - var props = { parent: me - , root: me.root || me - , type: entry.type - , depth: me.depth + 1 } - - var p = entry._path || entry.path || entry.props.path - if (entry.parent) { - p = p.substr(entry.parent._path.length + 1) - } - // get rid of any ../../ shenanigans - props.path = path.join(me.path, path.join("/", p)) - - // if i have a filter, the child should inherit it. - props.filter = me.filter - - // all the rest of the stuff, copy over from the source. - Object.keys(entry.props).forEach(function (k) { - if (!props.hasOwnProperty(k)) { - props[k] = entry.props[k] - } - }) - - // not sure at this point what kind of writer this is. - var child = me._currentChild = new Writer(props) - child.on("ready", function () { - // console.error("DW Child Ready", child.type, child._path) - // console.error(" resuming", entry._path) - entry.pipe(child) - entry.resume() - }) - - // XXX Make this work in node. - // Long filenames should not break stuff. - child.on("error", function (er) { - if (child._swallowErrors) { - me.warn(er) - child.emit("end") - child.emit("close") - } else { - me.emit("error", er) - } - }) - - // we fire _end internally *after* end, so that we don't move on - // until any "end" listeners have had their chance to do stuff. - child.on("close", onend) - var ended = false - function onend () { - if (ended) return - ended = true - // console.error("* DW Child end", child.basename) - me._currentChild = null - me._processing = false - me._process() - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-reader.js deleted file mode 100644 index e53718a..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-reader.js +++ /dev/null @@ -1,147 +0,0 @@ -// Basically just a wrapper around an fs.ReadStream - -module.exports = FileReader - -var fs = require("../../graceful-fs/graceful-fs.js") - , fstream = require("../fstream.js") - , Reader = fstream.Reader - , inherits = require("../../inherits/inherits.js") - , mkdir = require("../../mkdirp") - , Reader = require("./reader.js") - , EOF = {EOF: true} - , CLOSE = {CLOSE: true} - -inherits(FileReader, Reader) - -function FileReader (props) { - // console.error(" FR create", props.path, props.size, new Error().stack) - var me = this - if (!(me instanceof FileReader)) throw new Error( - "FileReader must be called as constructor.") - - // should already be established as a File type - // XXX Todo: preserve hardlinks by tracking dev+inode+nlink, - // with a HardLinkReader class. - if (!((props.type === "Link" && props.Link) || - (props.type === "File" && props.File))) { - throw new Error("Non-file type "+ props.type) - } - - me._buffer = [] - me._bytesEmitted = 0 - Reader.call(me, props) -} - -FileReader.prototype._getStream = function () { - var me = this - , stream = me._stream = fs.createReadStream(me._path, me.props) - - if (me.props.blksize) { - stream.bufferSize = me.props.blksize - } - - stream.on("open", me.emit.bind(me, "open")) - - stream.on("data", function (c) { - // console.error("\t\t%d %s", c.length, me.basename) - me._bytesEmitted += c.length - // no point saving empty chunks - if (!c.length) return - else if (me._paused || me._buffer.length) { - me._buffer.push(c) - me._read() - } else me.emit("data", c) - }) - - stream.on("end", function () { - if (me._paused || me._buffer.length) { - // console.error("FR Buffering End", me._path) - me._buffer.push(EOF) - me._read() - } else { - me.emit("end") - } - - if (me._bytesEmitted !== me.props.size) { - me.error("Didn't get expected byte count\n"+ - "expect: "+me.props.size + "\n" + - "actual: "+me._bytesEmitted) - } - }) - - stream.on("close", function () { - if (me._paused || me._buffer.length) { - // console.error("FR Buffering Close", me._path) - me._buffer.push(CLOSE) - me._read() - } else { - // console.error("FR close 1", me._path) - me.emit("close") - } - }) - - me._read() -} - -FileReader.prototype._read = function () { - var me = this - // console.error("FR _read", me._path) - if (me._paused) { - // console.error("FR _read paused", me._path) - return - } - - if (!me._stream) { - // console.error("FR _getStream calling", me._path) - return me._getStream() - } - - // clear out the buffer, if there is one. - if (me._buffer.length) { - // console.error("FR _read has buffer", me._buffer.length, me._path) - var buf = me._buffer - for (var i = 0, l = buf.length; i < l; i ++) { - var c = buf[i] - if (c === EOF) { - // console.error("FR Read emitting buffered end", me._path) - me.emit("end") - } else if (c === CLOSE) { - // console.error("FR Read emitting buffered close", me._path) - me.emit("close") - } else { - // console.error("FR Read emitting buffered data", me._path) - me.emit("data", c) - } - - if (me._paused) { - // console.error("FR Read Re-pausing at "+i, me._path) - me._buffer = buf.slice(i) - return - } - } - me._buffer.length = 0 - } - // console.error("FR _read done") - // that's about all there is to it. -} - -FileReader.prototype.pause = function (who) { - var me = this - // console.error("FR Pause", me._path) - if (me._paused) return - who = who || me - me._paused = true - if (me._stream) me._stream.pause() - me.emit("pause", who) -} - -FileReader.prototype.resume = function (who) { - var me = this - // console.error("FR Resume", me._path) - if (!me._paused) return - who = who || me - me.emit("resume", who) - me._paused = false - if (me._stream) me._stream.resume() - me._read() -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-writer.js deleted file mode 100644 index 70bb86d..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/file-writer.js +++ /dev/null @@ -1,95 +0,0 @@ -module.exports = FileWriter - -var fs = require("../../graceful-fs/graceful-fs.js") - , mkdir = require("../../mkdirp") - , Writer = require("./writer.js") - , inherits = require("../../inherits/inherits.js") - , EOF = {} - -inherits(FileWriter, Writer) - -function FileWriter (props) { - var me = this - if (!(me instanceof FileWriter)) throw new Error( - "FileWriter must be called as constructor.") - - // should already be established as a File type - if (props.type !== "File" || !props.File) { - throw new Error("Non-file type "+ props.type) - } - - me._buffer = [] - me._bytesWritten = 0 - - Writer.call(this, props) -} - -FileWriter.prototype._create = function () { - var me = this - if (me._stream) return - - var so = {} - if (me.props.flags) so.flags = me.props.flags - so.mode = Writer.filemode - if (me._old && me._old.blksize) so.bufferSize = me._old.blksize - - me._stream = fs.createWriteStream(me._path, so) - - me._stream.on("open", function (fd) { - me.ready = true - me._buffer.forEach(function (c) { - if (c === EOF) me._stream.end() - else me._stream.write(c) - }) - me.emit("ready") - }) - - me._stream.on("drain", function () { me.emit("drain") }) - - me._stream.on("close", function () { - // console.error("\n\nFW Stream Close", me._path, me.size) - me._finish() - }) -} - -FileWriter.prototype.write = function (c) { - var me = this - - me._bytesWritten += c.length - - if (!me.ready) { - me._buffer.push(c) - return false - } - - var ret = me._stream.write(c) - // console.error("\t-- fw wrote, _stream says", ret, me._stream._queue.length) - - // allow 2 buffered writes, because otherwise there's just too - // much stop and go bs. - return ret || (me._stream._queue && me._stream._queue.length <= 2) -} - -FileWriter.prototype.end = function (c) { - var me = this - - if (c) me.write(c) - - if (!me.ready) { - me._buffer.push(EOF) - return false - } - - return me._stream.end() -} - -FileWriter.prototype._finish = function () { - var me = this - if (typeof me.size === "number" && me._bytesWritten != me.size) { - me.error( - "Did not get expected byte count.\n" + - "expect: " + me.size + "\n" + - "actual: " + me._bytesWritten) - } - Writer.prototype._finish.call(me) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/get-type.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/get-type.js deleted file mode 100644 index cd65c41..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/get-type.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = getType - -function getType (st) { - var types = - [ "Directory" - , "File" - , "SymbolicLink" - , "Link" // special for hardlinks from tarballs - , "BlockDevice" - , "CharacterDevice" - , "FIFO" - , "Socket" ] - , type - - if (st.type && -1 !== types.indexOf(st.type)) { - st[st.type] = true - return st.type - } - - for (var i = 0, l = types.length; i < l; i ++) { - type = types[i] - var is = st[type] || st["is" + type] - if (typeof is === "function") is = is.call(st) - if (is) { - st[type] = true - st.type = type - return type - } - } - - return null -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-reader.js deleted file mode 100644 index 1d07e2f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-reader.js +++ /dev/null @@ -1,54 +0,0 @@ -// Basically just a wrapper around an fs.readlink -// -// XXX: Enhance this to support the Link type, by keeping -// a lookup table of {:}, so that hardlinks -// can be preserved in tarballs. - -module.exports = LinkReader - -var fs = require("../../graceful-fs/graceful-fs.js") - , fstream = require("../fstream.js") - , inherits = require("../../inherits/inherits.js") - , mkdir = require("../../mkdirp") - , Reader = require("./reader.js") - -inherits(LinkReader, Reader) - -function LinkReader (props) { - var me = this - if (!(me instanceof LinkReader)) throw new Error( - "LinkReader must be called as constructor.") - - if (!((props.type === "Link" && props.Link) || - (props.type === "SymbolicLink" && props.SymbolicLink))) { - throw new Error("Non-link type "+ props.type) - } - - Reader.call(me, props) -} - -// When piping a LinkReader into a LinkWriter, we have to -// already have the linkpath property set, so that has to -// happen *before* the "ready" event, which means we need to -// override the _stat method. -LinkReader.prototype._stat = function (currentStat) { - var me = this - fs.readlink(me._path, function (er, linkpath) { - if (er) return me.error(er) - me.linkpath = me.props.linkpath = linkpath - me.emit("linkpath", linkpath) - Reader.prototype._stat.call(me, currentStat) - }) -} - -LinkReader.prototype._read = function () { - var me = this - if (me._paused) return - // basically just a no-op, since we got all the info we need - // from the _stat method - if (!me._ended) { - me.emit("end") - me.emit("close") - me._ended = true - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-writer.js deleted file mode 100644 index c652eb3..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/link-writer.js +++ /dev/null @@ -1,95 +0,0 @@ - -module.exports = LinkWriter - -var fs = require("../../graceful-fs/graceful-fs.js") - , Writer = require("./writer.js") - , inherits = require("../../inherits/inherits.js") - , path = require("path") - , rimraf = require("../../rimraf/rimraf.js") - -inherits(LinkWriter, Writer) - -function LinkWriter (props) { - var me = this - if (!(me instanceof LinkWriter)) throw new Error( - "LinkWriter must be called as constructor.") - - // should already be established as a Link type - if (!((props.type === "Link" && props.Link) || - (props.type === "SymbolicLink" && props.SymbolicLink))) { - throw new Error("Non-link type "+ props.type) - } - - if (props.linkpath === "") props.linkpath = "." - if (!props.linkpath) { - me.error("Need linkpath property to create " + props.type) - } - - Writer.call(this, props) -} - -LinkWriter.prototype._create = function () { - // console.error(" LW _create") - var me = this - , hard = me.type === "Link" || process.platform === "win32" - , link = hard ? "link" : "symlink" - , lp = hard ? path.resolve(me.dirname, me.linkpath) : me.linkpath - - // can only change the link path by clobbering - // For hard links, let's just assume that's always the case, since - // there's no good way to read them if we don't already know. - if (hard) return clobber(me, lp, link) - - fs.readlink(me._path, function (er, p) { - // only skip creation if it's exactly the same link - if (p && p === lp) return finish(me) - clobber(me, lp, link) - }) -} - -function clobber (me, lp, link) { - rimraf(me._path, function (er) { - if (er) return me.error(er) - create(me, lp, link) - }) -} - -function create (me, lp, link) { - fs[link](lp, me._path, function (er) { - // if this is a hard link, and we're in the process of writing out a - // directory, it's very possible that the thing we're linking to - // doesn't exist yet (especially if it was intended as a symlink), - // so swallow ENOENT errors here and just soldier in. - // Additionally, an EPERM or EACCES can happen on win32 if it's trying - // to make a link to a directory. Again, just skip it. - // A better solution would be to have fs.symlink be supported on - // windows in some nice fashion. - if (er) { - if ((er.code === "ENOENT" || - er.code === "EACCES" || - er.code === "EPERM" ) && process.platform === "win32") { - me.ready = true - me.emit("ready") - me.emit("end") - me.emit("close") - me.end = me._finish = function () {} - } else return me.error(er) - } - finish(me) - }) -} - -function finish (me) { - me.ready = true - me.emit("ready") - if (me._ended && !me._finished) me._finish() -} - -LinkWriter.prototype.end = function () { - // console.error("LW finish in end") - this._ended = true - if (this.ready) { - this._finished = true - this._finish() - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-reader.js deleted file mode 100644 index a51ebdf..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-reader.js +++ /dev/null @@ -1,93 +0,0 @@ -// A reader for when we don't yet know what kind of thing -// the thing is. - -module.exports = ProxyReader - -var Reader = require("./reader.js") - , getType = require("./get-type.js") - , inherits = require("../../inherits/inherits.js") - , fs = require("../../graceful-fs/graceful-fs.js") - -inherits(ProxyReader, Reader) - -function ProxyReader (props) { - var me = this - if (!(me instanceof ProxyReader)) throw new Error( - "ProxyReader must be called as constructor.") - - me.props = props - me._buffer = [] - me.ready = false - - Reader.call(me, props) -} - -ProxyReader.prototype._stat = function () { - var me = this - , props = me.props - // stat the thing to see what the proxy should be. - , stat = props.follow ? "stat" : "lstat" - - fs[stat](props.path, function (er, current) { - var type - if (er || !current) { - type = "File" - } else { - type = getType(current) - } - - props[type] = true - props.type = me.type = type - - me._old = current - me._addProxy(Reader(props, current)) - }) -} - -ProxyReader.prototype._addProxy = function (proxy) { - var me = this - if (me._proxyTarget) { - return me.error("proxy already set") - } - - me._proxyTarget = proxy - proxy._proxy = me - - ; [ "error" - , "data" - , "end" - , "close" - , "linkpath" - , "entry" - , "entryEnd" - , "child" - , "childEnd" - , "warn" - , "stat" - ].forEach(function (ev) { - // console.error("~~ proxy event", ev, me.path) - proxy.on(ev, me.emit.bind(me, ev)) - }) - - me.emit("proxy", proxy) - - proxy.on("ready", function () { - // console.error("~~ proxy is ready!", me.path) - me.ready = true - me.emit("ready") - }) - - var calls = me._buffer - me._buffer.length = 0 - calls.forEach(function (c) { - proxy[c[0]].apply(proxy, c[1]) - }) -} - -ProxyReader.prototype.pause = function () { - return this._proxyTarget ? this._proxyTarget.pause() : false -} - -ProxyReader.prototype.resume = function () { - return this._proxyTarget ? this._proxyTarget.resume() : false -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-writer.js deleted file mode 100644 index 2e6bae4..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/proxy-writer.js +++ /dev/null @@ -1,109 +0,0 @@ -// A writer for when we don't know what kind of thing -// the thing is. That is, it's not explicitly set, -// so we're going to make it whatever the thing already -// is, or "File" -// -// Until then, collect all events. - -module.exports = ProxyWriter - -var Writer = require("./writer.js") - , getType = require("./get-type.js") - , inherits = require("../../inherits/inherits.js") - , collect = require("./collect.js") - , fs = require("fs") - -inherits(ProxyWriter, Writer) - -function ProxyWriter (props) { - var me = this - if (!(me instanceof ProxyWriter)) throw new Error( - "ProxyWriter must be called as constructor.") - - me.props = props - me._needDrain = false - - Writer.call(me, props) -} - -ProxyWriter.prototype._stat = function () { - var me = this - , props = me.props - // stat the thing to see what the proxy should be. - , stat = props.follow ? "stat" : "lstat" - - fs[stat](props.path, function (er, current) { - var type - if (er || !current) { - type = "File" - } else { - type = getType(current) - } - - props[type] = true - props.type = me.type = type - - me._old = current - me._addProxy(Writer(props, current)) - }) -} - -ProxyWriter.prototype._addProxy = function (proxy) { - // console.error("~~ set proxy", this.path) - var me = this - if (me._proxy) { - return me.error("proxy already set") - } - - me._proxy = proxy - ; [ "ready" - , "error" - , "close" - , "pipe" - , "drain" - , "warn" - ].forEach(function (ev) { - proxy.on(ev, me.emit.bind(me, ev)) - }) - - me.emit("proxy", proxy) - - var calls = me._buffer - calls.forEach(function (c) { - // console.error("~~ ~~ proxy buffered call", c[0], c[1]) - proxy[c[0]].call(proxy, c[1]) - }) - me._buffer.length = 0 - if (me._needsDrain) me.emit("drain") -} - -ProxyWriter.prototype.add = function (entry) { - // console.error("~~ proxy add") - collect(entry) - - if (!this._proxy) { - this._buffer.push(["add", [entry]]) - this._needDrain = true - return false - } - return this._proxy.add(entry) -} - -ProxyWriter.prototype.write = function (c) { - // console.error("~~ proxy write") - if (!this._proxy) { - this._buffer.push(["write", [c]]) - this._needDrain = true - return false - } - return this._proxy.write(c) -} - -ProxyWriter.prototype.end = function (c) { - // console.error("~~ proxy end") - if (!this._proxy) { - this._buffer.push(["end", c]) - return false - } - return this._proxy.end(c) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/reader.js deleted file mode 100644 index 42a8701..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/reader.js +++ /dev/null @@ -1,258 +0,0 @@ - -module.exports = Reader - -var fs = require("../../graceful-fs/graceful-fs.js") - , Stream = require("stream").Stream - , inherits = require("../../inherits/inherits.js") - , path = require("path") - , getType = require("./get-type.js") - , hardLinks = Reader.hardLinks = {} - , Abstract = require("./abstract.js") - -// Must do this *before* loading the child classes -inherits(Reader, Abstract) - -var DirReader = require("./dir-reader.js") - , FileReader = require("./file-reader.js") - , LinkReader = require("./link-reader.js") - , SocketReader = require("./socket-reader.js") - , ProxyReader = require("./proxy-reader.js") - -function Reader (props, currentStat) { - var me = this - if (!(me instanceof Reader)) return new Reader(props, currentStat) - - if (typeof props === "string") { - props = { path: props } - } - - if (!props.path) { - me.error("Must provide a path", null, true) - } - - // polymorphism. - // call fstream.Reader(dir) to get a DirReader object, etc. - // Note that, unlike in the Writer case, ProxyReader is going - // to be the *normal* state of affairs, since we rarely know - // the type of a file prior to reading it. - - - var type - , ClassType - - if (props.type && typeof props.type === "function") { - type = props.type - ClassType = type - } else { - type = getType(props) - ClassType = Reader - } - - if (currentStat && !type) { - type = getType(currentStat) - props[type] = true - props.type = type - } - - switch (type) { - case "Directory": - ClassType = DirReader - break - - case "Link": - // XXX hard links are just files. - // However, it would be good to keep track of files' dev+inode - // and nlink values, and create a HardLinkReader that emits - // a linkpath value of the original copy, so that the tar - // writer can preserve them. - // ClassType = HardLinkReader - // break - - case "File": - ClassType = FileReader - break - - case "SymbolicLink": - ClassType = LinkReader - break - - case "Socket": - ClassType = SocketReader - break - - case null: - ClassType = ProxyReader - break - } - - if (!(me instanceof ClassType)) { - return new ClassType(props) - } - - Abstract.call(me) - - me.readable = true - me.writable = false - - me.type = type - me.props = props - me.depth = props.depth = props.depth || 0 - me.parent = props.parent || null - me.root = props.root || (props.parent && props.parent.root) || me - - me._path = me.path = path.resolve(props.path) - if (process.platform === "win32") { - me.path = me._path = me.path.replace(/\?/g, "_") - if (me._path.length >= 260) { - // how DOES one create files on the moon? - // if the path has spaces in it, then UNC will fail. - me._swallowErrors = true - //if (me._path.indexOf(" ") === -1) { - me._path = "\\\\?\\" + me.path.replace(/\//g, "\\") - //} - } - } - me.basename = props.basename = path.basename(me.path) - me.dirname = props.dirname = path.dirname(me.path) - - // these have served their purpose, and are now just noisy clutter - props.parent = props.root = null - - // console.error("\n\n\n%s setting size to", props.path, props.size) - me.size = props.size - me.filter = typeof props.filter === "function" ? props.filter : null - if (props.sort === "alpha") props.sort = alphasort - - // start the ball rolling. - // this will stat the thing, and then call me._read() - // to start reading whatever it is. - // console.error("calling stat", props.path, currentStat) - me._stat(currentStat) -} - -function alphasort (a, b) { - return a === b ? 0 - : a.toLowerCase() > b.toLowerCase() ? 1 - : a.toLowerCase() < b.toLowerCase() ? -1 - : a > b ? 1 - : -1 -} - -Reader.prototype._stat = function (currentStat) { - var me = this - , props = me.props - , stat = props.follow ? "stat" : "lstat" - - // console.error("Reader._stat", me._path, currentStat) - if (currentStat) process.nextTick(statCb.bind(null, null, currentStat)) - else fs[stat](me._path, statCb) - - - function statCb (er, props_) { - // console.error("Reader._stat, statCb", me._path, props_, props_.nlink) - if (er) return me.error(er) - - Object.keys(props_).forEach(function (k) { - props[k] = props_[k] - }) - - // if it's not the expected size, then abort here. - if (undefined !== me.size && props.size !== me.size) { - return me.error("incorrect size") - } - me.size = props.size - - var type = getType(props) - // special little thing for handling hardlinks. - if (type !== "Directory" && props.nlink && props.nlink > 1) { - var k = props.dev + ":" + props.ino - // console.error("Reader has nlink", me._path, k) - if (hardLinks[k] === me._path || !hardLinks[k]) hardLinks[k] = me._path - else { - // switch into hardlink mode. - type = me.type = me.props.type = "Link" - me.Link = me.props.Link = true - me.linkpath = me.props.linkpath = hardLinks[k] - // console.error("Hardlink detected, switching mode", me._path, me.linkpath) - // Setting __proto__ would arguably be the "correct" - // approach here, but that just seems too wrong. - me._stat = me._read = LinkReader.prototype._read - } - } - - if (me.type && me.type !== type) { - me.error("Unexpected type: " + type) - } - - // if the filter doesn't pass, then just skip over this one. - // still have to emit end so that dir-walking can move on. - if (me.filter) { - var who = me._proxy || me - // special handling for ProxyReaders - if (!me.filter.call(who, who, props)) { - if (!me._disowned) { - me.abort() - me.emit("end") - me.emit("close") - } - return - } - } - - // last chance to abort or disown before the flow starts! - var events = ["_stat", "stat", "ready"] - var e = 0 - ;(function go () { - if (me._aborted) { - me.emit("end") - me.emit("close") - return - } - - if (me._paused) { - me.once("resume", go) - return - } - - var ev = events[e ++] - if (!ev) return me._read() - me.emit(ev, props) - go() - })() - } -} - -Reader.prototype.pipe = function (dest, opts) { - var me = this - if (typeof dest.add === "function") { - // piping to a multi-compatible, and we've got directory entries. - me.on("entry", function (entry) { - var ret = dest.add(entry) - if (false === ret) { - me.pause() - } - }) - } - - // console.error("R Pipe apply Stream Pipe") - return Stream.prototype.pipe.apply(this, arguments) -} - -Reader.prototype.pause = function (who) { - this._paused = true - who = who || this - this.emit("pause", who) - if (this._stream) this._stream.pause(who) -} - -Reader.prototype.resume = function (who) { - this._paused = false - who = who || this - this.emit("resume", who) - if (this._stream) this._stream.resume(who) - this._read() -} - -Reader.prototype._read = function () { - this.error("Cannot read unknown type: "+this.type) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/socket-reader.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/socket-reader.js deleted file mode 100644 index 1de8ce9..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/socket-reader.js +++ /dev/null @@ -1,38 +0,0 @@ -// Just get the stats, and then don't do anything. -// You can't really "read" from a socket. You "connect" to it. -// Mostly, this is here so that reading a dir with a socket in it -// doesn't blow up. - -module.exports = SocketReader - -var fs = require("../../graceful-fs/graceful-fs.js") - , fstream = require("../fstream.js") - , inherits = require("../../inherits/inherits.js") - , mkdir = require("../../mkdirp") - , Reader = require("./reader.js") - -inherits(SocketReader, Reader) - -function SocketReader (props) { - var me = this - if (!(me instanceof SocketReader)) throw new Error( - "SocketReader must be called as constructor.") - - if (!(props.type === "Socket" && props.Socket)) { - throw new Error("Non-socket type "+ props.type) - } - - Reader.call(me, props) -} - -SocketReader.prototype._read = function () { - var me = this - if (me._paused) return - // basically just a no-op, since we got all the info we have - // from the _stat method - if (!me._ended) { - me.emit("end") - me.emit("close") - me._ended = true - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/writer.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/writer.js deleted file mode 100644 index decc20e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/fstream/lib/writer.js +++ /dev/null @@ -1,389 +0,0 @@ - -module.exports = Writer - -var fs = require("../../graceful-fs/graceful-fs.js") - , inherits = require("../../inherits/inherits.js") - , rimraf = require("../../rimraf/rimraf.js") - , mkdir = require("../../mkdirp") - , path = require("path") - , umask = process.platform === "win32" ? 0 : process.umask() - , getType = require("./get-type.js") - , Abstract = require("./abstract.js") - -// Must do this *before* loading the child classes -inherits(Writer, Abstract) - -Writer.dirmode = 0777 & (~umask) -Writer.filemode = 0666 & (~umask) - -var DirWriter = require("./dir-writer.js") - , LinkWriter = require("./link-writer.js") - , FileWriter = require("./file-writer.js") - , ProxyWriter = require("./proxy-writer.js") - -// props is the desired state. current is optionally the current stat, -// provided here so that subclasses can avoid statting the target -// more than necessary. -function Writer (props, current) { - var me = this - - if (typeof props === "string") { - props = { path: props } - } - - if (!props.path) me.error("Must provide a path", null, true) - - // polymorphism. - // call fstream.Writer(dir) to get a DirWriter object, etc. - var type = getType(props) - , ClassType = Writer - - switch (type) { - case "Directory": - ClassType = DirWriter - break - case "File": - ClassType = FileWriter - break - case "Link": - case "SymbolicLink": - ClassType = LinkWriter - break - case null: - // Don't know yet what type to create, so we wrap in a proxy. - ClassType = ProxyWriter - break - } - - if (!(me instanceof ClassType)) return new ClassType(props) - - // now get down to business. - - Abstract.call(me) - - // props is what we want to set. - // set some convenience properties as well. - me.type = props.type - me.props = props - me.depth = props.depth || 0 - me.clobber = false === props.clobber ? props.clobber : true - me.parent = props.parent || null - me.root = props.root || (props.parent && props.parent.root) || me - - me._path = me.path = path.resolve(props.path) - if (process.platform === "win32") { - me.path = me._path = me.path.replace(/\?/g, "_") - if (me._path.length >= 260) { - me._swallowErrors = true - me._path = "\\\\?\\" + me.path.replace(/\//g, "\\") - } - } - me.basename = path.basename(props.path) - me.dirname = path.dirname(props.path) - me.linkpath = props.linkpath || null - - props.parent = props.root = null - - // console.error("\n\n\n%s setting size to", props.path, props.size) - me.size = props.size - - if (typeof props.mode === "string") { - props.mode = parseInt(props.mode, 8) - } - - me.readable = false - me.writable = true - - // buffer until ready, or while handling another entry - me._buffer = [] - me.ready = false - - me.filter = typeof props.filter === "function" ? props.filter: null - - // start the ball rolling. - // this checks what's there already, and then calls - // me._create() to call the impl-specific creation stuff. - me._stat(current) -} - -// Calling this means that it's something we can't create. -// Just assert that it's already there, otherwise raise a warning. -Writer.prototype._create = function () { - var me = this - fs[me.props.follow ? "stat" : "lstat"](me._path, function (er, current) { - if (er) { - return me.warn("Cannot create " + me._path + "\n" + - "Unsupported type: "+me.type, "ENOTSUP") - } - me._finish() - }) -} - -Writer.prototype._stat = function (current) { - var me = this - , props = me.props - , stat = props.follow ? "stat" : "lstat" - , who = me._proxy || me - - if (current) statCb(null, current) - else fs[stat](me._path, statCb) - - function statCb (er, current) { - if (me.filter && !me.filter.call(who, who, current)) { - me._aborted = true - me.emit("end") - me.emit("close") - return - } - - // if it's not there, great. We'll just create it. - // if it is there, then we'll need to change whatever differs - if (er || !current) { - return create(me) - } - - me._old = current - var currentType = getType(current) - - // if it's a type change, then we need to clobber or error. - // if it's not a type change, then let the impl take care of it. - if (currentType !== me.type) { - return rimraf(me._path, function (er) { - if (er) return me.error(er) - me._old = null - create(me) - }) - } - - // otherwise, just handle in the app-specific way - // this creates a fs.WriteStream, or mkdir's, or whatever - create(me) - } -} - -function create (me) { - // console.error("W create", me._path, Writer.dirmode) - - // XXX Need to clobber non-dirs that are in the way, - // unless { clobber: false } in the props. - mkdir(path.dirname(me._path), Writer.dirmode, function (er, made) { - // console.error("W created", path.dirname(me._path), er) - if (er) return me.error(er) - - // later on, we have to set the mode and owner for these - me._madeDir = made - return me._create() - }) -} - -function endChmod (me, want, current, path, cb) { - var wantMode = want.mode - , chmod = want.follow || me.type !== "SymbolicLink" - ? "chmod" : "lchmod" - - if (!fs[chmod]) return cb() - if (typeof wantMode !== "number") return cb() - - var curMode = current.mode & 0777 - wantMode = wantMode & 0777 - if (wantMode === curMode) return cb() - - fs[chmod](path, wantMode, cb) -} - - -function endChown (me, want, current, path, cb) { - // Don't even try it unless root. Too easy to EPERM. - if (process.platform === "win32") return cb() - if (!process.getuid || !process.getuid() === 0) return cb() - if (typeof want.uid !== "number" && - typeof want.gid !== "number" ) return cb() - - if (current.uid === want.uid && - current.gid === want.gid) return cb() - - var chown = (me.props.follow || me.type !== "SymbolicLink") - ? "chown" : "lchown" - if (!fs[chown]) return cb() - - if (typeof want.uid !== "number") want.uid = current.uid - if (typeof want.gid !== "number") want.gid = current.gid - - fs[chown](path, want.uid, want.gid, cb) -} - -function endUtimes (me, want, current, path, cb) { - if (!fs.utimes || process.platform === "win32") return cb() - - var utimes = (want.follow || me.type !== "SymbolicLink") - ? "utimes" : "lutimes" - - if (utimes === "lutimes" && !fs[utimes]) { - utimes = "utimes" - } - - if (!fs[utimes]) return cb() - - var curA = current.atime - , curM = current.mtime - , meA = want.atime - , meM = want.mtime - - if (meA === undefined) meA = curA - if (meM === undefined) meM = curM - - if (!isDate(meA)) meA = new Date(meA) - if (!isDate(meM)) meA = new Date(meM) - - if (meA.getTime() === curA.getTime() && - meM.getTime() === curM.getTime()) return cb() - - fs[utimes](path, meA, meM, cb) -} - - -// XXX This function is beastly. Break it up! -Writer.prototype._finish = function () { - var me = this - - // console.error(" W Finish", me._path, me.size) - - // set up all the things. - // At this point, we're already done writing whatever we've gotta write, - // adding files to the dir, etc. - var todo = 0 - var errState = null - var done = false - - if (me._old) { - // the times will almost *certainly* have changed. - // adds the utimes syscall, but remove another stat. - me._old.atime = new Date(0) - me._old.mtime = new Date(0) - // console.error(" W Finish Stale Stat", me._path, me.size) - setProps(me._old) - } else { - var stat = me.props.follow ? "stat" : "lstat" - // console.error(" W Finish Stating", me._path, me.size) - fs[stat](me._path, function (er, current) { - // console.error(" W Finish Stated", me._path, me.size, current) - if (er) { - // if we're in the process of writing out a - // directory, it's very possible that the thing we're linking to - // doesn't exist yet (especially if it was intended as a symlink), - // so swallow ENOENT errors here and just soldier on. - if (er.code === "ENOENT" && - (me.type === "Link" || me.type === "SymbolicLink") && - process.platform === "win32") { - me.ready = true - me.emit("ready") - me.emit("end") - me.emit("close") - me.end = me._finish = function () {} - return - } else return me.error(er) - } - setProps(me._old = current) - }) - } - - return - - function setProps (current) { - endChmod(me, me.props, current, me._path, next("chmod")) - endChown(me, me.props, current, me._path, next("chown")) - endUtimes(me, me.props, current, me._path, next("chown")) - } - - function next (what) { - todo ++ - return function (er) { - // console.error(" W Finish", what, todo) - if (errState) return - if (er) { - er.fstream_finish_call = what - return me.error(errState = er) - } - if (--todo > 0) return - if (done) return - done = true - - // we may still need to set the mode/etc. on some parent dirs - // that were created previously. delay end/close until then. - if (!me._madeDir) return end() - else endMadeDir(me, me._path, end) - - function end (er) { - if (er) { - er.fstream_finish_call = "setupMadeDir" - return me.error(er) - } - // all the props have been set, so we're completely done. - me.emit("end") - me.emit("close") - } - } - } -} - -function endMadeDir (me, p, cb) { - var made = me._madeDir - // everything *between* made and path.dirname(me._path) - // needs to be set up. Note that this may just be one dir. - var d = path.dirname(p) - - endMadeDir_(me, d, function (er) { - if (er) return cb(er) - if (d === made) { - return cb() - } - endMadeDir(me, d, cb) - }) -} - -function endMadeDir_ (me, p, cb) { - var dirProps = {} - Object.keys(me.props).forEach(function (k) { - dirProps[k] = me.props[k] - - // only make non-readable dirs if explicitly requested. - if (k === "mode" && me.type !== "Directory") { - dirProps[k] = dirProps[k] | 0111 - } - }) - - var todo = 3 - , errState = null - fs.stat(p, function (er, current) { - if (er) return cb(errState = er) - endChmod(me, dirProps, current, p, next) - endChown(me, dirProps, current, p, next) - endUtimes(me, dirProps, current, p, next) - }) - - function next (er) { - if (errState) return - if (er) return cb(errState = er) - if (-- todo === 0) return cb() - } -} - -Writer.prototype.pipe = function () { - this.error("Can't pipe from writable stream") -} - -Writer.prototype.add = function () { - this.error("Cannot add to non-Directory type") -} - -Writer.prototype.write = function () { - return true -} - -function objectToString (d) { - return Object.prototype.toString.call(d) -} - -function isDate(d) { - return typeof d === 'object' && objectToString(d) === '[object Date]'; -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md deleted file mode 100644 index 7d2e681..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Just like node's `fs` module, but it does an incremental back-off when -EMFILE is encountered. - -Useful in asynchronous situations where one needs to try to open lots -and lots of files. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/graceful-fs.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/graceful-fs.js deleted file mode 100644 index be9951e..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/graceful-fs/graceful-fs.js +++ /dev/null @@ -1,312 +0,0 @@ -// this keeps a queue of opened file descriptors, and will make -// fs operations wait until some have closed before trying to open more. - -var fs = require("fs") - -// there is such a thing as TOO graceful. -if (fs.open === gracefulOpen) return - -var queue = [] - , constants = require("constants") - -exports = module.exports = fs -fs._curOpen = 0 - -fs.MIN_MAX_OPEN = 64 -fs.MAX_OPEN = 1024 - -var originalOpen = fs.open - , originalOpenSync = fs.openSync - , originalClose = fs.close - , originalCloseSync = fs.closeSync - - -// prevent EMFILE errors -function OpenReq (path, flags, mode, cb) { - this.path = path - this.flags = flags - this.mode = mode - this.cb = cb -} - -function noop () {} - -fs.open = gracefulOpen - -function gracefulOpen (path, flags, mode, cb) { - if (typeof mode === "function") cb = mode, mode = null - if (typeof cb !== "function") cb = noop - - if (fs._curOpen >= fs.MAX_OPEN) { - queue.push(new OpenReq(path, flags, mode, cb)) - setTimeout(flush) - return - } - open(path, flags, mode, function (er, fd) { - if (er && er.code === "EMFILE" && fs._curOpen > fs.MIN_MAX_OPEN) { - // that was too many. reduce max, get back in queue. - // this should only happen once in a great while, and only - // if the ulimit -n is set lower than 1024. - fs.MAX_OPEN = fs._curOpen - 1 - return fs.open(path, flags, mode, cb) - } - cb(er, fd) - }) -} - -function open (path, flags, mode, cb) { - cb = cb || noop - fs._curOpen ++ - originalOpen.call(fs, path, flags, mode, function (er, fd) { - if (er) onclose() - cb(er, fd) - }) -} - -fs.openSync = function (path, flags, mode) { - var ret - ret = originalOpenSync.call(fs, path, flags, mode) - fs._curOpen ++ - return ret -} - -function onclose () { - fs._curOpen -- - flush() -} - -function flush () { - while (fs._curOpen < fs.MAX_OPEN) { - var req = queue.shift() - if (!req) return - open(req.path, req.flags || "r", req.mode || 0777, req.cb) - } -} - -fs.close = function (fd, cb) { - cb = cb || noop - originalClose.call(fs, fd, function (er) { - onclose() - cb(er) - }) -} - -fs.closeSync = function (fd) { - onclose() - return originalCloseSync.call(fs, fd) -} - - -// (re-)implement some things that are known busted or missing. - -var constants = require("constants") - -// lchmod, broken prior to 0.6.2 -// back-port the fix here. -if (constants.hasOwnProperty('O_SYMLINK') && - process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { - fs.lchmod = function (path, mode, callback) { - callback = callback || noop - fs.open( path - , constants.O_WRONLY | constants.O_SYMLINK - , mode - , function (err, fd) { - if (err) { - callback(err) - return - } - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - fs.fchmod(fd, mode, function (err) { - fs.close(fd, function(err2) { - callback(err || err2) - }) - }) - }) - } - - fs.lchmodSync = function (path, mode) { - var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) - - // prefer to return the chmod error, if one occurs, - // but still try to close, and report closing errors if they occur. - var err, err2 - try { - var ret = fs.fchmodSync(fd, mode) - } catch (er) { - err = er - } - try { - fs.closeSync(fd) - } catch (er) { - err2 = er - } - if (err || err2) throw (err || err2) - return ret - } -} - - -// lutimes implementation, or no-op -if (!fs.lutimes) { - if (constants.hasOwnProperty("O_SYMLINK")) { - fs.lutimes = function (path, at, mt, cb) { - fs.open(path, constants.O_SYMLINK, function (er, fd) { - cb = cb || noop - if (er) return cb(er) - fs.futimes(fd, at, mt, function (er) { - fs.close(fd, function (er2) { - return cb(er || er2) - }) - }) - }) - } - - fs.lutimesSync = function (path, at, mt) { - var fd = fs.openSync(path, constants.O_SYMLINK) - , err - , err2 - , ret - - try { - var ret = fs.futimesSync(fd, at, mt) - } catch (er) { - err = er - } - try { - fs.closeSync(fd) - } catch (er) { - err2 = er - } - if (err || err2) throw (err || err2) - return ret - } - - } else if (fs.utimensat && constants.hasOwnProperty("AT_SYMLINK_NOFOLLOW")) { - // maybe utimensat will be bound soonish? - fs.lutimes = function (path, at, mt, cb) { - fs.utimensat(path, at, mt, constants.AT_SYMLINK_NOFOLLOW, cb) - } - - fs.lutimesSync = function (path, at, mt) { - return fs.utimensatSync(path, at, mt, constants.AT_SYMLINK_NOFOLLOW) - } - - } else { - fs.lutimes = function (_a, _b, _c, cb) { process.nextTick(cb) } - fs.lutimesSync = function () {} - } -} - - -// https://github.com/isaacs/node-graceful-fs/issues/4 -// Chown should not fail on einval or eperm if non-root. - -fs.chown = chownFix(fs.chown) -fs.fchown = chownFix(fs.fchown) -fs.lchown = chownFix(fs.lchown) - -fs.chownSync = chownFixSync(fs.chownSync) -fs.fchownSync = chownFixSync(fs.fchownSync) -fs.lchownSync = chownFixSync(fs.lchownSync) - -function chownFix (orig) { - if (!orig) return orig - return function (target, uid, gid, cb) { - return orig.call(fs, target, uid, gid, function (er, res) { - if (chownErOk(er)) er = null - cb(er, res) - }) - } -} - -function chownFixSync (orig) { - if (!orig) return orig - return function (target, uid, gid) { - try { - return orig.call(fs, target, uid, gid) - } catch (er) { - if (!chownErOk(er)) throw er - } - } -} - -function chownErOk (er) { - // if there's no getuid, or if getuid() is something other than 0, - // and the error is EINVAL or EPERM, then just ignore it. - // This specific case is a silent failure in cp, install, tar, - // and most other unix tools that manage permissions. - // When running as root, or if other types of errors are encountered, - // then it's strict. - if (!er || (!process.getuid || process.getuid() !== 0) - && (er.code === "EINVAL" || er.code === "EPERM")) return true -} - - -// if lchmod/lchown do not exist, then make them no-ops -if (!fs.lchmod) { - fs.lchmod = function (path, mode, cb) { - process.nextTick(cb) - } - fs.lchmodSync = function () {} -} -if (!fs.lchown) { - fs.lchown = function (path, uid, gid, cb) { - process.nextTick(cb) - } - fs.lchownSync = function () {} -} - - - -// on Windows, A/V software can lock the directory, causing this -// to fail with an EACCES or EPERM if the directory contains newly -// created files. Try again on failure, for up to 1 second. -if (process.platform === "win32") { - var rename_ = fs.rename - fs.rename = function rename (from, to, cb) { - var start = Date.now() - rename_(from, to, function CB (er) { - if (er - && (er.code === "EACCES" || er.code === "EPERM") - && Date.now() - start < 1000) { - return rename_(from, to, CB) - } - cb(er) - }) - } -} - - -// if read() returns EAGAIN, then just try it again. -var read = fs.read -fs.read = function (fd, buffer, offset, length, position, callback_) { - var callback - if (callback_ && typeof callback_ === 'function') { - var eagCounter = 0 - callback = function (er, _, __) { - if (er && er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - return read.call(fs, fd, buffer, offset, length, position, callback) - } - callback_.apply(this, arguments) - } - } - return read.call(fs, fd, buffer, offset, length, position, callback) -} - -var readSync = fs.readSync -fs.readSync = function (fd, buffer, offset, length, position) { - var eagCounter = 0 - while (true) { - try { - return readSync.call(fs, fd, buffer, offset, length, position) - } catch (er) { - if (er.code === 'EAGAIN' && eagCounter < 10) { - eagCounter ++ - continue - } - throw er - } - } -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/README.md deleted file mode 100644 index b2beaed..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/README.md +++ /dev/null @@ -1,51 +0,0 @@ -A dead simple way to do inheritance in JS. - - var inherits = require("inherits") - - function Animal () { - this.alive = true - } - Animal.prototype.say = function (what) { - console.log(what) - } - - inherits(Dog, Animal) - function Dog () { - Dog.super.apply(this) - } - Dog.prototype.sniff = function () { - this.say("sniff sniff") - } - Dog.prototype.bark = function () { - this.say("woof woof") - } - - inherits(Chihuahua, Dog) - function Chihuahua () { - Chihuahua.super.apply(this) - } - Chihuahua.prototype.bark = function () { - this.say("yip yip") - } - - // also works - function Cat () { - Cat.super.apply(this) - } - Cat.prototype.hiss = function () { - this.say("CHSKKSS!!") - } - inherits(Cat, Animal, { - meow: function () { this.say("miao miao") } - }) - Cat.prototype.purr = function () { - this.say("purr purr") - } - - - var c = new Chihuahua - assert(c instanceof Chihuahua) - assert(c instanceof Dog) - assert(c instanceof Animal) - -The actual function is laughably small. 10-lines small. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/inherits.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/inherits.js deleted file mode 100644 index 061b396..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/inherits/inherits.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = inherits - -function inherits (c, p, proto) { - proto = proto || {} - var e = {} - ;[c.prototype, proto].forEach(function (s) { - Object.getOwnPropertyNames(s).forEach(function (k) { - e[k] = Object.getOwnPropertyDescriptor(s, k) - }) - }) - c.prototype = Object.create(p.prototype, e) - c.super = p -} - -//function Child () { -// Child.super.call(this) -// console.error([this -// ,this.constructor -// ,this.constructor === Child -// ,this.constructor.super === Parent -// ,Object.getPrototypeOf(this) === Child.prototype -// ,Object.getPrototypeOf(Object.getPrototypeOf(this)) -// === Parent.prototype -// ,this instanceof Child -// ,this instanceof Parent]) -//} -//function Parent () {} -//inherits(Child, Parent) -//new Child diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE deleted file mode 100644 index 432d1ae..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2010 James Halliday (mail@substack.net) - -This project is free software released under the MIT/X11 license: - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown deleted file mode 100644 index 40de04f..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/README.markdown +++ /dev/null @@ -1,61 +0,0 @@ -mkdirp -====== - -Like `mkdir -p`, but in node.js! - -[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp) - -example -======= - -pow.js ------- - var mkdirp = require('mkdirp'); - - mkdirp('/tmp/foo/bar/baz', function (err) { - if (err) console.error(err) - else console.log('pow!') - }); - -Output - pow! - -And now /tmp/foo/bar/baz exists, huzzah! - -methods -======= - -var mkdirp = require('mkdirp'); - -mkdirp(dir, mode, cb) ---------------------- - -Create a new directory and any necessary subdirectories at `dir` with octal -permission string `mode`. - -If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -`cb(err, made)` fires with the error or the first directory `made` -that had to be created, if any. - -mkdirp.sync(dir, mode) ----------------------- - -Synchronously create a new directory and any necessary subdirectories at `dir` -with octal permission string `mode`. - -If `mode` isn't specified, it defaults to `0777 & (~process.umask())`. - -Returns the first directory that had to be created, if any. - -install -======= - -With [npm](http://npmjs.org) do: - - npm install mkdirp - -license -======= - -MIT/X11 diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/index.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/index.js deleted file mode 100644 index fda6de8..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/mkdirp/index.js +++ /dev/null @@ -1,82 +0,0 @@ -var path = require('path'); -var fs = require('fs'); - -module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP; - -function mkdirP (p, mode, f, made) { - if (typeof mode === 'function' || mode === undefined) { - f = mode; - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - var cb = f || function () {}; - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - fs.mkdir(p, mode, function (er) { - if (!er) { - made = made || p; - return cb(null, made); - } - switch (er.code) { - case 'ENOENT': - mkdirP(path.dirname(p), mode, function (er, made) { - if (er) cb(er, made); - else mkdirP(p, mode, cb, made); - }); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - fs.stat(p, function (er2, stat) { - // if the stat fails, then that's super weird. - // let the original error be the failure reason. - if (er2 || !stat.isDirectory()) cb(er, made) - else cb(null, made); - }); - break; - } - }); -} - -mkdirP.sync = function sync (p, mode, made) { - if (mode === undefined) { - mode = 0777 & (~process.umask()); - } - if (!made) made = null; - - if (typeof mode === 'string') mode = parseInt(mode, 8); - p = path.resolve(p); - - try { - fs.mkdirSync(p, mode); - made = made || p; - } - catch (err0) { - switch (err0.code) { - case 'ENOENT' : - made = sync(path.dirname(p), mode, made); - sync(p, mode, made); - break; - - // In the case of any other error, just see if there's a dir - // there already. If so, then hooray! If not, then something - // is borked. - default: - var stat; - try { - stat = fs.statSync(p); - } - catch (err1) { - throw err0; - } - if (!stat.isDirectory()) throw err0; - break; - } - } - - return made; -}; diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS deleted file mode 100644 index 247b754..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -# Authors sorted by whether or not they're me. -Isaac Z. Schlueter (http://blog.izs.me) -Wayne Larsen (http://github.com/wvl) -ritch -Marcel Laverdet -Yosef Dinerstein diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE deleted file mode 100644 index 05a4010..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2009, 2010, 2011 Isaac Z. Schlueter. -All rights reserved. - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/README.md deleted file mode 100644 index 96ce9b2..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/README.md +++ /dev/null @@ -1,21 +0,0 @@ -A `rm -rf` for node. - -Install with `npm install rimraf`, or just drop rimraf.js somewhere. - -## API - -`rimraf(f, callback)` - -The callback will be called with an error if there is one. Certain -errors are handled for you: - -* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times - before giving up. -* `EMFILE` - If too many file descriptors get opened, rimraf will - patiently wait until more become available. - - -## rimraf.sync - -It can remove stuff synchronously, too. But that's not so good. Use -the async API. It's better. diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/rimraf.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/rimraf.js deleted file mode 100644 index bef2e06..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/tar/vendor/rimraf/rimraf.js +++ /dev/null @@ -1,161 +0,0 @@ -module.exports = rimraf -rimraf.sync = rimrafSync - -var path = require("path") - , fs - -try { - // optional dependency - fs = require("../../graceful-fs/graceful-fs.js") -} catch (er) { - fs = require("fs") -} - -var lstat = "lstat" -if (process.platform === "win32") { - // not reliable on windows prior to 0.7.9 - var v = process.version.replace(/^v/, '').split(/\.|-/).map(Number) - if (v[0] === 0 && (v[1] < 7 || v[1] == 7 && v[2] < 9)) { - lstat = "stat" - } -} -if (!fs[lstat]) lstat = "stat" -var lstatSync = lstat + "Sync" - -// for EMFILE handling -var timeout = 0 -exports.EMFILE_MAX = 1000 -exports.BUSYTRIES_MAX = 3 - -function rimraf (p, cb) { - - if (!cb) throw new Error("No callback passed to rimraf()") - - var busyTries = 0 - - rimraf_(p, function CB (er) { - if (er) { - if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) { - busyTries ++ - var time = busyTries * 100 - // try again, with the same exact callback as this one. - return setTimeout(function () { - rimraf_(p, CB) - }, time) - } - - // this one won't happen if graceful-fs is used. - if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) { - return setTimeout(function () { - rimraf_(p, CB) - }, timeout ++) - } - - // already gone - if (er.code === "ENOENT") er = null - } - - timeout = 0 - cb(er) - }) -} - -function rimraf_ (p, cb) { - fs[lstat](p, function (er, s) { - if (er) { - // already gone - if (er.code === "ENOENT") return cb() - // some other kind of error, permissions, etc. - return cb(er) - } - - return rm_(p, s, false, cb) - }) -} - - -var myGid = function myGid () { - var g = process.getuid && process.getgid() - myGid = function myGid () { return g } - return g -} - -var myUid = function myUid () { - var u = process.getuid && process.getuid() - myUid = function myUid () { return u } - return u -} - - -function writable (s) { - var mode = s.mode || 0777 - , uid = myUid() - , gid = myGid() - return (mode & 0002) - || (gid === s.gid && (mode & 0020)) - || (uid === s.uid && (mode & 0200)) -} - -function rm_ (p, s, didWritableCheck, cb) { - if (!didWritableCheck && !writable(s)) { - // make file writable - // user/group/world, doesn't matter at this point - // since it's about to get nuked. - return fs.chmod(p, s.mode | 0222, function (er) { - if (er) return cb(er) - rm_(p, s, true, cb) - }) - } - - if (!s.isDirectory()) { - return fs.unlink(p, cb) - } - - // directory - fs.readdir(p, function (er, files) { - if (er) return cb(er) - asyncForEach(files.map(function (f) { - return path.join(p, f) - }), function (file, cb) { - rimraf(file, cb) - }, function (er) { - if (er) return cb(er) - fs.rmdir(p, cb) - }) - }) -} - -function asyncForEach (list, fn, cb) { - if (!list.length) cb() - var c = list.length - , errState = null - list.forEach(function (item, i, list) { - fn(item, function (er) { - if (errState) return - if (er) return cb(errState = er) - if (-- c === 0) return cb() - }) - }) -} - -// this looks simpler, but it will fail with big directory trees, -// or on slow stupid awful cygwin filesystems -function rimrafSync (p) { - try { - var s = fs[lstatSync](p) - } catch (er) { - if (er.code === "ENOENT") return - throw er - } - - if (!writable(s)) { - fs.chmodSync(p, s.mode | 0222) - } - - if (!s.isDirectory()) return fs.unlinkSync(p) - - fs.readdirSync(p).forEach(function (f) { - rimrafSync(path.join(p, f)) - }) - fs.rmdirSync(p) -} diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/LICENSE b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/LICENSE deleted file mode 100644 index 61d28c0..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2009-2012 Jeremy Ashkenas, DocumentCloud - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/README.md b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/README.md deleted file mode 100644 index b1f3e50..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/README.md +++ /dev/null @@ -1,19 +0,0 @@ - __ - /\ \ __ - __ __ ___ \_\ \ __ _ __ ____ ___ ___ _ __ __ /\_\ ____ - /\ \/\ \ /' _ `\ /'_ \ /'__`\/\ __\/ ,__\ / ___\ / __`\/\ __\/'__`\ \/\ \ /',__\ - \ \ \_\ \/\ \/\ \/\ \ \ \/\ __/\ \ \//\__, `\/\ \__//\ \ \ \ \ \//\ __/ __ \ \ \/\__, `\ - \ \____/\ \_\ \_\ \___,_\ \____\\ \_\\/\____/\ \____\ \____/\ \_\\ \____\/\_\ _\ \ \/\____/ - \/___/ \/_/\/_/\/__,_ /\/____/ \/_/ \/___/ \/____/\/___/ \/_/ \/____/\/_//\ \_\ \/___/ - \ \____/ - \/___/ - -Underscore.js is a utility-belt library for JavaScript that provides -support for the usual functional suspects (each, map, reduce, filter...) -without extending any core JavaScript objects. - -For Docs, License, Tests, and pre-packed downloads, see: -http://underscorejs.org - -Many thanks to our contributors: -https://github.com/documentcloud/underscore/contributors diff --git a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/underscore.js b/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/underscore.js deleted file mode 100644 index e518514..0000000 --- a/node_modules/grunt-contrib-watch/node_modules/gaze/node_modules/lodash/vendor/underscore/underscore.js +++ /dev/null @@ -1,1204 +0,0 @@ -// Underscore.js 1.4.2 -// http://underscorejs.org -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore may be freely distributed under the MIT license. - -(function() { - - // Baseline setup - // -------------- - - // Establish the root object, `window` in the browser, or `global` on the server. - var root = this; - - // Save the previous value of the `_` variable. - var previousUnderscore = root._; - - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - - // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - - // Create quick reference variables for speed access to core prototypes. - var push = ArrayProto.push, - slice = ArrayProto.slice, - concat = ArrayProto.concat, - unshift = ArrayProto.unshift, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - - // All **ECMAScript 5** native function implementations that we hope to use - // are declared here. - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - - // Create a safe reference to the Underscore object for use below. - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - - // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in - // the browser, add `_` as a global object via a string identifier, - // for Closure Compiler "advanced" mode. - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root._ = _; - } - - // Current version. - _.VERSION = '1.4.2'; - - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - for (var key in obj) { - if (_.has(obj, key)) { - if (iterator.call(context, obj[key], key, obj) === breaker) return; - } - } - } - }; - - // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - return results; - }; - - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError('Reduce of empty array with no initial value'); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError('Reduce of empty array with no initial value'); - return memo; - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, iterator, context) { - var result; - any(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); - each(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, iterator, context) { - return _.filter(obj, function(value, index, list) { - return !iterator.call(context, value, index, list); - }, context); - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); - each(obj, function(value, index, list) { - if (!(result = result && iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); - each(obj, function(value, index, list) { - if (result || (result = iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if the array or object contains a given value (using `===`). - // Aliased as `include`. - _.contains = _.include = function(obj, target) { - if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - return _.map(obj, function(value) { - return (_.isFunction(method) ? method : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, function(value){ return value[key]; }); - }; - - // Convenience version of a common use case of `filter`: selecting only objects - // with specific `key:value` pairs. - _.where = function(obj, attrs) { - if (_.isEmpty(attrs)) return []; - return _.filter(obj, function(value) { - for (var key in attrs) { - if (_.has(attrs, key) && attrs[key] !== value[key]) return false; - } - return true; - }); - }; - - // Return the maximum element or (element-based computation). - // Can't optimize arrays of integers longer than 65,535 elements. - // See: https://bugs.webkit.org/show_bug.cgi?id=80797 - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity, value: -Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed >= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity, value: Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Shuffle an array. - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - - // An internal function to generate lookup iterators. - var lookupIterator = function(value) { - return _.isFunction(value) ? value : function(obj){ return obj[value]; }; - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, value, context) { - var iterator = lookupIterator(value); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - index : index, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index < right.index ? -1 : 1; - }), 'value'); - }; - - // An internal function used for aggregate "group by" operations. - var group = function(obj, value, context, behavior) { - var result = {}; - var iterator = lookupIterator(value); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - (_.has(result, key) ? result[key] : (result[key] = [])).push(value); - }); - }; - - // Counts instances of an object that group by a certain criterion. Pass - // either a string attribute to count by, or a function that returns the - // criterion. - _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - if (!_.has(result, key)) result[key] = 0; - result[key]++; - }); - }; - - // Use a comparator function to figure out the smallest index at which - // an object should be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator, context) { - iterator = iterator == null ? _.identity : lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely convert anything iterable into a real, live array. - _.toArray = function(obj) { - if (!obj) return []; - if (obj.length === +obj.length) return slice.call(obj); - return _.values(obj); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head` and `take`. The **guard** check - // allows it to work with `_.map`. - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; - }; - - // Returns everything but the last entry of the array. Especially useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if (array == null) return void 0; - if ((n != null) && !guard) { - return slice.call(array, Math.max(array.length - n, 0)); - } else { - return array[array.length - 1]; - } - }; - - // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. - // Especially useful on the arguments object. Passing an **n** will return - // the rest N values in the array. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, function(value){ return !!value; }); - }; - - // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, output) { - each(input, function(value) { - if (_.isArray(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - - // Return a completely flattened version of an array. - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(concat.apply(ArrayProto, arguments)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var args = slice.call(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(args, "" + i); - } - return results; - }; - - // Converts lists into objects. Pass either a single array of `[key, value]` - // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. - _.object = function(list, values) { - if (list == null) return {}; - var result = {}; - for (var i = 0, l = list.length; i < l; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, l = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < l; i++) if (array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var len = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(len); - - while(idx < len) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Reusable constructor function for prototype setting. - var ctor = function(){}; - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Binding with arguments is also known as `curry`. - // Delegates to **ECMAScript 5**'s native `Function.bind` if available. - // We check for `func.bind` first, to fail fast when `func` is undefined. - _.bind = function bind(func, context) { - var bound, args; - if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; - args = slice.call(arguments, 2); - return bound = function() { - if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - var result = func.apply(self, args.concat(slice.call(arguments))); - if (Object(result) === result) return result; - return self; - }; - }; - - // Bind all of an object's methods to that object. Useful for ensuring that - // all callbacks defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length == 0) funcs = _.functions(obj); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. - _.throttle = function(func, wait) { - var context, args, timeout, result; - var previous = 0; - var later = function() { - previous = new Date; - timeout = null; - result = func.apply(context, args); - }; - return function() { - var now = new Date; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - previous = now; - result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. If `immediate` is passed, trigger the function on the - // leading edge, instead of the trailing. - _.debounce = function(func, wait, immediate) { - var timeout, result; - return function() { - var context = this, args = arguments; - var later = function() { - timeout = null; - if (!immediate) result = func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(context, args); - return result; - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return function() { - var args = [func]; - push.apply(args, arguments); - return wrapper.apply(this, args); - }; - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - if (times <= 0) return func(); - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = nativeKeys || function(obj) { - if (obj !== Object(obj)) throw new TypeError('Invalid object'); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - var values = []; - for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); - return values; - }; - - // Convert an object into a list of `[key, value]` pairs. - _.pairs = function(obj) { - var pairs = []; - for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); - return pairs; - }; - - // Invert the keys and values of an object. The values must be serializable. - _.invert = function(obj) { - var result = {}; - for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; - return result; - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Return a copy of the object only containing the whitelisted properties. - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = aStack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (aStack[length] == a) return bStack[length] == b; - } - // Add the first object to the stack of traversed objects. - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - // Objects with different constructors are not equivalent, but `Object`s - // from different frames are. - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor))) { - return false; - } - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - aStack.pop(); - bStack.pop(); - return result; - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; - }); - - // Define a fallback version of the method in browsers (ahem, IE), where - // there isn't any inspectable "Arguments" type. - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Optimize `isFunction` if appropriate. - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; - } - - // Is a given object a finite number? - _.isFinite = function(obj) { - return isFinite( obj ) && !isNaN( parseFloat(obj) ); - }; - - // Is the given value `NaN`? (NaN is the only number which does not equal itself). - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Shortcut function for checking if an object has a given property directly - // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - // Run a function **n** times. - _.times = function(n, iterator, context) { - for (var i = 0; i < n; i++) iterator.call(context, i); - }; - - // Return a random integer between min and max (inclusive). - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + (0 | Math.random() * (max - min + 1)); - }; - - // List of HTML entities for escaping. - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '/': '/' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - - // Regexes containing the keys and values listed immediately above. - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - - // Functions for escaping and unescaping strings to/from HTML interpolation. - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - - // If the value of the named property is a function then invoke it; - // otherwise, return it. - _.result = function(object, property) { - if (object == null) return null; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - - // Add your own custom functions to the Underscore object. - _.mixin = function(obj) { - each(_.functions(obj), function(name){ - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = idCounter++; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /(.)^/; - - // Certain characters need to be escaped so that they can be put into a - // string literal. - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; - - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(text, data, settings) { - settings = _.defaults({}, settings, _.templateSettings); - - // Combine delimiters into one regular expression via alternation. - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - - // Compile the template source, escaping string literals appropriately. - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); - source += - escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : - interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : - evaluate ? "';\n" + evaluate + "\n__p+='" : ''; - index = offset + match.length; - }); - source += "';\n"; - - // If a variable is not specified, place data values in local scope. - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; - - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - var render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - - // Provide the compiled function source as a convenience for precompilation. - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // OOP - // --------------- - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - - // Helper function to continue chaining intermediate results. - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - - // Start chaining a wrapped Underscore object. - chain: function() { - this._chain = true; - return this; - }, - - // Extracts the result from a wrapped and chained object. - value: function() { - return this._wrapped; - } - - }); - -}).call(this);