code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
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
onESMImportLiveBinding (filePath, node, ancestors) { let { output, code } = activeModules[filePath]; let parent = ancestors[ancestors.length - 1]; if (parent.type === 'Property' && parent.shorthand) { output.prependLeft(node.start, node.name + ': '); } output.overwri...
@param {string} filePath @param {ESTree} node @param {any} args
onESMImportLiveBinding
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 resolveMetaProperty (container, input, output, node, currentpath, generator) { let name = node.type === 'MetaProperty'? null : node.property && node.property.name; output.metaProperties.push(name); generator.onESMNodeFound(currentpath, node, name); }
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {string} currentpath @param {CodeGenerator} generator
resolveMetaProperty
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
async function resolveDynamicImport (container, input, output, node, currentpath, generator) { let arg = node.source; let value; if (arg.type === 'Literal') { value = arg.value; } if (arg.type === 'TemplateLiteral') { if (arg.expressions.length === 0 && arg.quasis[0] && arg.qua...
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {string} currentpath @param {CodeGenerator} generator
resolveDynamicImport
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
async function resolveImport (container, input, output, node, currentpath, generator) { let resolved = await container.hooks.resolveId(node.source.value, currentpath); let dependency = { source: undefined, specifiers: [] }; if (resolved.external) { dependency.external = true; ...
@param {PluginContainer} container @param {string} input @param {Object} output @param {ESTree} node @param {string} currentpath @param {CodeGenerator} generator
resolveImport
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 function findESMNodes (nodes, output) { for (let i = 0; i < nodes.length; i++) { let node = nodes[i]; if (!node) { // There's a possibility of null nodes continue; } if (node.type === 'ImportDeclaration') { output.imports.push({ node }); ...
@param {PluginContainer} container @param {string} input @param {Object} output @param {Array<ESTree>} nodes @param {Array<string>} found @param {number} level @param {CodeGenerator} generator
findESMNodes
javascript
PepsRyuu/nollup
lib/impl/NollupImportExportResolver.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/NollupImportExportResolver.js
MIT
getBindings(code) { // TODO: Store the ast for later parsing? let ast = AcornParser.parse(code); let output = { imports: [], exports: [], dynamicImports: [], metaProperties: [] }; findESMNodes(ast.body, output); return { ...
@param {PluginContainer} container @param {string} input @param {Object} output @param {Array<ESTree>} nodes @param {Array<string>} found @param {number} level @param {CodeGenerator} generator
getBindings
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
isExternal () { throw new Error('isExternal: deprecated in Rollup, not implemented'); }
@param {string} id @param {string|Uint8Array} source
isExternal
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
function _getSortedPlugins(plugins, hook) { plugins = plugins.slice(0); return plugins.filter(p => { return typeof p.execute[hook] === 'object' && p.execute[hook].order === 'pre'; }).concat(plugins.filter(p => { return typeof p.execute[hook] === 'function' || typeof p.execute[hook] === 'str...
@param {NollupInternalPluginWrapper} plugin @param {string} hook @param {any[]} args @return {any}
_getSortedPlugins
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
function triggerNotImplemented(name, args) { let error = `"${name}" not implemented`; console.error(error, args); throw new Error(error); }
@param {string} name @param {any[]} args
triggerNotImplemented
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function isExternal (config, name) { if (config && config.external) { let external = config.external; if (Array.isArray(external)) { return external.indexOf(name) > -1; } if (typeof external === 'function') { return external(name, undefined, undefined); ...
@param {RollupConfigContainer} config @param {string} name @return {boolean | void}
isExternal
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
async resolveIdImpl (container, id, parentFilePath, options = {}) { options.isEntry = options.isEntry || false; options.custom = options.hasOwnProperty('custom')? options.custom : {}; let __plugins = container.__plugins.filter(p => !this.resolveIdSkips.contains(p.execute, parentFilePath, id)); ...
@param {PluginContainer} container @param {string} id @param {string} parentFilePath @return {Promise<RollupResolveIdResult>}
resolveIdImpl
javascript
PepsRyuu/nollup
lib/impl/PluginLifecycle.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js
MIT
function prepareSourceMapChain (mapChain, original_code, filepath) { mapChain = mapChain.filter(o => o.map && o.map.mappings).reverse(); if (mapChain.length > 1) { mapChain.forEach((obj, index) => { obj.map.version = 3; obj.map.file = filepath + '_' + index; // Check...
@param {NollupTransformMapEntry[]} mapChain @param {string} original_code @param {string} filepath @return {NollupTransformMapEntry[]}
prepareSourceMapChain
javascript
PepsRyuu/nollup
lib/impl/PluginUtils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js
MIT
function generateSourceMap (mapChain, mapGenerator, original_code, filepath) { let map; if (mapChain.length > 1) { // @ts-ignore map = mapGenerator.toJSON(); } else { map = mapChain.length > 0? mapChain[0].map : undefined; } if (map) { map.file = filepath; m...
@param {NollupTransformMapEntry[]} mapChain @param {SourceMapGenerator} mapGenerator @param {string} original_code @param {string} filepath @return {RollupSourceMap}
generateSourceMap
javascript
PepsRyuu/nollup
lib/impl/PluginUtils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js
MIT
function combineSourceMapChain (inputMapChain, original_code, filepath) { let mapGenerator, mapChain = prepareSourceMapChain(inputMapChain, original_code, filepath); if (mapChain.length > 1) { // @ts-ignore mapGenerator = SourceMap.SourceMapGenerator.fromSourceMap(new SourceMap.SourceMapConsume...
@param {NollupTransformMapEntry[]} inputMapChain @param {string} original_code @param {string} filepath @return {RollupSourceMap}
combineSourceMapChain
javascript
PepsRyuu/nollup
lib/impl/PluginUtils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js
MIT
async function combineSourceMapChainFast (inputMapChain, original_code, filepath) { let mapGenerator, mapChain = prepareSourceMapChain(inputMapChain, original_code, filepath); if (mapChain.length > 1) { mapGenerator = SourceMapFast.SourceMapGenerator.fromSourceMap(await new SourceMapFast.SourceMapConsu...
@param {NollupTransformMapEntry[]} inputMapChain @param {string} original_code @param {string} filepath @return {Promise<RollupSourceMap>}
combineSourceMapChainFast
javascript
PepsRyuu/nollup
lib/impl/PluginUtils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js
MIT
function getModuleInfo (container, id) { let response = container.__onGetModuleInfo(id); return { id: id, code: response.code || null, isEntry: response.isEntry || false, isExternal: response.isExternal || false, importers: response.importers || [], importedIds: ...
@param {PluginContainer} container @param {string} id @return {RollupModuleInfo}
getModuleInfo
javascript
PepsRyuu/nollup
lib/impl/PluginUtils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js
MIT
function callOutputOptionsHook (plugins, outputOptions) { if (plugins) { plugins.forEach(plugin => { if (plugin.outputOptions) { outputOptions = plugin.outputOptions.call({ meta: PluginMeta }, outputOptions) || outputOptions; } ...
@param {RollupPlugin[]} plugins @param {RollupOutputOptions} outputOptions
callOutputOptionsHook
javascript
PepsRyuu/nollup
lib/impl/RollupConfigContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/RollupConfigContainer.js
MIT
function normalizeInput (input) { if (typeof input === 'string') { return [input]; } if (Array.isArray(input)) { return input; } return input; }
@param {RollupInputOption} input @return {string[]|Object<string, string>}
normalizeInput
javascript
PepsRyuu/nollup
lib/impl/RollupConfigContainer.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/RollupConfigContainer.js
MIT
function findChildNodes (node) { let children = []; for (let prop in node) { if (Array.isArray(node[prop]) && node[prop][0] && node[prop][0].constructor && node[prop][0].constructor.name === 'Node') { children.push(...node[prop]); } if (node[prop] && node[prop].constructor...
@param {ESTree} node @return {Array<ESTree>}
findChildNodes
javascript
PepsRyuu/nollup
lib/impl/utils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js
MIT
function resolvePath (target, current) { if (path.isAbsolute(target)) { return path.normalize(target); } else { // Plugins like CommonJS have namespaced imports. let parts = target.split(':'); let namespace = parts.length === 2? parts[0] + ':' : ''; let file = parts.lengt...
@param {string} target @param {string} current @return {string}
resolvePath
javascript
PepsRyuu/nollup
lib/impl/utils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js
MIT
function formatFileName (format, fileName, pattern) { let name = path.basename(fileName).replace(path.extname(fileName), ''); if (typeof pattern === 'string') { return pattern.replace('[name]', name) .replace('[extname]', path.extname(fileName)) .replace('[ext]', path.extname(fi...
@param {string} format @param {string} fileName @param {string|function(RollupPreRenderedFile): string} pattern @return {string}
formatFileName
javascript
PepsRyuu/nollup
lib/impl/utils.js
https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js
MIT
async function logs (count = 1, timeout = 5000) { let start = Date.now(); // Wait until we acquire the requested number of logs while (logbuffer.length < count) { await wait(100); if (Date.now() - start > timeout) { break; } } // return the logs and clear it af...
Returns a list of logs. Waits until the number of requested logs have accumulated. There's a timeout to force it to stop checking. @param {Number} count @param {Number} timeout @returns {Promise<String[]>}
logs
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
async function call (fn, arg) { // TODO: Find deterministic way of handling this await wait(100); global._evaluatorInstance.send({ call: [fn, arg] }); await wait(100); }
Call the global function in the VM. @param {String} fn @param {*} arg
call
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
function invalidate (chunks) { global._evaluatorInstance.send({ invalidate: true, chunks }); }
Sends updated bundle chunks to VM. @param {Object[]} chunks
invalidate
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
function init (format, entry, chunks, globals = {}, async = false) { logbuffer = []; return new Promise((resolve, reject) => { let impl = (resolve, reject) => { global._evaluatorResultListener = msg => { if (msg.log) { logbuffer.push(msg.log); ...
Evaluates the VM with the provided code. @param {String} format @param {String} entry @param {Object[]} chunks @param {Object} globals @param {Boolean} async @returns {Object}
init
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
impl = (resolve, reject) => { global._evaluatorResultListener = msg => { if (msg.log) { logbuffer.push(msg.log); return; } if (msg.error) { return reject(msg.error); } ...
Evaluates the VM with the provided code. @param {String} format @param {String} entry @param {Object[]} chunks @param {Object} globals @param {Boolean} async @returns {Object}
impl
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
impl = (resolve, reject) => { global._evaluatorResultListener = msg => { if (msg.log) { logbuffer.push(msg.log); return; } if (msg.error) { return reject(msg.error); } ...
Evaluates the VM with the provided code. @param {String} format @param {String} entry @param {Object[]} chunks @param {Object} globals @param {Boolean} async @returns {Object}
impl
javascript
PepsRyuu/nollup
test/utils/evaluator.js
https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js
MIT
constructor(capacity) { this.capacity = capacity; this.regExpMap = new Map(); // Since our capacity tends to be fairly small, `.shift()` will be fairly quick despite being O(n). We just use a // normal array to keep it simple. this.regExpQueue = []; }
This is a reusable regular expression cache class. Given a certain maximum number of regular expressions we're allowed to store in the cache, it provides a way to avoid recreating regular expression objects over and over. When it needs to evict something, it evicts the oldest one.
constructor
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
getRegExp(pattern) { const regExpFromCache = this.regExpMap.get(pattern); if (regExpFromCache !== undefined) { return regExpFromCache; } const regExpNew = new RegExp(pattern); if (this.regExpQueue.length === this.capacity) { this.regExpMap.delete(this.regExpQueue.shift()); } this...
This is a reusable regular expression cache class. Given a certain maximum number of regular expressions we're allowed to store in the cache, it provides a way to avoid recreating regular expression objects over and over. When it needs to evict something, it evicts the oldest one.
getRegExp
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
looksLikeObjectPath = (key, nsSeparator, keySeparator) => { nsSeparator = nsSeparator || ''; keySeparator = keySeparator || ''; const possibleChars = chars.filter( (c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0, ); if (possibleChars.length === 0) return true; const r = looksLikeObjectP...
This is a reusable regular expression cache class. Given a certain maximum number of regular expressions we're allowed to store in the cache, it provides a way to avoid recreating regular expression objects over and over. When it needs to evict something, it evicts the oldest one.
looksLikeObjectPath
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
looksLikeObjectPath = (key, nsSeparator, keySeparator) => { nsSeparator = nsSeparator || ''; keySeparator = keySeparator || ''; const possibleChars = chars.filter( (c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0, ); if (possibleChars.length === 0) return true; const r = looksLikeObjectP...
This is a reusable regular expression cache class. Given a certain maximum number of regular expressions we're allowed to store in the cache, it provides a way to avoid recreating regular expression objects over and over. When it needs to evict something, it evicts the oldest one.
looksLikeObjectPath
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
deepFind = (obj, path, keySeparator = '.') => { if (!obj) return undefined; if (obj[path]) { if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined; return obj[path]; } const tokens = path.split(keySeparator); let current = obj; for (let i = 0; i < tokens.length; ) { if (!current...
Given 1. a top level object obj, and 2. a path to a deeply nested string or object within it Find and return that deeply nested string or object. The caveat is that the keys of objects within the nesting chain may contain period characters. Therefore, we need to DFS and explore all possible keys at each step until we...
deepFind
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
deepFind = (obj, path, keySeparator = '.') => { if (!obj) return undefined; if (obj[path]) { if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined; return obj[path]; } const tokens = path.split(keySeparator); let current = obj; for (let i = 0; i < tokens.length; ) { if (!current...
Given 1. a top level object obj, and 2. a path to a deeply nested string or object within it Find and return that deeply nested string or object. The caveat is that the keys of objects within the nesting chain may contain period characters. Therefore, we need to DFS and explore all possible keys at each step until we...
deepFind
javascript
i18next/i18next
src/utils.js
https://github.com/i18next/i18next/blob/master/src/utils.js
MIT
httpApiReadMockImplementation = (language, namespace, callback) => { const namespacePath = `${__dirname}/locales/${language}/${namespace}.json`; // console.info('httpApiReadMockImplementation', namespacePath); if (fs.existsSync(namespacePath)) { const data = JSON.parse(fs.readFileSync(namespacePath, 'utf-8'...
@param {string} language @param {string} namespace @param {import('i18next').ReadCallback} callback @returns {void}
httpApiReadMockImplementation
javascript
i18next/i18next
test/compatibility/v1/v1.i18nInstance.js
https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js
MIT
httpApiReadMockImplementation = (language, namespace, callback) => { const namespacePath = `${__dirname}/locales/${language}/${namespace}.json`; // console.info('httpApiReadMockImplementation', namespacePath); if (fs.existsSync(namespacePath)) { const data = JSON.parse(fs.readFileSync(namespacePath, 'utf-8'...
@param {string} language @param {string} namespace @param {import('i18next').ReadCallback} callback @returns {void}
httpApiReadMockImplementation
javascript
i18next/i18next
test/compatibility/v1/v1.i18nInstance.js
https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js
MIT
getI18nCompatibilityV1InitOptions = () => ({ compatibilityAPI: 'v1', compatibilityJSON: 'v1', lng: 'en-US', load: 'all', fallbackLng: 'dev', fallbackNS: [], fallbackOnNull: true, fallbackOnEmpty: false, preload: [], lowerCaseLng: false, ns: 'translation', fallbackToDefaultNS: false, resGetPath...
using a function to have always a new object
getI18nCompatibilityV1InitOptions
javascript
i18next/i18next
test/compatibility/v1/v1.i18nInstance.js
https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js
MIT
getI18nCompatibilityV1InitOptions = () => ({ compatibilityAPI: 'v1', compatibilityJSON: 'v1', lng: 'en-US', load: 'all', fallbackLng: 'dev', fallbackNS: [], fallbackOnNull: true, fallbackOnEmpty: false, preload: [], lowerCaseLng: false, ns: 'translation', fallbackToDefaultNS: false, resGetPath...
using a function to have always a new object
getI18nCompatibilityV1InitOptions
javascript
i18next/i18next
test/compatibility/v1/v1.i18nInstance.js
https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js
MIT
function distance(p1, p2) { return Math.hypot(p1.x - p2.x, p1.y - p2.y); }
Calculates distance between two points. Each point must have `x` and `y` property @param {*} p1 point 1 @param {*} p2 point 2 @returns distance between two points
distance
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
loadOpenCV(callback) { cv = require("./opencv"); cv["onRuntimeInitialized"] = () => { callback(cv); }; }
Calculates distance between two points. Each point must have `x` and `y` property @param {*} p1 point 1 @param {*} p2 point 2 @returns distance between two points
loadOpenCV
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
findPaperContour(img) { const imgGray = new cv.Mat(); cv.Canny(img, imgGray, 50, 200); const imgBlur = new cv.Mat(); cv.GaussianBlur( imgGray, imgBlur, new cv.Size(3, 3), 0, 0, cv.BORDER_DEFAULT ); const imgThresh = new cv.Mat(); cv.threshold(imgBlur, im...
Finds the contour of the paper within the image @param {*} img image to process (cv.Mat) @returns the biggest contour inside the image
findPaperContour
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
highlightPaper(image, options) { options = options || {}; options.color = options.color || "orange"; options.thickness = options.thickness || 10; const canvas = createCanvas(); const ctx = canvas.getContext("2d"); const img = cv.imread(image); const maxContour = this.findPaperContour(img); ...
Highlights the paper detected inside the image. @param {*} image image to process @param {*} options options for highlighting. Accepts `color` and `thickness` parameter @returns `HTMLCanvasElement` with original image and paper highlighted
highlightPaper
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
extractPaper(image, resultWidth, resultHeight, cornerPoints) { const canvas = createCanvas(); const img = cv.imread(image); const maxContour = cornerPoints ? null : this.findPaperContour(img); if(maxContour == null && cornerPoints === undefined){ return null; } const { topLeftCorne...
Extracts and undistorts the image detected within the frame. Returns `null` if no paper is detected. @param {*} image image to process @param {*} resultWidth desired result paper width @param {*} resultHeight desired result paper height @param {*} cornerPoints optional custom corner points, in case automatic corner p...
extractPaper
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
getCornerPoints(contour) { let rect = cv.minAreaRect(contour); const center = rect.center; let topLeftCorner; let topLeftCornerDist = 0; let topRightCorner; let topRightCornerDist = 0; let bottomLeftCorner; let bottomLeftCornerDist = 0; let bottomRightCorner; let bottomRightC...
Calculates the corner points of a contour. @param {*} contour contour from {@link findPaperContour} @returns object with properties `topLeftCorner`, `topRightCorner`, `bottomLeftCorner`, `bottomRightCorner`, each with `x` and `y` property
getCornerPoints
javascript
puffinsoft/jscanify
src/jscanify-node.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js
MIT
function distance(p1, p2) { return Math.hypot(p1.x - p2.x, p1.y - p2.y); }
Calculates distance between two points. Each point must have `x` and `y` property @param {*} p1 point 1 @param {*} p2 point 2 @returns distance between two points
distance
javascript
puffinsoft/jscanify
src/jscanify.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js
MIT
findPaperContour(img) { const imgGray = new cv.Mat(); cv.Canny(img, imgGray, 50, 200); const imgBlur = new cv.Mat(); cv.GaussianBlur( imgGray, imgBlur, new cv.Size(3, 3), 0, 0, cv.BORDER_DEFAULT ); const imgThresh = new cv.Mat(); ...
Finds the contour of the paper within the image @param {*} img image to process (cv.Mat) @returns the biggest contour inside the image
findPaperContour
javascript
puffinsoft/jscanify
src/jscanify.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js
MIT
highlightPaper(image, options) { options = options || {}; options.color = options.color || "orange"; options.thickness = options.thickness || 10; const canvas = document.createElement("canvas"); const ctx = canvas.getContext("2d"); const img = cv.imread(image); const maxContou...
Highlights the paper detected inside the image. @param {*} image image to process @param {*} options options for highlighting. Accepts `color` and `thickness` parameter @returns `HTMLCanvasElement` with original image and paper highlighted
highlightPaper
javascript
puffinsoft/jscanify
src/jscanify.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js
MIT
extractPaper(image, resultWidth, resultHeight, cornerPoints) { const canvas = document.createElement("canvas"); const img = cv.imread(image); const maxContour = cornerPoints ? null : this.findPaperContour(img); if(maxContour == null && cornerPoints === undefined){ return null; } ...
Extracts and undistorts the image detected within the frame. Returns `null` if no paper is detected. @param {*} image image to process @param {*} resultWidth desired result paper width @param {*} resultHeight desired result paper height @param {*} cornerPoints optional custom corner points, in case automatic corner ...
extractPaper
javascript
puffinsoft/jscanify
src/jscanify.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js
MIT
getCornerPoints(contour) { let rect = cv.minAreaRect(contour); const center = rect.center; let topLeftCorner; let topLeftCornerDist = 0; let topRightCorner; let topRightCornerDist = 0; let bottomLeftCorner; let bottomLeftCornerDist = 0; let bottomRightCorner; ...
Calculates the corner points of a contour. @param {*} contour contour from {@link findPaperContour} @returns object with properties `topLeftCorner`, `topRightCorner`, `bottomLeftCorner`, `bottomRightCorner`, each with `x` and `y` property
getCornerPoints
javascript
puffinsoft/jscanify
src/jscanify.js
https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js
MIT
function processSegmentation(canvas, segmentation) { var ctx = canvas.getContext('2d'); console.log(segmentation) // Get data from our overlay canvas which is attempting to estimate background. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); var data = imageData.data; // Get data fro...
***************************************************************** Real-Time-Person-Removal Created by Jason Mayes 2020. Get latest code on my Github: https://github.com/jasonmayes/Real-Time-Person-Removal Got questions? Reach out to me on social: Twitter: @jason_mayes LinkedIn: https://www.linkedin.com/in/creativetec...
processSegmentation
javascript
jasonmayes/Real-Time-Person-Removal
script.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js
Apache-2.0
function hasGetUserMedia() { return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); }
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
hasGetUserMedia
javascript
jasonmayes/Real-Time-Person-Removal
script.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js
Apache-2.0
function predictWebcam() { if (previousSegmentationComplete) { // Copy the video frame from webcam to a tempory canvas in memory only (not in the DOM). videoRenderCanvasCtx.drawImage(video, 0, 0); previousSegmentationComplete = false; // Now classify the canvas image we have available. model.segme...
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
predictWebcam
javascript
jasonmayes/Real-Time-Person-Removal
script.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js
Apache-2.0
function enableCam(event) { if (!modelHasLoaded) { return; } // Hide the button. event.target.classList.add('removed'); // getUsermedia parameters. const constraints = { video: true }; // Activate the webcam stream. navigator.mediaDevices.getUserMedia(constraints).then(function(stream...
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
enableCam
javascript
jasonmayes/Real-Time-Person-Removal
script.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js
Apache-2.0
function processSegmentation(canvas, segmentation) { var ctx = canvas.getContext('2d'); // Get data from our overlay canvas which is attempting to estimate background. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); var data = imageData.data; // Get data from the live webcam view wh...
***************************************************************** Real-Time-Person-Removal Created by Jason Mayes 2020. Get latest code on my Github: https://github.com/jasonmayes/Real-Time-Person-Removal Got questions? Reach out to me on social: Twitter: @jason_mayes LinkedIn: https://www.linkedin.com/in/creativetec...
processSegmentation
javascript
jasonmayes/Real-Time-Person-Removal
script_original.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script_original.js
Apache-2.0
function hasGetUserMedia() { return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); }
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
hasGetUserMedia
javascript
jasonmayes/Real-Time-Person-Removal
script_original.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script_original.js
Apache-2.0
function predictWebcam() { if (previousSegmentationComplete) { // Copy the video frame from webcam to a tempory canvas in memory only (not in the DOM). videoRenderCanvasCtx.drawImage(video, 0, 0); previousSegmentationComplete = false; // Now classify the canvas image we have available. model.segme...
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
predictWebcam
javascript
jasonmayes/Real-Time-Person-Removal
script_original.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script_original.js
Apache-2.0
function enableCam(event) { if (!modelHasLoaded) { return; } // Hide the button. event.target.classList.add('removed'); // getUsermedia parameters. const constraints = { video: true }; // Activate the webcam stream. navigator.mediaDevices.getUserMedia(constraints).then(function(stream...
***************************************************************** // Continuously grab image from webcam stream and classify it. ******************************************************************
enableCam
javascript
jasonmayes/Real-Time-Person-Removal
script_original.js
https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script_original.js
Apache-2.0
function f(n) { // Format integers to have at least two digits. return n < 10 ? '0' + n : n; }
Based on JSON2 (http://www.JSON.org/js.html).
f
javascript
maccman/juggernaut
client.js
https://github.com/maccman/juggernaut/blob/master/client.js
MIT
function date(d, key) { return isFinite(d.valueOf()) ? d.getUTCFullYear() + '-' + f(d.getUTCMonth() + 1) + '-' + f(d.getUTCDate()) + 'T' + f(d.getUTCHours()) + ':' + f(d.getUTCMinutes()) + ':' + f(d.getUTCSeconds()) + 'Z' : null; }
Based on JSON2 (http://www.JSON.org/js.html).
date
javascript
maccman/juggernaut
client.js
https://github.com/maccman/juggernaut/blob/master/client.js
MIT