prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
41 lines (33 loc) • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _index = require("../../values/index.js");
var _singletons = require("../../singletons.js");
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* strict-local */
function _default(realm) {
// ECMA262 18.2.6.5
let name = "encodeURIComponent";
return new _index.NativeFunctionValue(realm, name, name, 1, (context, [_uriComponent], argCount, NewTarget) => {
let uriComponent = _uriComponent;
if (NewTarget) throw realm.createErrorThrowCompletion(realm.intrinsics.TypeError, `${name} is not a constructor`);
uriComponent = uriComponent.throwIfNotConcrete(); // 1. Let componentString be ? ToString(uri).
let componentString = _singletons.To.ToString(realm, uriComponent); // 2. Let unescapedURIComponentSet be a String containing one instance of each code unit valid in uriUnescaped.
// 3. Return ? Encode(componentString, unescapedURIComponentSet).
try {
return new _index.StringValue(realm, encodeURIComponent(componentString));
} catch (e) {
throw realm.createErrorThrowCompletion(realm.intrinsics.URIError, e.message);
}
});
}
//# sourceMappingURL=encodeURIComponent.js.map