119 lines
4.4 KiB
JavaScript
119 lines
4.4 KiB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.returnExports = f()}})(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(_dereq_,module,exports){
|
|
/**
|
|
* @file ES6 abstract ToString with Symbol conversion support.
|
|
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tostring|7.1.12 ToString ( argument )}
|
|
* @version 1.0.0
|
|
* @author Xotic750 <Xotic750@gmail.com>
|
|
* @copyright Xotic750
|
|
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
|
* @module to-string-symbols-supported-x
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var castString = _dereq_('cached-constructors-x').String;
|
|
var pToString = _dereq_('has-symbol-support-x') && Symbol.prototype.toString;
|
|
var isSymbol = typeof pToString === 'function' && _dereq_('is-symbol');
|
|
|
|
/**
|
|
* The abstract operation ToString converts argument to a value of type String,
|
|
* however the specification states that if the argument is a Symbol then a
|
|
* 'TypeError' is thrown. This version also allows Symbols be converted to
|
|
* a string. Other uncoercible exotics will still throw though.
|
|
*
|
|
* @param {*} value - The value to convert to a string.
|
|
* @returns {string} The converted value.
|
|
* @example
|
|
* var toStringSymbolsSupported = require('to-string-symbols-supported-x');
|
|
*
|
|
* toStringSymbolsSupported(); // 'undefined'
|
|
* toStringSymbolsSupported(null); // 'null'
|
|
* toStringSymbolsSupported('abc'); // 'abc'
|
|
* toStringSymbolsSupported(true); // 'true'
|
|
* toStringSymbolsSupported(Symbol('foo')); // 'Symbol('foo')'
|
|
* toStringSymbolsSupported(Object(Symbol('foo'))); // 'Symbol('foo')'
|
|
* toStringSymbolsSupported(Object.create(null)); // TypeError
|
|
*/
|
|
module.exports = function toStringSymbolsSupported(value) {
|
|
return isSymbol && isSymbol(value) ? pToString.call(value) : castString(value);
|
|
};
|
|
|
|
},{"cached-constructors-x":2,"has-symbol-support-x":3,"is-symbol":4}],2:[function(_dereq_,module,exports){
|
|
/**
|
|
* @file Constructors cached from literals.
|
|
* @version 1.0.0
|
|
* @author Xotic750 <Xotic750@gmail.com>
|
|
* @copyright Xotic750
|
|
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
|
* @module cached-constructors-x
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Constructors cached from literals.
|
|
*
|
|
* @type Object
|
|
* @example
|
|
* var constructors = require('cached-constructors-x');
|
|
*/
|
|
module.exports = {
|
|
Array: [].constructor,
|
|
Boolean: true.constructor,
|
|
Number: (0).constructor,
|
|
Object: {}.constructor,
|
|
RegExp: (/(?:)/).constructor,
|
|
String: ''.constructor
|
|
};
|
|
|
|
},{}],3:[function(_dereq_,module,exports){
|
|
/**
|
|
* @file Tests if ES6 Symbol is supported.
|
|
* @version 1.4.1
|
|
* @author Xotic750 <Xotic750@gmail.com>
|
|
* @copyright Xotic750
|
|
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
|
* @module has-symbol-support-x
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Indicates if `Symbol`exists and creates the correct type.
|
|
* `true`, if it exists and creates the correct type, otherwise `false`.
|
|
*
|
|
* @type boolean
|
|
*/
|
|
module.exports = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
|
|
|
},{}],4:[function(_dereq_,module,exports){
|
|
'use strict';
|
|
|
|
var toStr = Object.prototype.toString;
|
|
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
|
|
|
|
if (hasSymbols) {
|
|
var symToStr = Symbol.prototype.toString;
|
|
var symStringRegex = /^Symbol\(.*\)$/;
|
|
var isSymbolObject = function isSymbolObject(value) {
|
|
if (typeof value.valueOf() !== 'symbol') { return false; }
|
|
return symStringRegex.test(symToStr.call(value));
|
|
};
|
|
module.exports = function isSymbol(value) {
|
|
if (typeof value === 'symbol') { return true; }
|
|
if (toStr.call(value) !== '[object Symbol]') { return false; }
|
|
try {
|
|
return isSymbolObject(value);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
} else {
|
|
module.exports = function isSymbol(value) {
|
|
// this environment does not support Symbols.
|
|
return false;
|
|
};
|
|
}
|
|
|
|
},{}]},{},[1])(1)
|
|
}); |