Update included modules

This commit is contained in:
Timothy Warren 2015-01-28 15:33:44 -05:00
parent 5dffbc5ef5
commit ba6b3c311d
612 changed files with 41581 additions and 36451 deletions

View File

@ -72,7 +72,7 @@ var d = {
}
// Handle commas
if (str.contains(','))
if (str.includes(','))
{
var parts = str.split(',').map(helpers.stringTrim);
str = parts.map(d.quoteIdentifiers).join(',');
@ -83,7 +83,7 @@ var d = {
raw = hiers.join('.');
// Fix functions
if (raw.contains('(') && raw.contains(')'))
if (raw.includes('(') && raw.includes(')'))
{
var funcs = pattern.exec(raw);

2
node_modules/dblite/package.json generated vendored
View File

@ -39,7 +39,7 @@
},
"_id": "dblite@0.6.1",
"_shasum": "18e6d3811f4031ff0119e8a7b13ef1558215376a",
"_from": "dblite@^0.6.1",
"_from": "dblite@>=0.6.1 <0.7.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "webreflection",

8
node_modules/es6-shim/.flowconfig generated vendored Normal file
View File

@ -0,0 +1,8 @@
[ignore]
.min.js
Gruntfile.js
.map
[include]
es6-shim.js
es6-sham.js

2
node_modules/es6-shim/.jscs.json generated vendored
View File

@ -13,6 +13,8 @@
"requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
"requireSpaceBetweenArguments": true,
"disallowSpacesInsideParentheses": true,
"disallowSpacesInsideArrayBrackets": true,

3
node_modules/es6-shim/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,3 @@
{
"es3": true
}

51
node_modules/es6-shim/CHANGELOG.md generated vendored
View File

@ -1,5 +1,48 @@
# es6-shim x.x.x (not yet released)
# es6-shim 0.23.0 (26 Jan 2015)
* Use Symbol.species when available, else fall back to "@@species" (renamed from "@@create")
* Fix `npm run test-native`
* Correct broken Math implementations: `log1p`, `exmp1`, `tanh`, `acosh`, `cosh`, `sinh`, `round` (#314)
* Update `jscs`, `grunt-saucelabs`, `jshint`
# es6-shim 0.22.2 (4 Jan 2015)
* Faster travis-ci builds
* Better ES3 support: quoting/avoiding reserved words
* Update `mocha`, `jscs`, `jshint`, `grunt-saucelabs`, `uglify-js`
# es6-shim 0.22.1 (13 Dec 2014)
* Make RegExp#flags generic, per spec (#310)
# es6-shim 0.22.0 (12 Dec 2014)
* Add RegExp#flags
* Make `new RegExp` work with both a regex and a flags string
* Remove non-spec `Object.{getPropertyNames,getPropertyDescriptor}`
# es6-shim 0.21.1 (4 Dec 2014)
* Promise/Promise.prototype methods, and String#{startsWith,endsWith} are now not enumerable
* Array#{keys, values, entries} should all be @@unscopeable in browsers that support that
* Ensure that tampering with Function#{call,apply} wont break internal methods
* Add Math.clz32, RegExp tests
* Update es6-sham UMD
* Update `chai`, `es5-shim`, `grunt-saucelabs`, `jscs`
# es6-shim 0.21.0 (21 Nov 2014)
* String#contains → String#includes per 2014-11-19 TC39 meeting
* Use an invalid identifier as the es6-shim iterator key, so it doesnt show up in the console as easily.
# es6-shim 0.20.4 (20 Nov 2014)
* Performance improvements: avoid slicing arguments, avoid `Function#call` when possible
* Name `String.{fromCodePoint,raw}` for debugging
* Fix `String.raw` to match spec
* Ensure Chromes excess Promise methods are purged
* Ensure `Set#keys === Set#values`, per spec
# es6-shim 0.20.3 (19 Nov 2014)
* Fix Set#add and Map#set to always return "this" (#302)
* Clarify TypeError messages thrown by Map/Set
* Fix Chrome 38 bug with Array#values
# es6-shim 0.20.2 (28 Oct 2014)
* Fix AMD (#299)
@ -20,7 +63,7 @@
# es6-shim 0.19.0 (9 Oct 2014)
* Detect and override noncompliant Map in Firefox 32 (#294)
* Fix Map and Set for engines that don't preserve numeric key order (#292, #290)
* Fix Map and Set for engines that dont preserve numeric key order (#292, #290)
* Detect and override noncompliant Safari 7.1 Promises (#289)
* Fix Array#keys and Array#entries in Safari 7.1
* General style and whitespace cleanup
@ -57,9 +100,9 @@
# es6-shim 0.14.0 (20 Jul 2014)
* Properly recognize Symbol.iterator when it is present (#277)
* Fix Math.clz's improper handling of values that coerce to NaN (#269)
* Fix Math.clzs improper handling of values that coerce to NaN (#269)
* Fix incorrect handling of negative end index on Array#fill (#270)
* Removed Object.getOwnPropertyKeys, which shouldn't be anywhere (#267)
* Removed Object.getOwnPropertyKeys, which shouldnt be anywhere (#267)
* Fixed arity of Map and Set constructors, per 2014.04.27 draft spec (rev 24)
* Added a full additional suite of ES6 promise tests (thanks to @smikes!) (#265)
* Make Number.isInteger a bit more efficient (#266)
@ -92,7 +135,7 @@
# es6-shim 0.10.1 (13 Mar 2014)
* Update bower.json, component.json, and .npmignore (#229, #230, #233)
* Minor updates to `Promise` implementation and test suite.
* Workaround lack of 'strict mode' in IE9. (#232)
* Workaround lack of "strict mode" in IE9. (#232)
# es6-shim 0.10.0 (1 March 2014)
* Implement `Promise`, per spec. (#209, #215, #224, #225)

13
node_modules/es6-shim/README.md generated vendored
View File

@ -36,7 +36,11 @@ details.
* `repeat()` ([a standalone shim is also available](http://mths.be/repeat))
* `startsWith()` ([a standalone shim is also available](http://mths.be/startswith))
* `endsWith()` ([a standalone shim is also available](http://mths.be/endswith))
* `contains()` ([a standalone shim is also available](http://mths.be/contains))
* `includes()` ([a standalone shim is also available](http://mths.be/includes))
* `RegExp`:
* `new RegExp`, when given a RegExp as the pattern, will no longer throw when given a "flags" string argument. (requires ES5)
* `RegExp.prototype`:
* `flags` (requires ES5) ([a standalone shim is also available](https://github.com/es-shims/RegExp.prototype.flags))
* `Number`:
* `MAX_SAFE_INTEGER`
* `MIN_SAFE_INTEGER`
@ -59,10 +63,7 @@ details.
* `entries()`
* `values()`
* `Object`:
* `getPropertyDescriptor()` (ES5)
* `getPropertyNames()` (ES5)
* `getPropertyKeys()` (ES5)
* `keys()` (ES5, but no longer throws on non-object non-null/undefined values in ES6)
* `keys()` (in ES5, but no longer throws on non-object non-null/undefined values in ES6)
* `is()` ([a standalone shim is also available](https://github.com/ljharb/object-is))
* `assign()` ([a standalone shim is also available](https://github.com/ljharb/object.assign))
* `setPrototypeOf()` (IE >= 11)
@ -126,7 +127,7 @@ WeakMap has a very unusual use-case so you probably won't need it at all
```javascript
'abc'.startsWith('a') // true
'abc'.endsWith('a') // false
'john alice'.contains('john') // true
'john alice'.includes('john') // true
'123'.repeat(2) // '123123'
Object.is(NaN, NaN) // Fixes ===. 0 isnt -0, NaN is NaN

2
node_modules/es6-shim/bower.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "es6-shim",
"version": "0.20.2",
"version": "0.23.0",
"repo": "paulmillr/es6-shim",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [

View File

@ -1,6 +1,6 @@
{
"name": "es6-shim",
"version": "0.20.2",
"version": "0.23.0",
"repo": "paulmillr/es6-shim",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [

188
node_modules/es6-shim/es6-sham.js generated vendored
View File

@ -2,112 +2,118 @@
* https://github.com/paulmillr/es6-shim
* @license es6-shim Copyright 2013-2014 by Paul Miller (http://paulmillr.com)
* and contributors, MIT License
* es6-sham: v0.20.2
* see https://github.com/paulmillr/es6-shim/blob/master/LICENSE
* es6-sham: v0.23.0
* see https://github.com/paulmillr/es6-shim/blob/0.22.2/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
(function (undefined) {
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
/*global define, exports, module */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like enviroments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
}
}(this, function (undefined) {
'use strict';
/*jshint evil: true */
var getGlobal = new Function('return this;');
/*jshint evil: false */
var main = function () {
var globals = getGlobal();
var Object = globals.Object;
var globals = getGlobal();
var Object = globals.Object;
// NOTE: This versions needs object ownership
// beacuse every promoted object needs to be reassigned
// otherwise uncompatible browsers cannot work as expected
//
// NOTE: This might need es5-shim or polyfills upfront
// because it's based on ES5 API.
// (probably just an IE <= 8 problem)
//
// NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
(function () {
if (Object.setPrototypeOf) { return; }
// NOTE: This versions needs object ownership
// beacuse every promoted object needs to be reassigned
// otherwise uncompatible browsers cannot work as expected
//
// NOTE: This might need es5-shim or polyfills upfront
// because it's based on ES5 API.
// (probably just an IE <= 8 problem)
//
// NOTE: nodejs is fine in version 0.8, 0.10, and future versions.
(function () {
if (Object.setPrototypeOf) { return; }
/*jshint proto: true */
// @author Andrea Giammarchi - @WebReflection
// define into target descriptors from source
var copyDescriptors = function (target, source) {
getOwnPropertyNames(source).forEach(function (key) {
defineProperty(
target,
key,
getOwnPropertyDescriptor(source, key)
);
});
return target;
/*jshint proto: true */
// @author Andrea Giammarchi - @WebReflection
// define into target descriptors from source
var copyDescriptors = function (target, source) {
getOwnPropertyNames(source).forEach(function (key) {
defineProperty(
target,
key,
getOwnPropertyDescriptor(source, key)
);
});
return target;
};
// used as fallback when no promotion is possible
var createAndCopy = function (origin, proto) {
return copyDescriptors(create(proto), origin);
};
var create = Object.create;
var defineProperty = Object.defineProperty;
var getPrototypeOf = Object.getPrototypeOf;
var getOwnPropertyNames = Object.getOwnPropertyNames;
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var proto = Object.prototype;
var set, setPrototypeOf;
try {
// this might fail for various reasons
// ignore if Chrome cought it at runtime
set = getOwnPropertyDescriptor(proto, '__proto__').set;
set.call({}, null);
// setter not poisoned, it can promote
// Firefox, Chrome
setPrototypeOf = function (origin, proto) {
set.call(origin, proto);
return origin;
};
// used as fallback when no promotion is possible
var createAndCopy = function (origin, proto) {
return copyDescriptors(create(proto), origin);
};
var create = Object.create;
var defineProperty = Object.defineProperty;
var getPrototypeOf = Object.getPrototypeOf;
var getOwnPropertyNames = Object.getOwnPropertyNames;
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var proto = Object.prototype;
var set, setPrototypeOf;
try {
// this might fail for various reasons
// ignore if Chrome cought it at runtime
set = getOwnPropertyDescriptor(proto, '__proto__').set;
set.call({}, null);
// setter not poisoned, it can promote
// Firefox, Chrome
setPrototypeOf = function (origin, proto) {
set.call(origin, proto);
return origin;
};
} catch (e) {
// do one or more feature detections
set = {__proto__: null};
// if proto does not work, needs to fallback
// some Opera, Rhino, ducktape
} catch (e) {
// do one or more feature detections
set = {__proto__: null};
// if proto does not work, needs to fallback
// some Opera, Rhino, ducktape
if (set instanceof Object) {
setPrototypeOf = createAndCopy;
} else {
// verify if null objects are buggy
set.__proto__ = proto;
// if null objects are buggy
// nodejs 0.8 to 0.10
if (set instanceof Object) {
setPrototypeOf = createAndCopy;
setPrototypeOf = function (origin, proto) {
// use such bug to promote
origin.__proto__ = proto;
return origin;
};
} else {
// verify if null objects are buggy
set.__proto__ = proto;
// if null objects are buggy
// nodejs 0.8 to 0.10
if (set instanceof Object) {
setPrototypeOf = function (origin, proto) {
// use such bug to promote
origin.__proto__ = proto;
return origin;
};
} else {
// try to use proto or fallback
// Safari, old Firefox, many others
setPrototypeOf = function (origin, proto) {
// if proto is not null
return getPrototypeOf(origin) ?
// use __proto__ to promote
((origin.__proto__ = proto), origin) :
// otherwise unable to promote: fallback
createAndCopy(origin, proto);
};
}
// try to use proto or fallback
// Safari, old Firefox, many others
setPrototypeOf = function (origin, proto) {
// if proto is not null
return getPrototypeOf(origin) ?
// use __proto__ to promote
((origin.__proto__ = proto), origin) :
// otherwise unable to promote: fallback
createAndCopy(origin, proto);
};
}
}
Object.setPrototypeOf = setPrototypeOf;
}());
};
if (typeof define === 'function' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
}());
}
Object.setPrototypeOf = setPrototypeOf;
}());
}));

2
node_modules/es6-shim/es6-sham.map generated vendored
View File

@ -1 +1 @@
{"version":3,"sources":["es6-sham.js"],"names":["undefined","getGlobal","Function","main","globals","Object","setPrototypeOf","copyDescriptors","target","source","getOwnPropertyNames","forEach","key","defineProperty","getOwnPropertyDescriptor","createAndCopy","origin","proto","create","getPrototypeOf","prototype","set","call","e","__proto__","define","amd"],"mappings":";;;;;;;;;CAUC,SAAUA,GACT,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAO,WACT,GAAIC,GAAUH,GACd,IAAII,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAkB,SAAUC,EAAQC,GACtCC,EAAoBD,GAAQE,QAAQ,SAAUC,GAC5CC,EACEL,EACAI,EACAE,EAAyBL,EAAQG,KAGrC,OAAOJ,GAGT,IAAIO,GAAgB,SAAUC,EAAQC,GACpC,MAAOV,GAAgBW,EAAOD,GAAQD,GAExC,IAAIE,GAASb,EAAOa,MACpB,IAAIL,GAAiBR,EAAOQ,cAC5B,IAAIM,GAAiBd,EAAOc,cAC5B,IAAIT,GAAsBL,EAAOK,mBACjC,IAAII,GAA2BT,EAAOS,wBACtC,IAAIG,GAAQZ,EAAOe,SACnB,IAAIC,GAAKf,CAET,KAGEe,EAAMP,EAAyBG,EAAO,aAAaI,GACnDA,GAAIC,QAAS,KAGbhB,GAAiB,SAAUU,EAAQC,GACjCI,EAAIC,KAAKN,EAAQC,EACjB,OAAOD,IAET,MAAOO,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAehB,GAAQ,CACzBC,EAAiBS,MACZ,CAELM,EAAIG,UAAYP,CAGhB,IAAII,YAAehB,GAAQ,CACzBC,EAAiB,SAAUU,EAAQC,GAEjCD,EAAOQ,UAAYP,CACnB,OAAOD,QAEJ,CAGLV,EAAiB,SAAUU,EAAQC,GAEjC,MAAOE,GAAeH,IAElBA,EAAOQ,UAAYP,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhCZ,EAAOC,eAAiBA,MAK5B,UAAWmB,UAAW,YAAcA,OAAOC,IAAK,CAC9CD,OAAOtB,OACF,CACLA"}
{"version":3,"sources":["es6-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","undefined","getGlobal","Function","globals","Object","setPrototypeOf","copyDescriptors","target","source","getOwnPropertyNames","forEach","key","defineProperty","getOwnPropertyDescriptor","createAndCopy","origin","proto","create","getPrototypeOf","prototype","set","call","e","__proto__"],"mappings":";;;;;;;;;CAYC,SAAUA,EAAMC,GAEf,SAAWC,UAAW,YAAcA,OAAOC,IAAK,CAE9CD,OAAOD,OACF,UAAWG,WAAY,SAAU,CAItCC,OAAOD,QAAUH,QACZ,CAELD,EAAKM,cAAgBL,OAEvBM,KAAM,SAAUC,GAChB,YAGA,IAAIC,GAAY,GAAIC,UAAS,eAG7B,IAAIC,GAAUF,GACd,IAAIG,GAASD,EAAQC,QAWpB,WACC,GAAIA,EAAOC,eAAgB,CAAE,OAK7B,GAAIC,GAAkB,SAAUC,EAAQC,GACtCC,EAAoBD,GAAQE,QAAQ,SAAUC,GAC5CC,EACEL,EACAI,EACAE,EAAyBL,EAAQG,KAGrC,OAAOJ,GAGT,IAAIO,GAAgB,SAAUC,EAAQC,GACpC,MAAOV,GAAgBW,EAAOD,GAAQD,GAExC,IAAIE,GAASb,EAAOa,MACpB,IAAIL,GAAiBR,EAAOQ,cAC5B,IAAIM,GAAiBd,EAAOc,cAC5B,IAAIT,GAAsBL,EAAOK,mBACjC,IAAII,GAA2BT,EAAOS,wBACtC,IAAIG,GAAQZ,EAAOe,SACnB,IAAIC,GAAKf,CACT,KAGEe,EAAMP,EAAyBG,EAAO,aAAaI,GACnDA,GAAIC,QAAS,KAGbhB,GAAiB,SAAUU,EAAQC,GACjCI,EAAIC,KAAKN,EAAQC,EACjB,OAAOD,IAET,MAAOO,GAEPF,GAAOG,UAAW,KAGlB,IAAIH,YAAehB,GAAQ,CACzBC,EAAiBS,MACZ,CAELM,EAAIG,UAAYP,CAGhB,IAAII,YAAehB,GAAQ,CACzBC,EAAiB,SAAUU,EAAQC,GAEjCD,EAAOQ,UAAYP,CACnB,OAAOD,QAEJ,CAGLV,EAAiB,SAAUU,EAAQC,GAEjC,MAAOE,GAAeH,IAElBA,EAAOQ,UAAYP,EAAQD,GAE7BD,EAAcC,EAAQC,MAKhCZ,EAAOC,eAAiBA"}

View File

@ -2,10 +2,10 @@
* https://github.com/paulmillr/es6-shim
* @license es6-shim Copyright 2013-2014 by Paul Miller (http://paulmillr.com)
* and contributors, MIT License
* es6-sham: v0.20.2
* see https://github.com/paulmillr/es6-shim/blob/master/LICENSE
* es6-sham: v0.23.0
* see https://github.com/paulmillr/es6-shim/blob/0.22.2/LICENSE
* Details and documentation:
* https://github.com/paulmillr/es6-shim/
*/
(function(t){"use strict";var r=new Function("return this;");var e=function(){var t=r();var e=t.Object;(function(){if(e.setPrototypeOf){return}var t=function(t,r){i(r).forEach(function(e){o(t,e,a(r,e))});return t};var r=function(r,e){return t(n(e),r)};var n=e.create;var o=e.defineProperty;var f=e.getPrototypeOf;var i=e.getOwnPropertyNames;var a=e.getOwnPropertyDescriptor;var c=e.prototype;var u,_;try{u=a(c,"__proto__").set;u.call({},null);_=function(t,r){u.call(t,r);return t}}catch(p){u={__proto__:null};if(u instanceof e){_=r}else{u.__proto__=c;if(u instanceof e){_=function(t,r){t.__proto__=r;return t}}else{_=function(t,e){return f(t)?(t.__proto__=e,t):r(t,e)}}}}e.setPrototypeOf=_})()};if(typeof define==="function"&&define.amd){define(e)}else{e()}})();
(function(t,e){if(typeof define==="function"&&define.amd){define(e)}else if(typeof exports==="object"){module.exports=e()}else{t.returnExports=e()}})(this,function(t){"use strict";var e=new Function("return this;");var r=e();var n=r.Object;(function(){if(n.setPrototypeOf){return}var t=function(t,e){i(e).forEach(function(r){o(t,r,c(e,r))});return t};var e=function(e,n){return t(r(n),e)};var r=n.create;var o=n.defineProperty;var f=n.getPrototypeOf;var i=n.getOwnPropertyNames;var c=n.getOwnPropertyDescriptor;var u=n.prototype;var a,_;try{a=c(u,"__proto__").set;a.call({},null);_=function(t,e){a.call(t,e);return t}}catch(p){a={__proto__:null};if(a instanceof n){_=e}else{a.__proto__=u;if(a instanceof n){_=function(t,e){t.__proto__=e;return t}}else{_=function(t,r){return f(t)?(t.__proto__=r,t):e(t,r)}}}}n.setPrototypeOf=_})()});
//# sourceMappingURL=es6-sham.map

877
node_modules/es6-shim/es6-shim.js generated vendored

File diff suppressed because it is too large Load Diff

2
node_modules/es6-shim/es6-shim.map generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

65
node_modules/es6-shim/package.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "es6-shim",
"version": "0.20.2",
"version": "0.23.0",
"author": {
"name": "Paul Miller",
"url": "http://paulmillr.com"
@ -26,13 +26,19 @@
},
"main": "es6-shim",
"scripts": {
"test": "npm run test-shim && npm run test-sham",
"test": "npm run lint && npm run test-shim && npm run test-sham",
"test-shim": "mocha test/*.js test/*/*.js",
"test-sham": "mocha test-sham/*.js",
"test-native": "npm run jshint-shim && NO_ES6_SHIM=1 mocha test/*.js test/*/*.js",
"lint": "npm run lint-shim && npm run lint-sham",
"lint-shim": "jshint es6-shim.js test/*.js test/*/*.js && jscs es6-shim.js test/*.js test/*/*.js",
"lint-sham": "jshint es6-sham.js test-sham/*.js && jscs es6-sham.js test-sham/*.js",
"test-shim": "npm run lint-shim && mocha test/*.js test/*/*.js",
"test-sham": "npm run lint-sham && mocha test-sham/*.js",
"test-native": "jshint es6-shim.js && NO_ES6_SHIM=1 mocha test/*.js test/*/*.js",
"lint-shim": "npm run jshint-shim && npm run jscs-shim",
"lint-sham": "npm run jshint-sham && npm run jscs-sham",
"jshint": "npm run jshint-shim && npm run jshint-sham",
"jshint-shim": "jshint es6-shim.js test/*.js test/*/*.js",
"jshint-sham": "jshint es6-sham.js test-sham/*.js",
"jscs": "npm run jscs-shim && npm run jscs-sham",
"jscs-shim": "jscs es6-shim.js test/*.js test/*/*.js",
"jscs-sham": "jscs es6-sham.js test-sham/*.js",
"minify": "npm run minify-shim && npm run minify-sham",
"minify-shim": "uglifyjs es6-shim.js --comments --source-map=es6-shim.map -m -b ascii_only=true,beautify=false > es6-shim.min.js",
"minify-sham": "uglifyjs es6-sham.js --comments --source-map=es6-sham.map -m -b ascii_only=true,beautify=false > es6-sham.min.js",
@ -41,42 +47,44 @@
"testling": {
"html": "testling.html",
"browsers": [
"iexplore/9.0..latest",
"iexplore/6.0..latest",
"firefox/3.0..6.0",
"firefox/10.0",
"firefox/17.0",
"firefox/22.0..latest",
"firefox/15.0..latest",
"firefox/nightly",
"chrome/25.0..latest",
"chrome/4.0..10.0",
"chrome/20.0..latest",
"chrome/canary",
"safari/5.0.5..latest",
"opera/10.0..latest",
"opera/next",
"safari/4.0..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"opera/12.0..latest",
"android-browser/4.2..latest"
]
},
"dependencies": {},
"devDependencies": {
"chai": "~1.9.2",
"es5-shim": "~4.0.3",
"chai": "~1.10.0",
"es5-shim": "~4.0.5",
"grunt": "~0.4.5",
"grunt-contrib-connect": "~0.8.0",
"grunt-contrib-connect": "~0.9.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-saucelabs": "~8.3.2",
"jscs": "~1.7.3",
"jshint": "~2.5.6",
"mocha": "~2.0.1",
"grunt-saucelabs": "~8.5.0",
"jscs": "~1.10.0",
"jshint": "~2.6.0",
"mocha": "~2.1.0",
"promises-aplus-tests": "~2.1.0",
"promises-es6-tests": "~0.5.0",
"uglify-js": "~2.4.15"
"uglify-js": "~2.4.16"
},
"gitHead": "f1a9e182eead8a2df3a441dc021881233988b9dd",
"gitHead": "fde6f2134762d36e9b1324f212fd939282700ca5",
"bugs": {
"url": "https://github.com/paulmillr/es6-shim/issues"
},
"_id": "es6-shim@0.20.2",
"_shasum": "4f174a32d293adb34f6ad9b25b9aa56d7f9d1a76",
"_from": "es6-shim@0.20.2",
"_id": "es6-shim@0.23.0",
"_shasum": "ea65bdcfc076eb109ea839f92dfed8c0517a2b72",
"_from": "es6-shim@0.23.0",
"_npmVersion": "1.4.28",
"_npmUser": {
"name": "ljharb",
@ -93,9 +101,10 @@
}
],
"dist": {
"shasum": "4f174a32d293adb34f6ad9b25b9aa56d7f9d1a76",
"tarball": "http://registry.npmjs.org/es6-shim/-/es6-shim-0.20.2.tgz"
"shasum": "ea65bdcfc076eb109ea839f92dfed8c0517a2b72",
"tarball": "http://registry.npmjs.org/es6-shim/-/es6-shim-0.23.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.20.2.tgz"
"_resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.23.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -1,24 +1,25 @@
/*global expect */
describe('Object.setPrototypeOf(o, p)', function () {
'use strict';
it('changes prototype to regular objects', function () {
var obj = {a: 123};
expect(obj instanceof Object).to.equal(true);
expect(obj).to.be.an.instanceOf(Object);
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, null);
expect(obj instanceof Object).to.equal(false);
expect(obj).not.to.be.an.instanceOf(Object);
expect(obj.a).to.equal(123);
});
it('changes prototype to null objects', function () {
var obj = Object.create(null);
obj.a = 456;
expect(obj instanceof Object).to.equal(false);
expect(obj).not.to.be.an.instanceOf(Object);
expect(obj.a).to.equal(456);
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, {});
expect(obj instanceof Object).to.equal(true);
expect(obj).to.be.an.instanceOf(Object);
expect(obj.a).to.equal(456);
});
});

View File

@ -0,0 +1,95 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var chalk = module.exports;
function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
builder.__proto__ = proto;
return builder;
}
var styles = (function () {
var ret = {};
ansiStyles.grey = ansiStyles.gray;
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build(this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!chalk.enabled || !str) {
return str;
}
/*jshint validthis: true*/
var nestedStyles = this._styles;
for (var i = 0; i < nestedStyles.length; i++) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build([name]);
}
};
});
return ret;
}
defineProps(chalk, init());
chalk.styles = ansiStyles;
chalk.hasColor = hasAnsi;
chalk.stripColor = stripAnsi;
chalk.supportsColor = supportsColor;
// detect mode if not set manually
if (chalk.enabled === undefined) {
chalk.enabled = chalk.supportsColor;
}

View File

@ -0,0 +1 @@
../has-ansi/cli.js

View File

@ -0,0 +1 @@
../strip-ansi/cli.js

View File

@ -0,0 +1 @@
../supports-color/cli.js

View File

@ -0,0 +1,40 @@
'use strict';
var styles = module.exports;
var codes = {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29],
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39],
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
};
Object.keys(codes).forEach(function (key) {
var val = codes[key];
var style = styles[key] = {};
style.open = '\u001b[' + val[0] + 'm';
style.close = '\u001b[' + val[1] + 'm';
});

View File

@ -0,0 +1,74 @@
{
"name": "ansi-styles",
"version": "1.1.0",
"description": "ANSI escape codes for styling strings in the terminal",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-styles"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-styles/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-styles",
"_id": "ansi-styles@1.1.0",
"_shasum": "eaecbf66cd706882760b2f4691582b8f55d7a7de",
"_from": "ansi-styles@>=1.1.0 <2.0.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "eaecbf66cd706882760b2f4691582b8f55d7a7de",
"tarball": "http://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,70 @@
# ansi-styles [![Build Status](https://travis-ci.org/sindresorhus/ansi-styles.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
![screenshot](screenshot.png)
## Install
```sh
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### General
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Text colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,11 @@
'use strict';
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};

View File

@ -0,0 +1,69 @@
{
"name": "escape-string-regexp",
"version": "1.0.2",
"description": "Escape RegExp special characters",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sindresorhus/escape-string-regexp"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"regex",
"regexp",
"re",
"regular",
"expression",
"escape",
"string",
"str",
"special",
"characters"
],
"devDependencies": {
"mocha": "*"
},
"gitHead": "0587ee0ee03ea3fcbfa3c15cf67b47f214e20987",
"bugs": {
"url": "https://github.com/sindresorhus/escape-string-regexp/issues"
},
"homepage": "https://github.com/sindresorhus/escape-string-regexp",
"_id": "escape-string-regexp@1.0.2",
"_shasum": "4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1",
"_from": "escape-string-regexp@>=1.0.0 <2.0.0",
"_npmVersion": "1.4.23",
"_npmUser": {
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"dist": {
"shasum": "4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1",
"tarball": "http://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,27 @@
# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
> Escape RegExp special characters
## Install
```sh
$ npm install --save escape-string-regexp
```
## Usage
```js
var escapeStringRegexp = require('escape-string-regexp');
var escapedString = escapeStringRegexp('how much $ for a unicorn?');
//=> how much \$ for a unicorn\?
new RegExp(escapedString);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,53 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var hasAnsi = require('./');
var input = process.argv[2];
function stdin(cb) {
var ret = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
ret += data;
});
process.stdin.on('end', function () {
cb(ret);
});
}
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ has-ansi <string>',
' $ echo <string> | has-ansi',
'',
'Exits with code 0 if input has ANSI escape codes and 1 if not'
].join('\n'));
}
function init(data) {
process.exit(hasAnsi(data) ? 0 : 1);
}
if (process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (process.stdin.isTTY) {
if (!input) {
help();
return;
}
init(input);
} else {
stdin(init);
}

View File

@ -0,0 +1,4 @@
'use strict';
var ansiRegex = require('ansi-regex');
var re = new RegExp(ansiRegex().source); // remove the `g` flag
module.exports = re.test.bind(re);

View File

@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
};

View File

@ -0,0 +1,79 @@
{
"name": "ansi-regex",
"version": "0.2.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-regex"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@0.2.1",
"_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"_from": "ansi-regex@>=0.2.0 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,33 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,85 @@
{
"name": "has-ansi",
"version": "0.1.0",
"description": "Check if a string has ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/has-ansi"
},
"bin": {
"has-ansi": "cli.js"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli",
"bin",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"string",
"tty",
"escape",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern",
"has"
],
"dependencies": {
"ansi-regex": "^0.2.0"
},
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/has-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/has-ansi",
"_id": "has-ansi@0.1.0",
"_shasum": "84f265aae8c0e6a88a12d7022894b7568894c62e",
"_from": "has-ansi@>=0.1.0 <0.2.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "84f265aae8c0e6a88a12d7022894b7568894c62e",
"tarball": "http://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,45 @@
# has-ansi [![Build Status](https://travis-ci.org/sindresorhus/has-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/has-ansi)
> Check if a string has [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save has-ansi
```
## Usage
```js
var hasAnsi = require('has-ansi');
hasAnsi('\u001b[4mcake\u001b[0m');
//=> true
hasAnsi('cake');
//=> false
```
## CLI
```sh
$ npm install --global has-ansi
```
```
$ has-ansi --help
Usage
$ has-ansi <string>
$ echo <string> | has-ansi
Exits with code 0 if input has ANSI escape codes and 1 if not
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var pkg = require('./package.json');
var strip = require('./');
var input = process.argv[2];
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ strip-ansi <input-file> > <output-file>',
' $ cat <input-file> | strip-ansi > <output-file>',
'',
'Example',
' $ strip-ansi unicorn.txt > unicorn-stripped.txt'
].join('\n'));
}
if (process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (input) {
process.stdout.write(strip(fs.readFileSync(input, 'utf8')));
return;
}
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
process.stdout.write(strip(data));
});

View File

@ -0,0 +1,6 @@
'use strict';
var ansiRegex = require('ansi-regex')();
module.exports = function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
};

View File

@ -0,0 +1,4 @@
'use strict';
module.exports = function () {
return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
};

View File

@ -0,0 +1,79 @@
{
"name": "ansi-regex",
"version": "0.2.1",
"description": "Regular expression for matching ANSI escape codes",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/ansi-regex"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"text",
"regex",
"regexp",
"re",
"match",
"test",
"find",
"pattern"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/ansi-regex/issues"
},
"homepage": "https://github.com/sindresorhus/ansi-regex",
"_id": "ansi-regex@0.2.1",
"_shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"_from": "ansi-regex@>=0.2.0 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "0d8e946967a3d8143f93e24e298525fc1b2235f9",
"tarball": "http://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,33 @@
# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save ansi-regex
```
## Usage
```js
var ansiRegex = require('ansi-regex');
ansiRegex().test('\u001b[4mcake\u001b[0m');
//=> true
ansiRegex().test('cake');
//=> false
'\u001b[4mcake\u001b[0m'.match(ansiRegex());
//=> ['\u001b[4m', '\u001b[0m']
```
*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,84 @@
{
"name": "strip-ansi",
"version": "0.3.0",
"description": "Strip ANSI escape codes",
"license": "MIT",
"bin": {
"strip-ansi": "cli.js"
},
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/strip-ansi"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"strip",
"trim",
"remove",
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-regex": "^0.2.1"
},
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/strip-ansi/issues"
},
"homepage": "https://github.com/sindresorhus/strip-ansi",
"_id": "strip-ansi@0.3.0",
"_shasum": "25f48ea22ca79187f3174a4db8759347bb126220",
"_from": "strip-ansi@>=0.3.0 <0.4.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "25f48ea22ca79187f3174a4db8759347bb126220",
"tarball": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,43 @@
# strip-ansi [![Build Status](https://travis-ci.org/sindresorhus/strip-ansi.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-ansi)
> Strip [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
## Install
```sh
$ npm install --save strip-ansi
```
## Usage
```js
var stripAnsi = require('strip-ansi');
stripAnsi('\x1b[4mcake\x1b[0m');
//=> 'cake'
```
## CLI
```sh
$ npm install --global strip-ansi
```
```sh
$ strip-ansi --help
Usage
$ strip-ansi <input-file> > <output-file>
$ cat <input-file> | strip-ansi > <output-file>
Example
$ strip-ansi unicorn.txt > unicorn-stripped.txt
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,28 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var supportsColor = require('./');
var input = process.argv[2];
function help() {
console.log([
pkg.description,
'',
'Usage',
' $ supports-color',
'',
'Exits with code 0 if color is supported and 1 if not'
].join('\n'));
}
if (!input || process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
process.exit(supportsColor ? 0 : 1);

View File

@ -0,0 +1,32 @@
'use strict';
module.exports = (function () {
if (process.argv.indexOf('--no-color') !== -1) {
return false;
}
if (process.argv.indexOf('--color') !== -1) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();

View File

@ -0,0 +1,78 @@
{
"name": "supports-color",
"version": "0.2.0",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/supports-color"
},
"bin": {
"supports-color": "cli.js"
},
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli",
"bin",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect"
],
"devDependencies": {
"mocha": "*"
},
"bugs": {
"url": "https://github.com/sindresorhus/supports-color/issues"
},
"homepage": "https://github.com/sindresorhus/supports-color",
"_id": "supports-color@0.2.0",
"_shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a",
"_from": "supports-color@>=0.2.0 <0.3.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"dist": {
"shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a",
"tarball": "http://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,44 @@
# supports-color [![Build Status](https://travis-ci.org/sindresorhus/supports-color.svg?branch=master)](https://travis-ci.org/sindresorhus/supports-color)
> Detect whether a terminal supports color
## Install
```sh
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
```
It obeys the `--color` and `--no-color` CLI flags.
## CLI
```sh
$ npm install --global supports-color
```
```sh
$ supports-color --help
Usage
$ supports-color
# Exits with code 0 if color is supported and 1 if not
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -0,0 +1,82 @@
{
"name": "chalk",
"version": "0.5.1",
"description": "Terminal string styling done right. Created because the `colors` module does some really horrible things.",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/sindresorhus/chalk"
},
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
{
"name": "jbnicolai",
"email": "jappelman@xebia.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha",
"bench": "matcha benchmark.js"
},
"files": [
"index.js"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"ansi",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"dependencies": {
"ansi-styles": "^1.1.0",
"escape-string-regexp": "^1.0.0",
"has-ansi": "^0.1.0",
"strip-ansi": "^0.3.0",
"supports-color": "^0.2.0"
},
"devDependencies": {
"matcha": "^0.5.0",
"mocha": "*"
},
"gitHead": "994758f01293f1fdcf63282e9917cb9f2cfbdaac",
"bugs": {
"url": "https://github.com/sindresorhus/chalk/issues"
},
"homepage": "https://github.com/sindresorhus/chalk",
"_id": "chalk@0.5.1",
"_shasum": "663b3a648b68b55d04690d49167aa837858f2174",
"_from": "chalk@>=0.5.1 <0.6.0",
"_npmVersion": "1.4.14",
"_npmUser": {
"name": "jbnicolai",
"email": "jappelman@xebia.com"
},
"dist": {
"shasum": "663b3a648b68b55d04690d49167aa837858f2174",
"tarball": "http://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz"
},
"directories": {},
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -0,0 +1,175 @@
# <img width="300" src="https://cdn.rawgit.com/sindresorhus/chalk/77ae94f63ab1ac61389b190e5a59866569d1a376/logo.svg" alt="chalk">
> Terminal string styling done right
[![Build Status](https://travis-ci.org/sindresorhus/chalk.svg?branch=master)](https://travis-ci.org/sindresorhus/chalk)
![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)
[colors.js](https://github.com/Marak/colors.js) is currently the most popular string styling module, but it has serious deficiencies like extending String.prototype which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
**Chalk is a clean and focused alternative.**
![screenshot](https://github.com/sindresorhus/ansi-styles/raw/master/screenshot.png)
## Why
- Highly performant
- Doesn't extend String.prototype
- Expressive API
- Ability to nest styles
- Clean and focused
- Auto-detects color support
- Actively maintained
- [Used by 1000+ modules](https://npmjs.org/browse/depended/chalk)
## Install
```sh
$ npm install --save chalk
```
## Usage
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
var chalk = require('chalk');
// style a string
console.log( chalk.blue('Hello world!') );
// combine styled and normal strings
console.log( chalk.blue('Hello'), 'World' + chalk.red('!') );
// compose multiple styles using the chainable API
console.log( chalk.blue.bgRed.bold('Hello world!') );
// pass in multiple arguments
console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') );
// nest styles
console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') );
// nest styles of the same type even (color, underline, background)
console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') );
```
Easily define your own themes.
```js
var chalk = require('chalk');
var error = chalk.bold.red;
console.log(error('Error!'));
```
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
```js
var name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> Hello Sindre
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter.
Multiple arguments will be separated by space.
### chalk.enabled
Color support is automatically detected, but you can override it.
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/sindresorhus/supports-color).
Can be overridden by the user with the flags `--color` and `--no-color`.
Used internally and handled for you, but exposed for convenience.
### chalk.styles
Exposes the styles as [ANSI escape codes](https://github.com/sindresorhus/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with yours.
```js
var chalk = require('chalk');
console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'}
console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
```
### chalk.hasColor(string)
Check whether a string [has color](https://github.com/sindresorhus/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/sindresorhus/strip-ansi) from a string.
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
Example:
```js
var chalk = require('chalk');
var styledString = getText();
if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString);
}
```
## Styles
### General
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Text colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@ -24,7 +24,7 @@
"homepage": "https://github.com/isaacs/abbrev-js",
"_id": "abbrev@1.0.5",
"_shasum": "5d8257bd9ebe435e698b2fa431afde4fe7b10b03",
"_from": "abbrev@1.0.x",
"_from": "abbrev@>=1.0.0 <1.1.0",
"_npmVersion": "1.4.7",
"_npmUser": {
"name": "isaacs",

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
{
"name": "async",
"repo": "caolan/async",
"description": "Higher-order functions and common patterns for asynchronous code",
"version": "0.1.23",
"keywords": [],
"dependencies": {},
"development": {},
"main": "lib/async.js",
"scripts": [ "lib/async.js" ]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -82,5 +82,5 @@
"readme": "**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,\nstandard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\nparser written in ECMAScript (also popularly known as\n[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).\nEsprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),\nwith the help of [many contributors](https://github.com/ariya/esprima/contributors).\n\n### Features\n\n- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))\n- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla\n[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)\n- Optional tracking of syntax node location (index-based and line-column)\n- Heavily tested (> 600 [unit tests](http://esprima.org/test/) with solid statement and branch coverage)\n- Experimental support for ES6/Harmony (module, class, destructuring, ...)\n\nEsprima serves as a **building block** for some JavaScript\nlanguage tools, from [code instrumentation](http://esprima.org/demo/functiontrace.html)\nto [editor autocompletion](http://esprima.org/demo/autocomplete.html).\n\nEsprima runs on many popular web browsers, as well as other ECMAScript platforms such as\n[Rhino](http://www.mozilla.org/rhino) and [Node.js](https://npmjs.org/package/esprima).\n\nFor more information, check the web site [esprima.org](http://esprima.org).\n",
"readmeFilename": "README.md",
"_id": "esprima@1.1.1",
"_from": "esprima@~1.1.1"
"_from": "esprima@>=1.1.1 <1.2.0"
}

View File

@ -46,7 +46,7 @@
"shasum": "867a3e8e58a9f84618afb6c2ddbcd916b7cbaf71",
"tarball": "http://registry.npmjs.org/estraverse/-/estraverse-1.5.1.tgz"
},
"_from": "estraverse@~1.5.0",
"_from": "estraverse@>=1.5.0 <1.6.0",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "constellation",

View File

@ -45,5 +45,5 @@
"url": "https://github.com/Constellation/esutils/issues"
},
"_id": "esutils@1.0.0",
"_from": "esutils@~1.0.0"
"_from": "esutils@>=1.0.0 <1.1.0"
}

View File

@ -1,5 +1,26 @@
# Change Log
## 0.1.43
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
#148 for some discussion and issues #150, #151, and #152 for implementations.
## 0.1.42
* Fix an issue where `SourceNode`s from different versions of the source-map
library couldn't be used in conjunction with each other. See issue #142.
## 0.1.41
* Fix a bug with getting the source content of relative sources with a "./"
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
column span of each mapping.
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
all generated positions associated with a given original source and line.
## 0.1.40
* Performance improvements for parsing source maps in SourceMapConsumer.

View File

@ -175,6 +175,11 @@ following attributes:
* `file`: Optional. The generated filename this source map is associated with.
#### SourceMapConsumer.prototype.computeColumnSpans()
Compute the last column for each generated mapping. The last column is
inclusive.
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
Returns the original source, line, and column information for the generated
@ -216,6 +221,22 @@ and an object is returned with the following properties:
* `column`: The column number in the generated source, or null.
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)
Returns all generated line and column information for the original source
and line provided. The only argument is an object with the following
properties:
* `source`: The filename of the original source.
* `line`: The line number in the original source.
and an array of objects is returned, each with the following properties:
* `line`: The line number in the generated source, or null.
* `column`: The column number in the generated source, or null.
#### SourceMapConsumer.prototype.sourceContentFor(source)
Returns the original source content for the source provided. The only
@ -253,6 +274,11 @@ You may pass an object with the following properties:
* `sourceRoot`: A root for all relative URLs in this source map.
* `skipValidation`: Optional. When `true`, disables validation of mappings as
they are added. This can improve performance but should be used with
discretion, as a last resort. Even then, one should avoid using this flag when
running tests, if possible.
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)
Creates a new SourceMapGenerator based on a SourceMapConsumer

View File

@ -66,7 +66,7 @@ define(function (require, exports, module) {
/**
* Converts from a two-complement value to a value where the sign bit is
* is placed in the least significant bit. For example, as decimals:
* placed in the least significant bit. For example, as decimals:
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
*/
@ -78,7 +78,7 @@ define(function (require, exports, module) {
/**
* Converts to a two-complement value from a value where the sign bit is
* is placed in the least significant bit. For example, as decimals:
* placed in the least significant bit. For example, as decimals:
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
*/

View File

@ -23,17 +23,17 @@ define(function (require, exports, module) {
//
// 1. We find the exact element we are looking for.
//
// 2. We did not find the exact element, but we can return the next
// closest element that is less than that element.
// 2. We did not find the exact element, but we can return the index of
// the next closest element that is less than that element.
//
// 3. We did not find the exact element, and there is no next-closest
// element which is less than the one we are searching for, so we
// return null.
// return -1.
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
var cmp = aCompare(aNeedle, aHaystack[mid], true);
if (cmp === 0) {
// Found the element we are looking for.
return aHaystack[mid];
return mid;
}
else if (cmp > 0) {
// aHaystack[mid] is greater than our needle.
@ -43,7 +43,7 @@ define(function (require, exports, module) {
}
// We did not find an exact match, return the next closest one
// (termination case 2).
return aHaystack[mid];
return mid;
}
else {
// aHaystack[mid] is less than our needle.
@ -53,18 +53,16 @@ define(function (require, exports, module) {
}
// The exact needle element was not found in this haystack. Determine if
// we are in termination case (2) or (3) and return the appropriate thing.
return aLow < 0
? null
: aHaystack[aLow];
return aLow < 0 ? -1 : aLow;
}
}
/**
* This is an implementation of binary search which will always try and return
* the next lowest value checked if there is no exact hit. This is because
* mappings between original and generated line/col pairs are single points,
* and there is an implicit region between each of them, so a miss just means
* that you aren't on the very start of a region.
* the index of next lowest value checked if there is no exact hit. This is
* because mappings between original and generated line/col pairs are single
* points, and there is an implicit region between each of them, so a miss
* just means that you aren't on the very start of a region.
*
* @param aNeedle The element you are looking for.
* @param aHaystack The array that is being searched.
@ -73,9 +71,10 @@ define(function (require, exports, module) {
* than, equal to, or greater than the element, respectively.
*/
exports.search = function search(aNeedle, aHaystack, aCompare) {
return aHaystack.length > 0
? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
: null;
if (aHaystack.length === 0) {
return -1;
}
return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
};
});

View File

@ -0,0 +1,86 @@
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2014 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
if (typeof define !== 'function') {
var define = require('amdefine')(module, require);
}
define(function (require, exports, module) {
var util = require('./util');
/**
* Determine whether mappingB is after mappingA with respect to generated
* position.
*/
function generatedPositionAfter(mappingA, mappingB) {
// Optimized for most common case
var lineA = mappingA.generatedLine;
var lineB = mappingB.generatedLine;
var columnA = mappingA.generatedColumn;
var columnB = mappingB.generatedColumn;
return lineB > lineA || lineB == lineA && columnB >= columnA ||
util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
}
/**
* A data structure to provide a sorted view of accumulated mappings in a
* performance conscious manner. It trades a neglibable overhead in general
* case for a large speedup in case of mappings being added in order.
*/
function MappingList() {
this._array = [];
this._sorted = true;
// Serves as infimum
this._last = {generatedLine: -1, generatedColumn: 0};
}
/**
* Iterate through internal items. This method takes the same arguments that
* `Array.prototype.forEach` takes.
*
* NOTE: The order of the mappings is NOT guaranteed.
*/
MappingList.prototype.unsortedForEach =
function MappingList_forEach(aCallback, aThisArg) {
this._array.forEach(aCallback, aThisArg);
};
/**
* Add the given source mapping.
*
* @param Object aMapping
*/
MappingList.prototype.add = function MappingList_add(aMapping) {
var mapping;
if (generatedPositionAfter(this._last, aMapping)) {
this._last = aMapping;
this._array.push(aMapping);
} else {
this._sorted = false;
this._array.push(aMapping);
}
};
/**
* Returns the flat, sorted array of mappings. The mappings are sorted by
* generated position.
*
* WARNING: This method returns internal data without copying, for
* performance. The return value must NOT be mutated, and should be treated as
* an immutable borrow. If you want to take ownership, you must make your own
* copy.
*/
MappingList.prototype.toArray = function MappingList_toArray() {
if (!this._sorted) {
this._array.sort(util.compareByGeneratedPositions);
this._sorted = true;
}
return this._array;
};
exports.MappingList = MappingList;
});

View File

@ -66,6 +66,11 @@ define(function (require, exports, module) {
throw new Error('Unsupported version: ' + version);
}
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
sources = sources.map(util.normalize);
// Pass `true` below to allow duplicate names and sources. While source maps
// are intended to be compressed and deduplicated, the TypeScript compiler
// sometimes generates source maps with duplicates in them. See Github issue
@ -97,9 +102,8 @@ define(function (require, exports, module) {
smc.sourceRoot);
smc.file = aSourceMap._file;
smc.__generatedMappings = aSourceMap._mappings.slice()
.sort(util.compareByGeneratedPositions);
smc.__originalMappings = aSourceMap._mappings.slice()
smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
smc.__originalMappings = aSourceMap._mappings.toArray().slice()
.sort(util.compareByOriginalPositions);
return smc;
@ -290,6 +294,33 @@ define(function (require, exports, module) {
return binarySearch.search(aNeedle, aMappings, aComparator);
};
/**
* Compute the last column for each generated mapping. The last column is
* inclusive.
*/
SourceMapConsumer.prototype.computeColumnSpans =
function SourceMapConsumer_computeColumnSpans() {
for (var index = 0; index < this._generatedMappings.length; ++index) {
var mapping = this._generatedMappings[index];
// Mappings do not contain a field for the last generated columnt. We
// can come up with an optimistic estimate, however, by assuming that
// mappings are contiguous (i.e. given two consecutive mappings, the
// first mapping ends where the second one starts).
if (index + 1 < this._generatedMappings.length) {
var nextMapping = this._generatedMappings[index + 1];
if (mapping.generatedLine === nextMapping.generatedLine) {
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
continue;
}
}
// The last mapping for each line spans the entire line.
mapping.lastGeneratedColumn = Infinity;
}
};
/**
* Returns the original source, line, and column information for the generated
* source's line and column positions provided. The only argument is an object
@ -312,23 +343,27 @@ define(function (require, exports, module) {
generatedColumn: util.getArg(aArgs, 'column')
};
var mapping = this._findMapping(needle,
this._generatedMappings,
"generatedLine",
"generatedColumn",
util.compareByGeneratedPositions);
var index = this._findMapping(needle,
this._generatedMappings,
"generatedLine",
"generatedColumn",
util.compareByGeneratedPositions);
if (mapping && mapping.generatedLine === needle.generatedLine) {
var source = util.getArg(mapping, 'source', null);
if (source != null && this.sourceRoot != null) {
source = util.join(this.sourceRoot, source);
if (index >= 0) {
var mapping = this._generatedMappings[index];
if (mapping.generatedLine === needle.generatedLine) {
var source = util.getArg(mapping, 'source', null);
if (source != null && this.sourceRoot != null) {
source = util.join(this.sourceRoot, source);
}
return {
source: source,
line: util.getArg(mapping, 'originalLine', null),
column: util.getArg(mapping, 'originalColumn', null),
name: util.getArg(mapping, 'name', null)
};
}
return {
source: source,
line: util.getArg(mapping, 'originalLine', null),
column: util.getArg(mapping, 'originalColumn', null),
name: util.getArg(mapping, 'name', null)
};
}
return {
@ -406,25 +441,82 @@ define(function (require, exports, module) {
needle.source = util.relative(this.sourceRoot, needle.source);
}
var mapping = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
var index = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
if (index >= 0) {
var mapping = this._originalMappings[index];
if (mapping) {
return {
line: util.getArg(mapping, 'generatedLine', null),
column: util.getArg(mapping, 'generatedColumn', null)
column: util.getArg(mapping, 'generatedColumn', null),
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
};
}
return {
line: null,
column: null
column: null,
lastColumn: null
};
};
/**
* Returns all generated line and column information for the original source
* and line provided. The only argument is an object with the following
* properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
*
* and an array of objects is returned, each with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
SourceMapConsumer.prototype.allGeneratedPositionsFor =
function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
// When there is no exact match, SourceMapConsumer.prototype._findMapping
// returns the index of the closest mapping less than the needle. By
// setting needle.originalColumn to Infinity, we thus find the last
// mapping for the given line, provided such a mapping exists.
var needle = {
source: util.getArg(aArgs, 'source'),
originalLine: util.getArg(aArgs, 'line'),
originalColumn: Infinity
};
if (this.sourceRoot != null) {
needle.source = util.relative(this.sourceRoot, needle.source);
}
var mappings = [];
var index = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
if (index >= 0) {
var mapping = this._originalMappings[index];
while (mapping && mapping.originalLine === needle.originalLine) {
mappings.push({
line: util.getArg(mapping, 'generatedLine', null),
column: util.getArg(mapping, 'generatedColumn', null),
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
});
mapping = this._originalMappings[--index];
}
}
return mappings.reverse();
};
SourceMapConsumer.GENERATED_ORDER = 1;
SourceMapConsumer.ORIGINAL_ORDER = 2;

View File

@ -12,6 +12,7 @@ define(function (require, exports, module) {
var base64VLQ = require('./base64-vlq');
var util = require('./util');
var ArraySet = require('./array-set').ArraySet;
var MappingList = require('./mapping-list').MappingList;
/**
* An instance of the SourceMapGenerator represents a source map which is
@ -27,9 +28,10 @@ define(function (require, exports, module) {
}
this._file = util.getArg(aArgs, 'file', null);
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
this._sources = new ArraySet();
this._names = new ArraySet();
this._mappings = [];
this._mappings = new MappingList();
this._sourcesContents = null;
}
@ -99,7 +101,9 @@ define(function (require, exports, module) {
var source = util.getArg(aArgs, 'source', null);
var name = util.getArg(aArgs, 'name', null);
this._validateMapping(generated, original, source, name);
if (!this._skipValidation) {
this._validateMapping(generated, original, source, name);
}
if (source != null && !this._sources.has(source)) {
this._sources.add(source);
@ -109,7 +113,7 @@ define(function (require, exports, module) {
this._names.add(name);
}
this._mappings.push({
this._mappings.add({
generatedLine: generated.line,
generatedColumn: generated.column,
originalLine: original != null && original.line,
@ -186,7 +190,7 @@ define(function (require, exports, module) {
var newNames = new ArraySet();
// Find mappings for the "sourceFile"
this._mappings.forEach(function (mapping) {
this._mappings.unsortedForEach(function (mapping) {
if (mapping.source === sourceFile && mapping.originalLine != null) {
// Check if it can be mapped by the source map, then update the mapping.
var original = aSourceMapConsumer.originalPositionFor({
@ -292,15 +296,10 @@ define(function (require, exports, module) {
var result = '';
var mapping;
// The mappings must be guaranteed to be in sorted order before we start
// serializing them or else the generated line numbers (which are defined
// via the ';' separators) will be all messed up. Note: it might be more
// performant to maintain the sorting as we insert them, rather than as we
// serialize them, but the big O is the same either way.
this._mappings.sort(util.compareByGeneratedPositions);
var mappings = this._mappings.toArray();
for (var i = 0, len = this._mappings.length; i < len; i++) {
mapping = this._mappings[i];
for (var i = 0, len = mappings.length; i < len; i++) {
mapping = mappings[i];
if (mapping.generatedLine !== previousGeneratedLine) {
previousGeneratedColumn = 0;
@ -311,7 +310,7 @@ define(function (require, exports, module) {
}
else {
if (i > 0) {
if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
continue;
}
result += ',';

View File

@ -16,8 +16,13 @@ define(function (require, exports, module) {
// operating systems these days (capturing the result).
var REGEX_NEWLINE = /(\r?\n)/;
// Matches a Windows-style newline, or any character.
var REGEX_CHARACTER = /\r\n|[\s\S]/g;
// Newline character code for charCodeAt() comparisons
var NEWLINE_CODE = 10;
// Private symbol for identifying `SourceNode`s when multiple versions of
// the source-map library are loaded. This MUST NOT CHANGE across
// versions!
var isSourceNode = "$$$isSourceNode$$$";
/**
* SourceNodes provide a way to abstract over interpolating/concatenating
@ -38,6 +43,7 @@ define(function (require, exports, module) {
this.column = aColumn == null ? null : aColumn;
this.source = aSource == null ? null : aSource;
this.name = aName == null ? null : aName;
this[isSourceNode] = true;
if (aChunks != null) this.add(aChunks);
}
@ -168,7 +174,7 @@ define(function (require, exports, module) {
this.add(chunk);
}, this);
}
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
if (aChunk) {
this.children.push(aChunk);
}
@ -193,7 +199,7 @@ define(function (require, exports, module) {
this.prepend(aChunk[i]);
}
}
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
this.children.unshift(aChunk);
}
else {
@ -215,7 +221,7 @@ define(function (require, exports, module) {
var chunk;
for (var i = 0, len = this.children.length; i < len; i++) {
chunk = this.children[i];
if (chunk instanceof SourceNode) {
if (chunk[isSourceNode]) {
chunk.walk(aFn);
}
else {
@ -260,7 +266,7 @@ define(function (require, exports, module) {
*/
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
var lastChild = this.children[this.children.length - 1];
if (lastChild instanceof SourceNode) {
if (lastChild[isSourceNode]) {
lastChild.replaceRight(aPattern, aReplacement);
}
else if (typeof lastChild === 'string') {
@ -293,7 +299,7 @@ define(function (require, exports, module) {
SourceNode.prototype.walkSourceContents =
function SourceNode_walkSourceContents(aFn) {
for (var i = 0, len = this.children.length; i < len; i++) {
if (this.children[i] instanceof SourceNode) {
if (this.children[i][isSourceNode]) {
this.children[i].walkSourceContents(aFn);
}
}
@ -369,12 +375,12 @@ define(function (require, exports, module) {
lastOriginalSource = null;
sourceMappingActive = false;
}
chunk.match(REGEX_CHARACTER).forEach(function (ch, idx, array) {
if (REGEX_NEWLINE.test(ch)) {
for (var idx = 0, length = chunk.length; idx < length; idx++) {
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
generated.line++;
generated.column = 0;
// Mappings end at eol
if (idx + 1 === array.length) {
if (idx + 1 === length) {
lastOriginalSource = null;
sourceMappingActive = false;
} else if (sourceMappingActive) {
@ -392,9 +398,9 @@ define(function (require, exports, module) {
});
}
} else {
generated.column += ch.length;
generated.column++;
}
});
}
});
this.walkSourceContents(function (sourceFile, sourceContent) {
map.setSourceContent(sourceFile, sourceContent);

View File

@ -1,7 +1,7 @@
{
"name": "source-map",
"description": "Generates and consumes source maps",
"version": "0.1.40",
"version": "0.1.43",
"homepage": "https://github.com/mozilla/source-map",
"author": {
"name": "Nick Fitzgerald",
@ -107,6 +107,22 @@
{
"name": "Chris Montgomery",
"email": "christopher.montgomery@dowjones.com"
},
{
"name": "J. Ryan Stinnett",
"email": "jryans@gmail.com"
},
{
"name": "Jack Herrington",
"email": "jherrington@walmartlabs.com"
},
{
"name": "Chris Truter",
"email": "jeffpalentine@gmail.com"
},
{
"name": "Daniel Espeset",
"email": "daniel@danielespeset.com"
}
],
"repository": {
@ -139,9 +155,9 @@
"bugs": {
"url": "https://github.com/mozilla/source-map/issues"
},
"_id": "source-map@0.1.40",
"_shasum": "7e0ee49ec0452aa9ac2b93ad5ae54ef33e82b37f",
"_from": "source-map@~0.1.33",
"_id": "source-map@0.1.43",
"_shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346",
"_from": "source-map@>=0.1.33 <0.2.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "nickfitzgerald",
@ -162,9 +178,9 @@
}
],
"dist": {
"shasum": "7e0ee49ec0452aa9ac2b93ad5ae54ef33e82b37f",
"tarball": "http://registry.npmjs.org/source-map/-/source-map-0.1.40.tgz"
"shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346",
"tarball": "http://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz"
},
"_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.40.tgz",
"_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -23,7 +23,7 @@ define(function (require, exports, module) {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(binarySearch.search(needle, haystack, numberCompare), 20);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 20);
};
exports['test too low'] = function (assert, util) {
@ -34,21 +34,21 @@ define(function (require, exports, module) {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(binarySearch.search(needle, haystack, numberCompare), null);
assert.equal(binarySearch.search(needle, haystack, numberCompare), -1);
};
exports['test exact search'] = function (assert, util) {
var needle = 4;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(binarySearch.search(needle, haystack, numberCompare), 4);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 4);
};
exports['test fuzzy search'] = function (assert, util) {
var needle = 19;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(binarySearch.search(needle, haystack, numberCompare), 18);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 18);
};
});

View File

@ -252,6 +252,25 @@ define(function (require, exports, module) {
}, Error);
};
exports['test that we can get the original source content with relative source paths'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMapRelativeSources);
var sources = map.sources;
assert.equal(map.sourceContentFor(sources[0]), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor(sources[1]), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.equal(map.sourceContentFor("one.js"), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor("two.js"), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.throws(function () {
map.sourceContentFor("");
}, Error);
assert.throws(function () {
map.sourceContentFor("/the/root/three.js");
}, Error);
assert.throws(function () {
map.sourceContentFor("three.js");
}, Error);
};
exports['test sourceRoot + generatedPositionFor'] = function (assert, util) {
var map = new SourceMapGenerator({
sourceRoot: 'foo/bar',
@ -290,6 +309,158 @@ define(function (require, exports, module) {
assert.equal(pos.column, 2);
};
exports['test allGeneratedPositionsFor'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 2, column: 1 },
generated: { line: 3, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 2, column: 2 },
generated: { line: 3, column: 3 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 4, column: 2 },
source: 'bar.coffee'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 2);
assert.equal(mappings[0].line, 3);
assert.equal(mappings[0].column, 2);
assert.equal(mappings[1].line, 3);
assert.equal(mappings[1].column, 3);
};
exports['test allGeneratedPositionsFor for line with no mappings'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 4, column: 2 },
source: 'bar.coffee'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 0);
};
exports['test allGeneratedPositionsFor source map with no mappings'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 0);
};
exports['test computeColumnSpans'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 1, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 1 },
generated: { line: 2, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 2 },
generated: { line: 2, column: 10 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 3 },
generated: { line: 2, column: 20 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 3, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 3, column: 2 },
generated: { line: 3, column: 2 },
source: 'foo.coffee'
});
map = new SourceMapConsumer(map.toString());
map.computeColumnSpans();
var mappings = map.allGeneratedPositionsFor({
line: 1,
source: 'foo.coffee'
});
assert.equal(mappings.length, 1);
assert.equal(mappings[0].lastColumn, Infinity);
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'foo.coffee'
});
assert.equal(mappings.length, 3);
assert.equal(mappings[0].lastColumn, 9);
assert.equal(mappings[1].lastColumn, 19);
assert.equal(mappings[2].lastColumn, Infinity);
var mappings = map.allGeneratedPositionsFor({
line: 3,
source: 'foo.coffee'
});
assert.equal(mappings.length, 2);
assert.equal(mappings[0].lastColumn, 1);
assert.equal(mappings[1].lastColumn, Infinity);
};
exports['test sourceRoot + originalPositionFor'] = function (assert, util) {
var map = new SourceMapGenerator({
sourceRoot: 'foo/bar',

View File

@ -98,6 +98,27 @@ define(function (require, exports, module) {
});
};
exports['test adding mappings with skipValidation'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated-foo.js',
sourceRoot: '.',
skipValidation: true
});
// Not enough info, caught by `util.getArgs`
assert.throws(function () {
map.addMapping({});
});
// Original file position, but no source. Not checked.
assert.doesNotThrow(function () {
map.addMapping({
generated: { line: 1, column: 1 },
original: { line: 1, column: 1 }
});
});
};
exports['test that the correct mappings are being generated'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'min.js',

View File

@ -71,6 +71,22 @@ define(function (require, exports, module) {
sourceRoot: '/the/root',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
exports.testMapRelativeSources = {
version: 3,
file: 'min.js',
names: ['bar', 'baz', 'n'],
sources: ['./one.js', './two.js'],
sourcesContent: [
' ONE.foo = function (bar) {\n' +
' return baz(bar);\n' +
' };',
' TWO.inc = function (n) {\n' +
' return n + 1;\n' +
' };'
],
sourceRoot: '/the/root',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
exports.emptyMap = {
version: 3,
file: 'min.js',

View File

@ -65,7 +65,7 @@
"shasum": "f024016f5a88e046fd12005055e939802e6c5f23",
"tarball": "http://registry.npmjs.org/escodegen/-/escodegen-1.3.3.tgz"
},
"_from": "escodegen@1.3.x",
"_from": "escodegen@>=1.3.0 <1.4.0",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "constellation",

View File

@ -1260,7 +1260,7 @@ parseStatement: true, parseSourceElement: true */
}
return collectRegex();
}
if (prevToken.type === 'Keyword') {
if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
return collectRegex();
}
return scanPunctuator();
@ -3724,7 +3724,7 @@ parseStatement: true, parseSourceElement: true */
}
// Sync with *.json manifests.
exports.version = '1.2.2';
exports.version = '1.2.3';
exports.tokenize = tokenize;

View File

@ -7,7 +7,7 @@
"esparse": "./bin/esparse.js",
"esvalidate": "./bin/esvalidate.js"
},
"version": "1.2.2",
"version": "1.2.3",
"files": [
"bin",
"test/run.js",
@ -67,7 +67,7 @@
"lint": "npm run-script check-version && npm run-script eslint && npm run-script jscs && npm run-script jslint",
"check-version": "node tools/check-version.js",
"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
"jscs": "node node_modules/.bin/jscs esprima.js",
"jscs": "node node_modules/jscs/bin/jscs esprima.js",
"jslint": "node node_modules/jslint/bin/jslint.js esprima.js",
"coverage": "npm run-script analyze-coverage && npm run-script check-coverage",
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
@ -78,19 +78,19 @@
"benchmark": "node test/benchmarks.js",
"benchmark-quick": "node test/benchmarks.js quick"
},
"_id": "esprima@1.2.2",
"_id": "esprima@1.2.3",
"dist": {
"shasum": "76a0fd66fcfe154fd292667dc264019750b1657b",
"tarball": "http://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz"
"shasum": "173c9c28d0ec7753afb977b6b21b3017367aac1b",
"tarball": "http://registry.npmjs.org/esprima/-/esprima-1.2.3.tgz"
},
"_from": "esprima@1.2.x",
"_from": "esprima@>=1.2.0 <1.3.0",
"_npmVersion": "1.4.3",
"_npmUser": {
"name": "ariya",
"email": "ariya.hidayat@gmail.com"
},
"directories": {},
"_shasum": "76a0fd66fcfe154fd292667dc264019750b1657b",
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz",
"_shasum": "173c9c28d0ec7753afb977b6b21b3017367aac1b",
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.3.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -21840,8 +21840,82 @@ var testFixture = {
lineNumber: 1,
column: 8,
message: 'Error: Line 1: Invalid regular expression: missing /'
}
},
'this / 100;': [
{
"type": "Keyword",
"value": "this",
"range": [
0,
4
],
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 4
}
}
},
{
"type": "Punctuator",
"value": "/",
"range": [
5,
6
],
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
}
}
},
{
"type": "Numeric",
"value": "100",
"range": [
7,
10
],
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 10
}
}
},
{
"type": "Punctuator",
"value": ";",
"range": [
10,
11
],
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
}
}
]
},
'API': {

View File

@ -29,5 +29,5 @@
},
"homepage": "https://github.com/isaacs/inherits",
"_id": "inherits@2.0.1",
"_from": "inherits@2"
"_from": "inherits@>=2.0.0 <3.0.0"
}

View File

@ -29,5 +29,5 @@
},
"homepage": "https://github.com/isaacs/node-lru-cache",
"_id": "lru-cache@2.5.0",
"_from": "lru-cache@2"
"_from": "lru-cache@>=2.0.0 <3.0.0"
}

View File

@ -38,5 +38,5 @@
},
"homepage": "https://github.com/isaacs/sigmund",
"_id": "sigmund@1.0.0",
"_from": "sigmund@~1.0.0"
"_from": "sigmund@>=1.0.0 <1.1.0"
}

View File

@ -35,7 +35,7 @@
"homepage": "https://github.com/isaacs/minimatch",
"_id": "minimatch@0.3.0",
"_shasum": "275d8edaac4f1bb3326472089e7949c8394699dd",
"_from": "minimatch@0.3",
"_from": "minimatch@>=0.3.0 <0.4.0",
"_npmVersion": "1.4.10",
"_npmUser": {
"name": "isaacs",

View File

@ -36,7 +36,7 @@
"homepage": "https://github.com/isaacs/node-glob",
"_id": "glob@3.2.11",
"_shasum": "4a973f635b9190f715d10987d5c00fd2815ebe3d",
"_from": "glob@3.x",
"_from": "glob@>=3.0.0 <4.0.0",
"_npmVersion": "1.4.10",
"_npmUser": {
"name": "isaacs",

View File

@ -29,5 +29,5 @@
},
"homepage": "https://github.com/isaacs/node-lru-cache",
"_id": "lru-cache@2.5.0",
"_from": "lru-cache@2"
"_from": "lru-cache@>=2.0.0 <3.0.0"
}

View File

@ -38,5 +38,5 @@
},
"homepage": "https://github.com/isaacs/sigmund",
"_id": "sigmund@1.0.0",
"_from": "sigmund@~1.0.0"
"_from": "sigmund@>=1.0.0 <1.1.0"
}

View File

@ -36,7 +36,7 @@
"homepage": "https://github.com/isaacs/minimatch",
"_id": "minimatch@0.4.0",
"_shasum": "bd2c7d060d2c8c8fd7cde7f1f2ed2d5b270fdb1b",
"_from": "minimatch@0.x",
"_from": "minimatch@>=0.0.0 <1.0.0",
"_npmVersion": "1.5.0-alpha-1",
"_npmUser": {
"name": "isaacs",

View File

@ -30,5 +30,5 @@
"url": "https://github.com/mklabs/node-fileset/issues"
},
"_id": "fileset@0.1.5",
"_from": "fileset@0.1.x"
"_from": "fileset@>=0.1.0 <0.2.0"
}

View File

@ -42,5 +42,5 @@
},
"homepage": "https://github.com/substack/node-optimist",
"_id": "optimist@0.3.7",
"_from": "optimist@~0.3"
"_from": "optimist@>=0.3.0 <0.4.0"
}

View File

@ -39,5 +39,5 @@
"readmeFilename": "README.md",
"homepage": "https://github.com/caolan/async",
"_id": "async@0.2.10",
"_from": "async@~0.2.6"
"_from": "async@>=0.2.6 <0.3.0"
}

View File

@ -1,5 +1,26 @@
# Change Log
## 0.1.43
* Performance improvements for `SourceMapGenerator` and `SourceNode`. See issue
#148 for some discussion and issues #150, #151, and #152 for implementations.
## 0.1.42
* Fix an issue where `SourceNode`s from different versions of the source-map
library couldn't be used in conjunction with each other. See issue #142.
## 0.1.41
* Fix a bug with getting the source content of relative sources with a "./"
prefix. See issue #145 and [Bug 1090768](bugzil.la/1090768).
* Add the `SourceMapConsumer.prototype.computeColumnSpans` method to compute the
column span of each mapping.
* Add the `SourceMapConsumer.prototype.allGeneratedPositionsFor` method to find
all generated positions associated with a given original source and line.
## 0.1.40
* Performance improvements for parsing source maps in SourceMapConsumer.

View File

@ -175,6 +175,11 @@ following attributes:
* `file`: Optional. The generated filename this source map is associated with.
#### SourceMapConsumer.prototype.computeColumnSpans()
Compute the last column for each generated mapping. The last column is
inclusive.
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
Returns the original source, line, and column information for the generated
@ -216,6 +221,22 @@ and an object is returned with the following properties:
* `column`: The column number in the generated source, or null.
#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)
Returns all generated line and column information for the original source
and line provided. The only argument is an object with the following
properties:
* `source`: The filename of the original source.
* `line`: The line number in the original source.
and an array of objects is returned, each with the following properties:
* `line`: The line number in the generated source, or null.
* `column`: The column number in the generated source, or null.
#### SourceMapConsumer.prototype.sourceContentFor(source)
Returns the original source content for the source provided. The only
@ -253,6 +274,11 @@ You may pass an object with the following properties:
* `sourceRoot`: A root for all relative URLs in this source map.
* `skipValidation`: Optional. When `true`, disables validation of mappings as
they are added. This can improve performance but should be used with
discretion, as a last resort. Even then, one should avoid using this flag when
running tests, if possible.
#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)
Creates a new SourceMapGenerator based on a SourceMapConsumer

View File

@ -66,7 +66,7 @@ define(function (require, exports, module) {
/**
* Converts from a two-complement value to a value where the sign bit is
* is placed in the least significant bit. For example, as decimals:
* placed in the least significant bit. For example, as decimals:
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
*/
@ -78,7 +78,7 @@ define(function (require, exports, module) {
/**
* Converts to a two-complement value from a value where the sign bit is
* is placed in the least significant bit. For example, as decimals:
* placed in the least significant bit. For example, as decimals:
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
*/

View File

@ -23,17 +23,17 @@ define(function (require, exports, module) {
//
// 1. We find the exact element we are looking for.
//
// 2. We did not find the exact element, but we can return the next
// closest element that is less than that element.
// 2. We did not find the exact element, but we can return the index of
// the next closest element that is less than that element.
//
// 3. We did not find the exact element, and there is no next-closest
// element which is less than the one we are searching for, so we
// return null.
// return -1.
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
var cmp = aCompare(aNeedle, aHaystack[mid], true);
if (cmp === 0) {
// Found the element we are looking for.
return aHaystack[mid];
return mid;
}
else if (cmp > 0) {
// aHaystack[mid] is greater than our needle.
@ -43,7 +43,7 @@ define(function (require, exports, module) {
}
// We did not find an exact match, return the next closest one
// (termination case 2).
return aHaystack[mid];
return mid;
}
else {
// aHaystack[mid] is less than our needle.
@ -53,18 +53,16 @@ define(function (require, exports, module) {
}
// The exact needle element was not found in this haystack. Determine if
// we are in termination case (2) or (3) and return the appropriate thing.
return aLow < 0
? null
: aHaystack[aLow];
return aLow < 0 ? -1 : aLow;
}
}
/**
* This is an implementation of binary search which will always try and return
* the next lowest value checked if there is no exact hit. This is because
* mappings between original and generated line/col pairs are single points,
* and there is an implicit region between each of them, so a miss just means
* that you aren't on the very start of a region.
* the index of next lowest value checked if there is no exact hit. This is
* because mappings between original and generated line/col pairs are single
* points, and there is an implicit region between each of them, so a miss
* just means that you aren't on the very start of a region.
*
* @param aNeedle The element you are looking for.
* @param aHaystack The array that is being searched.
@ -73,9 +71,10 @@ define(function (require, exports, module) {
* than, equal to, or greater than the element, respectively.
*/
exports.search = function search(aNeedle, aHaystack, aCompare) {
return aHaystack.length > 0
? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
: null;
if (aHaystack.length === 0) {
return -1;
}
return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
};
});

View File

@ -0,0 +1,86 @@
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2014 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
* http://opensource.org/licenses/BSD-3-Clause
*/
if (typeof define !== 'function') {
var define = require('amdefine')(module, require);
}
define(function (require, exports, module) {
var util = require('./util');
/**
* Determine whether mappingB is after mappingA with respect to generated
* position.
*/
function generatedPositionAfter(mappingA, mappingB) {
// Optimized for most common case
var lineA = mappingA.generatedLine;
var lineB = mappingB.generatedLine;
var columnA = mappingA.generatedColumn;
var columnB = mappingB.generatedColumn;
return lineB > lineA || lineB == lineA && columnB >= columnA ||
util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
}
/**
* A data structure to provide a sorted view of accumulated mappings in a
* performance conscious manner. It trades a neglibable overhead in general
* case for a large speedup in case of mappings being added in order.
*/
function MappingList() {
this._array = [];
this._sorted = true;
// Serves as infimum
this._last = {generatedLine: -1, generatedColumn: 0};
}
/**
* Iterate through internal items. This method takes the same arguments that
* `Array.prototype.forEach` takes.
*
* NOTE: The order of the mappings is NOT guaranteed.
*/
MappingList.prototype.unsortedForEach =
function MappingList_forEach(aCallback, aThisArg) {
this._array.forEach(aCallback, aThisArg);
};
/**
* Add the given source mapping.
*
* @param Object aMapping
*/
MappingList.prototype.add = function MappingList_add(aMapping) {
var mapping;
if (generatedPositionAfter(this._last, aMapping)) {
this._last = aMapping;
this._array.push(aMapping);
} else {
this._sorted = false;
this._array.push(aMapping);
}
};
/**
* Returns the flat, sorted array of mappings. The mappings are sorted by
* generated position.
*
* WARNING: This method returns internal data without copying, for
* performance. The return value must NOT be mutated, and should be treated as
* an immutable borrow. If you want to take ownership, you must make your own
* copy.
*/
MappingList.prototype.toArray = function MappingList_toArray() {
if (!this._sorted) {
this._array.sort(util.compareByGeneratedPositions);
this._sorted = true;
}
return this._array;
};
exports.MappingList = MappingList;
});

View File

@ -66,6 +66,11 @@ define(function (require, exports, module) {
throw new Error('Unsupported version: ' + version);
}
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
sources = sources.map(util.normalize);
// Pass `true` below to allow duplicate names and sources. While source maps
// are intended to be compressed and deduplicated, the TypeScript compiler
// sometimes generates source maps with duplicates in them. See Github issue
@ -97,9 +102,8 @@ define(function (require, exports, module) {
smc.sourceRoot);
smc.file = aSourceMap._file;
smc.__generatedMappings = aSourceMap._mappings.slice()
.sort(util.compareByGeneratedPositions);
smc.__originalMappings = aSourceMap._mappings.slice()
smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
smc.__originalMappings = aSourceMap._mappings.toArray().slice()
.sort(util.compareByOriginalPositions);
return smc;
@ -290,6 +294,33 @@ define(function (require, exports, module) {
return binarySearch.search(aNeedle, aMappings, aComparator);
};
/**
* Compute the last column for each generated mapping. The last column is
* inclusive.
*/
SourceMapConsumer.prototype.computeColumnSpans =
function SourceMapConsumer_computeColumnSpans() {
for (var index = 0; index < this._generatedMappings.length; ++index) {
var mapping = this._generatedMappings[index];
// Mappings do not contain a field for the last generated columnt. We
// can come up with an optimistic estimate, however, by assuming that
// mappings are contiguous (i.e. given two consecutive mappings, the
// first mapping ends where the second one starts).
if (index + 1 < this._generatedMappings.length) {
var nextMapping = this._generatedMappings[index + 1];
if (mapping.generatedLine === nextMapping.generatedLine) {
mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
continue;
}
}
// The last mapping for each line spans the entire line.
mapping.lastGeneratedColumn = Infinity;
}
};
/**
* Returns the original source, line, and column information for the generated
* source's line and column positions provided. The only argument is an object
@ -312,23 +343,27 @@ define(function (require, exports, module) {
generatedColumn: util.getArg(aArgs, 'column')
};
var mapping = this._findMapping(needle,
this._generatedMappings,
"generatedLine",
"generatedColumn",
util.compareByGeneratedPositions);
var index = this._findMapping(needle,
this._generatedMappings,
"generatedLine",
"generatedColumn",
util.compareByGeneratedPositions);
if (mapping && mapping.generatedLine === needle.generatedLine) {
var source = util.getArg(mapping, 'source', null);
if (source != null && this.sourceRoot != null) {
source = util.join(this.sourceRoot, source);
if (index >= 0) {
var mapping = this._generatedMappings[index];
if (mapping.generatedLine === needle.generatedLine) {
var source = util.getArg(mapping, 'source', null);
if (source != null && this.sourceRoot != null) {
source = util.join(this.sourceRoot, source);
}
return {
source: source,
line: util.getArg(mapping, 'originalLine', null),
column: util.getArg(mapping, 'originalColumn', null),
name: util.getArg(mapping, 'name', null)
};
}
return {
source: source,
line: util.getArg(mapping, 'originalLine', null),
column: util.getArg(mapping, 'originalColumn', null),
name: util.getArg(mapping, 'name', null)
};
}
return {
@ -406,25 +441,82 @@ define(function (require, exports, module) {
needle.source = util.relative(this.sourceRoot, needle.source);
}
var mapping = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
var index = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
if (index >= 0) {
var mapping = this._originalMappings[index];
if (mapping) {
return {
line: util.getArg(mapping, 'generatedLine', null),
column: util.getArg(mapping, 'generatedColumn', null)
column: util.getArg(mapping, 'generatedColumn', null),
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
};
}
return {
line: null,
column: null
column: null,
lastColumn: null
};
};
/**
* Returns all generated line and column information for the original source
* and line provided. The only argument is an object with the following
* properties:
*
* - source: The filename of the original source.
* - line: The line number in the original source.
*
* and an array of objects is returned, each with the following properties:
*
* - line: The line number in the generated source, or null.
* - column: The column number in the generated source, or null.
*/
SourceMapConsumer.prototype.allGeneratedPositionsFor =
function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
// When there is no exact match, SourceMapConsumer.prototype._findMapping
// returns the index of the closest mapping less than the needle. By
// setting needle.originalColumn to Infinity, we thus find the last
// mapping for the given line, provided such a mapping exists.
var needle = {
source: util.getArg(aArgs, 'source'),
originalLine: util.getArg(aArgs, 'line'),
originalColumn: Infinity
};
if (this.sourceRoot != null) {
needle.source = util.relative(this.sourceRoot, needle.source);
}
var mappings = [];
var index = this._findMapping(needle,
this._originalMappings,
"originalLine",
"originalColumn",
util.compareByOriginalPositions);
if (index >= 0) {
var mapping = this._originalMappings[index];
while (mapping && mapping.originalLine === needle.originalLine) {
mappings.push({
line: util.getArg(mapping, 'generatedLine', null),
column: util.getArg(mapping, 'generatedColumn', null),
lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
});
mapping = this._originalMappings[--index];
}
}
return mappings.reverse();
};
SourceMapConsumer.GENERATED_ORDER = 1;
SourceMapConsumer.ORIGINAL_ORDER = 2;

View File

@ -12,6 +12,7 @@ define(function (require, exports, module) {
var base64VLQ = require('./base64-vlq');
var util = require('./util');
var ArraySet = require('./array-set').ArraySet;
var MappingList = require('./mapping-list').MappingList;
/**
* An instance of the SourceMapGenerator represents a source map which is
@ -27,9 +28,10 @@ define(function (require, exports, module) {
}
this._file = util.getArg(aArgs, 'file', null);
this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
this._sources = new ArraySet();
this._names = new ArraySet();
this._mappings = [];
this._mappings = new MappingList();
this._sourcesContents = null;
}
@ -99,7 +101,9 @@ define(function (require, exports, module) {
var source = util.getArg(aArgs, 'source', null);
var name = util.getArg(aArgs, 'name', null);
this._validateMapping(generated, original, source, name);
if (!this._skipValidation) {
this._validateMapping(generated, original, source, name);
}
if (source != null && !this._sources.has(source)) {
this._sources.add(source);
@ -109,7 +113,7 @@ define(function (require, exports, module) {
this._names.add(name);
}
this._mappings.push({
this._mappings.add({
generatedLine: generated.line,
generatedColumn: generated.column,
originalLine: original != null && original.line,
@ -186,7 +190,7 @@ define(function (require, exports, module) {
var newNames = new ArraySet();
// Find mappings for the "sourceFile"
this._mappings.forEach(function (mapping) {
this._mappings.unsortedForEach(function (mapping) {
if (mapping.source === sourceFile && mapping.originalLine != null) {
// Check if it can be mapped by the source map, then update the mapping.
var original = aSourceMapConsumer.originalPositionFor({
@ -292,15 +296,10 @@ define(function (require, exports, module) {
var result = '';
var mapping;
// The mappings must be guaranteed to be in sorted order before we start
// serializing them or else the generated line numbers (which are defined
// via the ';' separators) will be all messed up. Note: it might be more
// performant to maintain the sorting as we insert them, rather than as we
// serialize them, but the big O is the same either way.
this._mappings.sort(util.compareByGeneratedPositions);
var mappings = this._mappings.toArray();
for (var i = 0, len = this._mappings.length; i < len; i++) {
mapping = this._mappings[i];
for (var i = 0, len = mappings.length; i < len; i++) {
mapping = mappings[i];
if (mapping.generatedLine !== previousGeneratedLine) {
previousGeneratedColumn = 0;
@ -311,7 +310,7 @@ define(function (require, exports, module) {
}
else {
if (i > 0) {
if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
continue;
}
result += ',';

View File

@ -16,8 +16,13 @@ define(function (require, exports, module) {
// operating systems these days (capturing the result).
var REGEX_NEWLINE = /(\r?\n)/;
// Matches a Windows-style newline, or any character.
var REGEX_CHARACTER = /\r\n|[\s\S]/g;
// Newline character code for charCodeAt() comparisons
var NEWLINE_CODE = 10;
// Private symbol for identifying `SourceNode`s when multiple versions of
// the source-map library are loaded. This MUST NOT CHANGE across
// versions!
var isSourceNode = "$$$isSourceNode$$$";
/**
* SourceNodes provide a way to abstract over interpolating/concatenating
@ -38,6 +43,7 @@ define(function (require, exports, module) {
this.column = aColumn == null ? null : aColumn;
this.source = aSource == null ? null : aSource;
this.name = aName == null ? null : aName;
this[isSourceNode] = true;
if (aChunks != null) this.add(aChunks);
}
@ -168,7 +174,7 @@ define(function (require, exports, module) {
this.add(chunk);
}, this);
}
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
if (aChunk) {
this.children.push(aChunk);
}
@ -193,7 +199,7 @@ define(function (require, exports, module) {
this.prepend(aChunk[i]);
}
}
else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
else if (aChunk[isSourceNode] || typeof aChunk === "string") {
this.children.unshift(aChunk);
}
else {
@ -215,7 +221,7 @@ define(function (require, exports, module) {
var chunk;
for (var i = 0, len = this.children.length; i < len; i++) {
chunk = this.children[i];
if (chunk instanceof SourceNode) {
if (chunk[isSourceNode]) {
chunk.walk(aFn);
}
else {
@ -260,7 +266,7 @@ define(function (require, exports, module) {
*/
SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
var lastChild = this.children[this.children.length - 1];
if (lastChild instanceof SourceNode) {
if (lastChild[isSourceNode]) {
lastChild.replaceRight(aPattern, aReplacement);
}
else if (typeof lastChild === 'string') {
@ -293,7 +299,7 @@ define(function (require, exports, module) {
SourceNode.prototype.walkSourceContents =
function SourceNode_walkSourceContents(aFn) {
for (var i = 0, len = this.children.length; i < len; i++) {
if (this.children[i] instanceof SourceNode) {
if (this.children[i][isSourceNode]) {
this.children[i].walkSourceContents(aFn);
}
}
@ -369,12 +375,12 @@ define(function (require, exports, module) {
lastOriginalSource = null;
sourceMappingActive = false;
}
chunk.match(REGEX_CHARACTER).forEach(function (ch, idx, array) {
if (REGEX_NEWLINE.test(ch)) {
for (var idx = 0, length = chunk.length; idx < length; idx++) {
if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
generated.line++;
generated.column = 0;
// Mappings end at eol
if (idx + 1 === array.length) {
if (idx + 1 === length) {
lastOriginalSource = null;
sourceMappingActive = false;
} else if (sourceMappingActive) {
@ -392,9 +398,9 @@ define(function (require, exports, module) {
});
}
} else {
generated.column += ch.length;
generated.column++;
}
});
}
});
this.walkSourceContents(function (sourceFile, sourceContent) {
map.setSourceContent(sourceFile, sourceContent);

View File

@ -1,7 +1,7 @@
{
"name": "source-map",
"description": "Generates and consumes source maps",
"version": "0.1.40",
"version": "0.1.43",
"homepage": "https://github.com/mozilla/source-map",
"author": {
"name": "Nick Fitzgerald",
@ -107,6 +107,22 @@
{
"name": "Chris Montgomery",
"email": "christopher.montgomery@dowjones.com"
},
{
"name": "J. Ryan Stinnett",
"email": "jryans@gmail.com"
},
{
"name": "Jack Herrington",
"email": "jherrington@walmartlabs.com"
},
{
"name": "Chris Truter",
"email": "jeffpalentine@gmail.com"
},
{
"name": "Daniel Espeset",
"email": "daniel@danielespeset.com"
}
],
"repository": {
@ -139,9 +155,9 @@
"bugs": {
"url": "https://github.com/mozilla/source-map/issues"
},
"_id": "source-map@0.1.40",
"_shasum": "7e0ee49ec0452aa9ac2b93ad5ae54ef33e82b37f",
"_from": "source-map@~0.1.7",
"_id": "source-map@0.1.43",
"_shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346",
"_from": "source-map@>=0.1.7 <0.2.0",
"_npmVersion": "1.4.9",
"_npmUser": {
"name": "nickfitzgerald",
@ -162,9 +178,9 @@
}
],
"dist": {
"shasum": "7e0ee49ec0452aa9ac2b93ad5ae54ef33e82b37f",
"tarball": "http://registry.npmjs.org/source-map/-/source-map-0.1.40.tgz"
"shasum": "c24bc146ca517c1471f5dacbe2571b2b7f9e3346",
"tarball": "http://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz"
},
"_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.40.tgz",
"_resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz",
"readme": "ERROR: No README data found!"
}

View File

@ -23,7 +23,7 @@ define(function (require, exports, module) {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(binarySearch.search(needle, haystack, numberCompare), 20);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 20);
};
exports['test too low'] = function (assert, util) {
@ -34,21 +34,21 @@ define(function (require, exports, module) {
binarySearch.search(needle, haystack, numberCompare);
});
assert.equal(binarySearch.search(needle, haystack, numberCompare), null);
assert.equal(binarySearch.search(needle, haystack, numberCompare), -1);
};
exports['test exact search'] = function (assert, util) {
var needle = 4;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(binarySearch.search(needle, haystack, numberCompare), 4);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 4);
};
exports['test fuzzy search'] = function (assert, util) {
var needle = 19;
var haystack = [2,4,6,8,10,12,14,16,18,20];
assert.equal(binarySearch.search(needle, haystack, numberCompare), 18);
assert.equal(haystack[binarySearch.search(needle, haystack, numberCompare)], 18);
};
});

View File

@ -252,6 +252,25 @@ define(function (require, exports, module) {
}, Error);
};
exports['test that we can get the original source content with relative source paths'] = function (assert, util) {
var map = new SourceMapConsumer(util.testMapRelativeSources);
var sources = map.sources;
assert.equal(map.sourceContentFor(sources[0]), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor(sources[1]), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.equal(map.sourceContentFor("one.js"), ' ONE.foo = function (bar) {\n return baz(bar);\n };');
assert.equal(map.sourceContentFor("two.js"), ' TWO.inc = function (n) {\n return n + 1;\n };');
assert.throws(function () {
map.sourceContentFor("");
}, Error);
assert.throws(function () {
map.sourceContentFor("/the/root/three.js");
}, Error);
assert.throws(function () {
map.sourceContentFor("three.js");
}, Error);
};
exports['test sourceRoot + generatedPositionFor'] = function (assert, util) {
var map = new SourceMapGenerator({
sourceRoot: 'foo/bar',
@ -290,6 +309,158 @@ define(function (require, exports, module) {
assert.equal(pos.column, 2);
};
exports['test allGeneratedPositionsFor'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 2, column: 1 },
generated: { line: 3, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 2, column: 2 },
generated: { line: 3, column: 3 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 4, column: 2 },
source: 'bar.coffee'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 2);
assert.equal(mappings[0].line, 3);
assert.equal(mappings[0].column, 2);
assert.equal(mappings[1].line, 3);
assert.equal(mappings[1].column, 3);
};
exports['test allGeneratedPositionsFor for line with no mappings'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 2, column: 2 },
source: 'bar.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 4, column: 2 },
source: 'bar.coffee'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 0);
};
exports['test allGeneratedPositionsFor source map with no mappings'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map = new SourceMapConsumer(map.toString());
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'bar.coffee'
});
assert.equal(mappings.length, 0);
};
exports['test computeColumnSpans'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated.js'
});
map.addMapping({
original: { line: 1, column: 1 },
generated: { line: 1, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 1 },
generated: { line: 2, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 2 },
generated: { line: 2, column: 10 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 2, column: 3 },
generated: { line: 2, column: 20 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 3, column: 1 },
generated: { line: 3, column: 1 },
source: 'foo.coffee'
});
map.addMapping({
original: { line: 3, column: 2 },
generated: { line: 3, column: 2 },
source: 'foo.coffee'
});
map = new SourceMapConsumer(map.toString());
map.computeColumnSpans();
var mappings = map.allGeneratedPositionsFor({
line: 1,
source: 'foo.coffee'
});
assert.equal(mappings.length, 1);
assert.equal(mappings[0].lastColumn, Infinity);
var mappings = map.allGeneratedPositionsFor({
line: 2,
source: 'foo.coffee'
});
assert.equal(mappings.length, 3);
assert.equal(mappings[0].lastColumn, 9);
assert.equal(mappings[1].lastColumn, 19);
assert.equal(mappings[2].lastColumn, Infinity);
var mappings = map.allGeneratedPositionsFor({
line: 3,
source: 'foo.coffee'
});
assert.equal(mappings.length, 2);
assert.equal(mappings[0].lastColumn, 1);
assert.equal(mappings[1].lastColumn, Infinity);
};
exports['test sourceRoot + originalPositionFor'] = function (assert, util) {
var map = new SourceMapGenerator({
sourceRoot: 'foo/bar',

View File

@ -98,6 +98,27 @@ define(function (require, exports, module) {
});
};
exports['test adding mappings with skipValidation'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'generated-foo.js',
sourceRoot: '.',
skipValidation: true
});
// Not enough info, caught by `util.getArgs`
assert.throws(function () {
map.addMapping({});
});
// Original file position, but no source. Not checked.
assert.doesNotThrow(function () {
map.addMapping({
generated: { line: 1, column: 1 },
original: { line: 1, column: 1 }
});
});
};
exports['test that the correct mappings are being generated'] = function (assert, util) {
var map = new SourceMapGenerator({
file: 'min.js',

View File

@ -71,6 +71,22 @@ define(function (require, exports, module) {
sourceRoot: '/the/root',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
exports.testMapRelativeSources = {
version: 3,
file: 'min.js',
names: ['bar', 'baz', 'n'],
sources: ['./one.js', './two.js'],
sourcesContent: [
' ONE.foo = function (bar) {\n' +
' return baz(bar);\n' +
' };',
' TWO.inc = function (n) {\n' +
' return n + 1;\n' +
' };'
],
sourceRoot: '/the/root',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
exports.emptyMap = {
version: 3,
file: 'min.js',

View File

@ -35,5 +35,5 @@
"url": "https://github.com/mishoo/UglifyJS2/issues"
},
"_id": "uglify-js@2.3.6",
"_from": "uglify-js@~2.3"
"_from": "uglify-js@>=2.3.0 <2.4.0"
}

View File

@ -68,7 +68,7 @@
"shasum": "9e9b130a93e389491322d975cf3ec1818c37ce34",
"tarball": "http://registry.npmjs.org/handlebars/-/handlebars-1.3.0.tgz"
},
"_from": "handlebars@1.3.x",
"_from": "handlebars@>=1.3.0 <1.4.0",
"_npmVersion": "1.3.11",
"_npmUser": {
"name": "kpdecker",

View File

@ -1,3 +1,17 @@
3.2.5 / 2014-12-28
------------------
- Fixed resolving of all built-in types on empty nodes.
- Fixed invalid warning on empty lines within quoted scalars and flow collections.
- Fixed bug: Tag on an empty node didn't resolve in some cases.
3.2.4 / 2014-12-19
------------------
- Fixed resolving of !!null tag on an empty node.
3.2.3 / 2014-11-08
------------------

View File

@ -1,4 +1,4 @@
/* js-yaml 3.2.3 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/* js-yaml 3.2.5 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
@ -1026,15 +1026,15 @@ function skipSeparationSpace(state, allowComments, checkIndent) {
state.lineIndent++;
ch = state.input.charCodeAt(++state.position);
}
if (state.lineIndent < checkIndent) {
throwWarning(state, 'deficient indentation');
}
} else {
break;
}
}
if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
throwWarning(state, 'deficient indentation');
}
return lineBreaks;
}
@ -1930,8 +1930,8 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
var allowBlockStyles,
allowBlockScalars,
allowBlockCollections,
indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
atNewLine = false,
isIndented = true,
hasContent = false,
typeIndex,
typeQuantity,
@ -1953,33 +1953,28 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
if (skipSeparationSpace(state, true, -1)) {
atNewLine = true;
if (state.lineIndent === parentIndent) {
isIndented = false;
} else if (state.lineIndent > parentIndent) {
isIndented = true;
} else {
return false;
if (state.lineIndent > parentIndent) {
indentStatus = 1;
} else if (state.lineIndent === parentIndent) {
indentStatus = 0;
} else if (state.lineIndent < parentIndent) {
indentStatus = -1;
}
}
}
if (isIndented) {
if (1 === indentStatus) {
while (readTagProperty(state) || readAnchorProperty(state)) {
if (skipSeparationSpace(state, true, -1)) {
atNewLine = true;
allowBlockCollections = allowBlockStyles;
if (state.lineIndent > parentIndent) {
isIndented = true;
allowBlockCollections = allowBlockStyles;
indentStatus = 1;
} else if (state.lineIndent === parentIndent) {
isIndented = false;
allowBlockCollections = allowBlockStyles;
} else {
return true;
indentStatus = 0;
} else if (state.lineIndent < parentIndent) {
indentStatus = -1;
}
} else {
allowBlockCollections = false;
@ -1991,7 +1986,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
allowBlockCollections = atNewLine || allowCompact;
}
if (isIndented || CONTEXT_BLOCK_OUT === nodeContext) {
if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
flowIndent = parentIndent;
} else {
@ -2000,7 +1995,7 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
blockIndent = state.position - state.lineStart;
if (isIndented) {
if (1 === indentStatus) {
if (allowBlockCollections &&
(readBlockSequence(state, blockIndent) ||
readBlockMapping(state, blockIndent, flowIndent)) ||
@ -2031,7 +2026,9 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
state.anchorMap[state.anchor] = state.result;
}
}
} else {
} else if (0 === indentStatus) {
// Special case: block sequences are allowed to have same indentation level as the parent.
// http://www.yaml.org/spec/1.2/spec.html#id2799784
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
}
}
@ -2646,6 +2643,10 @@ var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
function resolveYamlBinary(data) {
if (null === data) {
return false;
}
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
// Convert one by one.
@ -2768,6 +2769,10 @@ module.exports = new Type('tag:yaml.org,2002:binary', {
var Type = require('../type');
function resolveYamlBoolean(data) {
if (null === data) {
return false;
}
var max = data.length;
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
@ -2811,6 +2816,10 @@ var YAML_FLOAT_PATTERN = new RegExp(
'|\\.(?:nan|NaN|NAN))$');
function resolveYamlFloat(data) {
if (null === data) {
return false;
}
var value, sign, base, digits;
if (!YAML_FLOAT_PATTERN.test(data)) {
@ -2926,6 +2935,10 @@ function isDecCode(c) {
}
function resolveYamlInteger(data) {
if (null === data) {
return false;
}
var max = data.length,
index = 0,
hasDigits = false,
@ -3108,6 +3121,10 @@ try {
var Type = require('../../type');
function resolveJavascriptFunction(data) {
if (null === data) {
return false;
}
try {
var source = '(' + data + ')',
ast = esprima.parse(source, { range: true }),
@ -3175,6 +3192,14 @@ module.exports = new Type('tag:yaml.org,2002:js/function', {
var Type = require('../../type');
function resolveJavascriptRegExp(data) {
if (null === data) {
return false;
}
if (0 === data.length) {
return false;
}
var regexp = data,
tail = /\/([gim]*)$/.exec(data),
modifiers = '';
@ -3282,7 +3307,8 @@ module.exports = new Type('tag:yaml.org,2002:js/undefined', {
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:map', {
kind: 'mapping'
kind: 'mapping',
construct: function (data) { return null !== data ? data : {}; }
});
},{"../type":13}],22:[function(require,module,exports){
@ -3291,12 +3317,12 @@ module.exports = new Type('tag:yaml.org,2002:map', {
var Type = require('../type');
function resolveYamlMerge(data) {
return '<<' === data;
return '<<' === data || null === data;
}
module.exports = new Type('tag:yaml.org,2002:merge', {
kind: 'scalar',
resolve: resolveYamlMerge,
resolve: resolveYamlMerge
});
},{"../type":13}],23:[function(require,module,exports){
@ -3305,6 +3331,10 @@ module.exports = new Type('tag:yaml.org,2002:merge', {
var Type = require('../type');
function resolveYamlNull(data) {
if (null === data) {
return true;
}
var max = data.length;
return (max === 1 && data === '~') ||
@ -3342,6 +3372,10 @@ var _hasOwnProperty = Object.prototype.hasOwnProperty;
var _toString = Object.prototype.toString;
function resolveYamlOmap(data) {
if (null === data) {
return true;
}
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
object = data;
@ -3377,9 +3411,14 @@ function resolveYamlOmap(data) {
return true;
}
function constructYamlOmap(data) {
return null !== data ? data : [];
}
module.exports = new Type('tag:yaml.org,2002:omap', {
kind: 'sequence',
resolve: resolveYamlOmap
resolve: resolveYamlOmap,
construct: constructYamlOmap
});
},{"../type":13}],25:[function(require,module,exports){
@ -3390,6 +3429,10 @@ var Type = require('../type');
var _toString = Object.prototype.toString;
function resolveYamlPairs(data) {
if (null === data) {
return true;
}
var index, length, pair, keys, result,
object = data;
@ -3415,6 +3458,10 @@ function resolveYamlPairs(data) {
}
function constructYamlPairs(data) {
if (null === data) {
return [];
}
var index, length, pair, keys, result,
object = data;
@ -3443,7 +3490,8 @@ module.exports = new Type('tag:yaml.org,2002:pairs', {
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:seq', {
kind: 'sequence'
kind: 'sequence',
construct: function (data) { return null !== data ? data : []; }
});
},{"../type":13}],27:[function(require,module,exports){
@ -3454,6 +3502,10 @@ var Type = require('../type');
var _hasOwnProperty = Object.prototype.hasOwnProperty;
function resolveYamlSet(data) {
if (null === data) {
return true;
}
var key, object = data;
for (key in object) {
@ -3467,9 +3519,14 @@ function resolveYamlSet(data) {
return true;
}
function constructYamlSet(data) {
return null !== data ? data : {};
}
module.exports = new Type('tag:yaml.org,2002:set', {
kind: 'mapping',
resolve: resolveYamlSet
resolve: resolveYamlSet,
construct: constructYamlSet
});
},{"../type":13}],28:[function(require,module,exports){
@ -3478,7 +3535,8 @@ module.exports = new Type('tag:yaml.org,2002:set', {
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:str', {
kind: 'scalar'
kind: 'scalar',
construct: function (data) { return null !== data ? data : ''; }
});
},{"../type":13}],29:[function(require,module,exports){
@ -3499,6 +3557,10 @@ var YAML_TIMESTAMP_REGEXP = new RegExp(
'(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
function resolveYamlTimestamp(data) {
if (null === data) {
return false;
}
var match, year, month, day, hour, minute, second, fraction = 0,
delta = null, tz_hour, tz_minute, date;

Some files were not shown because too many files have changed in this diff Show More