react / wstein / node_modules / browserify / node_modules / readable-stream / node_modules / core-util-is / float.patch
80542 viewsdiff --git a/lib/util.js b/lib/util.js1index a03e874..9074e8e 1006442--- a/lib/util.js3+++ b/lib/util.js4@@ -19,430 +19,6 @@5// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE6// USE OR OTHER DEALINGS IN THE SOFTWARE.78-var formatRegExp = /%[sdj%]/g;9-exports.format = function(f) {10- if (!isString(f)) {11- var objects = [];12- for (var i = 0; i < arguments.length; i++) {13- objects.push(inspect(arguments[i]));14- }15- return objects.join(' ');16- }17-18- var i = 1;19- var args = arguments;20- var len = args.length;21- var str = String(f).replace(formatRegExp, function(x) {22- if (x === '%%') return '%';23- if (i >= len) return x;24- switch (x) {25- case '%s': return String(args[i++]);26- case '%d': return Number(args[i++]);27- case '%j':28- try {29- return JSON.stringify(args[i++]);30- } catch (_) {31- return '[Circular]';32- }33- default:34- return x;35- }36- });37- for (var x = args[i]; i < len; x = args[++i]) {38- if (isNull(x) || !isObject(x)) {39- str += ' ' + x;40- } else {41- str += ' ' + inspect(x);42- }43- }44- return str;45-};46-47-48-// Mark that a method should not be used.49-// Returns a modified function which warns once by default.50-// If --no-deprecation is set, then it is a no-op.51-exports.deprecate = function(fn, msg) {52- // Allow for deprecating things in the process of starting up.53- if (isUndefined(global.process)) {54- return function() {55- return exports.deprecate(fn, msg).apply(this, arguments);56- };57- }58-59- if (process.noDeprecation === true) {60- return fn;61- }62-63- var warned = false;64- function deprecated() {65- if (!warned) {66- if (process.throwDeprecation) {67- throw new Error(msg);68- } else if (process.traceDeprecation) {69- console.trace(msg);70- } else {71- console.error(msg);72- }73- warned = true;74- }75- return fn.apply(this, arguments);76- }77-78- return deprecated;79-};80-81-82-var debugs = {};83-var debugEnviron;84-exports.debuglog = function(set) {85- if (isUndefined(debugEnviron))86- debugEnviron = process.env.NODE_DEBUG || '';87- set = set.toUpperCase();88- if (!debugs[set]) {89- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {90- var pid = process.pid;91- debugs[set] = function() {92- var msg = exports.format.apply(exports, arguments);93- console.error('%s %d: %s', set, pid, msg);94- };95- } else {96- debugs[set] = function() {};97- }98- }99- return debugs[set];100-};101-102-103-/**104- * Echos the value of a value. Trys to print the value out105- * in the best way possible given the different types.106- *107- * @param {Object} obj The object to print out.108- * @param {Object} opts Optional options object that alters the output.109- */110-/* legacy: obj, showHidden, depth, colors*/111-function inspect(obj, opts) {112- // default options113- var ctx = {114- seen: [],115- stylize: stylizeNoColor116- };117- // legacy...118- if (arguments.length >= 3) ctx.depth = arguments[2];119- if (arguments.length >= 4) ctx.colors = arguments[3];120- if (isBoolean(opts)) {121- // legacy...122- ctx.showHidden = opts;123- } else if (opts) {124- // got an "options" object125- exports._extend(ctx, opts);126- }127- // set default options128- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;129- if (isUndefined(ctx.depth)) ctx.depth = 2;130- if (isUndefined(ctx.colors)) ctx.colors = false;131- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;132- if (ctx.colors) ctx.stylize = stylizeWithColor;133- return formatValue(ctx, obj, ctx.depth);134-}135-exports.inspect = inspect;136-137-138-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics139-inspect.colors = {140- 'bold' : [1, 22],141- 'italic' : [3, 23],142- 'underline' : [4, 24],143- 'inverse' : [7, 27],144- 'white' : [37, 39],145- 'grey' : [90, 39],146- 'black' : [30, 39],147- 'blue' : [34, 39],148- 'cyan' : [36, 39],149- 'green' : [32, 39],150- 'magenta' : [35, 39],151- 'red' : [31, 39],152- 'yellow' : [33, 39]153-};154-155-// Don't use 'blue' not visible on cmd.exe156-inspect.styles = {157- 'special': 'cyan',158- 'number': 'yellow',159- 'boolean': 'yellow',160- 'undefined': 'grey',161- 'null': 'bold',162- 'string': 'green',163- 'date': 'magenta',164- // "name": intentionally not styling165- 'regexp': 'red'166-};167-168-169-function stylizeWithColor(str, styleType) {170- var style = inspect.styles[styleType];171-172- if (style) {173- return '\u001b[' + inspect.colors[style][0] + 'm' + str +174- '\u001b[' + inspect.colors[style][1] + 'm';175- } else {176- return str;177- }178-}179-180-181-function stylizeNoColor(str, styleType) {182- return str;183-}184-185-186-function arrayToHash(array) {187- var hash = {};188-189- array.forEach(function(val, idx) {190- hash[val] = true;191- });192-193- return hash;194-}195-196-197-function formatValue(ctx, value, recurseTimes) {198- // Provide a hook for user-specified inspect functions.199- // Check that value is an object with an inspect function on it200- if (ctx.customInspect &&201- value &&202- isFunction(value.inspect) &&203- // Filter out the util module, it's inspect function is special204- value.inspect !== exports.inspect &&205- // Also filter out any prototype objects using the circular check.206- !(value.constructor && value.constructor.prototype === value)) {207- var ret = value.inspect(recurseTimes, ctx);208- if (!isString(ret)) {209- ret = formatValue(ctx, ret, recurseTimes);210- }211- return ret;212- }213-214- // Primitive types cannot have properties215- var primitive = formatPrimitive(ctx, value);216- if (primitive) {217- return primitive;218- }219-220- // Look up the keys of the object.221- var keys = Object.keys(value);222- var visibleKeys = arrayToHash(keys);223-224- if (ctx.showHidden) {225- keys = Object.getOwnPropertyNames(value);226- }227-228- // Some type of object without properties can be shortcutted.229- if (keys.length === 0) {230- if (isFunction(value)) {231- var name = value.name ? ': ' + value.name : '';232- return ctx.stylize('[Function' + name + ']', 'special');233- }234- if (isRegExp(value)) {235- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');236- }237- if (isDate(value)) {238- return ctx.stylize(Date.prototype.toString.call(value), 'date');239- }240- if (isError(value)) {241- return formatError(value);242- }243- }244-245- var base = '', array = false, braces = ['{', '}'];246-247- // Make Array say that they are Array248- if (isArray(value)) {249- array = true;250- braces = ['[', ']'];251- }252-253- // Make functions say that they are functions254- if (isFunction(value)) {255- var n = value.name ? ': ' + value.name : '';256- base = ' [Function' + n + ']';257- }258-259- // Make RegExps say that they are RegExps260- if (isRegExp(value)) {261- base = ' ' + RegExp.prototype.toString.call(value);262- }263-264- // Make dates with properties first say the date265- if (isDate(value)) {266- base = ' ' + Date.prototype.toUTCString.call(value);267- }268-269- // Make error with message first say the error270- if (isError(value)) {271- base = ' ' + formatError(value);272- }273-274- if (keys.length === 0 && (!array || value.length == 0)) {275- return braces[0] + base + braces[1];276- }277-278- if (recurseTimes < 0) {279- if (isRegExp(value)) {280- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');281- } else {282- return ctx.stylize('[Object]', 'special');283- }284- }285-286- ctx.seen.push(value);287-288- var output;289- if (array) {290- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);291- } else {292- output = keys.map(function(key) {293- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);294- });295- }296-297- ctx.seen.pop();298-299- return reduceToSingleString(output, base, braces);300-}301-302-303-function formatPrimitive(ctx, value) {304- if (isUndefined(value))305- return ctx.stylize('undefined', 'undefined');306- if (isString(value)) {307- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')308- .replace(/'/g, "\\'")309- .replace(/\\"/g, '"') + '\'';310- return ctx.stylize(simple, 'string');311- }312- if (isNumber(value)) {313- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0,314- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .315- if (value === 0 && 1 / value < 0)316- return ctx.stylize('-0', 'number');317- return ctx.stylize('' + value, 'number');318- }319- if (isBoolean(value))320- return ctx.stylize('' + value, 'boolean');321- // For some reason typeof null is "object", so special case here.322- if (isNull(value))323- return ctx.stylize('null', 'null');324-}325-326-327-function formatError(value) {328- return '[' + Error.prototype.toString.call(value) + ']';329-}330-331-332-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {333- var output = [];334- for (var i = 0, l = value.length; i < l; ++i) {335- if (hasOwnProperty(value, String(i))) {336- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,337- String(i), true));338- } else {339- output.push('');340- }341- }342- keys.forEach(function(key) {343- if (!key.match(/^\d+$/)) {344- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,345- key, true));346- }347- });348- return output;349-}350-351-352-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {353- var name, str, desc;354- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };355- if (desc.get) {356- if (desc.set) {357- str = ctx.stylize('[Getter/Setter]', 'special');358- } else {359- str = ctx.stylize('[Getter]', 'special');360- }361- } else {362- if (desc.set) {363- str = ctx.stylize('[Setter]', 'special');364- }365- }366- if (!hasOwnProperty(visibleKeys, key)) {367- name = '[' + key + ']';368- }369- if (!str) {370- if (ctx.seen.indexOf(desc.value) < 0) {371- if (isNull(recurseTimes)) {372- str = formatValue(ctx, desc.value, null);373- } else {374- str = formatValue(ctx, desc.value, recurseTimes - 1);375- }376- if (str.indexOf('\n') > -1) {377- if (array) {378- str = str.split('\n').map(function(line) {379- return ' ' + line;380- }).join('\n').substr(2);381- } else {382- str = '\n' + str.split('\n').map(function(line) {383- return ' ' + line;384- }).join('\n');385- }386- }387- } else {388- str = ctx.stylize('[Circular]', 'special');389- }390- }391- if (isUndefined(name)) {392- if (array && key.match(/^\d+$/)) {393- return str;394- }395- name = JSON.stringify('' + key);396- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {397- name = name.substr(1, name.length - 2);398- name = ctx.stylize(name, 'name');399- } else {400- name = name.replace(/'/g, "\\'")401- .replace(/\\"/g, '"')402- .replace(/(^"|"$)/g, "'");403- name = ctx.stylize(name, 'string');404- }405- }406-407- return name + ': ' + str;408-}409-410-411-function reduceToSingleString(output, base, braces) {412- var numLinesEst = 0;413- var length = output.reduce(function(prev, cur) {414- numLinesEst++;415- if (cur.indexOf('\n') >= 0) numLinesEst++;416- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;417- }, 0);418-419- if (length > 60) {420- return braces[0] +421- (base === '' ? '' : base + '\n ') +422- ' ' +423- output.join(',\n ') +424- ' ' +425- braces[1];426- }427-428- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];429-}430-431-432// NOTE: These type checking functions intentionally don't use `instanceof`433// because it is fragile and can be easily faked with `Object.create()`.434function isArray(ar) {435@@ -522,166 +98,10 @@ function isPrimitive(arg) {436exports.isPrimitive = isPrimitive;437438function isBuffer(arg) {439- return arg instanceof Buffer;440+ return Buffer.isBuffer(arg);441}442exports.isBuffer = isBuffer;443444function objectToString(o) {445return Object.prototype.toString.call(o);446-}447-448-449-function pad(n) {450- return n < 10 ? '0' + n.toString(10) : n.toString(10);451-}452-453-454-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',455- 'Oct', 'Nov', 'Dec'];456-457-// 26 Feb 16:19:34458-function timestamp() {459- var d = new Date();460- var time = [pad(d.getHours()),461- pad(d.getMinutes()),462- pad(d.getSeconds())].join(':');463- return [d.getDate(), months[d.getMonth()], time].join(' ');464-}465-466-467-// log is just a thin wrapper to console.log that prepends a timestamp468-exports.log = function() {469- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));470-};471-472-473-/**474- * Inherit the prototype methods from one constructor into another.475- *476- * The Function.prototype.inherits from lang.js rewritten as a standalone477- * function (not on Function.prototype). NOTE: If this file is to be loaded478- * during bootstrapping this function needs to be rewritten using some native479- * functions as prototype setup using normal JavaScript does not work as480- * expected during bootstrapping (see mirror.js in r114903).481- *482- * @param {function} ctor Constructor function which needs to inherit the483- * prototype.484- * @param {function} superCtor Constructor function to inherit prototype from.485- */486-exports.inherits = function(ctor, superCtor) {487- ctor.super_ = superCtor;488- ctor.prototype = Object.create(superCtor.prototype, {489- constructor: {490- value: ctor,491- enumerable: false,492- writable: true,493- configurable: true494- }495- });496-};497-498-exports._extend = function(origin, add) {499- // Don't do anything if add isn't an object500- if (!add || !isObject(add)) return origin;501-502- var keys = Object.keys(add);503- var i = keys.length;504- while (i--) {505- origin[keys[i]] = add[keys[i]];506- }507- return origin;508-};509-510-function hasOwnProperty(obj, prop) {511- return Object.prototype.hasOwnProperty.call(obj, prop);512-}513-514-515-// Deprecated old stuff.516-517-exports.p = exports.deprecate(function() {518- for (var i = 0, len = arguments.length; i < len; ++i) {519- console.error(exports.inspect(arguments[i]));520- }521-}, 'util.p: Use console.error() instead');522-523-524-exports.exec = exports.deprecate(function() {525- return require('child_process').exec.apply(this, arguments);526-}, 'util.exec is now called `child_process.exec`.');527-528-529-exports.print = exports.deprecate(function() {530- for (var i = 0, len = arguments.length; i < len; ++i) {531- process.stdout.write(String(arguments[i]));532- }533-}, 'util.print: Use console.log instead');534-535-536-exports.puts = exports.deprecate(function() {537- for (var i = 0, len = arguments.length; i < len; ++i) {538- process.stdout.write(arguments[i] + '\n');539- }540-}, 'util.puts: Use console.log instead');541-542-543-exports.debug = exports.deprecate(function(x) {544- process.stderr.write('DEBUG: ' + x + '\n');545-}, 'util.debug: Use console.error instead');546-547-548-exports.error = exports.deprecate(function(x) {549- for (var i = 0, len = arguments.length; i < len; ++i) {550- process.stderr.write(arguments[i] + '\n');551- }552-}, 'util.error: Use console.error instead');553-554-555-exports.pump = exports.deprecate(function(readStream, writeStream, callback) {556- var callbackCalled = false;557-558- function call(a, b, c) {559- if (callback && !callbackCalled) {560- callback(a, b, c);561- callbackCalled = true;562- }563- }564-565- readStream.addListener('data', function(chunk) {566- if (writeStream.write(chunk) === false) readStream.pause();567- });568-569- writeStream.addListener('drain', function() {570- readStream.resume();571- });572-573- readStream.addListener('end', function() {574- writeStream.end();575- });576-577- readStream.addListener('close', function() {578- call();579- });580-581- readStream.addListener('error', function(err) {582- writeStream.end();583- call(err);584- });585-586- writeStream.addListener('error', function(err) {587- readStream.destroy();588- call(err);589- });590-}, 'util.pump(): Use readableStream.pipe() instead');591-592-593-var uv;594-exports._errnoException = function(err, syscall) {595- if (isUndefined(uv)) uv = process.binding('uv');596- var errname = uv.errname(err);597- var e = new Error(syscall + ' ' + errname);598- e.code = errname;599- e.errno = errname;600- e.syscall = syscall;601- return e;602-};603+}604605