source: imaps-frontend/node_modules/es-abstract/2020/StringGetOwnProperty.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
[79a0317]5var callBound = require('call-bound');
[d565449]6var $charAt = callBound('String.prototype.charAt');
7var $stringToString = callBound('String.prototype.toString');
8
9var CanonicalNumericIndexString = require('./CanonicalNumericIndexString');
10var IsInteger = require('./IsInteger');
11
[79a0317]12var isObject = require('../helpers/isObject');
13var isPropertyKey = require('../helpers/isPropertyKey');
14
15var isNegativeZero = require('math-intrinsics/isNegativeZero');
[d565449]16
17// https://262.ecma-international.org/8.0/#sec-stringgetownproperty
18
19module.exports = function StringGetOwnProperty(S, P) {
20 var str;
[79a0317]21 if (isObject(S)) {
[d565449]22 try {
23 str = $stringToString(S);
24 } catch (e) { /**/ }
25 }
26 if (typeof str !== 'string') {
27 throw new $TypeError('Assertion failed: `S` must be a boxed string object');
28 }
[79a0317]29 if (!isPropertyKey(P)) {
30 throw new $TypeError('Assertion failed: P is not a Property Key');
[d565449]31 }
32 if (typeof P !== 'string') {
33 return void undefined;
34 }
35 var index = CanonicalNumericIndexString(P);
36 var len = str.length;
37 if (typeof index === 'undefined' || !IsInteger(index) || isNegativeZero(index) || index < 0 || len <= index) {
38 return void undefined;
39 }
40 var resultStr = $charAt(S, index);
41 return {
42 '[[Configurable]]': false,
43 '[[Enumerable]]': true,
44 '[[Value]]': resultStr,
45 '[[Writable]]': false
46 };
47};
Note: See TracBrowser for help on using the repository browser.