-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** @module Provides joke language support for importing JSONP modules. */ | ||
|
||
/** | ||
* @import {ParseFn, ParserImplementation} from '../src/types.js' | ||
*/ | ||
|
||
const textDecoder = new TextDecoder(); | ||
|
||
/** @type {ParseFn} */ | ||
export const parseJsonp = (bytes, _specifier, _location, _packageLocation) => { | ||
// Presumes that all JSONP module bytes are retrieved with ?callback=exports. | ||
const source = textDecoder.decode(bytes); | ||
const imports = harden([]); | ||
|
||
/** | ||
* @param {object} exports | ||
*/ | ||
const execute = exports => { | ||
const compartment = new Compartment({ | ||
__options__: true, | ||
globals: harden({ | ||
exports(value) { | ||
exports.default = value; | ||
}, | ||
}), | ||
}); | ||
compartment.evaluate(source); | ||
}; | ||
return { | ||
parser: 'jsonp', | ||
bytes, | ||
record: harden({ | ||
imports, | ||
exports: ['default'], | ||
execute, | ||
}), | ||
}; | ||
}; | ||
|
||
/** @type {ParserImplementation} */ | ||
export default { | ||
parse: parseJsonp, | ||
heuristicImports: false, | ||
synchronous: true, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.