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
partition
stringclasses
1 value
dmarcos/aframe-motion-capture-components
src/components/avatar-recorder.js
function (recordingData) { var data = this.data; if (!data.localStorage) { return; } log('Recording stored in localStorage.'); this.el.systems.recordingdb.addRecording(data.recordingName, recordingData); }
javascript
function (recordingData) { var data = this.data; if (!data.localStorage) { return; } log('Recording stored in localStorage.'); this.el.systems.recordingdb.addRecording(data.recordingName, recordingData); }
[ "function", "(", "recordingData", ")", "{", "var", "data", "=", "this", ".", "data", ";", "if", "(", "!", "data", ".", "localStorage", ")", "{", "return", ";", "}", "log", "(", "'Recording stored in localStorage.'", ")", ";", "this", ".", "el", ".", "s...
Store recording in IndexedDB using recordingdb system.
[ "Store", "recording", "in", "IndexedDB", "using", "recordingdb", "system", "." ]
3a3cbd73ffc751285be95e9729a09121ff03c440
https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/components/avatar-recorder.js#L199-L204
train
dmarcos/aframe-motion-capture-components
src/systems/motion-capture-replayer.js
function (gamepads) { var i; var sceneEl = this.sceneEl; var trackedControlsSystem = sceneEl.systems['tracked-controls']; gamepads = gamepads || [] // convert from read-only GamepadList gamepads = Array.from(gamepads) this.gamepads.forEach(function (gamepad) { if (gamepads[gamepad.ind...
javascript
function (gamepads) { var i; var sceneEl = this.sceneEl; var trackedControlsSystem = sceneEl.systems['tracked-controls']; gamepads = gamepads || [] // convert from read-only GamepadList gamepads = Array.from(gamepads) this.gamepads.forEach(function (gamepad) { if (gamepads[gamepad.ind...
[ "function", "(", "gamepads", ")", "{", "var", "i", ";", "var", "sceneEl", "=", "this", ".", "sceneEl", ";", "var", "trackedControlsSystem", "=", "sceneEl", ".", "systems", "[", "'tracked-controls'", "]", ";", "gamepads", "=", "gamepads", "||", "[", "]", ...
Wrap `updateControllerList` to stub in the gamepads and emit `controllersupdated`.
[ "Wrap", "updateControllerList", "to", "stub", "in", "the", "gamepads", "and", "emit", "controllersupdated", "." ]
3a3cbd73ffc751285be95e9729a09121ff03c440
https://github.com/dmarcos/aframe-motion-capture-components/blob/3a3cbd73ffc751285be95e9729a09121ff03c440/src/systems/motion-capture-replayer.js#L43-L59
train
Alhadis/Accordion
src/accordion.js
setToken
function setToken(list, token, enabled){ enabled ? list.add(token) : list.remove(token); }
javascript
function setToken(list, token, enabled){ enabled ? list.add(token) : list.remove(token); }
[ "function", "setToken", "(", "list", ",", "token", ",", "enabled", ")", "{", "enabled", "?", "list", ".", "add", "(", "token", ")", ":", "list", ".", "remove", "(", "token", ")", ";", "}" ]
Conditionally add or remove a token from a token-list. @param {DOMTokenList} list @param {String} token @param {Boolean} enabled
[ "Conditionally", "add", "or", "remove", "a", "token", "from", "a", "token", "-", "list", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L25-L27
train
Alhadis/Accordion
src/accordion.js
debounce
function debounce(fn, limit, soon){ var limit = limit < 0 ? 0 : limit, started, context, args, timer, delayed = function(){ // Get the time between now and when the function was first fired var timeSince = Date.now() - started; if(timeSince >= limit){ if(!soon) fn.apply(context, args); ...
javascript
function debounce(fn, limit, soon){ var limit = limit < 0 ? 0 : limit, started, context, args, timer, delayed = function(){ // Get the time between now and when the function was first fired var timeSince = Date.now() - started; if(timeSince >= limit){ if(!soon) fn.apply(context, args); ...
[ "function", "debounce", "(", "fn", ",", "limit", ",", "soon", ")", "{", "var", "limit", "=", "limit", "<", "0", "?", "0", ":", "limit", ",", "started", ",", "context", ",", "args", ",", "timer", ",", "delayed", "=", "function", "(", ")", "{", "//...
Stop a function from firing too quickly. Returns a copy of the original function that runs only after the designated number of milliseconds have elapsed. Useful for throttling onResize handlers. @param {Number} limit - Threshold to stall execution by, in milliseconds. @param {Boolean} soon - If TRUE, will call the fu...
[ "Stop", "a", "function", "from", "firing", "too", "quickly", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L41-L74
train
Alhadis/Accordion
src/accordion.js
fit
function fit(){ var height = THIS.headingHeight; if(THIS.open) height += content.scrollHeight; if(useBorders) height += THIS.elBorder; THIS.height = height; }
javascript
function fit(){ var height = THIS.headingHeight; if(THIS.open) height += content.scrollHeight; if(useBorders) height += THIS.elBorder; THIS.height = height; }
[ "function", "fit", "(", ")", "{", "var", "height", "=", "THIS", ".", "headingHeight", ";", "if", "(", "THIS", ".", "open", ")", "height", "+=", "content", ".", "scrollHeight", ";", "if", "(", "useBorders", ")", "height", "+=", "THIS", ".", "elBorder", ...
Adjust a fold's container to fit its content.
[ "Adjust", "a", "fold", "s", "container", "to", "fit", "its", "content", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L623-L628
train
Alhadis/Accordion
src/accordion.js
updateFold
function updateFold(fold, offset){ var next = fold; var parentFold = THIS.parentFold; while(next = next.nextFold) next.y += offset; parentFold || edgeCheck(offset); fold.height += offset; THIS.height += offset; parentFold && parentFold.open && THIS.parent.updateFold(parentFold, offset)...
javascript
function updateFold(fold, offset){ var next = fold; var parentFold = THIS.parentFold; while(next = next.nextFold) next.y += offset; parentFold || edgeCheck(offset); fold.height += offset; THIS.height += offset; parentFold && parentFold.open && THIS.parent.updateFold(parentFold, offset)...
[ "function", "updateFold", "(", "fold", ",", "offset", ")", "{", "var", "next", "=", "fold", ";", "var", "parentFold", "=", "THIS", ".", "parentFold", ";", "while", "(", "next", "=", "next", ".", "nextFold", ")", "next", ".", "y", "+=", "offset", ";",...
Update the vertical ordinate of each sibling for a particular fold. @param {Fold} fold @param {Number} offset - Pixel distance to adjust by
[ "Update", "the", "vertical", "ordinate", "of", "each", "sibling", "for", "a", "particular", "fold", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L906-L917
train
Alhadis/Accordion
src/accordion.js
update
function update(){ var y = 0; var height = 0; var i = 0; var l = folds.length; var parentFold = THIS.parentFold; var fold, diff; for(; i < l; ++i){ fold = folds[i]; fold.y = y; fold.fit(); y += fold.height; height += fold.height; } diff = heig...
javascript
function update(){ var y = 0; var height = 0; var i = 0; var l = folds.length; var parentFold = THIS.parentFold; var fold, diff; for(; i < l; ++i){ fold = folds[i]; fold.y = y; fold.fit(); y += fold.height; height += fold.height; } diff = heig...
[ "function", "update", "(", ")", "{", "var", "y", "=", "0", ";", "var", "height", "=", "0", ";", "var", "i", "=", "0", ";", "var", "l", "=", "folds", ".", "length", ";", "var", "parentFold", "=", "THIS", ".", "parentFold", ";", "var", "fold", ",...
Update the height of each fold to fit its content.
[ "Update", "the", "height", "of", "each", "fold", "to", "fit", "its", "content", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L923-L945
train
Alhadis/Accordion
src/accordion.js
refresh
function refresh(allowSnap){ var snap = allowSnap ? snapClass : false; snap && elClasses.add(snap); THIS.update(); THIS.childAccordions && THIS.childAccordions.forEach(function(a){ a.parentFold.open ? a.refresh(allowSnap) : (a.parentFold.needsRefresh = true); }); snap && setTimeo...
javascript
function refresh(allowSnap){ var snap = allowSnap ? snapClass : false; snap && elClasses.add(snap); THIS.update(); THIS.childAccordions && THIS.childAccordions.forEach(function(a){ a.parentFold.open ? a.refresh(allowSnap) : (a.parentFold.needsRefresh = true); }); snap && setTimeo...
[ "function", "refresh", "(", "allowSnap", ")", "{", "var", "snap", "=", "allowSnap", "?", "snapClass", ":", "false", ";", "snap", "&&", "elClasses", ".", "add", "(", "snap", ")", ";", "THIS", ".", "update", "(", ")", ";", "THIS", ".", "childAccordions",...
Recalculate the boundaries of an Accordion and its descendants. This method should only be called if the width of a container changes, or a fold's contents have resized unexpectedly (such as when images load). @param {Boolean} allowSnap - Snap folds instantly into place without transitioning
[ "Recalculate", "the", "boundaries", "of", "an", "Accordion", "and", "its", "descendants", "." ]
057b2fdf9f875519120991df59e68e4ec0c06a6d
https://github.com/Alhadis/Accordion/blob/057b2fdf9f875519120991df59e68e4ec0c06a6d/src/accordion.js#L957-L969
train
decaffeinate/bulk-decaffeinate
src/config/resolveConfig.js
getCLIParamsConfig
function getCLIParamsConfig(config, commander) { let { file, pathFile, dir, useJsModules, landBase, numWorkers, skipVerify, decaffeinatePath, jscodeshiftPath, eslintPath, } = commander; // As a special case, specifying files to process from the CLI should cause // any equ...
javascript
function getCLIParamsConfig(config, commander) { let { file, pathFile, dir, useJsModules, landBase, numWorkers, skipVerify, decaffeinatePath, jscodeshiftPath, eslintPath, } = commander; // As a special case, specifying files to process from the CLI should cause // any equ...
[ "function", "getCLIParamsConfig", "(", "config", ",", "commander", ")", "{", "let", "{", "file", ",", "pathFile", ",", "dir", ",", "useJsModules", ",", "landBase", ",", "numWorkers", ",", "skipVerify", ",", "decaffeinatePath", ",", "jscodeshiftPath", ",", "esl...
Fill in a configuration from the CLI arguments.
[ "Fill", "in", "a", "configuration", "from", "the", "CLI", "arguments", "." ]
78a75de4eb3d7a3bd5a4d8e882a6b5d4ca8cd7f1
https://github.com/decaffeinate/bulk-decaffeinate/blob/78a75de4eb3d7a3bd5a4d8e882a6b5d4ca8cd7f1/src/config/resolveConfig.js#L97-L149
train
decaffeinate/bulk-decaffeinate
src/config/resolveConfig.js
resolveBinary
async function resolveBinary(binaryName) { let nodeModulesPath = `./node_modules/.bin/${binaryName}`; if (await exists(nodeModulesPath)) { return nodeModulesPath; } else { try { await exec(`which ${binaryName}`); return binaryName; } catch (e) { console.log(`${binaryName} binary not ...
javascript
async function resolveBinary(binaryName) { let nodeModulesPath = `./node_modules/.bin/${binaryName}`; if (await exists(nodeModulesPath)) { return nodeModulesPath; } else { try { await exec(`which ${binaryName}`); return binaryName; } catch (e) { console.log(`${binaryName} binary not ...
[ "async", "function", "resolveBinary", "(", "binaryName", ")", "{", "let", "nodeModulesPath", "=", "`", "${", "binaryName", "}", "`", ";", "if", "(", "await", "exists", "(", "nodeModulesPath", ")", ")", "{", "return", "nodeModulesPath", ";", "}", "else", "{...
Determine the shell command that can be used to run the given binary, prompting to globally install it if necessary.
[ "Determine", "the", "shell", "command", "that", "can", "be", "used", "to", "run", "the", "given", "binary", "prompting", "to", "globally", "install", "it", "if", "necessary", "." ]
78a75de4eb3d7a3bd5a4d8e882a6b5d4ca8cd7f1
https://github.com/decaffeinate/bulk-decaffeinate/blob/78a75de4eb3d7a3bd5a4d8e882a6b5d4ca8cd7f1/src/config/resolveConfig.js#L184-L206
train
image-js/mrz-detection
src/svm.js
getDescriptors
function getDescriptors(images) { const result = []; for (let image of images) { result.push(extractHOG(image)); } const heights = images.map((img) => img.height); const maxHeight = Math.max.apply(null, heights); const minHeight = Math.min.apply(null, heights); for (let i = 0; i < images.length; i++)...
javascript
function getDescriptors(images) { const result = []; for (let image of images) { result.push(extractHOG(image)); } const heights = images.map((img) => img.height); const maxHeight = Math.max.apply(null, heights); const minHeight = Math.min.apply(null, heights); for (let i = 0; i < images.length; i++)...
[ "function", "getDescriptors", "(", "images", ")", "{", "const", "result", "=", "[", "]", ";", "for", "(", "let", "image", "of", "images", ")", "{", "result", ".", "push", "(", "extractHOG", "(", "image", ")", ")", ";", "}", "const", "heights", "=", ...
Get descriptors for images from 1 identity card
[ "Get", "descriptors", "for", "images", "from", "1", "identity", "card" ]
8d5f96f1f0a0897960fe29400e5ae3cd2a536ecd
https://github.com/image-js/mrz-detection/blob/8d5f96f1f0a0897960fe29400e5ae3cd2a536ecd/src/svm.js#L60-L78
train
bibig/node-shorthash
examples/sandbox.js
randomEnglishWord
function randomEnglishWord (length) { var consonants = 'bcdfghjklmnpqrstvwxyz', vowels = 'aeiou', i, word='', consonants = consonants.split(''), vowels = vowels.split(''); for (i=0;i<length/2;i++) { var randConsonant = consonants[randomNumber(consonants.length-1)], randVowel = vowels[randomNumber(vowels....
javascript
function randomEnglishWord (length) { var consonants = 'bcdfghjklmnpqrstvwxyz', vowels = 'aeiou', i, word='', consonants = consonants.split(''), vowels = vowels.split(''); for (i=0;i<length/2;i++) { var randConsonant = consonants[randomNumber(consonants.length-1)], randVowel = vowels[randomNumber(vowels....
[ "function", "randomEnglishWord", "(", "length", ")", "{", "var", "consonants", "=", "'bcdfghjklmnpqrstvwxyz'", ",", "vowels", "=", "'aeiou'", ",", "i", ",", "word", "=", "''", ",", "consonants", "=", "consonants", ".", "split", "(", "''", ")", ",", "vowels...
people name, term
[ "people", "name", "term" ]
7afa157422d04240d40df65b6d609a956f5ebbff
https://github.com/bibig/node-shorthash/blob/7afa157422d04240d40df65b6d609a956f5ebbff/examples/sandbox.js#L35-L49
train
yahoo/pngjs-image
lib/conversion.js
function (idx, funcName) { var colors = 0, colorCounter = 0, fn, width = this._image.width, height = this._image.height, dim = width * height, spaceOnRight, spaceOnLeft, spaceOnTop, spaceOnBottom; funcName = funcName || "getLuminosityAtIndex"; fn = function (idx) { colors += this[...
javascript
function (idx, funcName) { var colors = 0, colorCounter = 0, fn, width = this._image.width, height = this._image.height, dim = width * height, spaceOnRight, spaceOnLeft, spaceOnTop, spaceOnBottom; funcName = funcName || "getLuminosityAtIndex"; fn = function (idx) { colors += this[...
[ "function", "(", "idx", ",", "funcName", ")", "{", "var", "colors", "=", "0", ",", "colorCounter", "=", "0", ",", "fn", ",", "width", "=", "this", ".", "_image", ".", "width", ",", "height", "=", "this", ".", "_image", ".", "height", ",", "dim", ...
Gets the blurred value of a pixel with a gray-scale function @method getBlurPixelAtIndex @param {int} idx Index @param {string} [funcName] Gray-scale function @return {int}
[ "Gets", "the", "blurred", "value", "of", "a", "pixel", "with", "a", "gray", "-", "scale", "function" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/conversion.js#L21-L75
train
yahoo/pngjs-image
lib/conversion.js
function (x, y, funcName) { var idx = this.getIndex(x, y); return this.getBlurPixelAtIndex(idx, funcName); }
javascript
function (x, y, funcName) { var idx = this.getIndex(x, y); return this.getBlurPixelAtIndex(idx, funcName); }
[ "function", "(", "x", ",", "y", ",", "funcName", ")", "{", "var", "idx", "=", "this", ".", "getIndex", "(", "x", ",", "y", ")", ";", "return", "this", ".", "getBlurPixelAtIndex", "(", "idx", ",", "funcName", ")", ";", "}" ]
Gets the blur-value of a pixel at a specific coordinate @method getBlurPixel @param {int} x X-coordinate of pixel @param {int} y Y-coordinate of pixel @param {string} [funcName] Gray-scale function @return {int} blur-value
[ "Gets", "the", "blur", "-", "value", "of", "a", "pixel", "at", "a", "specific", "coordinate" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/conversion.js#L86-L89
train
yahoo/pngjs-image
lib/conversion.js
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx), y, i, q; y = this.getLumaAtIndex(idx); i = Math.floor((0.595716 * r) - (0.274453 * g) - (0.321263 * b)); q = Math.floor((0.211456 * r) - (0.522591 * g) + (0.311135 * b)); y = y < 0 ? 0 : (y > 255 ? 255 ...
javascript
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx), y, i, q; y = this.getLumaAtIndex(idx); i = Math.floor((0.595716 * r) - (0.274453 * g) - (0.321263 * b)); q = Math.floor((0.211456 * r) - (0.522591 * g) + (0.311135 * b)); y = y < 0 ? 0 : (y > 255 ? 255 ...
[ "function", "(", "idx", ")", "{", "var", "r", "=", "this", ".", "getRed", "(", "idx", ")", ",", "g", "=", "this", ".", "getGreen", "(", "idx", ")", ",", "b", "=", "this", ".", "getBlue", "(", "idx", ")", ",", "y", ",", "i", ",", "q", ";", ...
Gets the YIQ-value of a pixel at a specific index The values for RGB correspond afterwards to YIQ respectively. @method getYIQAtIndex @param {int} idx Index of pixel @return {object} YIQ-value
[ "Gets", "the", "YIQ", "-", "value", "of", "a", "pixel", "at", "a", "specific", "index", "The", "values", "for", "RGB", "correspond", "afterwards", "to", "YIQ", "respectively", "." ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/conversion.js#L100-L118
train
yahoo/pngjs-image
lib/conversion.js
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx); r = Math.floor((0.393 * r) + (0.769 * g) + (0.189 * b)); g = Math.floor((0.349 * r) + (0.686 * g) + (0.168 * b)); b = Math.floor((0.272 * r) + (0.534 * g) + (0.131 * b)); r = r < 0 ? 0 : (r > 255 ? 255 : r); g ...
javascript
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx); r = Math.floor((0.393 * r) + (0.769 * g) + (0.189 * b)); g = Math.floor((0.349 * r) + (0.686 * g) + (0.168 * b)); b = Math.floor((0.272 * r) + (0.534 * g) + (0.131 * b)); r = r < 0 ? 0 : (r > 255 ? 255 : r); g ...
[ "function", "(", "idx", ")", "{", "var", "r", "=", "this", ".", "getRed", "(", "idx", ")", ",", "g", "=", "this", ".", "getGreen", "(", "idx", ")", ",", "b", "=", "this", ".", "getBlue", "(", "idx", ")", ";", "r", "=", "Math", ".", "floor", ...
Gets the sepia of a pixel at a specific index @method getSepiaAtIndex @param {int} idx Index of pixel @return {object} Color
[ "Gets", "the", "sepia", "of", "a", "pixel", "at", "a", "specific", "index" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/conversion.js#L166-L180
train
yahoo/pngjs-image
lib/conversion.js
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx); return Math.floor((Math.max(r, g, b) + Math.min(r, g, b)) / 2); }
javascript
function (idx) { var r = this.getRed(idx), g = this.getGreen(idx), b = this.getBlue(idx); return Math.floor((Math.max(r, g, b) + Math.min(r, g, b)) / 2); }
[ "function", "(", "idx", ")", "{", "var", "r", "=", "this", ".", "getRed", "(", "idx", ")", ",", "g", "=", "this", ".", "getGreen", "(", "idx", ")", ",", "b", "=", "this", ".", "getBlue", "(", "idx", ")", ";", "return", "Math", ".", "floor", "...
Gets the lightness of a pixel at a specific index @method getLightnessAtIndex @param {int} idx Index of pixel @return {int} Lightness
[ "Gets", "the", "lightness", "of", "a", "pixel", "at", "a", "specific", "index" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/conversion.js#L227-L233
train
yahoo/pngjs-image
lib/modify.js
function () { var Class = this.constructor, x, y, width = this.getWidth(), height = this.getHeight(), image = Class.createImage(height, width); for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { image.setPixel(y, width - x - 1, this.getPixel(x, y)); } } return image; }
javascript
function () { var Class = this.constructor, x, y, width = this.getWidth(), height = this.getHeight(), image = Class.createImage(height, width); for (x = 0; x < width; x++) { for (y = 0; y < height; y++) { image.setPixel(y, width - x - 1, this.getPixel(x, y)); } } return image; }
[ "function", "(", ")", "{", "var", "Class", "=", "this", ".", "constructor", ",", "x", ",", "y", ",", "width", "=", "this", ".", "getWidth", "(", ")", ",", "height", "=", "this", ".", "getHeight", "(", ")", ",", "image", "=", "Class", ".", "create...
Rotates the current image 90 degree counter-clockwise @method rotateCCW @return {PNGImage} Rotated image
[ "Rotates", "the", "current", "image", "90", "degree", "counter", "-", "clockwise" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/modify.js#L19-L33
train
yahoo/pngjs-image
index.js
PNGImage
function PNGImage (image) { image.on('error', function (err) { PNGImage.log(err.message); }); this._image = image; }
javascript
function PNGImage (image) { image.on('error', function (err) { PNGImage.log(err.message); }); this._image = image; }
[ "function", "PNGImage", "(", "image", ")", "{", "image", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "PNGImage", ".", "log", "(", "err", ".", "message", ")", ";", "}", ")", ";", "this", ".", "_image", "=", "image", ";", "}" ...
PNGjs-image class @class PNGImage @submodule Core @param {PNG} image png-js object @constructor
[ "PNGjs", "-", "image", "class" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L26-L31
train
yahoo/pngjs-image
index.js
function (x, y, width, height) { var image; width = Math.min(width, this.getWidth() - x); height = Math.min(height, this.getHeight() - y); if ((width < 0) || (height < 0)) { throw new Error('Width and height cannot be negative.'); } image = new PNG({ width: width, height: height }); this._ima...
javascript
function (x, y, width, height) { var image; width = Math.min(width, this.getWidth() - x); height = Math.min(height, this.getHeight() - y); if ((width < 0) || (height < 0)) { throw new Error('Width and height cannot be negative.'); } image = new PNG({ width: width, height: height }); this._ima...
[ "function", "(", "x", ",", "y", ",", "width", ",", "height", ")", "{", "var", "image", ";", "width", "=", "Math", ".", "min", "(", "width", ",", "this", ".", "getWidth", "(", ")", "-", "x", ")", ";", "height", "=", "Math", ".", "min", "(", "h...
Clips the current image by modifying it in-place @method clip @param {int} x Starting x-coordinate @param {int} y Starting y-coordinate @param {int} width Width of area relative to starting coordinate @param {int} height Height of area relative to starting coordinate
[ "Clips", "the", "current", "image", "by", "modifying", "it", "in", "-", "place" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L299-L316
train
yahoo/pngjs-image
index.js
function (x, y, width, height, color) { var i, iLen = x + width, j, jLen = y + height, index; for (i = x; i < iLen; i++) { for (j = y; j < jLen; j++) { index = this.getIndex(i, j); this.setAtIndex(index, color); } } }
javascript
function (x, y, width, height, color) { var i, iLen = x + width, j, jLen = y + height, index; for (i = x; i < iLen; i++) { for (j = y; j < jLen; j++) { index = this.getIndex(i, j); this.setAtIndex(index, color); } } }
[ "function", "(", "x", ",", "y", ",", "width", ",", "height", ",", "color", ")", "{", "var", "i", ",", "iLen", "=", "x", "+", "width", ",", "j", ",", "jLen", "=", "y", "+", "height", ",", "index", ";", "for", "(", "i", "=", "x", ";", "i", ...
Fills an area with the specified color @method fillRect @param {int} x Starting x-coordinate @param {int} y Starting y-coordinate @param {int} width Width of area relative to starting coordinate @param {int} height Height of area relative to starting coordinate @param {object} color @param {int} [color.red] Red channe...
[ "Fills", "an", "area", "with", "the", "specified", "color" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L333-L347
train
yahoo/pngjs-image
index.js
function (filters, returnResult) { var image, newFilters; // Convert to array if (_.isString(filters)) { filters = [filters]; } else if (!_.isArray(filters) && _.isObject(filters)) { filters = [filters]; } // Format array as needed by the function newFilters = []; (filters || []).forEach(fun...
javascript
function (filters, returnResult) { var image, newFilters; // Convert to array if (_.isString(filters)) { filters = [filters]; } else if (!_.isArray(filters) && _.isObject(filters)) { filters = [filters]; } // Format array as needed by the function newFilters = []; (filters || []).forEach(fun...
[ "function", "(", "filters", ",", "returnResult", ")", "{", "var", "image", ",", "newFilters", ";", "// Convert to array", "if", "(", "_", ".", "isString", "(", "filters", ")", ")", "{", "filters", "=", "[", "filters", "]", ";", "}", "else", "if", "(", ...
Applies a list of filters to the image @method applyFilters @param {string|object|object[]} filters Names of filters in sequence `{key:<string>, options:<object>}` @param {boolean} [returnResult=false] @return {PNGImage}
[ "Applies", "a", "list", "of", "filters", "to", "the", "image" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L358-L406
train
yahoo/pngjs-image
index.js
function (filename, fn) { fn = fn || function () {}; this._image.pack().pipe(fs.createWriteStream(filename)).once('close', function () { this._image.removeListener('error', fn); fn(undefined, this); }.bind(this)).once('error', function (err) { this._image.removeListener('close', fn); fn(err, this); ...
javascript
function (filename, fn) { fn = fn || function () {}; this._image.pack().pipe(fs.createWriteStream(filename)).once('close', function () { this._image.removeListener('error', fn); fn(undefined, this); }.bind(this)).once('error', function (err) { this._image.removeListener('close', fn); fn(err, this); ...
[ "function", "(", "filename", ",", "fn", ")", "{", "fn", "=", "fn", "||", "function", "(", ")", "{", "}", ";", "this", ".", "_image", ".", "pack", "(", ")", ".", "pipe", "(", "fs", ".", "createWriteStream", "(", "filename", ")", ")", ".", "once", ...
Writes the image to the filesystem @method writeImage @param {string} filename Path to file @param {function} fn Callback
[ "Writes", "the", "image", "to", "the", "filesystem" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L429-L440
train
yahoo/pngjs-image
index.js
function (fn) { var writeBuffer = new streamBuffers.WritableStreamBuffer({ initialSize: (100 * 1024), incrementAmount: (10 * 1024) }); fn = fn || function () {}; this._image.pack().pipe(writeBuffer).once('close', function () { this._image.removeListener('error', fn); fn(undefined, writeBuffer.getCon...
javascript
function (fn) { var writeBuffer = new streamBuffers.WritableStreamBuffer({ initialSize: (100 * 1024), incrementAmount: (10 * 1024) }); fn = fn || function () {}; this._image.pack().pipe(writeBuffer).once('close', function () { this._image.removeListener('error', fn); fn(undefined, writeBuffer.getCon...
[ "function", "(", "fn", ")", "{", "var", "writeBuffer", "=", "new", "streamBuffers", ".", "WritableStreamBuffer", "(", "{", "initialSize", ":", "(", "100", "*", "1024", ")", ",", "incrementAmount", ":", "(", "10", "*", "1024", ")", "}", ")", ";", "fn", ...
Writes the image to a buffer @method toBlob @param {function} fn Callback
[ "Writes", "the", "image", "to", "a", "buffer" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/index.js#L457-L472
train
yahoo/pngjs-image
lib/filters.js
generateFilter
function generateFilter (fn) { /** * Creates a destination image * * @method * @param {PNGImage} image * @param {object} options * @param {object} [options.needsCopy=false] * @return {PNGImage} */ return function (image, options) { if (options.needsCopy) { var newImage = image.constructor.creat...
javascript
function generateFilter (fn) { /** * Creates a destination image * * @method * @param {PNGImage} image * @param {object} options * @param {object} [options.needsCopy=false] * @return {PNGImage} */ return function (image, options) { if (options.needsCopy) { var newImage = image.constructor.creat...
[ "function", "generateFilter", "(", "fn", ")", "{", "/**\n\t * Creates a destination image\n\t *\n\t * @method\n\t * @param {PNGImage} image\n\t * @param {object} options\n\t * @param {object} [options.needsCopy=false]\n\t * @return {PNGImage}\n\t */", "return", "function", "(", "image", ",", ...
Generates a filter function by doing common tasks to abstract this away from the actual filter functions @method generateFilter @param {function} fn @return {Function} @private
[ "Generates", "a", "filter", "function", "by", "doing", "common", "tasks", "to", "abstract", "this", "away", "from", "the", "actual", "filter", "functions" ]
63f11c69d87da204d7aebb4160c2d21bbfee3d4a
https://github.com/yahoo/pngjs-image/blob/63f11c69d87da204d7aebb4160c2d21bbfee3d4a/lib/filters.js#L20-L43
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (index, appId, userId, deviceId) { 'use strict'; this.index = index; this.appId = appId; this.userId = userId; this.deviceId = deviceId || 'amzn1.ask.device.VOID'; }
javascript
function (index, appId, userId, deviceId) { 'use strict'; this.index = index; this.appId = appId; this.userId = userId; this.deviceId = deviceId || 'amzn1.ask.device.VOID'; }
[ "function", "(", "index", ",", "appId", ",", "userId", ",", "deviceId", ")", "{", "'use strict'", ";", "this", ".", "index", "=", "index", ";", "this", ".", "appId", "=", "appId", ";", "this", ".", "userId", "=", "userId", ";", "this", ".", "deviceId...
Initializes necessary values before using the test framework. @param {object} index The object containing your skill's 'handler' method. @param {string} appId The Skill's app ID. Looks like "amzn1.ask.skill.00000000-0000-0000-0000-000000000000". @param {string} userId The Amazon User ID to test with. Looks like "amzn1....
[ "Initializes", "necessary", "values", "before", "using", "the", "test", "framework", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L102-L108
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (resources) { 'use strict'; this.i18n = require('i18next'); var sprintf = require('i18next-sprintf-postprocessor'); this.i18n.use(sprintf).init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler, returnObjects: true, lng: this.locale, resources: resources }); }
javascript
function (resources) { 'use strict'; this.i18n = require('i18next'); var sprintf = require('i18next-sprintf-postprocessor'); this.i18n.use(sprintf).init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler, returnObjects: true, lng: this.locale, resources: resources }); }
[ "function", "(", "resources", ")", "{", "'use strict'", ";", "this", ".", "i18n", "=", "require", "(", "'i18next'", ")", ";", "var", "sprintf", "=", "require", "(", "'i18next-sprintf-postprocessor'", ")", ";", "this", ".", "i18n", ".", "use", "(", "sprintf...
Initializes i18n. @param {object} resources The 'resources' object to give to i18n.
[ "Initializes", "i18n", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L114-L124
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (tableName, partitionKeyName, attributesName) { 'use strict'; if (!tableName) { throw "'tableName' argument must be provided."; } this.dynamoDBTable = tableName; this.partitionKeyName = partitionKeyName || 'userId'; this.attributesName = attributesName || 'mapAttr'; let self = this; AWSMO...
javascript
function (tableName, partitionKeyName, attributesName) { 'use strict'; if (!tableName) { throw "'tableName' argument must be provided."; } this.dynamoDBTable = tableName; this.partitionKeyName = partitionKeyName || 'userId'; this.attributesName = attributesName || 'mapAttr'; let self = this; AWSMO...
[ "function", "(", "tableName", ",", "partitionKeyName", ",", "attributesName", ")", "{", "'use strict'", ";", "if", "(", "!", "tableName", ")", "{", "throw", "\"'tableName' argument must be provided.\"", ";", "}", "this", ".", "dynamoDBTable", "=", "tableName", ";"...
Activates mocking of DynamoDB backed attributes @param {string} tableName name of the DynamoDB Table @param {string} partitionKeyName the key to be used as id (default: userId) @param {string} attributesName the key to be used for the attributes (default: mapAttr)
[ "Activates", "mocking", "of", "DynamoDB", "backed", "attributes" ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L159-L177
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (intentName, slots, locale) { 'use strict'; var requestSlots; if (!slots) { requestSlots = {}; } else { requestSlots = JSON.parse(JSON.stringify(slots)); for (var key in requestSlots) { requestSlots[key] = {name: key, value: requestSlots[key]}; } } return { "version": this.vers...
javascript
function (intentName, slots, locale) { 'use strict'; var requestSlots; if (!slots) { requestSlots = {}; } else { requestSlots = JSON.parse(JSON.stringify(slots)); for (var key in requestSlots) { requestSlots[key] = {name: key, value: requestSlots[key]}; } } return { "version": this.vers...
[ "function", "(", "intentName", ",", "slots", ",", "locale", ")", "{", "'use strict'", ";", "var", "requestSlots", ";", "if", "(", "!", "slots", ")", "{", "requestSlots", "=", "{", "}", ";", "}", "else", "{", "requestSlots", "=", "JSON", ".", "parse", ...
Generates an intent request object. @param {string} intentName The name of the intent to call. @param {object} slots Slot data to call the intent with. @param {string} locale Optional locale to use. If not specified, uses the locale specified by `setLocale`.
[ "Generates", "an", "intent", "request", "object", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L225-L249
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (reason, locale) { 'use strict'; return { "version": this.version, "session": this._getSessionData(), "context": this._getContextData(), "request": { "type": "SessionEndedRequest", "requestId": "EdwRequestId." + uuid.v4(), "timestamp": new Date().toISOString(), "locale": locale ...
javascript
function (reason, locale) { 'use strict'; return { "version": this.version, "session": this._getSessionData(), "context": this._getContextData(), "request": { "type": "SessionEndedRequest", "requestId": "EdwRequestId." + uuid.v4(), "timestamp": new Date().toISOString(), "locale": locale ...
[ "function", "(", "reason", ",", "locale", ")", "{", "'use strict'", ";", "return", "{", "\"version\"", ":", "this", ".", "version", ",", "\"session\"", ":", "this", ".", "_getSessionData", "(", ")", ",", "\"context\"", ":", "this", ".", "_getContextData", ...
Generates a sesson ended request object. @param {string} reason The reason the session was ended. @param {string} locale Optional locale to use. If not specified, uses the locale specified by `setLocale`. @see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-standard-request-types-refere...
[ "Generates", "a", "sesson", "ended", "request", "object", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L257-L272
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (request, token, offset, activity) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (token) { request.context.AudioPlayer.token = token; } if (offset) { request.context.AudioPlayer.offsetInMilliseconds = offset; } if (activity) { re...
javascript
function (request, token, offset, activity) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (token) { request.context.AudioPlayer.token = token; } if (offset) { request.context.AudioPlayer.offsetInMilliseconds = offset; } if (activity) { re...
[ "function", "(", "request", ",", "token", ",", "offset", ",", "activity", ")", "{", "'use strict'", ";", "if", "(", "!", "request", ")", "{", "throw", "'request must be specified to add entity resolution'", ";", "}", "if", "(", "token", ")", "{", "request", ...
Adds an AudioPlayer context to the given request. @param {object} request The intent request to modify. @param {string} token An opaque token that represents the audio stream described by this AudioPlayer object. You provide this token when sending the Play directive. @param {string} offset Identifies a track’s offset ...
[ "Adds", "an", "AudioPlayer", "context", "to", "the", "given", "request", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L282-L298
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (request, slotName, slotType, value, id) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (!slotName) { throw 'slotName must be specified to add entity resolution'; } if (!value) { throw 'value must be specified to add entity resolution'; }...
javascript
function (request, slotName, slotType, value, id) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (!slotName) { throw 'slotName must be specified to add entity resolution'; } if (!value) { throw 'value must be specified to add entity resolution'; }...
[ "function", "(", "request", ",", "slotName", ",", "slotType", ",", "value", ",", "id", ")", "{", "'use strict'", ";", "if", "(", "!", "request", ")", "{", "throw", "'request must be specified to add entity resolution'", ";", "}", "if", "(", "!", "slotName", ...
Adds an entity resolution to the given request. @param {object} request The intent request to modify. @param {string} slotName The name of the slot to add the resolution to. If the slot does not exist it is added. @param {string} slotType The type of the slot. @param {string} value The value of the slot. @param {string...
[ "Adds", "an", "entity", "resolution", "to", "the", "given", "request", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L309-L362
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (request, resolutions) { 'use strict'; let alexaTest = this; resolutions.forEach(resolution => { alexaTest.addEntityResolutionToRequest(request, resolution.slotName, resolution.slotType, resolution.value, resolution.id); }); return request; }
javascript
function (request, resolutions) { 'use strict'; let alexaTest = this; resolutions.forEach(resolution => { alexaTest.addEntityResolutionToRequest(request, resolution.slotName, resolution.slotType, resolution.value, resolution.id); }); return request; }
[ "function", "(", "request", ",", "resolutions", ")", "{", "'use strict'", ";", "let", "alexaTest", "=", "this", ";", "resolutions", ".", "forEach", "(", "resolution", "=>", "{", "alexaTest", ".", "addEntityResolutionToRequest", "(", "request", ",", "resolution",...
Adds multiple entity resolutions to the given request. @param {object} request The intent request to modify. @param {array} resolutions The array containing the resolutions to add @return {object} the given intent request to allow chaining.
[ "Adds", "multiple", "entity", "resolutions", "to", "the", "given", "request", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L370-L377
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (request, slotName, slotType, value) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (!slotName) { throw 'slotName must be specified to add entity resolution'; } if (!value) { throw 'value must be specified to add entity resolution'; } ...
javascript
function (request, slotName, slotType, value) { 'use strict'; if (!request) { throw 'request must be specified to add entity resolution'; } if (!slotName) { throw 'slotName must be specified to add entity resolution'; } if (!value) { throw 'value must be specified to add entity resolution'; } ...
[ "function", "(", "request", ",", "slotName", ",", "slotType", ",", "value", ")", "{", "'use strict'", ";", "if", "(", "!", "request", ")", "{", "throw", "'request must be specified to add entity resolution'", ";", "}", "if", "(", "!", "slotName", ")", "{", "...
Adds an entity resolution with code ER_SUCCESS_NO_MATCH to the given request. @param {object} request The intent request to modify. @param {string} slotName The name of the slot to add the resolution to. If the slot does not exist it is added. @param {string} slotType The type of the slot. @param {string} value The val...
[ "Adds", "an", "entity", "resolution", "with", "code", "ER_SUCCESS_NO_MATCH", "to", "the", "given", "request", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L387-L416
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (context, name, actual, expected) { 'use strict'; if (expected !== actual) { context.assert( { message: "the response did not return the correct " + name + " value", expected: expected, actual: actual ? actual : String(actual), operator: "==", showDiff: true }); } }
javascript
function (context, name, actual, expected) { 'use strict'; if (expected !== actual) { context.assert( { message: "the response did not return the correct " + name + " value", expected: expected, actual: actual ? actual : String(actual), operator: "==", showDiff: true }); } }
[ "function", "(", "context", ",", "name", ",", "actual", ",", "expected", ")", "{", "'use strict'", ";", "if", "(", "expected", "!==", "actual", ")", "{", "context", ".", "assert", "(", "{", "message", ":", "\"the response did not return the correct \"", "+", ...
Internal method. Asserts if the strings are not equal.
[ "Internal", "method", ".", "Asserts", "if", "the", "strings", "are", "not", "equal", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L752-L762
train
BrianMacIntosh/alexa-skill-test-framework
index.js
function (context, name, actual, expectedArray) { 'use strict'; for (let i = 0; i < expectedArray.length; i++) { if (actual === expectedArray[i]) { return; } } context.assert( { message: "the response did not contain a valid speechOutput", expected: "one of [" + expectedArray.map(text => `"...
javascript
function (context, name, actual, expectedArray) { 'use strict'; for (let i = 0; i < expectedArray.length; i++) { if (actual === expectedArray[i]) { return; } } context.assert( { message: "the response did not contain a valid speechOutput", expected: "one of [" + expectedArray.map(text => `"...
[ "function", "(", "context", ",", "name", ",", "actual", ",", "expectedArray", ")", "{", "'use strict'", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "expectedArray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "actual", "===", "exp...
Internal method. Asserts if the string is not part of the array.
[ "Internal", "method", ".", "Asserts", "if", "the", "string", "is", "not", "part", "of", "the", "array", "." ]
6476443369e85e45800dd88f05ccc42a23ce6c48
https://github.com/BrianMacIntosh/alexa-skill-test-framework/blob/6476443369e85e45800dd88f05ccc42a23ce6c48/index.js#L767-L781
train
owncloud/davclient.js
lib/client.js
function(url, properties, depth, headers) { if(typeof depth === "undefined") { depth = '0'; } // depth header must be a string, in case a number was passed in depth = '' + depth; headers = headers || {}; headers['Depth'] = depth; headers['Content-T...
javascript
function(url, properties, depth, headers) { if(typeof depth === "undefined") { depth = '0'; } // depth header must be a string, in case a number was passed in depth = '' + depth; headers = headers || {}; headers['Depth'] = depth; headers['Content-T...
[ "function", "(", "url", ",", "properties", ",", "depth", ",", "headers", ")", "{", "if", "(", "typeof", "depth", "===", "\"undefined\"", ")", "{", "depth", "=", "'0'", ";", "}", "// depth header must be a string, in case a number was passed in", "depth", "=", "'...
Generates a propFind request. @param {string} url Url to do the propfind request on @param {Array} properties List of properties to retrieve. @param {string} depth "0", "1" or "infinity" @param {Object} [headers] headers @return {Promise}
[ "Generates", "a", "propFind", "request", "." ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L52-L112
train
owncloud/davclient.js
lib/client.js
function(url, properties, headers) { headers = headers || {}; headers['Content-Type'] = 'application/xml; charset=utf-8'; var body = '<?xml version="1.0"?>\n' + '<d:propertyupdate '; var namespace; for (namespace in this.xmlNamespaces) { body...
javascript
function(url, properties, headers) { headers = headers || {}; headers['Content-Type'] = 'application/xml; charset=utf-8'; var body = '<?xml version="1.0"?>\n' + '<d:propertyupdate '; var namespace; for (namespace in this.xmlNamespaces) { body...
[ "function", "(", "url", ",", "properties", ",", "headers", ")", "{", "headers", "=", "headers", "||", "{", "}", ";", "headers", "[", "'Content-Type'", "]", "=", "'application/xml; charset=utf-8'", ";", "var", "body", "=", "'<?xml version=\"1.0\"?>\\n'", "+", "...
Generates a propPatch request. @param {string} url Url to do the proppatch request on @param {Object.<String,String>} properties List of properties to store. @param {Object} [headers] headers @return {Promise}
[ "Generates", "a", "propPatch", "request", "." ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L158-L183
train
owncloud/davclient.js
lib/client.js
function(method, url, headers, body, responseType) { var self = this; var xhr = this.xhrProvider(); headers = headers || {}; responseType = responseType || ""; if (this.userName) { headers['Authorization'] = 'Basic ' + btoa(this.userName + ':' + this.passwor...
javascript
function(method, url, headers, body, responseType) { var self = this; var xhr = this.xhrProvider(); headers = headers || {}; responseType = responseType || ""; if (this.userName) { headers['Authorization'] = 'Basic ' + btoa(this.userName + ':' + this.passwor...
[ "function", "(", "method", ",", "url", ",", "headers", ",", "body", ",", "responseType", ")", "{", "var", "self", "=", "this", ";", "var", "xhr", "=", "this", ".", "xhrProvider", "(", ")", ";", "headers", "=", "headers", "||", "{", "}", ";", "respo...
Performs a HTTP request, and returns a Promise @param {string} method HTTP method @param {string} url Relative or absolute url @param {Object} headers HTTP headers as an object. @param {string} body HTTP request body. @param {string} responseType HTTP request response type. @return {Promise}
[ "Performs", "a", "HTTP", "request", "and", "returns", "a", "Promise" ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L233-L287
train
owncloud/davclient.js
lib/client.js
function(propNode) { var content = null; if (propNode.childNodes && propNode.childNodes.length > 0) { var subNodes = []; // filter out text nodes for (var j = 0; j < propNode.childNodes.length; j++) { var node = propNode.childNodes[j]; ...
javascript
function(propNode) { var content = null; if (propNode.childNodes && propNode.childNodes.length > 0) { var subNodes = []; // filter out text nodes for (var j = 0; j < propNode.childNodes.length; j++) { var node = propNode.childNodes[j]; ...
[ "function", "(", "propNode", ")", "{", "var", "content", "=", "null", ";", "if", "(", "propNode", ".", "childNodes", "&&", "propNode", ".", "childNodes", ".", "length", ">", "0", ")", "{", "var", "subNodes", "=", "[", "]", ";", "// filter out text nodes"...
Parses a property node. Either returns a string if the node only contains text, or returns an array of non-text subnodes. @param {Object} propNode node to parse @return {string|Array} text content as string or array of subnodes, excluding text nodes
[ "Parses", "a", "property", "node", "." ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L311-L328
train
owncloud/davclient.js
lib/client.js
function(xmlBody) { var parser = new DOMParser(); var doc = parser.parseFromString(xmlBody, "application/xml"); var resolver = function(foo) { var ii; for(ii in this.xmlNamespaces) { if (this.xmlNamespaces[ii] === foo) { return ii; ...
javascript
function(xmlBody) { var parser = new DOMParser(); var doc = parser.parseFromString(xmlBody, "application/xml"); var resolver = function(foo) { var ii; for(ii in this.xmlNamespaces) { if (this.xmlNamespaces[ii] === foo) { return ii; ...
[ "function", "(", "xmlBody", ")", "{", "var", "parser", "=", "new", "DOMParser", "(", ")", ";", "var", "doc", "=", "parser", ".", "parseFromString", "(", "xmlBody", ",", "\"application/xml\"", ")", ";", "var", "resolver", "=", "function", "(", "foo", ")",...
Parses a multi-status response body. @param {string} xmlBody @param {Array}
[ "Parses", "a", "multi", "-", "status", "response", "body", "." ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L336-L395
train
owncloud/davclient.js
lib/client.js
function(url) { // Note: this is rudamentary.. not sure yet if it handles every case. if (/^https?:\/\//i.test(url)) { // absolute return url; } var baseParts = this.parseUrl(this.baseUrl); if (url.charAt('/')) { // Url starts with a slash ...
javascript
function(url) { // Note: this is rudamentary.. not sure yet if it handles every case. if (/^https?:\/\//i.test(url)) { // absolute return url; } var baseParts = this.parseUrl(this.baseUrl); if (url.charAt('/')) { // Url starts with a slash ...
[ "function", "(", "url", ")", "{", "// Note: this is rudamentary.. not sure yet if it handles every case.", "if", "(", "/", "^https?:\\/\\/", "/", "i", ".", "test", "(", "url", ")", ")", "{", "// absolute", "return", "url", ";", "}", "var", "baseParts", "=", "thi...
Takes a relative url, and maps it to an absolute url, using the baseUrl @param {string} url @return {string}
[ "Takes", "a", "relative", "url", "and", "maps", "it", "to", "an", "absolute", "url", "using", "the", "baseUrl" ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L403-L425
train
owncloud/davclient.js
lib/client.js
function(url) { var parts = url.match(/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/); var result = { url : parts[0], scheme : parts[1], host : parts[3], port : parts[4], path : parts[5...
javascript
function(url) { var parts = url.match(/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/); var result = { url : parts[0], scheme : parts[1], host : parts[3], port : parts[4], path : parts[5...
[ "function", "(", "url", ")", "{", "var", "parts", "=", "url", ".", "match", "(", "/", "^(?:([A-Za-z]+):)?(\\/{0,3})([0-9.\\-A-Za-z]+)(?::(\\d+))?(?:\\/([^?#]*))?(?:\\?([^#]*))?(?:#(.*))?$", "/", ")", ";", "var", "result", "=", "{", "url", ":", "parts", "[", "0", "...
Parses a url and returns its individual components. @param {String} url @return {Object}
[ "Parses", "a", "url", "and", "returns", "its", "individual", "components", "." ]
07237a4bb813eb19e19e322e2457ce216721d529
https://github.com/owncloud/davclient.js/blob/07237a4bb813eb19e19e322e2457ce216721d529/lib/client.js#L433-L452
train
naholyr/github-todos
index.js
checkUpdate
function checkUpdate () { var pkg = require("./package.json"); require("update-notifier")({ packageName: pkg.name, packageVersion: pkg.version }).notify(); }
javascript
function checkUpdate () { var pkg = require("./package.json"); require("update-notifier")({ packageName: pkg.name, packageVersion: pkg.version }).notify(); }
[ "function", "checkUpdate", "(", ")", "{", "var", "pkg", "=", "require", "(", "\"./package.json\"", ")", ";", "require", "(", "\"update-notifier\"", ")", "(", "{", "packageName", ":", "pkg", ".", "name", ",", "packageVersion", ":", "pkg", ".", "version", "}...
Check for package update
[ "Check", "for", "package", "update" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/index.js#L35-L41
train
naholyr/github-todos
index.js
main
function main (processArgv, conf) { // CLI input var opts = getOpts(processArgv); var argv = opts.argv; // Update notifier if (!argv["no-notifier"]) { checkUpdate(); } // Convert options "--help" and "-h" into command "help" if (argv.help) { processArgv = transformHelpArgs(processArgv); /...
javascript
function main (processArgv, conf) { // CLI input var opts = getOpts(processArgv); var argv = opts.argv; // Update notifier if (!argv["no-notifier"]) { checkUpdate(); } // Convert options "--help" and "-h" into command "help" if (argv.help) { processArgv = transformHelpArgs(processArgv); /...
[ "function", "main", "(", "processArgv", ",", "conf", ")", "{", "// CLI input", "var", "opts", "=", "getOpts", "(", "processArgv", ")", ";", "var", "argv", "=", "opts", ".", "argv", ";", "// Update notifier", "if", "(", "!", "argv", "[", "\"no-notifier\"", ...
Main execution, after env has been checked
[ "Main", "execution", "after", "env", "has", "been", "checked" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/index.js#L71-L136
train
naholyr/github-todos
lib/todos.js
rememberSkip
function rememberSkip (title) { return readIgnoreFile().spread(function (ignores, skipFile) { if (!_.contains(ignores, title)) { return fs.writeFile(skipFile, ignores.concat([title]).join("\n")); } }); }
javascript
function rememberSkip (title) { return readIgnoreFile().spread(function (ignores, skipFile) { if (!_.contains(ignores, title)) { return fs.writeFile(skipFile, ignores.concat([title]).join("\n")); } }); }
[ "function", "rememberSkip", "(", "title", ")", "{", "return", "readIgnoreFile", "(", ")", ".", "spread", "(", "function", "(", "ignores", ",", "skipFile", ")", "{", "if", "(", "!", "_", ".", "contains", "(", "ignores", ",", "title", ")", ")", "{", "r...
Add line to github-todos-ignore
[ "Add", "line", "to", "github", "-", "todos", "-", "ignore" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/lib/todos.js#L92-L98
train
naholyr/github-todos
doc/issue-service/sample.js
convertIssue
function convertIssue (issue) { if (!issue) { return null; } return { "type": "issue", "number": issue.number, "url": issue.url, "title": issue.title, "labels": issue.labels }; }
javascript
function convertIssue (issue) { if (!issue) { return null; } return { "type": "issue", "number": issue.number, "url": issue.url, "title": issue.title, "labels": issue.labels }; }
[ "function", "convertIssue", "(", "issue", ")", "{", "if", "(", "!", "issue", ")", "{", "return", "null", ";", "}", "return", "{", "\"type\"", ":", "\"issue\"", ",", "\"number\"", ":", "issue", ".", "number", ",", "\"url\"", ":", "issue", ".", "url", ...
Convert issue to Github-Todos format
[ "Convert", "issue", "to", "Github", "-", "Todos", "format" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L41-L53
train
naholyr/github-todos
doc/issue-service/sample.js
allIssues
function allIssues (client, repo) { return client.getIssues(repo).then(function (issues) { return issues.map(convertIssue); }); }
javascript
function allIssues (client, repo) { return client.getIssues(repo).then(function (issues) { return issues.map(convertIssue); }); }
[ "function", "allIssues", "(", "client", ",", "repo", ")", "{", "return", "client", ".", "getIssues", "(", "repo", ")", ".", "then", "(", "function", "(", "issues", ")", "{", "return", "issues", ".", "map", "(", "convertIssue", ")", ";", "}", ")", ";"...
Assuming client.getIssues returns promise of issues
[ "Assuming", "client", ".", "getIssues", "returns", "promise", "of", "issues" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L77-L81
train
naholyr/github-todos
doc/issue-service/sample.js
createIssue
function createIssue (client, repo, title, body, labels) { return client.createIssue(repo, title, body, labels).then(convertIssue); }
javascript
function createIssue (client, repo, title, body, labels) { return client.createIssue(repo, title, body, labels).then(convertIssue); }
[ "function", "createIssue", "(", "client", ",", "repo", ",", "title", ",", "body", ",", "labels", ")", "{", "return", "client", ".", "createIssue", "(", "repo", ",", "title", ",", "body", ",", "labels", ")", ".", "then", "(", "convertIssue", ")", ";", ...
Assuming client.createIssue returns a promise of issue
[ "Assuming", "client", ".", "createIssue", "returns", "a", "promise", "of", "issue" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L84-L86
train
naholyr/github-todos
doc/issue-service/sample.js
commentIssue
function commentIssue (client, repo, number, comment) { return client.createComment(repo, number, comment).then(convertComment); }
javascript
function commentIssue (client, repo, number, comment) { return client.createComment(repo, number, comment).then(convertComment); }
[ "function", "commentIssue", "(", "client", ",", "repo", ",", "number", ",", "comment", ")", "{", "return", "client", ".", "createComment", "(", "repo", ",", "number", ",", "comment", ")", ".", "then", "(", "convertComment", ")", ";", "}" ]
Assuming client.createComment returns a promise of comment
[ "Assuming", "client", ".", "createComment", "returns", "a", "promise", "of", "comment" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L89-L91
train
naholyr/github-todos
doc/issue-service/sample.js
tagIssue
function tagIssue (client, repo, number, label) { return client.addLabel(repo, number, label).then(convertIssue); }
javascript
function tagIssue (client, repo, number, label) { return client.addLabel(repo, number, label).then(convertIssue); }
[ "function", "tagIssue", "(", "client", ",", "repo", ",", "number", ",", "label", ")", "{", "return", "client", ".", "addLabel", "(", "repo", ",", "number", ",", "label", ")", ".", "then", "(", "convertIssue", ")", ";", "}" ]
Assuming client.addLabel returns a promise of issue
[ "Assuming", "client", ".", "addLabel", "returns", "a", "promise", "of", "issue" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L94-L96
train
naholyr/github-todos
doc/issue-service/sample.js
connect
function connect (conf) { // Instantiating API client, this is the one that will be passed to other methods var client = new Client(); if (conf["my-host.token"]) { // Authorize client client.setToken(conf["my-host.token"]); // Check token… return checkToken(client) .then(null, function () {...
javascript
function connect (conf) { // Instantiating API client, this is the one that will be passed to other methods var client = new Client(); if (conf["my-host.token"]) { // Authorize client client.setToken(conf["my-host.token"]); // Check token… return checkToken(client) .then(null, function () {...
[ "function", "connect", "(", "conf", ")", "{", "// Instantiating API client, this is the one that will be passed to other methods", "var", "client", "=", "new", "Client", "(", ")", ";", "if", "(", "conf", "[", "\"my-host.token\"", "]", ")", "{", "// Authorize client", ...
Assuming client.setToken sets authorization token for next calls
[ "Assuming", "client", ".", "setToken", "sets", "authorization", "token", "for", "next", "calls" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L111-L129
train
naholyr/github-todos
doc/issue-service/sample.js
createToken
function createToken (client) { return ask([ {"type": "input", "message": "Username", "name": "user"}, {"type": "password", "message": "Password", "name": "password"} ]).then(function (answers) { return client.createToken(answers.username, answers.password) .then(saveToken) .then(functi...
javascript
function createToken (client) { return ask([ {"type": "input", "message": "Username", "name": "user"}, {"type": "password", "message": "Password", "name": "password"} ]).then(function (answers) { return client.createToken(answers.username, answers.password) .then(saveToken) .then(functi...
[ "function", "createToken", "(", "client", ")", "{", "return", "ask", "(", "[", "{", "\"type\"", ":", "\"input\"", ",", "\"message\"", ":", "\"Username\"", ",", "\"name\"", ":", "\"user\"", "}", ",", "{", "\"type\"", ":", "\"password\"", ",", "\"message\"", ...
Assuming client.createToken returns a promise of string
[ "Assuming", "client", ".", "createToken", "returns", "a", "promise", "of", "string" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/doc/issue-service/sample.js#L141-L155
train
naholyr/github-todos
lib/issue-service/bitbucket.js
getFileUrl
function getFileUrl (repo, path, sha, line) { return HOST + "/" + repo + "/src/" + sha + "/" + path + "#cl-" + line; }
javascript
function getFileUrl (repo, path, sha, line) { return HOST + "/" + repo + "/src/" + sha + "/" + path + "#cl-" + line; }
[ "function", "getFileUrl", "(", "repo", ",", "path", ",", "sha", ",", "line", ")", "{", "return", "HOST", "+", "\"/\"", "+", "repo", "+", "\"/src/\"", "+", "sha", "+", "\"/\"", "+", "path", "+", "\"#cl-\"", "+", "line", ";", "}" ]
Synchronously generate direct link to file
[ "Synchronously", "generate", "direct", "link", "to", "file" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/lib/issue-service/bitbucket.js#L130-L132
train
naholyr/github-todos
lib/commands.js
load
function load (commandName) { var command; try { command = require("./cli/" + commandName); } catch (e) { debug("Error loading command", commandName, e); command = null; } return command; }
javascript
function load (commandName) { var command; try { command = require("./cli/" + commandName); } catch (e) { debug("Error loading command", commandName, e); command = null; } return command; }
[ "function", "load", "(", "commandName", ")", "{", "var", "command", ";", "try", "{", "command", "=", "require", "(", "\"./cli/\"", "+", "commandName", ")", ";", "}", "catch", "(", "e", ")", "{", "debug", "(", "\"Error loading command\"", ",", "commandName"...
Safe-require command module
[ "Safe", "-", "require", "command", "module" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/lib/commands.js#L14-L25
train
naholyr/github-todos
lib/commands.js
run
function run (command, opts, conf) { // Use "new Promise" to isolate process and catch any error return new Promise(function (resolve, reject) { if (command.config) { opts = command.config(opts, conf); } Promise.cast(command.run(opts.argv, opts, conf)).then(resolve, reject); }); }
javascript
function run (command, opts, conf) { // Use "new Promise" to isolate process and catch any error return new Promise(function (resolve, reject) { if (command.config) { opts = command.config(opts, conf); } Promise.cast(command.run(opts.argv, opts, conf)).then(resolve, reject); }); }
[ "function", "run", "(", "command", ",", "opts", ",", "conf", ")", "{", "// Use \"new Promise\" to isolate process and catch any error", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "if", "(", "command", ".", "config", ")"...
Safe-fun command
[ "Safe", "-", "fun", "command" ]
4f9b0ce4be718d911b82e414a0b7135c9bdfcade
https://github.com/naholyr/github-todos/blob/4f9b0ce4be718d911b82e414a0b7135c9bdfcade/lib/commands.js#L28-L37
train
robophil/Product-Tour
js/product-tour.js
getActiveStepCount
function getActiveStepCount() { var tourWrapper = jQuery('.cd-tour-wrapper'), //get the wrapper element tourSteps = tourWrapper.children('li'); //get all its children with tag 'li' var current_index = 0; tourSteps.each(function (index, li) { if (jQuer...
javascript
function getActiveStepCount() { var tourWrapper = jQuery('.cd-tour-wrapper'), //get the wrapper element tourSteps = tourWrapper.children('li'); //get all its children with tag 'li' var current_index = 0; tourSteps.each(function (index, li) { if (jQuer...
[ "function", "getActiveStepCount", "(", ")", "{", "var", "tourWrapper", "=", "jQuery", "(", "'.cd-tour-wrapper'", ")", ",", "//get the wrapper element", "tourSteps", "=", "tourWrapper", ".", "children", "(", "'li'", ")", ";", "//get all its children with tag 'li'", "va...
this returns the active step number @return {number}
[ "this", "returns", "the", "active", "step", "number" ]
5613a945e01144cd553ecbe1be73fc1e81f85500
https://github.com/robophil/Product-Tour/blob/5613a945e01144cd553ecbe1be73fc1e81f85500/js/product-tour.js#L296-L307
train
dunn/libgen.js
lib/check.js
function(text, callback){ const md5 = (text.md5) ? text.md5.toLowerCase() : text.toLowerCase(); const mirrors = require('../available_mirrors.js'); let downloadMirrors = []; let n = mirrors.length; // create an array of mirrors that allow direct downloads while (n--) if (mirrors[n].canDow...
javascript
function(text, callback){ const md5 = (text.md5) ? text.md5.toLowerCase() : text.toLowerCase(); const mirrors = require('../available_mirrors.js'); let downloadMirrors = []; let n = mirrors.length; // create an array of mirrors that allow direct downloads while (n--) if (mirrors[n].canDow...
[ "function", "(", "text", ",", "callback", ")", "{", "const", "md5", "=", "(", "text", ".", "md5", ")", "?", "text", ".", "md5", ".", "toLowerCase", "(", ")", ":", "text", ".", "toLowerCase", "(", ")", ";", "const", "mirrors", "=", "require", "(", ...
text can be a json object or an MD5 string
[ "text", "can", "be", "a", "json", "object", "or", "an", "MD5", "string" ]
12bf14e7deef9e8a704c8500a9951b609e2168df
https://github.com/dunn/libgen.js/blob/12bf14e7deef9e8a704c8500a9951b609e2168df/lib/check.js#L17-L54
train
dunn/libgen.js
lib/clean.js
function(json, fields) { if (((typeof json) === 'object') && !Array.isArray(json)) return hasFields(json,fields); else if (Array.isArray(json)) { var spliced = []; var n = json.length; while (n--) if (hasFields(json[n],fields)) spliced.push(json[n]); if (spliced....
javascript
function(json, fields) { if (((typeof json) === 'object') && !Array.isArray(json)) return hasFields(json,fields); else if (Array.isArray(json)) { var spliced = []; var n = json.length; while (n--) if (hasFields(json[n],fields)) spliced.push(json[n]); if (spliced....
[ "function", "(", "json", ",", "fields", ")", "{", "if", "(", "(", "(", "typeof", "json", ")", "===", "'object'", ")", "&&", "!", "Array", ".", "isArray", "(", "json", ")", ")", "return", "hasFields", "(", "json", ",", "fields", ")", ";", "else", ...
removes texts that don't have the specified fields
[ "removes", "texts", "that", "don", "t", "have", "the", "specified", "fields" ]
12bf14e7deef9e8a704c8500a9951b609e2168df
https://github.com/dunn/libgen.js/blob/12bf14e7deef9e8a704c8500a9951b609e2168df/lib/clean.js#L32-L49
train
dunn/libgen.js
lib/clean.js
function(array) { let sorted = array.sort((a, b) => { return a.id - b.id; }); let i = sorted.length - 1; while (i--) if (sorted[i + 1].id === sorted[i].id) sorted.splice(i,1); return sorted; }
javascript
function(array) { let sorted = array.sort((a, b) => { return a.id - b.id; }); let i = sorted.length - 1; while (i--) if (sorted[i + 1].id === sorted[i].id) sorted.splice(i,1); return sorted; }
[ "function", "(", "array", ")", "{", "let", "sorted", "=", "array", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "{", "return", "a", ".", "id", "-", "b", ".", "id", ";", "}", ")", ";", "let", "i", "=", "sorted", ".", "length", "-", "1", ...
removes duplicate texts from an array of libgen json objects
[ "removes", "duplicate", "texts", "from", "an", "array", "of", "libgen", "json", "objects" ]
12bf14e7deef9e8a704c8500a9951b609e2168df
https://github.com/dunn/libgen.js/blob/12bf14e7deef9e8a704c8500a9951b609e2168df/lib/clean.js#L51-L61
train
anvaka/oflow
demo/pingpong/src/game.js
Game
function Game(scene) { var isOver = false, overCallbacks = [], cachedPos = new Geometry.Point(), ball = new Ball(scene), gameOver = function (side) { var i; isOver = true; for (i = 0; i < overCallbacks.length; ++i) { overCallbacks[...
javascript
function Game(scene) { var isOver = false, overCallbacks = [], cachedPos = new Geometry.Point(), ball = new Ball(scene), gameOver = function (side) { var i; isOver = true; for (i = 0; i < overCallbacks.length; ++i) { overCallbacks[...
[ "function", "Game", "(", "scene", ")", "{", "var", "isOver", "=", "false", ",", "overCallbacks", "=", "[", "]", ",", "cachedPos", "=", "new", "Geometry", ".", "Point", "(", ")", ",", "ball", "=", "new", "Ball", "(", "scene", ")", ",", "gameOver", "...
Ping Pong game model
[ "Ping", "Pong", "game", "model" ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/game.js#L13-L61
train
anvaka/oflow
demo/pingpong/src/scene.js
Scene
function Scene(container) { var ctx = container.getContext('2d'), cachedHeight = container.height, cachedWidth = container.width, getWidth = function () { return cachedWidth; }, getHeight = function () { return cachedHeight; }, renderHa...
javascript
function Scene(container) { var ctx = container.getContext('2d'), cachedHeight = container.height, cachedWidth = container.width, getWidth = function () { return cachedWidth; }, getHeight = function () { return cachedHeight; }, renderHa...
[ "function", "Scene", "(", "container", ")", "{", "var", "ctx", "=", "container", ".", "getContext", "(", "'2d'", ")", ",", "cachedHeight", "=", "container", ".", "height", ",", "cachedWidth", "=", "container", ".", "width", ",", "getWidth", "=", "function"...
Renders game to the canvas.
[ "Renders", "game", "to", "the", "canvas", "." ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/scene.js#L10-L50
train
anvaka/oflow
demo/pingpong/src/eventLoop.js
EventLoop
function EventLoop() { var renderCallbacks = [], intervalId, startInternal = function () { intervalId = requestAnimationFrame(startInternal); for (var i = 0, n = renderCallbacks.length; i < n; ++i) { renderCallbacks[i](); } }; this.onR...
javascript
function EventLoop() { var renderCallbacks = [], intervalId, startInternal = function () { intervalId = requestAnimationFrame(startInternal); for (var i = 0, n = renderCallbacks.length; i < n; ++i) { renderCallbacks[i](); } }; this.onR...
[ "function", "EventLoop", "(", ")", "{", "var", "renderCallbacks", "=", "[", "]", ",", "intervalId", ",", "startInternal", "=", "function", "(", ")", "{", "intervalId", "=", "requestAnimationFrame", "(", "startInternal", ")", ";", "for", "(", "var", "i", "=...
A simple event loop class, which fires onRender events on each animation frame
[ "A", "simple", "event", "loop", "class", "which", "fires", "onRender", "events", "on", "each", "animation", "frame" ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/eventLoop.js#L8-L32
train
anvaka/oflow
demo/pingpong/src/utils.js
whenReady
function whenReady() { var pendingObjects = [].slice.call(arguments), wait = pendingObjects.length, resolvedCallback, promise = { run : function (callback) { resolvedCallback = callback; } }, resolved = function () { wait -=...
javascript
function whenReady() { var pendingObjects = [].slice.call(arguments), wait = pendingObjects.length, resolvedCallback, promise = { run : function (callback) { resolvedCallback = callback; } }, resolved = function () { wait -=...
[ "function", "whenReady", "(", ")", "{", "var", "pendingObjects", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ",", "wait", "=", "pendingObjects", ".", "length", ",", "resolvedCallback", ",", "promise", "=", "{", "run", ":", "function"...
just a little helper method to wait for multiple objects and fire event when all of them indicated they are ready
[ "just", "a", "little", "helper", "method", "to", "wait", "for", "multiple", "objects", "and", "fire", "event", "when", "all", "of", "them", "indicated", "they", "are", "ready" ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/utils.js#L10-L39
train
anvaka/oflow
demo/pingpong/src/handle.js
Handle
function Handle(isLeft, scene) { this.height = settings.handleHeight; this.width = settings.handleWidth; this.x = isLeft ? 0 : scene.width() - this.width; this.y = (scene.height() - this.height) / 2; var offset = isLeft ? this.width : 0, intersect = new Geometry.Intersect(); this.hit =...
javascript
function Handle(isLeft, scene) { this.height = settings.handleHeight; this.width = settings.handleWidth; this.x = isLeft ? 0 : scene.width() - this.width; this.y = (scene.height() - this.height) / 2; var offset = isLeft ? this.width : 0, intersect = new Geometry.Intersect(); this.hit =...
[ "function", "Handle", "(", "isLeft", ",", "scene", ")", "{", "this", ".", "height", "=", "settings", ".", "handleHeight", ";", "this", ".", "width", "=", "settings", ".", "handleWidth", ";", "this", ".", "x", "=", "isLeft", "?", "0", ":", "scene", "....
Represents a single ping pong handle either left or right
[ "Represents", "a", "single", "ping", "pong", "handle", "either", "left", "or", "right" ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/handle.js#L11-L33
train
anvaka/oflow
demo/pingpong/src/ball.js
Ball
function Ball(scene) { this.x = scene.width() / 2; this.y = scene.height() / 2; this.vx = 1;// + Math.random()* 2; this.vy = 1;// + Math.random() * 2; this.move = function () { this.x += this.vx; this.y += this.vy; if (this.y < 0) { this.y = 0; this.v...
javascript
function Ball(scene) { this.x = scene.width() / 2; this.y = scene.height() / 2; this.vx = 1;// + Math.random()* 2; this.vy = 1;// + Math.random() * 2; this.move = function () { this.x += this.vx; this.y += this.vy; if (this.y < 0) { this.y = 0; this.v...
[ "function", "Ball", "(", "scene", ")", "{", "this", ".", "x", "=", "scene", ".", "width", "(", ")", "/", "2", ";", "this", ".", "y", "=", "scene", ".", "height", "(", ")", "/", "2", ";", "this", ".", "vx", "=", "1", ";", "// + Math.random()* 2;...
Represents a ball object on the scene
[ "Represents", "a", "ball", "object", "on", "the", "scene" ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/ball.js#L8-L38
train
anvaka/oflow
demo/pingpong/src/controllers/webcamController.js
WebCamController
function WebCamController() { var flow = new oflow.WebCamFlow(), readyCallback, waitReady = true; return { mount: function (handle) { flow.onCalculated(function (direction) { if (waitReady) { readyCallback(); waitReady ...
javascript
function WebCamController() { var flow = new oflow.WebCamFlow(), readyCallback, waitReady = true; return { mount: function (handle) { flow.onCalculated(function (direction) { if (waitReady) { readyCallback(); waitReady ...
[ "function", "WebCamController", "(", ")", "{", "var", "flow", "=", "new", "oflow", ".", "WebCamFlow", "(", ")", ",", "readyCallback", ",", "waitReady", "=", "true", ";", "return", "{", "mount", ":", "function", "(", "handle", ")", "{", "flow", ".", "on...
Controls a handle via optical flow detection from the webcam.
[ "Controls", "a", "handle", "via", "optical", "flow", "detection", "from", "the", "webcam", "." ]
6e81b16756eb55c6544261a26395c32a6d07374d
https://github.com/anvaka/oflow/blob/6e81b16756eb55c6544261a26395c32a6d07374d/demo/pingpong/src/controllers/webcamController.js#L9-L34
train
mikolalysenko/static-kdtree
bench/ubilabs.js
loadTree
function loadTree (data) { // Just need to restore the `parent` parameter self.root = data; function restoreParent (root) { if (root.left) { root.left.parent = root; restoreParent(root.left); } if (root.right) { root.right.parent = root; ...
javascript
function loadTree (data) { // Just need to restore the `parent` parameter self.root = data; function restoreParent (root) { if (root.left) { root.left.parent = root; restoreParent(root.left); } if (root.right) { root.right.parent = root; ...
[ "function", "loadTree", "(", "data", ")", "{", "// Just need to restore the `parent` parameter", "self", ".", "root", "=", "data", ";", "function", "restoreParent", "(", "root", ")", "{", "if", "(", "root", ".", "left", ")", "{", "root", ".", "left", ".", ...
Reloads a serialied tree
[ "Reloads", "a", "serialied", "tree" ]
9bbc8397ca81c5bf2233776310206ed779a83c2e
https://github.com/mikolalysenko/static-kdtree/blob/9bbc8397ca81c5bf2233776310206ed779a83c2e/bench/ubilabs.js#L51-L68
train
dwmkerr/wait-port
lib/wait-port.js
tryConnect
function tryConnect(options, timeout) { return new Promise((resolve, reject) => { try { const socket = createConnectionWithTimeout(options, timeout, (err) => { if (err) { if (err.code === 'ECONNREFUSED') { // We successfully *tried* to connect, so resolve with false so ...
javascript
function tryConnect(options, timeout) { return new Promise((resolve, reject) => { try { const socket = createConnectionWithTimeout(options, timeout, (err) => { if (err) { if (err.code === 'ECONNREFUSED') { // We successfully *tried* to connect, so resolve with false so ...
[ "function", "tryConnect", "(", "options", ",", "timeout", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "try", "{", "const", "socket", "=", "createConnectionWithTimeout", "(", "options", ",", "timeout", ",", "(",...
This function attempts to open a connection, given a limited time window. This is the function which we will run repeatedly until we connect.
[ "This", "function", "attempts", "to", "open", "a", "connection", "given", "a", "limited", "time", "window", ".", "This", "is", "the", "function", "which", "we", "will", "run", "repeatedly", "until", "we", "connect", "." ]
e68862259ff1c0f095b057cd50dbab6911e49103
https://github.com/dwmkerr/wait-port/blob/e68862259ff1c0f095b057cd50dbab6911e49103/lib/wait-port.js#L83-L156
train
jacoborus/estilo
src/load-project.js
loadNterm
function loadNterm (project) { const templatePath = path.resolve(project.path, 'estilo/addons/nvim-term.yml') if (!fs.existsSync(templatePath)) { project.nterm = false } else { project.nterm = yaml.safeLoad(fs.readFileSync(templatePath)) } return project }
javascript
function loadNterm (project) { const templatePath = path.resolve(project.path, 'estilo/addons/nvim-term.yml') if (!fs.existsSync(templatePath)) { project.nterm = false } else { project.nterm = yaml.safeLoad(fs.readFileSync(templatePath)) } return project }
[ "function", "loadNterm", "(", "project", ")", "{", "const", "templatePath", "=", "path", ".", "resolve", "(", "project", ".", "path", ",", "'estilo/addons/nvim-term.yml'", ")", "if", "(", "!", "fs", ".", "existsSync", "(", "templatePath", ")", ")", "{", "p...
load nvim term template
[ "load", "nvim", "term", "template" ]
8feea237b27826b9c84a8f0d862ae278dc9c312e
https://github.com/jacoborus/estilo/blob/8feea237b27826b9c84a8f0d862ae278dc9c312e/src/load-project.js#L131-L139
train
mysticatea/eslint-plugin-es
lib/rules/no-unicode-codepoint-escapes.js
findAndReport
function findAndReport(text, node) { for (const match of codePointEscapeSearchGenerator(text)) { const start = match.index const end = start + match[0].length const range = [start + node.start, end + node.start] context.report({ ...
javascript
function findAndReport(text, node) { for (const match of codePointEscapeSearchGenerator(text)) { const start = match.index const end = start + match[0].length const range = [start + node.start, end + node.start] context.report({ ...
[ "function", "findAndReport", "(", "text", ",", "node", ")", "{", "for", "(", "const", "match", "of", "codePointEscapeSearchGenerator", "(", "text", ")", ")", "{", "const", "start", "=", "match", ".", "index", "const", "end", "=", "start", "+", "match", "...
find code point escape, and report @param {string} text text @param {Node} node node @returns {void}
[ "find", "code", "point", "escape", "and", "report" ]
5203ab2902f4ebd68b7089465a8785e122cebf87
https://github.com/mysticatea/eslint-plugin-es/blob/5203ab2902f4ebd68b7089465a8785e122cebf87/lib/rules/no-unicode-codepoint-escapes.js#L46-L83
train
uqee/sticky-cluster
example/index.js
function (callback) { async.parallel( [ // fake db 1 function (callback) { setTimeout(callback, 2000); }, // fake db 2 function (callback) { setTimeout(callback, 1000); } ], callback ); }
javascript
function (callback) { async.parallel( [ // fake db 1 function (callback) { setTimeout(callback, 2000); }, // fake db 2 function (callback) { setTimeout(callback, 1000); } ], callback ); }
[ "function", "(", "callback", ")", "{", "async", ".", "parallel", "(", "[", "// fake db 1", "function", "(", "callback", ")", "{", "setTimeout", "(", "callback", ",", "2000", ")", ";", "}", ",", "// fake db 2", "function", "(", "callback", ")", "{", "setT...
connect to remote services
[ "connect", "to", "remote", "services" ]
4cc3a9066b2d666b0cc175d3b97f7e1eab2154e6
https://github.com/uqee/sticky-cluster/blob/4cc3a9066b2d666b0cc175d3b97f7e1eab2154e6/example/index.js#L11-L22
train
uqee/sticky-cluster
example/index.js
function (services, callback) { var http = require('http'); var app = require('express')(); var server = http.createServer(app); // get remote services //var fakedb1 = services[0]; //var fakedb2 = services[1]; // all express-related stuff goes here...
javascript
function (services, callback) { var http = require('http'); var app = require('express')(); var server = http.createServer(app); // get remote services //var fakedb1 = services[0]; //var fakedb2 = services[1]; // all express-related stuff goes here...
[ "function", "(", "services", ",", "callback", ")", "{", "var", "http", "=", "require", "(", "'http'", ")", ";", "var", "app", "=", "require", "(", "'express'", ")", "(", ")", ";", "var", "server", "=", "http", ".", "createServer", "(", "app", ")", ...
configure the worker
[ "configure", "the", "worker" ]
4cc3a9066b2d666b0cc175d3b97f7e1eab2154e6
https://github.com/uqee/sticky-cluster/blob/4cc3a9066b2d666b0cc175d3b97f7e1eab2154e6/example/index.js#L26-L44
train
mysticatea/eslint-plugin-es
lib/rules/no-template-literals.js
isStringLiteralCode
function isStringLiteralCode(s) { return ( (s.startsWith("'") && s.endsWith("'")) || (s.startsWith('"') && s.endsWith('"')) ) }
javascript
function isStringLiteralCode(s) { return ( (s.startsWith("'") && s.endsWith("'")) || (s.startsWith('"') && s.endsWith('"')) ) }
[ "function", "isStringLiteralCode", "(", "s", ")", "{", "return", "(", "(", "s", ".", "startsWith", "(", "\"'\"", ")", "&&", "s", ".", "endsWith", "(", "\"'\"", ")", ")", "||", "(", "s", ".", "startsWith", "(", "'\"'", ")", "&&", "s", ".", "endsWith...
Checks whether it is string literal @param {string} s string source code @returns {boolean} true: is string literal source code
[ "Checks", "whether", "it", "is", "string", "literal" ]
5203ab2902f4ebd68b7089465a8785e122cebf87
https://github.com/mysticatea/eslint-plugin-es/blob/5203ab2902f4ebd68b7089465a8785e122cebf87/lib/rules/no-template-literals.js#L12-L17
train
mysticatea/eslint-plugin-es
lib/rules/no-template-literals.js
templateLiteralToStringConcat
function templateLiteralToStringConcat(node, sourceCode) { const ss = [] node.quasis.forEach((q, i) => { const value = q.value.cooked if (value) { ss.push(JSON.stringify(value)) } if (i < node.expressions.length) { const e = node.expressions[i] ...
javascript
function templateLiteralToStringConcat(node, sourceCode) { const ss = [] node.quasis.forEach((q, i) => { const value = q.value.cooked if (value) { ss.push(JSON.stringify(value)) } if (i < node.expressions.length) { const e = node.expressions[i] ...
[ "function", "templateLiteralToStringConcat", "(", "node", ",", "sourceCode", ")", "{", "const", "ss", "=", "[", "]", "node", ".", "quasis", ".", "forEach", "(", "(", "q", ",", "i", ")", "=>", "{", "const", "value", "=", "q", ".", "value", ".", "cooke...
Transform template literal to string concatenation. @param {ASTNode} node TemplateLiteral node.(not within TaggedTemplateExpression) @param {SourceCode} sourceCode SourceCode @returns {string} After transformation
[ "Transform", "template", "literal", "to", "string", "concatenation", "." ]
5203ab2902f4ebd68b7089465a8785e122cebf87
https://github.com/mysticatea/eslint-plugin-es/blob/5203ab2902f4ebd68b7089465a8785e122cebf87/lib/rules/no-template-literals.js#L25-L43
train
mysticatea/eslint-plugin-es
lib/rules/no-arrow-functions.js
toFunctionExpression
function toFunctionExpression(node) { const params = node.params const paramText = params.length ? sourceCode.text.slice( params[0].range[0], params[params.length - 1].range[1] ) : "" const...
javascript
function toFunctionExpression(node) { const params = node.params const paramText = params.length ? sourceCode.text.slice( params[0].range[0], params[params.length - 1].range[1] ) : "" const...
[ "function", "toFunctionExpression", "(", "node", ")", "{", "const", "params", "=", "node", ".", "params", "const", "paramText", "=", "params", ".", "length", "?", "sourceCode", ".", "text", ".", "slice", "(", "params", "[", "0", "]", ".", "range", "[", ...
ArrowFunctionExpression to FunctionExpression @param {Node} node ArrowFunctionExpression Node @returns {string} function expression text
[ "ArrowFunctionExpression", "to", "FunctionExpression" ]
5203ab2902f4ebd68b7089465a8785e122cebf87
https://github.com/mysticatea/eslint-plugin-es/blob/5203ab2902f4ebd68b7089465a8785e122cebf87/lib/rules/no-arrow-functions.js#L32-L61
train
mysticatea/eslint-plugin-es
lib/rules/no-arrow-functions.js
report
function report(node, hasThis, hasSuper) { context.report({ node, messageId: "forbidden", fix(fixer) { if (hasSuper) { return undefined } const functionText = toFunctionExpress...
javascript
function report(node, hasThis, hasSuper) { context.report({ node, messageId: "forbidden", fix(fixer) { if (hasSuper) { return undefined } const functionText = toFunctionExpress...
[ "function", "report", "(", "node", ",", "hasThis", ",", "hasSuper", ")", "{", "context", ".", "report", "(", "{", "node", ",", "messageId", ":", "\"forbidden\"", ",", "fix", "(", "fixer", ")", "{", "if", "(", "hasSuper", ")", "{", "return", "undefined"...
Report that ArrowFunctionExpression is being used @param {Node} node ArrowFunctionExpression Node @param {boolean} hasThis Whether `this` is referenced in` function` scope @param {boolean} hasSuper Whether `super` is referenced in` function` scope @returns {void}
[ "Report", "that", "ArrowFunctionExpression", "is", "being", "used" ]
5203ab2902f4ebd68b7089465a8785e122cebf87
https://github.com/mysticatea/eslint-plugin-es/blob/5203ab2902f4ebd68b7089465a8785e122cebf87/lib/rules/no-arrow-functions.js#L70-L85
train
words/dice-coefficient
index.js
diceCoefficient
function diceCoefficient(value, alternative) { var val = String(value).toLowerCase() var alt = String(alternative).toLowerCase() var left = val.length === 1 ? [val] : bigrams(val) var right = alt.length === 1 ? [alt] : bigrams(alt) var leftLength = left.length var rightLength = right.length var index = -1...
javascript
function diceCoefficient(value, alternative) { var val = String(value).toLowerCase() var alt = String(alternative).toLowerCase() var left = val.length === 1 ? [val] : bigrams(val) var right = alt.length === 1 ? [alt] : bigrams(alt) var leftLength = left.length var rightLength = right.length var index = -1...
[ "function", "diceCoefficient", "(", "value", ",", "alternative", ")", "{", "var", "val", "=", "String", "(", "value", ")", ".", "toLowerCase", "(", ")", "var", "alt", "=", "String", "(", "alternative", ")", ".", "toLowerCase", "(", ")", "var", "left", ...
Get the edit-distance according to Dice between two values.
[ "Get", "the", "edit", "-", "distance", "according", "to", "Dice", "between", "two", "values", "." ]
8eac06e9af5715e7ae2b07fdc9a5833bfb08485e
https://github.com/words/dice-coefficient/blob/8eac06e9af5715e7ae2b07fdc9a5833bfb08485e/index.js#L8-L39
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildVpc
function buildVpc(cidrBlock = '10.0.0.0/16', { name = 'VPC' } = {}) { return { [name]: { Type: 'AWS::EC2::VPC', Properties: { CidrBlock: cidrBlock, EnableDnsSupport: true, EnableDnsHostnames: true, InstanceTenancy: 'default', Tags: [ { Key:...
javascript
function buildVpc(cidrBlock = '10.0.0.0/16', { name = 'VPC' } = {}) { return { [name]: { Type: 'AWS::EC2::VPC', Properties: { CidrBlock: cidrBlock, EnableDnsSupport: true, EnableDnsHostnames: true, InstanceTenancy: 'default', Tags: [ { Key:...
[ "function", "buildVpc", "(", "cidrBlock", "=", "'10.0.0.0/16'", ",", "{", "name", "=", "'VPC'", "}", "=", "{", "}", ")", "{", "return", "{", "[", "name", "]", ":", "{", "Type", ":", "'AWS::EC2::VPC'", ",", "Properties", ":", "{", "CidrBlock", ":", "c...
Build a VPC @param {String} cidrBlock @param {Object} params @return {Object}
[ "Build", "a", "VPC" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L8-L28
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildSubnet
function buildSubnet(name, position, zone, cidrBlock) { const cfName = `${name}Subnet${position}`; return { [cfName]: { Type: 'AWS::EC2::Subnet', Properties: { AvailabilityZone: zone, CidrBlock: cidrBlock, Tags: [ { Key: 'Name', Value: { ...
javascript
function buildSubnet(name, position, zone, cidrBlock) { const cfName = `${name}Subnet${position}`; return { [cfName]: { Type: 'AWS::EC2::Subnet', Properties: { AvailabilityZone: zone, CidrBlock: cidrBlock, Tags: [ { Key: 'Name', Value: { ...
[ "function", "buildSubnet", "(", "name", ",", "position", ",", "zone", ",", "cidrBlock", ")", "{", "const", "cfName", "=", "`", "${", "name", "}", "${", "position", "}", "`", ";", "return", "{", "[", "cfName", "]", ":", "{", "Type", ":", "'AWS::EC2::S...
Create a subnet @param {String} name Name of subnet @param {Number} position Subnet position @param {String} zone Availability zone @param {String} cidrBlock Subnet CIDR block @return {Object}
[ "Create", "a", "subnet" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L85-L116
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildRouteTable
function buildRouteTable(name, position, zone) { const cfName = `${name}RouteTable${position}`; return { [cfName]: { Type: 'AWS::EC2::RouteTable', Properties: { VpcId: { Ref: 'VPC', }, Tags: [ { Key: 'Name', Value: { '...
javascript
function buildRouteTable(name, position, zone) { const cfName = `${name}RouteTable${position}`; return { [cfName]: { Type: 'AWS::EC2::RouteTable', Properties: { VpcId: { Ref: 'VPC', }, Tags: [ { Key: 'Name', Value: { '...
[ "function", "buildRouteTable", "(", "name", ",", "position", ",", "zone", ")", "{", "const", "cfName", "=", "`", "${", "name", "}", "${", "position", "}", "`", ";", "return", "{", "[", "cfName", "]", ":", "{", "Type", ":", "'AWS::EC2::RouteTable'", ","...
Build a RouteTable in a given AZ @param {String} name @param {Number} position @param {String} zone @return {Object}
[ "Build", "a", "RouteTable", "in", "a", "given", "AZ" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L126-L155
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildRouteTableAssociation
function buildRouteTableAssociation(name, position) { const cfName = `${name}RouteTableAssociation${position}`; return { [cfName]: { Type: 'AWS::EC2::SubnetRouteTableAssociation', Properties: { RouteTableId: { Ref: `${name}RouteTable${position}`, }, SubnetId: { ...
javascript
function buildRouteTableAssociation(name, position) { const cfName = `${name}RouteTableAssociation${position}`; return { [cfName]: { Type: 'AWS::EC2::SubnetRouteTableAssociation', Properties: { RouteTableId: { Ref: `${name}RouteTable${position}`, }, SubnetId: { ...
[ "function", "buildRouteTableAssociation", "(", "name", ",", "position", ")", "{", "const", "cfName", "=", "`", "${", "name", "}", "${", "position", "}", "`", ";", "return", "{", "[", "cfName", "]", ":", "{", "Type", ":", "'AWS::EC2::SubnetRouteTableAssociati...
Build a RouteTableAssociation @param {String} name @param {Number} position @return {Object}
[ "Build", "a", "RouteTableAssociation" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L164-L179
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildRoute
function buildRoute( name, position, { NatGatewayId = null, GatewayId = null, InstanceId = null } = {}, ) { const route = { Type: 'AWS::EC2::Route', Properties: { DestinationCidrBlock: '0.0.0.0/0', RouteTableId: { Ref: `${name}RouteTable${position}`, }, }, }; if (NatGa...
javascript
function buildRoute( name, position, { NatGatewayId = null, GatewayId = null, InstanceId = null } = {}, ) { const route = { Type: 'AWS::EC2::Route', Properties: { DestinationCidrBlock: '0.0.0.0/0', RouteTableId: { Ref: `${name}RouteTable${position}`, }, }, }; if (NatGa...
[ "function", "buildRoute", "(", "name", ",", "position", ",", "{", "NatGatewayId", "=", "null", ",", "GatewayId", "=", "null", ",", "InstanceId", "=", "null", "}", "=", "{", "}", ",", ")", "{", "const", "route", "=", "{", "Type", ":", "'AWS::EC2::Route'...
Build a Route for a NatGateway or InternetGateway @param {String} name @param {Number} position @param {Object} params @return {Object}
[ "Build", "a", "Route", "for", "a", "NatGateway", "or", "InternetGateway" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L189-L226
train
smoketurner/serverless-vpc-plugin
src/vpc.js
buildLambdaSecurityGroup
function buildLambdaSecurityGroup({ name = 'LambdaExecutionSecurityGroup' } = {}) { return { [name]: { Type: 'AWS::EC2::SecurityGroup', Properties: { GroupDescription: 'Lambda Execution Group', VpcId: { Ref: 'VPC', }, Tags: [ { Key: 'Name...
javascript
function buildLambdaSecurityGroup({ name = 'LambdaExecutionSecurityGroup' } = {}) { return { [name]: { Type: 'AWS::EC2::SecurityGroup', Properties: { GroupDescription: 'Lambda Execution Group', VpcId: { Ref: 'VPC', }, Tags: [ { Key: 'Name...
[ "function", "buildLambdaSecurityGroup", "(", "{", "name", "=", "'LambdaExecutionSecurityGroup'", "}", "=", "{", "}", ")", "{", "return", "{", "[", "name", "]", ":", "{", "Type", ":", "'AWS::EC2::SecurityGroup'", ",", "Properties", ":", "{", "GroupDescription", ...
Build a SecurityGroup to be used by Lambda's when they execute. @param {Object} params @return {Object}
[ "Build", "a", "SecurityGroup", "to", "be", "used", "by", "Lambda", "s", "when", "they", "execute", "." ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/vpc.js#L234-L262
train
smoketurner/serverless-vpc-plugin
src/bastion.js
getPublicIp
function getPublicIp() { return new Promise((resolve, reject) => { const options = { host: 'api.ipify.org', port: 80, path: '/', }; http .get(options, res => { res.setEncoding('utf8'); let body = ''; res.on('data', chunk => { body += chunk; ...
javascript
function getPublicIp() { return new Promise((resolve, reject) => { const options = { host: 'api.ipify.org', port: 80, path: '/', }; http .get(options, res => { res.setEncoding('utf8'); let body = ''; res.on('data', chunk => { body += chunk; ...
[ "function", "getPublicIp", "(", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "options", "=", "{", "host", ":", "'api.ipify.org'", ",", "port", ":", "80", ",", "path", ":", "'/'", ",", "}", ";", ...
Return the public IP @return {Promise}
[ "Return", "the", "public", "IP" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L10-L34
train
smoketurner/serverless-vpc-plugin
src/bastion.js
buildBastionIamRole
function buildBastionIamRole({ name = 'BastionIamRole' } = {}) { return { [name]: { Type: 'AWS::IAM::Role', Properties: { AssumeRolePolicyDocument: { Statement: [ { Effect: 'Allow', Principal: { Service: 'ec2.amazonaws.com', ...
javascript
function buildBastionIamRole({ name = 'BastionIamRole' } = {}) { return { [name]: { Type: 'AWS::IAM::Role', Properties: { AssumeRolePolicyDocument: { Statement: [ { Effect: 'Allow', Principal: { Service: 'ec2.amazonaws.com', ...
[ "function", "buildBastionIamRole", "(", "{", "name", "=", "'BastionIamRole'", "}", "=", "{", "}", ")", "{", "return", "{", "[", "name", "]", ":", "{", "Type", ":", "'AWS::IAM::Role'", ",", "Properties", ":", "{", "AssumeRolePolicyDocument", ":", "{", "Stat...
Build an IAM role for the bastion host @param {Object} params @return {Object}
[ "Build", "an", "IAM", "role", "for", "the", "bastion", "host" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L58-L93
train
smoketurner/serverless-vpc-plugin
src/bastion.js
buildBastionLaunchConfiguration
function buildBastionLaunchConfiguration( keyPairName, { name = 'BastionLaunchConfiguration' } = {}, ) { return { [name]: { Type: 'AWS::AutoScaling::LaunchConfiguration', Properties: { AssociatePublicIpAddress: true, BlockDeviceMappings: [ { DeviceName: '/dev/...
javascript
function buildBastionLaunchConfiguration( keyPairName, { name = 'BastionLaunchConfiguration' } = {}, ) { return { [name]: { Type: 'AWS::AutoScaling::LaunchConfiguration', Properties: { AssociatePublicIpAddress: true, BlockDeviceMappings: [ { DeviceName: '/dev/...
[ "function", "buildBastionLaunchConfiguration", "(", "keyPairName", ",", "{", "name", "=", "'BastionLaunchConfiguration'", "}", "=", "{", "}", ",", ")", "{", "return", "{", "[", "name", "]", ":", "{", "Type", ":", "'AWS::AutoScaling::LaunchConfiguration'", ",", "...
Build the auto-scaling group launch configuration for the bastion host @param {String} keyPairName Existing key pair name @param {Object} params @return {Object}
[ "Build", "the", "auto", "-", "scaling", "group", "launch", "configuration", "for", "the", "bastion", "host" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L123-L187
train
smoketurner/serverless-vpc-plugin
src/bastion.js
buildBastionAutoScalingGroup
function buildBastionAutoScalingGroup(numZones = 0, { name = 'BastionAutoScalingGroup' } = {}) { if (numZones < 1) { return {}; } const zones = []; for (let i = 1; i <= numZones; i += 1) { zones.push({ Ref: `${PUBLIC_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::AutoScaling::Au...
javascript
function buildBastionAutoScalingGroup(numZones = 0, { name = 'BastionAutoScalingGroup' } = {}) { if (numZones < 1) { return {}; } const zones = []; for (let i = 1; i <= numZones; i += 1) { zones.push({ Ref: `${PUBLIC_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::AutoScaling::Au...
[ "function", "buildBastionAutoScalingGroup", "(", "numZones", "=", "0", ",", "{", "name", "=", "'BastionAutoScalingGroup'", "}", "=", "{", "}", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "const", "zones", "=", "["...
Build the bastion host auto-scaling group @param {Number} numZones Number of availability zones @param {Object} params @return {Object}
[ "Build", "the", "bastion", "host", "auto", "-", "scaling", "group" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L196-L244
train
smoketurner/serverless-vpc-plugin
src/bastion.js
buildBastionSecurityGroup
function buildBastionSecurityGroup(sourceIp = '0.0.0.0/0', { name = 'BastionSecurityGroup' } = {}) { return { [name]: { Type: 'AWS::EC2::SecurityGroup', Properties: { GroupDescription: 'Bastion Host', VpcId: { Ref: 'VPC', }, SecurityGroupIngress: [ {...
javascript
function buildBastionSecurityGroup(sourceIp = '0.0.0.0/0', { name = 'BastionSecurityGroup' } = {}) { return { [name]: { Type: 'AWS::EC2::SecurityGroup', Properties: { GroupDescription: 'Bastion Host', VpcId: { Ref: 'VPC', }, SecurityGroupIngress: [ {...
[ "function", "buildBastionSecurityGroup", "(", "sourceIp", "=", "'0.0.0.0/0'", ",", "{", "name", "=", "'BastionSecurityGroup'", "}", "=", "{", "}", ")", "{", "return", "{", "[", "name", "]", ":", "{", "Type", ":", "'AWS::EC2::SecurityGroup'", ",", "Properties",...
Build a SecurityGroup to be used by the bastion host @param {String} sourceIp source IP address @param {Object} params @return {Object}
[ "Build", "a", "SecurityGroup", "to", "be", "used", "by", "the", "bastion", "host" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L253-L297
train
smoketurner/serverless-vpc-plugin
src/bastion.js
buildBastion
async function buildBastion(keyPairName, numZones = 0) { if (numZones < 1) { return {}; } let publicIp = '0.0.0.0/0'; try { publicIp = await getPublicIp(); publicIp = `${publicIp}/32`; } catch (err) { console.error('Unable to discover public IP address:', err); } return Object.assign( ...
javascript
async function buildBastion(keyPairName, numZones = 0) { if (numZones < 1) { return {}; } let publicIp = '0.0.0.0/0'; try { publicIp = await getPublicIp(); publicIp = `${publicIp}/32`; } catch (err) { console.error('Unable to discover public IP address:', err); } return Object.assign( ...
[ "async", "function", "buildBastion", "(", "keyPairName", ",", "numZones", "=", "0", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "let", "publicIp", "=", "'0.0.0.0/0'", ";", "try", "{", "publicIp", "=", "await", "...
Build the bastion host @param {String} keyPairName Existing key pair name @param {Number} numZones Number of availability zones @return {Promise}
[ "Build", "the", "bastion", "host" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/bastion.js#L306-L327
train
smoketurner/serverless-vpc-plugin
src/subnet_groups.js
buildRDSSubnetGroup
function buildRDSSubnetGroup(numZones = 0, { name = 'RDSSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::RDS::DBSubnetGroup', Pr...
javascript
function buildRDSSubnetGroup(numZones = 0, { name = 'RDSSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::RDS::DBSubnetGroup', Pr...
[ "function", "buildRDSSubnetGroup", "(", "numZones", "=", "0", ",", "{", "name", "=", "'RDSSubnetGroup'", "}", "=", "{", "}", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "const", "subnetIds", "=", "[", "]", ";"...
Build an RDSubnetGroup for a given number of zones @param {Number} numZones Number of availability zones @param {Objects} params @return {Object}
[ "Build", "an", "RDSubnetGroup", "for", "a", "given", "number", "of", "zones" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/subnet_groups.js#L10-L34
train
smoketurner/serverless-vpc-plugin
src/subnet_groups.js
buildElastiCacheSubnetGroup
function buildElastiCacheSubnetGroup(numZones = 0, { name = 'ElastiCacheSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::ElastiCache::...
javascript
function buildElastiCacheSubnetGroup(numZones = 0, { name = 'ElastiCacheSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::ElastiCache::...
[ "function", "buildElastiCacheSubnetGroup", "(", "numZones", "=", "0", ",", "{", "name", "=", "'ElastiCacheSubnetGroup'", "}", "=", "{", "}", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "const", "subnetIds", "=", "...
Build an ElastiCacheSubnetGroup for a given number of zones @param {Number} numZones Number of availability zones @param {Object} params @return {Object}
[ "Build", "an", "ElastiCacheSubnetGroup", "for", "a", "given", "number", "of", "zones" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/subnet_groups.js#L43-L67
train
smoketurner/serverless-vpc-plugin
src/subnet_groups.js
buildRedshiftSubnetGroup
function buildRedshiftSubnetGroup(numZones = 0, { name = 'RedshiftSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::Redshift::ClusterSu...
javascript
function buildRedshiftSubnetGroup(numZones = 0, { name = 'RedshiftSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::Redshift::ClusterSu...
[ "function", "buildRedshiftSubnetGroup", "(", "numZones", "=", "0", ",", "{", "name", "=", "'RedshiftSubnetGroup'", "}", "=", "{", "}", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "const", "subnetIds", "=", "[", ...
Build an RedshiftSubnetGroup for a given number of zones @param {Number} numZones Number of availability zones @param {Object} params @return {Object}
[ "Build", "an", "RedshiftSubnetGroup", "for", "a", "given", "number", "of", "zones" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/subnet_groups.js#L76-L97
train
smoketurner/serverless-vpc-plugin
src/subnet_groups.js
buildDAXSubnetGroup
function buildDAXSubnetGroup(numZones = 0, { name = 'DAXSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::DAX::SubnetGroup', Prop...
javascript
function buildDAXSubnetGroup(numZones = 0, { name = 'DAXSubnetGroup' } = {}) { if (numZones < 1) { return {}; } const subnetIds = []; for (let i = 1; i <= numZones; i += 1) { subnetIds.push({ Ref: `${DB_SUBNET}Subnet${i}` }); } return { [name]: { Type: 'AWS::DAX::SubnetGroup', Prop...
[ "function", "buildDAXSubnetGroup", "(", "numZones", "=", "0", ",", "{", "name", "=", "'DAXSubnetGroup'", "}", "=", "{", "}", ")", "{", "if", "(", "numZones", "<", "1", ")", "{", "return", "{", "}", ";", "}", "const", "subnetIds", "=", "[", "]", ";"...
Build an DAXSubnetGroup for a given number of zones @param {Number} numZones Number of availability zones @param {Object} params @return {Object}
[ "Build", "an", "DAXSubnetGroup", "for", "a", "given", "number", "of", "zones" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/subnet_groups.js#L106-L130
train
smoketurner/serverless-vpc-plugin
src/subnet_groups.js
buildSubnetGroups
function buildSubnetGroups(numZones = 0) { if (numZones < 2) { return {}; } return Object.assign( {}, buildRDSSubnetGroup(numZones), buildRedshiftSubnetGroup(numZones), buildElastiCacheSubnetGroup(numZones), buildDAXSubnetGroup(numZones), ); }
javascript
function buildSubnetGroups(numZones = 0) { if (numZones < 2) { return {}; } return Object.assign( {}, buildRDSSubnetGroup(numZones), buildRedshiftSubnetGroup(numZones), buildElastiCacheSubnetGroup(numZones), buildDAXSubnetGroup(numZones), ); }
[ "function", "buildSubnetGroups", "(", "numZones", "=", "0", ")", "{", "if", "(", "numZones", "<", "2", ")", "{", "return", "{", "}", ";", "}", "return", "Object", ".", "assign", "(", "{", "}", ",", "buildRDSSubnetGroup", "(", "numZones", ")", ",", "b...
Build the database subnet groups @param {Number} numZones Number of availability zones @return {Object}
[ "Build", "the", "database", "subnet", "groups" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/subnet_groups.js#L138-L149
train
smoketurner/serverless-vpc-plugin
src/nat_instance.js
buildNatSecurityGroup
function buildNatSecurityGroup(subnets = [], { name = 'NatSecurityGroup' } = {}) { const SecurityGroupIngress = []; if (Array.isArray(subnets) && subnets.length > 0) { subnets.forEach((subnet, index) => { const position = index + 1; const http = { Description: `Allow inbound HTTP traffic f...
javascript
function buildNatSecurityGroup(subnets = [], { name = 'NatSecurityGroup' } = {}) { const SecurityGroupIngress = []; if (Array.isArray(subnets) && subnets.length > 0) { subnets.forEach((subnet, index) => { const position = index + 1; const http = { Description: `Allow inbound HTTP traffic f...
[ "function", "buildNatSecurityGroup", "(", "subnets", "=", "[", "]", ",", "{", "name", "=", "'NatSecurityGroup'", "}", "=", "{", "}", ")", "{", "const", "SecurityGroupIngress", "=", "[", "]", ";", "if", "(", "Array", ".", "isArray", "(", "subnets", ")", ...
Build a SecurityGroup to be used by the NAT instance @param {Array} subnets Array of subnets @param {Object} params @return {Object}
[ "Build", "a", "SecurityGroup", "to", "be", "used", "by", "the", "NAT", "instance" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/nat_instance.js#L10-L79
train
smoketurner/serverless-vpc-plugin
src/nat_instance.js
buildNatInstance
function buildNatInstance(imageId, zones = [], { name = 'NatInstance' } = {}) { if (!imageId) { return {}; } if (!Array.isArray(zones) || zones.length < 1) { return {}; } return { [name]: { Type: 'AWS::EC2::Instance', DependsOn: 'InternetGatewayAttachment', Properties: { ...
javascript
function buildNatInstance(imageId, zones = [], { name = 'NatInstance' } = {}) { if (!imageId) { return {}; } if (!Array.isArray(zones) || zones.length < 1) { return {}; } return { [name]: { Type: 'AWS::EC2::Instance', DependsOn: 'InternetGatewayAttachment', Properties: { ...
[ "function", "buildNatInstance", "(", "imageId", ",", "zones", "=", "[", "]", ",", "{", "name", "=", "'NatInstance'", "}", "=", "{", "}", ")", "{", "if", "(", "!", "imageId", ")", "{", "return", "{", "}", ";", "}", "if", "(", "!", "Array", ".", ...
Build the NAT instance @param {Object} imageId AMI image ID @param {Array} zones Array of availability zones @param {Object} params @return {Object}
[ "Build", "the", "NAT", "instance" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/nat_instance.js#L89-L154
train
smoketurner/serverless-vpc-plugin
src/az.js
buildAvailabilityZones
function buildAvailabilityZones( subnets, zones = [], { numNatGateway = 0, createDbSubnet = true, createNatInstance = false } = {}, ) { if (!(subnets instanceof Map) || subnets.size < 1) { return {}; } if (!Array.isArray(zones) || zones.length < 1) { return {}; } const resources = {}; if (nu...
javascript
function buildAvailabilityZones( subnets, zones = [], { numNatGateway = 0, createDbSubnet = true, createNatInstance = false } = {}, ) { if (!(subnets instanceof Map) || subnets.size < 1) { return {}; } if (!Array.isArray(zones) || zones.length < 1) { return {}; } const resources = {}; if (nu...
[ "function", "buildAvailabilityZones", "(", "subnets", ",", "zones", "=", "[", "]", ",", "{", "numNatGateway", "=", "0", ",", "createDbSubnet", "=", "true", ",", "createNatInstance", "=", "false", "}", "=", "{", "}", ",", ")", "{", "if", "(", "!", "(", ...
Builds the Availability Zones for the region. 1.) Splits the VPC CIDR Block into /20 subnets, one per AZ. 2.) Split each AZ /20 CIDR Block into two /21 subnets 3.) Use the first /21 subnet for Applications 4.) Split the second /21 subnet into two /22 subnets: one Public subnet (for load balancers), and one for databas...
[ "Builds", "the", "Availability", "Zones", "for", "the", "region", "." ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/az.js#L21-L87
train
smoketurner/serverless-vpc-plugin
src/natgw.js
buildNatGateway
function buildNatGateway(position, zone) { const cfName = `NatGateway${position}`; return { [cfName]: { Type: 'AWS::EC2::NatGateway', Properties: { AllocationId: { 'Fn::GetAtt': [`EIP${position}`, 'AllocationId'], }, SubnetId: { Ref: `${PUBLIC_SUBNET}Subne...
javascript
function buildNatGateway(position, zone) { const cfName = `NatGateway${position}`; return { [cfName]: { Type: 'AWS::EC2::NatGateway', Properties: { AllocationId: { 'Fn::GetAtt': [`EIP${position}`, 'AllocationId'], }, SubnetId: { Ref: `${PUBLIC_SUBNET}Subne...
[ "function", "buildNatGateway", "(", "position", ",", "zone", ")", "{", "const", "cfName", "=", "`", "${", "position", "}", "`", ";", "return", "{", "[", "cfName", "]", ":", "{", "Type", ":", "'AWS::EC2::NatGateway'", ",", "Properties", ":", "{", "Allocat...
Build a NatGateway in a given AZ @param {Number} position @param {String} zone @return {Object}
[ "Build", "a", "NatGateway", "in", "a", "given", "AZ" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/natgw.js#L28-L59
train
smoketurner/serverless-vpc-plugin
src/flow_logs.js
buildLogBucket
function buildLogBucket() { return { LogBucket: { Type: 'AWS::S3::Bucket', DeletionPolicy: 'Retain', Properties: { AccessControl: 'LogDeliveryWrite', BucketEncryption: { ServerSideEncryptionConfiguration: [ { ServerSideEncryptionByDefault: { ...
javascript
function buildLogBucket() { return { LogBucket: { Type: 'AWS::S3::Bucket', DeletionPolicy: 'Retain', Properties: { AccessControl: 'LogDeliveryWrite', BucketEncryption: { ServerSideEncryptionConfiguration: [ { ServerSideEncryptionByDefault: { ...
[ "function", "buildLogBucket", "(", ")", "{", "return", "{", "LogBucket", ":", "{", "Type", ":", "'AWS::S3::Bucket'", ",", "DeletionPolicy", ":", "'Retain'", ",", "Properties", ":", "{", "AccessControl", ":", "'LogDeliveryWrite'", ",", "BucketEncryption", ":", "{...
Build an S3 bucket for logging @return {Object}
[ "Build", "an", "S3", "bucket", "for", "logging" ]
21a862ac01cc14fc5699fc9d7978bd736622cc1d
https://github.com/smoketurner/serverless-vpc-plugin/blob/21a862ac01cc14fc5699fc9d7978bd736622cc1d/src/flow_logs.js#L6-L39
train