swc/bundler/tests/.cache/untrusted/adc9d3c33fb74f2e25e896b384ffe58c521e8966.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

46 lines
1.2 KiB
TypeScript

// Loaded from https://cdn.skypack.dev/-/once@v1.4.0-dZva3nt1fLBY6vpXF5Hj/dist=es2020,mode=imports/optimized/once.js
import wrappy2 from "/-/wrappy@v1.0.2-e8nLh7Qms0NRhbAbUpJP/dist=es2020,mode=imports/optimized/wrappy.js";
var once_1 = wrappy2(once);
var strict = wrappy2(onceStrict);
once.proto = once(function() {
Object.defineProperty(Function.prototype, "once", {
value: function() {
return once(this);
},
configurable: true
});
Object.defineProperty(Function.prototype, "onceStrict", {
value: function() {
return onceStrict(this);
},
configurable: true
});
});
function once(fn) {
var f = function() {
if (f.called)
return f.value;
f.called = true;
return f.value = fn.apply(this, arguments);
};
f.called = false;
return f;
}
function onceStrict(fn) {
var f = function() {
if (f.called)
throw new Error(f.onceError);
f.called = true;
return f.value = fn.apply(this, arguments);
};
var name = fn.name || "Function wrapped with `once`";
f.onceError = name + " shouldn't be called more than once";
f.called = false;
return f;
}
once_1.strict = strict;
export default once_1;
export {once_1 as __moduleExports, strict};