'use strict'; var toStr = Object.prototype.toString; var isPrimitive = require('./helpers/isPrimitive'); var isCallable = require('is-callable'); // http://ecma-international.org/ecma-262/5.1/#sec-8.12.8 var ES5internalSlots = { '[[DefaultValue]]': function (O) { var actualHint; if (arguments.length > 1) { actualHint = arguments[1]; } else { actualHint = toStr.call(O) === '[object Date]' ? String : Number; } if (actualHint === String || actualHint === Number) { var methods = actualHint === String ? ['toString', 'valueOf'] : ['valueOf', 'toString']; var value, i; for (i = 0; i < methods.length; ++i) { if (isCallable(O[methods[i]])) { value = O[methods[i]](); if (isPrimitive(value)) { return value; } } } throw new TypeError('No default value'); } throw new TypeError('invalid [[DefaultValue]] hint supplied'); } }; // http://ecma-international.org/ecma-262/5.1/#sec-9.1 module.exports = function ToPrimitive(input) { if (isPrimitive(input)) { return input; } if (arguments.length > 1) { return ES5internalSlots['[[DefaultValue]]'](input, arguments[1]); } return ES5internalSlots['[[DefaultValue]]'](input); };
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
helpers | Folder | 0755 |
|
|
.editorconfig | File | 286 B | 0644 |
|
.jscs.json | File | 4.03 KB | 0644 |
|
.travis.yml | File | 7.03 KB | 0644 |
|
CHANGELOG.md | File | 1.63 KB | 0644 |
|
LICENSE | File | 1.06 KB | 0644 |
|
Makefile | File | 3.74 KB | 0644 |
|
README.md | File | 2.07 KB | 0644 |
|
es2015.js | File | 2.09 KB | 0644 |
|
es5.js | File | 1.17 KB | 0644 |
|
es6.js | File | 53 B | 0644 |
|
index.js | File | 454 B | 0644 |
|
package.json | File | 1.97 KB | 0644 |
|