Projekt

Obecné

Profil

Stáhnout (656 Bajtů) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
var GetIntrinsic = require('../GetIntrinsic');
4

    
5
var $TypeError = GetIntrinsic('%TypeError%');
6

    
7
var SameValue = require('./SameValue');
8
var ToNumber = require('./ToNumber');
9
var ToString = require('./ToString');
10
var Type = require('./Type');
11

    
12
// https://ecma-international.org/ecma-262/6.0/#sec-canonicalnumericindexstring
13

    
14
module.exports = function CanonicalNumericIndexString(argument) {
15
	if (Type(argument) !== 'String') {
16
		throw new $TypeError('Assertion failed: `argument` must be a String');
17
	}
18
	if (argument === '-0') { return -0; }
19
	var n = ToNumber(argument);
20
	if (SameValue(ToString(n), argument)) { return n; }
21
	return void 0;
22
};
(5-5/117)