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
openshift/origin-web-common
dist/origin-web-common-services.js
function(forceRefresh) { if (cachedProjectData && !forceRefresh) { Logger.debug('ProjectsService: returning cached project data'); return $q.when(cachedProjectData); } Logger.debug('ProjectsService: listing projects, force refresh', forceRefresh); ...
javascript
function(forceRefresh) { if (cachedProjectData && !forceRefresh) { Logger.debug('ProjectsService: returning cached project data'); return $q.when(cachedProjectData); } Logger.debug('ProjectsService: listing projects, force refresh', forceRefresh); ...
[ "function", "(", "forceRefresh", ")", "{", "if", "(", "cachedProjectData", "&&", "!", "forceRefresh", ")", "{", "Logger", ".", "debug", "(", "'ProjectsService: returning cached project data'", ")", ";", "return", "$q", ".", "when", "(", "cachedProjectData", ")", ...
List the projects the user has access to. This method returns cached data if the projects had previously been fetched to avoid requesting them again and again, which is a problem for admins who might have hundreds or more.
[ "List", "the", "projects", "the", "user", "has", "access", "to", ".", "This", "method", "returns", "cached", "data", "if", "the", "projects", "had", "previously", "been", "fetched", "to", "avoid", "requesting", "them", "again", "and", "again", "which", "is",...
a56152ba5a42b95bd91c0e65531f6104b9a4dc8f
https://github.com/openshift/origin-web-common/blob/a56152ba5a42b95bd91c0e65531f6104b9a4dc8f/dist/origin-web-common-services.js#L3808-L3824
train
openshift/origin-web-common
dist/origin-web-common-services.js
function(params, stateData) { // Handle an error response from the OAuth server if (params.error) { authLogger.log("RedirectLoginService.finish(), error", params.error, params.error_description, params.error_uri); return $q.reject({ error: params.error, ...
javascript
function(params, stateData) { // Handle an error response from the OAuth server if (params.error) { authLogger.log("RedirectLoginService.finish(), error", params.error, params.error_description, params.error_uri); return $q.reject({ error: params.error, ...
[ "function", "(", "params", ",", "stateData", ")", "{", "// Handle an error response from the OAuth server", "if", "(", "params", ".", "error", ")", "{", "authLogger", ".", "log", "(", "\"RedirectLoginService.finish(), error\"", ",", "params", ".", "error", ",", "par...
handleParams handles error or access_token responses
[ "handleParams", "handles", "error", "or", "access_token", "responses" ]
a56152ba5a42b95bd91c0e65531f6104b9a4dc8f
https://github.com/openshift/origin-web-common/blob/a56152ba5a42b95bd91c0e65531f6104b9a4dc8f/dist/origin-web-common-services.js#L4183-L4209
train
openshift/origin-web-common
dist/origin-web-common.js
function (notification) { if (!notification.id) { return false; } return _.some(notifications, function(next) { return !next.hidden && notification.id === next.id; }); }
javascript
function (notification) { if (!notification.id) { return false; } return _.some(notifications, function(next) { return !next.hidden && notification.id === next.id; }); }
[ "function", "(", "notification", ")", "{", "if", "(", "!", "notification", ".", "id", ")", "{", "return", "false", ";", "}", "return", "_", ".", "some", "(", "notifications", ",", "function", "(", "next", ")", "{", "return", "!", "next", ".", "hidden...
Is there a visible toast notification with the same ID right now?
[ "Is", "there", "a", "visible", "toast", "notification", "with", "the", "same", "ID", "right", "now?" ]
a56152ba5a42b95bd91c0e65531f6104b9a4dc8f
https://github.com/openshift/origin-web-common/blob/a56152ba5a42b95bd91c0e65531f6104b9a4dc8f/dist/origin-web-common.js#L6024-L6032
train
toomuchdesign/offside
dist/offside.js
_factoryDomInit
function _factoryDomInit() { // Add class to sliding elements slidingElements.forEach( function( item ) { addClass( item, slidingElementsClass ); }); // DOM Fallbacks when CSS transform 3d not available if ( !has3d ) {...
javascript
function _factoryDomInit() { // Add class to sliding elements slidingElements.forEach( function( item ) { addClass( item, slidingElementsClass ); }); // DOM Fallbacks when CSS transform 3d not available if ( !has3d ) {...
[ "function", "_factoryDomInit", "(", ")", "{", "// Add class to sliding elements", "slidingElements", ".", "forEach", "(", "function", "(", "item", ")", "{", "addClass", "(", "item", ",", "slidingElementsClass", ")", ";", "}", ")", ";", "// DOM Fallbacks when CSS tra...
Offside singleton-factory Dom initialization It's called just once on Offside singleton-factory init.
[ "Offside", "singleton", "-", "factory", "Dom", "initialization", "It", "s", "called", "just", "once", "on", "Offside", "singleton", "-", "factory", "init", "." ]
17f0936eaeb4a4abdfafe991fa4471d456b71e5d
https://github.com/toomuchdesign/offside/blob/17f0936eaeb4a4abdfafe991fa4471d456b71e5d/dist/offside.js#L148-L163
train
toomuchdesign/offside
dist/offside.js
function( el, options ) { // Get length of instantiated Offsides array var offsideId = instantiatedOffsides.length || 0, // Instantiate new Offside instance offsideInstance = createOffsideInstance( el, options, offsideId ); ...
javascript
function( el, options ) { // Get length of instantiated Offsides array var offsideId = instantiatedOffsides.length || 0, // Instantiate new Offside instance offsideInstance = createOffsideInstance( el, options, offsideId ); ...
[ "function", "(", "el", ",", "options", ")", "{", "// Get length of instantiated Offsides array", "var", "offsideId", "=", "instantiatedOffsides", ".", "length", "||", "0", ",", "// Instantiate new Offside instance", "offsideInstance", "=", "createOffsideInstance", "(", "e...
This is the method responsible for creating a new Offside instance and register it into "instantiatedOffsides" array
[ "This", "is", "the", "method", "responsible", "for", "creating", "a", "new", "Offside", "instance", "and", "register", "it", "into", "instantiatedOffsides", "array" ]
17f0936eaeb4a4abdfafe991fa4471d456b71e5d
https://github.com/toomuchdesign/offside/blob/17f0936eaeb4a4abdfafe991fa4471d456b71e5d/dist/offside.js#L437-L456
train
toomuchdesign/offside
dist/offside.js
function ( el, options ) { /* * When Offside is called for the first time, * inject a singleton-factory object * as a static method in "offside.factory". * * Offside factory serves the following purposes: * ...
javascript
function ( el, options ) { /* * When Offside is called for the first time, * inject a singleton-factory object * as a static method in "offside.factory". * * Offside factory serves the following purposes: * ...
[ "function", "(", "el", ",", "options", ")", "{", "/*\n * When Offside is called for the first time,\n * inject a singleton-factory object\n * as a static method in \"offside.factory\".\n *\n * Offside factory serves the followi...
Get the Singleton instance if one exists or create one if it doesn't
[ "Get", "the", "Singleton", "instance", "if", "one", "exists", "or", "create", "one", "if", "it", "doesn", "t" ]
17f0936eaeb4a4abdfafe991fa4471d456b71e5d
https://github.com/toomuchdesign/offside/blob/17f0936eaeb4a4abdfafe991fa4471d456b71e5d/dist/offside.js#L466-L482
train
tensorflow/tfjs-tsne
examples/synthetic_data/index.js
start
async function start() { const numDimensions = 100; const numPoints = 10000; const data = generateData(numDimensions, numPoints); const coordinates = await computeEmbedding(data, numPoints); showEmbedding(coordinates); }
javascript
async function start() { const numDimensions = 100; const numPoints = 10000; const data = generateData(numDimensions, numPoints); const coordinates = await computeEmbedding(data, numPoints); showEmbedding(coordinates); }
[ "async", "function", "start", "(", ")", "{", "const", "numDimensions", "=", "100", ";", "const", "numPoints", "=", "10000", ";", "const", "data", "=", "generateData", "(", "numDimensions", ",", "numPoints", ")", ";", "const", "coordinates", "=", "await", "...
Run the example
[ "Run", "the", "example" ]
7757693607dbc363660f81e609cbc00f392a1c35
https://github.com/tensorflow/tfjs-tsne/blob/7757693607dbc363660f81e609cbc00f392a1c35/examples/synthetic_data/index.js#L26-L33
train
tensorflow/tfjs-tsne
examples/synthetic_data/index.js
showEmbedding
function showEmbedding(data) { const margin = {top: 20, right: 15, bottom: 60, left: 60}; const width = 800 - margin.left - margin.right; const height = 800 - margin.top - margin.bottom; const x = d3.scaleLinear().domain([0, 1]).range([0, width]); const y = d3.scaleLinear().domain([0, 1]).range([height, 0]);...
javascript
function showEmbedding(data) { const margin = {top: 20, right: 15, bottom: 60, left: 60}; const width = 800 - margin.left - margin.right; const height = 800 - margin.top - margin.bottom; const x = d3.scaleLinear().domain([0, 1]).range([0, width]); const y = d3.scaleLinear().domain([0, 1]).range([height, 0]);...
[ "function", "showEmbedding", "(", "data", ")", "{", "const", "margin", "=", "{", "top", ":", "20", ",", "right", ":", "15", ",", "bottom", ":", "60", ",", "left", ":", "60", "}", ";", "const", "width", "=", "800", "-", "margin", ".", "left", "-",...
This will add a new plot visualizing the embedding space on a scatterplot.
[ "This", "will", "add", "a", "new", "plot", "visualizing", "the", "embedding", "space", "on", "a", "scatterplot", "." ]
7757693607dbc363660f81e609cbc00f392a1c35
https://github.com/tensorflow/tfjs-tsne/blob/7757693607dbc363660f81e609cbc00f392a1c35/examples/synthetic_data/index.js#L75-L121
train
web-perf/react-worker-dom
src/worker/ReactWWComponent.js
extractEventHandlers
function extractEventHandlers(props) { let result = { eventHandlers: {}, options: {} }; for (let key in props) { if (ReactBrowserEventEmitter.registrationNameModules.hasOwnProperty(key)) { result.eventHandlers[key] = props[key]; } else { result.options...
javascript
function extractEventHandlers(props) { let result = { eventHandlers: {}, options: {} }; for (let key in props) { if (ReactBrowserEventEmitter.registrationNameModules.hasOwnProperty(key)) { result.eventHandlers[key] = props[key]; } else { result.options...
[ "function", "extractEventHandlers", "(", "props", ")", "{", "let", "result", "=", "{", "eventHandlers", ":", "{", "}", ",", "options", ":", "{", "}", "}", ";", "for", "(", "let", "key", "in", "props", ")", "{", "if", "(", "ReactBrowserEventEmitter", "....
Function to separate event Handlers and regular props @param {Object} props Props passed to a React Component @return {eventHandlers: {}, options: {}} An object containing eventHandlers and options
[ "Function", "to", "separate", "event", "Handlers", "and", "regular", "props" ]
8fc5c011bc5c5ff43c6f5b184b60f6edd5872a6b
https://github.com/web-perf/react-worker-dom/blob/8fc5c011bc5c5ff43c6f5b184b60f6edd5872a6b/src/worker/ReactWWComponent.js#L14-L27
train
web-perf/react-worker-dom
src/worker/index.js
render
function render(element) { // Is the given element valid? invariant( ReactElement.isValidElement(element), 'render(): You must pass a valid ReactElement.' ); const id = ReactInstanceHandles.createReactRootID(); // Creating a root id & creating the screen const component = instantiat...
javascript
function render(element) { // Is the given element valid? invariant( ReactElement.isValidElement(element), 'render(): You must pass a valid ReactElement.' ); const id = ReactInstanceHandles.createReactRootID(); // Creating a root id & creating the screen const component = instantiat...
[ "function", "render", "(", "element", ")", "{", "// Is the given element valid?", "invariant", "(", "ReactElement", ".", "isValidElement", "(", "element", ")", ",", "'render(): You must pass a valid ReactElement.'", ")", ";", "const", "id", "=", "ReactInstanceHandles", ...
Renders the given react element using a web worker. @param {ReactElement} element - Node to update. @return {ReactComponent} - The rendered component instance.
[ "Renders", "the", "given", "react", "element", "using", "a", "web", "worker", "." ]
8fc5c011bc5c5ff43c6f5b184b60f6edd5872a6b
https://github.com/web-perf/react-worker-dom/blob/8fc5c011bc5c5ff43c6f5b184b60f6edd5872a6b/src/worker/index.js#L22-L46
train
brendanashworth/generate-password
src/generate.js
function(max) { // gives a number between 0 (inclusive) and max (exclusive) var rand = crypto.randomBytes(1)[0]; while (rand >= 256 - (256 % max)) { rand = crypto.randomBytes(1)[0]; } return rand % max; }
javascript
function(max) { // gives a number between 0 (inclusive) and max (exclusive) var rand = crypto.randomBytes(1)[0]; while (rand >= 256 - (256 % max)) { rand = crypto.randomBytes(1)[0]; } return rand % max; }
[ "function", "(", "max", ")", "{", "// gives a number between 0 (inclusive) and max (exclusive)", "var", "rand", "=", "crypto", ".", "randomBytes", "(", "1", ")", "[", "0", "]", ";", "while", "(", "rand", ">=", "256", "-", "(", "256", "%", "max", ")", ")", ...
Generates a random number
[ "Generates", "a", "random", "number" ]
75032c47a1a13283decab5e963c582084ab6e72a
https://github.com/brendanashworth/generate-password/blob/75032c47a1a13283decab5e963c582084ab6e72a/src/generate.js#L6-L13
train
speckjs/speckjs
src/parsing/parse-comments.js
onComment
function onComment(isBlock, text, _s, _e, sLoc, eLoc) { var tRegex = /test\s*>\s*(.*)/i; var aRegex = /#\s*(.*)/i; var isTest = R.test(tRegex); var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim()); var isAssertion = R.test(aRegex); var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim())...
javascript
function onComment(isBlock, text, _s, _e, sLoc, eLoc) { var tRegex = /test\s*>\s*(.*)/i; var aRegex = /#\s*(.*)/i; var isTest = R.test(tRegex); var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim()); var isAssertion = R.test(aRegex); var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim())...
[ "function", "onComment", "(", "isBlock", ",", "text", ",", "_s", ",", "_e", ",", "sLoc", ",", "eLoc", ")", "{", "var", "tRegex", "=", "/", "test\\s*>\\s*(.*)", "/", "i", ";", "var", "aRegex", "=", "/", "#\\s*(.*)", "/", "i", ";", "var", "isTest", "...
Sanitizing iterator to run on each comment found during parsing
[ "Sanitizing", "iterator", "to", "run", "on", "each", "comment", "found", "during", "parsing" ]
860d90bc4479287f316c8dfa8695572c61cda879
https://github.com/speckjs/speckjs/blob/860d90bc4479287f316c8dfa8695572c61cda879/src/parsing/parse-comments.js#L32-L88
train
nol13/fuzzball.js
lib/xregexp/unicode-base.js
charCode
function charCode(chr) { var esc = /^\\[xu](.+)/.exec(chr); return esc ? dec(esc[1]) : chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0); }
javascript
function charCode(chr) { var esc = /^\\[xu](.+)/.exec(chr); return esc ? dec(esc[1]) : chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0); }
[ "function", "charCode", "(", "chr", ")", "{", "var", "esc", "=", "/", "^\\\\[xu](.+)", "/", ".", "exec", "(", "chr", ")", ";", "return", "esc", "?", "dec", "(", "esc", "[", "1", "]", ")", ":", "chr", ".", "charCodeAt", "(", "chr", ".", "charAt", ...
Gets the decimal code of a literal code unit, \xHH, \uHHHH, or a backslash-escaped literal
[ "Gets", "the", "decimal", "code", "of", "a", "literal", "code", "unit", "\\", "xHH", "\\", "uHHHH", "or", "a", "backslash", "-", "escaped", "literal" ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/unicode-base.js#L42-L47
train
nol13/fuzzball.js
lib/xregexp/unicode-base.js
invertBmp
function invertBmp(range) { var output = ''; var lastEnd = -1; XRegExp.forEach( range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function(m) { var start = charCode(m[1]); if (start > (lastEnd + 1)) { ...
javascript
function invertBmp(range) { var output = ''; var lastEnd = -1; XRegExp.forEach( range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function(m) { var start = charCode(m[1]); if (start > (lastEnd + 1)) { ...
[ "function", "invertBmp", "(", "range", ")", "{", "var", "output", "=", "''", ";", "var", "lastEnd", "=", "-", "1", ";", "XRegExp", ".", "forEach", "(", "range", ",", "/", "(\\\\x..|\\\\u....|\\\\?[\\s\\S])(?:-(\\\\x..|\\\\u....|\\\\?[\\s\\S]))?", "/", ",", "func...
Inverts a list of ordered BMP characters and ranges
[ "Inverts", "a", "list", "of", "ordered", "BMP", "characters", "and", "ranges" ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/unicode-base.js#L50-L77
train
nol13/fuzzball.js
lib/xregexp/unicode-base.js
cacheInvertedBmp
function cacheInvertedBmp(slug) { var prop = 'b!'; return ( unicode[slug][prop] || (unicode[slug][prop] = invertBmp(unicode[slug].bmp)) ); }
javascript
function cacheInvertedBmp(slug) { var prop = 'b!'; return ( unicode[slug][prop] || (unicode[slug][prop] = invertBmp(unicode[slug].bmp)) ); }
[ "function", "cacheInvertedBmp", "(", "slug", ")", "{", "var", "prop", "=", "'b!'", ";", "return", "(", "unicode", "[", "slug", "]", "[", "prop", "]", "||", "(", "unicode", "[", "slug", "]", "[", "prop", "]", "=", "invertBmp", "(", "unicode", "[", "...
Generates an inverted BMP range on first use
[ "Generates", "an", "inverted", "BMP", "range", "on", "first", "use" ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/unicode-base.js#L80-L86
train
nol13/fuzzball.js
lib/xregexp/xregexp.js
augment
function augment(regex, captureNames, xSource, xFlags, isInternalOnly) { var p; regex[REGEX_DATA] = { captureNames: captureNames }; if (isInternalOnly) { return regex; } // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value if (regex.__prot...
javascript
function augment(regex, captureNames, xSource, xFlags, isInternalOnly) { var p; regex[REGEX_DATA] = { captureNames: captureNames }; if (isInternalOnly) { return regex; } // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value if (regex.__prot...
[ "function", "augment", "(", "regex", ",", "captureNames", ",", "xSource", ",", "xFlags", ",", "isInternalOnly", ")", "{", "var", "p", ";", "regex", "[", "REGEX_DATA", "]", "=", "{", "captureNames", ":", "captureNames", "}", ";", "if", "(", "isInternalOnly"...
Attaches extended data and `XRegExp.prototype` properties to a regex object. @private @param {RegExp} regex Regex to augment. @param {Array} captureNames Array with capture names, or `null`. @param {String} xSource XRegExp pattern used to generate `regex`, or `null` if N/A. @param {String} xFlags XRegExp flags used to...
[ "Attaches", "extended", "data", "and", "XRegExp", ".", "prototype", "properties", "to", "a", "regex", "object", "." ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/xregexp.js#L107-L135
train
nol13/fuzzball.js
lib/xregexp/xregexp.js
getNativeFlags
function getNativeFlags(regex) { return hasFlagsProp ? regex.flags : // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation // with an empty string) allows this to continue working predictably when // `XRegExp.proptotype.toString` is overridden ...
javascript
function getNativeFlags(regex) { return hasFlagsProp ? regex.flags : // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation // with an empty string) allows this to continue working predictably when // `XRegExp.proptotype.toString` is overridden ...
[ "function", "getNativeFlags", "(", "regex", ")", "{", "return", "hasFlagsProp", "?", "regex", ".", "flags", ":", "// Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation", "// with an empty string) allows this to continue working predictably when", "...
Returns native `RegExp` flags used by a regex object. @private @param {RegExp} regex Regex to check. @returns {String} Native flags in use.
[ "Returns", "native", "RegExp", "flags", "used", "by", "a", "regex", "object", "." ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/xregexp.js#L238-L245
train
nol13/fuzzball.js
lib/xregexp/xregexp.js
runTokens
function runTokens(pattern, flags, pos, scope, context) { var i = tokens.length, leadChar = pattern.charAt(pos), result = null, match, t; // Run in reverse insertion order while (i--) { t = tokens[i]; if ( (t.leadChar && t.leadChar !== leadChar) |...
javascript
function runTokens(pattern, flags, pos, scope, context) { var i = tokens.length, leadChar = pattern.charAt(pos), result = null, match, t; // Run in reverse insertion order while (i--) { t = tokens[i]; if ( (t.leadChar && t.leadChar !== leadChar) |...
[ "function", "runTokens", "(", "pattern", ",", "flags", ",", "pos", ",", "scope", ",", "context", ")", "{", "var", "i", "=", "tokens", ".", "length", ",", "leadChar", "=", "pattern", ".", "charAt", "(", "pos", ")", ",", "result", "=", "null", ",", "...
Runs built-in and custom regex syntax tokens in reverse insertion order at the specified position, until a match is found. @private @param {String} pattern Original pattern from which an XRegExp object is being built. @param {String} flags Flags being used to construct the regex. @param {Number} pos Position to search...
[ "Runs", "built", "-", "in", "and", "custom", "regex", "syntax", "tokens", "in", "reverse", "insertion", "order", "at", "the", "specified", "position", "until", "a", "match", "is", "found", "." ]
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/xregexp.js#L422-L453
train
nol13/fuzzball.js
lib/xregexp/xregexp.js
setNatives
function setNatives(on) { RegExp.prototype.exec = (on ? fixed : nativ).exec; RegExp.prototype.test = (on ? fixed : nativ).test; String.prototype.match = (on ? fixed : nativ).match; String.prototype.replace = (on ? fixed : nativ).replace; String.prototype.split = (on ? fixed : nativ).split; feat...
javascript
function setNatives(on) { RegExp.prototype.exec = (on ? fixed : nativ).exec; RegExp.prototype.test = (on ? fixed : nativ).test; String.prototype.match = (on ? fixed : nativ).match; String.prototype.replace = (on ? fixed : nativ).replace; String.prototype.split = (on ? fixed : nativ).split; feat...
[ "function", "setNatives", "(", "on", ")", "{", "RegExp", ".", "prototype", ".", "exec", "=", "(", "on", "?", "fixed", ":", "nativ", ")", ".", "exec", ";", "RegExp", ".", "prototype", ".", "test", "=", "(", "on", "?", "fixed", ":", "nativ", ")", "...
Enables or disables implicit astral mode opt-in. When enabled, flag A is automatically added to all new regexes created by XRegExp. This causes an error to be thrown when creating regexes if the Unicode Base addon is not available, since flag A is registered by that addon. @private @param {Boolean} on `true` to enable...
[ "Enables", "or", "disables", "implicit", "astral", "mode", "opt", "-", "in", ".", "When", "enabled", "flag", "A", "is", "automatically", "added", "to", "all", "new", "regexes", "created", "by", "XRegExp", ".", "This", "causes", "an", "error", "to", "be", ...
740315fd9c531325cccd0b729f379ed7e448766a
https://github.com/nol13/fuzzball.js/blob/740315fd9c531325cccd0b729f379ed7e448766a/lib/xregexp/xregexp.js#L473-L481
train
Samsung/jalangi2
src/js/instrument/esnstrument.js
hoistFunctionDeclaration
function hoistFunctionDeclaration(ast, hoisteredFunctions) { var key, child, startIndex = 0; if (ast.body) { var newBody = []; if (ast.body.length > 0) { // do not hoister function declaration before J$.Fe or J$.Se if (ast.body[0].type === 'ExpressionStatement') {...
javascript
function hoistFunctionDeclaration(ast, hoisteredFunctions) { var key, child, startIndex = 0; if (ast.body) { var newBody = []; if (ast.body.length > 0) { // do not hoister function declaration before J$.Fe or J$.Se if (ast.body[0].type === 'ExpressionStatement') {...
[ "function", "hoistFunctionDeclaration", "(", "ast", ",", "hoisteredFunctions", ")", "{", "var", "key", ",", "child", ",", "startIndex", "=", "0", ";", "if", "(", "ast", ".", "body", ")", "{", "var", "newBody", "=", "[", "]", ";", "if", "(", "ast", "....
START of Liang Gong's AST post-processor
[ "START", "of", "Liang", "Gong", "s", "AST", "post", "-", "processor" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/esnstrument.js#L1800-L1855
train
Samsung/jalangi2
src/js/instrument/esnstrument.js
transformString
function transformString(code, visitorsPost, visitorsPre) { // StatCollector.resumeTimer("parse"); // console.time("parse") // var newAst = esprima.parse(code, {loc:true, range:true}); var newAst = acorn.parse(code, {locations: true, ecmaVersion: 6 }); // console.timeEnd("parse") //...
javascript
function transformString(code, visitorsPost, visitorsPre) { // StatCollector.resumeTimer("parse"); // console.time("parse") // var newAst = esprima.parse(code, {loc:true, range:true}); var newAst = acorn.parse(code, {locations: true, ecmaVersion: 6 }); // console.timeEnd("parse") //...
[ "function", "transformString", "(", "code", ",", "visitorsPost", ",", "visitorsPre", ")", "{", "// StatCollector.resumeTimer(\"parse\");", "// console.time(\"parse\")", "// var newAst = esprima.parse(code, {loc:true, range:true});", "var", "newAst", "=", "acorn"...
END of Liang Gong's AST post-processor
[ "END", "of", "Liang", "Gong", "s", "AST", "post", "-", "processor" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/esnstrument.js#L1859-L1877
train
Samsung/jalangi2
src/js/instrument/esnstrument.js
instrumentCode
function instrumentCode(options) { var aret, skip = false; var isEval = options.isEval, code = options.code, thisIid = options.thisIid, inlineSource = options.inlineSource, url = options.url; iidSourceInfo = {}; initializeIIDCounters(isEval); instCodeFileName = optio...
javascript
function instrumentCode(options) { var aret, skip = false; var isEval = options.isEval, code = options.code, thisIid = options.thisIid, inlineSource = options.inlineSource, url = options.url; iidSourceInfo = {}; initializeIIDCounters(isEval); instCodeFileName = optio...
[ "function", "instrumentCode", "(", "options", ")", "{", "var", "aret", ",", "skip", "=", "false", ";", "var", "isEval", "=", "options", ".", "isEval", ",", "code", "=", "options", ".", "code", ",", "thisIid", "=", "options", ".", "thisIid", ",", "inlin...
Instruments the provided code. @param {{isEval: boolean, code: string, thisIid: int, origCodeFileName: string, instCodeFileName: string, inlineSourceMap: boolean, inlineSource: boolean, url: string, isDirect: boolean }} options @return {{code:string, instAST: object, sourceMapObject: object, sourceMapString: string}}
[ "Instruments", "the", "provided", "code", "." ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/esnstrument.js#L1916-L1989
train
Samsung/jalangi2
src/js/runtime/analysis.js
R
function R(iid, name, val, flags) { var aret; var bFlags = decodeBitPattern(flags, 2); // [isGlobal, isScriptLocal] if (sandbox.analysis && sandbox.analysis.read) { aret = sandbox.analysis.read(iid, name, val, bFlags[0], bFlags[1]); if (aret) { val = aret...
javascript
function R(iid, name, val, flags) { var aret; var bFlags = decodeBitPattern(flags, 2); // [isGlobal, isScriptLocal] if (sandbox.analysis && sandbox.analysis.read) { aret = sandbox.analysis.read(iid, name, val, bFlags[0], bFlags[1]); if (aret) { val = aret...
[ "function", "R", "(", "iid", ",", "name", ",", "val", ",", "flags", ")", "{", "var", "aret", ";", "var", "bFlags", "=", "decodeBitPattern", "(", "flags", ",", "2", ")", ";", "// [isGlobal, isScriptLocal]", "if", "(", "sandbox", ".", "analysis", "&&", "...
variable write isGlobal means that the variable is global and not declared as var isScriptLocal means that the variable is global and is declared as var
[ "variable", "write", "isGlobal", "means", "that", "the", "variable", "is", "global", "and", "not", "declared", "as", "var", "isScriptLocal", "means", "that", "the", "variable", "is", "global", "and", "is", "declared", "as", "var" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/runtime/analysis.js#L372-L383
train
Samsung/jalangi2
src/js/runtime/analysis.js
A
function A(iid, base, offset, op, flags) { var bFlags = decodeBitPattern(flags, 1); // [isComputed] // avoid iid collision: make sure that iid+2 has the same source map as iid (@todo) var oprnd1 = G(iid+2, base, offset, createBitPattern(bFlags[0], true, false)); return function (oprnd2) ...
javascript
function A(iid, base, offset, op, flags) { var bFlags = decodeBitPattern(flags, 1); // [isComputed] // avoid iid collision: make sure that iid+2 has the same source map as iid (@todo) var oprnd1 = G(iid+2, base, offset, createBitPattern(bFlags[0], true, false)); return function (oprnd2) ...
[ "function", "A", "(", "iid", ",", "base", ",", "offset", ",", "op", ",", "flags", ")", "{", "var", "bFlags", "=", "decodeBitPattern", "(", "flags", ",", "1", ")", ";", "// [isComputed]", "// avoid iid collision: make sure that iid+2 has the same source map as iid (@...
Modify and assign +=, -= ...
[ "Modify", "and", "assign", "+", "=", "-", "=", "..." ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/runtime/analysis.js#L522-L531
train
Samsung/jalangi2
src/js/runtime/analysis.js
C2
function C2(iid, right) { var aret, result; // avoid iid collision; iid may not have a map in the sourcemap result = B(iid+1, "===", switchLeft, right, createBitPattern(false, false, true)); if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.con...
javascript
function C2(iid, right) { var aret, result; // avoid iid collision; iid may not have a map in the sourcemap result = B(iid+1, "===", switchLeft, right, createBitPattern(false, false, true)); if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.con...
[ "function", "C2", "(", "iid", ",", "right", ")", "{", "var", "aret", ",", "result", ";", "// avoid iid collision; iid may not have a map in the sourcemap", "result", "=", "B", "(", "iid", "+", "1", ",", "\"===\"", ",", "switchLeft", ",", "right", ",", "createB...
case label inside switch
[ "case", "label", "inside", "switch" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/runtime/analysis.js#L702-L719
train
Samsung/jalangi2
src/js/runtime/analysis.js
C
function C(iid, left) { var aret; if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.conditional(iid, left); if (aret) { left = aret.result; } } lastVal = left; return (lastComputedValue = left); ...
javascript
function C(iid, left) { var aret; if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.conditional(iid, left); if (aret) { left = aret.result; } } lastVal = left; return (lastComputedValue = left); ...
[ "function", "C", "(", "iid", ",", "left", ")", "{", "var", "aret", ";", "if", "(", "sandbox", ".", "analysis", "&&", "sandbox", ".", "analysis", ".", "conditional", ")", "{", "aret", "=", "sandbox", ".", "analysis", ".", "conditional", "(", "iid", ",...
Expression in conditional
[ "Expression", "in", "conditional" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/runtime/analysis.js#L722-L733
train
Samsung/jalangi2
src/js/commands/instrument.js
accumulateData
function accumulateData(chunk, enc, cb) { this.data = this.data == null ? chunk : Buffer.concat([this.data,chunk]);; cb(); }
javascript
function accumulateData(chunk, enc, cb) { this.data = this.data == null ? chunk : Buffer.concat([this.data,chunk]);; cb(); }
[ "function", "accumulateData", "(", "chunk", ",", "enc", ",", "cb", ")", "{", "this", ".", "data", "=", "this", ".", "data", "==", "null", "?", "chunk", ":", "Buffer", ".", "concat", "(", "[", "this", ".", "data", ",", "chunk", "]", ")", ";", ";",...
shared between HTMLRewriteStream and InstrumentJSStream
[ "shared", "between", "HTMLRewriteStream", "and", "InstrumentJSStream" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/commands/instrument.js#L154-L157
train
Samsung/jalangi2
src/js/commands/instrument.js
includedFile
function includedFile(fileName) { var relativePath = fileName.substring(appDir.length + 1); var result = false; for (var i = 0; i < onlyIncludeList.length; i++) { var prefix = onlyIncludeList[i]; if (relativePath.indexOf(prefix) === 0) { ...
javascript
function includedFile(fileName) { var relativePath = fileName.substring(appDir.length + 1); var result = false; for (var i = 0; i < onlyIncludeList.length; i++) { var prefix = onlyIncludeList[i]; if (relativePath.indexOf(prefix) === 0) { ...
[ "function", "includedFile", "(", "fileName", ")", "{", "var", "relativePath", "=", "fileName", ".", "substring", "(", "appDir", ".", "length", "+", "1", ")", ";", "var", "result", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", ...
determine if a file is in the include list @param fileName @returns {boolean}
[ "determine", "if", "a", "file", "is", "in", "the", "include", "list" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/commands/instrument.js#L324-L335
train
Samsung/jalangi2
src/js/commands/instrument.js
function () { var outputDir = path.join(copyDir, jalangiRuntimeDir); mkdirp.sync(outputDir); var copyFile = function (srcFile) { if (jalangiRoot) { srcFile = path.join(jalangiRoot, srcFile); } var outputFile = path.j...
javascript
function () { var outputDir = path.join(copyDir, jalangiRuntimeDir); mkdirp.sync(outputDir); var copyFile = function (srcFile) { if (jalangiRoot) { srcFile = path.join(jalangiRoot, srcFile); } var outputFile = path.j...
[ "function", "(", ")", "{", "var", "outputDir", "=", "path", ".", "join", "(", "copyDir", ",", "jalangiRuntimeDir", ")", ";", "mkdirp", ".", "sync", "(", "outputDir", ")", ";", "var", "copyFile", "=", "function", "(", "srcFile", ")", "{", "if", "(", "...
copy the Jalangi runtime files into the directory with instrumented code, so they can be loaded with relative paths
[ "copy", "the", "Jalangi", "runtime", "files", "into", "the", "directory", "with", "instrumented", "code", "so", "they", "can", "be", "loaded", "with", "relative", "paths" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/commands/instrument.js#L369-L386
train
Samsung/jalangi2
src/js/utils/api.js
setupConfig
function setupConfig(instHandler) { var conf = J$.Config; conf.INSTR_READ = instHandler.instrRead; conf.INSTR_WRITE = instHandler.instrWrite; conf.INSTR_GETFIELD = instHandler.instrGetfield; conf.INSTR_PUTFIELD = instHandler.instrPutfield; conf.INSTR_BINARY = instHandler.instrBinary; conf.IN...
javascript
function setupConfig(instHandler) { var conf = J$.Config; conf.INSTR_READ = instHandler.instrRead; conf.INSTR_WRITE = instHandler.instrWrite; conf.INSTR_GETFIELD = instHandler.instrGetfield; conf.INSTR_PUTFIELD = instHandler.instrPutfield; conf.INSTR_BINARY = instHandler.instrBinary; conf.IN...
[ "function", "setupConfig", "(", "instHandler", ")", "{", "var", "conf", "=", "J$", ".", "Config", ";", "conf", ".", "INSTR_READ", "=", "instHandler", ".", "instrRead", ";", "conf", ".", "INSTR_WRITE", "=", "instHandler", ".", "instrWrite", ";", "conf", "."...
setup the global Config object based on the given instrumentation handler object @param instHandler
[ "setup", "the", "global", "Config", "object", "based", "on", "the", "given", "instrumentation", "handler", "object" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/utils/api.js#L49-L60
train
Samsung/jalangi2
src/js/utils/api.js
clearConfig
function clearConfig() { var conf = J$.Config; conf.INSTR_READ = null; conf.INSTR_WRITE = null; conf.INSTR_GETFIELD = null; conf.INSTR_PUTFIELD = null; conf.INSTR_BINARY = null; conf.INSTR_PROPERTY_BINARY_ASSIGNMENT = null; conf.INSTR_UNARY = null; conf.INSTR_LITERAL = null; conf...
javascript
function clearConfig() { var conf = J$.Config; conf.INSTR_READ = null; conf.INSTR_WRITE = null; conf.INSTR_GETFIELD = null; conf.INSTR_PUTFIELD = null; conf.INSTR_BINARY = null; conf.INSTR_PROPERTY_BINARY_ASSIGNMENT = null; conf.INSTR_UNARY = null; conf.INSTR_LITERAL = null; conf...
[ "function", "clearConfig", "(", ")", "{", "var", "conf", "=", "J$", ".", "Config", ";", "conf", ".", "INSTR_READ", "=", "null", ";", "conf", ".", "INSTR_WRITE", "=", "null", ";", "conf", ".", "INSTR_GETFIELD", "=", "null", ";", "conf", ".", "INSTR_PUTF...
clear any configured instrumentation control functions from the global Config object
[ "clear", "any", "configured", "instrumentation", "control", "functions", "from", "the", "global", "Config", "object" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/utils/api.js#L65-L76
train
Samsung/jalangi2
src/js/utils/api.js
runChildAndCaptureOutput
function runChildAndCaptureOutput(forkedProcess) { var stdout_parts = [], stdoutLength = 0, stderr_parts = [], stderrLength = 0, deferred = Q.defer(); forkedProcess.stdout.on('data', function (data) { stdout_parts.push(data); stdoutLength += data.length; }); forkedProcess.stderr....
javascript
function runChildAndCaptureOutput(forkedProcess) { var stdout_parts = [], stdoutLength = 0, stderr_parts = [], stderrLength = 0, deferred = Q.defer(); forkedProcess.stdout.on('data', function (data) { stdout_parts.push(data); stdoutLength += data.length; }); forkedProcess.stderr....
[ "function", "runChildAndCaptureOutput", "(", "forkedProcess", ")", "{", "var", "stdout_parts", "=", "[", "]", ",", "stdoutLength", "=", "0", ",", "stderr_parts", "=", "[", "]", ",", "stderrLength", "=", "0", ",", "deferred", "=", "Q", ".", "defer", "(", ...
Runs a process created via the node child_process API and captures its output. @param forkedProcess the process @returns {promise|Q.promise} A promise that, when process execution completes normally, is resolved with an object with the following properties: 'stdout': the stdout output of the process 'stderr': the stde...
[ "Runs", "a", "process", "created", "via", "the", "node", "child_process", "API", "and", "captures", "its", "output", "." ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/utils/api.js#L180-L210
train
Samsung/jalangi2
src/js/utils/api.js
analyze
function analyze(script, clientAnalyses, initParam) { var directJSScript = path.resolve(__dirname, "../commands/direct.js"); var cliArgs = []; if (!script) { throw new Error("must provide a script to analyze"); } if (!clientAnalyses) { throw new Error("must provide an analysis to run...
javascript
function analyze(script, clientAnalyses, initParam) { var directJSScript = path.resolve(__dirname, "../commands/direct.js"); var cliArgs = []; if (!script) { throw new Error("must provide a script to analyze"); } if (!clientAnalyses) { throw new Error("must provide an analysis to run...
[ "function", "analyze", "(", "script", ",", "clientAnalyses", ",", "initParam", ")", "{", "var", "directJSScript", "=", "path", ".", "resolve", "(", "__dirname", ",", "\"../commands/direct.js\"", ")", ";", "var", "cliArgs", "=", "[", "]", ";", "if", "(", "!...
direct analysis of an instrumented file using analysis2 engine @param {string} script the instrumented script to analyze @param {string[]} clientAnalyses the analyses to run @param {object} [initParam] parameter to pass to client init() function @return promise|Q.promise promise that gets resolved at the end of analysi...
[ "direct", "analysis", "of", "an", "instrumented", "file", "using", "analysis2", "engine" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/utils/api.js#L224-L246
train
Samsung/jalangi2
src/js/sample_analyses/datatraces/TraceWriter.js
tryRemoteLog2
function tryRemoteLog2() { trying = false; remoteBuffer.shift(); if (remoteBuffer.length === 0) { if (cb) { cb(); cb = undefined; } } tryRemoteLog(); }
javascript
function tryRemoteLog2() { trying = false; remoteBuffer.shift(); if (remoteBuffer.length === 0) { if (cb) { cb(); cb = undefined; } } tryRemoteLog(); }
[ "function", "tryRemoteLog2", "(", ")", "{", "trying", "=", "false", ";", "remoteBuffer", ".", "shift", "(", ")", ";", "if", "(", "remoteBuffer", ".", "length", "===", "0", ")", "{", "if", "(", "cb", ")", "{", "cb", "(", ")", ";", "cb", "=", "unde...
invoked when we receive a message over the websocket, indicating that the last trace chunk in the remoteBuffer has been received
[ "invoked", "when", "we", "receive", "a", "message", "over", "the", "websocket", "indicating", "that", "the", "last", "trace", "chunk", "in", "the", "remoteBuffer", "has", "been", "received" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/sample_analyses/datatraces/TraceWriter.js#L84-L94
train
Samsung/jalangi2
src/js/instrument/astUtil.js
serialize
function serialize(root) { // Stores a pointer to the most-recently encountered node representing a function or a // top-level script. We need this stored pointer since a function expression or declaration // has no associated IID, but we'd like to have the ASTs as entries in the table. Instea...
javascript
function serialize(root) { // Stores a pointer to the most-recently encountered node representing a function or a // top-level script. We need this stored pointer since a function expression or declaration // has no associated IID, but we'd like to have the ASTs as entries in the table. Instea...
[ "function", "serialize", "(", "root", ")", "{", "// Stores a pointer to the most-recently encountered node representing a function or a", "// top-level script. We need this stored pointer since a function expression or declaration", "// has no associated IID, but we'd like to have the ASTs as entri...
computes a map from iids to the corresponding AST nodes for root. The root AST is destructively updated to include SymbolicReference nodes that reference other nodes by iid, in order to save space in the map.
[ "computes", "a", "map", "from", "iids", "to", "the", "corresponding", "AST", "nodes", "for", "root", ".", "The", "root", "AST", "is", "destructively", "updated", "to", "include", "SymbolicReference", "nodes", "that", "reference", "other", "nodes", "by", "iid",...
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/astUtil.js#L164-L228
train
Samsung/jalangi2
src/js/instrument/astUtil.js
computeTopLevelExpressions
function computeTopLevelExpressions(ast) { var exprDepth = 0; var exprDepthStack = []; var topLevelExprs = []; var visitorIdentifyTopLevelExprPre = { "CallExpression":function (node) { if (node.callee.type === 'MemberExpression' && node.cal...
javascript
function computeTopLevelExpressions(ast) { var exprDepth = 0; var exprDepthStack = []; var topLevelExprs = []; var visitorIdentifyTopLevelExprPre = { "CallExpression":function (node) { if (node.callee.type === 'MemberExpression' && node.cal...
[ "function", "computeTopLevelExpressions", "(", "ast", ")", "{", "var", "exprDepth", "=", "0", ";", "var", "exprDepthStack", "=", "[", "]", ";", "var", "topLevelExprs", "=", "[", "]", ";", "var", "visitorIdentifyTopLevelExprPre", "=", "{", "\"CallExpression\"", ...
given an instrumented AST, returns an array of IIDs corresponding to "top-level expressions," i.e., expressions that are not nested within another @param ast
[ "given", "an", "instrumented", "AST", "returns", "an", "array", "of", "IIDs", "corresponding", "to", "top", "-", "level", "expressions", "i", ".", "e", ".", "expressions", "that", "are", "not", "nested", "within", "another" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/astUtil.js#L258-L336
train
Samsung/jalangi2
src/js/instrument/instUtil.js
createFilenameForScript
function createFilenameForScript(url) { // TODO make this much more robust console.log("url:" + url); var parsed = urlParser.parse(url); if (inlineRegexp.test(url)) { return parsed.hash.substring(1) + ".js"; } else { return parsed.pathname.substring(parsed.pathname.lastIndexOf("/") +...
javascript
function createFilenameForScript(url) { // TODO make this much more robust console.log("url:" + url); var parsed = urlParser.parse(url); if (inlineRegexp.test(url)) { return parsed.hash.substring(1) + ".js"; } else { return parsed.pathname.substring(parsed.pathname.lastIndexOf("/") +...
[ "function", "createFilenameForScript", "(", "url", ")", "{", "// TODO make this much more robust", "console", ".", "log", "(", "\"url:\"", "+", "url", ")", ";", "var", "parsed", "=", "urlParser", ".", "parse", "(", "url", ")", ";", "if", "(", "inlineRegexp", ...
generate a filename for a script with the given url
[ "generate", "a", "filename", "for", "a", "script", "with", "the", "given", "url" ]
08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110
https://github.com/Samsung/jalangi2/blob/08f6f38abc2f5a09ffa48d173b7f0d92d6d8b110/src/js/instrument/instUtil.js#L188-L197
train
Mevrael/bunny
src/bunny.route.js
function(uri) { var original_segments = window.location.pathname.split('/'); var route_segments = uri.split('/'); var route_length = route_segments.length; var params = {}; for (var i = 1; i < route_length; i++) { if (route_segments[i].indexOf('{') !== -1) { ...
javascript
function(uri) { var original_segments = window.location.pathname.split('/'); var route_segments = uri.split('/'); var route_length = route_segments.length; var params = {}; for (var i = 1; i < route_length; i++) { if (route_segments[i].indexOf('{') !== -1) { ...
[ "function", "(", "uri", ")", "{", "var", "original_segments", "=", "window", ".", "location", ".", "pathname", ".", "split", "(", "'/'", ")", ";", "var", "route_segments", "=", "uri", ".", "split", "(", "'/'", ")", ";", "var", "route_length", "=", "rou...
Get route params @param uri @returns {{}}
[ "Get", "route", "params" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/src/bunny.route.js#L35-L47
train
Mevrael/bunny
src/bunny.route.js
function(uri) { if (this._routes[uri] !== undefined) { return uri; } for (var route in this._routes) { if (this.is(route, uri)) { return route; } } return false; }
javascript
function(uri) { if (this._routes[uri] !== undefined) { return uri; } for (var route in this._routes) { if (this.is(route, uri)) { return route; } } return false; }
[ "function", "(", "uri", ")", "{", "if", "(", "this", ".", "_routes", "[", "uri", "]", "!==", "undefined", ")", "{", "return", "uri", ";", "}", "for", "(", "var", "route", "in", "this", ".", "_routes", ")", "{", "if", "(", "this", ".", "is", "("...
Check if route is defined. Returns route if found or false @param uri @returns {*}
[ "Check", "if", "route", "is", "defined", ".", "Returns", "route", "if", "found", "or", "false" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/src/bunny.route.js#L81-L94
train
Mevrael/bunny
src/bunny.route.js
function(uri) { if (this.defined(uri)) { history.pushState(null, null, uri); var event = new CustomEvent('onRouteChange'); event.route = uri; document.dispatchEvent(event, uri); } else { console.error('Route "' + uri + '" is not defined.'); ...
javascript
function(uri) { if (this.defined(uri)) { history.pushState(null, null, uri); var event = new CustomEvent('onRouteChange'); event.route = uri; document.dispatchEvent(event, uri); } else { console.error('Route "' + uri + '" is not defined.'); ...
[ "function", "(", "uri", ")", "{", "if", "(", "this", ".", "defined", "(", "uri", ")", ")", "{", "history", ".", "pushState", "(", "null", ",", "null", ",", "uri", ")", ";", "var", "event", "=", "new", "CustomEvent", "(", "'onRouteChange'", ")", ";"...
Redirect to new route @param uri @returns {boolean}
[ "Redirect", "to", "new", "route" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/src/bunny.route.js#L125-L135
train
Mevrael/bunny
examples/dropdown/dist/index.js
iteratorFor
function iteratorFor(items) { var iterator = { next: function next() { var value = items.shift(); return { done: value === undefined, value: value }; } }; if (support.iterable) { iterator[Symbol.iterator] = function () { return iterator; }; } return ...
javascript
function iteratorFor(items) { var iterator = { next: function next() { var value = items.shift(); return { done: value === undefined, value: value }; } }; if (support.iterable) { iterator[Symbol.iterator] = function () { return iterator; }; } return ...
[ "function", "iteratorFor", "(", "items", ")", "{", "var", "iterator", "=", "{", "next", ":", "function", "next", "(", ")", "{", "var", "value", "=", "items", ".", "shift", "(", ")", ";", "return", "{", "done", ":", "value", "===", "undefined", ",", ...
Build a destructive iterator for the value list
[ "Build", "a", "destructive", "iterator", "for", "the", "value", "list" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L376-L391
train
Mevrael/bunny
examples/dropdown/dist/index.js
addEventOnce
function addEventOnce(element, eventName, eventListener) { var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500; var timeout = 0; return addEvent(element, eventName, function (e) { clearTimeout(timeout); timeout = setTimeout(function () { eventListener(e); }, dela...
javascript
function addEventOnce(element, eventName, eventListener) { var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500; var timeout = 0; return addEvent(element, eventName, function (e) { clearTimeout(timeout); timeout = setTimeout(function () { eventListener(e); }, dela...
[ "function", "addEventOnce", "(", "element", ",", "eventName", ",", "eventListener", ")", "{", "var", "delay", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", "]", ":", "500", ...
Call event listener only once after "delay" ms Useful for scroll, keydown and other events when the actions must be done only once when user stopped typing or scrolling for example @param {HTMLElement} element @param {String} eventName @param {Function} eventListener @param {Number} delay @returns {Number}
[ "Call", "event", "listener", "only", "once", "after", "delay", "ms", "Useful", "for", "scroll", "keydown", "and", "other", "events", "when", "the", "actions", "must", "be", "done", "only", "once", "when", "user", "stopped", "typing", "or", "scrolling", "for"...
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L919-L929
train
Mevrael/bunny
examples/dropdown/dist/index.js
addEventKeyNavigation
function addEventKeyNavigation(element, items, itemSelectCallback) { var itemSwitchCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var currentItemIndex = null; for (var k = 0; k < items.length; k++) { if (items[k].hasAttribute('aria-selected')) { currentItemIndex =...
javascript
function addEventKeyNavigation(element, items, itemSelectCallback) { var itemSwitchCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var currentItemIndex = null; for (var k = 0; k < items.length; k++) { if (items[k].hasAttribute('aria-selected')) { currentItemIndex =...
[ "function", "addEventKeyNavigation", "(", "element", ",", "items", ",", "itemSelectCallback", ")", "{", "var", "itemSwitchCallback", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", ...
Adds up, down, esc, enter keypress event on 'element' to traverse though 'items' @param {HTMLElement} element @param {HTMLCollection|NodeList} items @param {function} itemSelectCallback callback(null) if Enter was pressed and no item was selected (for example custom value entered) callback(false) if Esc was pressed (c...
[ "Adds", "up", "down", "esc", "enter", "keypress", "event", "on", "element", "to", "traverse", "though", "items" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L1003-L1092
train
Mevrael/bunny
examples/dropdown/dist/index.js
checkPromise
function checkPromise(index) { var res = cb(callbacks[index]); // actually calling callback if (res instanceof Promise) { res.then(function (cbRes) { if (cbRes !== false) { // keep going if (index > 0) { checkPromise(index - 1); } ...
javascript
function checkPromise(index) { var res = cb(callbacks[index]); // actually calling callback if (res instanceof Promise) { res.then(function (cbRes) { if (cbRes !== false) { // keep going if (index > 0) { checkPromise(index - 1); } ...
[ "function", "checkPromise", "(", "index", ")", "{", "var", "res", "=", "cb", "(", "callbacks", "[", "index", "]", ")", ";", "// actually calling callback", "if", "(", "res", "instanceof", "Promise", ")", "{", "res", ".", "then", "(", "function", "(", "cb...
process each promise in direct order if promise returns false, do not execute further promises
[ "process", "each", "promise", "in", "direct", "order", "if", "promise", "returns", "false", "do", "not", "execute", "further", "promises" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L1248-L1267
train
Mevrael/bunny
examples/dropdown/dist/index.js
rgbaToColorMatrix
function rgbaToColorMatrix(red, green, blue) { var alpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; var decToFloat = function decToFloat(value) { return Math.round(value / 255 * 10) / 10; }; var redFloat = decToFloat(red); var greenFloat = decToFloat(green); var blueFloat ...
javascript
function rgbaToColorMatrix(red, green, blue) { var alpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; var decToFloat = function decToFloat(value) { return Math.round(value / 255 * 10) / 10; }; var redFloat = decToFloat(red); var greenFloat = decToFloat(green); var blueFloat ...
[ "function", "rgbaToColorMatrix", "(", "red", ",", "green", ",", "blue", ")", "{", "var", "alpha", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", "]", ":", "0", ";", "var", ...
SVG color matrix filter
[ "SVG", "color", "matrix", "filter" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L2202-L2213
train
Mevrael/bunny
examples/dropdown/dist/index.js
syncUI
function syncUI(customSelect, defaultValue, isMultiple) { var _this2 = this; console.log(defaultValue, isMultiple); var menuItems = this.getMenuItems(customSelect); var tglBtn = this.getToggleBtn(customSelect); var hasSelected = false; [].forEach.call(menuItems, function (menuItem) { if (...
javascript
function syncUI(customSelect, defaultValue, isMultiple) { var _this2 = this; console.log(defaultValue, isMultiple); var menuItems = this.getMenuItems(customSelect); var tglBtn = this.getToggleBtn(customSelect); var hasSelected = false; [].forEach.call(menuItems, function (menuItem) { if (...
[ "function", "syncUI", "(", "customSelect", ",", "defaultValue", ",", "isMultiple", ")", "{", "var", "_this2", "=", "this", ";", "console", ".", "log", "(", "defaultValue", ",", "isMultiple", ")", ";", "var", "menuItems", "=", "this", ".", "getMenuItems", "...
Synchronizes default value and selected options with UI If dropdown item has aria-selected but has no active class, add it If dropdown item has no aria-selected but has active class, remove it If no dropdown item selected, select 1st item and hidden option If customselect has value attribute, sets selected option accor...
[ "Synchronizes", "default", "value", "and", "selected", "options", "with", "UI", "If", "dropdown", "item", "has", "aria", "-", "selected", "but", "has", "no", "active", "class", "add", "it", "If", "dropdown", "item", "has", "no", "aria", "-", "selected", "b...
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L2521-L2566
train
Mevrael/bunny
examples/dropdown/dist/index.js
getDefaultValue
function getDefaultValue(customSelect) { var val = customSelect.getAttribute('value'); if (val === null) { return ''; } var firstChar = val[0]; if (firstChar === undefined) { return ''; } else if (firstChar === '[') { return JSON.parse(val); } return val; }
javascript
function getDefaultValue(customSelect) { var val = customSelect.getAttribute('value'); if (val === null) { return ''; } var firstChar = val[0]; if (firstChar === undefined) { return ''; } else if (firstChar === '[') { return JSON.parse(val); } return val; }
[ "function", "getDefaultValue", "(", "customSelect", ")", "{", "var", "val", "=", "customSelect", ".", "getAttribute", "(", "'value'", ")", ";", "if", "(", "val", "===", "null", ")", "{", "return", "''", ";", "}", "var", "firstChar", "=", "val", "[", "0...
Get default value from value="" attribute which might be a string representing a single selected option value or a JSON array representing selected options in multiple select This attribute has highest priority over aria-selected which will be updated in syncUI() If value is empty string or no value attribute found th...
[ "Get", "default", "value", "from", "value", "=", "attribute", "which", "might", "be", "a", "string", "representing", "a", "single", "selected", "option", "value", "or", "a", "JSON", "array", "representing", "selected", "options", "in", "multiple", "select" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L2655-L2667
train
Mevrael/bunny
examples/dropdown/dist/index.js
getSelectedValue
function getSelectedValue(customSelect) { var hiddenSelect = this.UI.getHiddenSelect(customSelect); if (this.isMultiple(customSelect)) { var selectedOptions = []; [].forEach.call(hiddenSelect.options, function (option) { if (option.selected) { selectedOptions.push(option.value); ...
javascript
function getSelectedValue(customSelect) { var hiddenSelect = this.UI.getHiddenSelect(customSelect); if (this.isMultiple(customSelect)) { var selectedOptions = []; [].forEach.call(hiddenSelect.options, function (option) { if (option.selected) { selectedOptions.push(option.value); ...
[ "function", "getSelectedValue", "(", "customSelect", ")", "{", "var", "hiddenSelect", "=", "this", ".", "UI", ".", "getHiddenSelect", "(", "customSelect", ")", ";", "if", "(", "this", ".", "isMultiple", "(", "customSelect", ")", ")", "{", "var", "selectedOpt...
Get selected value If select is multiple then returns array @param customSelect @returns {String|Array}
[ "Get", "selected", "value", "If", "select", "is", "multiple", "then", "returns", "array" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/dropdown/dist/index.js#L2712-L2725
train
Mevrael/bunny
examples/form/dist/index.js
_attachChangeAndDefaultFileEvent
function _attachChangeAndDefaultFileEvent(form_id) { var _this = this; var elements = this._collection[form_id].getInputs(); [].forEach.call(elements, function (form_control) { _this.__attachSingleChangeEvent(form_id, form_control); _this.__observeSingleValueChange(form...
javascript
function _attachChangeAndDefaultFileEvent(form_id) { var _this = this; var elements = this._collection[form_id].getInputs(); [].forEach.call(elements, function (form_control) { _this.__attachSingleChangeEvent(form_id, form_control); _this.__observeSingleValueChange(form...
[ "function", "_attachChangeAndDefaultFileEvent", "(", "form_id", ")", "{", "var", "_this", "=", "this", ";", "var", "elements", "=", "this", ".", "_collection", "[", "form_id", "]", ".", "getInputs", "(", ")", ";", "[", "]", ".", "forEach", ".", "call", "...
Update FormData when user changed input's value or when value changed from script Also init default value for File inputs @param {string} form_id @private
[ "Update", "FormData", "when", "user", "changed", "input", "s", "value", "or", "when", "value", "changed", "from", "script" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L742-L759
train
Mevrael/bunny
examples/form/dist/index.js
_parseFormControl
function _parseFormControl(form_id, form_control) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var type = this._collection[form_id].getInputType(form_control); console.log(type); // check if parser for specific input type exists and call...
javascript
function _parseFormControl(form_id, form_control) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var type = this._collection[form_id].getInputType(form_control); console.log(type); // check if parser for specific input type exists and call...
[ "function", "_parseFormControl", "(", "form_id", ",", "form_control", ")", "{", "var", "value", "=", "arguments", ".", "length", ">", "2", "&&", "arguments", "[", "2", "]", "!==", "undefined", "?", "arguments", "[", "2", "]", ":", "undefined", ";", "var"...
handlers for different input types with 4th argument - setter without 4th argument - getter called from .value property observer
[ "handlers", "for", "different", "input", "types", "with", "4th", "argument", "-", "setter", "without", "4th", "argument", "-", "getter", "called", "from", ".", "value", "property", "observer" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L795-L822
train
Mevrael/bunny
examples/form/dist/index.js
download
function download(URL) { var convert_to_blob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var request = new XMLHttpRequest(); var p = new Promise(function (success, fail) { request.onload = function () { if (request.status === 200) { ...
javascript
function download(URL) { var convert_to_blob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var request = new XMLHttpRequest(); var p = new Promise(function (success, fail) { request.onload = function () { if (request.status === 200) { ...
[ "function", "download", "(", "URL", ")", "{", "var", "convert_to_blob", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "true", ";", "var", "request", "=", "new", ...
Download file from URL via AJAX and make Blob object or return base64 string if 2nd argument is false Only files from CORS-enabled domains can be downloaded or AJAX will get security error @param {String} URL @param {Boolean} convert_to_blob = true @returns {Promise}: success(Blob object | base64 string), fail(respons...
[ "Download", "file", "from", "URL", "via", "AJAX", "and", "make", "Blob", "object", "or", "return", "base64", "string", "if", "2nd", "argument", "is", "false", "Only", "files", "from", "CORS", "-", "enabled", "domains", "can", "be", "downloaded", "or", "AJA...
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L1343-L1365
train
Mevrael/bunny
examples/form/dist/index.js
base64ToBlob
function base64ToBlob(base64) { // convert base64 to raw binary data held in a string // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this var byteString = atob(base64.split(',')[1]); // separate out the mime component var mimeString = base64.sp...
javascript
function base64ToBlob(base64) { // convert base64 to raw binary data held in a string // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this var byteString = atob(base64.split(',')[1]); // separate out the mime component var mimeString = base64.sp...
[ "function", "base64ToBlob", "(", "base64", ")", "{", "// convert base64 to raw binary data held in a string", "// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this", "var", "byteString", "=", "atob", "(", "base64", ".", "split", "(", "','", ")", ...
Convert base64 string to Blob object @param {String} base64 @returns {Blob}
[ "Convert", "base64", "string", "to", "Blob", "object" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L1415-L1432
train
Mevrael/bunny
examples/form/dist/index.js
blobToBase64
function blobToBase64(blob) { var reader = new FileReader(); var p = new Promise(function (success, fail) { reader.onloadend = function () { var base64 = reader.result; success(base64); }; reader.onerror = function (e) { ...
javascript
function blobToBase64(blob) { var reader = new FileReader(); var p = new Promise(function (success, fail) { reader.onloadend = function () { var base64 = reader.result; success(base64); }; reader.onerror = function (e) { ...
[ "function", "blobToBase64", "(", "blob", ")", "{", "var", "reader", "=", "new", "FileReader", "(", ")", ";", "var", "p", "=", "new", "Promise", "(", "function", "(", "success", ",", "fail", ")", "{", "reader", ".", "onloadend", "=", "function", "(", ...
Convert Blob object to base64string @param {Blob} blob @returns {Promise} success(base64 string), fail(error)
[ "Convert", "Blob", "object", "to", "base64string" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L1440-L1455
train
Mevrael/bunny
examples/form/dist/index.js
getBlobLocalURL
function getBlobLocalURL(blob) { if (!(blob instanceof Blob || blob instanceof File)) { throw new TypeError('Argument in BunnyFile.getBlobLocalURL() is not a Blob or File object'); } return URL.createObjectURL(blob); }
javascript
function getBlobLocalURL(blob) { if (!(blob instanceof Blob || blob instanceof File)) { throw new TypeError('Argument in BunnyFile.getBlobLocalURL() is not a Blob or File object'); } return URL.createObjectURL(blob); }
[ "function", "getBlobLocalURL", "(", "blob", ")", "{", "if", "(", "!", "(", "blob", "instanceof", "Blob", "||", "blob", "instanceof", "File", ")", ")", "{", "throw", "new", "TypeError", "(", "'Argument in BunnyFile.getBlobLocalURL() is not a Blob or File object'", ")...
Get local browser object URL which can be used in img.src for example @param {Blob} blob @returns {String}
[ "Get", "local", "browser", "object", "URL", "which", "can", "be", "used", "in", "img", ".", "src", "for", "example" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/form/dist/index.js#L1463-L1468
train
Mevrael/bunny
examples/validation/dist/index.js
scrollTo
function scrollTo(target) { var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var rootElement = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : window; return ne...
javascript
function scrollTo(target) { var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var rootElement = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : window; return ne...
[ "function", "scrollTo", "(", "target", ")", "{", "var", "duration", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "500", ";", "var", "offset", "=", "arguments", ...
Smooth scrolling to DOM element or to relative window position If target is string it should be CSS selector If target is object it should be DOM element If target is number - it is used to relatively scroll X pixels form current position Based on https://www.sitepoint.com/smooth-scrolling-vanilla-javascript/ @param ...
[ "Smooth", "scrolling", "to", "DOM", "element", "or", "to", "relative", "window", "position", "If", "target", "is", "string", "it", "should", "be", "CSS", "selector", "If", "target", "is", "object", "it", "should", "be", "DOM", "element", "If", "target", "i...
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L849-L925
train
Mevrael/bunny
examples/validation/dist/index.js
_bn_getFile
function _bn_getFile(input) { // if there is custom file upload logic, for example, images are resized client-side // generated Blobs should be assigned to fileInput._file // and can be sent via ajax with FormData // if file was deleted, custom field can be set to an empty string // Bunny Validati...
javascript
function _bn_getFile(input) { // if there is custom file upload logic, for example, images are resized client-side // generated Blobs should be assigned to fileInput._file // and can be sent via ajax with FormData // if file was deleted, custom field can be set to an empty string // Bunny Validati...
[ "function", "_bn_getFile", "(", "input", ")", "{", "// if there is custom file upload logic, for example, images are resized client-side", "// generated Blobs should be assigned to fileInput._file", "// and can be sent via ajax with FormData", "// if file was deleted, custom field can be set to an...
Bunny Validation helper - get file to validate @param {HTMLInputElement} input @returns {File|Blob|boolean} - If no file uploaded - returns false @private
[ "Bunny", "Validation", "helper", "-", "get", "file", "to", "validate" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1046-L1063
train
Mevrael/bunny
examples/validation/dist/index.js
image
function image(input) { return new Promise(function (valid, invalid) { if (input.getAttribute('type') === 'file' && input.getAttribute('accept').indexOf('image') > -1 && _bn_getFile(input) !== false) { BunnyFile.getSignature(_bn_getFile(input)).then(function (signature) { ...
javascript
function image(input) { return new Promise(function (valid, invalid) { if (input.getAttribute('type') === 'file' && input.getAttribute('accept').indexOf('image') > -1 && _bn_getFile(input) !== false) { BunnyFile.getSignature(_bn_getFile(input)).then(function (signature) { ...
[ "function", "image", "(", "input", ")", "{", "return", "new", "Promise", "(", "function", "(", "valid", ",", "invalid", ")", "{", "if", "(", "input", ".", "getAttribute", "(", "'type'", ")", "===", "'file'", "&&", "input", ".", "getAttribute", "(", "'a...
if file input has "accept" attribute and it contains "image", then check if uploaded file is a JPG or PNG
[ "if", "file", "input", "has", "accept", "attribute", "and", "it", "contains", "image", "then", "check", "if", "uploaded", "file", "is", "a", "JPG", "or", "PNG" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1171-L1187
train
Mevrael/bunny
examples/validation/dist/index.js
createErrorNode
function createErrorNode() { var el = document.createElement(this.config.tagNameError); el.classList.add(this.config.classError); return el; }
javascript
function createErrorNode() { var el = document.createElement(this.config.tagNameError); el.classList.add(this.config.classError); return el; }
[ "function", "createErrorNode", "(", ")", "{", "var", "el", "=", "document", ".", "createElement", "(", "this", ".", "config", ".", "tagNameError", ")", ";", "el", ".", "classList", ".", "add", "(", "this", ".", "config", ".", "classError", ")", ";", "r...
Create DOM element for error message @returns {HTMLElement}
[ "Create", "DOM", "element", "for", "error", "message" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1369-L1373
train
Mevrael/bunny
examples/validation/dist/index.js
removeErrorNode
function removeErrorNode(inputGroup) { var el = this.getErrorNode(inputGroup); if (el) { el.parentNode.removeChild(el); this.toggleErrorClass(inputGroup); } }
javascript
function removeErrorNode(inputGroup) { var el = this.getErrorNode(inputGroup); if (el) { el.parentNode.removeChild(el); this.toggleErrorClass(inputGroup); } }
[ "function", "removeErrorNode", "(", "inputGroup", ")", "{", "var", "el", "=", "this", ".", "getErrorNode", "(", "inputGroup", ")", ";", "if", "(", "el", ")", "{", "el", ".", "parentNode", ".", "removeChild", "(", "el", ")", ";", "this", ".", "toggleErr...
Removes error node and class from input group if exists @param {HTMLElement} inputGroup
[ "Removes", "error", "node", "and", "class", "from", "input", "group", "if", "exists" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1393-L1399
train
Mevrael/bunny
examples/validation/dist/index.js
removeErrorNodesFromSection
function removeErrorNodesFromSection(section) { var _this = this; [].forEach.call(this.getInputGroupsInSection(section), function (inputGroup) { _this.removeErrorNode(inputGroup); }); }
javascript
function removeErrorNodesFromSection(section) { var _this = this; [].forEach.call(this.getInputGroupsInSection(section), function (inputGroup) { _this.removeErrorNode(inputGroup); }); }
[ "function", "removeErrorNodesFromSection", "(", "section", ")", "{", "var", "_this", "=", "this", ";", "[", "]", ".", "forEach", ".", "call", "(", "this", ".", "getInputGroupsInSection", "(", "section", ")", ",", "function", "(", "inputGroup", ")", "{", "_...
Removes all error node and class from input group if exists within section @param {HTMLElement} section
[ "Removes", "all", "error", "node", "and", "class", "from", "input", "group", "if", "exists", "within", "section" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1407-L1413
train
Mevrael/bunny
examples/validation/dist/index.js
setErrorMessage
function setErrorMessage(inputGroup, message) { var errorNode = this.getErrorNode(inputGroup); if (errorNode === false) { // container for error message doesn't exists, create new errorNode = this.createErrorNode(); this.toggleErrorClass(inputGroup); this....
javascript
function setErrorMessage(inputGroup, message) { var errorNode = this.getErrorNode(inputGroup); if (errorNode === false) { // container for error message doesn't exists, create new errorNode = this.createErrorNode(); this.toggleErrorClass(inputGroup); this....
[ "function", "setErrorMessage", "(", "inputGroup", ",", "message", ")", "{", "var", "errorNode", "=", "this", ".", "getErrorNode", "(", "inputGroup", ")", ";", "if", "(", "errorNode", "===", "false", ")", "{", "// container for error message doesn't exists, create ne...
Creates and includes into DOM error node or updates error message @param {HTMLElement} inputGroup @param {String} message
[ "Creates", "and", "includes", "into", "DOM", "error", "node", "or", "updates", "error", "message" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1422-L1432
train
Mevrael/bunny
examples/validation/dist/index.js
getInputGroup
function getInputGroup(input) { var el = input; while ((el = el.parentNode) && !el.classList.contains(this.config.classInputGroup)) {} return el; }
javascript
function getInputGroup(input) { var el = input; while ((el = el.parentNode) && !el.classList.contains(this.config.classInputGroup)) {} return el; }
[ "function", "getInputGroup", "(", "input", ")", "{", "var", "el", "=", "input", ";", "while", "(", "(", "el", "=", "el", ".", "parentNode", ")", "&&", "!", "el", ".", "classList", ".", "contains", "(", "this", ".", "config", ".", "classInputGroup", "...
Find closest parent inputGroup element by Input element @param {HTMLElement} input @returns {HTMLElement}
[ "Find", "closest", "parent", "inputGroup", "element", "by", "Input", "element" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1468-L1472
train
Mevrael/bunny
examples/validation/dist/index.js
getInputsInSection
function getInputsInSection(node) { var resolving = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var inputGroups = this.getInputGroupsInSection(node); var inputs = void 0; if (resolving) { inputs = { inputs: {}, i...
javascript
function getInputsInSection(node) { var resolving = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var inputGroups = this.getInputGroupsInSection(node); var inputs = void 0; if (resolving) { inputs = { inputs: {}, i...
[ "function", "getInputsInSection", "(", "node", ")", "{", "var", "resolving", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "false", ";", "var", "inputGroups", "=", ...
Find inputs in section @meta if second argument true - return object with meta information to use during promise resolving @param {HTMLElement} node @param {boolean} resolving = false @returns {Array|Object}
[ "Find", "inputs", "in", "section" ]
90bea09545288e0f050b5c2a5f72c0ed7252b98e
https://github.com/Mevrael/bunny/blob/90bea09545288e0f050b5c2a5f72c0ed7252b98e/examples/validation/dist/index.js#L1485-L1519
train
L33T-KR3W/push-dir
index.js
getCurrentBranch
function getCurrentBranch(verbose) { return Promise.resolve() .then(execCmd.bind(null, 'git', ['symbolic-ref', 'HEAD', '-q'], 'problem getting current branch', verbose )) .catch(function() { return ''; }) .then(function(result) { return result.replace(new RegExp...
javascript
function getCurrentBranch(verbose) { return Promise.resolve() .then(execCmd.bind(null, 'git', ['symbolic-ref', 'HEAD', '-q'], 'problem getting current branch', verbose )) .catch(function() { return ''; }) .then(function(result) { return result.replace(new RegExp...
[ "function", "getCurrentBranch", "(", "verbose", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "execCmd", ".", "bind", "(", "null", ",", "'git'", ",", "[", "'symbolic-ref'", ",", "'HEAD'", ",", "'-q'", "]", ",", "'problem gett...
Returns name of current branch or empty string if detached HEAD @return {string} - name of current branch
[ "Returns", "name", "of", "current", "branch", "or", "empty", "string", "if", "detached", "HEAD" ]
a708b3c95a4fd4698ee0a4dc91090ca2796ae174
https://github.com/L33T-KR3W/push-dir/blob/a708b3c95a4fd4698ee0a4dc91090ca2796ae174/index.js#L66-L80
train
Nhogs/popoto
src/graph/util/appendFittedText.js
computeTextRadius
function computeTextRadius(lines) { var textRadius = 0; for (var i = 0, n = lines.length; i < n; ++i) { var dx = lines[i].width / 2; var dy = (Math.abs(i - n / 2 + 0.5) + 0.5) * DEFAULT_CANVAS_LINE_HEIGHT; textRadius = Math.max(textRadius, Math.sqrt(dx * dx + dy * dy)); } retur...
javascript
function computeTextRadius(lines) { var textRadius = 0; for (var i = 0, n = lines.length; i < n; ++i) { var dx = lines[i].width / 2; var dy = (Math.abs(i - n / 2 + 0.5) + 0.5) * DEFAULT_CANVAS_LINE_HEIGHT; textRadius = Math.max(textRadius, Math.sqrt(dx * dx + dy * dy)); } retur...
[ "function", "computeTextRadius", "(", "lines", ")", "{", "var", "textRadius", "=", "0", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "lines", ".", "length", ";", "i", "<", "n", ";", "++", "i", ")", "{", "var", "dx", "=", "lines", "[", ...
Compute the radius of the circle wrapping all the lines. @param lines array of text lines @return {number}
[ "Compute", "the", "radius", "of", "the", "circle", "wrapping", "all", "the", "lines", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/graph/util/appendFittedText.js#L17-L27
train
Nhogs/popoto
src/graph/util/appendFittedText.js
computeWords
function computeWords(text) { var words = text.split(/\s+/g); // To hyphenate: /\s+|(?<=-)/ if (!words[words.length - 1]) words.pop(); if (!words[0]) words.shift(); return words; }
javascript
function computeWords(text) { var words = text.split(/\s+/g); // To hyphenate: /\s+|(?<=-)/ if (!words[words.length - 1]) words.pop(); if (!words[0]) words.shift(); return words; }
[ "function", "computeWords", "(", "text", ")", "{", "var", "words", "=", "text", ".", "split", "(", "/", "\\s+", "/", "g", ")", ";", "// To hyphenate: /\\s+|(?<=-)/", "if", "(", "!", "words", "[", "words", ".", "length", "-", "1", "]", ")", "words", "...
Split text into words. @param text @return {*|string[]}
[ "Split", "text", "into", "words", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/graph/util/appendFittedText.js#L60-L65
train
Nhogs/popoto
src/popoto.js
checkHtmlComponents
function checkHtmlComponents() { var graphHTMLContainer = d3.select("#" + graph.containerId); var taxonomyHTMLContainer = d3.select("#" + taxonomy.containerId); var queryHTMLContainer = d3.select("#" + queryviewer.containerId); var cypherHTMLContainer = d3.select("#" + cypherviewer.containerId); var...
javascript
function checkHtmlComponents() { var graphHTMLContainer = d3.select("#" + graph.containerId); var taxonomyHTMLContainer = d3.select("#" + taxonomy.containerId); var queryHTMLContainer = d3.select("#" + queryviewer.containerId); var cypherHTMLContainer = d3.select("#" + cypherviewer.containerId); var...
[ "function", "checkHtmlComponents", "(", ")", "{", "var", "graphHTMLContainer", "=", "d3", ".", "select", "(", "\"#\"", "+", "graph", ".", "containerId", ")", ";", "var", "taxonomyHTMLContainer", "=", "d3", ".", "select", "(", "\"#\"", "+", "taxonomy", ".", ...
Check in the HTML page the components to generate.
[ "Check", "in", "the", "HTML", "page", "the", "components", "to", "generate", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/popoto.js#L70-L111
train
Nhogs/popoto
src/provider/provider.js
function (link) { if (link.type === graph.link.LinkTypes.VALUE) { // Links between node and list of values. if (provider.node.isTextDisplayed(link.target)) { // Don't display text on link if text is displayed on target node. return ""; } else ...
javascript
function (link) { if (link.type === graph.link.LinkTypes.VALUE) { // Links between node and list of values. if (provider.node.isTextDisplayed(link.target)) { // Don't display text on link if text is displayed on target node. return ""; } else ...
[ "function", "(", "link", ")", "{", "if", "(", "link", ".", "type", "===", "graph", ".", "link", ".", "LinkTypes", ".", "VALUE", ")", "{", "// Links between node and list of values.", "if", "(", "provider", ".", "node", ".", "isTextDisplayed", "(", "link", ...
Function used to return the text representation of a link. The default behavior is to return the internal relation name as text for relation links. And return the target node text value for links between a node and its expanded values but only if text is not displayed on value node. @param link the link to represent ...
[ "Function", "used", "to", "return", "the", "text", "representation", "of", "a", "link", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L130-L149
train
Nhogs/popoto
src/provider/provider.js
function (link, element, attribute) { if (link.type === graph.link.LinkTypes.VALUE) { return "#525863"; } else { var colorId = link.source.label + link.label + link.target.label; var color = provider.colorScale(colorId); if (attribute === "stroke") { ...
javascript
function (link, element, attribute) { if (link.type === graph.link.LinkTypes.VALUE) { return "#525863"; } else { var colorId = link.source.label + link.label + link.target.label; var color = provider.colorScale(colorId); if (attribute === "stroke") { ...
[ "function", "(", "link", ",", "element", ",", "attribute", ")", "{", "if", "(", "link", ".", "type", "===", "graph", ".", "link", ".", "LinkTypes", ".", "VALUE", ")", "{", "return", "\"#525863\"", ";", "}", "else", "{", "var", "colorId", "=", "link",...
Return the color to use on links and relation donut segments. Return null or undefined @param link @param element @param attribute @return {*}
[ "Return", "the", "color", "to", "use", "on", "links", "and", "relation", "donut", "segments", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L174-L186
train
Nhogs/popoto
src/provider/provider.js
function (node) { if (node.type === graph.node.NodeTypes.VALUE) { return provider.node.getColor(node.parent); } else { var parentLabel = ""; if (node.hasOwnProperty("parent")) { parentLabel = node.parent.label } ...
javascript
function (node) { if (node.type === graph.node.NodeTypes.VALUE) { return provider.node.getColor(node.parent); } else { var parentLabel = ""; if (node.hasOwnProperty("parent")) { parentLabel = node.parent.label } ...
[ "function", "(", "node", ")", "{", "if", "(", "node", ".", "type", "===", "graph", ".", "node", ".", "NodeTypes", ".", "VALUE", ")", "{", "return", "provider", ".", "node", ".", "getColor", "(", "node", ".", "parent", ")", ";", "}", "else", "{", ...
Return a color for the node. @param node @returns {*}
[ "Return", "a", "color", "for", "the", "node", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L927-L941
train
Nhogs/popoto
src/provider/provider.js
function (node, element) { var labelAsCSSName = node.label.replace(/[^0-9a-z\-_]/gi, ''); var cssClass = "ppt-node__" + element; if (node.type === graph.node.NodeTypes.ROOT) { cssClass = cssClass + "--root"; } if (node.type === graph.node.Nod...
javascript
function (node, element) { var labelAsCSSName = node.label.replace(/[^0-9a-z\-_]/gi, ''); var cssClass = "ppt-node__" + element; if (node.type === graph.node.NodeTypes.ROOT) { cssClass = cssClass + "--root"; } if (node.type === graph.node.Nod...
[ "function", "(", "node", ",", "element", ")", "{", "var", "labelAsCSSName", "=", "node", ".", "label", ".", "replace", "(", "/", "[^0-9a-z\\-_]", "/", "gi", ",", "''", ")", ";", "var", "cssClass", "=", "\"ppt-node__\"", "+", "element", ";", "if", "(", ...
Generate a CSS class for the node depending on its type. @param node @param element @return {string}
[ "Generate", "a", "CSS", "class", "for", "the", "node", "depending", "on", "its", "type", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L950-L975
train
Nhogs/popoto
src/provider/provider.js
function (node) { var text = ""; var displayAttr = provider.node.getDisplayAttribute(node.label); if (node.type === graph.node.NodeTypes.VALUE) { if (displayAttr === query.NEO4J_INTERNAL_ID) { text = "" + node.internalID; } else { ...
javascript
function (node) { var text = ""; var displayAttr = provider.node.getDisplayAttribute(node.label); if (node.type === graph.node.NodeTypes.VALUE) { if (displayAttr === query.NEO4J_INTERNAL_ID) { text = "" + node.internalID; } else { ...
[ "function", "(", "node", ")", "{", "var", "text", "=", "\"\"", ";", "var", "displayAttr", "=", "provider", ".", "node", ".", "getDisplayAttribute", "(", "node", ".", "label", ")", ";", "if", "(", "node", ".", "type", "===", "graph", ".", "node", ".",...
Function used to return a descriptive text representation of a link. This representation should be more complete than getTextValue and can contain semantic data. This function is used for example to generate the label in the query viewer. The default behavior is to return the getTextValue not truncated. @param node t...
[ "Function", "used", "to", "return", "a", "descriptive", "text", "representation", "of", "a", "link", ".", "This", "representation", "should", "be", "more", "complete", "than", "getTextValue", "and", "can", "contain", "semantic", "data", ".", "This", "function", ...
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L1066-L1095
train
Nhogs/popoto
src/provider/provider.js
function (node) { var size = provider.node.getSize(node); return [ { "d": "M 0, 0 m -" + size + ", 0 a " + size + "," + size + " 0 1,0 " + 2 * size + ",0 a " + size + "," + size + " 0 1,0 -" + 2 * size + ",0", "fill": "transparent", ...
javascript
function (node) { var size = provider.node.getSize(node); return [ { "d": "M 0, 0 m -" + size + ", 0 a " + size + "," + size + " 0 1,0 " + 2 * size + ",0 a " + size + "," + size + " 0 1,0 -" + 2 * size + ",0", "fill": "transparent", ...
[ "function", "(", "node", ")", "{", "var", "size", "=", "provider", ".", "node", ".", "getSize", "(", "node", ")", ";", "return", "[", "{", "\"d\"", ":", "\"M 0, 0 m -\"", "+", "size", "+", "\", 0 a \"", "+", "size", "+", "\",\"", "+", "size", "+", ...
Function returning a array of path objects to display in the node. @param node @returns {*[]}
[ "Function", "returning", "a", "array", "of", "path", "objects", "to", "display", "in", "the", "node", "." ]
1dbed2f0e0c999a75c786d4955f14e3fe2ace47b
https://github.com/Nhogs/popoto/blob/1dbed2f0e0c999a75c786d4955f14e3fe2ace47b/src/provider/provider.js#L1120-L1130
train
ampproject/animations
docs/demo/lightbox/index.js
getTransitionContainer
function getTransitionContainer(show) { if (document.body.scrollHeight <= window.innerHeight) { return lightboxTransitionContainer; } return document.body; }
javascript
function getTransitionContainer(show) { if (document.body.scrollHeight <= window.innerHeight) { return lightboxTransitionContainer; } return document.body; }
[ "function", "getTransitionContainer", "(", "show", ")", "{", "if", "(", "document", ".", "body", ".", "scrollHeight", "<=", "window", ".", "innerHeight", ")", "{", "return", "lightboxTransitionContainer", ";", "}", "return", "document", ".", "body", ";", "}" ]
Gets the container to do the transition in. This is either the body or a fixed position container, depending on if the body has overflow or not. This is needed as doing the transition with position absolute can cause overflow, causing the scrollbars to show up during the animation. Depending on the OS, this can cause ...
[ "Gets", "the", "container", "to", "do", "the", "transition", "in", ".", "This", "is", "either", "the", "body", "or", "a", "fixed", "position", "container", "depending", "on", "if", "the", "body", "has", "overflow", "or", "not", "." ]
03fd1132095e8e60234280d4adccf05366bab58f
https://github.com/ampproject/animations/blob/03fd1132095e8e60234280d4adccf05366bab58f/docs/demo/lightbox/index.js#L49-L55
train
ampproject/animations
docs/demo/gallery/index.js
loadLargerImgSrc
function loadLargerImgSrc(img, largerSize) { if (img._preloaded) { return; } const dummyImg = new Image(); dummyImg.srcset = img.srcset; dummyImg.sizes = largerSize; img._preloaded = true; }
javascript
function loadLargerImgSrc(img, largerSize) { if (img._preloaded) { return; } const dummyImg = new Image(); dummyImg.srcset = img.srcset; dummyImg.sizes = largerSize; img._preloaded = true; }
[ "function", "loadLargerImgSrc", "(", "img", ",", "largerSize", ")", "{", "if", "(", "img", ".", "_preloaded", ")", "{", "return", ";", "}", "const", "dummyImg", "=", "new", "Image", "(", ")", ";", "dummyImg", ".", "srcset", "=", "img", ".", "srcset", ...
Loads an img using a srcset, with a larger `size` value. This does not actually set the `size` attribute on the img.
[ "Loads", "an", "img", "using", "a", "srcset", "with", "a", "larger", "size", "value", ".", "This", "does", "not", "actually", "set", "the", "size", "attribute", "on", "the", "img", "." ]
03fd1132095e8e60234280d4adccf05366bab58f
https://github.com/ampproject/animations/blob/03fd1132095e8e60234280d4adccf05366bab58f/docs/demo/gallery/index.js#L36-L46
train
mourner/flatbush
index.js
upperBound
function upperBound(value, arr) { let i = 0; let j = arr.length - 1; while (i < j) { const m = (i + j) >> 1; if (arr[m] > value) { j = m; } else { i = m + 1; } } return arr[i]; }
javascript
function upperBound(value, arr) { let i = 0; let j = arr.length - 1; while (i < j) { const m = (i + j) >> 1; if (arr[m] > value) { j = m; } else { i = m + 1; } } return arr[i]; }
[ "function", "upperBound", "(", "value", ",", "arr", ")", "{", "let", "i", "=", "0", ";", "let", "j", "=", "arr", ".", "length", "-", "1", ";", "while", "(", "i", "<", "j", ")", "{", "const", "m", "=", "(", "i", "+", "j", ")", ">>", "1", "...
binary search for the first value in the array bigger than the given
[ "binary", "search", "for", "the", "first", "value", "in", "the", "array", "bigger", "than", "the", "given" ]
65a01d9fe60b643ae6b6728a839a07c845fc0cd9
https://github.com/mourner/flatbush/blob/65a01d9fe60b643ae6b6728a839a07c845fc0cd9/index.js#L263-L275
train
mourner/flatbush
index.js
sort
function sort(values, boxes, indices, left, right) { if (left >= right) return; const pivot = values[(left + right) >> 1]; let i = left - 1; let j = right + 1; while (true) { do i++; while (values[i] < pivot); do j--; while (values[j] > pivot); if (i >= j) break; sw...
javascript
function sort(values, boxes, indices, left, right) { if (left >= right) return; const pivot = values[(left + right) >> 1]; let i = left - 1; let j = right + 1; while (true) { do i++; while (values[i] < pivot); do j--; while (values[j] > pivot); if (i >= j) break; sw...
[ "function", "sort", "(", "values", ",", "boxes", ",", "indices", ",", "left", ",", "right", ")", "{", "if", "(", "left", ">=", "right", ")", "return", ";", "const", "pivot", "=", "values", "[", "(", "left", "+", "right", ")", ">>", "1", "]", ";",...
custom quicksort that sorts bbox data alongside the hilbert values
[ "custom", "quicksort", "that", "sorts", "bbox", "data", "alongside", "the", "hilbert", "values" ]
65a01d9fe60b643ae6b6728a839a07c845fc0cd9
https://github.com/mourner/flatbush/blob/65a01d9fe60b643ae6b6728a839a07c845fc0cd9/index.js#L278-L294
train
mourner/flatbush
index.js
swap
function swap(values, boxes, indices, i, j) { const temp = values[i]; values[i] = values[j]; values[j] = temp; const k = 4 * i; const m = 4 * j; const a = boxes[k]; const b = boxes[k + 1]; const c = boxes[k + 2]; const d = boxes[k + 3]; boxes[k] = boxes[m]; boxes[k + 1] = b...
javascript
function swap(values, boxes, indices, i, j) { const temp = values[i]; values[i] = values[j]; values[j] = temp; const k = 4 * i; const m = 4 * j; const a = boxes[k]; const b = boxes[k + 1]; const c = boxes[k + 2]; const d = boxes[k + 3]; boxes[k] = boxes[m]; boxes[k + 1] = b...
[ "function", "swap", "(", "values", ",", "boxes", ",", "indices", ",", "i", ",", "j", ")", "{", "const", "temp", "=", "values", "[", "i", "]", ";", "values", "[", "i", "]", "=", "values", "[", "j", "]", ";", "values", "[", "j", "]", "=", "temp...
swap two values and two corresponding boxes
[ "swap", "two", "values", "and", "two", "corresponding", "boxes" ]
65a01d9fe60b643ae6b6728a839a07c845fc0cd9
https://github.com/mourner/flatbush/blob/65a01d9fe60b643ae6b6728a839a07c845fc0cd9/index.js#L297-L321
train
boilerplates/scaffold
index.js
Scaffold
function Scaffold(options) { if (!(this instanceof Scaffold)) { return new Scaffold(options); } Base.call(this); this.use(utils.plugins()); this.is('scaffold'); options = options || {}; this.options = options; this.targets = {}; if (Scaffold.isScaffold(options)) { this.options = {}; fow...
javascript
function Scaffold(options) { if (!(this instanceof Scaffold)) { return new Scaffold(options); } Base.call(this); this.use(utils.plugins()); this.is('scaffold'); options = options || {}; this.options = options; this.targets = {}; if (Scaffold.isScaffold(options)) { this.options = {}; fow...
[ "function", "Scaffold", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Scaffold", ")", ")", "{", "return", "new", "Scaffold", "(", "options", ")", ";", "}", "Base", ".", "call", "(", "this", ")", ";", "this", ".", "use", "(",...
Create a new Scaffold with the given `options` ```js var scaffold = new Scaffold({cwd: 'src'}); scaffold.addTargets({ site: {src: ['*.hbs']}, blog: {src: ['*.md']} }); ``` @param {Object} `options` @api public
[ "Create", "a", "new", "Scaffold", "with", "the", "given", "options" ]
baa526928d0f7e0bcae266fbaa6174ddf4007a66
https://github.com/boilerplates/scaffold/blob/baa526928d0f7e0bcae266fbaa6174ddf4007a66/index.js#L28-L49
train
boilerplates/scaffold
index.js
foward
function foward(app, options) { if (typeof options.name === 'string') { app.name = options.name; delete options.name; } Scaffold.emit('scaffold', app); emit('target', app, Scaffold); emit('files', app, Scaffold); }
javascript
function foward(app, options) { if (typeof options.name === 'string') { app.name = options.name; delete options.name; } Scaffold.emit('scaffold', app); emit('target', app, Scaffold); emit('files', app, Scaffold); }
[ "function", "foward", "(", "app", ",", "options", ")", "{", "if", "(", "typeof", "options", ".", "name", "===", "'string'", ")", "{", "app", ".", "name", "=", "options", ".", "name", ";", "delete", "options", ".", "name", ";", "}", "Scaffold", ".", ...
Forward events from the scaffold instance to the `Scaffold` constructor
[ "Forward", "events", "from", "the", "scaffold", "instance", "to", "the", "Scaffold", "constructor" ]
baa526928d0f7e0bcae266fbaa6174ddf4007a66
https://github.com/boilerplates/scaffold/blob/baa526928d0f7e0bcae266fbaa6174ddf4007a66/index.js#L241-L249
train
boilerplates/scaffold
index.js
emit
function emit(name, a, b) { a.on(name, b.emit.bind(b, name)); }
javascript
function emit(name, a, b) { a.on(name, b.emit.bind(b, name)); }
[ "function", "emit", "(", "name", ",", "a", ",", "b", ")", "{", "a", ".", "on", "(", "name", ",", "b", ".", "emit", ".", "bind", "(", "b", ",", "name", ")", ")", ";", "}" ]
Forward events from emitter `a` to emitter `b`
[ "Forward", "events", "from", "emitter", "a", "to", "emitter", "b" ]
baa526928d0f7e0bcae266fbaa6174ddf4007a66
https://github.com/boilerplates/scaffold/blob/baa526928d0f7e0bcae266fbaa6174ddf4007a66/index.js#L255-L257
train
GoogleChrome/inert-polyfill
suite.js
sendTab
function sendTab(opt_shiftKey) { var ev = null; try { ev = new KeyboardEvent('keydown', { keyCode: 9, which: 9, key: 'Tab', code: 'Tab', keyIdentifier: 'U+0009', shiftKey: !!opt_shiftKey, bubbles: true }); } catch (e) { try { ...
javascript
function sendTab(opt_shiftKey) { var ev = null; try { ev = new KeyboardEvent('keydown', { keyCode: 9, which: 9, key: 'Tab', code: 'Tab', keyIdentifier: 'U+0009', shiftKey: !!opt_shiftKey, bubbles: true }); } catch (e) { try { ...
[ "function", "sendTab", "(", "opt_shiftKey", ")", "{", "var", "ev", "=", "null", ";", "try", "{", "ev", "=", "new", "KeyboardEvent", "(", "'keydown'", ",", "{", "keyCode", ":", "9", ",", "which", ":", "9", ",", "key", ":", "'Tab'", ",", "code", ":",...
Sends a tab event on this document. Note that this is a copy of dispatchTabEvent from the polyfill source. @param {boolean=} opt_shiftKey whether to send this tab with shiftKey
[ "Sends", "a", "tab", "event", "on", "this", "document", ".", "Note", "that", "this", "is", "a", "copy", "of", "dispatchTabEvent", "from", "the", "polyfill", "source", "." ]
d307e9a64e3c8efaacf8fbe2efbdde8bbdf7a5e6
https://github.com/GoogleChrome/inert-polyfill/blob/d307e9a64e3c8efaacf8fbe2efbdde8bbdf7a5e6/suite.js#L26-L61
train
plepers/nanogl
program.js
function( vert, frag, prefix ){ this.ready = false; prefix = ( prefix === undefined ) ? '' : prefix+'\n'; var gl = this.gl; if( !( compileShader( gl, this.fShader, prefix + frag ) && compileShader( gl, this.vShader, prefix + vert ) ) ) { return false; } gl.linkProgram(this...
javascript
function( vert, frag, prefix ){ this.ready = false; prefix = ( prefix === undefined ) ? '' : prefix+'\n'; var gl = this.gl; if( !( compileShader( gl, this.fShader, prefix + frag ) && compileShader( gl, this.vShader, prefix + vert ) ) ) { return false; } gl.linkProgram(this...
[ "function", "(", "vert", ",", "frag", ",", "prefix", ")", "{", "this", ".", "ready", "=", "false", ";", "prefix", "=", "(", "prefix", "===", "undefined", ")", "?", "''", ":", "prefix", "+", "'\\n'", ";", "var", "gl", "=", "this", ".", "gl", ";", ...
Compile vertex and fragment shader then link gl program This method can be safely called several times. @param {String} vert vertex shader code @param {String} frag fragment shader code @param {String} [prefix=''] an optional string append to both fragment and vertex code
[ "Compile", "vertex", "and", "fragment", "shader", "then", "link", "gl", "program", "This", "method", "can", "be", "safely", "called", "several", "times", "." ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/program.js#L69-L96
train
plepers/nanogl
program.js
function() { if( this.gl !== null ){ this.gl.deleteProgram( this.program ); this.gl.deleteShader( this.fShader ); this.gl.deleteShader( this.vShader ); this.gl = null; } }
javascript
function() { if( this.gl !== null ){ this.gl.deleteProgram( this.program ); this.gl.deleteShader( this.fShader ); this.gl.deleteShader( this.vShader ); this.gl = null; } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "gl", "!==", "null", ")", "{", "this", ".", "gl", ".", "deleteProgram", "(", "this", ".", "program", ")", ";", "this", ".", "gl", ".", "deleteShader", "(", "this", ".", "fShader", ")", ";", "this...
Delete program and shaders
[ "Delete", "program", "and", "shaders" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/program.js#L101-L108
train
plepers/nanogl
texture.js
function( format, type, internal ){ this.format = format || this.gl.RGB; this.internal = internal || this.format; this.type = type || this.gl.UNSIGNED_BYTE; }
javascript
function( format, type, internal ){ this.format = format || this.gl.RGB; this.internal = internal || this.format; this.type = type || this.gl.UNSIGNED_BYTE; }
[ "function", "(", "format", ",", "type", ",", "internal", ")", "{", "this", ".", "format", "=", "format", "||", "this", ".", "gl", ".", "RGB", ";", "this", ".", "internal", "=", "internal", "||", "this", ".", "format", ";", "this", ".", "type", "=",...
define underlying format, internal format and data type of texture @param {GLenum} [format =GL_RGB] the pixel format, default to gl.RGB (can be gl.RGB, gl.RGBA, gl.LUMINANCE...) @param {GLenum} [type =GL_UNSIGNED_BYTE] the pixel data type, default to gl.UNSIGNED_BYTE @param {GLenum} [internal=format] the pixel inte...
[ "define", "underlying", "format", "internal", "format", "and", "data", "type", "of", "texture" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/texture.js#L50-L54
train
plepers/nanogl
texture.js
function( img ){ var gl = this.gl; this.width = img.width; this.height = img.height; gl.bindTexture( T2D, this.id ); gl.texImage2D( T2D, 0, this.internal, this.format, this.type, img ); }
javascript
function( img ){ var gl = this.gl; this.width = img.width; this.height = img.height; gl.bindTexture( T2D, this.id ); gl.texImage2D( T2D, 0, this.internal, this.format, this.type, img ); }
[ "function", "(", "img", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "this", ".", "width", "=", "img", ".", "width", ";", "this", ".", "height", "=", "img", ".", "height", ";", "gl", ".", "bindTexture", "(", "T2D", ",", "this", ".", "id"...
set texture data from html source @param {TexImageSource} img the source. Can be ImageBitmap, ImageData, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
[ "set", "texture", "data", "from", "html", "source" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/texture.js#L60-L68
train
plepers/nanogl
texture.js
function( unit ){ var gl = this.gl; if( unit !== undefined ){ gl.activeTexture( gl.TEXTURE0 + (0|unit) ); } gl.bindTexture( T2D, this.id ); }
javascript
function( unit ){ var gl = this.gl; if( unit !== undefined ){ gl.activeTexture( gl.TEXTURE0 + (0|unit) ); } gl.bindTexture( T2D, this.id ); }
[ "function", "(", "unit", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "if", "(", "unit", "!==", "undefined", ")", "{", "gl", ".", "activeTexture", "(", "gl", ".", "TEXTURE0", "+", "(", "0", "|", "unit", ")", ")", ";", "}", "gl", ".", "...
Bind the texture @param {uint} [unit=undefined] optional texture unit to make active before binding
[ "Bind", "the", "texture" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/texture.js#L93-L99
train
plepers/nanogl
arraybuffer.js
function( array ){ var gl = this.gl; gl.bindBuffer( TGT, this.buffer ); gl.bufferData( TGT, array, this.usage ); gl.bindBuffer( TGT, null ); this.byteLength = ( array.byteLength === undefined ) ? array : array.byteLength; this._computeLength(); }
javascript
function( array ){ var gl = this.gl; gl.bindBuffer( TGT, this.buffer ); gl.bufferData( TGT, array, this.usage ); gl.bindBuffer( TGT, null ); this.byteLength = ( array.byteLength === undefined ) ? array : array.byteLength; this._computeLength(); }
[ "function", "(", "array", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "gl", ".", "bindBuffer", "(", "TGT", ",", "this", ".", "buffer", ")", ";", "gl", ".", "bufferData", "(", "TGT", ",", "array", ",", "this", ".", "usage", ")", ";", "gl...
Fill webgl buffer with the given data. You can also pass a uint to allocate the buffer to the given size. @param {TypedArray|uint} array the data to send to the buffer, or a size.
[ "Fill", "webgl", "buffer", "with", "the", "given", "data", ".", "You", "can", "also", "pass", "a", "uint", "to", "allocate", "the", "buffer", "to", "the", "given", "size", "." ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/arraybuffer.js#L66-L74
train
plepers/nanogl
fbo.js
function( format, type, internal ){ var t = new Texture( this.gl, format, type, internal ); return this.attach( 0x8CE0, t ); }
javascript
function( format, type, internal ){ var t = new Texture( this.gl, format, type, internal ); return this.attach( 0x8CE0, t ); }
[ "function", "(", "format", ",", "type", ",", "internal", ")", "{", "var", "t", "=", "new", "Texture", "(", "this", ".", "gl", ",", "format", ",", "type", ",", "internal", ")", ";", "return", "this", ".", "attach", "(", "0x8CE0", ",", "t", ")", ";...
Shortcut to attach texture to color attachment 0
[ "Shortcut", "to", "attach", "texture", "to", "color", "attachment", "0" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/fbo.js#L149-L152
train
plepers/nanogl
fbo.js
function( w, h ){ if( this.width !== w || this.height !== h ) { this.width = w|0; this.height = h|0; this._allocate(); } }
javascript
function( w, h ){ if( this.width !== w || this.height !== h ) { this.width = w|0; this.height = h|0; this._allocate(); } }
[ "function", "(", "w", ",", "h", ")", "{", "if", "(", "this", ".", "width", "!==", "w", "||", "this", ".", "height", "!==", "h", ")", "{", "this", ".", "width", "=", "w", "|", "0", ";", "this", ".", "height", "=", "h", "|", "0", ";", "this",...
Resize FBO attachments @param {uint} w new width @param {uint} h new height
[ "Resize", "FBO", "attachments" ]
7cdf82ffe7bbb3121d2a999e98373832cecd112c
https://github.com/plepers/nanogl/blob/7cdf82ffe7bbb3121d2a999e98373832cecd112c/fbo.js#L185-L191
train
goddyZhao/nproxy
lib/middlewares/respond.js
_watchRuleFile
function _watchRuleFile(file, callback){ fs.watchFile(file, function(curr, prev){ log.warn('The rule file has been modified!'); callback(); }); }
javascript
function _watchRuleFile(file, callback){ fs.watchFile(file, function(curr, prev){ log.warn('The rule file has been modified!'); callback(); }); }
[ "function", "_watchRuleFile", "(", "file", ",", "callback", ")", "{", "fs", ".", "watchFile", "(", "file", ",", "function", "(", "curr", ",", "prev", ")", "{", "log", ".", "warn", "(", "'The rule file has been modified!'", ")", ";", "callback", "(", ")", ...
Watch the rule file to support applying changed rules without restart the proxy @param {String} file the path of the file @param {Function} callback
[ "Watch", "the", "rule", "file", "to", "support", "applying", "changed", "rules", "without", "restart", "the", "proxy" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/middlewares/respond.js#L174-L179
train
goddyZhao/nproxy
lib/middlewares/respond.js
_loadResponderList
function _loadResponderList(responderListFilePath){ var filePath = responderListFilePath; if(typeof filePath !== 'string'){ return null; } if(!fs.existsSync(responderListFilePath)){ throw new Error('File doesn\'t exist!'); } if(!utils.isAbsolutePath(responderListFilePath)){ filePath = path.jo...
javascript
function _loadResponderList(responderListFilePath){ var filePath = responderListFilePath; if(typeof filePath !== 'string'){ return null; } if(!fs.existsSync(responderListFilePath)){ throw new Error('File doesn\'t exist!'); } if(!utils.isAbsolutePath(responderListFilePath)){ filePath = path.jo...
[ "function", "_loadResponderList", "(", "responderListFilePath", ")", "{", "var", "filePath", "=", "responderListFilePath", ";", "if", "(", "typeof", "filePath", "!==", "'string'", ")", "{", "return", "null", ";", "}", "if", "(", "!", "fs", ".", "existsSync", ...
Load the list file and return the list object @param {String} responderListFilePath @return {Array} responder list @api private
[ "Load", "the", "list", "file", "and", "return", "the", "list", "object" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/middlewares/respond.js#L189-L205
train
goddyZhao/nproxy
lib/middlewares/respond.js
_loadFile
function _loadFile(filename){ var module = require(filename); delete require.cache[require.resolve(filename)]; return module; }
javascript
function _loadFile(filename){ var module = require(filename); delete require.cache[require.resolve(filename)]; return module; }
[ "function", "_loadFile", "(", "filename", ")", "{", "var", "module", "=", "require", "(", "filename", ")", ";", "delete", "require", ".", "cache", "[", "require", ".", "resolve", "(", "filename", ")", "]", ";", "return", "module", ";", "}" ]
Load file without cache @return {Array} load list from a file
[ "Load", "file", "without", "cache" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/middlewares/respond.js#L212-L216
train
goddyZhao/nproxy
lib/nproxy.js
nproxy
function nproxy(port, options){ var nm; if(typeof options.timeout === 'number'){ utils.reqTimeout = options.timeout; utils.resTimeout = options.timeout; } if(typeof options.debug === 'boolean'){ log.isDebug = options.debug; } nm = require('./middlewares'); //nproxy middles port = typeof po...
javascript
function nproxy(port, options){ var nm; if(typeof options.timeout === 'number'){ utils.reqTimeout = options.timeout; utils.resTimeout = options.timeout; } if(typeof options.debug === 'boolean'){ log.isDebug = options.debug; } nm = require('./middlewares'); //nproxy middles port = typeof po...
[ "function", "nproxy", "(", "port", ",", "options", ")", "{", "var", "nm", ";", "if", "(", "typeof", "options", ".", "timeout", "===", "'number'", ")", "{", "utils", ".", "reqTimeout", "=", "options", ".", "timeout", ";", "utils", ".", "resTimeout", "="...
Start up nproxy server on the specified port and combine the processors defined as connect middlewares into it. @param {String} port the port proxy server will listen on @param {Object} options options for the middlewares
[ "Start", "up", "nproxy", "server", "on", "the", "specified", "port", "and", "combine", "the", "processors", "defined", "as", "connect", "middlewares", "into", "it", "." ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/nproxy.js#L30-L75
train
goddyZhao/nproxy
lib/nproxy.js
proxyHttps
function proxyHttps(){ httpServer.on('connect', function(req, socket, upgradeHead){ var hostname = req.url.split(':')[0]; log.debug('Create internal https server for ' + hostname); createInternalHttpsServer(hostname, function (err, httpsServerPort) { if (err) { log.error('Failed to create in...
javascript
function proxyHttps(){ httpServer.on('connect', function(req, socket, upgradeHead){ var hostname = req.url.split(':')[0]; log.debug('Create internal https server for ' + hostname); createInternalHttpsServer(hostname, function (err, httpsServerPort) { if (err) { log.error('Failed to create in...
[ "function", "proxyHttps", "(", ")", "{", "httpServer", ".", "on", "(", "'connect'", ",", "function", "(", "req", ",", "socket", ",", "upgradeHead", ")", "{", "var", "hostname", "=", "req", ".", "url", ".", "split", "(", "':'", ")", "[", "0", "]", "...
Listen the CONNECTION method and forward the https request to internal https server
[ "Listen", "the", "CONNECTION", "method", "and", "forward", "the", "https", "request", "to", "internal", "https", "server" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/nproxy.js#L120-L167
train
goddyZhao/nproxy
lib/agent.js
getAgentByUrl
function getAgentByUrl (requestUrl) { if (!requestUrl) { return null; } var parsedRequestUrl = url.parse(requestUrl); var proxyUrl = getSystemProxyByUrl(parsedRequestUrl); if (!proxyUrl) { log.debug('No system proxy'); return null; } log.debug('Detect system proxy Url: ' + proxyUrl); var pa...
javascript
function getAgentByUrl (requestUrl) { if (!requestUrl) { return null; } var parsedRequestUrl = url.parse(requestUrl); var proxyUrl = getSystemProxyByUrl(parsedRequestUrl); if (!proxyUrl) { log.debug('No system proxy'); return null; } log.debug('Detect system proxy Url: ' + proxyUrl); var pa...
[ "function", "getAgentByUrl", "(", "requestUrl", ")", "{", "if", "(", "!", "requestUrl", ")", "{", "return", "null", ";", "}", "var", "parsedRequestUrl", "=", "url", ".", "parse", "(", "requestUrl", ")", ";", "var", "proxyUrl", "=", "getSystemProxyByUrl", "...
Get agent only if it has system proxy
[ "Get", "agent", "only", "if", "it", "has", "system", "proxy" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/agent.js#L40-L59
train
goddyZhao/nproxy
lib/cert.js
_checkRootCA
function _checkRootCA () { var caKeyFilePath = path.join(certDir, 'ca.key'); var caCrtFilePath = path.join(certDir, 'ca.crt'); var keysDir = path.join(__dirname, '..', 'keys'); if (!fs.existsSync(caKeyFilePath) || !fs.existsSync(caCrtFilePath)) { log.debug('CA files do not exist'); log.debug('Copy CA ...
javascript
function _checkRootCA () { var caKeyFilePath = path.join(certDir, 'ca.key'); var caCrtFilePath = path.join(certDir, 'ca.crt'); var keysDir = path.join(__dirname, '..', 'keys'); if (!fs.existsSync(caKeyFilePath) || !fs.existsSync(caCrtFilePath)) { log.debug('CA files do not exist'); log.debug('Copy CA ...
[ "function", "_checkRootCA", "(", ")", "{", "var", "caKeyFilePath", "=", "path", ".", "join", "(", "certDir", ",", "'ca.key'", ")", ";", "var", "caCrtFilePath", "=", "path", ".", "join", "(", "certDir", ",", "'ca.crt'", ")", ";", "var", "keysDir", "=", ...
Check the ca files Copy them if they does not exist
[ "Check", "the", "ca", "files" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/cert.js#L64-L76
train
goddyZhao/nproxy
lib/middlewares/forward.js
forward
function forward(){ return function forward(req, res, next){ var url = utils.processUrl(req); var options = { url: url, method: req.method, headers: req.headers } var buffers = []; log.debug('forward: ' + url); if(req.method === 'POST'){ req.on('data', function(c...
javascript
function forward(){ return function forward(req, res, next){ var url = utils.processUrl(req); var options = { url: url, method: req.method, headers: req.headers } var buffers = []; log.debug('forward: ' + url); if(req.method === 'POST'){ req.on('data', function(c...
[ "function", "forward", "(", ")", "{", "return", "function", "forward", "(", "req", ",", "res", ",", "next", ")", "{", "var", "url", "=", "utils", ".", "processUrl", "(", "req", ")", ";", "var", "options", "=", "{", "url", ":", "url", ",", "method",...
Forward the request directly
[ "Forward", "the", "request", "directly" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/middlewares/forward.js#L8-L37
train
goddyZhao/nproxy
lib/middlewares/responders/combo.js
respondFromCombo
function respondFromCombo(options, req, res, next){ var dir; var src; if(typeof options !== 'object' || typeof options === null){ log.warn('Options are invalid when responding from combo!'); next(); } dir = typeof options.dir === 'undefined' ? null : options.dir; src = Array.isArray(options.src) ?...
javascript
function respondFromCombo(options, req, res, next){ var dir; var src; if(typeof options !== 'object' || typeof options === null){ log.warn('Options are invalid when responding from combo!'); next(); } dir = typeof options.dir === 'undefined' ? null : options.dir; src = Array.isArray(options.src) ?...
[ "function", "respondFromCombo", "(", "options", ",", "req", ",", "res", ",", "next", ")", "{", "var", "dir", ";", "var", "src", ";", "if", "(", "typeof", "options", "!==", "'object'", "||", "typeof", "options", "===", "null", ")", "{", "log", ".", "w...
respond the request following the algorithm 1. Read the file content according to the configured src list 2. Concat them into a file 3. Respond the file to the request @param {Object} options dir and source file lists {dir: String, src: Array} @param {Object} req request @param {Object} res response @param {Object} n...
[ "respond", "the", "request", "following", "the", "algorithm" ]
e0af30c0edb7adc6e611ea90428d0f83d175d50d
https://github.com/goddyZhao/nproxy/blob/e0af30c0edb7adc6e611ea90428d0f83d175d50d/lib/middlewares/responders/combo.js#L20-L58
train
expressjs/response-time
index.js
responseTime
function responseTime (options) { var opts = options || {} if (typeof options === 'number') { // back-compat single number argument deprecate('number argument: use {digits: ' + JSON.stringify(options) + '} instead') opts = { digits: options } } // get the function to invoke var fn = typeof opts ...
javascript
function responseTime (options) { var opts = options || {} if (typeof options === 'number') { // back-compat single number argument deprecate('number argument: use {digits: ' + JSON.stringify(options) + '} instead') opts = { digits: options } } // get the function to invoke var fn = typeof opts ...
[ "function", "responseTime", "(", "options", ")", "{", "var", "opts", "=", "options", "||", "{", "}", "if", "(", "typeof", "options", "===", "'number'", ")", "{", "// back-compat single number argument", "deprecate", "(", "'number argument: use {digits: '", "+", "J...
Create a middleware to add a `X-Response-Time` header displaying the response duration in milliseconds. @param {object|function} [options] @param {number} [options.digits=3] @param {string} [options.header=X-Response-Time] @param {boolean} [options.suffix=true] @return {function} @public
[ "Create", "a", "middleware", "to", "add", "a", "X", "-", "Response", "-", "Time", "header", "displaying", "the", "response", "duration", "in", "milliseconds", "." ]
5b396e3c87420bdc5a1bd283495de54d4ded4abf
https://github.com/expressjs/response-time/blob/5b396e3c87420bdc5a1bd283495de54d4ded4abf/index.js#L38-L64
train