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
adaltas/node-nikita
packages/core/lib/misc/ini.js
function(obj, section, options = {}) { var children, dotSplit, out, safe; if (arguments.length === 2) { options = section; section = void 0; } if (options.separator == null) { options.separator = ' = '; } if (options.eol == null) { options.eol = !options.ssh && process.pl...
javascript
function(obj, section, options = {}) { var children, dotSplit, out, safe; if (arguments.length === 2) { options = section; section = void 0; } if (options.separator == null) { options.separator = ' = '; } if (options.eol == null) { options.eol = !options.ssh && process.pl...
[ "function", "(", "obj", ",", "section", ",", "options", "=", "{", "}", ")", "{", "var", "children", ",", "dotSplit", ",", "out", ",", "safe", ";", "if", "(", "arguments", ".", "length", "===", "2", ")", "{", "options", "=", "section", ";", "section...
same as ini parse but transform value which are true and type of true as '' to be user by stringify_single_key
[ "same", "as", "ini", "parse", "but", "transform", "value", "which", "are", "true", "and", "type", "of", "true", "as", "to", "be", "user", "by", "stringify_single_key" ]
35c4b249da7f3fe3550f1679989d7795969fe6a6
https://github.com/adaltas/node-nikita/blob/35c4b249da7f3fe3550f1679989d7795969fe6a6/packages/core/lib/misc/ini.js#L262-L315
train
proj4js/mgrs
mgrs.js
encode
function encode(utm, accuracy) { // prepend with leading zeroes const seasting = '00000' + utm.easting, snorthing = '00000' + utm.northing; return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthi...
javascript
function encode(utm, accuracy) { // prepend with leading zeroes const seasting = '00000' + utm.easting, snorthing = '00000' + utm.northing; return utm.zoneNumber + utm.zoneLetter + get100kID(utm.easting, utm.northing, utm.zoneNumber) + seasting.substr(seasting.length - 5, accuracy) + snorthing.substr(snorthi...
[ "function", "encode", "(", "utm", ",", "accuracy", ")", "{", "// prepend with leading zeroes", "const", "seasting", "=", "'00000'", "+", "utm", ".", "easting", ",", "snorthing", "=", "'00000'", "+", "utm", ".", "northing", ";", "return", "utm", ".", "zoneNum...
Encodes a UTM location as MGRS string. @private @param {object} utm An object literal with easting, northing, zoneLetter, zoneNumber @param {number} accuracy Accuracy in digits (1-5). @return {string} MGRS string for the given UTM location.
[ "Encodes", "a", "UTM", "location", "as", "MGRS", "string", "." ]
1780ee78d247425ea73ddb2730849c54bae9f34c
https://github.com/proj4js/mgrs/blob/1780ee78d247425ea73ddb2730849c54bae9f34c/mgrs.js#L327-L333
train
proj4js/mgrs
mgrs.js
get100kID
function get100kID(easting, northing, zoneNumber) { const setParm = get100kSetForZone(zoneNumber); const setColumn = Math.floor(easting / 100000); const setRow = Math.floor(northing / 100000) % 20; return getLetter100kID(setColumn, setRow, setParm); }
javascript
function get100kID(easting, northing, zoneNumber) { const setParm = get100kSetForZone(zoneNumber); const setColumn = Math.floor(easting / 100000); const setRow = Math.floor(northing / 100000) % 20; return getLetter100kID(setColumn, setRow, setParm); }
[ "function", "get100kID", "(", "easting", ",", "northing", ",", "zoneNumber", ")", "{", "const", "setParm", "=", "get100kSetForZone", "(", "zoneNumber", ")", ";", "const", "setColumn", "=", "Math", ".", "floor", "(", "easting", "/", "100000", ")", ";", "con...
Get the two letter 100k designator for a given UTM easting, northing and zone number value. @private @param {number} easting @param {number} northing @param {number} zoneNumber @return {string} the two letter 100k designator for the given UTM location.
[ "Get", "the", "two", "letter", "100k", "designator", "for", "a", "given", "UTM", "easting", "northing", "and", "zone", "number", "value", "." ]
1780ee78d247425ea73ddb2730849c54bae9f34c
https://github.com/proj4js/mgrs/blob/1780ee78d247425ea73ddb2730849c54bae9f34c/mgrs.js#L345-L350
train
libp2p/js-libp2p-circuit
src/circuit/utils.js
getB58String
function getB58String (peer) { let b58Id = null if (multiaddr.isMultiaddr(peer)) { const relayMa = multiaddr(peer) b58Id = relayMa.getPeerId() } else if (PeerInfo.isPeerInfo(peer)) { b58Id = peer.id.toB58String() } return b58Id }
javascript
function getB58String (peer) { let b58Id = null if (multiaddr.isMultiaddr(peer)) { const relayMa = multiaddr(peer) b58Id = relayMa.getPeerId() } else if (PeerInfo.isPeerInfo(peer)) { b58Id = peer.id.toB58String() } return b58Id }
[ "function", "getB58String", "(", "peer", ")", "{", "let", "b58Id", "=", "null", "if", "(", "multiaddr", ".", "isMultiaddr", "(", "peer", ")", ")", "{", "const", "relayMa", "=", "multiaddr", "(", "peer", ")", "b58Id", "=", "relayMa", ".", "getPeerId", "...
Get b58 string from multiaddr or peerinfo @param {Multiaddr|PeerInfo} peer @return {*}
[ "Get", "b58", "string", "from", "multiaddr", "or", "peerinfo" ]
ed35c767f8fa525560dea20e8bf663d45743361f
https://github.com/libp2p/js-libp2p-circuit/blob/ed35c767f8fa525560dea20e8bf663d45743361f/src/circuit/utils.js#L15-L25
train
libp2p/js-libp2p-circuit
src/circuit/utils.js
peerInfoFromMa
function peerInfoFromMa (peer) { let p // PeerInfo if (PeerInfo.isPeerInfo(peer)) { p = peer // Multiaddr instance (not string) } else if (multiaddr.isMultiaddr(peer)) { const peerIdB58Str = peer.getPeerId() try { p = swarm._peerBook.get(peerIdB58Str) } catch (err) ...
javascript
function peerInfoFromMa (peer) { let p // PeerInfo if (PeerInfo.isPeerInfo(peer)) { p = peer // Multiaddr instance (not string) } else if (multiaddr.isMultiaddr(peer)) { const peerIdB58Str = peer.getPeerId() try { p = swarm._peerBook.get(peerIdB58Str) } catch (err) ...
[ "function", "peerInfoFromMa", "(", "peer", ")", "{", "let", "p", "// PeerInfo", "if", "(", "PeerInfo", ".", "isPeerInfo", "(", "peer", ")", ")", "{", "p", "=", "peer", "// Multiaddr instance (not string)", "}", "else", "if", "(", "multiaddr", ".", "isMultiad...
Helper to make a peer info from a multiaddrs @param {Multiaddr|PeerInfo|PeerId} ma @param {Swarm} swarm @return {PeerInfo} @private TODO: this is ripped off of libp2p, should probably be a generally available util function
[ "Helper", "to", "make", "a", "peer", "info", "from", "a", "multiaddrs" ]
ed35c767f8fa525560dea20e8bf663d45743361f
https://github.com/libp2p/js-libp2p-circuit/blob/ed35c767f8fa525560dea20e8bf663d45743361f/src/circuit/utils.js#L36-L57
train
libp2p/js-libp2p-circuit
src/circuit/utils.js
writeResponse
function writeResponse (streamHandler, status, cb) { cb = cb || (() => {}) streamHandler.write(proto.CircuitRelay.encode({ type: proto.CircuitRelay.Type.STATUS, code: status })) return cb() }
javascript
function writeResponse (streamHandler, status, cb) { cb = cb || (() => {}) streamHandler.write(proto.CircuitRelay.encode({ type: proto.CircuitRelay.Type.STATUS, code: status })) return cb() }
[ "function", "writeResponse", "(", "streamHandler", ",", "status", ",", "cb", ")", "{", "cb", "=", "cb", "||", "(", "(", ")", "=>", "{", "}", ")", "streamHandler", ".", "write", "(", "proto", ".", "CircuitRelay", ".", "encode", "(", "{", "type", ":", ...
Write a response @param {StreamHandler} streamHandler @param {CircuitRelay.Status} status @param {Function} cb @returns {*}
[ "Write", "a", "response" ]
ed35c767f8fa525560dea20e8bf663d45743361f
https://github.com/libp2p/js-libp2p-circuit/blob/ed35c767f8fa525560dea20e8bf663d45743361f/src/circuit/utils.js#L78-L85
train
googleapis/gaxios
samples/quickstart.js
quickstart
async function quickstart() { const url = 'https://www.googleapis.com/discovery/v1/apis/'; const res = await request({url}); console.log(`status: ${res.status}`); console.log(`data:`); console.log(res.data); }
javascript
async function quickstart() { const url = 'https://www.googleapis.com/discovery/v1/apis/'; const res = await request({url}); console.log(`status: ${res.status}`); console.log(`data:`); console.log(res.data); }
[ "async", "function", "quickstart", "(", ")", "{", "const", "url", "=", "'https://www.googleapis.com/discovery/v1/apis/'", ";", "const", "res", "=", "await", "request", "(", "{", "url", "}", ")", ";", "console", ".", "log", "(", "`", "${", "res", ".", "stat...
Perform a simple `GET` request to a JSON API.
[ "Perform", "a", "simple", "GET", "request", "to", "a", "JSON", "API", "." ]
076afae4b37c02747908a01509266b5fee926d47
https://github.com/googleapis/gaxios/blob/076afae4b37c02747908a01509266b5fee926d47/samples/quickstart.js#L23-L29
train
enketo/enketo-core
src/js/widgets-controller.js
disable
function disable( group ) { widgets.forEach( Widget => { const els = _getElements( group, Widget.selector ); new Collection( els ).disable( Widget ); } ); }
javascript
function disable( group ) { widgets.forEach( Widget => { const els = _getElements( group, Widget.selector ); new Collection( els ).disable( Widget ); } ); }
[ "function", "disable", "(", "group", ")", "{", "widgets", ".", "forEach", "(", "Widget", "=>", "{", "const", "els", "=", "_getElements", "(", "group", ",", "Widget", ".", "selector", ")", ";", "new", "Collection", "(", "els", ")", ".", "disable", "(", ...
Disables widgets, if they aren't disabled already when the branch was disabled by the controller. In most widgets, this function will do nothing because all fieldsets, inputs, textareas and selects will get the disabled attribute automatically when the branch element provided as parameter becomes irrelevant. @param ...
[ "Disables", "widgets", "if", "they", "aren", "t", "disabled", "already", "when", "the", "branch", "was", "disabled", "by", "the", "controller", ".", "In", "most", "widgets", "this", "function", "will", "do", "nothing", "because", "all", "fieldsets", "inputs", ...
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/widgets-controller.js#L57-L62
train
enketo/enketo-core
src/js/widgets-controller.js
_getElements
function _getElements( group, selector ) { if ( selector ) { if ( selector === 'form' ) { return [ formHtml ]; } // e.g. if the widget selector starts at .question level (e.g. ".or-appearance-draw input") if ( group.classList.contains( 'question' ) ) { return ...
javascript
function _getElements( group, selector ) { if ( selector ) { if ( selector === 'form' ) { return [ formHtml ]; } // e.g. if the widget selector starts at .question level (e.g. ".or-appearance-draw input") if ( group.classList.contains( 'question' ) ) { return ...
[ "function", "_getElements", "(", "group", ",", "selector", ")", "{", "if", "(", "selector", ")", "{", "if", "(", "selector", "===", "'form'", ")", "{", "return", "[", "formHtml", "]", ";", "}", "// e.g. if the widget selector starts at .question level (e.g. \".or-...
Returns the elements on which to apply the widget @param {Element} group a jQuery-wrapped element @param {string} selector if the selector is null, the form element will be returned @return {jQuery} a jQuery collection
[ "Returns", "the", "elements", "on", "which", "to", "apply", "the", "widget" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/widgets-controller.js#L71-L85
train
enketo/enketo-core
src/js/print.js
setDpi
function setDpi() { const dpiO = {}; const e = document.body.appendChild( document.createElement( 'DIV' ) ); e.style.width = '1in'; e.style.padding = '0'; dpiO.v = e.offsetWidth; e.parentNode.removeChild( e ); dpi = dpiO.v; }
javascript
function setDpi() { const dpiO = {}; const e = document.body.appendChild( document.createElement( 'DIV' ) ); e.style.width = '1in'; e.style.padding = '0'; dpiO.v = e.offsetWidth; e.parentNode.removeChild( e ); dpi = dpiO.v; }
[ "function", "setDpi", "(", ")", "{", "const", "dpiO", "=", "{", "}", ";", "const", "e", "=", "document", ".", "body", ".", "appendChild", "(", "document", ".", "createElement", "(", "'DIV'", ")", ")", ";", "e", ".", "style", ".", "width", "=", "'1i...
Calculates the dots per inch and sets the dpi property
[ "Calculates", "the", "dots", "per", "inch", "and", "sets", "the", "dpi", "property" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/print.js#L19-L27
train
enketo/enketo-core
src/js/print.js
getPrintStyleSheet
function getPrintStyleSheet() { let sheet; // document.styleSheets is an Object not an Array! for ( const i in document.styleSheets ) { if ( document.styleSheets.hasOwnProperty( i ) ) { sheet = document.styleSheets[ i ]; if ( sheet.media.mediaText === 'print' ) { ...
javascript
function getPrintStyleSheet() { let sheet; // document.styleSheets is an Object not an Array! for ( const i in document.styleSheets ) { if ( document.styleSheets.hasOwnProperty( i ) ) { sheet = document.styleSheets[ i ]; if ( sheet.media.mediaText === 'print' ) { ...
[ "function", "getPrintStyleSheet", "(", ")", "{", "let", "sheet", ";", "// document.styleSheets is an Object not an Array!", "for", "(", "const", "i", "in", "document", ".", "styleSheets", ")", "{", "if", "(", "document", ".", "styleSheets", ".", "hasOwnProperty", ...
Gets print stylesheets @return {Element} [description]
[ "Gets", "print", "stylesheets" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/print.js#L33-L45
train
enketo/enketo-core
src/js/print.js
styleToAll
function styleToAll() { // sometimes, setStylesheet fails upon loading printStyleSheet = printStyleSheet || getPrintStyleSheet(); $printStyleSheetLink = $printStyleSheetLink || getPrintStyleSheetLink(); // Chrome: printStyleSheet.media.mediaText = 'all'; // Firefox: $printStyleSheetLink.attr...
javascript
function styleToAll() { // sometimes, setStylesheet fails upon loading printStyleSheet = printStyleSheet || getPrintStyleSheet(); $printStyleSheetLink = $printStyleSheetLink || getPrintStyleSheetLink(); // Chrome: printStyleSheet.media.mediaText = 'all'; // Firefox: $printStyleSheetLink.attr...
[ "function", "styleToAll", "(", ")", "{", "// sometimes, setStylesheet fails upon loading", "printStyleSheet", "=", "printStyleSheet", "||", "getPrintStyleSheet", "(", ")", ";", "$printStyleSheetLink", "=", "$printStyleSheetLink", "||", "getPrintStyleSheetLink", "(", ")", ";...
Applies the print stylesheet to the current view by changing stylesheets media property to 'all'
[ "Applies", "the", "print", "stylesheet", "to", "the", "current", "view", "by", "changing", "stylesheets", "media", "property", "to", "all" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/print.js#L54-L63
train
enketo/enketo-core
src/js/fake-translator.js
t
function t( key, options ) { let str = ''; let target = SOURCE_STRINGS; // crude string getter key.split( '.' ).forEach( part => { target = target ? target[ part ] : ''; str = target; } ); // crude interpolator options = options || {}; str = str.replace( /__([^_]+)__/, (...
javascript
function t( key, options ) { let str = ''; let target = SOURCE_STRINGS; // crude string getter key.split( '.' ).forEach( part => { target = target ? target[ part ] : ''; str = target; } ); // crude interpolator options = options || {}; str = str.replace( /__([^_]+)__/, (...
[ "function", "t", "(", "key", ",", "options", ")", "{", "let", "str", "=", "''", ";", "let", "target", "=", "SOURCE_STRINGS", ";", "// crude string getter", "key", ".", "split", "(", "'.'", ")", ".", "forEach", "(", "part", "=>", "{", "target", "=", "...
Add keys from XSL stylesheets manually so i18next-parser will detect them. t('constraint.invalid'); t('constraint.required'); Meant to be replaced by a real translator in the app that consumes enketo-core @param {String} key translation key @param {*} key translation options @return {String} translation output
[ "Add", "keys", "from", "XSL", "stylesheets", "manually", "so", "i18next", "-", "parser", "will", "detect", "them", "." ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/fake-translator.js#L95-L111
train
enketo/enketo-core
app.js
initializeForm
function initializeForm() { form = new Form( 'form.or:eq(0)', { modelStr: modelStr }, { arcGis: { basemaps: [ 'streets', 'topo', 'satellite', 'osm' ], webMapId: 'f2e9b762544945f390ca4ac3671cfa72', hasZ: true }, 'clearIrrelevantImmediately': tru...
javascript
function initializeForm() { form = new Form( 'form.or:eq(0)', { modelStr: modelStr }, { arcGis: { basemaps: [ 'streets', 'topo', 'satellite', 'osm' ], webMapId: 'f2e9b762544945f390ca4ac3671cfa72', hasZ: true }, 'clearIrrelevantImmediately': tru...
[ "function", "initializeForm", "(", ")", "{", "form", "=", "new", "Form", "(", "'form.or:eq(0)'", ",", "{", "modelStr", ":", "modelStr", "}", ",", "{", "arcGis", ":", "{", "basemaps", ":", "[", "'streets'", ",", "'topo'", ",", "'satellite'", ",", "'osm'",...
initialize the form
[ "initialize", "the", "form" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/app.js#L64-L82
train
enketo/enketo-core
app.js
getURLParameter
function getURLParameter( name ) { return decodeURI( ( new RegExp( name + '=' + '(.+?)(&|$)' ).exec( location.search ) || [ null, null ] )[ 1 ] ); }
javascript
function getURLParameter( name ) { return decodeURI( ( new RegExp( name + '=' + '(.+?)(&|$)' ).exec( location.search ) || [ null, null ] )[ 1 ] ); }
[ "function", "getURLParameter", "(", "name", ")", "{", "return", "decodeURI", "(", "(", "new", "RegExp", "(", "name", "+", "'='", "+", "'(.+?)(&|$)'", ")", ".", "exec", "(", "location", ".", "search", ")", "||", "[", "null", ",", "null", "]", ")", "["...
get query string parameter
[ "get", "query", "string", "parameter" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/app.js#L85-L89
train
enketo/enketo-core
src/js/translated-error.js
TranslatedError
function TranslatedError( message, translationKey, translationOptions ) { this.message = message; this.translationKey = translationKey; this.translationOptions = translationOptions; }
javascript
function TranslatedError( message, translationKey, translationOptions ) { this.message = message; this.translationKey = translationKey; this.translationOptions = translationOptions; }
[ "function", "TranslatedError", "(", "message", ",", "translationKey", ",", "translationOptions", ")", "{", "this", ".", "message", "=", "message", ";", "this", ".", "translationKey", "=", "translationKey", ";", "this", ".", "translationOptions", "=", "translationO...
Error to be translated
[ "Error", "to", "be", "translated" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/translated-error.js#L2-L6
train
enketo/enketo-core
src/js/utils.js
parseFunctionFromExpression
function parseFunctionFromExpression( expr, func ) { let index; let result; let openBrackets; let start; let argStart; let args; const findFunc = new RegExp( `${func}\\s*\\(`, 'g' ); const results = []; if ( !expr || !func ) { return results; } while ( ( result = fi...
javascript
function parseFunctionFromExpression( expr, func ) { let index; let result; let openBrackets; let start; let argStart; let args; const findFunc = new RegExp( `${func}\\s*\\(`, 'g' ); const results = []; if ( !expr || !func ) { return results; } while ( ( result = fi...
[ "function", "parseFunctionFromExpression", "(", "expr", ",", "func", ")", "{", "let", "index", ";", "let", "result", ";", "let", "openBrackets", ";", "let", "start", ";", "let", "argStart", ";", "let", "args", ";", "const", "findFunc", "=", "new", "RegExp"...
Parses an Expression to extract all function calls and theirs argument arrays. @param {String} expr The expression to search @param {String} func The function name to search for @return {<String, <String*>>} The result array, where each result is an array containing the function call and array of arguments.
[ "Parses", "an", "Expression", "to", "extract", "all", "function", "calls", "and", "theirs", "argument", "arrays", "." ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/utils.js#L11-L52
train
enketo/enketo-core
src/js/utils.js
toArray
function toArray( list ) { const array = []; // iterate backwards ensuring that length is an UInt32 for ( let i = list.length >>> 0; i--; ) { array[ i ] = list[ i ]; } return array; }
javascript
function toArray( list ) { const array = []; // iterate backwards ensuring that length is an UInt32 for ( let i = list.length >>> 0; i--; ) { array[ i ] = list[ i ]; } return array; }
[ "function", "toArray", "(", "list", ")", "{", "const", "array", "=", "[", "]", ";", "// iterate backwards ensuring that length is an UInt32", "for", "(", "let", "i", "=", "list", ".", "length", ">>>", "0", ";", "i", "--", ";", ")", "{", "array", "[", "i"...
Converts NodeLists or DOMtokenLists to an array @param {[type]} list [description] @return {[type]} [description]
[ "Converts", "NodeLists", "or", "DOMtokenLists", "to", "an", "array" ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/utils.js#L85-L92
train
enketo/enketo-core
src/js/utils.js
updateDownloadLink
function updateDownloadLink( anchor, objectUrl, fileName ) { if ( window.updateDownloadLinkIe11 ) { return window.updateDownloadLinkIe11( ...arguments ); } anchor.setAttribute( 'href', objectUrl || '' ); anchor.setAttribute( 'download', fileName || '' ); }
javascript
function updateDownloadLink( anchor, objectUrl, fileName ) { if ( window.updateDownloadLinkIe11 ) { return window.updateDownloadLinkIe11( ...arguments ); } anchor.setAttribute( 'href', objectUrl || '' ); anchor.setAttribute( 'download', fileName || '' ); }
[ "function", "updateDownloadLink", "(", "anchor", ",", "objectUrl", ",", "fileName", ")", "{", "if", "(", "window", ".", "updateDownloadLinkIe11", ")", "{", "return", "window", ".", "updateDownloadLinkIe11", "(", "...", "arguments", ")", ";", "}", "anchor", "."...
Update a HTML anchor to serve as a download or reset it if an empty objectUrl is provided. @param {HTMLElement} anchor the anchor element @param {*} objectUrl the objectUrl to download @param {*} fileName the filename of the file
[ "Update", "a", "HTML", "anchor", "to", "serve", "as", "a", "download", "or", "reset", "it", "if", "an", "empty", "objectUrl", "is", "provided", "." ]
b47a98dd5c4ace2410424efa706c96de43e2e6a2
https://github.com/enketo/enketo-core/blob/b47a98dd5c4ace2410424efa706c96de43e2e6a2/src/js/utils.js#L163-L169
train
namics/stylelint-bem-namics
index.js
getValidSyntax
function getValidSyntax(className, namespaces) { const parsedClassName = parseClassName(className, namespaces); // Try to guess the namespaces or use the first one let validSyntax = parsedClassName.namespace || namespaces[0] || ''; if (parsedClassName.helper) { validSyntax += `${parsedClassName.helper}-`; ...
javascript
function getValidSyntax(className, namespaces) { const parsedClassName = parseClassName(className, namespaces); // Try to guess the namespaces or use the first one let validSyntax = parsedClassName.namespace || namespaces[0] || ''; if (parsedClassName.helper) { validSyntax += `${parsedClassName.helper}-`; ...
[ "function", "getValidSyntax", "(", "className", ",", "namespaces", ")", "{", "const", "parsedClassName", "=", "parseClassName", "(", "className", ",", "namespaces", ")", ";", "// Try to guess the namespaces or use the first one", "let", "validSyntax", "=", "parsedClassNam...
Helper for error messages to tell the correct syntax @param {string} className the class name @param {string[]} namespaces (optional) namespace @returns {string} valid syntax
[ "Helper", "for", "error", "messages", "to", "tell", "the", "correct", "syntax" ]
83deeb7871a49604b51b12bb48c0ac4186851a57
https://github.com/namics/stylelint-bem-namics/blob/83deeb7871a49604b51b12bb48c0ac4186851a57/index.js#L90-L112
train
i18next/react-i18next
react-i18next.js
pushTextNode
function pushTextNode(list, html, level, start, ignoreWhitespace) { // calculate correct end of the content slice in case there's // no tag after the text node. var end = html.indexOf('<', start); var content = html.slice(start, end === -1 ? undefined : end); // if a node is nothing but whitespace, coll...
javascript
function pushTextNode(list, html, level, start, ignoreWhitespace) { // calculate correct end of the content slice in case there's // no tag after the text node. var end = html.indexOf('<', start); var content = html.slice(start, end === -1 ? undefined : end); // if a node is nothing but whitespace, coll...
[ "function", "pushTextNode", "(", "list", ",", "html", ",", "level", ",", "start", ",", "ignoreWhitespace", ")", "{", "// calculate correct end of the content slice in case there's", "// no tag after the text node.", "var", "end", "=", "html", ".", "indexOf", "(", "'<'",...
common logic for pushing a child node onto a list
[ "common", "logic", "for", "pushing", "a", "child", "node", "onto", "a", "list" ]
8d1e5d469f78498c8f62bb4c7ceed58362c47d70
https://github.com/i18next/react-i18next/blob/8d1e5d469f78498c8f62bb4c7ceed58362c47d70/react-i18next.js#L195-L216
train
i18next/react-i18next
example/locize/src/App.js
Page
function Page() { const { t, i18n } = useTranslation(); const changeLanguage = lng => { i18n.changeLanguage(lng); }; return ( <div className="App"> <div className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <Welcome /> </div> <div className="App-i...
javascript
function Page() { const { t, i18n } = useTranslation(); const changeLanguage = lng => { i18n.changeLanguage(lng); }; return ( <div className="App"> <div className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <Welcome /> </div> <div className="App-i...
[ "function", "Page", "(", ")", "{", "const", "{", "t", ",", "i18n", "}", "=", "useTranslation", "(", ")", ";", "const", "changeLanguage", "=", "lng", "=>", "{", "i18n", ".", "changeLanguage", "(", "lng", ")", ";", "}", ";", "return", "(", "<", "div"...
page uses the hook
[ "page", "uses", "the", "hook" ]
8d1e5d469f78498c8f62bb4c7ceed58362c47d70
https://github.com/i18next/react-i18next/blob/8d1e5d469f78498c8f62bb4c7ceed58362c47d70/example/locize/src/App.js#L25-L48
train
wycats/handlebars.js
spec/precompiler.js
mockRequireUglify
function mockRequireUglify(loadError, callback) { var Module = require('module'); var _resolveFilename = Module._resolveFilename; delete require.cache[require.resolve('uglify-js')]; delete require.cache[require.resolve('../dist/cjs/precompiler')]; Module._resolveFilename = function(request, mod) { ...
javascript
function mockRequireUglify(loadError, callback) { var Module = require('module'); var _resolveFilename = Module._resolveFilename; delete require.cache[require.resolve('uglify-js')]; delete require.cache[require.resolve('../dist/cjs/precompiler')]; Module._resolveFilename = function(request, mod) { ...
[ "function", "mockRequireUglify", "(", "loadError", ",", "callback", ")", "{", "var", "Module", "=", "require", "(", "'module'", ")", ";", "var", "_resolveFilename", "=", "Module", ".", "_resolveFilename", ";", "delete", "require", ".", "cache", "[", "require",...
Mock the Module.prototype.require-function such that an error is thrown, when "uglify-js" is loaded. The function cleans up its mess when "callback" is finished @param {Error} loadError the error that should be thrown if uglify is loaded @param {function} callback a callback-function to run when the mock is active.
[ "Mock", "the", "Module", ".", "prototype", ".", "require", "-", "function", "such", "that", "an", "error", "is", "thrown", "when", "uglify", "-", "js", "is", "loaded", "." ]
3ce4425056998c1db921d7b6c0662b843acb593b
https://github.com/wycats/handlebars.js/blob/3ce4425056998c1db921d7b6c0662b843acb593b/spec/precompiler.js#L39-L57
train
wycats/handlebars.js
lib/precompiler.js
minify
function minify(output, sourceMapFile) { try { // Try to resolve uglify-js in order to see if it does exist require.resolve('uglify-js'); } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') { // Something else seems to be wrong throw e; } // it does not exist! console.error('Code mi...
javascript
function minify(output, sourceMapFile) { try { // Try to resolve uglify-js in order to see if it does exist require.resolve('uglify-js'); } catch (e) { if (e.code !== 'MODULE_NOT_FOUND') { // Something else seems to be wrong throw e; } // it does not exist! console.error('Code mi...
[ "function", "minify", "(", "output", ",", "sourceMapFile", ")", "{", "try", "{", "// Try to resolve uglify-js in order to see if it does exist", "require", ".", "resolve", "(", "'uglify-js'", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "e", ".", "co...
Run uglify to minify the compiled template, if uglify exists in the dependencies. We are using `require` instead of `import` here, because es6-modules do not allow dynamic imports and uglify-js is an optional dependency. Since we are inside NodeJS here, this should not be a problem. @param {string} output the compile...
[ "Run", "uglify", "to", "minify", "the", "compiled", "template", "if", "uglify", "exists", "in", "the", "dependencies", "." ]
3ce4425056998c1db921d7b6c0662b843acb593b
https://github.com/wycats/handlebars.js/blob/3ce4425056998c1db921d7b6c0662b843acb593b/lib/precompiler.js#L279-L298
train
wycats/handlebars.js
lib/handlebars/compiler/visitor.js
function(node, name) { let value = this.accept(node[name]); if (this.mutating) { // Hacky sanity check: This may have a few false positives for type for the helper // methods but will generally do the right thing without a lot of overhead. if (value && !Visitor.prototype[value.type]) { ...
javascript
function(node, name) { let value = this.accept(node[name]); if (this.mutating) { // Hacky sanity check: This may have a few false positives for type for the helper // methods but will generally do the right thing without a lot of overhead. if (value && !Visitor.prototype[value.type]) { ...
[ "function", "(", "node", ",", "name", ")", "{", "let", "value", "=", "this", ".", "accept", "(", "node", "[", "name", "]", ")", ";", "if", "(", "this", ".", "mutating", ")", "{", "// Hacky sanity check: This may have a few false positives for type for the helper...
Visits a given value. If mutating, will replace the value if necessary.
[ "Visits", "a", "given", "value", ".", "If", "mutating", "will", "replace", "the", "value", "if", "necessary", "." ]
3ce4425056998c1db921d7b6c0662b843acb593b
https://github.com/wycats/handlebars.js/blob/3ce4425056998c1db921d7b6c0662b843acb593b/lib/handlebars/compiler/visitor.js#L12-L22
train
wycats/handlebars.js
lib/handlebars/compiler/visitor.js
function(node, name) { this.acceptKey(node, name); if (!node[name]) { throw new Exception(node.type + ' requires ' + name); } }
javascript
function(node, name) { this.acceptKey(node, name); if (!node[name]) { throw new Exception(node.type + ' requires ' + name); } }
[ "function", "(", "node", ",", "name", ")", "{", "this", ".", "acceptKey", "(", "node", ",", "name", ")", ";", "if", "(", "!", "node", "[", "name", "]", ")", "{", "throw", "new", "Exception", "(", "node", ".", "type", "+", "' requires '", "+", "na...
Performs an accept operation with added sanity check to ensure required keys are not removed.
[ "Performs", "an", "accept", "operation", "with", "added", "sanity", "check", "to", "ensure", "required", "keys", "are", "not", "removed", "." ]
3ce4425056998c1db921d7b6c0662b843acb593b
https://github.com/wycats/handlebars.js/blob/3ce4425056998c1db921d7b6c0662b843acb593b/lib/handlebars/compiler/visitor.js#L26-L32
train
facebook/regenerator
packages/regenerator-transform/src/visit.js
shouldRegenerate
function shouldRegenerate(node, state) { if (node.generator) { if (node.async) { // Async generator return state.opts.asyncGenerators !== false; } else { // Plain generator return state.opts.generators !== false; } } else if (node.async) { // Async function return state.o...
javascript
function shouldRegenerate(node, state) { if (node.generator) { if (node.async) { // Async generator return state.opts.asyncGenerators !== false; } else { // Plain generator return state.opts.generators !== false; } } else if (node.async) { // Async function return state.o...
[ "function", "shouldRegenerate", "(", "node", ",", "state", ")", "{", "if", "(", "node", ".", "generator", ")", "{", "if", "(", "node", ".", "async", ")", "{", "// Async generator", "return", "state", ".", "opts", ".", "asyncGenerators", "!==", "false", "...
Check if a node should be transformed by regenerator
[ "Check", "if", "a", "node", "should", "be", "transformed", "by", "regenerator" ]
d4ccc3ba278753c7c37e2db2147834007b9075b1
https://github.com/facebook/regenerator/blob/d4ccc3ba278753c7c37e2db2147834007b9075b1/packages/regenerator-transform/src/visit.js#L202-L218
train
facebook/regenerator
packages/regenerator-transform/src/visit.js
getOuterFnExpr
function getOuterFnExpr(funPath) { const t = util.getTypes(); let node = funPath.node; t.assertFunction(node); if (!node.id) { // Default-exported function declarations, and function expressions may not // have a name to reference, so we explicitly add one. node.id = funPath.scope.parent.generateUi...
javascript
function getOuterFnExpr(funPath) { const t = util.getTypes(); let node = funPath.node; t.assertFunction(node); if (!node.id) { // Default-exported function declarations, and function expressions may not // have a name to reference, so we explicitly add one. node.id = funPath.scope.parent.generateUi...
[ "function", "getOuterFnExpr", "(", "funPath", ")", "{", "const", "t", "=", "util", ".", "getTypes", "(", ")", ";", "let", "node", "=", "funPath", ".", "node", ";", "t", ".", "assertFunction", "(", "node", ")", ";", "if", "(", "!", "node", ".", "id"...
Given a NodePath for a Function, return an Expression node that can be used to refer reliably to the function object from inside the function. This expression is essentially a replacement for arguments.callee, with the key advantage that it works in strict mode.
[ "Given", "a", "NodePath", "for", "a", "Function", "return", "an", "Expression", "node", "that", "can", "be", "used", "to", "refer", "reliably", "to", "the", "function", "object", "from", "inside", "the", "function", ".", "This", "expression", "is", "essentia...
d4ccc3ba278753c7c37e2db2147834007b9075b1
https://github.com/facebook/regenerator/blob/d4ccc3ba278753c7c37e2db2147834007b9075b1/packages/regenerator-transform/src/visit.js#L224-L242
train
facebook/regenerator
packages/regenerator-transform/src/emit.js
explodeViaTempVar
function explodeViaTempVar(tempVar, childPath, ignoreChildResult) { assert.ok( !ignoreChildResult || !tempVar, "Ignoring the result of a child expression but forcing it to " + "be assigned to a temporary variable?" ); let result = self.explodeExpression(childPath, ignoreChildResult); ...
javascript
function explodeViaTempVar(tempVar, childPath, ignoreChildResult) { assert.ok( !ignoreChildResult || !tempVar, "Ignoring the result of a child expression but forcing it to " + "be assigned to a temporary variable?" ); let result = self.explodeExpression(childPath, ignoreChildResult); ...
[ "function", "explodeViaTempVar", "(", "tempVar", ",", "childPath", ",", "ignoreChildResult", ")", "{", "assert", ".", "ok", "(", "!", "ignoreChildResult", "||", "!", "tempVar", ",", "\"Ignoring the result of a child expression but forcing it to \"", "+", "\"be assigned to...
In order to save the rest of explodeExpression from a combinatorial trainwreck of special cases, explodeViaTempVar is responsible for deciding when a subexpression needs to be "exploded," which is my very technical term for emitting the subexpression as an assignment to a temporary variable and the substituting the tem...
[ "In", "order", "to", "save", "the", "rest", "of", "explodeExpression", "from", "a", "combinatorial", "trainwreck", "of", "special", "cases", "explodeViaTempVar", "is", "responsible", "for", "deciding", "when", "a", "subexpression", "needs", "to", "be", "exploded",...
d4ccc3ba278753c7c37e2db2147834007b9075b1
https://github.com/facebook/regenerator/blob/d4ccc3ba278753c7c37e2db2147834007b9075b1/packages/regenerator-transform/src/emit.js#L946-L977
train
willmcpo/body-scroll-lock
lib/bodyScrollLock.js
allowTouchMove
function allowTouchMove(el) { return locks.some(function (lock) { if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) { return true; } return false; }); }
javascript
function allowTouchMove(el) { return locks.some(function (lock) { if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) { return true; } return false; }); }
[ "function", "allowTouchMove", "(", "el", ")", "{", "return", "locks", ".", "some", "(", "function", "(", "lock", ")", "{", "if", "(", "lock", ".", "options", ".", "allowTouchMove", "&&", "lock", ".", "options", ".", "allowTouchMove", "(", "el", ")", ")...
returns true if `el` should be allowed to receive touchmove events
[ "returns", "true", "if", "el", "should", "be", "allowed", "to", "receive", "touchmove", "events" ]
0e65e5fc9018b84975440b92ac84669f21ea5b3b
https://github.com/willmcpo/body-scroll-lock/blob/0e65e5fc9018b84975440b92ac84669f21ea5b3b/lib/bodyScrollLock.js#L59-L67
train
benmosher/eslint-plugin-import
src/rules/no-useless-path-segments.js
toRelativePath
function toRelativePath(relativePath) { const stripped = relativePath.replace(/\/$/g, '') // Remove trailing / return /^((\.\.)|(\.))($|\/)/.test(stripped) ? stripped : `./${stripped}` }
javascript
function toRelativePath(relativePath) { const stripped = relativePath.replace(/\/$/g, '') // Remove trailing / return /^((\.\.)|(\.))($|\/)/.test(stripped) ? stripped : `./${stripped}` }
[ "function", "toRelativePath", "(", "relativePath", ")", "{", "const", "stripped", "=", "relativePath", ".", "replace", "(", "/", "\\/$", "/", "g", ",", "''", ")", "// Remove trailing /", "return", "/", "^((\\.\\.)|(\\.))($|\\/)", "/", ".", "test", "(", "stripp...
convert a potentially relative path from node utils into a true relative path. ../ -> .. ./ -> . .foo/bar -> ./.foo/bar ..foo/bar -> ./..foo/bar foo/bar -> ./foo/bar @param relativePath {string} relative posix path potentially missing leading './' @returns {string} relative posix path that always starts with a ./
[ "convert", "a", "potentially", "relative", "path", "from", "node", "utils", "into", "a", "true", "relative", "path", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-useless-path-segments.js#L25-L29
train
benmosher/eslint-plugin-import
src/rules/no-duplicates.js
getDefaultImportName
function getDefaultImportName(node) { const defaultSpecifier = node.specifiers .find(specifier => specifier.type === 'ImportDefaultSpecifier') return defaultSpecifier != null ? defaultSpecifier.local.name : undefined }
javascript
function getDefaultImportName(node) { const defaultSpecifier = node.specifiers .find(specifier => specifier.type === 'ImportDefaultSpecifier') return defaultSpecifier != null ? defaultSpecifier.local.name : undefined }
[ "function", "getDefaultImportName", "(", "node", ")", "{", "const", "defaultSpecifier", "=", "node", ".", "specifiers", ".", "find", "(", "specifier", "=>", "specifier", ".", "type", "===", "'ImportDefaultSpecifier'", ")", "return", "defaultSpecifier", "!=", "null...
Get the name of the default import of `node`, if any.
[ "Get", "the", "name", "of", "the", "default", "import", "of", "node", "if", "any", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-duplicates.js#L167-L171
train
benmosher/eslint-plugin-import
src/rules/no-duplicates.js
hasNamespace
function hasNamespace(node) { const specifiers = node.specifiers .filter(specifier => specifier.type === 'ImportNamespaceSpecifier') return specifiers.length > 0 }
javascript
function hasNamespace(node) { const specifiers = node.specifiers .filter(specifier => specifier.type === 'ImportNamespaceSpecifier') return specifiers.length > 0 }
[ "function", "hasNamespace", "(", "node", ")", "{", "const", "specifiers", "=", "node", ".", "specifiers", ".", "filter", "(", "specifier", "=>", "specifier", ".", "type", "===", "'ImportNamespaceSpecifier'", ")", "return", "specifiers", ".", "length", ">", "0"...
Checks whether `node` has a namespace import.
[ "Checks", "whether", "node", "has", "a", "namespace", "import", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-duplicates.js#L174-L178
train
benmosher/eslint-plugin-import
src/rules/no-duplicates.js
hasSpecifiers
function hasSpecifiers(node) { const specifiers = node.specifiers .filter(specifier => specifier.type === 'ImportSpecifier') return specifiers.length > 0 }
javascript
function hasSpecifiers(node) { const specifiers = node.specifiers .filter(specifier => specifier.type === 'ImportSpecifier') return specifiers.length > 0 }
[ "function", "hasSpecifiers", "(", "node", ")", "{", "const", "specifiers", "=", "node", ".", "specifiers", ".", "filter", "(", "specifier", "=>", "specifier", ".", "type", "===", "'ImportSpecifier'", ")", "return", "specifiers", ".", "length", ">", "0", "}" ...
Checks whether `node` has any non-default specifiers.
[ "Checks", "whether", "node", "has", "any", "non", "-", "default", "specifiers", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-duplicates.js#L181-L185
train
benmosher/eslint-plugin-import
src/rules/no-duplicates.js
hasProblematicComments
function hasProblematicComments(node, sourceCode) { return ( hasCommentBefore(node, sourceCode) || hasCommentAfter(node, sourceCode) || hasCommentInsideNonSpecifiers(node, sourceCode) ) }
javascript
function hasProblematicComments(node, sourceCode) { return ( hasCommentBefore(node, sourceCode) || hasCommentAfter(node, sourceCode) || hasCommentInsideNonSpecifiers(node, sourceCode) ) }
[ "function", "hasProblematicComments", "(", "node", ",", "sourceCode", ")", "{", "return", "(", "hasCommentBefore", "(", "node", ",", "sourceCode", ")", "||", "hasCommentAfter", "(", "node", ",", "sourceCode", ")", "||", "hasCommentInsideNonSpecifiers", "(", "node"...
It's not obvious what the user wants to do with comments associated with duplicate imports, so skip imports with comments when autofixing.
[ "It", "s", "not", "obvious", "what", "the", "user", "wants", "to", "do", "with", "comments", "associated", "with", "duplicate", "imports", "so", "skip", "imports", "with", "comments", "when", "autofixing", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-duplicates.js#L189-L195
train
benmosher/eslint-plugin-import
utils/module-require.js
createModule
function createModule(filename) { const mod = new Module(filename) mod.filename = filename mod.paths = Module._nodeModulePaths(path.dirname(filename)) return mod }
javascript
function createModule(filename) { const mod = new Module(filename) mod.filename = filename mod.paths = Module._nodeModulePaths(path.dirname(filename)) return mod }
[ "function", "createModule", "(", "filename", ")", "{", "const", "mod", "=", "new", "Module", "(", "filename", ")", "mod", ".", "filename", "=", "filename", "mod", ".", "paths", "=", "Module", ".", "_nodeModulePaths", "(", "path", ".", "dirname", "(", "fi...
borrowed from babel-eslint
[ "borrowed", "from", "babel", "-", "eslint" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/utils/module-require.js#L8-L13
train
benmosher/eslint-plugin-import
src/rules/namespace.js
function ({ body }) { function processBodyStatement(declaration) { if (declaration.type !== 'ImportDeclaration') return if (declaration.specifiers.length === 0) return const imports = Exports.get(declaration.source.value, context) if (imports == null) return null ...
javascript
function ({ body }) { function processBodyStatement(declaration) { if (declaration.type !== 'ImportDeclaration') return if (declaration.specifiers.length === 0) return const imports = Exports.get(declaration.source.value, context) if (imports == null) return null ...
[ "function", "(", "{", "body", "}", ")", "{", "function", "processBodyStatement", "(", "declaration", ")", "{", "if", "(", "declaration", ".", "type", "!==", "'ImportDeclaration'", ")", "return", "if", "(", "declaration", ".", "specifiers", ".", "length", "==...
pick up all imports at body entry time, to properly respect hoisting
[ "pick", "up", "all", "imports", "at", "body", "entry", "time", "to", "properly", "respect", "hoisting" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/namespace.js#L48-L84
train
benmosher/eslint-plugin-import
src/rules/namespace.js
function (namespace) { var declaration = importDeclaration(context) var imports = Exports.get(declaration.source.value, context) if (imports == null) return null if (imports.errors.length) { imports.reportErrors(context, declaration) return } if (!i...
javascript
function (namespace) { var declaration = importDeclaration(context) var imports = Exports.get(declaration.source.value, context) if (imports == null) return null if (imports.errors.length) { imports.reportErrors(context, declaration) return } if (!i...
[ "function", "(", "namespace", ")", "{", "var", "declaration", "=", "importDeclaration", "(", "context", ")", "var", "imports", "=", "Exports", ".", "get", "(", "declaration", ".", "source", ".", "value", ",", "context", ")", "if", "(", "imports", "==", "...
same as above, but does not add names to local map
[ "same", "as", "above", "but", "does", "not", "add", "names", "to", "local", "map" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/namespace.js#L87-L102
train
benmosher/eslint-plugin-import
utils/moduleVisitor.js
checkCommon
function checkCommon(call) { if (call.callee.type !== 'Identifier') return if (call.callee.name !== 'require') return if (call.arguments.length !== 1) return const modulePath = call.arguments[0] if (modulePath.type !== 'Literal') return if (typeof modulePath.value !== 'string') return chec...
javascript
function checkCommon(call) { if (call.callee.type !== 'Identifier') return if (call.callee.name !== 'require') return if (call.arguments.length !== 1) return const modulePath = call.arguments[0] if (modulePath.type !== 'Literal') return if (typeof modulePath.value !== 'string') return chec...
[ "function", "checkCommon", "(", "call", ")", "{", "if", "(", "call", ".", "callee", ".", "type", "!==", "'Identifier'", ")", "return", "if", "(", "call", ".", "callee", ".", "name", "!==", "'require'", ")", "return", "if", "(", "call", ".", "arguments"...
for CommonJS `require` calls adapted from @mctep: http://git.io/v4rAu
[ "for", "CommonJS", "require", "calls", "adapted", "from" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/utils/moduleVisitor.js#L51-L61
train
benmosher/eslint-plugin-import
utils/moduleVisitor.js
makeOptionsSchema
function makeOptionsSchema(additionalProperties) { const base = { 'type': 'object', 'properties': { 'commonjs': { 'type': 'boolean' }, 'amd': { 'type': 'boolean' }, 'esmodule': { 'type': 'boolean' }, 'ignore': { 'type': 'array', 'minItems': 1, 'items': { 'type'...
javascript
function makeOptionsSchema(additionalProperties) { const base = { 'type': 'object', 'properties': { 'commonjs': { 'type': 'boolean' }, 'amd': { 'type': 'boolean' }, 'esmodule': { 'type': 'boolean' }, 'ignore': { 'type': 'array', 'minItems': 1, 'items': { 'type'...
[ "function", "makeOptionsSchema", "(", "additionalProperties", ")", "{", "const", "base", "=", "{", "'type'", ":", "'object'", ",", "'properties'", ":", "{", "'commonjs'", ":", "{", "'type'", ":", "'boolean'", "}", ",", "'amd'", ":", "{", "'type'", ":", "'b...
make an options schema for the module visitor, optionally adding extra fields.
[ "make", "an", "options", "schema", "for", "the", "module", "visitor", "optionally", "adding", "extra", "fields", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/utils/moduleVisitor.js#L109-L133
train
benmosher/eslint-plugin-import
src/rules/order.js
reverse
function reverse(array) { return array.map(function (v) { return { name: v.name, rank: -v.rank, node: v.node, } }).reverse() }
javascript
function reverse(array) { return array.map(function (v) { return { name: v.name, rank: -v.rank, node: v.node, } }).reverse() }
[ "function", "reverse", "(", "array", ")", "{", "return", "array", ".", "map", "(", "function", "(", "v", ")", "{", "return", "{", "name", ":", "v", ".", "name", ",", "rank", ":", "-", "v", ".", "rank", ",", "node", ":", "v", ".", "node", ",", ...
REPORTING AND FIXING
[ "REPORTING", "AND", "FIXING" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/order.js#L11-L19
train
benmosher/eslint-plugin-import
src/rules/no-internal-modules.js
isReachViolation
function isReachViolation(importPath) { const steps = normalizeSep(importPath) .split('/') .reduce((acc, step) => { if (!step || step === '.') { return acc } else if (step === '..') { return acc.slice(0, -1) } else { return acc.conc...
javascript
function isReachViolation(importPath) { const steps = normalizeSep(importPath) .split('/') .reduce((acc, step) => { if (!step || step === '.') { return acc } else if (step === '..') { return acc.slice(0, -1) } else { return acc.conc...
[ "function", "isReachViolation", "(", "importPath", ")", "{", "const", "steps", "=", "normalizeSep", "(", "importPath", ")", ".", "split", "(", "'/'", ")", ".", "reduce", "(", "(", "acc", ",", "step", ")", "=>", "{", "if", "(", "!", "step", "||", "ste...
find a directory that is being reached into, but which shouldn't be
[ "find", "a", "directory", "that", "is", "being", "reached", "into", "but", "which", "shouldn", "t", "be" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-internal-modules.js#L47-L76
train
benmosher/eslint-plugin-import
src/ExportMap.js
captureDoc
function captureDoc(source, docStyleParsers, ...nodes) { const metadata = {} // 'some' short-circuits on first 'true' nodes.some(n => { try { let leadingComments // n.leadingComments is legacy `attachComments` behavior if ('leadingComments' in n) { leadingComments = n.leadingComme...
javascript
function captureDoc(source, docStyleParsers, ...nodes) { const metadata = {} // 'some' short-circuits on first 'true' nodes.some(n => { try { let leadingComments // n.leadingComments is legacy `attachComments` behavior if ('leadingComments' in n) { leadingComments = n.leadingComme...
[ "function", "captureDoc", "(", "source", ",", "docStyleParsers", ",", "...", "nodes", ")", "{", "const", "metadata", "=", "{", "}", "// 'some' short-circuits on first 'true'", "nodes", ".", "some", "(", "n", "=>", "{", "try", "{", "let", "leadingComments", "//...
parse docs from the first node that has leading comments
[ "parse", "docs", "from", "the", "first", "node", "that", "has", "leading", "comments" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/ExportMap.js#L196-L228
train
benmosher/eslint-plugin-import
src/ExportMap.js
captureJsDoc
function captureJsDoc(comments) { let doc // capture XSDoc comments.forEach(comment => { // skip non-block comments if (comment.type !== 'Block') return try { doc = doctrine.parse(comment.value, { unwrap: true }) } catch (err) { /* don't care, for now? maybe add to `errors?` */ } ...
javascript
function captureJsDoc(comments) { let doc // capture XSDoc comments.forEach(comment => { // skip non-block comments if (comment.type !== 'Block') return try { doc = doctrine.parse(comment.value, { unwrap: true }) } catch (err) { /* don't care, for now? maybe add to `errors?` */ } ...
[ "function", "captureJsDoc", "(", "comments", ")", "{", "let", "doc", "// capture XSDoc", "comments", ".", "forEach", "(", "comment", "=>", "{", "// skip non-block comments", "if", "(", "comment", ".", "type", "!==", "'Block'", ")", "return", "try", "{", "doc",...
parse JSDoc from leading comments @param {...[type]} comments [description] @return {{doc: object}}
[ "parse", "JSDoc", "from", "leading", "comments" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/ExportMap.js#L240-L255
train
benmosher/eslint-plugin-import
src/ExportMap.js
captureTomDoc
function captureTomDoc(comments) { // collect lines up to first paragraph break const lines = [] for (let i = 0; i < comments.length; i++) { const comment = comments[i] if (comment.value.match(/^\s*$/)) break lines.push(comment.value.trim()) } // return doctrine-like object const statusMatch = ...
javascript
function captureTomDoc(comments) { // collect lines up to first paragraph break const lines = [] for (let i = 0; i < comments.length; i++) { const comment = comments[i] if (comment.value.match(/^\s*$/)) break lines.push(comment.value.trim()) } // return doctrine-like object const statusMatch = ...
[ "function", "captureTomDoc", "(", "comments", ")", "{", "// collect lines up to first paragraph break", "const", "lines", "=", "[", "]", "for", "(", "let", "i", "=", "0", ";", "i", "<", "comments", ".", "length", ";", "i", "++", ")", "{", "const", "comment...
parse TomDoc section from comments
[ "parse", "TomDoc", "section", "from", "comments" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/ExportMap.js#L260-L280
train
benmosher/eslint-plugin-import
src/ExportMap.js
childContext
function childContext(path, context) { const { settings, parserOptions, parserPath } = context return { settings, parserOptions, parserPath, path, } }
javascript
function childContext(path, context) { const { settings, parserOptions, parserPath } = context return { settings, parserOptions, parserPath, path, } }
[ "function", "childContext", "(", "path", ",", "context", ")", "{", "const", "{", "settings", ",", "parserOptions", ",", "parserPath", "}", "=", "context", "return", "{", "settings", ",", "parserOptions", ",", "parserPath", ",", "path", ",", "}", "}" ]
don't hold full context object in memory, just grab what we need.
[ "don", "t", "hold", "full", "context", "object", "in", "memory", "just", "grab", "what", "we", "need", "." ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/ExportMap.js#L562-L570
train
benmosher/eslint-plugin-import
src/ExportMap.js
makeSourceCode
function makeSourceCode(text, ast) { if (SourceCode.length > 1) { // ESLint 3 return new SourceCode(text, ast) } else { // ESLint 4, 5 return new SourceCode({ text, ast }) } }
javascript
function makeSourceCode(text, ast) { if (SourceCode.length > 1) { // ESLint 3 return new SourceCode(text, ast) } else { // ESLint 4, 5 return new SourceCode({ text, ast }) } }
[ "function", "makeSourceCode", "(", "text", ",", "ast", ")", "{", "if", "(", "SourceCode", ".", "length", ">", "1", ")", "{", "// ESLint 3", "return", "new", "SourceCode", "(", "text", ",", "ast", ")", "}", "else", "{", "// ESLint 4, 5", "return", "new", ...
sometimes legacy support isn't _that_ hard... right?
[ "sometimes", "legacy", "support", "isn", "t", "_that_", "hard", "...", "right?" ]
1edbbd03ec636469328ad59da922ed7edc8cd36d
https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/ExportMap.js#L576-L584
train
jprichardson/node-fs-extra
lib/copy-sync/copy-sync.js
isSrcSubdir
function isSrcSubdir (src, dest) { const srcArray = path.resolve(src).split(path.sep) const destArray = path.resolve(dest).split(path.sep) return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true) }
javascript
function isSrcSubdir (src, dest) { const srcArray = path.resolve(src).split(path.sep) const destArray = path.resolve(dest).split(path.sep) return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true) }
[ "function", "isSrcSubdir", "(", "src", ",", "dest", ")", "{", "const", "srcArray", "=", "path", ".", "resolve", "(", "src", ")", ".", "split", "(", "path", ".", "sep", ")", "const", "destArray", "=", "path", ".", "resolve", "(", "dest", ")", ".", "...
return true if dest is a subdir of src, otherwise false.
[ "return", "true", "if", "dest", "is", "a", "subdir", "of", "src", "otherwise", "false", "." ]
8e0879110fbdd597c36602fe3b81ef03a4b3ec7a
https://github.com/jprichardson/node-fs-extra/blob/8e0879110fbdd597c36602fe3b81ef03a4b3ec7a/lib/copy-sync/copy-sync.js#L164-L168
train
jprichardson/node-fs-extra
lib/mkdirs/win32.js
getRootPath
function getRootPath (p) { p = path.normalize(path.resolve(p)).split(path.sep) if (p.length > 0) return p[0] return null }
javascript
function getRootPath (p) { p = path.normalize(path.resolve(p)).split(path.sep) if (p.length > 0) return p[0] return null }
[ "function", "getRootPath", "(", "p", ")", "{", "p", "=", "path", ".", "normalize", "(", "path", ".", "resolve", "(", "p", ")", ")", ".", "split", "(", "path", ".", "sep", ")", "if", "(", "p", ".", "length", ">", "0", ")", "return", "p", "[", ...
get drive on windows
[ "get", "drive", "on", "windows" ]
8e0879110fbdd597c36602fe3b81ef03a4b3ec7a
https://github.com/jprichardson/node-fs-extra/blob/8e0879110fbdd597c36602fe3b81ef03a4b3ec7a/lib/mkdirs/win32.js#L6-L10
train
jprichardson/node-fs-extra
lib/remove/rimraf.js
rimraf_
function rimraf_ (p, options, cb) { assert(p) assert(options) assert(typeof cb === 'function') // sunos lets the root user unlink directories, which is... weird. // so we have to lstat here and make sure it's not a dir. options.lstat(p, (er, st) => { if (er && er.code === 'ENOENT') { return cb(nu...
javascript
function rimraf_ (p, options, cb) { assert(p) assert(options) assert(typeof cb === 'function') // sunos lets the root user unlink directories, which is... weird. // so we have to lstat here and make sure it's not a dir. options.lstat(p, (er, st) => { if (er && er.code === 'ENOENT') { return cb(nu...
[ "function", "rimraf_", "(", "p", ",", "options", ",", "cb", ")", "{", "assert", "(", "p", ")", "assert", "(", "options", ")", "assert", "(", "typeof", "cb", "===", "'function'", ")", "// sunos lets the root user unlink directories, which is... weird.", "// so we h...
Two possible strategies. 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR Both result in an extra syscall when you guess wrong. However, there are likely far more normal files in the world than directories. This is bas...
[ "Two", "possible", "strategies", ".", "1", ".", "Assume", "it", "s", "a", "file", ".", "unlink", "it", "then", "do", "the", "dir", "stuff", "on", "EPERM", "or", "EISDIR", "2", ".", "Assume", "it", "s", "a", "directory", ".", "readdir", "then", "do", ...
8e0879110fbdd597c36602fe3b81ef03a4b3ec7a
https://github.com/jprichardson/node-fs-extra/blob/8e0879110fbdd597c36602fe3b81ef03a4b3ec7a/lib/remove/rimraf.js#L72-L110
train
jprichardson/node-fs-extra
lib/move-sync/index.js
isSrcSubdir
function isSrcSubdir (src, dest) { try { return fs.statSync(src).isDirectory() && src !== dest && dest.indexOf(src) > -1 && dest.split(path.dirname(src) + path.sep)[1].split(path.sep)[0] === path.basename(src) } catch (e) { return false } }
javascript
function isSrcSubdir (src, dest) { try { return fs.statSync(src).isDirectory() && src !== dest && dest.indexOf(src) > -1 && dest.split(path.dirname(src) + path.sep)[1].split(path.sep)[0] === path.basename(src) } catch (e) { return false } }
[ "function", "isSrcSubdir", "(", "src", ",", "dest", ")", "{", "try", "{", "return", "fs", ".", "statSync", "(", "src", ")", ".", "isDirectory", "(", ")", "&&", "src", "!==", "dest", "&&", "dest", ".", "indexOf", "(", "src", ")", ">", "-", "1", "&...
return true if dest is a subdir of src, otherwise false. extract dest base dir and check if that is the same as src basename
[ "return", "true", "if", "dest", "is", "a", "subdir", "of", "src", "otherwise", "false", ".", "extract", "dest", "base", "dir", "and", "check", "if", "that", "is", "the", "same", "as", "src", "basename" ]
8e0879110fbdd597c36602fe3b81ef03a4b3ec7a
https://github.com/jprichardson/node-fs-extra/blob/8e0879110fbdd597c36602fe3b81ef03a4b3ec7a/lib/move-sync/index.js#L104-L113
train
gpbl/react-day-picker
lib/src/ModifiersUtils.js
dayMatchesModifier
function dayMatchesModifier(day, modifier) { if (!modifier) { return false; } var arr = Array.isArray(modifier) ? modifier : [modifier]; return arr.some(function (mod) { if (!mod) { return false; } if (mod instanceof Date) { return (0, _DateUtils.isSameDay)(day, mod); } if ((...
javascript
function dayMatchesModifier(day, modifier) { if (!modifier) { return false; } var arr = Array.isArray(modifier) ? modifier : [modifier]; return arr.some(function (mod) { if (!mod) { return false; } if (mod instanceof Date) { return (0, _DateUtils.isSameDay)(day, mod); } if ((...
[ "function", "dayMatchesModifier", "(", "day", ",", "modifier", ")", "{", "if", "(", "!", "modifier", ")", "{", "return", "false", ";", "}", "var", "arr", "=", "Array", ".", "isArray", "(", "modifier", ")", "?", "modifier", ":", "[", "modifier", "]", ...
Return `true` if a date matches the specified modifier. @export @param {Date} day @param {Any} modifier @return {Boolean}
[ "Return", "true", "if", "a", "date", "matches", "the", "specified", "modifier", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/ModifiersUtils.js#L21-L58
train
gpbl/react-day-picker
lib/src/ModifiersUtils.js
getModifiersForDay
function getModifiersForDay(day) { var modifiersObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return Object.keys(modifiersObj).reduce(function (modifiers, modifierName) { var value = modifiersObj[modifierName]; if (dayMatchesModifier(day, value)) { modifiers.push(modif...
javascript
function getModifiersForDay(day) { var modifiersObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return Object.keys(modifiersObj).reduce(function (modifiers, modifierName) { var value = modifiersObj[modifierName]; if (dayMatchesModifier(day, value)) { modifiers.push(modif...
[ "function", "getModifiersForDay", "(", "day", ")", "{", "var", "modifiersObj", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "}", ";", "return", "Object", "."...
Return the modifiers matching the given day for the given object of modifiers. @export @param {Date} day @param {Object} [modifiersObj={}] @return {Array}
[ "Return", "the", "modifiers", "matching", "the", "given", "day", "for", "the", "given", "object", "of", "modifiers", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/ModifiersUtils.js#L69-L79
train
gpbl/react-day-picker
lib/src/DateUtils.js
addMonths
function addMonths(d, n) { var newDate = clone(d); newDate.setMonth(d.getMonth() + n); return newDate; }
javascript
function addMonths(d, n) { var newDate = clone(d); newDate.setMonth(d.getMonth() + n); return newDate; }
[ "function", "addMonths", "(", "d", ",", "n", ")", "{", "var", "newDate", "=", "clone", "(", "d", ")", ";", "newDate", ".", "setMonth", "(", "d", ".", "getMonth", "(", ")", "+", "n", ")", ";", "return", "newDate", ";", "}" ]
Return `d` as a new date with `n` months added. @export @param {[type]} d @param {[type]} n
[ "Return", "d", "as", "a", "new", "date", "with", "n", "months", "added", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L48-L52
train
gpbl/react-day-picker
lib/src/DateUtils.js
isSameDay
function isSameDay(d1, d2) { if (!d1 || !d2) { return false; } return d1.getDate() === d2.getDate() && d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear(); }
javascript
function isSameDay(d1, d2) { if (!d1 || !d2) { return false; } return d1.getDate() === d2.getDate() && d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear(); }
[ "function", "isSameDay", "(", "d1", ",", "d2", ")", "{", "if", "(", "!", "d1", "||", "!", "d2", ")", "{", "return", "false", ";", "}", "return", "d1", ".", "getDate", "(", ")", "===", "d2", ".", "getDate", "(", ")", "&&", "d1", ".", "getMonth",...
Return `true` if two dates are the same day, ignoring the time. @export @param {Date} d1 @param {Date} d2 @return {Boolean}
[ "Return", "true", "if", "two", "dates", "are", "the", "same", "day", "ignoring", "the", "time", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L62-L67
train
gpbl/react-day-picker
lib/src/DateUtils.js
isSameMonth
function isSameMonth(d1, d2) { if (!d1 || !d2) { return false; } return d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear(); }
javascript
function isSameMonth(d1, d2) { if (!d1 || !d2) { return false; } return d1.getMonth() === d2.getMonth() && d1.getFullYear() === d2.getFullYear(); }
[ "function", "isSameMonth", "(", "d1", ",", "d2", ")", "{", "if", "(", "!", "d1", "||", "!", "d2", ")", "{", "return", "false", ";", "}", "return", "d1", ".", "getMonth", "(", ")", "===", "d2", ".", "getMonth", "(", ")", "&&", "d1", ".", "getFul...
Return `true` if two dates fall in the same month. @export @param {Date} d1 @param {Date} d2 @return {Boolean}
[ "Return", "true", "if", "two", "dates", "fall", "in", "the", "same", "month", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L77-L82
train
gpbl/react-day-picker
lib/src/DateUtils.js
isDayBefore
function isDayBefore(d1, d2) { var day1 = clone(d1).setHours(0, 0, 0, 0); var day2 = clone(d2).setHours(0, 0, 0, 0); return day1 < day2; }
javascript
function isDayBefore(d1, d2) { var day1 = clone(d1).setHours(0, 0, 0, 0); var day2 = clone(d2).setHours(0, 0, 0, 0); return day1 < day2; }
[ "function", "isDayBefore", "(", "d1", ",", "d2", ")", "{", "var", "day1", "=", "clone", "(", "d1", ")", ".", "setHours", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "var", "day2", "=", "clone", "(", "d2", ")", ".", "setHours", "(", "0",...
Returns `true` if the first day is before the second day. @export @param {Date} d1 @param {Date} d2 @returns {Boolean}
[ "Returns", "true", "if", "the", "first", "day", "is", "before", "the", "second", "day", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L92-L96
train
gpbl/react-day-picker
lib/src/DateUtils.js
isDayAfter
function isDayAfter(d1, d2) { var day1 = clone(d1).setHours(0, 0, 0, 0); var day2 = clone(d2).setHours(0, 0, 0, 0); return day1 > day2; }
javascript
function isDayAfter(d1, d2) { var day1 = clone(d1).setHours(0, 0, 0, 0); var day2 = clone(d2).setHours(0, 0, 0, 0); return day1 > day2; }
[ "function", "isDayAfter", "(", "d1", ",", "d2", ")", "{", "var", "day1", "=", "clone", "(", "d1", ")", ".", "setHours", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "var", "day2", "=", "clone", "(", "d2", ")", ".", "setHours", "(", "0", ...
Returns `true` if the first day is after the second day. @export @param {Date} d1 @param {Date} d2 @returns {Boolean}
[ "Returns", "true", "if", "the", "first", "day", "is", "after", "the", "second", "day", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L106-L110
train
gpbl/react-day-picker
lib/src/DateUtils.js
isDayBetween
function isDayBetween(d, d1, d2) { var date = clone(d); date.setHours(0, 0, 0, 0); return isDayAfter(date, d1) && isDayBefore(date, d2) || isDayAfter(date, d2) && isDayBefore(date, d1); }
javascript
function isDayBetween(d, d1, d2) { var date = clone(d); date.setHours(0, 0, 0, 0); return isDayAfter(date, d1) && isDayBefore(date, d2) || isDayAfter(date, d2) && isDayBefore(date, d1); }
[ "function", "isDayBetween", "(", "d", ",", "d1", ",", "d2", ")", "{", "var", "date", "=", "clone", "(", "d", ")", ";", "date", ".", "setHours", "(", "0", ",", "0", ",", "0", ",", "0", ")", ";", "return", "isDayAfter", "(", "date", ",", "d1", ...
Return `true` if day `d` is between days `d1` and `d2`, without including them. @export @param {Date} d @param {Date} d1 @param {Date} d2 @return {Boolean}
[ "Return", "true", "if", "day", "d", "is", "between", "days", "d1", "and", "d2", "without", "including", "them", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L150-L154
train
gpbl/react-day-picker
lib/src/DateUtils.js
addDayToRange
function addDayToRange(day) { var range = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: null, to: null }; var from = range.from, to = range.to; if (!from) { from = day; } else if (from && to && isSameDay(from, to) && isSameDay(day, from)) { from = null; to = null...
javascript
function addDayToRange(day) { var range = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: null, to: null }; var from = range.from, to = range.to; if (!from) { from = day; } else if (from && to && isSameDay(from, to) && isSameDay(day, from)) { from = null; to = null...
[ "function", "addDayToRange", "(", "day", ")", "{", "var", "range", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "from", ":", "null", ",", "to", ":", "nul...
Add a day to a range and return a new range. A range is an object with `from` and `to` days. @export @param {Date} day @param {Object} range @return {Object} Returns a new range object
[ "Add", "a", "day", "to", "a", "range", "and", "return", "a", "new", "range", ".", "A", "range", "is", "an", "object", "with", "from", "and", "to", "days", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L165-L189
train
gpbl/react-day-picker
lib/src/DateUtils.js
isDayInRange
function isDayInRange(day, range) { var from = range.from, to = range.to; return from && isSameDay(day, from) || to && isSameDay(day, to) || from && to && isDayBetween(day, from, to); }
javascript
function isDayInRange(day, range) { var from = range.from, to = range.to; return from && isSameDay(day, from) || to && isSameDay(day, to) || from && to && isDayBetween(day, from, to); }
[ "function", "isDayInRange", "(", "day", ",", "range", ")", "{", "var", "from", "=", "range", ".", "from", ",", "to", "=", "range", ".", "to", ";", "return", "from", "&&", "isSameDay", "(", "day", ",", "from", ")", "||", "to", "&&", "isSameDay", "("...
Return `true` if a day is included in a range of days. @export @param {Date} day @param {Object} range @return {Boolean}
[ "Return", "true", "if", "a", "day", "is", "included", "in", "a", "range", "of", "days", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DateUtils.js#L199-L204
train
gpbl/react-day-picker
lib/src/DayPickerInput.js
OverlayComponent
function OverlayComponent(_ref) { var input = _ref.input, selectedDay = _ref.selectedDay, month = _ref.month, children = _ref.children, classNames = _ref.classNames, props = _objectWithoutProperties(_ref, ['input', 'selectedDay', 'month', 'children', 'classNames']); return _react2.def...
javascript
function OverlayComponent(_ref) { var input = _ref.input, selectedDay = _ref.selectedDay, month = _ref.month, children = _ref.children, classNames = _ref.classNames, props = _objectWithoutProperties(_ref, ['input', 'selectedDay', 'month', 'children', 'classNames']); return _react2.def...
[ "function", "OverlayComponent", "(", "_ref", ")", "{", "var", "input", "=", "_ref", ".", "input", ",", "selectedDay", "=", "_ref", ".", "selectedDay", ",", "month", "=", "_ref", ".", "month", ",", "children", "=", "_ref", ".", "children", ",", "className...
The default component used as Overlay. @param {Object} props
[ "The", "default", "component", "used", "as", "Overlay", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DayPickerInput.js#L54-L71
train
gpbl/react-day-picker
lib/src/DayPickerInput.js
defaultFormat
function defaultFormat(d) { if ((0, _DateUtils.isDate)(d)) { var year = d.getFullYear(); var month = '' + (d.getMonth() + 1); var day = '' + d.getDate(); return year + '-' + month + '-' + day; } return ''; }
javascript
function defaultFormat(d) { if ((0, _DateUtils.isDate)(d)) { var year = d.getFullYear(); var month = '' + (d.getMonth() + 1); var day = '' + d.getDate(); return year + '-' + month + '-' + day; } return ''; }
[ "function", "defaultFormat", "(", "d", ")", "{", "if", "(", "(", "0", ",", "_DateUtils", ".", "isDate", ")", "(", "d", ")", ")", "{", "var", "year", "=", "d", ".", "getFullYear", "(", ")", ";", "var", "month", "=", "''", "+", "(", "d", ".", "...
The default function used to format a Date to String, passed to the `format` prop. @param {Date} d @return {String}
[ "The", "default", "function", "used", "to", "format", "a", "Date", "to", "String", "passed", "to", "the", "format", "prop", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DayPickerInput.js#L87-L95
train
gpbl/react-day-picker
lib/src/DayPickerInput.js
defaultParse
function defaultParse(str) { if (typeof str !== 'string') { return undefined; } var split = str.split('-'); if (split.length !== 3) { return undefined; } var year = parseInt(split[0], 10); var month = parseInt(split[1], 10) - 1; var day = parseInt(split[2], 10); if (isNaN(year) || String(year)...
javascript
function defaultParse(str) { if (typeof str !== 'string') { return undefined; } var split = str.split('-'); if (split.length !== 3) { return undefined; } var year = parseInt(split[0], 10); var month = parseInt(split[1], 10) - 1; var day = parseInt(split[2], 10); if (isNaN(year) || String(year)...
[ "function", "defaultParse", "(", "str", ")", "{", "if", "(", "typeof", "str", "!==", "'string'", ")", "{", "return", "undefined", ";", "}", "var", "split", "=", "str", ".", "split", "(", "'-'", ")", ";", "if", "(", "split", ".", "length", "!==", "3...
The default function used to parse a String as Date, passed to the `parse` prop. @param {String} str @return {Date}
[ "The", "default", "function", "used", "to", "parse", "a", "String", "as", "Date", "passed", "to", "the", "parse", "prop", "." ]
421af9f56b1b07ed58f864678b3bbb8617cdaff7
https://github.com/gpbl/react-day-picker/blob/421af9f56b1b07ed58f864678b3bbb8617cdaff7/lib/src/DayPickerInput.js#L103-L119
train
davidjbradshaw/iframe-resizer
js/iframeResizer.contentWindow.js
throttle
function throttle(func) { var context, args, result, timeout = null, previous = 0, later = function() { previous = getNow() timeout = null result = func.apply(context, args) if (!timeout) { // eslint-disable-next-line no-multi-assign ...
javascript
function throttle(func) { var context, args, result, timeout = null, previous = 0, later = function() { previous = getNow() timeout = null result = func.apply(context, args) if (!timeout) { // eslint-disable-next-line no-multi-assign ...
[ "function", "throttle", "(", "func", ")", "{", "var", "context", ",", "args", ",", "result", ",", "timeout", "=", "null", ",", "previous", "=", "0", ",", "later", "=", "function", "(", ")", "{", "previous", "=", "getNow", "(", ")", "timeout", "=", ...
Based on underscore.js
[ "Based", "on", "underscore", ".", "js" ]
772f24df77444aff5e6520ce31bf93111c70f0b3
https://github.com/davidjbradshaw/iframe-resizer/blob/772f24df77444aff5e6520ce31bf93111c70f0b3/js/iframeResizer.contentWindow.js#L106-L153
train
davidjbradshaw/iframe-resizer
js/iframeResizer.contentWindow.js
getComputedStyle
function getComputedStyle(prop, el) { var retVal = 0 el = el || document.body // Not testable in phantonJS retVal = document.defaultView.getComputedStyle(el, null) retVal = null !== retVal ? retVal[prop] : 0 return parseInt(retVal, base) }
javascript
function getComputedStyle(prop, el) { var retVal = 0 el = el || document.body // Not testable in phantonJS retVal = document.defaultView.getComputedStyle(el, null) retVal = null !== retVal ? retVal[prop] : 0 return parseInt(retVal, base) }
[ "function", "getComputedStyle", "(", "prop", ",", "el", ")", "{", "var", "retVal", "=", "0", "el", "=", "el", "||", "document", ".", "body", "// Not testable in phantonJS", "retVal", "=", "document", ".", "defaultView", ".", "getComputedStyle", "(", "el", ",...
document.documentElement.offsetHeight is not reliable, so we have to jump through hoops to get a better value.
[ "document", ".", "documentElement", ".", "offsetHeight", "is", "not", "reliable", "so", "we", "have", "to", "jump", "through", "hoops", "to", "get", "a", "better", "value", "." ]
772f24df77444aff5e6520ce31bf93111c70f0b3
https://github.com/davidjbradshaw/iframe-resizer/blob/772f24df77444aff5e6520ce31bf93111c70f0b3/js/iframeResizer.contentWindow.js#L853-L861
train
davidjbradshaw/iframe-resizer
js/iframeResizer.js
setupBodyMarginValues
function setupBodyMarginValues() { if ( 'number' === typeof (settings[iframeId] && settings[iframeId].bodyMargin) || '0' === (settings[iframeId] && settings[iframeId].bodyMargin) ) { settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin settings[iframeId]....
javascript
function setupBodyMarginValues() { if ( 'number' === typeof (settings[iframeId] && settings[iframeId].bodyMargin) || '0' === (settings[iframeId] && settings[iframeId].bodyMargin) ) { settings[iframeId].bodyMarginV1 = settings[iframeId].bodyMargin settings[iframeId]....
[ "function", "setupBodyMarginValues", "(", ")", "{", "if", "(", "'number'", "===", "typeof", "(", "settings", "[", "iframeId", "]", "&&", "settings", "[", "iframeId", "]", ".", "bodyMargin", ")", "||", "'0'", "===", "(", "settings", "[", "iframeId", "]", ...
The V1 iFrame script expects an int, where as in V2 expects a CSS string value such as '1px 3em', so if we have an int for V2, set V1=V2 and then convert V2 to a string PX value.
[ "The", "V1", "iFrame", "script", "expects", "an", "int", "where", "as", "in", "V2", "expects", "a", "CSS", "string", "value", "such", "as", "1px", "3em", "so", "if", "we", "have", "an", "int", "for", "V2", "set", "V1", "=", "V2", "and", "then", "co...
772f24df77444aff5e6520ce31bf93111c70f0b3
https://github.com/davidjbradshaw/iframe-resizer/blob/772f24df77444aff5e6520ce31bf93111c70f0b3/js/iframeResizer.js#L939-L949
train
davidjbradshaw/iframe-resizer
js/iframeResizer.js
init
function init(msg) { function iFrameLoaded() { trigger('iFrame.onload', msg, iframe, undefined, true) checkReset() } function createDestroyObserver(MutationObserver) { if (!iframe.parentNode) { return } var destroyObserver = new MutationObserver(func...
javascript
function init(msg) { function iFrameLoaded() { trigger('iFrame.onload', msg, iframe, undefined, true) checkReset() } function createDestroyObserver(MutationObserver) { if (!iframe.parentNode) { return } var destroyObserver = new MutationObserver(func...
[ "function", "init", "(", "msg", ")", "{", "function", "iFrameLoaded", "(", ")", "{", "trigger", "(", "'iFrame.onload'", ",", "msg", ",", "iframe", ",", "undefined", ",", "true", ")", "checkReset", "(", ")", "}", "function", "createDestroyObserver", "(", "M...
We have to call trigger twice, as we can not be sure if all iframes have completed loading when this code runs. The event listener also catches the page changing in the iFrame.
[ "We", "have", "to", "call", "trigger", "twice", "as", "we", "can", "not", "be", "sure", "if", "all", "iframes", "have", "completed", "loading", "when", "this", "code", "runs", ".", "The", "event", "listener", "also", "catches", "the", "page", "changing", ...
772f24df77444aff5e6520ce31bf93111c70f0b3
https://github.com/davidjbradshaw/iframe-resizer/blob/772f24df77444aff5e6520ce31bf93111c70f0b3/js/iframeResizer.js#L1007-L1040
train
karma-runner/karma
lib/middleware/proxy.js
createProxyHandler
function createProxyHandler (proxies, urlRoot) { if (!proxies.length) { const nullProxy = (request, response, next) => next() nullProxy.upgrade = () => {} return nullProxy } function createProxy (request, response, next) { const proxyRecord = proxies.find((p) => request.url.startsWith(p.path)) ...
javascript
function createProxyHandler (proxies, urlRoot) { if (!proxies.length) { const nullProxy = (request, response, next) => next() nullProxy.upgrade = () => {} return nullProxy } function createProxy (request, response, next) { const proxyRecord = proxies.find((p) => request.url.startsWith(p.path)) ...
[ "function", "createProxyHandler", "(", "proxies", ",", "urlRoot", ")", "{", "if", "(", "!", "proxies", ".", "length", ")", "{", "const", "nullProxy", "=", "(", "request", ",", "response", ",", "next", ")", "=>", "next", "(", ")", "nullProxy", ".", "upg...
Returns a handler which understands the proxies and its redirects, along with the proxy to use @param proxies An array of proxy record objects @param urlRoot The URL root that karma is mounted on @return {Function} handler function
[ "Returns", "a", "handler", "which", "understands", "the", "proxies", "and", "its", "redirects", "along", "with", "the", "proxy", "to", "use" ]
fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e
https://github.com/karma-runner/karma/blob/fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e/lib/middleware/proxy.js#L78-L112
train
karma-runner/karma
lib/middleware/source_files.js
createSourceFilesMiddleware
function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) { return function (request, response, next) { const requestedFilePath = composeUrl(request.url, basePath, urlRoot) // When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /) const requested...
javascript
function createSourceFilesMiddleware (filesPromise, serveFile, basePath, urlRoot) { return function (request, response, next) { const requestedFilePath = composeUrl(request.url, basePath, urlRoot) // When a path contains HTML-encoded characters (e.g %2F used by Jenkins for branches with /) const requested...
[ "function", "createSourceFilesMiddleware", "(", "filesPromise", ",", "serveFile", ",", "basePath", ",", "urlRoot", ")", "{", "return", "function", "(", "request", ",", "response", ",", "next", ")", "{", "const", "requestedFilePath", "=", "composeUrl", "(", "requ...
Source Files middleware is responsible for serving all the source files under the test.
[ "Source", "Files", "middleware", "is", "responsible", "for", "serving", "all", "the", "source", "files", "under", "the", "test", "." ]
fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e
https://github.com/karma-runner/karma/blob/fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e/lib/middleware/source_files.js#L21-L61
train
karma-runner/karma
lib/web-server.js
createReadFilePromise
function createReadFilePromise () { return (filepath) => { return new Promise((resolve, reject) => { fs.readFile(filepath, 'utf8', function (error, data) { if (error) { reject(new Error(`Cannot read ${filepath}, got: ${error}`)) } else if (!data) { reject(new Error(`No co...
javascript
function createReadFilePromise () { return (filepath) => { return new Promise((resolve, reject) => { fs.readFile(filepath, 'utf8', function (error, data) { if (error) { reject(new Error(`Cannot read ${filepath}, got: ${error}`)) } else if (!data) { reject(new Error(`No co...
[ "function", "createReadFilePromise", "(", ")", "{", "return", "(", "filepath", ")", "=>", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "fs", ".", "readFile", "(", "filepath", ",", "'utf8'", ",", "function", "(", ...
Bind the filesystem into the injectable file reader function
[ "Bind", "the", "filesystem", "into", "the", "injectable", "file", "reader", "function" ]
fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e
https://github.com/karma-runner/karma/blob/fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e/lib/web-server.js#L43-L57
train
karma-runner/karma
lib/launchers/capture_timeout.js
CaptureTimeoutLauncher
function CaptureTimeoutLauncher (timer, captureTimeout) { if (!captureTimeout) { return } let pendingTimeoutId = null this.on('start', () => { pendingTimeoutId = timer.setTimeout(() => { pendingTimeoutId = null if (this.state !== this.STATE_BEING_CAPTURED) { return } l...
javascript
function CaptureTimeoutLauncher (timer, captureTimeout) { if (!captureTimeout) { return } let pendingTimeoutId = null this.on('start', () => { pendingTimeoutId = timer.setTimeout(() => { pendingTimeoutId = null if (this.state !== this.STATE_BEING_CAPTURED) { return } l...
[ "function", "CaptureTimeoutLauncher", "(", "timer", ",", "captureTimeout", ")", "{", "if", "(", "!", "captureTimeout", ")", "{", "return", "}", "let", "pendingTimeoutId", "=", "null", "this", ".", "on", "(", "'start'", ",", "(", ")", "=>", "{", "pendingTim...
Kill browser if it does not capture in given `captureTimeout`.
[ "Kill", "browser", "if", "it", "does", "not", "capture", "in", "given", "captureTimeout", "." ]
fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e
https://github.com/karma-runner/karma/blob/fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e/lib/launchers/capture_timeout.js#L6-L32
train
karma-runner/karma
lib/launchers/base.js
BaseLauncher
function BaseLauncher (id, emitter) { if (this.start) { return } // TODO(vojta): figure out how to do inheritance with DI Object.keys(EventEmitter.prototype).forEach(function (method) { this[method] = EventEmitter.prototype[method] }, this) this.bind = KarmaEventEmitter.prototype.bind.bind(this) ...
javascript
function BaseLauncher (id, emitter) { if (this.start) { return } // TODO(vojta): figure out how to do inheritance with DI Object.keys(EventEmitter.prototype).forEach(function (method) { this[method] = EventEmitter.prototype[method] }, this) this.bind = KarmaEventEmitter.prototype.bind.bind(this) ...
[ "function", "BaseLauncher", "(", "id", ",", "emitter", ")", "{", "if", "(", "this", ".", "start", ")", "{", "return", "}", "// TODO(vojta): figure out how to do inheritance with DI", "Object", ".", "keys", "(", "EventEmitter", ".", "prototype", ")", ".", "forEac...
Base launcher that any custom launcher extends.
[ "Base", "launcher", "that", "any", "custom", "launcher", "extends", "." ]
fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e
https://github.com/karma-runner/karma/blob/fe9a1dd13b5eb3969f9e08acbce020e2a382fd9e/lib/launchers/base.js#L18-L133
train
kimmobrunfeldt/progressbar.js
Gruntfile.js
groupToElements
function groupToElements(array, n) { var lists = _.groupBy(array, function(element, index){ return Math.floor(index / n); }); return _.toArray(lists); }
javascript
function groupToElements(array, n) { var lists = _.groupBy(array, function(element, index){ return Math.floor(index / n); }); return _.toArray(lists); }
[ "function", "groupToElements", "(", "array", ",", "n", ")", "{", "var", "lists", "=", "_", ".", "groupBy", "(", "array", ",", "function", "(", "element", ",", "index", ")", "{", "return", "Math", ".", "floor", "(", "index", "/", "n", ")", ";", "}",...
Split array to smaller arrays containing n elements at max
[ "Split", "array", "to", "smaller", "arrays", "containing", "n", "elements", "at", "max" ]
cebeb0786a331de9e2083e416d191c5181047e53
https://github.com/kimmobrunfeldt/progressbar.js/blob/cebeb0786a331de9e2083e416d191c5181047e53/Gruntfile.js#L6-L12
train
kimmobrunfeldt/progressbar.js
src/utils.js
extend
function extend(destination, source, recursive) { destination = destination || {}; source = source || {}; recursive = recursive || false; for (var attrName in source) { if (source.hasOwnProperty(attrName)) { var destVal = destination[attrName]; var sourceVal = source[att...
javascript
function extend(destination, source, recursive) { destination = destination || {}; source = source || {}; recursive = recursive || false; for (var attrName in source) { if (source.hasOwnProperty(attrName)) { var destVal = destination[attrName]; var sourceVal = source[att...
[ "function", "extend", "(", "destination", ",", "source", ",", "recursive", ")", "{", "destination", "=", "destination", "||", "{", "}", ";", "source", "=", "source", "||", "{", "}", ";", "recursive", "=", "recursive", "||", "false", ";", "for", "(", "v...
Copy all attributes from source object to destination object. destination object is mutated.
[ "Copy", "all", "attributes", "from", "source", "object", "to", "destination", "object", ".", "destination", "object", "is", "mutated", "." ]
cebeb0786a331de9e2083e416d191c5181047e53
https://github.com/kimmobrunfeldt/progressbar.js/blob/cebeb0786a331de9e2083e416d191c5181047e53/src/utils.js#L8-L26
train
prescottprue/react-redux-firebase
src/actions/auth.js
createProfileWatchErrorHandler
function createProfileWatchErrorHandler(dispatch, firebase) { const { config: { onProfileListenerError, logErrors } } = firebase._ return function handleProfileError(err) { if (logErrors) { // eslint-disable-next-line no-console console.error(`Error with profile listener: ${err.message || ''}`, err)...
javascript
function createProfileWatchErrorHandler(dispatch, firebase) { const { config: { onProfileListenerError, logErrors } } = firebase._ return function handleProfileError(err) { if (logErrors) { // eslint-disable-next-line no-console console.error(`Error with profile listener: ${err.message || ''}`, err)...
[ "function", "createProfileWatchErrorHandler", "(", "dispatch", ",", "firebase", ")", "{", "const", "{", "config", ":", "{", "onProfileListenerError", ",", "logErrors", "}", "}", "=", "firebase", ".", "_", "return", "function", "handleProfileError", "(", "err", "...
Creates a function for handling errors from profile watcher. Used for both RTDB and Firestore. @param {Function} dispatch - Action dispatch function @param {Object} firebase - Internal firebase object @return {Function} Profile watch error handler function @private
[ "Creates", "a", "function", "for", "handling", "errors", "from", "profile", "watcher", ".", "Used", "for", "both", "RTDB", "and", "Firestore", "." ]
de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c
https://github.com/prescottprue/react-redux-firebase/blob/de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c/src/actions/auth.js#L151-L167
train
prescottprue/react-redux-firebase
bin/api-docs-upload.js
runCommand
function runCommand(cmd) { return exec(cmd).catch(err => Promise.reject( err.message && err.message.indexOf('not found') !== -1 ? new Error(`${cmd.split(' ')[0]} must be installed to upload`) : err ) ) }
javascript
function runCommand(cmd) { return exec(cmd).catch(err => Promise.reject( err.message && err.message.indexOf('not found') !== -1 ? new Error(`${cmd.split(' ')[0]} must be installed to upload`) : err ) ) }
[ "function", "runCommand", "(", "cmd", ")", "{", "return", "exec", "(", "cmd", ")", ".", "catch", "(", "err", "=>", "Promise", ".", "reject", "(", "err", ".", "message", "&&", "err", ".", "message", ".", "indexOf", "(", "'not found'", ")", "!==", "-",...
Run shell command with error handling. @param {String} cmd - Command to run @return {Promise} Resolves with stdout of running command @private
[ "Run", "shell", "command", "with", "error", "handling", "." ]
de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c
https://github.com/prescottprue/react-redux-firebase/blob/de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c/bin/api-docs-upload.js#L26-L34
train
prescottprue/react-redux-firebase
bin/api-docs-upload.js
uploadList
function uploadList(files) { return Promise.all( files.map(file => upload(file) .then(({ uploadPath, output }) => { console.log(`Successfully uploaded: ${uploadPath}`) // eslint-disable-line no-console return output }) .catch(err => { console.log('Error ...
javascript
function uploadList(files) { return Promise.all( files.map(file => upload(file) .then(({ uploadPath, output }) => { console.log(`Successfully uploaded: ${uploadPath}`) // eslint-disable-line no-console return output }) .catch(err => { console.log('Error ...
[ "function", "uploadList", "(", "files", ")", "{", "return", "Promise", ".", "all", "(", "files", ".", "map", "(", "file", "=>", "upload", "(", "file", ")", ".", "then", "(", "(", "{", "uploadPath", ",", "output", "}", ")", "=>", "{", "console", "."...
Upload list of files or folders to Google Cloud Storage @param {Array} files - List of files/folders to upload @return {Promise} Resolves with an array of upload results @private
[ "Upload", "list", "of", "files", "or", "folders", "to", "Google", "Cloud", "Storage" ]
de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c
https://github.com/prescottprue/react-redux-firebase/blob/de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c/bin/api-docs-upload.js#L61-L75
train
prescottprue/react-redux-firebase
src/utils/storage.js
createUploadMetaResponseHandler
function createUploadMetaResponseHandler({ fileData, firebase, uploadTaskSnapshot, downloadURL }) { /** * Converts upload meta data snapshot into an object (handling both * RTDB and Firestore) * @param {Object} metaDataSnapshot - Snapshot from metadata upload (from * RTDB or Firestore) * @retu...
javascript
function createUploadMetaResponseHandler({ fileData, firebase, uploadTaskSnapshot, downloadURL }) { /** * Converts upload meta data snapshot into an object (handling both * RTDB and Firestore) * @param {Object} metaDataSnapshot - Snapshot from metadata upload (from * RTDB or Firestore) * @retu...
[ "function", "createUploadMetaResponseHandler", "(", "{", "fileData", ",", "firebase", ",", "uploadTaskSnapshot", ",", "downloadURL", "}", ")", "{", "/**\n * Converts upload meta data snapshot into an object (handling both\n * RTDB and Firestore)\n * @param {Object} metaDataSnapsho...
Create a function to handle response from upload. @param {Object} fileData - File data which was uploaded @param {Object} uploadTaskSnapshot - Snapshot from storage upload task @return {Function} Function for handling upload result
[ "Create", "a", "function", "to", "handle", "response", "from", "upload", "." ]
de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c
https://github.com/prescottprue/react-redux-firebase/blob/de32c8e46f7f99b3e8d3afbbc9f8518ee15e0a5c/src/utils/storage.js#L49-L86
train
SSENSE/vue-carousel
docs/public/js/common.js
initMobileMenu
function initMobileMenu () { var mobileBar = document.getElementById('mobile-bar') var sidebar = document.querySelector('.sidebar') var menuButton = mobileBar.querySelector('.menu-button') menuButton.addEventListener('click', function () { sidebar.classList.toggle('open') }) document.bod...
javascript
function initMobileMenu () { var mobileBar = document.getElementById('mobile-bar') var sidebar = document.querySelector('.sidebar') var menuButton = mobileBar.querySelector('.menu-button') menuButton.addEventListener('click', function () { sidebar.classList.toggle('open') }) document.bod...
[ "function", "initMobileMenu", "(", ")", "{", "var", "mobileBar", "=", "document", ".", "getElementById", "(", "'mobile-bar'", ")", "var", "sidebar", "=", "document", ".", "querySelector", "(", "'.sidebar'", ")", "var", "menuButton", "=", "mobileBar", ".", "que...
Mobile burger menu button for toggling sidebar
[ "Mobile", "burger", "menu", "button", "for", "toggling", "sidebar" ]
7c8e213e6773100b7cfad19b3ee88feebd777970
https://github.com/SSENSE/vue-carousel/blob/7c8e213e6773100b7cfad19b3ee88feebd777970/docs/public/js/common.js#L80-L94
train
SSENSE/vue-carousel
docs/public/js/common.js
initVersionSelect
function initVersionSelect () { // version select var versionSelect = document.querySelector('.version-select') versionSelect && versionSelect.addEventListener('change', function (e) { var version = e.target.value var section = window.location.pathname.match(/\/v\d\/(\w+?)\//)[1] if (versi...
javascript
function initVersionSelect () { // version select var versionSelect = document.querySelector('.version-select') versionSelect && versionSelect.addEventListener('change', function (e) { var version = e.target.value var section = window.location.pathname.match(/\/v\d\/(\w+?)\//)[1] if (versi...
[ "function", "initVersionSelect", "(", ")", "{", "// version select", "var", "versionSelect", "=", "document", ".", "querySelector", "(", "'.version-select'", ")", "versionSelect", "&&", "versionSelect", ".", "addEventListener", "(", "'change'", ",", "function", "(", ...
Doc version select
[ "Doc", "version", "select" ]
7c8e213e6773100b7cfad19b3ee88feebd777970
https://github.com/SSENSE/vue-carousel/blob/7c8e213e6773100b7cfad19b3ee88feebd777970/docs/public/js/common.js#L100-L114
train
NaturalNode/natural
lib/natural/stemmers/porter_stemmer_fr.js
regions
function regions(token) { var r1, r2, rv, len; var i; r1 = r2 = rv = len = token.length; // R1 is the region after the first non-vowel following a vowel, for (var i = 0; i < len - 1 && r1 == len; i++) { if (isVowel(token[i]) && !isVowel(token[i + 1])) { r1 = i + 2; } } // Or is the null re...
javascript
function regions(token) { var r1, r2, rv, len; var i; r1 = r2 = rv = len = token.length; // R1 is the region after the first non-vowel following a vowel, for (var i = 0; i < len - 1 && r1 == len; i++) { if (isVowel(token[i]) && !isVowel(token[i + 1])) { r1 = i + 2; } } // Or is the null re...
[ "function", "regions", "(", "token", ")", "{", "var", "r1", ",", "r2", ",", "rv", ",", "len", ";", "var", "i", ";", "r1", "=", "r2", "=", "rv", "=", "len", "=", "token", ".", "length", ";", "// R1 is the region after the first non-vowel following a vowel,"...
Compute r1, r2, rv regions as required by french porter stemmer algorithm @param {String} token Word to compute regions on @return {Object} Regions r1, r2, rv as offsets from the begining of the word
[ "Compute", "r1", "r2", "rv", "regions", "as", "required", "by", "french", "porter", "stemmer", "algorithm" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_fr.js#L274-L317
train
NaturalNode/natural
lib/natural/stemmers/porter_stemmer_fr.js
endsinArr
function endsinArr(token, suffixes) { var i, longest = ''; for (i = 0; i < suffixes.length; i++) { if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length) longest = suffixes[i]; } return longest; }
javascript
function endsinArr(token, suffixes) { var i, longest = ''; for (i = 0; i < suffixes.length; i++) { if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length) longest = suffixes[i]; } return longest; }
[ "function", "endsinArr", "(", "token", ",", "suffixes", ")", "{", "var", "i", ",", "longest", "=", "''", ";", "for", "(", "i", "=", "0", ";", "i", "<", "suffixes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "endsin", "(", "token", ",",...
Return longest matching suffixes for a token or '' if no suffix match @param {String} token Word to find matching suffix @param {Array} suffixes Array of suffixes to test matching @return {String} Longest found matching suffix or ''
[ "Return", "longest", "matching", "suffixes", "for", "a", "token", "or", "if", "no", "suffix", "match" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_fr.js#L358-L366
train
NaturalNode/natural
lib/natural/phonetics/dm_soundex.js
normalizeLength
function normalizeLength(token, length) { length = length || 6; if (token.length < length) { token += (new Array(length - token.length + 1)).join('0'); } return token.slice(0, length); }
javascript
function normalizeLength(token, length) { length = length || 6; if (token.length < length) { token += (new Array(length - token.length + 1)).join('0'); } return token.slice(0, length); }
[ "function", "normalizeLength", "(", "token", ",", "length", ")", "{", "length", "=", "length", "||", "6", ";", "if", "(", "token", ".", "length", "<", "length", ")", "{", "token", "+=", "(", "new", "Array", "(", "length", "-", "token", ".", "length",...
Pad right with zeroes or cut excess symbols to fit length
[ "Pad", "right", "with", "zeroes", "or", "cut", "excess", "symbols", "to", "fit", "length" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/phonetics/dm_soundex.js#L235-L241
train
NaturalNode/natural
lib/natural/distance/levenshtein_distance.js
_getMatchStart
function _getMatchStart(distanceMatrix, matchEnd, sourceLength) { var row = sourceLength; var column = matchEnd; var tmpRow; var tmpColumn; // match will be empty string if (matchEnd === 0) { return 0; } while(row > 1 && column > 1) { tmpRow = row; tmpColumn = column; row = distanceMatrix[tmpRo...
javascript
function _getMatchStart(distanceMatrix, matchEnd, sourceLength) { var row = sourceLength; var column = matchEnd; var tmpRow; var tmpColumn; // match will be empty string if (matchEnd === 0) { return 0; } while(row > 1 && column > 1) { tmpRow = row; tmpColumn = column; row = distanceMatrix[tmpRo...
[ "function", "_getMatchStart", "(", "distanceMatrix", ",", "matchEnd", ",", "sourceLength", ")", "{", "var", "row", "=", "sourceLength", ";", "var", "column", "=", "matchEnd", ";", "var", "tmpRow", ";", "var", "tmpColumn", ";", "// match will be empty string", "i...
Walk the path back from the matchEnd to the beginning of the match. Do this by traversing the distanceMatrix as you would a linked list, following going from cell child to parent until reach row 0.
[ "Walk", "the", "path", "back", "from", "the", "matchEnd", "to", "the", "beginning", "of", "the", "match", ".", "Do", "this", "by", "traversing", "the", "distanceMatrix", "as", "you", "would", "a", "linked", "list", "following", "going", "from", "cell", "ch...
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/distance/levenshtein_distance.js#L37-L54
train
NaturalNode/natural
lib/natural/stemmers/indonesian/prefix_rules.js
runDisambiguator
function runDisambiguator(disambiguateRules, word){ var result = undefined; for(var i in disambiguateRules){ result = disambiguateRules[i](word); if(find(result)){ break; } } if(result==undefined){ this.current_word = word; this.removal = undefined; retur...
javascript
function runDisambiguator(disambiguateRules, word){ var result = undefined; for(var i in disambiguateRules){ result = disambiguateRules[i](word); if(find(result)){ break; } } if(result==undefined){ this.current_word = word; this.removal = undefined; retur...
[ "function", "runDisambiguator", "(", "disambiguateRules", ",", "word", ")", "{", "var", "result", "=", "undefined", ";", "for", "(", "var", "i", "in", "disambiguateRules", ")", "{", "result", "=", "disambiguateRules", "[", "i", "]", "(", "word", ")", ";", ...
Run the array of disambiguate rules on input word
[ "Run", "the", "array", "of", "disambiguate", "rules", "on", "input", "word" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/prefix_rules.js#L52-L69
train
NaturalNode/natural
lib/natural/stemmers/indonesian/stemmer_id.js
stemPluralWord
function stemPluralWord(plural_word){ var matches = plural_word.match(/^(.*)-(.*)$/); if(!matches){ return plural_word; } words = [matches[1], matches[2]]; //malaikat-malaikat-nya -> malaikat malaikat-nya suffix = words[1]; suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];...
javascript
function stemPluralWord(plural_word){ var matches = plural_word.match(/^(.*)-(.*)$/); if(!matches){ return plural_word; } words = [matches[1], matches[2]]; //malaikat-malaikat-nya -> malaikat malaikat-nya suffix = words[1]; suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];...
[ "function", "stemPluralWord", "(", "plural_word", ")", "{", "var", "matches", "=", "plural_word", ".", "match", "(", "/", "^(.*)-(.*)$", "/", ")", ";", "if", "(", "!", "matches", ")", "{", "return", "plural_word", ";", "}", "words", "=", "[", "matches", ...
Stem for plural word
[ "Stem", "for", "plural", "word" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L64-L94
train
NaturalNode/natural
lib/natural/stemmers/indonesian/stemmer_id.js
stemSingularWord
function stemSingularWord(word){ original_word = word; // Save the original word for reverting later current_word = word; // Step 1 if(current_word.length>3){ // Step 2-5 stemmingProcess(); } // Step 6 if(find(current_word)){ return current_word; } else{ ...
javascript
function stemSingularWord(word){ original_word = word; // Save the original word for reverting later current_word = word; // Step 1 if(current_word.length>3){ // Step 2-5 stemmingProcess(); } // Step 6 if(find(current_word)){ return current_word; } else{ ...
[ "function", "stemSingularWord", "(", "word", ")", "{", "original_word", "=", "word", ";", "// Save the original word for reverting later", "current_word", "=", "word", ";", "// Step 1", "if", "(", "current_word", ".", "length", ">", "3", ")", "{", "// Step 2-5", "...
Stem for singular word
[ "Stem", "for", "singular", "word" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L97-L114
train
NaturalNode/natural
lib/natural/stemmers/indonesian/stemmer_id.js
loopRestorePrefixes
function loopRestorePrefixes(){ restorePrefix(); var reversed_removals = removals.reverse(); var temp_current_word = current_word; for(var i in reversed_removals){ current_removal = reversed_removals[i]; if(!isSuffixRemovals(current_removal)){ continue } i...
javascript
function loopRestorePrefixes(){ restorePrefix(); var reversed_removals = removals.reverse(); var temp_current_word = current_word; for(var i in reversed_removals){ current_removal = reversed_removals[i]; if(!isSuffixRemovals(current_removal)){ continue } i...
[ "function", "loopRestorePrefixes", "(", ")", "{", "restorePrefix", "(", ")", ";", "var", "reversed_removals", "=", "removals", ".", "reverse", "(", ")", ";", "var", "temp_current_word", "=", "current_word", ";", "for", "(", "var", "i", "in", "reversed_removals...
Loop Restore Prefixes
[ "Loop", "Restore", "Prefixes" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L226-L259
train
NaturalNode/natural
lib/natural/stemmers/indonesian/stemmer_id.js
precedenceAdjustmentSpecification
function precedenceAdjustmentSpecification(word){ var regex_rules = [ /^be(.*)lah$/, /^be(.*)an$/, /^me(.*)i$/, /^di(.*)i$/, /^pe(.*)i$/, /^ter(.*)i$/, ]; for(var i in regex_rules){ if(word.match(regex_rules[i])){ return true; } ...
javascript
function precedenceAdjustmentSpecification(word){ var regex_rules = [ /^be(.*)lah$/, /^be(.*)an$/, /^me(.*)i$/, /^di(.*)i$/, /^pe(.*)i$/, /^ter(.*)i$/, ]; for(var i in regex_rules){ if(word.match(regex_rules[i])){ return true; } ...
[ "function", "precedenceAdjustmentSpecification", "(", "word", ")", "{", "var", "regex_rules", "=", "[", "/", "^be(.*)lah$", "/", ",", "/", "^be(.*)an$", "/", ",", "/", "^me(.*)i$", "/", ",", "/", "^di(.*)i$", "/", ",", "/", "^pe(.*)i$", "/", ",", "/", "^...
Check if word require precedence adjustment or not Adjustment means remove prefix then suffix instead of remove suffix then prefix
[ "Check", "if", "word", "require", "precedence", "adjustment", "or", "not", "Adjustment", "means", "remove", "prefix", "then", "suffix", "instead", "of", "remove", "suffix", "then", "prefix" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L284-L300
train
NaturalNode/natural
lib/natural/stemmers/porter_stemmer.js
attemptReplace
function attemptReplace(token, pattern, replacement, callback) { var result = null; if((typeof pattern == 'string') && token.substr(0 - pattern.length) == pattern) result = token.replace(new RegExp(pattern + '$'), replacement); else if((pattern instanceof RegExp) && token.match(pattern)) ...
javascript
function attemptReplace(token, pattern, replacement, callback) { var result = null; if((typeof pattern == 'string') && token.substr(0 - pattern.length) == pattern) result = token.replace(new RegExp(pattern + '$'), replacement); else if((pattern instanceof RegExp) && token.match(pattern)) ...
[ "function", "attemptReplace", "(", "token", ",", "pattern", ",", "replacement", ",", "callback", ")", "{", "var", "result", "=", "null", ";", "if", "(", "(", "typeof", "pattern", "==", "'string'", ")", "&&", "token", ".", "substr", "(", "0", "-", "patt...
replace a pattern in a word. if a replacement occurs an optional callback can be called to post-process the result. if no match is made NULL is returned.
[ "replace", "a", "pattern", "in", "a", "word", ".", "if", "a", "replacement", "occurs", "an", "optional", "callback", "can", "be", "called", "to", "post", "-", "process", "the", "result", ".", "if", "no", "match", "is", "made", "NULL", "is", "returned", ...
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer.js#L53-L65
train
NaturalNode/natural
lib/natural/stemmers/porter_stemmer_pt.js
function (start) { var index = start || 0, length = this.string.length, region = length; while (index < length - 1 && region === length) { if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) { region = index + 2; } index++; } return region; }
javascript
function (start) { var index = start || 0, length = this.string.length, region = length; while (index < length - 1 && region === length) { if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) { region = index + 2; } index++; } return region; }
[ "function", "(", "start", ")", "{", "var", "index", "=", "start", "||", "0", ",", "length", "=", "this", ".", "string", ".", "length", ",", "region", "=", "length", ";", "while", "(", "index", "<", "length", "-", "1", "&&", "region", "===", "length...
Marks a region after the first non-vowel following a vowel, or the null region at the end of the word if there is no such non-vowel. @param {Object} token Token to stem. @param {Number} start Start index (defaults to 0). @param {Number} Region start index.
[ "Marks", "a", "region", "after", "the", "first", "non", "-", "vowel", "following", "a", "vowel", "or", "the", "null", "region", "at", "the", "end", "of", "the", "word", "if", "there", "is", "no", "such", "non", "-", "vowel", "." ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_pt.js#L38-L51
train
NaturalNode/natural
lib/natural/stemmers/porter_stemmer_pt.js
function () { var rv = this.string.length; if (rv > 3) { if (!this.hasVowelAtIndex(1)) { rv = this.nextVowelIndex(2) + 1; } else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) { rv = this.nextConsonantIndex(2) + 1; } else { rv = 3; } } return ...
javascript
function () { var rv = this.string.length; if (rv > 3) { if (!this.hasVowelAtIndex(1)) { rv = this.nextVowelIndex(2) + 1; } else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) { rv = this.nextConsonantIndex(2) + 1; } else { rv = 3; } } return ...
[ "function", "(", ")", "{", "var", "rv", "=", "this", ".", "string", ".", "length", ";", "if", "(", "rv", ">", "3", ")", "{", "if", "(", "!", "this", ".", "hasVowelAtIndex", "(", "1", ")", ")", "{", "rv", "=", "this", ".", "nextVowelIndex", "(",...
Mark RV. @param {Object} token Token to stem. @return {Number} Region start index.
[ "Mark", "RV", "." ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_pt.js#L59-L75
train
NaturalNode/natural
lib/natural/stemmers/indonesian/removal.js
Removal
function Removal (original_word, result, removedPart, affixType) { this.original_word = original_word; this.result = result; this.removedPart = removedPart this.affixType = affixType; }
javascript
function Removal (original_word, result, removedPart, affixType) { this.original_word = original_word; this.result = result; this.removedPart = removedPart this.affixType = affixType; }
[ "function", "Removal", "(", "original_word", ",", "result", ",", "removedPart", ",", "affixType", ")", "{", "this", ".", "original_word", "=", "original_word", ";", "this", ".", "result", "=", "result", ";", "this", ".", "removedPart", "=", "removedPart", "t...
a list of commonly used words that have little meaning and can be excluded from analysis.
[ "a", "list", "of", "commonly", "used", "words", "that", "have", "little", "meaning", "and", "can", "be", "excluded", "from", "analysis", "." ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/removal.js#L26-L31
train
NaturalNode/natural
lib/natural/brill_pos_tagger/lib/Lexicon.js
Lexicon
function Lexicon(language, defaultCategory, defaultCategoryCapitalised) { switch (language) { case 'EN': this.lexicon = englishLexicon; break; case 'DU': this.lexicon = dutchLexicon; break; default: this.lexicon = dutchLexicon; break; } if (defaultCategory) { th...
javascript
function Lexicon(language, defaultCategory, defaultCategoryCapitalised) { switch (language) { case 'EN': this.lexicon = englishLexicon; break; case 'DU': this.lexicon = dutchLexicon; break; default: this.lexicon = dutchLexicon; break; } if (defaultCategory) { th...
[ "function", "Lexicon", "(", "language", ",", "defaultCategory", ",", "defaultCategoryCapitalised", ")", "{", "switch", "(", "language", ")", "{", "case", "'EN'", ":", "this", ".", "lexicon", "=", "englishLexicon", ";", "break", ";", "case", "'DU'", ":", "thi...
Constructor creates a Lexicon for language
[ "Constructor", "creates", "a", "Lexicon", "for", "language" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/brill_pos_tagger/lib/Lexicon.js#L26-L44
train
NaturalNode/natural
lib/natural/util/topological.js
function(g) { this.isDag = true; this.sorted = topoSort(uniqueVertexs(g.edges()), g.edges()); }
javascript
function(g) { this.isDag = true; this.sorted = topoSort(uniqueVertexs(g.edges()), g.edges()); }
[ "function", "(", "g", ")", "{", "this", ".", "isDag", "=", "true", ";", "this", ".", "sorted", "=", "topoSort", "(", "uniqueVertexs", "(", "g", ".", "edges", "(", ")", ")", ",", "g", ".", "edges", "(", ")", ")", ";", "}" ]
a topo sort for a digraph @param {Digraph}
[ "a", "topo", "sort", "for", "a", "digraph" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/util/topological.js#L28-L31
train
NaturalNode/natural
lib/natural/stemmers/lancaster_stemmer.js
applyRuleSection
function applyRuleSection(token, intact) { var section = token.substr( - 1); var rules = ruleTable[section]; if (rules) { for (var i = 0; i < rules.length; i++) { if ((intact || !rules[i].intact) // only apply intact rules to intact tokens && token.substr(0 - rul...
javascript
function applyRuleSection(token, intact) { var section = token.substr( - 1); var rules = ruleTable[section]; if (rules) { for (var i = 0; i < rules.length; i++) { if ((intact || !rules[i].intact) // only apply intact rules to intact tokens && token.substr(0 - rul...
[ "function", "applyRuleSection", "(", "token", ",", "intact", ")", "{", "var", "section", "=", "token", ".", "substr", "(", "-", "1", ")", ";", "var", "rules", "=", "ruleTable", "[", "section", "]", ";", "if", "(", "rules", ")", "{", "for", "(", "va...
take a token, look up the applicatble rule section and attempt some stemming!
[ "take", "a", "token", "look", "up", "the", "applicatble", "rule", "section", "and", "attempt", "some", "stemming!" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/lancaster_stemmer.js#L34-L68
train
NaturalNode/natural
lib/natural/classifiers/maxent/POS/POS_Element.js
currentWord
function currentWord(x) { if ((x.b.data.wordWindow["0"] === token) && (x.a === tag)) { return 1; } return 0; }
javascript
function currentWord(x) { if ((x.b.data.wordWindow["0"] === token) && (x.a === tag)) { return 1; } return 0; }
[ "function", "currentWord", "(", "x", ")", "{", "if", "(", "(", "x", ".", "b", ".", "data", ".", "wordWindow", "[", "\"0\"", "]", "===", "token", ")", "&&", "(", "x", ".", "a", "===", "tag", ")", ")", "{", "return", "1", ";", "}", "return", "0...
Feature for the current word
[ "Feature", "for", "the", "current", "word" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/classifiers/maxent/POS/POS_Element.js#L37-L43
train
NaturalNode/natural
lib/natural/ngrams/ngrams.js
countNgrams
function countNgrams(ngram) { nrOfNgrams++; var key = arrayToKey(ngram); if (!frequencies[key]) { frequencies[key] = 0; } frequencies[key]++; }
javascript
function countNgrams(ngram) { nrOfNgrams++; var key = arrayToKey(ngram); if (!frequencies[key]) { frequencies[key] = 0; } frequencies[key]++; }
[ "function", "countNgrams", "(", "ngram", ")", "{", "nrOfNgrams", "++", ";", "var", "key", "=", "arrayToKey", "(", "ngram", ")", ";", "if", "(", "!", "frequencies", "[", "key", "]", ")", "{", "frequencies", "[", "key", "]", "=", "0", ";", "}", "freq...
Updates the statistics for the new ngram
[ "Updates", "the", "statistics", "for", "the", "new", "ngram" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/ngrams/ngrams.js#L62-L69
train
NaturalNode/natural
lib/natural/ngrams/ngrams.js
function(sequence, n, startSymbol, endSymbol, stats) { var result = []; frequencies = {}; nrOfNgrams = 0; if (!_(sequence).isArray()) { sequence = tokenizer.tokenize(sequence); } var count = _.max([0, sequence.length - n + 1]); // Check for left padding if(typeof start...
javascript
function(sequence, n, startSymbol, endSymbol, stats) { var result = []; frequencies = {}; nrOfNgrams = 0; if (!_(sequence).isArray()) { sequence = tokenizer.tokenize(sequence); } var count = _.max([0, sequence.length - n + 1]); // Check for left padding if(typeof start...
[ "function", "(", "sequence", ",", "n", ",", "startSymbol", ",", "endSymbol", ",", "stats", ")", "{", "var", "result", "=", "[", "]", ";", "frequencies", "=", "{", "}", ";", "nrOfNgrams", "=", "0", ";", "if", "(", "!", "_", "(", "sequence", ")", "...
If stats is true, statistics will be returned
[ "If", "stats", "is", "true", "statistics", "will", "be", "returned" ]
01078b695fda3df41de26a7ac589a6478d802f1f
https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/ngrams/ngrams.js#L72-L153
train