MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / tameLocaleMethods

Function tameLocaleMethods

ses.cjs:5074–5109  ·  view source on GitHub ↗
(intrinsics, localeTaming=  'safe')

Source from the content-addressed store, hash-verified

5072const numberToString= tamedMethods.toString;
5073
5074function tameLocaleMethods(intrinsics, localeTaming= 'safe') {
5075 if( localeTaming!== 'safe'&& localeTaming!== 'unsafe') {
5076 throw TypeError( `unrecognized localeTaming ${localeTaming}`);
5077 }
5078 if( localeTaming=== 'unsafe') {
5079 return;
5080 }
5081
5082 defineProperty(String.prototype, 'localeCompare', {
5083 value: nonLocaleCompare});
5084
5085
5086 for( const intrinsicName of getOwnPropertyNames(intrinsics)) {
5087 const intrinsic= intrinsics[intrinsicName];
5088 if( isObject(intrinsic)) {
5089 for( const methodName of getOwnPropertyNames(intrinsic)) {
5090 const match= regexpExec(localePattern, methodName);
5091 if( match) {
5092 typeof intrinsic[methodName]=== 'function'||
5093 Fail `expected ${q(methodName)} to be a function`;
5094 const nonLocaleMethodName= `${match[1]}${match[2]}`;
5095 const method= intrinsic[nonLocaleMethodName];
5096 typeof method=== 'function'||
5097 Fail `function ${q(nonLocaleMethodName)} not found`;
5098 defineProperty(intrinsic, methodName, { value: method});
5099 }
5100 }
5101 }
5102 }
5103
5104 // Numbers are special because toString accepts a radix instead of ignoring
5105 // all of the arguments that we would otherwise forward.
5106 defineProperty(Number.prototype, 'toLocaleString', {
5107 value: numberToString});
5108
5109 }$h‍_once.default( tameLocaleMethods);
5110})()
5111,
5112// === functors[20] ===

Callers 1

repairIntrinsicsFunction · 0.85

Calls 3

definePropertyFunction · 0.85
FailFunction · 0.85
isObjectFunction · 0.70

Tested by

no test coverage detected