code
stringlengths
28
313k
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
74
language
stringclasses
1 value
repo
stringlengths
5
60
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function runModuleExecutionHooks(module, executeModule) { if (typeof globalThis.$RefreshInterceptModuleExecution$ === 'function') { const cleanupReactRefreshIntercept = globalThis.$RefreshInterceptModuleExecution$(module.id); try { executeModule({ register: globalThis.$Re...
NOTE(alexkirsz) Webpack has a "module execution" interception hook that Next.js' React Refresh runtime hooks into to add module context to the refresh registry.
runModuleExecutionHooks
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function registerExportsAndSetupBoundaryForReactRefresh(module, helpers) { const currentExports = module.exports; const prevExports = module.hot.data.prevExports ?? null; helpers.registerExportsForReactRefresh(currentExports, module.id); // A module can be accepted automatically based on its exports, e....
This is adapted from https://github.com/vercel/next.js/blob/3466862d9dc9c8bb3131712134d38757b918d1c0/packages/react-refresh-utils/internal/ReactRefreshModule.runtime.ts
registerExportsAndSetupBoundaryForReactRefresh
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function updateChunksPhase(chunksAddedModules, chunksDeletedModules) { for (const [chunkPath, addedModuleIds] of chunksAddedModules){ for (const moduleId of addedModuleIds){ addModuleToChunk(moduleId, chunkPath); } } const disposedModules = new Set(); for (const [chunkPath, a...
Adds, deletes, and moves modules between chunks. This must happen before the dispose phase as it needs to know which modules were removed from all chunks, which we can only compute *after* taking care of added and moved modules.
updateChunksPhase
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function disposeModule(moduleId, mode) { const module = devModuleCache[moduleId]; if (!module) { return; } const hotState = moduleHotState.get(module); const data = {}; // Run the `hot.dispose` handler, if any, passing in the persistent // `hot.data` object. for (const disposeHan...
Disposes of an instance of a module. Returns the persistent hot data that should be kept for the next module instance. NOTE: mode = "replace" will not remove modules from the devModuleCache This must be done in a separate step afterwards. This is important because all modules need to be disposed to update the parent/...
disposeModule
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function removeModuleFromChunk(moduleId, chunkPath) { const moduleChunks = moduleChunksMap.get(moduleId); moduleChunks.delete(chunkPath); const chunkModules = chunkModulesMap.get(chunkPath); chunkModules.delete(moduleId); const noRemainingModules = chunkModules.size === 0; if (noRemainingModules...
Removes a module from a chunk. Returns `true` if there are no remaining chunks including this module.
removeModuleFromChunk
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function disposeChunkList(chunkListPath) { const chunkPaths = chunkListChunksMap.get(chunkListPath); if (chunkPaths == null) { return false; } chunkListChunksMap.delete(chunkListPath); for (const chunkPath of chunkPaths){ const chunkChunkLists = chunkChunkListsMap.get(chunkPath); ...
Disposes of a chunk list and its corresponding exclusive chunks.
disposeChunkList
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function disposeChunk(chunkPath) { const chunkUrl = getChunkRelativeUrl(chunkPath); // This should happen whether the chunk has any modules in it or not. // For instance, CSS chunks have no modules in them, but they still need to be unloaded. DEV_BACKEND.unloadChunk?.(chunkUrl); const chunkModules =...
Disposes of a chunk and its corresponding exclusive modules. @returns Whether the chunk was disposed of.
disposeChunk
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function registerChunkList(chunkList) { const chunkListScript = chunkList.script; const chunkListPath = getPathFromScript(chunkListScript); // The "chunk" is also registered to finish the loading in the backend BACKEND.registerChunk(chunkListPath); globalThis.TURBOPACK_CHUNK_UPDATE_LISTENERS.push([ ...
Subscribes to chunk list updates from the update server and applies them.
registerChunkList
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function augmentContext(context) { return context; }
This file contains the runtime code specific to the Turbopack development ECMAScript DOM runtime. It will be appended to the base development runtime code.
augmentContext
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
async registerChunk (chunkPath, params) { const chunkUrl = getChunkRelativeUrl(chunkPath); const resolver = getOrCreateResolver(chunkUrl); resolver.resolve(); if (params == null) { return; } for (const otherChunkData of params.other...
Maps chunk paths to the corresponding resolver.
registerChunk
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
loadChunk (chunkUrl, source) { return doLoadChunk(chunkUrl, source); }
Loads the given chunk, and returns a promise that resolves once the chunk has been loaded.
loadChunk
javascript
vercel/next.js
turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
https://github.com/vercel/next.js/blob/master/turbopack/crates/turbopack-tests/tests/snapshot/runtime/default_dev_runtime/output/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_75df6705.js
MIT
function done(err) { if (!cbCalled) { cb(err); cbCalled = true; } }
This is the exposed module. This method facilitates copying a file. @param {String} fileSrc @param {String} fileDest @param {Function} cb @access public
done
javascript
aws/aws-iot-device-sdk-js
examples/lib/copy-file.js
https://github.com/aws/aws-iot-device-sdk-js/blob/master/examples/lib/copy-file.js
Apache-2.0
Unirest = function (method, uri, headers, body, callback) { var unirest = function (uri, headers, body, callback) { var $this = { /** * Stream Multipart form-data request * * @type {Boolean} */ _stream: false, /** * Container to hold multipart form data for pr...
Initialize our Rest Container @type {Object}
Unirest
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function handleRetriableRequestResponse (result) { // If retries is not defined or all attempts tried, return true to invoke end's callback. if ($this.options.retry === undefined || $this.options.retry.attempts === 0) { return true } // If status code is not listed,...
Sends HTTP Request and awaits Response finalization. Request compression and Response decompression occurs here. Upon HTTP Response post-processing occurs and invokes `callback` with a single argument, the `[Response](#response)` object. @param {Function} callback @return {Object}
handleRetriableRequestResponse
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function handleField (name, value, options) { var serialized var length var key var i options = options || { attachment: false } if (is(name).a(Object)) { for (key in name) { if (Object.prototype.hasOwnProperty.call(name, key)) { handleField(key, name[...
Handles Multipart Field Processing @param {String} name @param {Mixed} value @param {Object} options
handleField
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function handleFieldValue (value) { if (!(value instanceof Buffer || typeof value === 'string')) { if (is(value).a(Object)) { if (value instanceof fs.FileReadStream) { return value } else { return Unirest.serializers.json(value) } } else { ...
Handles Multipart Value Processing @param {Mixed} value
handleFieldValue
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function setupMethod (method) { Unirest[method] = Unirest(method) }
Generate sugar for request library. This allows us to mock super-agent chaining style while using request library under the hood.
setupMethod
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function is (value) { return { a: function (check) { if (check.prototype) check = check.prototype.constructor.name var type = Object.prototype.toString.call(value).slice(8, -1).toLowerCase() return value != null && type === check.toLowerCase() } } }
Simple Utility Methods for checking information about a value. @param {Mixed} value Could be anything. @return {Object}
is
javascript
Kong/unirest-nodejs
index.js
https://github.com/Kong/unirest-nodejs/blob/master/index.js
MIT
function broadcast(data, channel) { for (var client of server.clients) { if (channel ? client.channel === channel : client.channel) { send(data, client) } } }
Sends data to all clients channel: if not null, restricts broadcast to clients in the channel
broadcast
javascript
AndrewBelt/hack.chat
server.js
https://github.com/AndrewBelt/hack.chat/blob/master/server.js
MIT
function Options(data) { this.style = data.style; this.color = data.color; this.size = data.size; this.phantom = data.phantom; this.font = data.font; if (data.parentStyle === undefined) { this.parentStyle = data.style; } else { this.parentStyle = data.parentStyle; } ...
This is the main options class. It contains the style, size, color, and font of the current parse level. It also contains the style and size of the parent parse level, so size changes can be handled efficiently. Each of the `.with*` and `.reset` functions passes its current style and size as the parentStyle and parent...
Options
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
function get(option, defaultValue) { return option === undefined ? defaultValue : option; }
Helper function for getting a default value if the value is undefined
get
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
mathDefault = function(value, mode, color, classes, type) { if (type === "mathord") { return mathit(value, mode, color, classes); } else if (type === "textord") { return makeSymbol( value, "Main-Regular", mode, color, classes.concat(["mathrm"])); } else { throw new Error(...
Makes a symbol in the default font for mathords and textords.
mathDefault
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
buildHTML = function(tree, settings) { // buildExpression is destructive, so we need to make a clone // of the incoming tree so that it isn't accidentally changed tree = JSON.parse(JSON.stringify(tree)); var startStyle = Style.TEXT; if (settings.displayMode) { startStyle = Style.DISPLAY; ...
Take an entire parse tree, and build it into an appropriate set of HTML nodes.
buildHTML
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
getVariant = function(group, options) { var font = options.font; if (!font) { return null; } var mode = group.mode; if (font === "mathit") { return "italic"; } var value = group.value; if (utils.contains(["\\imath", "\\jmath"], value)) { return null; } ...
Returns the math variant as a string or null if none is required.
getVariant
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
buildExpression = function(expression, options) { var groups = []; for (var i = 0; i < expression.length; i++) { var group = expression[i]; groups.push(buildGroup(group, options)); } return groups; }
Takes a list of nodes, builds them, and returns a list of the generated MathML nodes. A little simpler than the HTML version because we don't do any previous-node handling.
buildExpression
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
buildGroup = function(group, options) { if (!group) { return new mathMLTree.MathNode("mrow"); } if (groupTypes[group.type]) { // Call the groupTypes function return groupTypes[group.type](group, options); } else { throw new ParseError( "Got group of unknown t...
Takes a group from the parser and calls the appropriate groupTypes function on it to produce a MathML node.
buildGroup
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
buildMathML = function(tree, texExpression, settings) { settings = settings || new Settings({}); var startStyle = Style.TEXT; if (settings.displayMode) { startStyle = Style.DISPLAY; } // Setup the default options var options = new Options({ style: startStyle, size: "siz...
Takes a full parse tree and settings and builds a MathML representation of it. In particular, we put the elements from building the parse tree into a <semantics> tag so we can also include that TeX source as an annotation. Note that we actually return a domTree element with a `<math>` inside it so we can do appropriat...
buildMathML
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
function MathNode(type, children) { this.type = type; this.attributes = {}; this.children = children || []; }
This node represents a general purpose MathML node of any type. The constructor requires the type of node to create (for example, `"mo"` or `"mspace"`, corresponding to `<mo>` and `<mspace>` tags).
MathNode
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
deflt = function(setting, defaultIfUndefined) { return setting === undefined ? defaultIfUndefined : setting; }
Provide a default value if a setting is undefined
deflt
javascript
AndrewBelt/hack.chat
client/katex/katex.js
https://github.com/AndrewBelt/hack.chat/blob/master/client/katex/katex.js
MIT
optionsToArray(obj, optionsPrefix, hasEquals) { optionsPrefix = optionsPrefix || '--' var ret = [] Object.keys(obj).forEach((key) => { ret.push(optionsPrefix + key + (hasEquals ? '=' : '')) if (obj[key]) { ret.push(obj[key]) } }) return ret }
Convert an options object into a valid arguments array for the child_process.spawn method from: var options = { foo: 'hello', baz: 'world' } to: ['--foo=', 'hello', '--baz=','world'] @param { Object } obj - object we need to convert @param { Array } optionsPrefix - use a prefix for the new array c...
optionsToArray
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
extend(obj1, obj2) { for (var i in obj2) { if (obj2.hasOwnProperty(i)) { obj1[i] = obj2[i] } } return obj1 }
Simple object extend function @param { Object } obj1 - destination @param { Object } obj2 - source @returns { Object } - destination object
extend
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
exec(command, args, envVariables) { var path = require('path'), os = require('os') return new Promise(function(resolve, reject) { if (os.platform() == 'win32' || os.platform() == 'win64') command += '.cmd' // extend the env variables with some other custom options utils.e...
Run any system command @param { String } command - command to execute @param { Array } args - command arguments @param { Object } envVariables - command environment variables @returns { Promise } chainable promise object
exec
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
listFiles(path, mustDelete) { utils.print(`Listing all the files in the folder: ${path}`, 'confirm') var files = [] if (fs.existsSync(path)) { var tmpFiles = fs.readdirSync(path) tmpFiles.forEach((file) => { var curPath = path + '/' + file files.push(curPath) ...
Read all the files crawling starting from a certain folder path @param { String } path directory path @param { bool } mustDelete delete the files found @returns { Array } files path list
listFiles
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
clean(path) { var files = utils.listFiles(path, true) utils.print(`Deleting the following files: \n ${files.join('\n')}`, 'cool') }
Delete synchronously any folder or file @param { String } path - path to clean
clean
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
print(msg, type) { var color switch (type) { case 'error': color = '\x1B[31m' break case 'warning': color = '\x1B[33m' break case 'confirm': color = '\x1B[32m' break case 'cool': color = '\x1B[36m' break default: ...
Log messages in the terminal using custom colors @param { String } msg - message to output @param { String } type - message type to handle the right color
print
javascript
GianlucaGuarini/es6-project-starter-kit
tasks/_utils.js
https://github.com/GianlucaGuarini/es6-project-starter-kit/blob/master/tasks/_utils.js
MIT
function SmoothieChart(options) { this.options = Util.extend({}, SmoothieChart.defaultChartOptions, options); this.seriesSet = []; this.currentValueRange = 1; this.currentVisMinValue = 0; this.lastRenderTimeMillis = 0; }
Initialises a new <code>SmoothieChart</code>. Options are optional, and should be of the form below. Just specify the values you need and the rest will be given sensible defaults as shown: <pre> { minValue: undefined, // specify to clamp the lower y-axis to a given value maxValue: undefined, ...
SmoothieChart
javascript
01alchemist/TurboScript
benchmark/web-dsp/demo/smoothie.js
https://github.com/01alchemist/TurboScript/blob/master/benchmark/web-dsp/demo/smoothie.js
Apache-2.0
function deriveConcreteClass(context, type, parameters, scope) { var templateNode = type.resolvedType.pointerTo ? type.resolvedType.pointerTo.symbol.node : type.resolvedType.symbol.node; var templateName = templateNode.stringValue; var typeName = templateNode.stringValue + ("<" + parameters[0].stringValue +...
Derive a concrete class from class template type @param context @param type @param parameters @param scope @returns {Symbol}
deriveConcreteClass
javascript
01alchemist/TurboScript
lib/turboscript.js
https://github.com/01alchemist/TurboScript/blob/master/lib/turboscript.js
Apache-2.0
function TouchScroll(/*HTMLElement*/scrollElement, /*Object*/options){ options = options || {}; this.elastic = !!options.elastic, this.snapToGrid = !!options.snapToGrid; this.containerSize = null; this.maxSegments = {e: 1, f: 1}; this.currentSegment = {e: 0, f: 0}; // references to scroll div elements this.sc...
Constructor for scrollers. @constructor @param {HTMLElement} scrollElement The node to make scrollable @param {Object} [options] Options for the scroller- Known options are elastic {Boolean} whether the scroller bounces
TouchScroll
javascript
davidaurelio/TouchScroll
src/touchscroll.js
https://github.com/davidaurelio/TouchScroll/blob/master/src/touchscroll.js
BSD-2-Clause
async viteFinal(config) { // Merge custom configuration into the default config return mergeConfig(config, { assetsInclude: ['**/*.glb', '**/*.hdr', '**/*.glsl'], build: { assetsInlineLimit: 1024, }, }); }
@type { import('@storybook/react-vite').StorybookConfig }
viteFinal
javascript
HamishMW/portfolio
.storybook/main.js
https://github.com/HamishMW/portfolio/blob/master/.storybook/main.js
MIT
async function loadImageFromSrcSet({ src, srcSet, sizes }) { return new Promise((resolve, reject) => { try { if (!src && !srcSet) { throw new Error('No image src or srcSet provided'); } let tempImage = new Image(); if (src) { tempImage.src = src; } if (srcSet...
Use the browser's image loading to load an image and grab the `src` it chooses from a `srcSet`
loadImageFromSrcSet
javascript
HamishMW/portfolio
app/utils/image.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/image.js
MIT
async function generateImage(width = 1, height = 1) { return new Promise(resolve => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); canvas.width = width; canvas.height = height; ctx.fillStyle = 'rgba(0, 0, 0, 0)'; ctx.fillRect(0, 0, width, height); ...
Generates a transparent png of a given width and height
generateImage
javascript
HamishMW/portfolio
app/utils/image.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/image.js
MIT
async function resolveSrcFromSrcSet({ srcSet, sizes }) { const sources = await Promise.all( srcSet.split(', ').map(async srcString => { const [src, width] = srcString.split(' '); const size = Number(width.replace('w', '')); const image = await generateImage(size); return { src, image, widt...
Use native html image `srcSet` resolution for non-html images
resolveSrcFromSrcSet
javascript
HamishMW/portfolio
app/utils/image.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/image.js
MIT
rgbToThreeColor = rgb => rgb?.split(' ').map(value => Number(value) / 255) || []
Convert an rgb theme property (e.g. rgbBlack: '0 0 0') to values that can be spread into a ThreeJS Color class
rgbToThreeColor
javascript
HamishMW/portfolio
app/utils/style.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/style.js
MIT
function cssProps(props, style = {}) { let result = {}; const keys = Object.keys(props); for (const key of keys) { let value = props[key]; if (typeof value === 'number' && key === 'delay') { value = numToMs(value); } if (typeof value === 'number' && key !== 'opacity') { value = num...
Convert a JS object into `--` prefixed css custom properties. Optionally pass a second param for normal styles
cssProps
javascript
HamishMW/portfolio
app/utils/style.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/style.js
MIT
cleanScene = scene => { scene?.traverse(object => { if (!object.isMesh) return; object.geometry.dispose(); if (object.material.isMaterial) { cleanMaterial(object.material); } else { for (const material of object.material) { cleanMaterial(material); } } }); }
Clean up a scene's materials and geometry
cleanScene
javascript
HamishMW/portfolio
app/utils/three.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/three.js
MIT
cleanMaterial = material => { material.dispose(); for (const key of Object.keys(material)) { const value = material[key]; if (value && typeof value === 'object' && 'minFilter' in value) { value.dispose(); // Close GLTF bitmap textures value.source?.data?.close?.(); } } }
Clean up and dispose of a material
cleanMaterial
javascript
HamishMW/portfolio
app/utils/three.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/three.js
MIT
cleanRenderer = renderer => { renderer.dispose(); renderer = null; }
Clean up and dispose of a renderer
cleanRenderer
javascript
HamishMW/portfolio
app/utils/three.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/three.js
MIT
removeLights = lights => { for (const light of lights) { light.parent.remove(light); } }
Clean up lights by removing them from their parent
removeLights
javascript
HamishMW/portfolio
app/utils/three.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/three.js
MIT
function formatTimecode(time) { const hours = time / 1000 / 60 / 60; const h = Math.floor(hours); const m = Math.floor((hours - h) * 60); const s = Math.floor(((hours - h) * 60 - m) * 60); const c = Math.floor(((((hours - h) * 60 - m) * 60 - s) * 1000) / 10); return `${zeroPrefix(h)}:${zeroPrefix(m)}:${ze...
Format a timecode intro a hours:minutes:seconds:centiseconds string
formatTimecode
javascript
HamishMW/portfolio
app/utils/timecode.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/timecode.js
MIT
function zeroPrefix(value) { return value < 10 ? `0${value}` : `${value}`; }
Prefix a number with zero as a string if less than 10
zeroPrefix
javascript
HamishMW/portfolio
app/utils/timecode.js
https://github.com/HamishMW/portfolio/blob/master/app/utils/timecode.js
MIT
function parse (input, options = {}) { try { options = Object.assign({}, defaultAcornOptions, options) return parser.parse(input, options); } catch (e) { e.message = [ e.message, ' ' + input.split('\n')[e.loc.line - 1], ' ' + '^'.padStart(e.loc....
@param {string} input @param {object} options @return {any}
parse
javascript
PepsRyuu/nollup
lib/impl/AcornParser.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/AcornParser.js
MIT
static async loadCJS(filepath, code) { // Once transpiled, we temporarily modify the require function // so that when it loads the config file, it will load the transpiled // version instead, and all of the require calls inside that will still work. let defaultLoader = require.extensions...
Uses compiler to compile rollup.config.js file. This allows config file to use ESM, but compiles to CJS so that import statements change to require statements. @param {string} filepath @param {string} code @return {Promise<object>}
loadCJS
javascript
PepsRyuu/nollup
lib/impl/ConfigLoader.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/ConfigLoader.js
MIT
static async loadESM(filepath, code) { let uri = `data:text/javascript;charset=utf-8,${encodeURIComponent(code)}`; return (await import(uri)).default; }
Directly imports rollup.config.mjs @param {string} filepath @param {string} code @return {Promise<object>}
loadESM
javascript
PepsRyuu/nollup
lib/impl/ConfigLoader.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/ConfigLoader.js
MIT
function blanker (input, start, end) { return input.substring(start, end).replace(/[^\n\r]/g, ' '); }
Setting imports to empty can cause source maps to break. This is because some imports could span across multiple lines when importing named exports. To bypass this problem, this function will replace all text except line breaks with spaces. This will preserve the lines so source maps function correctly. Source maps are...
blanker
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
function getSyntheticExports (synthetic) { if (synthetic === true) { synthetic = 'default'; } return `if (__m__.exports.${synthetic}) { for (let prop in __m__.exports.${synthetic}) { prop !== '${synthetic}' && !__m__.exports.hasOwnProperty(prop) && __e__(prop, function () { retu...
@param {boolean|string} synthetic @return {string}
getSyntheticExports
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
function createExternalImports (chunk, outputOptions, externalImports) { let output = ''; let { format, globals } = outputOptions; output += externalImports.map(ei => { let name = ei.source.replace(/[\W]/g, '_'); let { source, specifiers } = ei; // Bare external import if (...
@param {RollupRenderedChunk} chunk @param {RollupOutputOptions} outputOptions @param {Array<NollupInternalModuleImport>} externalImports @return {string}
createExternalImports
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
function callNollupModuleWrap (plugins, code) { return plugins.filter(p => { return p.nollupModuleWrap }).reduce((code, p) => { return p.nollupModuleWrap(code) }, code); }
@param {NollupPlugin[]} plugins @param {string} code @return {string}
callNollupModuleWrap
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onESMEnter (code, filePath, ast) { activeModules[filePath] = { output: new MagicString(code), code: code }; }
@param {string} code @param {string} filePath @param {ESTree} ast
onESMEnter
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onESMNodeFound (filePath, node, args) { let { output, code } = activeModules[filePath]; if (node.type === 'ImportDeclaration' || (args && args.source)) { output.overwrite(node.start, node.end, blanker(code, node.start, node.end)); return; } if (node.type...
@param {string} filePath @param {ESTree} node @param {any} args
onESMNodeFound
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onESMLateInitFound (filePath, node, found) { let { output, code } = activeModules[filePath]; let transpiled = ';' + found.map(name => `__e__('${name}', function () { return typeof ${name} !== 'undefined' && ${name} })`).join(';') + ';'; output.appendRight(node.end, transpiled); }
@param {ESTree} node @param {string[]} found
onESMLateInitFound
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onESMLeave (code, filePath, ast) { let { output } = activeModules[filePath]; let payload = { code: output.toString(), map: output.generateMap({ source: filePath }) }; delete activeModules[filePath]; return payload; }
@param {string} code @param {string} filePath @param {ESTree} ast @return {{ code: string, map: RollupSourceMap }}
onESMLeave
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onGenerateModule (modules, filePath, config) { let { esmTransformedCode: code, map, imports, exports, externalImports, dynamicImports, syntheticNamedExports, hoist } = modules[filePath]; // Validate dependencies exist. imports.forEach(dep => { if (!modules[dep.source]) { ...
@param {Object<string, NollupInternalModule>} modules @param {string} filePath @param {RollupConfigContainer} config @return {string}
onGenerateModule
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onGenerateModulePreChunk (file, bundle, modules) { if (file.dynamicImports.length > 0) { return file.generatedCode.replace(/require\.dynamic\((\\)?\'(.*?)(\\)?\'\)/g, (match, escapeLeft, inner, escapeRight) => { let foundOutputChunk = bundle.find(b => { // Look fo...
@param {NollupInternalModule} file @param {RollupOutputFile[]} bundle @param {Object<string, NollupInternalModule>} modules @return {string}
onGenerateModulePreChunk
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
onGenerateChunk (modules, chunk, outputOptions, config, externalImports) { let files = Object.keys(chunk.modules).map(filePath => { let file = modules[filePath]; return file.index + ':' + file.code; }); let entryIndex = modules[chunk.facadeModuleId].index; let ...
@param {Object<string, NollupOutputModule>} modules @param {RollupOutputChunk} chunk @param {RollupOutputOptions} outputOptions @param {RollupConfigContainer} config @param {Array<NollupInternalModuleImport>} externalImports @return {string}
onGenerateChunk
javascript
PepsRyuu/nollup
lib/impl/NollupCodeGenerator.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCodeGenerator.js
MIT
function applyOutputFileNames (outputOptions, bundle, bundleOutputTypes) { let name_map = {}; bundle.forEach(curr => { if (!name_map[curr.name]) { name_map[curr.name] = []; } name_map[curr.name].push(curr); }); Object.keys(name_map).forEach(name => { let en...
@param {RollupOutputOptions} outputOptions @param {RollupOutputFile[]} bundle @param {Object<string, string>} bundleOutputTypes
applyOutputFileNames
javascript
PepsRyuu/nollup
lib/impl/NollupCompiler.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCompiler.js
MIT
function resolveImportMetaProperty (plugins, moduleId, metaName, chunk, bundleReferenceIdMap) { if (metaName) { for (let i = 0; i < FILE_PROPS.length; i++) { if (metaName.startsWith(FILE_PROPS[i])) { let id = metaName.replace(FILE_PROPS[i], ''); let entry = bundle...
@param {PluginContainer} plugins @param {string} moduleId @param {string} metaName @param {RollupOutputChunk} chunk @param {Object<string, RollupOutputFile>} bundleReferenceIdMap @return {string}
resolveImportMetaProperty
javascript
PepsRyuu/nollup
lib/impl/NollupCompiler.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCompiler.js
MIT
async compile (context) { let generator = context.generator; context.plugins.start(); let bundle = /** @type {RollupOutputFile[]} */ ([]); let bundleError = /** @type {Error} */ (undefined); let bundleStartTime = Date.now(); let bundleEmittedChunks = /** @type {NollupInt...
@param {NollupContext} context @return {Promise<NollupCompileOutput>}
compile
javascript
PepsRyuu/nollup
lib/impl/NollupCompiler.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupCompiler.js
MIT
async function resolveInputId (context, id) { let resolved = await context.plugins.hooks.resolveId(id, undefined, { isEntry: true }); if ((typeof resolved === 'object' && resolved.external)) { throw new Error('Input cannot be external'); } return typeof resolved === 'object' && resolved.id; }
@param {NollupContext} context @param {string} id @return {Promise<string>}
resolveInputId
javascript
PepsRyuu/nollup
lib/impl/NollupContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupContext.js
MIT
async function getInputEntries (context, input) { if (typeof input === 'string') { input = await resolveInputId(context, input); return [{ name: getNameFromFileName(input), file: input }]; } if (Array.isArray(input)) { return await Promise.all(input...
@param {NollupContext} context @param {string|string[]|Object<string, string>} input @return {Promise<{name: string, file: string}[]>}
getInputEntries
javascript
PepsRyuu/nollup
lib/impl/NollupContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupContext.js
MIT
async initialize (options) { this.config = new RollupConfigContainer(options); if (this.config.acornInjectPlugins) { AcornParser.inject(this.config.acornInjectPlugins); } this.files = /** @type {Object<string, NollupInternalModule>} */ ({}); this.rawWatchFiles = /*...
@param {RollupOptions} options @return {Promise<void>}
initialize
javascript
PepsRyuu/nollup
lib/impl/NollupContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupContext.js
MIT
function resolveDefaultExport (container, input, output, node, currentpath, generator) { generator.onESMNodeFound(currentpath, node, undefined); output.exports.push({ local: '', exported: 'default' }); }
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {CodeGenerator} generator
resolveDefaultExport
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
async function resolveNamedExport (container, input, output, node, currentpath, generator, liveBindings) { let exports = []; // export function / class / let... if (node.declaration) { let dec = node.declaration; // Singular export declaration if (dec.id) { exports....
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {string} currentpath @param {CodeGenerator} generator @param {Boolean|String} liveBindings
resolveNamedExport
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
async function resolveAllExport (container, input, output, node, currentpath, generator) { // export * from './file'; let dep = await resolveImport(container, input, output, node, currentpath, generator); if (!dep) { return; } dep.export = true; dep.specifiers.push({ imported: '...
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {string} currentpath @param {CodeGenerator} generator
resolveAllExport
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
function walkSimpleLiveBindings (container, input, output, nodes, found, level, generator, currentpath) { for (let i = 0; i < nodes.length; i++) { let node = nodes[i]; let locals = []; if (!node) { continue; } if ( node.type === 'AssignmentExpressio...
@param {PluginContainer} container @param {string} input @param {Object} output @param {Array<ESTree>} nodes @param {Array<string>} found @param {number} level @param {CodeGenerator} generator
walkSimpleLiveBindings
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
async transformBindings(container, input, raw, currentpath, generator, liveBindings) { let output = { imports: [], externalImports: [], exports: [], dynamicImports: [], externalDynamicImports: [], metaProperties: [], dynamicMapp...
@param {PluginContainer} container @param {string} input @param {string} currentpath @param {CodeGenerator} generator @param {Boolean|String} liveBindings @return {Promise<Object>}
transformBindings
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
function NollupLiveBindingsResolver (imports, ast, generator, currentpath) { let specifiers = imports.flatMap(i => i.specifiers.map(s => s.local)); transformImportReferences(specifiers, ast, generator, currentpath); }
@param {NollupInternalModuleImport[]} imports @param {ESTree} ast @param {NollupCodeGenerator} generator
NollupLiveBindingsResolver
javascript
PepsRyuu/nollup
lib/impl/NollupLiveBindingsResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupLiveBindingsResolver.js
MIT
constructor (config, parser) { this.__config = config; this.__meta = {}; this.__currentModuleId = null; this.__currentMapChain = null; this.__currentOriginalCode = null; this.__currentLoadQueue = []; this.__parser = parser; this.__errorState = tru...
@param {RollupConfigContainer} config @param {{parse: function(string, object): ESTree}} parser
constructor
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onAddWatchFile (callback) { // Local copy of watch files for the getWatchFiles method, but also triggers this event this.__onAddWatchFile = callback; }
Receives source and parent file if any. @param {function(string, string): void} callback
onAddWatchFile
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onGetWatchFiles (callback) { this.__onGetWatchFiles = callback; }
Must return a list of files that are being watched. @param {function(): string[]} callback
onGetWatchFiles
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onGetModuleInfo (callback) { this.__onGetModuleInfo = callback; }
Receives the requested module. Must return module info. @param {function(string): object} callback
onGetModuleInfo
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onSetAssetSource (callback) { this.__onSetAssetSource = callback; }
Receives asset reference id, and source. @param {function(string, string|Uint8Array): void} callback
onSetAssetSource
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onGetModuleIds (callback) { this.__onGetModuleIds = callback; }
Must return iterable of all modules in the current bundle. @param {function(): IterableIterator<string>} callback
onGetModuleIds
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
onLoad (callback) { this.__onLoad = callback; }
Must load the module. @param {function(): Promise<void>} callback
onLoad
javascript
PepsRyuu/nollup
lib/impl/PluginContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContainer.js
MIT
create (container, plugin) { let context = { meta: PluginMeta, /** * @return {IterableIterator<string>} */ get moduleIds () { return context.getModuleIds(); }, /** * @param {string} filePath ...
@param {PluginContainer} container @param {RollupPlugin} plugin @return {RollupPluginContext}
create
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
async resolve (importee, importer, options = {}) { if (options.skipSelf) { PluginLifecycle.resolveIdSkips.add(plugin, importer, importee); } try { return await PluginLifecycle.resolveIdImpl(container, importee, importer...
@param {string} importee @param {string} importer @param {{ isEntry?: boolean, custom?: import('rollup').CustomPluginOptions, skipSelf?: boolean }} options @return {Promise<RollupResolveId>}
resolve
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
async load(resolvedId) { await container.__onLoad(resolvedId); return context.getModuleInfo(resolvedId.id); }
@param {import('rollup').ResolvedId} resolvedId @return {Promise<RollupModuleInfo>}
load
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
parse (code, options) { return container.__parser.parse(code, options); }
@param {string} code @param {Object} options @return {ESTree}
parse
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
emitAsset (name, source) { return context.emitFile({ type: 'asset', name: name, source: source }); }
@param {string} name @param {string|Uint8Array} source @return {string}
emitAsset
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
emitChunk (id, options = {}) { return context.emitFile({ type: 'chunk', id: id, name: options.name }); }
@param {string} id @param {Object} options @return {string}
emitChunk
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
setAssetSource (id, source) { container.__onSetAssetSource(id, source); }
@param {string} id @param {string|Uint8Array} source
setAssetSource
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
async resolveId (importee, importer) { let result = await container.hooks.resolveId(importee, importer); if (typeof result === 'object') { if (result.external) { return null; } return result.id; ...
@param {string} importee @param {string} importer @return {Promise<RollupResolveId>}
resolveId
javascript
PepsRyuu/nollup
lib/impl/PluginContext.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginContext.js
MIT
throw (e) { e = format(e); if (!this.__errorThrown) { this.__errorThrown = true; this.__onThrow(); if (this.__asyncErrorListener) { this.__asyncErrorListener(e); } else { throw e; } } }
@param {object|string} e @return {void|never}
throw
javascript
PepsRyuu/nollup
lib/impl/PluginErrorHandler.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginErrorHandler.js
MIT
async function _callAsyncHook (plugin, hook, args) { let handler = plugin.execute[hook]; if (typeof handler === 'string') { return handler; } if (typeof handler === 'object') { handler = handler.handler; } if (handler) { let hr = handler.apply(plugin.context, args); ...
@param {NollupInternalPluginWrapper} plugin @param {string} hook @param {any[]} args @return {Promise<any>}
_callAsyncHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function _callSyncHook (plugin, hook, args) { let handler = plugin.execute[hook]; if (typeof handler === 'object') { handler = handler.handler; } if (handler) { return handler.apply(plugin.context, args); } }
@param {NollupInternalPluginWrapper} plugin @param {string} hook @param {any[]} args @return {any}
_callSyncHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
async function callAsyncFirstHook (container, hook, args) { // hook may return a promise. // waits for hook to return value other than null or undefined. let plugins = _getSortedPlugins(container.__plugins, hook); for (let i = 0; i < plugins.length; i++) { let hr = await _callAsyncHook(plugins[...
@param {PluginContainer} container @param {string} hook @param {any[]} args @return {Promise<any>}
callAsyncFirstHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
async function callAsyncSequentialHook (container, hook, toArgs, fromResult, start) { // hook may return a promise. // all plugins that implement this hook will run, passing data onwards let plugins = _getSortedPlugins(container.__plugins, hook); let output = start; for (let i = 0; i < plugins.leng...
@param {PluginContainer} container @param {string} hook @param {function} toArgs @param {function} fromResult @param {any} start @return {Promise}
callAsyncSequentialHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
async function callAsyncParallelHook (container, hook, args) { // hooks may return promises. // all hooks are executed at the same time without waiting // will wait for all hooks to complete before returning let hookResults = []; let plugins = _getSortedPlugins(container.__plugins, hook); let pr...
@param {PluginContainer} container @param {string} hook @param {any[]} args @return {Promise}
callAsyncParallelHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function callSyncFirstHook (container, hook, args) { let plugins = _getSortedPlugins(container.__plugins, hook); // waits for hook to return value other than null of undefined for (let i = 0; i < plugins.length; i++) { let hr = _callSyncHook(plugins[i], hook, args); if (hr !== null && hr !...
@param {PluginContainer} container @param {string} hook @param {any[]} args @return {any}
callSyncFirstHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function callSyncSequentialHook (container, hook, args) { // all plugins that implement this hook will run, passing data onwards let plugins = _getSortedPlugins(container.__plugins, hook); let output = args[0]; for (let i = 0; i < plugins.length; i++) { let hr = _callSyncHook(plugins[i], hook, ...
@param {PluginContainer} container @param {string} hook @param {any[]} args @return {any}
callSyncSequentialHook
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function handleMetaProperty (container, filePath, meta) { if (meta) { let fileMeta = container.__meta[filePath]; if (!fileMeta) { fileMeta = {}; container.__meta[filePath] = fileMeta; } for (let prop in meta) { fileMeta[prop] = meta[prop];...
@param {PluginContainer} container @param {string} filePath @param {Object} meta
handleMetaProperty
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT