id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
17,300 | af/envalid | src/envalidWithoutDotenv.js | validateVar | function validateVar({ spec = {}, name, rawValue }) {
if (typeof spec._parse !== 'function') {
throw new EnvError(`Invalid spec for "${name}"`)
}
const value = spec._parse(rawValue)
if (spec.choices) {
if (!Array.isArray(spec.choices)) {
throw new TypeError(`"choices" must b... | javascript | function validateVar({ spec = {}, name, rawValue }) {
if (typeof spec._parse !== 'function') {
throw new EnvError(`Invalid spec for "${name}"`)
}
const value = spec._parse(rawValue)
if (spec.choices) {
if (!Array.isArray(spec.choices)) {
throw new TypeError(`"choices" must b... | [
"function",
"validateVar",
"(",
"{",
"spec",
"=",
"{",
"}",
",",
"name",
",",
"rawValue",
"}",
")",
"{",
"if",
"(",
"typeof",
"spec",
".",
"_parse",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"EnvError",
"(",
"`",
"${",
"name",
"}",
"`",
")",
... | Validate a single env var, given a spec object
@throws EnvError - If validation is unsuccessful
@return - The cleaned value | [
"Validate",
"a",
"single",
"env",
"var",
"given",
"a",
"spec",
"object"
] | 1e34b5f5ee06634ee526d58431373157a38324c7 | https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalidWithoutDotenv.js#L24-L39 |
17,301 | af/envalid | src/envalidWithoutDotenv.js | formatSpecDescription | function formatSpecDescription(spec) {
const egText = spec.example ? ` (eg. "${spec.example}")` : ''
const docsText = spec.docs ? `. See ${spec.docs}` : ''
return `${spec.desc}${egText}${docsText}` || ''
} | javascript | function formatSpecDescription(spec) {
const egText = spec.example ? ` (eg. "${spec.example}")` : ''
const docsText = spec.docs ? `. See ${spec.docs}` : ''
return `${spec.desc}${egText}${docsText}` || ''
} | [
"function",
"formatSpecDescription",
"(",
"spec",
")",
"{",
"const",
"egText",
"=",
"spec",
".",
"example",
"?",
"`",
"${",
"spec",
".",
"example",
"}",
"`",
":",
"''",
"const",
"docsText",
"=",
"spec",
".",
"docs",
"?",
"`",
"${",
"spec",
".",
"docs... | Format a string error message for when a required env var is missing | [
"Format",
"a",
"string",
"error",
"message",
"for",
"when",
"a",
"required",
"env",
"var",
"is",
"missing"
] | 1e34b5f5ee06634ee526d58431373157a38324c7 | https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalidWithoutDotenv.js#L42-L46 |
17,302 | af/envalid | src/envalid.js | extendWithDotEnv | function extendWithDotEnv(inputEnv, dotEnvPath = '.env') {
let dotEnvBuffer = null
try {
dotEnvBuffer = fs.readFileSync(dotEnvPath)
} catch (err) {
if (err.code === 'ENOENT') return inputEnv
throw err
}
const parsed = dotenv.parse(dotEnvBuffer)
return extend(parsed, input... | javascript | function extendWithDotEnv(inputEnv, dotEnvPath = '.env') {
let dotEnvBuffer = null
try {
dotEnvBuffer = fs.readFileSync(dotEnvPath)
} catch (err) {
if (err.code === 'ENOENT') return inputEnv
throw err
}
const parsed = dotenv.parse(dotEnvBuffer)
return extend(parsed, input... | [
"function",
"extendWithDotEnv",
"(",
"inputEnv",
",",
"dotEnvPath",
"=",
"'.env'",
")",
"{",
"let",
"dotEnvBuffer",
"=",
"null",
"try",
"{",
"dotEnvBuffer",
"=",
"fs",
".",
"readFileSync",
"(",
"dotEnvPath",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
... | Extend an env var object with the values parsed from a ".env" file, whose path is given by the second argument. | [
"Extend",
"an",
"env",
"var",
"object",
"with",
"the",
"values",
"parsed",
"from",
"a",
".",
"env",
"file",
"whose",
"path",
"is",
"given",
"by",
"the",
"second",
"argument",
"."
] | 1e34b5f5ee06634ee526d58431373157a38324c7 | https://github.com/af/envalid/blob/1e34b5f5ee06634ee526d58431373157a38324c7/src/envalid.js#L8-L18 |
17,303 | prettier/plugin-php | src/util.js | useSingleQuote | function useSingleQuote(node, options) {
return (
!node.isDoubleQuote ||
(options.singleQuote &&
!node.raw.match(/\\n|\\t|\\r|\\t|\\v|\\e|\\f/) &&
!node.value.match(
/["'$\n]|\\[0-7]{1,3}|\\x[0-9A-Fa-f]{1,2}|\\u{[0-9A-Fa-f]+}/
))
);
} | javascript | function useSingleQuote(node, options) {
return (
!node.isDoubleQuote ||
(options.singleQuote &&
!node.raw.match(/\\n|\\t|\\r|\\t|\\v|\\e|\\f/) &&
!node.value.match(
/["'$\n]|\\[0-7]{1,3}|\\x[0-9A-Fa-f]{1,2}|\\u{[0-9A-Fa-f]+}/
))
);
} | [
"function",
"useSingleQuote",
"(",
"node",
",",
"options",
")",
"{",
"return",
"(",
"!",
"node",
".",
"isDoubleQuote",
"||",
"(",
"options",
".",
"singleQuote",
"&&",
"!",
"node",
".",
"raw",
".",
"match",
"(",
"/",
"\\\\n|\\\\t|\\\\r|\\\\t|\\\\v|\\\\e|\\\\f",... | Check if string can safely be converted from double to single quotes, i.e.
- no embedded variables ("foo $bar")
- no linebreaks
- no special characters like \n, \t, ...
- no octal/hex/unicode characters
See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double | [
"Check",
"if",
"string",
"can",
"safely",
"be",
"converted",
"from",
"double",
"to",
"single",
"quotes",
"i",
".",
"e",
"."
] | 249651b8bf3f66d0c1cf63823b1a173a7f31e86a | https://github.com/prettier/plugin-php/blob/249651b8bf3f66d0c1cf63823b1a173a7f31e86a/src/util.js#L592-L601 |
17,304 | aaronshaf/dynamodb-admin | lib/util.js | doSearch | function doSearch(docClient, tableName, scanParams, limit, startKey, progress,
readOperation = 'scan') {
limit = limit !== undefined ? limit : null
startKey = startKey !== undefined ? startKey : null
let params = {
TableName: tableName,
}
if (scanParams !== undefined && scanParams) {
... | javascript | function doSearch(docClient, tableName, scanParams, limit, startKey, progress,
readOperation = 'scan') {
limit = limit !== undefined ? limit : null
startKey = startKey !== undefined ? startKey : null
let params = {
TableName: tableName,
}
if (scanParams !== undefined && scanParams) {
... | [
"function",
"doSearch",
"(",
"docClient",
",",
"tableName",
",",
"scanParams",
",",
"limit",
",",
"startKey",
",",
"progress",
",",
"readOperation",
"=",
"'scan'",
")",
"{",
"limit",
"=",
"limit",
"!==",
"undefined",
"?",
"limit",
":",
"null",
"startKey",
... | Invokes a database scan
@param {Object} docClient The AWS DynamoDB client
@param {String} tableName The table name
@param {Object} scanParams Extra params for the query
@param {Number} limit The of items to request per chunked query. NOT a limit
of items that should be returned.
@param {Object?} startKey The key to st... | [
"Invokes",
"a",
"database",
"scan"
] | c7726afa1a80f55e78502b6de7209f3639e7ff4a | https://github.com/aaronshaf/dynamodb-admin/blob/c7726afa1a80f55e78502b6de7209f3639e7ff4a/lib/util.js#L51-L111 |
17,305 | aaronshaf/dynamodb-admin | lib/backend.js | loadDynamoConfig | function loadDynamoConfig(env, AWS) {
const dynamoConfig = {
endpoint: 'http://localhost:8000',
sslEnabled: false,
region: 'us-east-1',
accessKeyId: 'key',
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || 'secret'
}
loadDynamoEndpoint(env, dynamoConfig)
if (AWS.config) {
if (AWS.config.re... | javascript | function loadDynamoConfig(env, AWS) {
const dynamoConfig = {
endpoint: 'http://localhost:8000',
sslEnabled: false,
region: 'us-east-1',
accessKeyId: 'key',
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || 'secret'
}
loadDynamoEndpoint(env, dynamoConfig)
if (AWS.config) {
if (AWS.config.re... | [
"function",
"loadDynamoConfig",
"(",
"env",
",",
"AWS",
")",
"{",
"const",
"dynamoConfig",
"=",
"{",
"endpoint",
":",
"'http://localhost:8000'",
",",
"sslEnabled",
":",
"false",
",",
"region",
":",
"'us-east-1'",
",",
"accessKeyId",
":",
"'key'",
",",
"secretA... | Create the configuration for the local dynamodb instance.
Region and AccessKeyId are determined as follows:
1) Look at local aws configuration in ~/.aws/credentials
2) Look at env variables env.AWS_REGION and env.AWS_ACCESS_KEY_ID
3) Use default values 'us-east-1' and 'key'
@param env - the process environment
@param... | [
"Create",
"the",
"configuration",
"for",
"the",
"local",
"dynamodb",
"instance",
"."
] | c7726afa1a80f55e78502b6de7209f3639e7ff4a | https://github.com/aaronshaf/dynamodb-admin/blob/c7726afa1a80f55e78502b6de7209f3639e7ff4a/lib/backend.js#L47-L79 |
17,306 | Jam3/layout-bmfont-text | demo/index.js | metrics | function metrics(context) {
//x-height
context.fillStyle = 'blue'
context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight)
//ascender
context.fillStyle = 'pink'
context.fillRect(27, -layout.height, 36, layout.ascender)
//cap height
context.fillStyle = 'yellow'
context.fillRect(110,... | javascript | function metrics(context) {
//x-height
context.fillStyle = 'blue'
context.fillRect(0, -layout.height + layout.baseline, 15, -layout.xHeight)
//ascender
context.fillStyle = 'pink'
context.fillRect(27, -layout.height, 36, layout.ascender)
//cap height
context.fillStyle = 'yellow'
context.fillRect(110,... | [
"function",
"metrics",
"(",
"context",
")",
"{",
"//x-height",
"context",
".",
"fillStyle",
"=",
"'blue'",
"context",
".",
"fillRect",
"(",
"0",
",",
"-",
"layout",
".",
"height",
"+",
"layout",
".",
"baseline",
",",
"15",
",",
"-",
"layout",
".",
"xHe... | draw our metrics squares | [
"draw",
"our",
"metrics",
"squares"
] | 5efcf3d8179e5ed95c268f76a87975979f845db6 | https://github.com/Jam3/layout-bmfont-text/blob/5efcf3d8179e5ed95c268f76a87975979f845db6/demo/index.js#L66-L93 |
17,307 | JetBrains/ring-ui | packages/docs/webpack-docs-plugin.setup.js | createNav | function createNav(sources) {
const defaultCategory = 'Uncategorized';
const sourcesByCategories = sources.
// get category names
reduce((categories, source) => categories.
concat(source.attrs.category || defaultCategory), []).
// remove duplicates
filter((value, i, self) => self.indexOf(val... | javascript | function createNav(sources) {
const defaultCategory = 'Uncategorized';
const sourcesByCategories = sources.
// get category names
reduce((categories, source) => categories.
concat(source.attrs.category || defaultCategory), []).
// remove duplicates
filter((value, i, self) => self.indexOf(val... | [
"function",
"createNav",
"(",
"sources",
")",
"{",
"const",
"defaultCategory",
"=",
"'Uncategorized'",
";",
"const",
"sourcesByCategories",
"=",
"sources",
".",
"// get category names",
"reduce",
"(",
"(",
"categories",
",",
"source",
")",
"=>",
"categories",
".",... | Creates navigation object.
@param {Array<Source>} sources
@returns {Array<Object>} | [
"Creates",
"navigation",
"object",
"."
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/packages/docs/webpack-docs-plugin.setup.js#L123-L148 |
17,308 | JetBrains/ring-ui | components/dialog-ng/dialog-ng.js | focusFirst | function focusFirst() {
const controls = node.queryAll('input,select,button,textarea,*[contentEditable=true]').
filter(inputNode => getStyles(inputNode).display !== 'none');
if (controls.length) {
controls[0].focus();
}
} | javascript | function focusFirst() {
const controls = node.queryAll('input,select,button,textarea,*[contentEditable=true]').
filter(inputNode => getStyles(inputNode).display !== 'none');
if (controls.length) {
controls[0].focus();
}
} | [
"function",
"focusFirst",
"(",
")",
"{",
"const",
"controls",
"=",
"node",
".",
"queryAll",
"(",
"'input,select,button,textarea,*[contentEditable=true]'",
")",
".",
"filter",
"(",
"inputNode",
"=>",
"getStyles",
"(",
"inputNode",
")",
".",
"display",
"!==",
"'none... | Focus first input | [
"Focus",
"first",
"input"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/dialog-ng/dialog-ng.js#L405-L411 |
17,309 | JetBrains/ring-ui | components/docked-panel-ng/docked-panel-ng.js | dock | function dock() {
onBeforeDock();
panel.classList.add(DOCKED_CSS_CLASS_NAME);
if (dockedPanelClass) {
panel.classList.add(dockedPanelClass);
}
isDocked = true;
} | javascript | function dock() {
onBeforeDock();
panel.classList.add(DOCKED_CSS_CLASS_NAME);
if (dockedPanelClass) {
panel.classList.add(dockedPanelClass);
}
isDocked = true;
} | [
"function",
"dock",
"(",
")",
"{",
"onBeforeDock",
"(",
")",
";",
"panel",
".",
"classList",
".",
"add",
"(",
"DOCKED_CSS_CLASS_NAME",
")",
";",
"if",
"(",
"dockedPanelClass",
")",
"{",
"panel",
".",
"classList",
".",
"add",
"(",
"dockedPanelClass",
")",
... | Docks the panel to the bottom of the page | [
"Docks",
"the",
"panel",
"to",
"the",
"bottom",
"of",
"the",
"page"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/docked-panel-ng/docked-panel-ng.js#L119-L127 |
17,310 | JetBrains/ring-ui | components/docked-panel-ng/docked-panel-ng.js | checkPanelPosition | function checkPanelPosition() {
const currentPanelRect = panel.getBoundingClientRect();
if (currentPanelRect.top + currentPanelRect.height > getScrollContainerHeight() &&
!isDocked) {
dock();
} else if (
isDocked &&
currentPanelRect.top + currentPanelRect... | javascript | function checkPanelPosition() {
const currentPanelRect = panel.getBoundingClientRect();
if (currentPanelRect.top + currentPanelRect.height > getScrollContainerHeight() &&
!isDocked) {
dock();
} else if (
isDocked &&
currentPanelRect.top + currentPanelRect... | [
"function",
"checkPanelPosition",
"(",
")",
"{",
"const",
"currentPanelRect",
"=",
"panel",
".",
"getBoundingClientRect",
"(",
")",
";",
"if",
"(",
"currentPanelRect",
".",
"top",
"+",
"currentPanelRect",
".",
"height",
">",
"getScrollContainerHeight",
"(",
")",
... | Check panel position | [
"Check",
"panel",
"position"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/docked-panel-ng/docked-panel-ng.js#L150-L163 |
17,311 | JetBrains/ring-ui | components/old-browsers-message/old-browsers-message.js | startOldBrowsersDetector | function startOldBrowsersDetector(onOldBrowserDetected) {
previousWindowErrorHandler = window.onerror;
window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) {
if (onOldBrowserDetected) {
onOldBrowserDetected();
}
if (previousWindowErrorHandler) {
return previousWind... | javascript | function startOldBrowsersDetector(onOldBrowserDetected) {
previousWindowErrorHandler = window.onerror;
window.onerror = function oldBrowsersMessageShower(errorMsg, url, lineNumber) {
if (onOldBrowserDetected) {
onOldBrowserDetected();
}
if (previousWindowErrorHandler) {
return previousWind... | [
"function",
"startOldBrowsersDetector",
"(",
"onOldBrowserDetected",
")",
"{",
"previousWindowErrorHandler",
"=",
"window",
".",
"onerror",
";",
"window",
".",
"onerror",
"=",
"function",
"oldBrowsersMessageShower",
"(",
"errorMsg",
",",
"url",
",",
"lineNumber",
")",... | Listens to unhandled errors and displays passed node | [
"Listens",
"to",
"unhandled",
"errors",
"and",
"displays",
"passed",
"node"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/old-browsers-message/old-browsers-message.js#L98-L112 |
17,312 | JetBrains/ring-ui | components/autofocus-ng/autofocus-ng.js | focusOnElement | function focusOnElement(element) {
if (!element) {
return;
}
if (element.hasAttribute(RING_SELECT) || element.tagName.toLowerCase() === RING_SELECT) {
focusOnElement(element.querySelector(RING_SELECT_SELECTOR));
return;
}
if (element.matches(FOCUSABLE_ELEMENTS) && element.focus) ... | javascript | function focusOnElement(element) {
if (!element) {
return;
}
if (element.hasAttribute(RING_SELECT) || element.tagName.toLowerCase() === RING_SELECT) {
focusOnElement(element.querySelector(RING_SELECT_SELECTOR));
return;
}
if (element.matches(FOCUSABLE_ELEMENTS) && element.focus) ... | [
"function",
"focusOnElement",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
")",
"{",
"return",
";",
"}",
"if",
"(",
"element",
".",
"hasAttribute",
"(",
"RING_SELECT",
")",
"||",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"===",
"... | Focuses on element itself if it has "focus" method.
Searches and focuses on select's button or input if element is rg-select
@param element | [
"Focuses",
"on",
"element",
"itself",
"if",
"it",
"has",
"focus",
"method",
".",
"Searches",
"and",
"focuses",
"on",
"select",
"s",
"button",
"or",
"input",
"if",
"element",
"is",
"rg",
"-",
"select"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/autofocus-ng/autofocus-ng.js#L23-L43 |
17,313 | JetBrains/ring-ui | components/date-picker/months.js | scrollSpeed | function scrollSpeed(date) {
const monthStart = moment(date).startOf('month');
const monthEnd = moment(date).endOf('month');
return (monthEnd - monthStart) / monthHeight(monthStart);
} | javascript | function scrollSpeed(date) {
const monthStart = moment(date).startOf('month');
const monthEnd = moment(date).endOf('month');
return (monthEnd - monthStart) / monthHeight(monthStart);
} | [
"function",
"scrollSpeed",
"(",
"date",
")",
"{",
"const",
"monthStart",
"=",
"moment",
"(",
"date",
")",
".",
"startOf",
"(",
"'month'",
")",
";",
"const",
"monthEnd",
"=",
"moment",
"(",
"date",
")",
".",
"endOf",
"(",
"'month'",
")",
";",
"return",
... | in milliseconds per pixel | [
"in",
"milliseconds",
"per",
"pixel"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/date-picker/months.js#L32-L36 |
17,314 | JetBrains/ring-ui | components/grid/row.js | getModifierClassNames | function getModifierClassNames(props) {
return modifierKeys.reduce((result, key) => {
if (props[key]) {
return result.concat(styles[`${key}-${props[key]}`]);
}
return result;
}, []);
} | javascript | function getModifierClassNames(props) {
return modifierKeys.reduce((result, key) => {
if (props[key]) {
return result.concat(styles[`${key}-${props[key]}`]);
}
return result;
}, []);
} | [
"function",
"getModifierClassNames",
"(",
"props",
")",
"{",
"return",
"modifierKeys",
".",
"reduce",
"(",
"(",
"result",
",",
"key",
")",
"=>",
"{",
"if",
"(",
"props",
"[",
"key",
"]",
")",
"{",
"return",
"result",
".",
"concat",
"(",
"styles",
"[",
... | Converts xs="middle" to class "middle-xs"
@param {Object} props incoming props
@returns {Array} result modifier classes | [
"Converts",
"xs",
"=",
"middle",
"to",
"class",
"middle",
"-",
"xs"
] | fa7c39f47a91bb4b75d642834cad5409715a8402 | https://github.com/JetBrains/ring-ui/blob/fa7c39f47a91bb4b75d642834cad5409715a8402/components/grid/row.js#L20-L27 |
17,315 | mattdesl/budo | lib/budo.js | watch | function watch (glob, watchOpt) {
if (!started) {
deferredWatch = emitter.watch.bind(null, glob, watchOpt)
} else {
// destroy previous
if (fileWatcher) fileWatcher.close()
glob = glob && glob.length > 0 ? glob : defaultWatchGlob
glob = Array.isArray(glob) ? glob : [ glob ]
w... | javascript | function watch (glob, watchOpt) {
if (!started) {
deferredWatch = emitter.watch.bind(null, glob, watchOpt)
} else {
// destroy previous
if (fileWatcher) fileWatcher.close()
glob = glob && glob.length > 0 ? glob : defaultWatchGlob
glob = Array.isArray(glob) ? glob : [ glob ]
w... | [
"function",
"watch",
"(",
"glob",
",",
"watchOpt",
")",
"{",
"if",
"(",
"!",
"started",
")",
"{",
"deferredWatch",
"=",
"emitter",
".",
"watch",
".",
"bind",
"(",
"null",
",",
"glob",
",",
"watchOpt",
")",
"}",
"else",
"{",
"// destroy previous",
"if",... | enable file watch capabilities | [
"enable",
"file",
"watch",
"capabilities"
] | 6800de2b083ba390a0936fce3f72c448d4b1ae3a | https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/budo.js#L199-L213 |
17,316 | mattdesl/budo | lib/budo.js | live | function live (liveOpts) {
if (!started) {
deferredLive = emitter.live.bind(null, liveOpts)
} else {
// destroy previous
if (reloader) reloader.close()
// pass some options for the server middleware
server.setLiveOptions(xtend(liveOpts))
// create a web socket server for li... | javascript | function live (liveOpts) {
if (!started) {
deferredLive = emitter.live.bind(null, liveOpts)
} else {
// destroy previous
if (reloader) reloader.close()
// pass some options for the server middleware
server.setLiveOptions(xtend(liveOpts))
// create a web socket server for li... | [
"function",
"live",
"(",
"liveOpts",
")",
"{",
"if",
"(",
"!",
"started",
")",
"{",
"deferredLive",
"=",
"emitter",
".",
"live",
".",
"bind",
"(",
"null",
",",
"liveOpts",
")",
"}",
"else",
"{",
"// destroy previous",
"if",
"(",
"reloader",
")",
"reloa... | enables LiveReload capabilities | [
"enables",
"LiveReload",
"capabilities"
] | 6800de2b083ba390a0936fce3f72c448d4b1ae3a | https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/budo.js#L216-L230 |
17,317 | mattdesl/budo | lib/error-handler.js | parseError | function parseError (err) {
var filePath, lineNum, splitLines
var result = {}
// For root files that syntax-error doesn't pick up:
var parseFilePrefix = 'Parsing file '
if (err.indexOf(parseFilePrefix) === 0) {
var pathWithErr = err.substring(parseFilePrefix.length)
filePath = getFilePa... | javascript | function parseError (err) {
var filePath, lineNum, splitLines
var result = {}
// For root files that syntax-error doesn't pick up:
var parseFilePrefix = 'Parsing file '
if (err.indexOf(parseFilePrefix) === 0) {
var pathWithErr = err.substring(parseFilePrefix.length)
filePath = getFilePa... | [
"function",
"parseError",
"(",
"err",
")",
"{",
"var",
"filePath",
",",
"lineNum",
",",
"splitLines",
"var",
"result",
"=",
"{",
"}",
"// For root files that syntax-error doesn't pick up:",
"var",
"parseFilePrefix",
"=",
"'Parsing file '",
"if",
"(",
"err",
".",
"... | parse an error message into pieces | [
"parse",
"an",
"error",
"message",
"into",
"pieces"
] | 6800de2b083ba390a0936fce3f72c448d4b1ae3a | https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/error-handler.js#L149-L221 |
17,318 | mattdesl/budo | lib/error-handler.js | getFilePath | function getFilePath (str) {
var hasRoot = /^[a-z]:/i.exec(str)
var colonLeftIndex = 0
if (hasRoot) {
colonLeftIndex = hasRoot[0].length
}
var pathEnd = str.split('\n')[0].indexOf(':', colonLeftIndex)
if (pathEnd === -1) {
// invalid string, return non-formattable result
return... | javascript | function getFilePath (str) {
var hasRoot = /^[a-z]:/i.exec(str)
var colonLeftIndex = 0
if (hasRoot) {
colonLeftIndex = hasRoot[0].length
}
var pathEnd = str.split('\n')[0].indexOf(':', colonLeftIndex)
if (pathEnd === -1) {
// invalid string, return non-formattable result
return... | [
"function",
"getFilePath",
"(",
"str",
")",
"{",
"var",
"hasRoot",
"=",
"/",
"^[a-z]:",
"/",
"i",
".",
"exec",
"(",
"str",
")",
"var",
"colonLeftIndex",
"=",
"0",
"if",
"(",
"hasRoot",
")",
"{",
"colonLeftIndex",
"=",
"hasRoot",
"[",
"0",
"]",
".",
... | get a file path from the error message | [
"get",
"a",
"file",
"path",
"from",
"the",
"error",
"message"
] | 6800de2b083ba390a0936fce3f72c448d4b1ae3a | https://github.com/mattdesl/budo/blob/6800de2b083ba390a0936fce3f72c448d4b1ae3a/lib/error-handler.js#L224-L236 |
17,319 | thysultan/stylis.js | docs/assets/javascript/editor.js | update | function update (e) {
// tab indent
if (e.keyCode === 9) {
e.preventDefault();
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var text = document.createTextNode('\t');
range.deleteContents();
range.insertNode(text);
range.setSta... | javascript | function update (e) {
// tab indent
if (e.keyCode === 9) {
e.preventDefault();
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var text = document.createTextNode('\t');
range.deleteContents();
range.insertNode(text);
range.setSta... | [
"function",
"update",
"(",
"e",
")",
"{",
"// tab indent",
"if",
"(",
"e",
".",
"keyCode",
"===",
"9",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"selection",
"=",
"window",
".",
"getSelection",
"(",
")",
";",
"var",
"range",
"=",
... | update output preview | [
"update",
"output",
"preview"
] | 4561e9bc830fccf1cb0e9e9838488b4d1d5cebf5 | https://github.com/thysultan/stylis.js/blob/4561e9bc830fccf1cb0e9e9838488b4d1d5cebf5/docs/assets/javascript/editor.js#L28-L66 |
17,320 | Automattic/cli-table | lib/utils.js | options | function options(defaults, opts) {
for (var p in opts) {
if (opts[p] && opts[p].constructor && opts[p].constructor === Object) {
defaults[p] = defaults[p] || {};
options(defaults[p], opts[p]);
} else {
defaults[p] = opts[p];
}
}
return defaults;
} | javascript | function options(defaults, opts) {
for (var p in opts) {
if (opts[p] && opts[p].constructor && opts[p].constructor === Object) {
defaults[p] = defaults[p] || {};
options(defaults[p], opts[p]);
} else {
defaults[p] = opts[p];
}
}
return defaults;
} | [
"function",
"options",
"(",
"defaults",
",",
"opts",
")",
"{",
"for",
"(",
"var",
"p",
"in",
"opts",
")",
"{",
"if",
"(",
"opts",
"[",
"p",
"]",
"&&",
"opts",
"[",
"p",
"]",
".",
"constructor",
"&&",
"opts",
"[",
"p",
"]",
".",
"constructor",
"... | Copies and merges options with defaults.
@param {Object} defaults
@param {Object} supplied options
@return {Object} new (merged) object | [
"Copies",
"and",
"merges",
"options",
"with",
"defaults",
"."
] | 7b14232ba779929e1859b267bf753c150d90a618 | https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/utils.js#L60-L70 |
17,321 | Automattic/cli-table | lib/index.js | line | function line (line, left, right, intersection){
var width = 0
, line =
left
+ repeat(line, totalWidth - 2)
+ right;
colWidths.forEach(function (w, i){
if (i == colWidths.length - 1) return;
width += w + 1;
line = line.substr(0, width) + intersection + line.sub... | javascript | function line (line, left, right, intersection){
var width = 0
, line =
left
+ repeat(line, totalWidth - 2)
+ right;
colWidths.forEach(function (w, i){
if (i == colWidths.length - 1) return;
width += w + 1;
line = line.substr(0, width) + intersection + line.sub... | [
"function",
"line",
"(",
"line",
",",
"left",
",",
"right",
",",
"intersection",
")",
"{",
"var",
"width",
"=",
"0",
",",
"line",
"=",
"left",
"+",
"repeat",
"(",
"line",
",",
"totalWidth",
"-",
"2",
")",
"+",
"right",
";",
"colWidths",
".",
"forEa... | draws a line | [
"draws",
"a",
"line"
] | 7b14232ba779929e1859b267bf753c150d90a618 | https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L137-L151 |
17,322 | Automattic/cli-table | lib/index.js | lineTop | function lineTop (){
var l = line(chars.top
, chars['top-left'] || chars.top
, chars['top-right'] || chars.top
, chars['top-mid']);
if (l)
ret += l + "\n";
} | javascript | function lineTop (){
var l = line(chars.top
, chars['top-left'] || chars.top
, chars['top-right'] || chars.top
, chars['top-mid']);
if (l)
ret += l + "\n";
} | [
"function",
"lineTop",
"(",
")",
"{",
"var",
"l",
"=",
"line",
"(",
"chars",
".",
"top",
",",
"chars",
"[",
"'top-left'",
"]",
"||",
"chars",
".",
"top",
",",
"chars",
"[",
"'top-right'",
"]",
"||",
"chars",
".",
"top",
",",
"chars",
"[",
"'top-mid... | draws the top line | [
"draws",
"the",
"top",
"line"
] | 7b14232ba779929e1859b267bf753c150d90a618 | https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L154-L161 |
17,323 | Automattic/cli-table | lib/index.js | string | function string (str, index){
var str = String(typeof str == 'object' && str.text ? str.text : str)
, length = utils.strlen(str)
, width = colWidths[index]
- (style['padding-left'] || 0)
- (style['padding-right'] || 0)
, align = options.colAligns[index] || 'left';
return r... | javascript | function string (str, index){
var str = String(typeof str == 'object' && str.text ? str.text : str)
, length = utils.strlen(str)
, width = colWidths[index]
- (style['padding-left'] || 0)
- (style['padding-right'] || 0)
, align = options.colAligns[index] || 'left';
return r... | [
"function",
"string",
"(",
"str",
",",
"index",
")",
"{",
"var",
"str",
"=",
"String",
"(",
"typeof",
"str",
"==",
"'object'",
"&&",
"str",
".",
"text",
"?",
"str",
".",
"text",
":",
"str",
")",
",",
"length",
"=",
"utils",
".",
"strlen",
"(",
"s... | renders a string, by padding it or truncating it | [
"renders",
"a",
"string",
"by",
"padding",
"it",
"or",
"truncating",
"it"
] | 7b14232ba779929e1859b267bf753c150d90a618 | https://github.com/Automattic/cli-table/blob/7b14232ba779929e1859b267bf753c150d90a618/lib/index.js#L236-L252 |
17,324 | jshttp/mime-types | index.js | charset | function charset (type) {
if (!type || typeof type !== 'string') {
return false
}
// TODO: use media-typer
var match = EXTRACT_TYPE_REGEXP.exec(type)
var mime = match && db[match[1].toLowerCase()]
if (mime && mime.charset) {
return mime.charset
}
// default text/* to utf-8
if (match && TEXT... | javascript | function charset (type) {
if (!type || typeof type !== 'string') {
return false
}
// TODO: use media-typer
var match = EXTRACT_TYPE_REGEXP.exec(type)
var mime = match && db[match[1].toLowerCase()]
if (mime && mime.charset) {
return mime.charset
}
// default text/* to utf-8
if (match && TEXT... | [
"function",
"charset",
"(",
"type",
")",
"{",
"if",
"(",
"!",
"type",
"||",
"typeof",
"type",
"!==",
"'string'",
")",
"{",
"return",
"false",
"}",
"// TODO: use media-typer",
"var",
"match",
"=",
"EXTRACT_TYPE_REGEXP",
".",
"exec",
"(",
"type",
")",
"var",... | Get the default charset for a MIME type.
@param {string} type
@return {boolean|string} | [
"Get",
"the",
"default",
"charset",
"for",
"a",
"MIME",
"type",
"."
] | e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0 | https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L49-L68 |
17,325 | jshttp/mime-types | index.js | contentType | function contentType (str) {
// TODO: should this even be in this module?
if (!str || typeof str !== 'string') {
return false
}
var mime = str.indexOf('/') === -1
? exports.lookup(str)
: str
if (!mime) {
return false
}
// TODO: use content-type or other module
if (mime.indexOf('charse... | javascript | function contentType (str) {
// TODO: should this even be in this module?
if (!str || typeof str !== 'string') {
return false
}
var mime = str.indexOf('/') === -1
? exports.lookup(str)
: str
if (!mime) {
return false
}
// TODO: use content-type or other module
if (mime.indexOf('charse... | [
"function",
"contentType",
"(",
"str",
")",
"{",
"// TODO: should this even be in this module?",
"if",
"(",
"!",
"str",
"||",
"typeof",
"str",
"!==",
"'string'",
")",
"{",
"return",
"false",
"}",
"var",
"mime",
"=",
"str",
".",
"indexOf",
"(",
"'/'",
")",
... | Create a full Content-Type header given a MIME type or extension.
@param {string} str
@return {boolean|string} | [
"Create",
"a",
"full",
"Content",
"-",
"Type",
"header",
"given",
"a",
"MIME",
"type",
"or",
"extension",
"."
] | e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0 | https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L77-L98 |
17,326 | jshttp/mime-types | index.js | extension | function extension (type) {
if (!type || typeof type !== 'string') {
return false
}
// TODO: use media-typer
var match = EXTRACT_TYPE_REGEXP.exec(type)
// get extensions
var exts = match && exports.extensions[match[1].toLowerCase()]
if (!exts || !exts.length) {
return false
}
return exts[0... | javascript | function extension (type) {
if (!type || typeof type !== 'string') {
return false
}
// TODO: use media-typer
var match = EXTRACT_TYPE_REGEXP.exec(type)
// get extensions
var exts = match && exports.extensions[match[1].toLowerCase()]
if (!exts || !exts.length) {
return false
}
return exts[0... | [
"function",
"extension",
"(",
"type",
")",
"{",
"if",
"(",
"!",
"type",
"||",
"typeof",
"type",
"!==",
"'string'",
")",
"{",
"return",
"false",
"}",
"// TODO: use media-typer",
"var",
"match",
"=",
"EXTRACT_TYPE_REGEXP",
".",
"exec",
"(",
"type",
")",
"// ... | Get the default extension for a MIME type.
@param {string} type
@return {boolean|string} | [
"Get",
"the",
"default",
"extension",
"for",
"a",
"MIME",
"type",
"."
] | e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0 | https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L107-L123 |
17,327 | jshttp/mime-types | index.js | populateMaps | function populateMaps (extensions, types) {
// source preference (least -> most)
var preference = ['nginx', 'apache', undefined, 'iana']
Object.keys(db).forEach(function forEachMimeType (type) {
var mime = db[type]
var exts = mime.extensions
if (!exts || !exts.length) {
return
}
// mi... | javascript | function populateMaps (extensions, types) {
// source preference (least -> most)
var preference = ['nginx', 'apache', undefined, 'iana']
Object.keys(db).forEach(function forEachMimeType (type) {
var mime = db[type]
var exts = mime.extensions
if (!exts || !exts.length) {
return
}
// mi... | [
"function",
"populateMaps",
"(",
"extensions",
",",
"types",
")",
"{",
"// source preference (least -> most)",
"var",
"preference",
"=",
"[",
"'nginx'",
",",
"'apache'",
",",
"undefined",
",",
"'iana'",
"]",
"Object",
".",
"keys",
"(",
"db",
")",
".",
"forEach... | Populate the extensions and types maps.
@private | [
"Populate",
"the",
"extensions",
"and",
"types",
"maps",
"."
] | e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0 | https://github.com/jshttp/mime-types/blob/e5b5f41ef0d7e4e66eb9baeec7920c0cd9ec81f0/index.js#L154-L188 |
17,328 | observing/pre-commit | install.js | getGitFolderPath | function getGitFolderPath(currentPath) {
var git = path.resolve(currentPath, '.git')
if (!exists(git) || !fs.lstatSync(git).isDirectory()) {
console.log('pre-commit:');
console.log('pre-commit: Not found .git folder in', git);
var newPath = path.resolve(currentPath, '..');
// Stop if we on to... | javascript | function getGitFolderPath(currentPath) {
var git = path.resolve(currentPath, '.git')
if (!exists(git) || !fs.lstatSync(git).isDirectory()) {
console.log('pre-commit:');
console.log('pre-commit: Not found .git folder in', git);
var newPath = path.resolve(currentPath, '..');
// Stop if we on to... | [
"function",
"getGitFolderPath",
"(",
"currentPath",
")",
"{",
"var",
"git",
"=",
"path",
".",
"resolve",
"(",
"currentPath",
",",
"'.git'",
")",
"if",
"(",
"!",
"exists",
"(",
"git",
")",
"||",
"!",
"fs",
".",
"lstatSync",
"(",
"git",
")",
".",
"isDi... | Function to recursively finding .git folder | [
"Function",
"to",
"recursively",
"finding",
".",
"git",
"folder"
] | 84aa9eac11634d8fe6053fa7946dee5b77f09581 | https://github.com/observing/pre-commit/blob/84aa9eac11634d8fe6053fa7946dee5b77f09581/install.js#L23-L43 |
17,329 | observing/pre-commit | index.js | Hook | function Hook(fn, options) {
if (!this) return new Hook(fn, options);
options = options || {};
this.options = options; // Used for testing only. Ignore this. Don't touch.
this.config = {}; // pre-commit configuration from the `package.json`.
this.json = {}; // Actual content of the ... | javascript | function Hook(fn, options) {
if (!this) return new Hook(fn, options);
options = options || {};
this.options = options; // Used for testing only. Ignore this. Don't touch.
this.config = {}; // pre-commit configuration from the `package.json`.
this.json = {}; // Actual content of the ... | [
"function",
"Hook",
"(",
"fn",
",",
"options",
")",
"{",
"if",
"(",
"!",
"this",
")",
"return",
"new",
"Hook",
"(",
"fn",
",",
"options",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"options",
";",
"// U... | Representation of a hook runner.
@constructor
@param {Function} fn Function to be called when we want to exit
@param {Object} options Optional configuration, primarily used for testing.
@api public | [
"Representation",
"of",
"a",
"hook",
"runner",
"."
] | 84aa9eac11634d8fe6053fa7946dee5b77f09581 | https://github.com/observing/pre-commit/blob/84aa9eac11634d8fe6053fa7946dee5b77f09581/index.js#L17-L31 |
17,330 | davidyack/Xrm.Tools.CRMWebAPI | JS/Examples/SinglePage/app/scripts/app.js | loadView | function loadView(view) {
$errorMessage.empty();
var ctrl = loadCtrl(view);
if (!ctrl)
return;
// Check if View Requires Authentication
if (ctrl.requireADLogin && !authContext.getCachedUser()) {
authContext.config.redirectUri = window.location.href;
... | javascript | function loadView(view) {
$errorMessage.empty();
var ctrl = loadCtrl(view);
if (!ctrl)
return;
// Check if View Requires Authentication
if (ctrl.requireADLogin && !authContext.getCachedUser()) {
authContext.config.redirectUri = window.location.href;
... | [
"function",
"loadView",
"(",
"view",
")",
"{",
"$errorMessage",
".",
"empty",
"(",
")",
";",
"var",
"ctrl",
"=",
"loadCtrl",
"(",
"view",
")",
";",
"if",
"(",
"!",
"ctrl",
")",
"return",
";",
"// Check if View Requires Authentication",
"if",
"(",
"ctrl",
... | Show a View | [
"Show",
"a",
"View"
] | c5569bb668e34d87fe4cba0f4089973943ab0ca0 | https://github.com/davidyack/Xrm.Tools.CRMWebAPI/blob/c5569bb668e34d87fe4cba0f4089973943ab0ca0/JS/Examples/SinglePage/app/scripts/app.js#L79-L112 |
17,331 | benwiley4000/cassette | packages/core/src/utils/getSourceList.js | getSourceList | function getSourceList(playlist) {
return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src);
} | javascript | function getSourceList(playlist) {
return (playlist || []).map((_, i) => getTrackSources(playlist, i)[0].src);
} | [
"function",
"getSourceList",
"(",
"playlist",
")",
"{",
"return",
"(",
"playlist",
"||",
"[",
"]",
")",
".",
"map",
"(",
"(",
"_",
",",
"i",
")",
"=>",
"getTrackSources",
"(",
"playlist",
",",
"i",
")",
"[",
"0",
"]",
".",
"src",
")",
";",
"}"
] | collapses playlist into flat list containing the first source url for each track | [
"collapses",
"playlist",
"into",
"flat",
"list",
"containing",
"the",
"first",
"source",
"url",
"for",
"each",
"track"
] | 2f6e15a911addb27fdf0d876e92c29c94779c1ca | https://github.com/benwiley4000/cassette/blob/2f6e15a911addb27fdf0d876e92c29c94779c1ca/packages/core/src/utils/getSourceList.js#L5-L7 |
17,332 | benwiley4000/cassette | packages/core/src/PlayerContextProvider.js | getGoToTrackState | function getGoToTrackState({
prevState,
index,
track,
shouldPlay = true,
shouldForceLoad = false
}) {
const isNewTrack = prevState.activeTrackIndex !== index;
const shouldLoadAsNew = Boolean(isNewTrack || shouldForceLoad);
const currentTime = track.startingTime || 0;
return {
duration: getInitialD... | javascript | function getGoToTrackState({
prevState,
index,
track,
shouldPlay = true,
shouldForceLoad = false
}) {
const isNewTrack = prevState.activeTrackIndex !== index;
const shouldLoadAsNew = Boolean(isNewTrack || shouldForceLoad);
const currentTime = track.startingTime || 0;
return {
duration: getInitialD... | [
"function",
"getGoToTrackState",
"(",
"{",
"prevState",
",",
"index",
",",
"track",
",",
"shouldPlay",
"=",
"true",
",",
"shouldForceLoad",
"=",
"false",
"}",
")",
"{",
"const",
"isNewTrack",
"=",
"prevState",
".",
"activeTrackIndex",
"!==",
"index",
";",
"c... | assumes playlist is valid | [
"assumes",
"playlist",
"is",
"valid"
] | 2f6e15a911addb27fdf0d876e92c29c94779c1ca | https://github.com/benwiley4000/cassette/blob/2f6e15a911addb27fdf0d876e92c29c94779c1ca/packages/core/src/PlayerContextProvider.js#L83-L105 |
17,333 | morajabi/styled-media-query | src/convertors.js | pxToEmOrRem | function pxToEmOrRem(breakpoints, ratio = 16, unit) {
const newBreakpoints = {};
for (let key in breakpoints) {
const point = breakpoints[key];
if (String(point).includes('px')) {
newBreakpoints[key] = +(parseInt(point) / ratio) + unit;
continue;
}
newBreakpoints[key] = point;
}
... | javascript | function pxToEmOrRem(breakpoints, ratio = 16, unit) {
const newBreakpoints = {};
for (let key in breakpoints) {
const point = breakpoints[key];
if (String(point).includes('px')) {
newBreakpoints[key] = +(parseInt(point) / ratio) + unit;
continue;
}
newBreakpoints[key] = point;
}
... | [
"function",
"pxToEmOrRem",
"(",
"breakpoints",
",",
"ratio",
"=",
"16",
",",
"unit",
")",
"{",
"const",
"newBreakpoints",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"key",
"in",
"breakpoints",
")",
"{",
"const",
"point",
"=",
"breakpoints",
"[",
"key",
"]"... | Converts breakpoint units in px to rem or em
@param {Object} breakpoints - an object containing breakpoint names as keys and the width as value
@param {number} ratio [16] - size of 1 rem in px. What is your main font-size in px?
@param {'rem' | 'em'} unit | [
"Converts",
"breakpoint",
"units",
"in",
"px",
"to",
"rem",
"or",
"em"
] | 687a2089dbf46924783a8b157f4d3ebcdead7b3b | https://github.com/morajabi/styled-media-query/blob/687a2089dbf46924783a8b157f4d3ebcdead7b3b/src/convertors.js#L7-L22 |
17,334 | Automattic/monk | lib/manager.js | Manager | function Manager (uri, opts, fn) {
if (!uri) {
throw Error('No connection URI provided.')
}
if (!(this instanceof Manager)) {
return new Manager(uri, opts, fn)
}
if (typeof opts === 'function') {
fn = opts
opts = {}
}
opts = opts || {}
this._collectionOptions = objectAssign({}, DEFAU... | javascript | function Manager (uri, opts, fn) {
if (!uri) {
throw Error('No connection URI provided.')
}
if (!(this instanceof Manager)) {
return new Manager(uri, opts, fn)
}
if (typeof opts === 'function') {
fn = opts
opts = {}
}
opts = opts || {}
this._collectionOptions = objectAssign({}, DEFAU... | [
"function",
"Manager",
"(",
"uri",
",",
"opts",
",",
"fn",
")",
"{",
"if",
"(",
"!",
"uri",
")",
"{",
"throw",
"Error",
"(",
"'No connection URI provided.'",
")",
"}",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Manager",
")",
")",
"{",
"return",
"ne... | Monk constructor.
@param {Array|String} uri replica sets can be an array or
comma-separated
@param {Object|Function} opts or connect callback
@param {Function} fn connect callback
@return {Promise} resolve when the connection is opened | [
"Monk",
"constructor",
"."
] | 39228eacd4d649de884b096624a55472cf20c40a | https://github.com/Automattic/monk/blob/39228eacd4d649de884b096624a55472cf20c40a/lib/manager.js#L47-L116 |
17,335 | flickr/yakbak | index.js | tapename | function tapename(req, body) {
var hash = opts.hash || messageHash.sync;
return hash(req, Buffer.concat(body)) + '.js';
} | javascript | function tapename(req, body) {
var hash = opts.hash || messageHash.sync;
return hash(req, Buffer.concat(body)) + '.js';
} | [
"function",
"tapename",
"(",
"req",
",",
"body",
")",
"{",
"var",
"hash",
"=",
"opts",
".",
"hash",
"||",
"messageHash",
".",
"sync",
";",
"return",
"hash",
"(",
"req",
",",
"Buffer",
".",
"concat",
"(",
"body",
")",
")",
"+",
"'.js'",
";",
"}"
] | Returns the tape name for `req`.
@param {http.IncomingMessage} req
@param {Array.<Buffer>} body
@returns {String} | [
"Returns",
"the",
"tape",
"name",
"for",
"req",
"."
] | 0047013893066a3b3b0a9d3143042c5430e4db75 | https://github.com/flickr/yakbak/blob/0047013893066a3b3b0a9d3143042c5430e4db75/index.js#L70-L74 |
17,336 | flickr/yakbak | lib/record.js | write | function write(filename, data) {
return Promise.fromCallback(function (done) {
debug('write', filename);
fs.writeFile(filename, data, done);
});
} | javascript | function write(filename, data) {
return Promise.fromCallback(function (done) {
debug('write', filename);
fs.writeFile(filename, data, done);
});
} | [
"function",
"write",
"(",
"filename",
",",
"data",
")",
"{",
"return",
"Promise",
".",
"fromCallback",
"(",
"function",
"(",
"done",
")",
"{",
"debug",
"(",
"'write'",
",",
"filename",
")",
";",
"fs",
".",
"writeFile",
"(",
"filename",
",",
"data",
","... | Write `data` to `filename`. Seems overkill to "promisify" this.
@param {String} filename
@param {String} data
@returns {Promise} | [
"Write",
"data",
"to",
"filename",
".",
"Seems",
"overkill",
"to",
"promisify",
"this",
"."
] | 0047013893066a3b3b0a9d3143042c5430e4db75 | https://github.com/flickr/yakbak/blob/0047013893066a3b3b0a9d3143042c5430e4db75/lib/record.js#L46-L51 |
17,337 | fluencelabs/fluence | fluence-js/src/examples/todo-list/index.js | createNewTask | function createNewTask(task) {
console.log("Creating task...");
//set up the new list item
const listItem = document.createElement("li");
const checkBox = document.createElement("input");
const label = document.createElement("label");
//pull the inputed text into label... | javascript | function createNewTask(task) {
console.log("Creating task...");
//set up the new list item
const listItem = document.createElement("li");
const checkBox = document.createElement("input");
const label = document.createElement("label");
//pull the inputed text into label... | [
"function",
"createNewTask",
"(",
"task",
")",
"{",
"console",
".",
"log",
"(",
"\"Creating task...\"",
")",
";",
"//set up the new list item",
"const",
"listItem",
"=",
"document",
".",
"createElement",
"(",
"\"li\"",
")",
";",
"const",
"checkBox",
"=",
"docume... | create functions creating the actual task list item | [
"create",
"functions",
"creating",
"the",
"actual",
"task",
"list",
"item"
] | 2877526629d7efd8aa61e0e250d3498b2837dfb8 | https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L130-L150 |
17,338 | fluencelabs/fluence | fluence-js/src/examples/todo-list/index.js | addTask | function addTask() {
const task = newTask.value.trim();
console.log("Adding task: " + task);
// *****
// *** we need to add a task to the fluence cluster after we pressed the `Add task` button
// *****
addTaskToFluence(task);
updateTaskList(task)
} | javascript | function addTask() {
const task = newTask.value.trim();
console.log("Adding task: " + task);
// *****
// *** we need to add a task to the fluence cluster after we pressed the `Add task` button
// *****
addTaskToFluence(task);
updateTaskList(task)
} | [
"function",
"addTask",
"(",
")",
"{",
"const",
"task",
"=",
"newTask",
".",
"value",
".",
"trim",
"(",
")",
";",
"console",
".",
"log",
"(",
"\"Adding task: \"",
"+",
"task",
")",
";",
"// *****",
"// *** we need to add a task to the fluence cluster after we press... | do the new task into actual incomplete list | [
"do",
"the",
"new",
"task",
"into",
"actual",
"incomplete",
"list"
] | 2877526629d7efd8aa61e0e250d3498b2837dfb8 | https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L187-L198 |
17,339 | fluencelabs/fluence | fluence-js/src/examples/todo-list/index.js | deleteTask | function deleteTask() {
console.log("Deleting task...");
const listItem = this.parentNode;
const ul = listItem.parentNode;
const task = listItem.getElementsByTagName('label')[0].innerText;
// *****
// *** delete a task from the cluster when we press `Delete` button on ... | javascript | function deleteTask() {
console.log("Deleting task...");
const listItem = this.parentNode;
const ul = listItem.parentNode;
const task = listItem.getElementsByTagName('label')[0].innerText;
// *****
// *** delete a task from the cluster when we press `Delete` button on ... | [
"function",
"deleteTask",
"(",
")",
"{",
"console",
".",
"log",
"(",
"\"Deleting task...\"",
")",
";",
"const",
"listItem",
"=",
"this",
".",
"parentNode",
";",
"const",
"ul",
"=",
"listItem",
".",
"parentNode",
";",
"const",
"task",
"=",
"listItem",
".",
... | delete task functions | [
"delete",
"task",
"functions"
] | 2877526629d7efd8aa61e0e250d3498b2837dfb8 | https://github.com/fluencelabs/fluence/blob/2877526629d7efd8aa61e0e250d3498b2837dfb8/fluence-js/src/examples/todo-list/index.js#L242-L257 |
17,340 | xtuc/webassemblyjs | packages/dce/src/used-exports.js | onLocalModuleBinding | function onLocalModuleBinding(ident, ast, acc) {
traverse(ast, {
CallExpression({ node: callExpression }) {
// left must be a member expression
if (t.isMemberExpression(callExpression.callee) === false) {
return;
}
const memberExpression = callExpression.callee;
/**
... | javascript | function onLocalModuleBinding(ident, ast, acc) {
traverse(ast, {
CallExpression({ node: callExpression }) {
// left must be a member expression
if (t.isMemberExpression(callExpression.callee) === false) {
return;
}
const memberExpression = callExpression.callee;
/**
... | [
"function",
"onLocalModuleBinding",
"(",
"ident",
",",
"ast",
",",
"acc",
")",
"{",
"traverse",
"(",
"ast",
",",
"{",
"CallExpression",
"(",
"{",
"node",
":",
"callExpression",
"}",
")",
"{",
"// left must be a member expression",
"if",
"(",
"t",
".",
"isMem... | We found a local binding from the wasm binary.
`import x from 'module.wasm'`
^ | [
"We",
"found",
"a",
"local",
"binding",
"from",
"the",
"wasm",
"binary",
"."
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/dce/src/used-exports.js#L23-L51 |
17,341 | xtuc/webassemblyjs | packages/dce/src/used-exports.js | onInstanceThenFn | function onInstanceThenFn(fn, acc) {
if (t.isArrowFunctionExpression(fn) === false) {
throw new Error("Unsupported function type: " + fn.type);
}
let [localIdent] = fn.params;
/**
* `then(({exports}) => ...)`
*
* We need to resolve the identifier (binding) from the ObjectPattern.
*
* TODO(s... | javascript | function onInstanceThenFn(fn, acc) {
if (t.isArrowFunctionExpression(fn) === false) {
throw new Error("Unsupported function type: " + fn.type);
}
let [localIdent] = fn.params;
/**
* `then(({exports}) => ...)`
*
* We need to resolve the identifier (binding) from the ObjectPattern.
*
* TODO(s... | [
"function",
"onInstanceThenFn",
"(",
"fn",
",",
"acc",
")",
"{",
"if",
"(",
"t",
".",
"isArrowFunctionExpression",
"(",
"fn",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unsupported function type: \"",
"+",
"fn",
".",
"type",
")",
";",
... | We found the function handling the module instance
`makeX().then(...)` | [
"We",
"found",
"the",
"function",
"handling",
"the",
"module",
"instance"
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/dce/src/used-exports.js#L58-L112 |
17,342 | xtuc/webassemblyjs | website/static/js/repl.js | configureMonaco | function configureMonaco() {
monaco.languages.register({ id: "wast" });
monaco.languages.setMonarchTokensProvider("wast", {
tokenizer: {
root: [
[REGEXP_KEYWORD, "keyword"],
[REGEXP_KEYWORD_ASSERTS, "keyword"],
[REGEXP_NUMBER, "number"],
[/\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\... | javascript | function configureMonaco() {
monaco.languages.register({ id: "wast" });
monaco.languages.setMonarchTokensProvider("wast", {
tokenizer: {
root: [
[REGEXP_KEYWORD, "keyword"],
[REGEXP_KEYWORD_ASSERTS, "keyword"],
[REGEXP_NUMBER, "number"],
[/\$([a-zA-Z0-9_`\+\-\*\/\\\^~=<>!\... | [
"function",
"configureMonaco",
"(",
")",
"{",
"monaco",
".",
"languages",
".",
"register",
"(",
"{",
"id",
":",
"\"wast\"",
"}",
")",
";",
"monaco",
".",
"languages",
".",
"setMonarchTokensProvider",
"(",
"\"wast\"",
",",
"{",
"tokenizer",
":",
"{",
"root"... | Monaco wast def | [
"Monaco",
"wast",
"def"
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/website/static/js/repl.js#L16-L40 |
17,343 | xtuc/webassemblyjs | packages/leb128/src/leb.js | encodeBufferCommon | function encodeBufferCommon(buffer, signed) {
let signBit;
let bitCount;
if (signed) {
signBit = bits.getSign(buffer);
bitCount = signedBitCount(buffer);
} else {
signBit = 0;
bitCount = unsignedBitCount(buffer);
}
const byteCount = Math.ceil(bitCount / 7);
const result = bufs.alloc(byte... | javascript | function encodeBufferCommon(buffer, signed) {
let signBit;
let bitCount;
if (signed) {
signBit = bits.getSign(buffer);
bitCount = signedBitCount(buffer);
} else {
signBit = 0;
bitCount = unsignedBitCount(buffer);
}
const byteCount = Math.ceil(bitCount / 7);
const result = bufs.alloc(byte... | [
"function",
"encodeBufferCommon",
"(",
"buffer",
",",
"signed",
")",
"{",
"let",
"signBit",
";",
"let",
"bitCount",
";",
"if",
"(",
"signed",
")",
"{",
"signBit",
"=",
"bits",
".",
"getSign",
"(",
"buffer",
")",
";",
"bitCount",
"=",
"signedBitCount",
"(... | Common encoder for both signed and unsigned ints. This takes a
bigint-ish buffer, returning an LEB128-encoded buffer. | [
"Common",
"encoder",
"for",
"both",
"signed",
"and",
"unsigned",
"ints",
".",
"This",
"takes",
"a",
"bigint",
"-",
"ish",
"buffer",
"returning",
"an",
"LEB128",
"-",
"encoded",
"buffer",
"."
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L95-L119 |
17,344 | xtuc/webassemblyjs | packages/leb128/src/leb.js | encodedLength | function encodedLength(encodedBuffer, index) {
let result = 0;
while (encodedBuffer[index + result] >= 0x80) {
result++;
}
result++; // to account for the last byte
if (index + result > encodedBuffer.length) {
// FIXME(sven): seems to cause false positives
// throw new Error("integer representa... | javascript | function encodedLength(encodedBuffer, index) {
let result = 0;
while (encodedBuffer[index + result] >= 0x80) {
result++;
}
result++; // to account for the last byte
if (index + result > encodedBuffer.length) {
// FIXME(sven): seems to cause false positives
// throw new Error("integer representa... | [
"function",
"encodedLength",
"(",
"encodedBuffer",
",",
"index",
")",
"{",
"let",
"result",
"=",
"0",
";",
"while",
"(",
"encodedBuffer",
"[",
"index",
"+",
"result",
"]",
">=",
"0x80",
")",
"{",
"result",
"++",
";",
"}",
"result",
"++",
";",
"// to ac... | Gets the byte-length of the value encoded in the given buffer at
the given index. | [
"Gets",
"the",
"byte",
"-",
"length",
"of",
"the",
"value",
"encoded",
"in",
"the",
"given",
"buffer",
"at",
"the",
"given",
"index",
"."
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L125-L140 |
17,345 | xtuc/webassemblyjs | packages/leb128/src/leb.js | decodeBufferCommon | function decodeBufferCommon(encodedBuffer, index, signed) {
index = index === undefined ? 0 : index;
let length = encodedLength(encodedBuffer, index);
const bitLength = length * 7;
let byteLength = Math.ceil(bitLength / 8);
let result = bufs.alloc(byteLength);
let outIndex = 0;
while (length > 0) {
... | javascript | function decodeBufferCommon(encodedBuffer, index, signed) {
index = index === undefined ? 0 : index;
let length = encodedLength(encodedBuffer, index);
const bitLength = length * 7;
let byteLength = Math.ceil(bitLength / 8);
let result = bufs.alloc(byteLength);
let outIndex = 0;
while (length > 0) {
... | [
"function",
"decodeBufferCommon",
"(",
"encodedBuffer",
",",
"index",
",",
"signed",
")",
"{",
"index",
"=",
"index",
"===",
"undefined",
"?",
"0",
":",
"index",
";",
"let",
"length",
"=",
"encodedLength",
"(",
"encodedBuffer",
",",
"index",
")",
";",
"con... | Common decoder for both signed and unsigned ints. This takes an
LEB128-encoded buffer, returning a bigint-ish buffer. | [
"Common",
"decoder",
"for",
"both",
"signed",
"and",
"unsigned",
"ints",
".",
"This",
"takes",
"an",
"LEB128",
"-",
"encoded",
"buffer",
"returning",
"a",
"bigint",
"-",
"ish",
"buffer",
"."
] | 32996b42072073f270adc178ce542da1ae9e9704 | https://github.com/xtuc/webassemblyjs/blob/32996b42072073f270adc178ce542da1ae9e9704/packages/leb128/src/leb.js#L146-L192 |
17,346 | expressjs/vhost | index.js | vhost | function vhost (hostname, handle) {
if (!hostname) {
throw new TypeError('argument hostname is required')
}
if (!handle) {
throw new TypeError('argument handle is required')
}
if (typeof handle !== 'function') {
throw new TypeError('argument handle must be a function')
}
// create regular e... | javascript | function vhost (hostname, handle) {
if (!hostname) {
throw new TypeError('argument hostname is required')
}
if (!handle) {
throw new TypeError('argument handle is required')
}
if (typeof handle !== 'function') {
throw new TypeError('argument handle must be a function')
}
// create regular e... | [
"function",
"vhost",
"(",
"hostname",
",",
"handle",
")",
"{",
"if",
"(",
"!",
"hostname",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'argument hostname is required'",
")",
"}",
"if",
"(",
"!",
"handle",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'ar... | Create a vhost middleware.
@param {string|RegExp} hostname
@param {function} handle
@return {Function}
@public | [
"Create",
"a",
"vhost",
"middleware",
"."
] | 1ba557c2e1772ba4b0afe2b7355ff0ec050eff80 | https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L37-L66 |
17,347 | expressjs/vhost | index.js | hostnameof | function hostnameof (req) {
var host = req.headers.host
if (!host) {
return
}
var offset = host[0] === '['
? host.indexOf(']') + 1
: 0
var index = host.indexOf(':', offset)
return index !== -1
? host.substring(0, index)
: host
} | javascript | function hostnameof (req) {
var host = req.headers.host
if (!host) {
return
}
var offset = host[0] === '['
? host.indexOf(']') + 1
: 0
var index = host.indexOf(':', offset)
return index !== -1
? host.substring(0, index)
: host
} | [
"function",
"hostnameof",
"(",
"req",
")",
"{",
"var",
"host",
"=",
"req",
".",
"headers",
".",
"host",
"if",
"(",
"!",
"host",
")",
"{",
"return",
"}",
"var",
"offset",
"=",
"host",
"[",
"0",
"]",
"===",
"'['",
"?",
"host",
".",
"indexOf",
"(",
... | Get hostname of request.
@param (object} req
@return {string}
@private | [
"Get",
"hostname",
"of",
"request",
"."
] | 1ba557c2e1772ba4b0afe2b7355ff0ec050eff80 | https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L76-L91 |
17,348 | expressjs/vhost | index.js | hostregexp | function hostregexp (val) {
var source = !isregexp(val)
? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE)
: val.source
// force leading anchor matching
if (source[0] !== '^') {
source = '^' + source
}
// force trailing anchor matching
if (!END_ANCH... | javascript | function hostregexp (val) {
var source = !isregexp(val)
? String(val).replace(ESCAPE_REGEXP, ESCAPE_REPLACE).replace(ASTERISK_REGEXP, ASTERISK_REPLACE)
: val.source
// force leading anchor matching
if (source[0] !== '^') {
source = '^' + source
}
// force trailing anchor matching
if (!END_ANCH... | [
"function",
"hostregexp",
"(",
"val",
")",
"{",
"var",
"source",
"=",
"!",
"isregexp",
"(",
"val",
")",
"?",
"String",
"(",
"val",
")",
".",
"replace",
"(",
"ESCAPE_REGEXP",
",",
"ESCAPE_REPLACE",
")",
".",
"replace",
"(",
"ASTERISK_REGEXP",
",",
"ASTERI... | Generate RegExp for given hostname value.
@param (string|RegExp} val
@private | [
"Generate",
"RegExp",
"for",
"given",
"hostname",
"value",
"."
] | 1ba557c2e1772ba4b0afe2b7355ff0ec050eff80 | https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L112-L128 |
17,349 | expressjs/vhost | index.js | vhostof | function vhostof (req, regexp) {
var host = req.headers.host
var hostname = hostnameof(req)
if (!hostname) {
return
}
var match = regexp.exec(hostname)
if (!match) {
return
}
var obj = Object.create(null)
obj.host = host
obj.hostname = hostname
obj.length = match.length - 1
for (va... | javascript | function vhostof (req, regexp) {
var host = req.headers.host
var hostname = hostnameof(req)
if (!hostname) {
return
}
var match = regexp.exec(hostname)
if (!match) {
return
}
var obj = Object.create(null)
obj.host = host
obj.hostname = hostname
obj.length = match.length - 1
for (va... | [
"function",
"vhostof",
"(",
"req",
",",
"regexp",
")",
"{",
"var",
"host",
"=",
"req",
".",
"headers",
".",
"host",
"var",
"hostname",
"=",
"hostnameof",
"(",
"req",
")",
"if",
"(",
"!",
"hostname",
")",
"{",
"return",
"}",
"var",
"match",
"=",
"re... | Get the vhost data of the request for RegExp
@param (object} req
@param (RegExp} regexp
@return {object}
@private | [
"Get",
"the",
"vhost",
"data",
"of",
"the",
"request",
"for",
"RegExp"
] | 1ba557c2e1772ba4b0afe2b7355ff0ec050eff80 | https://github.com/expressjs/vhost/blob/1ba557c2e1772ba4b0afe2b7355ff0ec050eff80/index.js#L139-L164 |
17,350 | sheerun/graphqlviz | index.js | analyzeField | function analyzeField (field) {
var obj = {}
var namedType = field.type
obj.name = field.name
obj.isDeprecated = field.isDeprecated
obj.deprecationReason = field.deprecationReason
obj.defaultValue = field.defaultValue
if (namedType.kind === 'NON_NULL') {
obj.isRequired = true
namedType = namedType... | javascript | function analyzeField (field) {
var obj = {}
var namedType = field.type
obj.name = field.name
obj.isDeprecated = field.isDeprecated
obj.deprecationReason = field.deprecationReason
obj.defaultValue = field.defaultValue
if (namedType.kind === 'NON_NULL') {
obj.isRequired = true
namedType = namedType... | [
"function",
"analyzeField",
"(",
"field",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
"var",
"namedType",
"=",
"field",
".",
"type",
"obj",
".",
"name",
"=",
"field",
".",
"name",
"obj",
".",
"isDeprecated",
"=",
"field",
".",
"isDeprecated",
"obj",
".",
... | analyzes a field and returns a simplified object | [
"analyzes",
"a",
"field",
"and",
"returns",
"a",
"simplified",
"object"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L70-L102 |
17,351 | sheerun/graphqlviz | index.js | processType | function processType (item, entities, types) {
var type = _.find(types, { name: item })
var additionalTypes = []
// get the type names of the union or interface's possible types, given its type name
var addPossibleTypes = typeName => {
var union = _.find(types, { name: typeName })
var possibleTypes = _... | javascript | function processType (item, entities, types) {
var type = _.find(types, { name: item })
var additionalTypes = []
// get the type names of the union or interface's possible types, given its type name
var addPossibleTypes = typeName => {
var union = _.find(types, { name: typeName })
var possibleTypes = _... | [
"function",
"processType",
"(",
"item",
",",
"entities",
",",
"types",
")",
"{",
"var",
"type",
"=",
"_",
".",
"find",
"(",
"types",
",",
"{",
"name",
":",
"item",
"}",
")",
"var",
"additionalTypes",
"=",
"[",
"]",
"// get the type names of the union or in... | process a graphql type object returns simplified version of the type | [
"process",
"a",
"graphql",
"type",
"object",
"returns",
"simplified",
"version",
"of",
"the",
"type"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L106-L156 |
17,352 | sheerun/graphqlviz | index.js | walkBFS | function walkBFS (obj, iter) {
var q = _.map(_.keys(obj), k => {
return { key: k, path: '["' + k + '"]' }
})
var current
var currentNode
var retval
var push = (v, k) => {
q.push({ key: k, path: current.path + '["' + k + '"]' })
}
while (q.length) {
current = q.shift()
currentNode = _.ge... | javascript | function walkBFS (obj, iter) {
var q = _.map(_.keys(obj), k => {
return { key: k, path: '["' + k + '"]' }
})
var current
var currentNode
var retval
var push = (v, k) => {
q.push({ key: k, path: current.path + '["' + k + '"]' })
}
while (q.length) {
current = q.shift()
currentNode = _.ge... | [
"function",
"walkBFS",
"(",
"obj",
",",
"iter",
")",
"{",
"var",
"q",
"=",
"_",
".",
"map",
"(",
"_",
".",
"keys",
"(",
"obj",
")",
",",
"k",
"=>",
"{",
"return",
"{",
"key",
":",
"k",
",",
"path",
":",
"'[\"'",
"+",
"k",
"+",
"'\"]'",
"}",... | walks the object in level-order invokes iter at each node if iter returns truthy, breaks & returns the value assumes no cycles | [
"walks",
"the",
"object",
"in",
"level",
"-",
"order",
"invokes",
"iter",
"at",
"each",
"node",
"if",
"iter",
"returns",
"truthy",
"breaks",
"&",
"returns",
"the",
"value",
"assumes",
"no",
"cycles"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L188-L211 |
17,353 | sheerun/graphqlviz | index.js | isEnabled | function isEnabled (obj) {
var enabled = false
if (obj.isEnumType) {
enabled = !this.theme.enums.hide
} else if (obj.isInputType) {
enabled = !this.theme.inputs.hide
} else if (obj.isInterfaceType) {
enabled = !this.theme.interfaces.hide
} else if (obj.isUnionType) {
enabled = !this.theme.unio... | javascript | function isEnabled (obj) {
var enabled = false
if (obj.isEnumType) {
enabled = !this.theme.enums.hide
} else if (obj.isInputType) {
enabled = !this.theme.inputs.hide
} else if (obj.isInterfaceType) {
enabled = !this.theme.interfaces.hide
} else if (obj.isUnionType) {
enabled = !this.theme.unio... | [
"function",
"isEnabled",
"(",
"obj",
")",
"{",
"var",
"enabled",
"=",
"false",
"if",
"(",
"obj",
".",
"isEnumType",
")",
"{",
"enabled",
"=",
"!",
"this",
".",
"theme",
".",
"enums",
".",
"hide",
"}",
"else",
"if",
"(",
"obj",
".",
"isInputType",
"... | get if the object type is enabled | [
"get",
"if",
"the",
"object",
"type",
"is",
"enabled"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L263-L277 |
17,354 | sheerun/graphqlviz | index.js | getColor | function getColor (obj) {
var color = this.theme.types.color
if (obj.isEnumType && !this.theme.enums.hide) {
color = this.theme.enums.color
} else if (obj.isInputType && !this.theme.inputs.hide) {
color = this.theme.inputs.color
} else if (obj.isInterfaceType && !this.theme.interfaces.hide) {
color ... | javascript | function getColor (obj) {
var color = this.theme.types.color
if (obj.isEnumType && !this.theme.enums.hide) {
color = this.theme.enums.color
} else if (obj.isInputType && !this.theme.inputs.hide) {
color = this.theme.inputs.color
} else if (obj.isInterfaceType && !this.theme.interfaces.hide) {
color ... | [
"function",
"getColor",
"(",
"obj",
")",
"{",
"var",
"color",
"=",
"this",
".",
"theme",
".",
"types",
".",
"color",
"if",
"(",
"obj",
".",
"isEnumType",
"&&",
"!",
"this",
".",
"theme",
".",
"enums",
".",
"hide",
")",
"{",
"color",
"=",
"this",
... | get the color for the given field | [
"get",
"the",
"color",
"for",
"the",
"given",
"field"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L280-L292 |
17,355 | sheerun/graphqlviz | index.js | createTable | function createTable (context) {
var result = '"' + context.typeName + '" '
result +=
'[label=<<TABLE COLOR="' +
context.color +
'" BORDER="0" CELLBORDER="1" CELLSPACING="0">'
result +=
'<TR><TD PORT="__title"' +
(this.theme.header.invert ? ' BGCOLOR="' + context.color + '"' : '') +
'><FON... | javascript | function createTable (context) {
var result = '"' + context.typeName + '" '
result +=
'[label=<<TABLE COLOR="' +
context.color +
'" BORDER="0" CELLBORDER="1" CELLSPACING="0">'
result +=
'<TR><TD PORT="__title"' +
(this.theme.header.invert ? ' BGCOLOR="' + context.color + '"' : '') +
'><FON... | [
"function",
"createTable",
"(",
"context",
")",
"{",
"var",
"result",
"=",
"'\"'",
"+",
"context",
".",
"typeName",
"+",
"'\" '",
"result",
"+=",
"'[label=<<TABLE COLOR=\"'",
"+",
"context",
".",
"color",
"+",
"'\" BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">'",
... | For the given context, creates a table for the class with the typeName as the header, and rows as the fields | [
"For",
"the",
"given",
"context",
"creates",
"a",
"table",
"for",
"the",
"class",
"with",
"the",
"typeName",
"as",
"the",
"header",
"and",
"rows",
"as",
"the",
"fields"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L381-L425 |
17,356 | sheerun/graphqlviz | index.js | graph | function graph (processedTypes, typeTheme) {
var result = ''
if (typeTheme.group) {
result += 'subgraph cluster_' + groupId++ + ' {'
if (typeTheme.color) {
result += 'color=' + typeTheme.color + ';'
}
if (typeTheme.groupLabel) {
result += 'label="' + typeTheme.groupLabel + '";'
}
... | javascript | function graph (processedTypes, typeTheme) {
var result = ''
if (typeTheme.group) {
result += 'subgraph cluster_' + groupId++ + ' {'
if (typeTheme.color) {
result += 'color=' + typeTheme.color + ';'
}
if (typeTheme.groupLabel) {
result += 'label="' + typeTheme.groupLabel + '";'
}
... | [
"function",
"graph",
"(",
"processedTypes",
",",
"typeTheme",
")",
"{",
"var",
"result",
"=",
"''",
"if",
"(",
"typeTheme",
".",
"group",
")",
"{",
"result",
"+=",
"'subgraph cluster_'",
"+",
"groupId",
"++",
"+",
"' {'",
"if",
"(",
"typeTheme",
".",
"co... | For the provided simplified types, creates all the tables to represent them. Optionally groups the supplied types in a subgraph. | [
"For",
"the",
"provided",
"simplified",
"types",
"creates",
"all",
"the",
"tables",
"to",
"represent",
"them",
".",
"Optionally",
"groups",
"the",
"supplied",
"types",
"in",
"a",
"subgraph",
"."
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/index.js#L431-L471 |
17,357 | sheerun/graphqlviz | cli.js | fatal | function fatal (e, text) {
console.error('ERROR processing input. Use --verbose flag to see output.')
console.error(e.message)
if (cli.flags.verbose) {
console.error(text)
}
process.exit(1)
} | javascript | function fatal (e, text) {
console.error('ERROR processing input. Use --verbose flag to see output.')
console.error(e.message)
if (cli.flags.verbose) {
console.error(text)
}
process.exit(1)
} | [
"function",
"fatal",
"(",
"e",
",",
"text",
")",
"{",
"console",
".",
"error",
"(",
"'ERROR processing input. Use --verbose flag to see output.'",
")",
"console",
".",
"error",
"(",
"e",
".",
"message",
")",
"if",
"(",
"cli",
".",
"flags",
".",
"verbose",
")... | logs the error and exits | [
"logs",
"the",
"error",
"and",
"exits"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/cli.js#L69-L78 |
17,358 | sheerun/graphqlviz | cli.js | introspect | function introspect (text) {
return new Promise(function (resolve, reject) {
try {
var astDocument = parse(text)
var schema = buildASTSchema(astDocument)
graphql(schema, graphqlviz.query)
.then(function (data) {
resolve(data)
})
.catch(function (e) {
r... | javascript | function introspect (text) {
return new Promise(function (resolve, reject) {
try {
var astDocument = parse(text)
var schema = buildASTSchema(astDocument)
graphql(schema, graphqlviz.query)
.then(function (data) {
resolve(data)
})
.catch(function (e) {
r... | [
"function",
"introspect",
"(",
"text",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"try",
"{",
"var",
"astDocument",
"=",
"parse",
"(",
"text",
")",
"var",
"schema",
"=",
"buildASTSchema",
"(",
"astDocu... | given a "GraphQL schema language" text file, converts into introspection JSON | [
"given",
"a",
"GraphQL",
"schema",
"language",
"text",
"file",
"converts",
"into",
"introspection",
"JSON"
] | 976d12bc3965e487a91892f278194599e51974d8 | https://github.com/sheerun/graphqlviz/blob/976d12bc3965e487a91892f278194599e51974d8/cli.js#L81-L99 |
17,359 | pillarjs/multiparty | index.js | function (done) {
if (called) return;
called = true;
// wait for req events to fire
process.nextTick(function() {
if (waitend && req.readable) {
// dump rest of request
req.resume();
req.once('end', done);
return;
}
done();
... | javascript | function (done) {
if (called) return;
called = true;
// wait for req events to fire
process.nextTick(function() {
if (waitend && req.readable) {
// dump rest of request
req.resume();
req.once('end', done);
return;
}
done();
... | [
"function",
"(",
"done",
")",
"{",
"if",
"(",
"called",
")",
"return",
";",
"called",
"=",
"true",
";",
"// wait for req events to fire",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"waitend",
"&&",
"req",
".",
"readable",
")",... | wait for request to end before calling cb | [
"wait",
"for",
"request",
"to",
"end",
"before",
"calling",
"cb"
] | 7034ca123d9db53827bc8c4a058d79db513d0d3d | https://github.com/pillarjs/multiparty/blob/7034ca123d9db53827bc8c4a058d79db513d0d3d/index.js#L101-L117 | |
17,360 | observing/thor | metrics.js | Metrics | function Metrics(requests) {
this.requests = requests; // The total amount of requests send
this.connections = 0; // Connections established
this.disconnects = 0; // Closed connections
this.failures = 0; // Connections that received an error
thi... | javascript | function Metrics(requests) {
this.requests = requests; // The total amount of requests send
this.connections = 0; // Connections established
this.disconnects = 0; // Closed connections
this.failures = 0; // Connections that received an error
thi... | [
"function",
"Metrics",
"(",
"requests",
")",
"{",
"this",
".",
"requests",
"=",
"requests",
";",
"// The total amount of requests send",
"this",
".",
"connections",
"=",
"0",
";",
"// Connections established",
"this",
".",
"disconnects",
"=",
"0",
";",
"// Closed ... | Metrics collection and generation.
@constructor
@param {Number} requests The total amount of requests scheduled to be send | [
"Metrics",
"collection",
"and",
"generation",
"."
] | 20c51d6c5dcc57a1927ae0c6e77f21836d71f9de | https://github.com/observing/thor/blob/20c51d6c5dcc57a1927ae0c6e77f21836d71f9de/metrics.js#L14-L32 |
17,361 | observing/thor | mjolnir.js | write | function write(socket, task, id, fn) {
session[binary ? 'binary' : 'utf8'](task.size, function message(err, data) {
var start = socket.last = Date.now();
socket.send(data, {
binary: binary,
mask: masked
}, function sending(err) {
if (err) {
process.send({ type: 'error', message:... | javascript | function write(socket, task, id, fn) {
session[binary ? 'binary' : 'utf8'](task.size, function message(err, data) {
var start = socket.last = Date.now();
socket.send(data, {
binary: binary,
mask: masked
}, function sending(err) {
if (err) {
process.send({ type: 'error', message:... | [
"function",
"write",
"(",
"socket",
",",
"task",
",",
"id",
",",
"fn",
")",
"{",
"session",
"[",
"binary",
"?",
"'binary'",
":",
"'utf8'",
"]",
"(",
"task",
".",
"size",
",",
"function",
"message",
"(",
"err",
",",
"data",
")",
"{",
"var",
"start",... | Helper function from writing messages to the socket.
@param {WebSocket} socket WebSocket connection we should write to
@param {Object} task The given task
@param {String} id
@param {Function} fn The callback
@api private | [
"Helper",
"function",
"from",
"writing",
"messages",
"to",
"the",
"socket",
"."
] | 20c51d6c5dcc57a1927ae0c6e77f21836d71f9de | https://github.com/observing/thor/blob/20c51d6c5dcc57a1927ae0c6e77f21836d71f9de/mjolnir.js#L102-L120 |
17,362 | takuyaa/kuromoji.js | gulpfile.js | toBuffer | function toBuffer (typed) {
var ab = typed.buffer;
var buffer = new Buffer(ab.byteLength);
var view = new Uint8Array(ab);
for (var i = 0; i < buffer.length; ++i) {
buffer[i] = view[i];
}
return buffer;
} | javascript | function toBuffer (typed) {
var ab = typed.buffer;
var buffer = new Buffer(ab.byteLength);
var view = new Uint8Array(ab);
for (var i = 0; i < buffer.length; ++i) {
buffer[i] = view[i];
}
return buffer;
} | [
"function",
"toBuffer",
"(",
"typed",
")",
"{",
"var",
"ab",
"=",
"typed",
".",
"buffer",
";",
"var",
"buffer",
"=",
"new",
"Buffer",
"(",
"ab",
".",
"byteLength",
")",
";",
"var",
"view",
"=",
"new",
"Uint8Array",
"(",
"ab",
")",
";",
"for",
"(",
... | To node.js Buffer | [
"To",
"node",
".",
"js",
"Buffer"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/gulpfile.js#L58-L66 |
17,363 | takuyaa/kuromoji.js | src/util/ByteBuffer.js | ByteBuffer | function ByteBuffer(arg) {
var initial_size;
if (arg == null) {
initial_size = 1024 * 1024;
} else if (typeof arg === "number") {
initial_size = arg;
} else if (arg instanceof Uint8Array) {
this.buffer = arg;
this.position = 0; // Overwrite
return;
} else {
... | javascript | function ByteBuffer(arg) {
var initial_size;
if (arg == null) {
initial_size = 1024 * 1024;
} else if (typeof arg === "number") {
initial_size = arg;
} else if (arg instanceof Uint8Array) {
this.buffer = arg;
this.position = 0; // Overwrite
return;
} else {
... | [
"function",
"ByteBuffer",
"(",
"arg",
")",
"{",
"var",
"initial_size",
";",
"if",
"(",
"arg",
"==",
"null",
")",
"{",
"initial_size",
"=",
"1024",
"*",
"1024",
";",
"}",
"else",
"if",
"(",
"typeof",
"arg",
"===",
"\"number\"",
")",
"{",
"initial_size",... | Utilities to manipulate byte sequence
@param {(number|Uint8Array)} arg Initial size of this buffer (number), or buffer to set (Uint8Array)
@constructor | [
"Utilities",
"to",
"manipulate",
"byte",
"sequence"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/util/ByteBuffer.js#L140-L157 |
17,364 | takuyaa/kuromoji.js | src/loader/DictionaryLoader.js | function (callback) {
async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
if(err) {
return _callback(err);
}
... | javascript | function (callback) {
async.map([ "tid.dat.gz", "tid_pos.dat.gz", "tid_map.dat.gz" ], function (filename, _callback) {
loadArrayBuffer(path.join(dic_path, filename), function (err, buffer) {
if(err) {
return _callback(err);
}
... | [
"function",
"(",
"callback",
")",
"{",
"async",
".",
"map",
"(",
"[",
"\"tid.dat.gz\"",
",",
"\"tid_pos.dat.gz\"",
",",
"\"tid_map.dat.gz\"",
"]",
",",
"function",
"(",
"filename",
",",
"_callback",
")",
"{",
"loadArrayBuffer",
"(",
"path",
".",
"join",
"(",... | Token info dictionaries | [
"Token",
"info",
"dictionaries"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/loader/DictionaryLoader.js#L69-L88 | |
17,365 | takuyaa/kuromoji.js | src/loader/DictionaryLoader.js | function (callback) {
loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) {
if(err) {
return callback(err);
}
var cc_buffer = new Int16Array(buffer);
dic.loadConnectionCosts(cc_buffer);
c... | javascript | function (callback) {
loadArrayBuffer(path.join(dic_path, "cc.dat.gz"), function (err, buffer) {
if(err) {
return callback(err);
}
var cc_buffer = new Int16Array(buffer);
dic.loadConnectionCosts(cc_buffer);
c... | [
"function",
"(",
"callback",
")",
"{",
"loadArrayBuffer",
"(",
"path",
".",
"join",
"(",
"dic_path",
",",
"\"cc.dat.gz\"",
")",
",",
"function",
"(",
"err",
",",
"buffer",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
"... | Connection cost matrix | [
"Connection",
"cost",
"matrix"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/loader/DictionaryLoader.js#L90-L99 | |
17,366 | takuyaa/kuromoji.js | src/dict/DynamicDictionaries.js | DynamicDictionaries | function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) {
if (trie != null) {
this.trie = trie;
} else {
this.trie = doublearray.builder(0).build([
{k: "", v: 1}
]);
}
if (token_info_dictionary != null) {
this.token_info... | javascript | function DynamicDictionaries(trie, token_info_dictionary, connection_costs, unknown_dictionary) {
if (trie != null) {
this.trie = trie;
} else {
this.trie = doublearray.builder(0).build([
{k: "", v: 1}
]);
}
if (token_info_dictionary != null) {
this.token_info... | [
"function",
"DynamicDictionaries",
"(",
"trie",
",",
"token_info_dictionary",
",",
"connection_costs",
",",
"unknown_dictionary",
")",
"{",
"if",
"(",
"trie",
"!=",
"null",
")",
"{",
"this",
".",
"trie",
"=",
"trie",
";",
"}",
"else",
"{",
"this",
".",
"tr... | Dictionaries container for Tokenizer
@param {DoubleArray} trie
@param {TokenInfoDictionary} token_info_dictionary
@param {ConnectionCosts} connection_costs
@param {UnknownDictionary} unknown_dictionary
@constructor | [
"Dictionaries",
"container",
"for",
"Tokenizer"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/dict/DynamicDictionaries.js#L33-L57 |
17,367 | takuyaa/kuromoji.js | src/viterbi/ViterbiNode.js | ViterbiNode | function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) {
this.name = node_name;
this.cost = node_cost;
this.start_pos = start_pos;
this.length = length;
this.left_id = left_id;
this.right_id = right_id;
this.prev = null;
this.surface_form = s... | javascript | function ViterbiNode(node_name, node_cost, start_pos, length, type, left_id, right_id, surface_form) {
this.name = node_name;
this.cost = node_cost;
this.start_pos = start_pos;
this.length = length;
this.left_id = left_id;
this.right_id = right_id;
this.prev = null;
this.surface_form = s... | [
"function",
"ViterbiNode",
"(",
"node_name",
",",
"node_cost",
",",
"start_pos",
",",
"length",
",",
"type",
",",
"left_id",
",",
"right_id",
",",
"surface_form",
")",
"{",
"this",
".",
"name",
"=",
"node_name",
";",
"this",
".",
"cost",
"=",
"node_cost",
... | ViterbiNode is a node of ViterbiLattice
@param {number} node_name Word ID
@param {number} node_cost Word cost to generate
@param {number} start_pos Start position from 1
@param {number} length Word length
@param {string} type Node type (KNOWN, UNKNOWN, BOS, EOS, ...)
@param {number} left_id Left context ID
@param {numb... | [
"ViterbiNode",
"is",
"a",
"node",
"of",
"ViterbiLattice"
] | 71ea8473bd119546977f22c61e4d52da28ac30a6 | https://github.com/takuyaa/kuromoji.js/blob/71ea8473bd119546977f22c61e4d52da28ac30a6/src/viterbi/ViterbiNode.js#L32-L47 |
17,368 | fgnass/domino | lib/Document.js | MultiId | function MultiId(node) {
this.nodes = Object.create(null);
this.nodes[node._nid] = node;
this.length = 1;
this.firstNode = undefined;
} | javascript | function MultiId(node) {
this.nodes = Object.create(null);
this.nodes[node._nid] = node;
this.length = 1;
this.firstNode = undefined;
} | [
"function",
"MultiId",
"(",
"node",
")",
"{",
"this",
".",
"nodes",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"this",
".",
"nodes",
"[",
"node",
".",
"_nid",
"]",
"=",
"node",
";",
"this",
".",
"length",
"=",
"1",
";",
"this",
".",
"... | A class for storing multiple nodes with the same ID | [
"A",
"class",
"for",
"storing",
"multiple",
"nodes",
"with",
"the",
"same",
"ID"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/Document.js#L833-L838 |
17,369 | fgnass/domino | lib/HTMLParser.js | isA | function isA(elt, set) {
if (typeof set === 'string') {
// convenience case for testing a particular HTML element
return elt.namespaceURI === NAMESPACE.HTML &&
elt.localName === set;
}
var tagnames = set[elt.namespaceURI];
return tagnames && tagnames[elt.localName];
} | javascript | function isA(elt, set) {
if (typeof set === 'string') {
// convenience case for testing a particular HTML element
return elt.namespaceURI === NAMESPACE.HTML &&
elt.localName === set;
}
var tagnames = set[elt.namespaceURI];
return tagnames && tagnames[elt.localName];
} | [
"function",
"isA",
"(",
"elt",
",",
"set",
")",
"{",
"if",
"(",
"typeof",
"set",
"===",
"'string'",
")",
"{",
"// convenience case for testing a particular HTML element",
"return",
"elt",
".",
"namespaceURI",
"===",
"NAMESPACE",
".",
"HTML",
"&&",
"elt",
".",
... | Determine whether the element is a member of the set. The set is an object that maps namespaces to objects. The objects then map local tagnames to the value true if that tag is part of the set | [
"Determine",
"whether",
"the",
"element",
"is",
"a",
"member",
"of",
"the",
"set",
".",
"The",
"set",
"is",
"an",
"object",
"that",
"maps",
"namespaces",
"to",
"objects",
".",
"The",
"objects",
"then",
"map",
"local",
"tagnames",
"to",
"the",
"value",
"t... | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L1568-L1576 |
17,370 | fgnass/domino | lib/HTMLParser.js | equal | function equal(newelt, oldelt, oldattrs) {
if (newelt.localName !== oldelt.localName) return false;
if (newelt._numattrs !== oldattrs.length) return false;
for(var i = 0, n = oldattrs.length; i < n; i++) {
var oldname = oldattrs[i][0];
var oldval = oldattrs[i][1];
if (!newelt.hasAttribute(... | javascript | function equal(newelt, oldelt, oldattrs) {
if (newelt.localName !== oldelt.localName) return false;
if (newelt._numattrs !== oldattrs.length) return false;
for(var i = 0, n = oldattrs.length; i < n; i++) {
var oldname = oldattrs[i][0];
var oldval = oldattrs[i][1];
if (!newelt.hasAttribute(... | [
"function",
"equal",
"(",
"newelt",
",",
"oldelt",
",",
"oldattrs",
")",
"{",
"if",
"(",
"newelt",
".",
"localName",
"!==",
"oldelt",
".",
"localName",
")",
"return",
"false",
";",
"if",
"(",
"newelt",
".",
"_numattrs",
"!==",
"oldattrs",
".",
"length",
... | This function defines equality of two elements for the purposes of the AFE list. Note that it compares the new elements attributes to the saved array of attributes associated with the old element because a script could have changed the old element's set of attributes | [
"This",
"function",
"defines",
"equality",
"of",
"two",
"elements",
"for",
"the",
"purposes",
"of",
"the",
"AFE",
"list",
".",
"Note",
"that",
"it",
"compares",
"the",
"new",
"elements",
"attributes",
"to",
"the",
"saved",
"array",
"of",
"attributes",
"assoc... | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L1858-L1868 |
17,371 | fgnass/domino | lib/HTMLParser.js | function() {
var frag = doc.createDocumentFragment();
var root = doc.firstChild;
while(root.hasChildNodes()) {
frag.appendChild(root.firstChild);
}
return frag;
} | javascript | function() {
var frag = doc.createDocumentFragment();
var root = doc.firstChild;
while(root.hasChildNodes()) {
frag.appendChild(root.firstChild);
}
return frag;
} | [
"function",
"(",
")",
"{",
"var",
"frag",
"=",
"doc",
".",
"createDocumentFragment",
"(",
")",
";",
"var",
"root",
"=",
"doc",
".",
"firstChild",
";",
"while",
"(",
"root",
".",
"hasChildNodes",
"(",
")",
")",
"{",
"frag",
".",
"appendChild",
"(",
"r... | Convenience function for internal use. Can only be called once, as it removes the nodes from `doc` to add them to fragment. | [
"Convenience",
"function",
"for",
"internal",
"use",
".",
"Can",
"only",
"be",
"called",
"once",
"as",
"it",
"removes",
"the",
"nodes",
"from",
"doc",
"to",
"add",
"them",
"to",
"fragment",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2008-L2015 | |
17,372 | fgnass/domino | lib/HTMLParser.js | handleSimpleAttribute | function handleSimpleAttribute() {
SIMPLEATTR.lastIndex = nextchar-1;
var matched = SIMPLEATTR.exec(chars);
if (!matched) throw new Error("should never happen");
var name = matched[1];
if (!name) return false;
var value = matched[2];
var len = value.length;
switch(value[0]) {
case '"... | javascript | function handleSimpleAttribute() {
SIMPLEATTR.lastIndex = nextchar-1;
var matched = SIMPLEATTR.exec(chars);
if (!matched) throw new Error("should never happen");
var name = matched[1];
if (!name) return false;
var value = matched[2];
var len = value.length;
switch(value[0]) {
case '"... | [
"function",
"handleSimpleAttribute",
"(",
")",
"{",
"SIMPLEATTR",
".",
"lastIndex",
"=",
"nextchar",
"-",
"1",
";",
"var",
"matched",
"=",
"SIMPLEATTR",
".",
"exec",
"(",
"chars",
")",
";",
"if",
"(",
"!",
"matched",
")",
"throw",
"new",
"Error",
"(",
... | Shortcut for simple attributes | [
"Shortcut",
"for",
"simple",
"attributes"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2337-L2367 |
17,373 | fgnass/domino | lib/HTMLParser.js | getMatchingChars | function getMatchingChars(pattern) {
pattern.lastIndex = nextchar - 1;
var match = pattern.exec(chars);
if (match && match.index === nextchar - 1) {
match = match[0];
nextchar += match.length - 1;
/* Careful! Make sure we haven't matched the EOF character! */
if (input_complete && n... | javascript | function getMatchingChars(pattern) {
pattern.lastIndex = nextchar - 1;
var match = pattern.exec(chars);
if (match && match.index === nextchar - 1) {
match = match[0];
nextchar += match.length - 1;
/* Careful! Make sure we haven't matched the EOF character! */
if (input_complete && n... | [
"function",
"getMatchingChars",
"(",
"pattern",
")",
"{",
"pattern",
".",
"lastIndex",
"=",
"nextchar",
"-",
"1",
";",
"var",
"match",
"=",
"pattern",
".",
"exec",
"(",
"chars",
")",
";",
"if",
"(",
"match",
"&&",
"match",
".",
"index",
"===",
"nextcha... | Consume chars matched by the pattern and return them as a string. Starts matching at the current position, so users should drop the current char otherwise. | [
"Consume",
"chars",
"matched",
"by",
"the",
"pattern",
"and",
"return",
"them",
"as",
"a",
"string",
".",
"Starts",
"matching",
"at",
"the",
"current",
"position",
"so",
"users",
"should",
"drop",
"the",
"current",
"char",
"otherwise",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2423-L2439 |
17,374 | fgnass/domino | lib/HTMLParser.js | emitCharsWhile | function emitCharsWhile(pattern) {
pattern.lastIndex = nextchar-1;
var match = pattern.exec(chars)[0];
if (!match) return false;
emitCharString(match);
nextchar += match.length - 1;
return true;
} | javascript | function emitCharsWhile(pattern) {
pattern.lastIndex = nextchar-1;
var match = pattern.exec(chars)[0];
if (!match) return false;
emitCharString(match);
nextchar += match.length - 1;
return true;
} | [
"function",
"emitCharsWhile",
"(",
"pattern",
")",
"{",
"pattern",
".",
"lastIndex",
"=",
"nextchar",
"-",
"1",
";",
"var",
"match",
"=",
"pattern",
".",
"exec",
"(",
"chars",
")",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"match",
")",
"return",
"false",
... | emit a string of chars that match a regexp Returns false if no chars matched. | [
"emit",
"a",
"string",
"of",
"chars",
"that",
"match",
"a",
"regexp",
"Returns",
"false",
"if",
"no",
"chars",
"matched",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2443-L2450 |
17,375 | fgnass/domino | lib/HTMLParser.js | emitCharString | function emitCharString(s) {
if (textrun.length > 0) flushText();
if (ignore_linefeed) {
ignore_linefeed = false;
if (s[0] === "\n") s = s.substring(1);
if (s.length === 0) return;
}
insertToken(TEXT, s);
} | javascript | function emitCharString(s) {
if (textrun.length > 0) flushText();
if (ignore_linefeed) {
ignore_linefeed = false;
if (s[0] === "\n") s = s.substring(1);
if (s.length === 0) return;
}
insertToken(TEXT, s);
} | [
"function",
"emitCharString",
"(",
"s",
")",
"{",
"if",
"(",
"textrun",
".",
"length",
">",
"0",
")",
"flushText",
"(",
")",
";",
"if",
"(",
"ignore_linefeed",
")",
"{",
"ignore_linefeed",
"=",
"false",
";",
"if",
"(",
"s",
"[",
"0",
"]",
"===",
"\... | This is used by CDATA sections | [
"This",
"is",
"used",
"by",
"CDATA",
"sections"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2453-L2463 |
17,376 | fgnass/domino | lib/HTMLParser.js | insertElement | function insertElement(eltFunc) {
var elt;
if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) {
elt = fosterParent(eltFunc);
}
else if (stack.top instanceof impl.HTMLTemplateElement) {
// "If the adjusted insertion location is inside a template element,
// let it instead be ... | javascript | function insertElement(eltFunc) {
var elt;
if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) {
elt = fosterParent(eltFunc);
}
else if (stack.top instanceof impl.HTMLTemplateElement) {
// "If the adjusted insertion location is inside a template element,
// let it instead be ... | [
"function",
"insertElement",
"(",
"eltFunc",
")",
"{",
"var",
"elt",
";",
"if",
"(",
"foster_parent_mode",
"&&",
"isA",
"(",
"stack",
".",
"top",
",",
"tablesectionrowSet",
")",
")",
"{",
"elt",
"=",
"fosterParent",
"(",
"eltFunc",
")",
";",
"}",
"else",... | Insert the element into the open element or foster parent it | [
"Insert",
"the",
"element",
"into",
"the",
"open",
"element",
"or",
"foster",
"parent",
"it"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L2640-L2657 |
17,377 | fgnass/domino | lib/HTMLParser.js | after_attribute_name_state | function after_attribute_name_state(c) {
switch(c) {
case 0x0009: // CHARACTER TABULATION (tab)
case 0x000A: // LINE FEED (LF)
case 0x000C: // FORM FEED (FF)
case 0x0020: // SPACE
/* Ignore the character. */
break;
case 0x002F: // SOLIDUS
// Keep in sync with before_attribute_n... | javascript | function after_attribute_name_state(c) {
switch(c) {
case 0x0009: // CHARACTER TABULATION (tab)
case 0x000A: // LINE FEED (LF)
case 0x000C: // FORM FEED (FF)
case 0x0020: // SPACE
/* Ignore the character. */
break;
case 0x002F: // SOLIDUS
// Keep in sync with before_attribute_n... | [
"function",
"after_attribute_name_state",
"(",
"c",
")",
"{",
"switch",
"(",
"c",
")",
"{",
"case",
"0x0009",
":",
"// CHARACTER TABULATION (tab)",
"case",
"0x000A",
":",
"// LINE FEED (LF)",
"case",
"0x000C",
":",
"// FORM FEED (FF)",
"case",
"0x0020",
":",
"// S... | There is an active attribute in attrnamebuf, but not yet in attrvaluebuf. | [
"There",
"is",
"an",
"active",
"attribute",
"in",
"attrnamebuf",
"but",
"not",
"yet",
"in",
"attrvaluebuf",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L4179-L4212 |
17,378 | fgnass/domino | lib/HTMLParser.js | before_html_mode | function before_html_mode(t,value,arg3,arg4) {
var elt;
switch(t) {
case 1: // TEXT
value = value.replace(LEADINGWS, ""); // Ignore spaces
if (value.length === 0) return; // Are we done?
break; // Handle anything non-space text below
case 5: // DOCTYPE
/* ignore the token */
... | javascript | function before_html_mode(t,value,arg3,arg4) {
var elt;
switch(t) {
case 1: // TEXT
value = value.replace(LEADINGWS, ""); // Ignore spaces
if (value.length === 0) return; // Are we done?
break; // Handle anything non-space text below
case 5: // DOCTYPE
/* ignore the token */
... | [
"function",
"before_html_mode",
"(",
"t",
",",
"value",
",",
"arg3",
",",
"arg4",
")",
"{",
"var",
"elt",
";",
"switch",
"(",
"t",
")",
"{",
"case",
"1",
":",
"// TEXT",
"value",
"=",
"value",
".",
"replace",
"(",
"LEADINGWS",
",",
"\"\"",
")",
";"... | 11.2.5.4.2 The "before html" insertion mode | [
"11",
".",
"2",
".",
"5",
".",
"4",
".",
"2",
"The",
"before",
"html",
"insertion",
"mode"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5332-L5374 |
17,379 | fgnass/domino | lib/HTMLParser.js | before_head_mode | function before_head_mode(t,value,arg3,arg4) {
switch(t) {
case 1: // TEXT
value = value.replace(LEADINGWS, ""); // Ignore spaces
if (value.length === 0) return; // Are we done?
break; // Handle anything non-space text below
case 5: // DOCTYPE
/* ignore the token */
return;
... | javascript | function before_head_mode(t,value,arg3,arg4) {
switch(t) {
case 1: // TEXT
value = value.replace(LEADINGWS, ""); // Ignore spaces
if (value.length === 0) return; // Are we done?
break; // Handle anything non-space text below
case 5: // DOCTYPE
/* ignore the token */
return;
... | [
"function",
"before_head_mode",
"(",
"t",
",",
"value",
",",
"arg3",
",",
"arg4",
")",
"{",
"switch",
"(",
"t",
")",
"{",
"case",
"1",
":",
"// TEXT",
"value",
"=",
"value",
".",
"replace",
"(",
"LEADINGWS",
",",
"\"\"",
")",
";",
"// Ignore spaces",
... | 11.2.5.4.3 The "before head" insertion mode | [
"11",
".",
"2",
".",
"5",
".",
"4",
".",
"3",
"The",
"before",
"head",
"insertion",
"mode"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5377-L5416 |
17,380 | fgnass/domino | lib/HTMLParser.js | in_head_noscript_mode | function in_head_noscript_mode(t, value, arg3, arg4) {
switch(t) {
case 5: // DOCTYPE
return;
case 4: // COMMENT
in_head_mode(t, value);
return;
case 1: // TEXT
var ws = value.match(LEADINGWS);
if (ws) {
in_head_mode(t, ws[0]);
value = value.substring(ws[0].... | javascript | function in_head_noscript_mode(t, value, arg3, arg4) {
switch(t) {
case 5: // DOCTYPE
return;
case 4: // COMMENT
in_head_mode(t, value);
return;
case 1: // TEXT
var ws = value.match(LEADINGWS);
if (ws) {
in_head_mode(t, ws[0]);
value = value.substring(ws[0].... | [
"function",
"in_head_noscript_mode",
"(",
"t",
",",
"value",
",",
"arg3",
",",
"arg4",
")",
"{",
"switch",
"(",
"t",
")",
"{",
"case",
"5",
":",
"// DOCTYPE",
"return",
";",
"case",
"4",
":",
"// COMMENT",
"in_head_mode",
"(",
"t",
",",
"value",
")",
... | 13.2.5.4.5 The "in head noscript" insertion mode | [
"13",
".",
"2",
".",
"5",
".",
"4",
".",
"5",
"The",
"in",
"head",
"noscript",
"insertion",
"mode"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/HTMLParser.js#L5521-L5571 |
17,381 | fgnass/domino | lib/EventTarget.js | function(event) {
return (this._armed !== null &&
event.type === 'mouseup' &&
event.isTrusted &&
event.button === 0 &&
event.timeStamp - this._armed.t < 1000 &&
Math.abs(event.clientX - this._armed.x) < 10 &&
Math.abs(event.clientY - this._armed.Y) < 10);
} | javascript | function(event) {
return (this._armed !== null &&
event.type === 'mouseup' &&
event.isTrusted &&
event.button === 0 &&
event.timeStamp - this._armed.t < 1000 &&
Math.abs(event.clientX - this._armed.x) < 10 &&
Math.abs(event.clientY - this._armed.Y) < 10);
} | [
"function",
"(",
"event",
")",
"{",
"return",
"(",
"this",
".",
"_armed",
"!==",
"null",
"&&",
"event",
".",
"type",
"===",
"'mouseup'",
"&&",
"event",
".",
"isTrusted",
"&&",
"event",
".",
"button",
"===",
"0",
"&&",
"event",
".",
"timeStamp",
"-",
... | Determine whether a click occurred XXX We don't support double clicks for now | [
"Determine",
"whether",
"a",
"click",
"occurred",
"XXX",
"We",
"don",
"t",
"support",
"double",
"clicks",
"for",
"now"
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/EventTarget.js#L222-L230 | |
17,382 | fgnass/domino | lib/cssparser.js | function(filter){
var buffer = "",
c = this.read();
while(c !== null && filter(c)){
buffer += c;
c = this.read();
}
return buffer;
} | javascript | function(filter){
var buffer = "",
c = this.read();
while(c !== null && filter(c)){
buffer += c;
c = this.read();
}
return buffer;
} | [
"function",
"(",
"filter",
")",
"{",
"var",
"buffer",
"=",
"\"\"",
",",
"c",
"=",
"this",
".",
"read",
"(",
")",
";",
"while",
"(",
"c",
"!==",
"null",
"&&",
"filter",
"(",
"c",
")",
")",
"{",
"buffer",
"+=",
"c",
";",
"c",
"=",
"this",
".",
... | Reads characters while each character causes the given
filter function to return true. The function is passed
in each character and either returns true to continue
reading or false to stop.
@param {Function} filter The function to read on each character.
@return {String} The string made up of all characters that passed... | [
"Reads",
"characters",
"while",
"each",
"character",
"causes",
"the",
"given",
"filter",
"function",
"to",
"return",
"true",
".",
"The",
"function",
"is",
"passed",
"in",
"each",
"character",
"and",
"either",
"returns",
"true",
"to",
"continue",
"reading",
"or... | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L320-L332 | |
17,383 | fgnass/domino | lib/cssparser.js | function(matcher){
var source = this._input.substring(this._cursor),
value = null;
//if it's a string, just do a straight match
if (typeof matcher === "string"){
if (source.indexOf(matcher) === 0){
value = this.readCount(matcher.length);
}
... | javascript | function(matcher){
var source = this._input.substring(this._cursor),
value = null;
//if it's a string, just do a straight match
if (typeof matcher === "string"){
if (source.indexOf(matcher) === 0){
value = this.readCount(matcher.length);
}
... | [
"function",
"(",
"matcher",
")",
"{",
"var",
"source",
"=",
"this",
".",
"_input",
".",
"substring",
"(",
"this",
".",
"_cursor",
")",
",",
"value",
"=",
"null",
";",
"//if it's a string, just do a straight match",
"if",
"(",
"typeof",
"matcher",
"===",
"\"s... | Reads characters that match either text or a regular expression and
returns those characters. If a match is found, the row and column
are adjusted; if no match is found, the reader's state is unchanged.
reading or false to stop.
@param {String|RegExp} matchter If a string, then the literal string
value is searched for.... | [
"Reads",
"characters",
"that",
"match",
"either",
"text",
"or",
"a",
"regular",
"expression",
"and",
"returns",
"those",
"characters",
".",
"If",
"a",
"match",
"is",
"found",
"the",
"row",
"and",
"column",
"are",
"adjusted",
";",
"if",
"no",
"match",
"is",... | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L346-L363 | |
17,384 | fgnass/domino | lib/cssparser.js | TokenStreamBase | function TokenStreamBase(input, tokenData){
/**
* The string reader for easy access to the text.
* @type StringReader
* @property _reader
* @private
*/
this._reader = input ? new StringReader(input.toString()) : null;
/**
* Token object for the last consumed token.
* @ty... | javascript | function TokenStreamBase(input, tokenData){
/**
* The string reader for easy access to the text.
* @type StringReader
* @property _reader
* @private
*/
this._reader = input ? new StringReader(input.toString()) : null;
/**
* Token object for the last consumed token.
* @ty... | [
"function",
"TokenStreamBase",
"(",
"input",
",",
"tokenData",
")",
"{",
"/**\n * The string reader for easy access to the text.\n * @type StringReader\n * @property _reader\n * @private\n */",
"this",
".",
"_reader",
"=",
"input",
"?",
"new",
"StringReader",
"(... | Generic TokenStream providing base functionality.
@class TokenStreamBase
@namespace parserlib.util
@constructor
@param {String|StringReader} input The text to tokenize or a reader from
which to read the input. | [
"Generic",
"TokenStream",
"providing",
"base",
"functionality",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/cssparser.js#L510-L553 |
17,385 | fgnass/domino | lib/Element.js | Attr | function Attr(elt, lname, prefix, namespace, value) {
// localName and namespace are constant for any attr object.
// But value may change. And so can prefix, and so, therefore can name.
this.localName = lname;
this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix);
this.namespaceURI = (namespac... | javascript | function Attr(elt, lname, prefix, namespace, value) {
// localName and namespace are constant for any attr object.
// But value may change. And so can prefix, and so, therefore can name.
this.localName = lname;
this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix);
this.namespaceURI = (namespac... | [
"function",
"Attr",
"(",
"elt",
",",
"lname",
",",
"prefix",
",",
"namespace",
",",
"value",
")",
"{",
"// localName and namespace are constant for any attr object.",
"// But value may change. And so can prefix, and so, therefore can name.",
"this",
".",
"localName",
"=",
"l... | The Attr class represents a single attribute. The values in _attrsByQName and _attrsByLName are instances of this class. | [
"The",
"Attr",
"class",
"represents",
"a",
"single",
"attribute",
".",
"The",
"values",
"in",
"_attrsByQName",
"and",
"_attrsByLName",
"are",
"instances",
"of",
"this",
"class",
"."
] | 2fc67e349e5a9ff978330d2247a546682e04753d | https://github.com/fgnass/domino/blob/2fc67e349e5a9ff978330d2247a546682e04753d/lib/Element.js#L964-L973 |
17,386 | wbyoung/avn | lib/hooks.js | function(version) {
var result;
/** local */
var ensure = function(key) {
return function(r) {
if (r && !r[key]) { throw new Error('result missing ' + key); }
return r;
};
};
return plugins.first(function(plugin) {
return Promise.resolve()
.then(function() { return plugin.match(ver... | javascript | function(version) {
var result;
/** local */
var ensure = function(key) {
return function(r) {
if (r && !r[key]) { throw new Error('result missing ' + key); }
return r;
};
};
return plugins.first(function(plugin) {
return Promise.resolve()
.then(function() { return plugin.match(ver... | [
"function",
"(",
"version",
")",
"{",
"var",
"result",
";",
"/** local */",
"var",
"ensure",
"=",
"function",
"(",
"key",
")",
"{",
"return",
"function",
"(",
"r",
")",
"{",
"if",
"(",
"r",
"&&",
"!",
"r",
"[",
"key",
"]",
")",
"{",
"throw",
"new... | Find the first plugin that can activate the requested version.
@private
@function hooks.~match
@param {String} version The semver version to activate.
@return {Promise} A promise that resolves with both `version` and `command`
properties. | [
"Find",
"the",
"first",
"plugin",
"that",
"can",
"activate",
"the",
"requested",
"version",
"."
] | 30884a077977181a5851025c9a309e196943b591 | https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/hooks.js#L20-L39 | |
17,387 | wbyoung/avn | lib/fmt.js | function(error) {
return util.format(' %s: %s',
chalk.magenta(error.plugin.name),
error.message);
} | javascript | function(error) {
return util.format(' %s: %s',
chalk.magenta(error.plugin.name),
error.message);
} | [
"function",
"(",
"error",
")",
"{",
"return",
"util",
".",
"format",
"(",
"' %s: %s'",
",",
"chalk",
".",
"magenta",
"(",
"error",
".",
"plugin",
".",
"name",
")",
",",
"error",
".",
"message",
")",
";",
"}"
] | Build a detailed error string for displaying to the user.
@private
@function fmt.~errorDetail
@param {Error} error The error for which to build a string.
@return {String} | [
"Build",
"a",
"detailed",
"error",
"string",
"for",
"displaying",
"to",
"the",
"user",
"."
] | 30884a077977181a5851025c9a309e196943b591 | https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/fmt.js#L34-L38 | |
17,388 | wbyoung/avn | lib/setup/plugins.js | function() {
return Promise.resolve()
.then(function() { return npm.loadAsync(); })
.then(function(npm) {
npm.config.set('spin', false);
npm.config.set('global', true);
npm.config.set('depth', 0);
return Promise.promisify(npm.commands.list)([], true);
})
.then(function(data) { return data; });... | javascript | function() {
return Promise.resolve()
.then(function() { return npm.loadAsync(); })
.then(function(npm) {
npm.config.set('spin', false);
npm.config.set('global', true);
npm.config.set('depth', 0);
return Promise.promisify(npm.commands.list)([], true);
})
.then(function(data) { return data; });... | [
"function",
"(",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"npm",
".",
"loadAsync",
"(",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"(",
"npm",
")",
"{",
"npm",
".",
"... | Get a list of all global npm modules.
@private
@function setup.plugins.~modules
@return {Promise} | [
"Get",
"a",
"list",
"of",
"all",
"global",
"npm",
"modules",
"."
] | 30884a077977181a5851025c9a309e196943b591 | https://github.com/wbyoung/avn/blob/30884a077977181a5851025c9a309e196943b591/lib/setup/plugins.js#L15-L25 | |
17,389 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | addTodo | function addTodo(text) {
var todo = {
_id: new Date().toISOString(),
title: text,
completed: false
};
db.put(todo, function callback (err, result) {
if (!err) {
console.log('Successfully posted a todo!');
}
});
} | javascript | function addTodo(text) {
var todo = {
_id: new Date().toISOString(),
title: text,
completed: false
};
db.put(todo, function callback (err, result) {
if (!err) {
console.log('Successfully posted a todo!');
}
});
} | [
"function",
"addTodo",
"(",
"text",
")",
"{",
"var",
"todo",
"=",
"{",
"_id",
":",
"new",
"Date",
"(",
")",
".",
"toISOString",
"(",
")",
",",
"title",
":",
"text",
",",
"completed",
":",
"false",
"}",
";",
"db",
".",
"put",
"(",
"todo",
",",
"... | We have to create a new todo document and enter it in the database | [
"We",
"have",
"to",
"create",
"a",
"new",
"todo",
"document",
"and",
"enter",
"it",
"in",
"the",
"database"
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L23-L34 |
17,390 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | showTodos | function showTodos() {
db.allDocs({
include_docs: true,
descending: true
}, function(err, doc) {
redrawTodosUI(doc.rows);
});
} | javascript | function showTodos() {
db.allDocs({
include_docs: true,
descending: true
}, function(err, doc) {
redrawTodosUI(doc.rows);
});
} | [
"function",
"showTodos",
"(",
")",
"{",
"db",
".",
"allDocs",
"(",
"{",
"include_docs",
":",
"true",
",",
"descending",
":",
"true",
"}",
",",
"function",
"(",
"err",
",",
"doc",
")",
"{",
"redrawTodosUI",
"(",
"doc",
".",
"rows",
")",
";",
"}",
")... | Show the current list of todos by reading them from the database | [
"Show",
"the",
"current",
"list",
"of",
"todos",
"by",
"reading",
"them",
"from",
"the",
"database"
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L37-L44 |
17,391 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | todoBlurred | function todoBlurred(todo, event) {
var trimmedText = event.target.value.trim();
if (!trimmedText) {
db.remove(todo);
} else {
todo.title = trimmedText;
db.put(todo);
}
} | javascript | function todoBlurred(todo, event) {
var trimmedText = event.target.value.trim();
if (!trimmedText) {
db.remove(todo);
} else {
todo.title = trimmedText;
db.put(todo);
}
} | [
"function",
"todoBlurred",
"(",
"todo",
",",
"event",
")",
"{",
"var",
"trimmedText",
"=",
"event",
".",
"target",
".",
"value",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"trimmedText",
")",
"{",
"db",
".",
"remove",
"(",
"todo",
")",
";",
"}",
... | The input box when editing a todo has blurred, we should save the new title or delete the todo if the title is empty | [
"The",
"input",
"box",
"when",
"editing",
"a",
"todo",
"has",
"blurred",
"we",
"should",
"save",
"the",
"new",
"title",
"or",
"delete",
"the",
"todo",
"if",
"the",
"title",
"is",
"empty"
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L58-L66 |
17,392 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | sync | function sync() {
syncDom.setAttribute('data-sync-state', 'syncing');
var opts = {continuous: true, complete: syncError};
db.replicate.to(remoteCouch, opts);
db.replicate.from(remoteCouch, opts);
} | javascript | function sync() {
syncDom.setAttribute('data-sync-state', 'syncing');
var opts = {continuous: true, complete: syncError};
db.replicate.to(remoteCouch, opts);
db.replicate.from(remoteCouch, opts);
} | [
"function",
"sync",
"(",
")",
"{",
"syncDom",
".",
"setAttribute",
"(",
"'data-sync-state'",
",",
"'syncing'",
")",
";",
"var",
"opts",
"=",
"{",
"continuous",
":",
"true",
",",
"complete",
":",
"syncError",
"}",
";",
"db",
".",
"replicate",
".",
"to",
... | Initialise a sync with the remote server | [
"Initialise",
"a",
"sync",
"with",
"the",
"remote",
"server"
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L69-L74 |
17,393 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | todoDblClicked | function todoDblClicked(todo) {
var div = document.getElementById('li_' + todo._id);
var inputEditTodo = document.getElementById('input_' + todo._id);
div.className = 'editing';
inputEditTodo.focus();
} | javascript | function todoDblClicked(todo) {
var div = document.getElementById('li_' + todo._id);
var inputEditTodo = document.getElementById('input_' + todo._id);
div.className = 'editing';
inputEditTodo.focus();
} | [
"function",
"todoDblClicked",
"(",
"todo",
")",
"{",
"var",
"div",
"=",
"document",
".",
"getElementById",
"(",
"'li_'",
"+",
"todo",
".",
"_id",
")",
";",
"var",
"inputEditTodo",
"=",
"document",
".",
"getElementById",
"(",
"'input_'",
"+",
"todo",
".",
... | User has double clicked a todo, display an input so they can edit the title | [
"User",
"has",
"double",
"clicked",
"a",
"todo",
"display",
"an",
"input",
"so",
"they",
"can",
"edit",
"the",
"title"
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L84-L89 |
17,394 | pouchdb/pouchdb-server | examples/todos/public/scripts/app.js | createTodoListItem | function createTodoListItem(todo) {
var checkbox = document.createElement('input');
checkbox.className = 'toggle';
checkbox.type = 'checkbox';
checkbox.addEventListener('change', checkboxChanged.bind(this, todo));
var label = document.createElement('label');
label.appendChild( document.createTe... | javascript | function createTodoListItem(todo) {
var checkbox = document.createElement('input');
checkbox.className = 'toggle';
checkbox.type = 'checkbox';
checkbox.addEventListener('change', checkboxChanged.bind(this, todo));
var label = document.createElement('label');
label.appendChild( document.createTe... | [
"function",
"createTodoListItem",
"(",
"todo",
")",
"{",
"var",
"checkbox",
"=",
"document",
".",
"createElement",
"(",
"'input'",
")",
";",
"checkbox",
".",
"className",
"=",
"'toggle'",
";",
"checkbox",
".",
"type",
"=",
"'checkbox'",
";",
"checkbox",
".",... | Given an object representing a todo, this will create a list item to display it. | [
"Given",
"an",
"object",
"representing",
"a",
"todo",
"this",
"will",
"create",
"a",
"list",
"item",
"to",
"display",
"it",
"."
] | 89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5 | https://github.com/pouchdb/pouchdb-server/blob/89d59b0c3f8cec3be38d75d01cf0fa205c1f2ad5/examples/todos/public/scripts/app.js#L102-L140 |
17,395 | ReactiveX/IxJS | gulp/closure-task.js | getPublicExportedNames | function getPublicExportedNames(entryModule) {
const fn = function() {};
const isStaticOrProtoName = (x) => (
!(x in fn) &&
(x !== `default`) &&
(x !== `undefined`) &&
(x !== `__esModule`) &&
(x !== `constructor`)
);
return Object
.getOwnPropertyNames(entr... | javascript | function getPublicExportedNames(entryModule) {
const fn = function() {};
const isStaticOrProtoName = (x) => (
!(x in fn) &&
(x !== `default`) &&
(x !== `undefined`) &&
(x !== `__esModule`) &&
(x !== `constructor`)
);
return Object
.getOwnPropertyNames(entr... | [
"function",
"getPublicExportedNames",
"(",
"entryModule",
")",
"{",
"const",
"fn",
"=",
"function",
"(",
")",
"{",
"}",
";",
"const",
"isStaticOrProtoName",
"=",
"(",
"x",
")",
"=>",
"(",
"!",
"(",
"x",
"in",
"fn",
")",
"&&",
"(",
"x",
"!==",
"`",
... | Reflect on the Ix entrypoint module to build the closure externs file. Assume all the non-inherited static and prototype members of the Ix entrypoint and its direct exports are public, and should be preserved through minification. | [
"Reflect",
"on",
"the",
"Ix",
"entrypoint",
"module",
"to",
"build",
"the",
"closure",
"externs",
"file",
".",
"Assume",
"all",
"the",
"non",
"-",
"inherited",
"static",
"and",
"prototype",
"members",
"of",
"the",
"Ix",
"entrypoint",
"and",
"its",
"direct",
... | 230791d96fe9e76e959c21a23e485e081b6bc4bb | https://github.com/ReactiveX/IxJS/blob/230791d96fe9e76e959c21a23e485e081b6bc4bb/gulp/closure-task.js#L160-L187 |
17,396 | substantial/updeep | lib/freeze.js | freeze | function freeze(object) {
if (process.env.NODE_ENV === 'production') {
return object
}
if (process.env.UPDEEP_MODE === 'dangerously_never_freeze') {
return object
}
if (needsFreezing(object)) {
recur(object)
}
return object
} | javascript | function freeze(object) {
if (process.env.NODE_ENV === 'production') {
return object
}
if (process.env.UPDEEP_MODE === 'dangerously_never_freeze') {
return object
}
if (needsFreezing(object)) {
recur(object)
}
return object
} | [
"function",
"freeze",
"(",
"object",
")",
"{",
"if",
"(",
"process",
".",
"env",
".",
"NODE_ENV",
"===",
"'production'",
")",
"{",
"return",
"object",
"}",
"if",
"(",
"process",
".",
"env",
".",
"UPDEEP_MODE",
"===",
"'dangerously_never_freeze'",
")",
"{",... | Deeply freeze a plain javascript object.
If `process.env.NODE_ENV === 'production'`, this returns the original object
without freezing.
Or if `process.env.UPDEEP_MODE === 'dangerously_never_freeze'`, this returns the original object
without freezing.
@function
@sig a -> a
@param {object} object Object to freeze.
@r... | [
"Deeply",
"freeze",
"a",
"plain",
"javascript",
"object",
"."
] | 8236f815402861f4f2f500a57305c361405e1784 | https://github.com/substantial/updeep/blob/8236f815402861f4f2f500a57305c361405e1784/lib/freeze.js#L40-L54 |
17,397 | substantial/updeep | lib/update.js | update | function update(updates, object, ...args) {
if (typeof updates === 'function') {
return updates(object, ...args)
}
if (!isPlainObject(updates)) {
return updates
}
const defaultedObject =
typeof object === 'undefined' || object === null ? {} : object
const resolvedUpdates = resolveUpdates(upda... | javascript | function update(updates, object, ...args) {
if (typeof updates === 'function') {
return updates(object, ...args)
}
if (!isPlainObject(updates)) {
return updates
}
const defaultedObject =
typeof object === 'undefined' || object === null ? {} : object
const resolvedUpdates = resolveUpdates(upda... | [
"function",
"update",
"(",
"updates",
",",
"object",
",",
"...",
"args",
")",
"{",
"if",
"(",
"typeof",
"updates",
"===",
"'function'",
")",
"{",
"return",
"updates",
"(",
"object",
",",
"...",
"args",
")",
"}",
"if",
"(",
"!",
"isPlainObject",
"(",
... | Recursively update an object or array.
Can update with values:
update({ foo: 3 }, { foo: 1, bar: 2 });
// => { foo: 3, bar: 2 }
Or with a function:
update({ foo: x => (x + 1) }, { foo: 2 });
// => { foo: 3 }
@function
@name update
@param {Object|Function} updates
@param {Object|Array} object to update
@return {Ob... | [
"Recursively",
"update",
"an",
"object",
"or",
"array",
"."
] | 8236f815402861f4f2f500a57305c361405e1784 | https://github.com/substantial/updeep/blob/8236f815402861f4f2f500a57305c361405e1784/lib/update.js#L74-L102 |
17,398 | nbubna/store | dist/app.js | function(k) {
if (typeof k !== "string"){ k = _.stringify(k); }
return this._ns ? this._ns + k : k;
} | javascript | function(k) {
if (typeof k !== "string"){ k = _.stringify(k); }
return this._ns ? this._ns + k : k;
} | [
"function",
"(",
"k",
")",
"{",
"if",
"(",
"typeof",
"k",
"!==",
"\"string\"",
")",
"{",
"k",
"=",
"_",
".",
"stringify",
"(",
"k",
")",
";",
"}",
"return",
"this",
".",
"_ns",
"?",
"this",
".",
"_ns",
"+",
"k",
":",
"k",
";",
"}"
] | internal use functions | [
"internal",
"use",
"functions"
] | 0d4d1ce35de6bd79c6a040e2546c87a85825868a | https://github.com/nbubna/store/blob/0d4d1ce35de6bd79c6a040e2546c87a85825868a/dist/app.js#L392-L395 | |
17,399 | pillarjs/hbs | lib/hbs.js | render_with_layout | function render_with_layout(template, locals, cb) {
render_file(locals, function(err, str) {
if (err) {
return cb(err);
}
locals.body = str;
var res = template(locals, handlebarsOpts);
self.async.done(function(values) {
Object.keys(values).forEach(function(id) {
... | javascript | function render_with_layout(template, locals, cb) {
render_file(locals, function(err, str) {
if (err) {
return cb(err);
}
locals.body = str;
var res = template(locals, handlebarsOpts);
self.async.done(function(values) {
Object.keys(values).forEach(function(id) {
... | [
"function",
"render_with_layout",
"(",
"template",
",",
"locals",
",",
"cb",
")",
"{",
"render_file",
"(",
"locals",
",",
"function",
"(",
"err",
",",
"str",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"locals",
... | render with a layout | [
"render",
"with",
"a",
"layout"
] | 3a8a47ec53bddf87183fb6e903d0d0cf0876c062 | https://github.com/pillarjs/hbs/blob/3a8a47ec53bddf87183fb6e903d0d0cf0876c062/lib/hbs.js#L79-L96 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.