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
overtrue/share.js
src/js/social-share.js
mixin
function mixin() { var args = arguments; if (Object$assign) { return Object$assign.apply(null, args); } var target = {}; each(args, function (it) { each(it, function (v, k) { target[k] = v; }); }); return arg...
javascript
function mixin() { var args = arguments; if (Object$assign) { return Object$assign.apply(null, args); } var target = {}; each(args, function (it) { each(it, function (v, k) { target[k] = v; }); }); return arg...
[ "function", "mixin", "(", ")", "{", "var", "args", "=", "arguments", ";", "if", "(", "Object$assign", ")", "{", "return", "Object$assign", ".", "apply", "(", "null", ",", "args", ")", ";", "}", "var", "target", "=", "{", "}", ";", "each", "(", "arg...
Merge objects. @returns {Object}
[ "Merge", "objects", "." ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L355-L371
train
overtrue/share.js
src/js/social-share.js
dataset
function dataset(elem) { if (elem.dataset) { return JSON.parse(JSON.stringify(elem.dataset)); } var target = {}; if (elem.hasAttributes()) { each(elem.attributes, function (attr) { var name = attr.name; if (name.indexOf('data-') !...
javascript
function dataset(elem) { if (elem.dataset) { return JSON.parse(JSON.stringify(elem.dataset)); } var target = {}; if (elem.hasAttributes()) { each(elem.attributes, function (attr) { var name = attr.name; if (name.indexOf('data-') !...
[ "function", "dataset", "(", "elem", ")", "{", "if", "(", "elem", ".", "dataset", ")", "{", "return", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "elem", ".", "dataset", ")", ")", ";", "}", "var", "target", "=", "{", "}", ";", "if", ...
Get dataset object. @param {Element} elem @returns {Object}
[ "Get", "dataset", "object", "." ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L381-L407
train
overtrue/share.js
src/js/social-share.js
inArray
function inArray(elem, arr, i) { var len; if (arr) { if (Array$indexOf) { return Array$indexOf.call(arr, elem, i); } len = arr.length; i = i ? i < 0 ? Math.max(0, len + i) : i : 0; for (; i < len; i++) { // Sk...
javascript
function inArray(elem, arr, i) { var len; if (arr) { if (Array$indexOf) { return Array$indexOf.call(arr, elem, i); } len = arr.length; i = i ? i < 0 ? Math.max(0, len + i) : i : 0; for (; i < len; i++) { // Sk...
[ "function", "inArray", "(", "elem", ",", "arr", ",", "i", ")", "{", "var", "len", ";", "if", "(", "arr", ")", "{", "if", "(", "Array$indexOf", ")", "{", "return", "Array$indexOf", ".", "call", "(", "arr", ",", "elem", ",", "i", ")", ";", "}", "...
found element in the array. @param {Array|Object} elem @param {Array} arr @param {Number} i @returns {Number}
[ "found", "element", "in", "the", "array", "." ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L419-L439
train
overtrue/share.js
src/js/social-share.js
each
function each(obj, callback) { var length = obj.length; if (length === undefined) { for (var name in obj) { if (obj.hasOwnProperty(name)) { if (callback.call(obj[name], obj[name], name) === false) { break; } ...
javascript
function each(obj, callback) { var length = obj.length; if (length === undefined) { for (var name in obj) { if (obj.hasOwnProperty(name)) { if (callback.call(obj[name], obj[name], name) === false) { break; } ...
[ "function", "each", "(", "obj", ",", "callback", ")", "{", "var", "length", "=", "obj", ".", "length", ";", "if", "(", "length", "===", "undefined", ")", "{", "for", "(", "var", "name", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty"...
Simple each. @param {Array|Object} obj @param {Function} callback @returns {*}
[ "Simple", "each", "." ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L450-L468
train
overtrue/share.js
src/js/social-share.js
alReady
function alReady ( fn ) { var add = 'addEventListener'; var pre = document[ add ] ? '' : 'on'; ~document.readyState.indexOf( 'm' ) ? fn() : 'load DOMContentLoaded readystatechange'.replace( /\w+/g, function( type, i ) { ( i ? document : window ) [...
javascript
function alReady ( fn ) { var add = 'addEventListener'; var pre = document[ add ] ? '' : 'on'; ~document.readyState.indexOf( 'm' ) ? fn() : 'load DOMContentLoaded readystatechange'.replace( /\w+/g, function( type, i ) { ( i ? document : window ) [...
[ "function", "alReady", "(", "fn", ")", "{", "var", "add", "=", "'addEventListener'", ";", "var", "pre", "=", "document", "[", "add", "]", "?", "''", ":", "'on'", ";", "~", "document", ".", "readyState", ".", "indexOf", "(", "'m'", ")", "?", "fn", "...
Dom ready. @param {Function} fn @link https://github.com/jed/alReady.js
[ "Dom", "ready", "." ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/social-share.js#L478-L492
train
overtrue/share.js
src/js/qrcode.js
_getAndroid
function _getAndroid() { var android = false; var sAgent = navigator.userAgent; if (/android/i.test(sAgent)) { // android android = true; var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i); if (aMat && aMat[1]) { android = parseFloat(aMat[1]); } } return android; }
javascript
function _getAndroid() { var android = false; var sAgent = navigator.userAgent; if (/android/i.test(sAgent)) { // android android = true; var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i); if (aMat && aMat[1]) { android = parseFloat(aMat[1]); } } return android; }
[ "function", "_getAndroid", "(", ")", "{", "var", "android", "=", "false", ";", "var", "sAgent", "=", "navigator", ".", "userAgent", ";", "if", "(", "/", "android", "/", "i", ".", "test", "(", "sAgent", ")", ")", "{", "// android", "android", "=", "tr...
android 2.x doesn't support Data-URI spec
[ "android", "2", ".", "x", "doesn", "t", "support", "Data", "-", "URI", "spec" ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/qrcode.js#L159-L173
train
overtrue/share.js
src/js/qrcode.js
_safeSetDataURI
function _safeSetDataURI(fSuccess, fFail) { var self = this; self._fFail = fFail; self._fSuccess = fSuccess; // Check it just once if (self._bSupportDataURI === null) { var el = document.createElement("img"); var fOnError = fun...
javascript
function _safeSetDataURI(fSuccess, fFail) { var self = this; self._fFail = fFail; self._fSuccess = fSuccess; // Check it just once if (self._bSupportDataURI === null) { var el = document.createElement("img"); var fOnError = fun...
[ "function", "_safeSetDataURI", "(", "fSuccess", ",", "fFail", ")", "{", "var", "self", "=", "this", ";", "self", ".", "_fFail", "=", "fFail", ";", "self", ".", "_fSuccess", "=", "fSuccess", ";", "// Check it just once", "if", "(", "self", ".", "_bSupportDa...
Check whether the user's browser supports Data URI or not @private @param {Function} fSuccess Occurs if it supports Data URI @param {Function} fFail Occurs if it doesn't support Data URI
[ "Check", "whether", "the", "user", "s", "browser", "supports", "Data", "URI", "or", "not" ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/qrcode.js#L310-L343
train
overtrue/share.js
src/js/qrcode.js
function (el, htOption) { this._bIsPainted = false; this._android = _getAndroid(); this._htOption = htOption; this._elCanvas = document.createElement("canvas"); this._elCanvas.width = htOption.width; this._elCanvas.height = htOption.height; el.appendChild(this._elCanvas); this._el = el;...
javascript
function (el, htOption) { this._bIsPainted = false; this._android = _getAndroid(); this._htOption = htOption; this._elCanvas = document.createElement("canvas"); this._elCanvas.width = htOption.width; this._elCanvas.height = htOption.height; el.appendChild(this._elCanvas); this._el = el;...
[ "function", "(", "el", ",", "htOption", ")", "{", "this", ".", "_bIsPainted", "=", "false", ";", "this", ".", "_android", "=", "_getAndroid", "(", ")", ";", "this", ".", "_htOption", "=", "htOption", ";", "this", ".", "_elCanvas", "=", "document", ".",...
Drawing QRCode by using canvas @constructor @param {HTMLElement} el @param {Object} htOption QRCode Options
[ "Drawing", "QRCode", "by", "using", "canvas" ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/qrcode.js#L352-L369
train
overtrue/share.js
src/js/qrcode.js
_getTypeNumber
function _getTypeNumber(sText, nCorrectLevel) { var nType = 1; var length = _getUTF8Length(sText); for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) { var nLimit = 0; switch (nCorrectLevel) { case QRErrorCorrectLevel.L : nLimit = QRCodeLimitLength[i][0]; break; case ...
javascript
function _getTypeNumber(sText, nCorrectLevel) { var nType = 1; var length = _getUTF8Length(sText); for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) { var nLimit = 0; switch (nCorrectLevel) { case QRErrorCorrectLevel.L : nLimit = QRCodeLimitLength[i][0]; break; case ...
[ "function", "_getTypeNumber", "(", "sText", ",", "nCorrectLevel", ")", "{", "var", "nType", "=", "1", ";", "var", "length", "=", "_getUTF8Length", "(", "sText", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "QRCodeLimitLength", ".", "len...
Get the type by string length @private @param {String} sText @param {Number} nCorrectLevel @return {Number} type
[ "Get", "the", "type", "by", "string", "length" ]
ddc699dfabf56b41f11865b6195dda05614f1e2a
https://github.com/overtrue/share.js/blob/ddc699dfabf56b41f11865b6195dda05614f1e2a/src/js/qrcode.js#L469-L503
train
conventional-changelog/standard-version
lib/lifecycles/bump.js
getCurrentActiveType
function getCurrentActiveType (version) { let typelist = TypeList for (let i = 0; i < typelist.length; i++) { if (semver[typelist[i]](version)) { return typelist[i] } } }
javascript
function getCurrentActiveType (version) { let typelist = TypeList for (let i = 0; i < typelist.length; i++) { if (semver[typelist[i]](version)) { return typelist[i] } } }
[ "function", "getCurrentActiveType", "(", "version", ")", "{", "let", "typelist", "=", "TypeList", "for", "(", "let", "i", "=", "0", ";", "i", "<", "typelist", ".", "length", ";", "i", "++", ")", "{", "if", "(", "semver", "[", "typelist", "[", "i", ...
extract the in-pre-release type in target version @param version @return {string}
[ "extract", "the", "in", "-", "pre", "-", "release", "type", "in", "target", "version" ]
a5ac84545a51ce8eb5ea2db0cf06fb8b39188e82
https://github.com/conventional-changelog/standard-version/blob/a5ac84545a51ce8eb5ea2db0cf06fb8b39188e82/lib/lifecycles/bump.js#L112-L119
train
bitinn/node-fetch
src/body.js
consumeBody
function consumeBody() { if (this[INTERNALS].disturbed) { return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); } this[INTERNALS].disturbed = true; if (this[INTERNALS].error) { return Body.Promise.reject(this[INTERNALS].error); } let body = this.body; // body is null if (body ...
javascript
function consumeBody() { if (this[INTERNALS].disturbed) { return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); } this[INTERNALS].disturbed = true; if (this[INTERNALS].error) { return Body.Promise.reject(this[INTERNALS].error); } let body = this.body; // body is null if (body ...
[ "function", "consumeBody", "(", ")", "{", "if", "(", "this", "[", "INTERNALS", "]", ".", "disturbed", ")", "{", "return", "Body", ".", "Promise", ".", "reject", "(", "new", "TypeError", "(", "`", "${", "this", ".", "url", "}", "`", ")", ")", ";", ...
Consume and convert an entire Body to a Buffer. Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body @return Promise
[ "Consume", "and", "convert", "an", "entire", "Body", "to", "a", "Buffer", "." ]
bf8b4e8db350ec76dbb9236620f774fcc21b8c12
https://github.com/bitinn/node-fetch/blob/bf8b4e8db350ec76dbb9236620f774fcc21b8c12/src/body.js#L182-L274
train
bitinn/node-fetch
src/headers.js
find
function find(map, name) { name = name.toLowerCase(); for (const key in map) { if (key.toLowerCase() === name) { return key; } } return undefined; }
javascript
function find(map, name) { name = name.toLowerCase(); for (const key in map) { if (key.toLowerCase() === name) { return key; } } return undefined; }
[ "function", "find", "(", "map", ",", "name", ")", "{", "name", "=", "name", ".", "toLowerCase", "(", ")", ";", "for", "(", "const", "key", "in", "map", ")", "{", "if", "(", "key", ".", "toLowerCase", "(", ")", "===", "name", ")", "{", "return", ...
Find the key in the map object given a header name. Returns undefined if not found. @param String name Header name @return String|Undefined
[ "Find", "the", "key", "in", "the", "map", "object", "given", "a", "header", "name", "." ]
bf8b4e8db350ec76dbb9236620f774fcc21b8c12
https://github.com/bitinn/node-fetch/blob/bf8b4e8db350ec76dbb9236620f774fcc21b8c12/src/headers.js#L33-L41
train
isaachinman/next-i18next
src/utils/console-message.js
logMessage
function logMessage(messageType, message) { if (Object.values(messageTypes).includes(messageType)) { console[messageType](message) } else { console.info(message) } }
javascript
function logMessage(messageType, message) { if (Object.values(messageTypes).includes(messageType)) { console[messageType](message) } else { console.info(message) } }
[ "function", "logMessage", "(", "messageType", ",", "message", ")", "{", "if", "(", "Object", ".", "values", "(", "messageTypes", ")", ".", "includes", "(", "messageType", ")", ")", "{", "console", "[", "messageType", "]", "(", "message", ")", "}", "else"...
Logs a custom message to console @param {messageTypes} messageType One of: error, warn or info @param {String} message
[ "Logs", "a", "custom", "message", "to", "console" ]
a78dcc52fd3312e1ddd8c3ba62110918ce81b5b5
https://github.com/isaachinman/next-i18next/blob/a78dcc52fd3312e1ddd8c3ba62110918ce81b5b5/src/utils/console-message.js#L20-L26
train
MetaMask/web3-provider-engine
util/async.js
function(fns, done) { done = done || function() {}; this.map(fns, function(fn, callback) { fn(callback); }, done); }
javascript
function(fns, done) { done = done || function() {}; this.map(fns, function(fn, callback) { fn(callback); }, done); }
[ "function", "(", "fns", ",", "done", ")", "{", "done", "=", "done", "||", "function", "(", ")", "{", "}", ";", "this", ".", "map", "(", "fns", ",", "function", "(", "fn", ",", "callback", ")", "{", "fn", "(", "callback", ")", ";", "}", ",", "...
Works the same as async.parallel
[ "Works", "the", "same", "as", "async", ".", "parallel" ]
5f7acf6c96028f151b5d3ad2a99cb935056f2b71
https://github.com/MetaMask/web3-provider-engine/blob/5f7acf6c96028f151b5d3ad2a99cb935056f2b71/util/async.js#L3-L8
train
MetaMask/web3-provider-engine
util/async.js
function(items, iterator, done) { done = done || function() {}; var results = []; var failure = false; var expected = items.length; var actual = 0; var createIntermediary = function(index) { return function(err, result) { // Return if we found a failure anywhere. // We can'...
javascript
function(items, iterator, done) { done = done || function() {}; var results = []; var failure = false; var expected = items.length; var actual = 0; var createIntermediary = function(index) { return function(err, result) { // Return if we found a failure anywhere. // We can'...
[ "function", "(", "items", ",", "iterator", ",", "done", ")", "{", "done", "=", "done", "||", "function", "(", ")", "{", "}", ";", "var", "results", "=", "[", "]", ";", "var", "failure", "=", "false", ";", "var", "expected", "=", "items", ".", "le...
Works the same as async.map
[ "Works", "the", "same", "as", "async", ".", "map" ]
5f7acf6c96028f151b5d3ad2a99cb935056f2b71
https://github.com/MetaMask/web3-provider-engine/blob/5f7acf6c96028f151b5d3ad2a99cb935056f2b71/util/async.js#L11-L48
train
MetaMask/web3-provider-engine
util/async.js
function(items, iterator, done) { done = done || function() {}; var results = []; var failure = false; var expected = items.length; var current = -1; function callback(err, result) { if (err) return done(err); results.push(result); if (current == expected) { return d...
javascript
function(items, iterator, done) { done = done || function() {}; var results = []; var failure = false; var expected = items.length; var current = -1; function callback(err, result) { if (err) return done(err); results.push(result); if (current == expected) { return d...
[ "function", "(", "items", ",", "iterator", ",", "done", ")", "{", "done", "=", "done", "||", "function", "(", ")", "{", "}", ";", "var", "results", "=", "[", "]", ";", "var", "failure", "=", "false", ";", "var", "expected", "=", "items", ".", "le...
Works like async.eachSeries
[ "Works", "like", "async", ".", "eachSeries" ]
5f7acf6c96028f151b5d3ad2a99cb935056f2b71
https://github.com/MetaMask/web3-provider-engine/blob/5f7acf6c96028f151b5d3ad2a99cb935056f2b71/util/async.js#L51-L78
train
MetaMask/web3-provider-engine
subproviders/hooked-wallet.js
cloneTxParams
function cloneTxParams(txParams){ return { from: txParams.from, to: txParams.to, value: txParams.value, data: txParams.data, gas: txParams.gas, gasPrice: txParams.gasPrice, nonce: txParams.nonce, } }
javascript
function cloneTxParams(txParams){ return { from: txParams.from, to: txParams.to, value: txParams.value, data: txParams.data, gas: txParams.gas, gasPrice: txParams.gasPrice, nonce: txParams.nonce, } }
[ "function", "cloneTxParams", "(", "txParams", ")", "{", "return", "{", "from", ":", "txParams", ".", "from", ",", "to", ":", "txParams", ".", "to", ",", "value", ":", "txParams", ".", "value", ",", "data", ":", "txParams", ".", "data", ",", "gas", ":...
util we use this to clean any custom params from the txParams
[ "util", "we", "use", "this", "to", "clean", "any", "custom", "params", "from", "the", "txParams" ]
5f7acf6c96028f151b5d3ad2a99cb935056f2b71
https://github.com/MetaMask/web3-provider-engine/blob/5f7acf6c96028f151b5d3ad2a99cb935056f2b71/subproviders/hooked-wallet.js#L549-L559
train
MetaMask/web3-provider-engine
subproviders/hooked-wallet.js
resemblesData
function resemblesData (string) { const fixed = ethUtil.addHexPrefix(string) const isValidAddress = ethUtil.isValidAddress(fixed) return !isValidAddress && isValidHex(string) }
javascript
function resemblesData (string) { const fixed = ethUtil.addHexPrefix(string) const isValidAddress = ethUtil.isValidAddress(fixed) return !isValidAddress && isValidHex(string) }
[ "function", "resemblesData", "(", "string", ")", "{", "const", "fixed", "=", "ethUtil", ".", "addHexPrefix", "(", "string", ")", "const", "isValidAddress", "=", "ethUtil", ".", "isValidAddress", "(", "fixed", ")", "return", "!", "isValidAddress", "&&", "isVali...
Returns true if resembles hex data but definitely not a valid address.
[ "Returns", "true", "if", "resembles", "hex", "data", "but", "definitely", "not", "a", "valid", "address", "." ]
5f7acf6c96028f151b5d3ad2a99cb935056f2b71
https://github.com/MetaMask/web3-provider-engine/blob/5f7acf6c96028f151b5d3ad2a99cb935056f2b71/subproviders/hooked-wallet.js#L573-L577
train
simonbengtsson/jsPDF-AutoTable
examples/examples.js
function(data) { if (data.row.index === 5) { data.cell.styles.fillColor = [40, 170, 100]; } if ((data.row.section === 'head' || data.row.section === 'foot') && data.column.dataKey === "expenses") { data.cell.text = '' // Use an icon in didDrawCell ins...
javascript
function(data) { if (data.row.index === 5) { data.cell.styles.fillColor = [40, 170, 100]; } if ((data.row.section === 'head' || data.row.section === 'foot') && data.column.dataKey === "expenses") { data.cell.text = '' // Use an icon in didDrawCell ins...
[ "function", "(", "data", ")", "{", "if", "(", "data", ".", "row", ".", "index", "===", "5", ")", "{", "data", ".", "cell", ".", "styles", ".", "fillColor", "=", "[", "40", ",", "170", ",", "100", "]", ";", "}", "if", "(", "(", "data", ".", ...
Use for customizing texts or styles of specific cells after they have been formatted by this plugin. This hook is called just before the column width and other features are computed.
[ "Use", "for", "customizing", "texts", "or", "styles", "of", "specific", "cells", "after", "they", "have", "been", "formatted", "by", "this", "plugin", ".", "This", "hook", "is", "called", "just", "before", "the", "column", "width", "and", "other", "features"...
3a2f64f113bafec212e5680aba22f548168b670c
https://github.com/simonbengtsson/jsPDF-AutoTable/blob/3a2f64f113bafec212e5680aba22f548168b670c/examples/examples.js#L359-L371
train
simonbengtsson/jsPDF-AutoTable
examples/examples.js
function(data) { if (data.row.section === 'body' && data.column.dataKey === "expenses") { if (data.cell.raw > 750) { doc.setTextColor(231, 76, 60); // Red doc.setFontStyle('bold'); } } }
javascript
function(data) { if (data.row.section === 'body' && data.column.dataKey === "expenses") { if (data.cell.raw > 750) { doc.setTextColor(231, 76, 60); // Red doc.setFontStyle('bold'); } } }
[ "function", "(", "data", ")", "{", "if", "(", "data", ".", "row", ".", "section", "===", "'body'", "&&", "data", ".", "column", ".", "dataKey", "===", "\"expenses\"", ")", "{", "if", "(", "data", ".", "cell", ".", "raw", ">", "750", ")", "{", "do...
Use for changing styles with jspdf functions or customize the positioning of cells or cell text just before they are drawn to the page.
[ "Use", "for", "changing", "styles", "with", "jspdf", "functions", "or", "customize", "the", "positioning", "of", "cells", "or", "cell", "text", "just", "before", "they", "are", "drawn", "to", "the", "page", "." ]
3a2f64f113bafec212e5680aba22f548168b670c
https://github.com/simonbengtsson/jsPDF-AutoTable/blob/3a2f64f113bafec212e5680aba22f548168b670c/examples/examples.js#L374-L381
train
simonbengtsson/jsPDF-AutoTable
examples/examples.js
function(data) { if ((data.row.section === 'head' || data.row.section === 'foot') && data.column.dataKey === "expenses" && coinBase64Img) { doc.addImage(coinBase64Img, 'PNG', data.cell.x + 5, data.cell.y + 2, 5, 5); } }
javascript
function(data) { if ((data.row.section === 'head' || data.row.section === 'foot') && data.column.dataKey === "expenses" && coinBase64Img) { doc.addImage(coinBase64Img, 'PNG', data.cell.x + 5, data.cell.y + 2, 5, 5); } }
[ "function", "(", "data", ")", "{", "if", "(", "(", "data", ".", "row", ".", "section", "===", "'head'", "||", "data", ".", "row", ".", "section", "===", "'foot'", ")", "&&", "data", ".", "column", ".", "dataKey", "===", "\"expenses\"", "&&", "coinBas...
Use for adding content to the cells after they are drawn. This could be images or links. You can also use this to draw other custom jspdf content to cells with doc.text or doc.rect for example.
[ "Use", "for", "adding", "content", "to", "the", "cells", "after", "they", "are", "drawn", ".", "This", "could", "be", "images", "or", "links", ".", "You", "can", "also", "use", "this", "to", "draw", "other", "custom", "jspdf", "content", "to", "cells", ...
3a2f64f113bafec212e5680aba22f548168b670c
https://github.com/simonbengtsson/jsPDF-AutoTable/blob/3a2f64f113bafec212e5680aba22f548168b670c/examples/examples.js#L385-L389
train
simonbengtsson/jsPDF-AutoTable
examples/examples.js
function(data) { doc.setFontSize(18); doc.text("Custom styling with hooks", data.settings.margin.left, 22); doc.setFontSize(12); doc.text("Conditional styling of cells, rows and columns, cell and table borders, custom font, image in cell", data.settings.margin.left, 30) ...
javascript
function(data) { doc.setFontSize(18); doc.text("Custom styling with hooks", data.settings.margin.left, 22); doc.setFontSize(12); doc.text("Conditional styling of cells, rows and columns, cell and table borders, custom font, image in cell", data.settings.margin.left, 30) ...
[ "function", "(", "data", ")", "{", "doc", ".", "setFontSize", "(", "18", ")", ";", "doc", ".", "text", "(", "\"Custom styling with hooks\"", ",", "data", ".", "settings", ".", "margin", ".", "left", ",", "22", ")", ";", "doc", ".", "setFontSize", "(", ...
Use this to add content to each page that has the autoTable on it. This can be page headers, page footers and page numbers for example.
[ "Use", "this", "to", "add", "content", "to", "each", "page", "that", "has", "the", "autoTable", "on", "it", ".", "This", "can", "be", "page", "headers", "page", "footers", "and", "page", "numbers", "for", "example", "." ]
3a2f64f113bafec212e5680aba22f548168b670c
https://github.com/simonbengtsson/jsPDF-AutoTable/blob/3a2f64f113bafec212e5680aba22f548168b670c/examples/examples.js#L392-L397
train
needim/noty
docs/_assets/docsify.js
findAll
function findAll (el, node) { return [].slice.call(node ? el.querySelectorAll(node) : $.querySelectorAll(el)) }
javascript
function findAll (el, node) { return [].slice.call(node ? el.querySelectorAll(node) : $.querySelectorAll(el)) }
[ "function", "findAll", "(", "el", ",", "node", ")", "{", "return", "[", "]", ".", "slice", ".", "call", "(", "node", "?", "el", ".", "querySelectorAll", "(", "node", ")", ":", "$", ".", "querySelectorAll", "(", "el", ")", ")", "}" ]
Find all elements @example findAll('a') => [].slice.call(document.querySelectorAll('a')) findAll(nav, 'a') => [].slice.call(nav.querySelectorAll('a'))
[ "Find", "all", "elements" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L200-L202
train
needim/noty
docs/_assets/docsify.js
corner
function corner (data) { if (!data) { return '' } if (!/\/\//.test(data)) { data = 'https://github.com/' + data; } data = data.replace(/^git\+/, ''); return ( "<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" + '<svg viewBox="0 0 250 250" aria-hidden="true">' + ...
javascript
function corner (data) { if (!data) { return '' } if (!/\/\//.test(data)) { data = 'https://github.com/' + data; } data = data.replace(/^git\+/, ''); return ( "<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" + '<svg viewBox="0 0 250 250" aria-hidden="true">' + ...
[ "function", "corner", "(", "data", ")", "{", "if", "(", "!", "data", ")", "{", "return", "''", "}", "if", "(", "!", "/", "\\/\\/", "/", ".", "test", "(", "data", ")", ")", "{", "data", "=", "'https://github.com/'", "+", "data", ";", "}", "data", ...
Render github corner @param {Object} data @return {String}
[ "Render", "github", "corner" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L278-L291
train
needim/noty
docs/_assets/docsify.js
main
function main (config) { var aside = ( '<button class="sidebar-toggle">' + '<div class="sidebar-toggle-button">' + '<span></span><span></span><span></span>' + '</div>' + '</button>' + '<aside class="sidebar">' + (config.name ? ("<h1><a class=\"app-name-link\" data-nosearc...
javascript
function main (config) { var aside = ( '<button class="sidebar-toggle">' + '<div class="sidebar-toggle-button">' + '<span></span><span></span><span></span>' + '</div>' + '</button>' + '<aside class="sidebar">' + (config.name ? ("<h1><a class=\"app-name-link\" data-nosearc...
[ "function", "main", "(", "config", ")", "{", "var", "aside", "=", "(", "'<button class=\"sidebar-toggle\">'", "+", "'<div class=\"sidebar-toggle-button\">'", "+", "'<span></span><span></span><span></span>'", "+", "'</div>'", "+", "'</button>'", "+", "'<aside class=\"sidebar\"...
Render main content
[ "Render", "main", "content" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L296-L315
train
needim/noty
docs/_assets/docsify.js
init
function init () { var div = create('div'); div.classList.add('progress'); appendTo(body, div); barEl = div; }
javascript
function init () { var div = create('div'); div.classList.add('progress'); appendTo(body, div); barEl = div; }
[ "function", "init", "(", ")", "{", "var", "div", "=", "create", "(", "'div'", ")", ";", "div", ".", "classList", ".", "add", "(", "'progress'", ")", ";", "appendTo", "(", "body", ",", "div", ")", ";", "barEl", "=", "div", ";", "}" ]
Init progress component
[ "Init", "progress", "component" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L367-L373
train
needim/noty
docs/_assets/docsify.js
function (ref) { var loaded = ref.loaded; var total = ref.total; var step = ref.step; var num; !barEl && init(); if (step) { num = parseInt(barEl.style.width || 0, 10) + step; num = num > 80 ? 80 : num; } else { num = Math.floor(loaded / total * 100); } barEl.style.opacity = 1; barEl...
javascript
function (ref) { var loaded = ref.loaded; var total = ref.total; var step = ref.step; var num; !barEl && init(); if (step) { num = parseInt(barEl.style.width || 0, 10) + step; num = num > 80 ? 80 : num; } else { num = Math.floor(loaded / total * 100); } barEl.style.opacity = 1; barEl...
[ "function", "(", "ref", ")", "{", "var", "loaded", "=", "ref", ".", "loaded", ";", "var", "total", "=", "ref", ".", "total", ";", "var", "step", "=", "ref", ".", "step", ";", "var", "num", ";", "!", "barEl", "&&", "init", "(", ")", ";", "if", ...
Render progress bar
[ "Render", "progress", "bar" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L377-L403
train
needim/noty
docs/_assets/docsify.js
genTree
function genTree (toc, maxLevel) { var headlines = []; var last = {}; toc.forEach(function (headline) { var level = headline.level || 1; var len = level - 1; if (level > maxLevel) { return } if (last[len]) { last[len].children = (last[len].children || []).concat(headline); } else { ...
javascript
function genTree (toc, maxLevel) { var headlines = []; var last = {}; toc.forEach(function (headline) { var level = headline.level || 1; var len = level - 1; if (level > maxLevel) { return } if (last[len]) { last[len].children = (last[len].children || []).concat(headline); } else { ...
[ "function", "genTree", "(", "toc", ",", "maxLevel", ")", "{", "var", "headlines", "=", "[", "]", ";", "var", "last", "=", "{", "}", ";", "toc", ".", "forEach", "(", "function", "(", "headline", ")", "{", "var", "level", "=", "headline", ".", "level...
gen toc tree @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81 @param {Array} toc @param {Number} maxLevel @return {Array}
[ "gen", "toc", "tree" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L2646-L2664
train
needim/noty
docs/_assets/docsify.js
getAndActive
function getAndActive (router, el, isParent, autoTitle) { el = getNode(el); var links = findAll(el, 'a'); var hash = router.toURL(router.getCurrentPath()); var target; links .sort(function (a, b) { return b.href.length - a.href.length; }) .forEach(function (a) { var href = a.getAttribute('href...
javascript
function getAndActive (router, el, isParent, autoTitle) { el = getNode(el); var links = findAll(el, 'a'); var hash = router.toURL(router.getCurrentPath()); var target; links .sort(function (a, b) { return b.href.length - a.href.length; }) .forEach(function (a) { var href = a.getAttribute('href...
[ "function", "getAndActive", "(", "router", ",", "el", ",", "isParent", ",", "autoTitle", ")", "{", "el", "=", "getNode", "(", "el", ")", ";", "var", "links", "=", "findAll", "(", "el", ",", "'a'", ")", ";", "var", "hash", "=", "router", ".", "toURL...
Get and active link @param {object} router @param {string|element} el @param {Boolean} isParent acitve parent @param {Boolean} autoTitle auto set title @return {element}
[ "Get", "and", "active", "link" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/_assets/docsify.js#L2995-L3021
train
needim/noty
docs/v2/vendor/noty-2.4.1/js/noty/jquery.noty.js
function () { var self = this; delete $.noty.store[self.options.id]; // deleting noty from store if (self.options.theme.callback && self.options.theme.callback.onClose) { self.options.theme.callback.onClose.apply(self); } if (!self.options.dismissQueue) { // Queue render $.noty....
javascript
function () { var self = this; delete $.noty.store[self.options.id]; // deleting noty from store if (self.options.theme.callback && self.options.theme.callback.onClose) { self.options.theme.callback.onClose.apply(self); } if (!self.options.dismissQueue) { // Queue render $.noty....
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "delete", "$", ".", "noty", ".", "store", "[", "self", ".", "options", ".", "id", "]", ";", "// deleting noty from store", "if", "(", "self", ".", "options", ".", "theme", ".", "callback", "...
end close clean up
[ "end", "close", "clean", "up" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/v2/vendor/noty-2.4.1/js/noty/jquery.noty.js#L387-L406
train
needim/noty
docs/v2/vendor/showdown/showdown.js
listen
function listen(name, callback) { if (!showdown.helper.isString(name)) { throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given'); } if (typeof callback !== 'function') { throw Error('Invalid argument in converter.listen() method: callba...
javascript
function listen(name, callback) { if (!showdown.helper.isString(name)) { throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given'); } if (typeof callback !== 'function') { throw Error('Invalid argument in converter.listen() method: callba...
[ "function", "listen", "(", "name", ",", "callback", ")", "{", "if", "(", "!", "showdown", ".", "helper", ".", "isString", "(", "name", ")", ")", "{", "throw", "Error", "(", "'Invalid argument in converter.listen() method: name must be a string, but '", "+", "typeo...
Listen to an event @param {string} name @param {function} callback
[ "Listen", "to", "an", "event" ]
ec741ca366b180292ca81d9412936006ae50e16e
https://github.com/needim/noty/blob/ec741ca366b180292ca81d9412936006ae50e16e/docs/v2/vendor/showdown/showdown.js#L893-L906
train
BrowserSync/browser-sync
examples/middleware.css.injection.js
function(req, res, next) { var parsed = require("url").parse(req.url); if (parsed.pathname.match(/\.less$/)) { return less(parsed.pathname).then(function(o) { res.setHeader("Content-Type", "text/css"); res.end(o.css); }); } next(); ...
javascript
function(req, res, next) { var parsed = require("url").parse(req.url); if (parsed.pathname.match(/\.less$/)) { return less(parsed.pathname).then(function(o) { res.setHeader("Content-Type", "text/css"); res.end(o.css); }); } next(); ...
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "parsed", "=", "require", "(", "\"url\"", ")", ".", "parse", "(", "req", ".", "url", ")", ";", "if", "(", "parsed", ".", "pathname", ".", "match", "(", "/", "\\.less$", "/", ")", ...
Catch all requests, if any are for .less files, recompile on the fly and send back a CSS response
[ "Catch", "all", "requests", "if", "any", "are", "for", ".", "less", "files", "recompile", "on", "the", "fly", "and", "send", "back", "a", "CSS", "response" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/examples/middleware.css.injection.js#L38-L47
train
BrowserSync/browser-sync
packages/browser-sync/lib/lodash.custom.js
iteratorToArray
function iteratorToArray(iterator) { var data, result = []; while (!(data = iterator.next()).done) { result.push(data.value); } return result; }
javascript
function iteratorToArray(iterator) { var data, result = []; while (!(data = iterator.next()).done) { result.push(data.value); } return result; }
[ "function", "iteratorToArray", "(", "iterator", ")", "{", "var", "data", ",", "result", "=", "[", "]", ";", "while", "(", "!", "(", "data", "=", "iterator", ".", "next", "(", ")", ")", ".", "done", ")", "{", "result", ".", "push", "(", "data", "....
Converts `iterator` to an array. @private @param {Object} iterator The iterator to convert. @returns {Array} Returns the converted array.
[ "Converts", "iterator", "to", "an", "array", "." ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/lodash.custom.js#L646-L654
train
BrowserSync/browser-sync
packages/browser-sync/lib/lodash.custom.js
getIteratee
function getIteratee() { var result = lodash.iteratee || iteratee; result = result === iteratee ? baseIteratee : result; return arguments.length ? result(arguments[0], arguments[1]) : result; }
javascript
function getIteratee() { var result = lodash.iteratee || iteratee; result = result === iteratee ? baseIteratee : result; return arguments.length ? result(arguments[0], arguments[1]) : result; }
[ "function", "getIteratee", "(", ")", "{", "var", "result", "=", "lodash", ".", "iteratee", "||", "iteratee", ";", "result", "=", "result", "===", "iteratee", "?", "baseIteratee", ":", "result", ";", "return", "arguments", ".", "length", "?", "result", "(",...
Gets the appropriate "iteratee" function. If `_.iteratee` is customized, this function returns the custom method, otherwise it returns `baseIteratee`. If arguments are provided, the chosen function is invoked with them and its result is returned. @private @param {*} [value] The value to convert to an iteratee. @param ...
[ "Gets", "the", "appropriate", "iteratee", "function", ".", "If", "_", ".", "iteratee", "is", "customized", "this", "function", "returns", "the", "custom", "method", "otherwise", "it", "returns", "baseIteratee", ".", "If", "arguments", "are", "provided", "the", ...
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/lodash.custom.js#L3150-L3154
train
BrowserSync/browser-sync
packages/browser-sync/lib/lodash.custom.js
memoizeCapped
function memoizeCapped(func) { var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; }
javascript
function memoizeCapped(func) { var result = memoize(func, function(key) { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } return key; }); var cache = result.cache; return result; }
[ "function", "memoizeCapped", "(", "func", ")", "{", "var", "result", "=", "memoize", "(", "func", ",", "function", "(", "key", ")", "{", "if", "(", "cache", ".", "size", "===", "MAX_MEMOIZE_SIZE", ")", "{", "cache", ".", "clear", "(", ")", ";", "}", ...
A specialized version of `_.memoize` which clears the memoized function's cache when it exceeds `MAX_MEMOIZE_SIZE`. @private @param {Function} func The function to have its output memoized. @returns {Function} Returns the new memoized function.
[ "A", "specialized", "version", "of", "_", ".", "memoize", "which", "clears", "the", "memoized", "function", "s", "cache", "when", "it", "exceeds", "MAX_MEMOIZE_SIZE", "." ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/lodash.custom.js#L3604-L3614
train
BrowserSync/browser-sync
packages/browser-sync/lib/lodash.custom.js
toInteger
function toInteger(value) { var result = toFinite(value), remainder = result % 1; return result === result ? remainder ? result - remainder : result : 0; }
javascript
function toInteger(value) { var result = toFinite(value), remainder = result % 1; return result === result ? remainder ? result - remainder : result : 0; }
[ "function", "toInteger", "(", "value", ")", "{", "var", "result", "=", "toFinite", "(", "value", ")", ",", "remainder", "=", "result", "%", "1", ";", "return", "result", "===", "result", "?", "remainder", "?", "result", "-", "remainder", ":", "result", ...
Converts `value` to an integer. **Note:** This method is loosely based on [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). @static @memberOf _ @since 4.0.0 @category Lang @param {*} value The value to convert. @returns {number} Returns the converted integer. @example _.toInteger(3.2); //...
[ "Converts", "value", "to", "an", "integer", "." ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/lodash.custom.js#L4480-L4487
train
BrowserSync/browser-sync
packages/browser-sync/lib/plugins.js
requirePlugin
function requirePlugin(item) { /** * if the "module" property already exists and * is not a string, then we bail and don't bother looking * for the file */ if (item.get("module") && typeof item.get("module") !== "string") { return item; } try { /** * Try a r...
javascript
function requirePlugin(item) { /** * if the "module" property already exists and * is not a string, then we bail and don't bother looking * for the file */ if (item.get("module") && typeof item.get("module") !== "string") { return item; } try { /** * Try a r...
[ "function", "requirePlugin", "(", "item", ")", "{", "/**\n * if the \"module\" property already exists and\n * is not a string, then we bail and don't bother looking\n * for the file\n */", "if", "(", "item", ".", "get", "(", "\"module\"", ")", "&&", "typeof", "item...
Load a plugin from disk @param item @returns {*}
[ "Load", "a", "plugin", "from", "disk" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/plugins.js#L122-L162
train
BrowserSync/browser-sync
packages/browser-sync/lib/logger.js
function(bs, data) { if (canLogFileChange(bs, data)) { if (data.path[0] === "*") { return logger.info( "{cyan:Reloading files that match: {magenta:%s", data.path ); } logger.info( "{cyan:...
javascript
function(bs, data) { if (canLogFileChange(bs, data)) { if (data.path[0] === "*") { return logger.info( "{cyan:Reloading files that match: {magenta:%s", data.path ); } logger.info( "{cyan:...
[ "function", "(", "bs", ",", "data", ")", "{", "if", "(", "canLogFileChange", "(", "bs", ",", "data", ")", ")", "{", "if", "(", "data", ".", "path", "[", "0", "]", "===", "\"*\"", ")", "{", "return", "logger", ".", "info", "(", "\"{cyan:Reloading fi...
Log when a file changes @param {BrowserSync} bs @param data
[ "Log", "when", "a", "file", "changes" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/logger.js#L45-L59
train
BrowserSync/browser-sync
packages/browser-sync/lib/logger.js
function(bs, data) { var uaString = utils.getUaString(data.ua); var msg = "{cyan:Browser Connected: {magenta:%s, version: %s}"; var method = "info"; if (!bs.options.get("logConnections")) { method = "debug"; } logger.log(method, msg, uaString.name, uaString....
javascript
function(bs, data) { var uaString = utils.getUaString(data.ua); var msg = "{cyan:Browser Connected: {magenta:%s, version: %s}"; var method = "info"; if (!bs.options.get("logConnections")) { method = "debug"; } logger.log(method, msg, uaString.name, uaString....
[ "function", "(", "bs", ",", "data", ")", "{", "var", "uaString", "=", "utils", ".", "getUaString", "(", "data", ".", "ua", ")", ";", "var", "msg", "=", "\"{cyan:Browser Connected: {magenta:%s, version: %s}\"", ";", "var", "method", "=", "\"info\"", ";", "if"...
Client connected logging @param {BrowserSync} bs @param data
[ "Client", "connected", "logging" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/logger.js#L106-L116
train
BrowserSync/browser-sync
packages/browser-sync/lib/logger.js
function(bs, data) { const type = data.type; if (bs.options.get('json')) { return console.log(JSON.stringify({ "service:running": { "options": bs.options.toJS() } })); } if (type === "server") { var b...
javascript
function(bs, data) { const type = data.type; if (bs.options.get('json')) { return console.log(JSON.stringify({ "service:running": { "options": bs.options.toJS() } })); } if (type === "server") { var b...
[ "function", "(", "bs", ",", "data", ")", "{", "const", "type", "=", "data", ".", "type", ";", "if", "(", "bs", ".", "options", ".", "get", "(", "'json'", ")", ")", "{", "return", "console", ".", "log", "(", "JSON", ".", "stringify", "(", "{", "...
Main logging when the service is running @param {BrowserSync} bs @param data
[ "Main", "logging", "when", "the", "service", "is", "running" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/logger.js#L122-L176
train
BrowserSync/browser-sync
packages/browser-sync/lib/logger.js
getKeyName
function getKeyName(key) { if (key.indexOf("ui") > -1) { if (key === "ui") { return "UI"; } if (key === "ui-external") { return "UI External"; } } return key.substr(0, 1).toUpperCase() + key.substring(1); }
javascript
function getKeyName(key) { if (key.indexOf("ui") > -1) { if (key === "ui") { return "UI"; } if (key === "ui-external") { return "UI External"; } } return key.substr(0, 1).toUpperCase() + key.substring(1); }
[ "function", "getKeyName", "(", "key", ")", "{", "if", "(", "key", ".", "indexOf", "(", "\"ui\"", ")", ">", "-", "1", ")", "{", "if", "(", "key", "===", "\"ui\"", ")", "{", "return", "\"UI\"", ";", "}", "if", "(", "key", "===", "\"ui-external\"", ...
Transform url-key names into something more presentable @param key @returns {string}
[ "Transform", "url", "-", "key", "names", "into", "something", "more", "presentable" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/logger.js#L277-L287
train
BrowserSync/browser-sync
packages/browser-sync/lib/logger.js
canLogFileChange
function canLogFileChange(bs, data) { if (data && data.log === false) { return false; } return bs.options.get("logFileChanges"); }
javascript
function canLogFileChange(bs, data) { if (data && data.log === false) { return false; } return bs.options.get("logFileChanges"); }
[ "function", "canLogFileChange", "(", "bs", ",", "data", ")", "{", "if", "(", "data", "&&", "data", ".", "log", "===", "false", ")", "{", "return", "false", ";", "}", "return", "bs", ".", "options", ".", "get", "(", "\"logFileChanges\"", ")", ";", "}"...
Determine if file changes should be logged @param bs @param data @returns {boolean}
[ "Determine", "if", "file", "changes", "should", "be", "logged" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/logger.js#L295-L301
train
BrowserSync/browser-sync
packages/browser-sync/lib/server/index.js
createServer
function createServer(bs) { var proxy = bs.options.get("proxy"); var server = bs.options.get("server"); if (!proxy && !server) { return require("./snippet-server")(bs); } if (proxy) { return require("./proxy-server")(bs); } if (server) { return require("./static-se...
javascript
function createServer(bs) { var proxy = bs.options.get("proxy"); var server = bs.options.get("server"); if (!proxy && !server) { return require("./snippet-server")(bs); } if (proxy) { return require("./proxy-server")(bs); } if (server) { return require("./static-se...
[ "function", "createServer", "(", "bs", ")", "{", "var", "proxy", "=", "bs", ".", "options", ".", "get", "(", "\"proxy\"", ")", ";", "var", "server", "=", "bs", ".", "options", ".", "get", "(", "\"server\"", ")", ";", "if", "(", "!", "proxy", "&&", ...
Launch the server for serving the client JS plus static files @param {BrowserSync} bs @returns {{staticServer: (http.Server), proxyServer: (http.Server)}}
[ "Launch", "the", "server", "for", "serving", "the", "client", "JS", "plus", "static", "files" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/server/index.js#L85-L100
train
BrowserSync/browser-sync
packages/browser-sync-ui/tasks/icons.js
icons
function icons (opts, ctx, done) { return vfs.src(opts.input) .pipe(easysvg.stream({js: false})) .on('error', done) .pipe(vfs.dest(opts.output)) }
javascript
function icons (opts, ctx, done) { return vfs.src(opts.input) .pipe(easysvg.stream({js: false})) .on('error', done) .pipe(vfs.dest(opts.output)) }
[ "function", "icons", "(", "opts", ",", "ctx", ",", "done", ")", "{", "return", "vfs", ".", "src", "(", "opts", ".", "input", ")", ".", "pipe", "(", "easysvg", ".", "stream", "(", "{", "js", ":", "false", "}", ")", ")", ".", "on", "(", "'error'"...
Compile SVG Symbols
[ "Compile", "SVG", "Symbols" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/tasks/icons.js#L7-L12
train
BrowserSync/browser-sync
packages/browser-sync-ui/src/scripts/services/Pages.js
function ($section) { angular.forEach(pagesConfig, function (item) { item.active = false; }); $section.active = true; return pagesConfig; }
javascript
function ($section) { angular.forEach(pagesConfig, function (item) { item.active = false; }); $section.active = true; return pagesConfig; }
[ "function", "(", "$section", ")", "{", "angular", ".", "forEach", "(", "pagesConfig", ",", "function", "(", "item", ")", "{", "item", ".", "active", "=", "false", ";", "}", ")", ";", "$section", ".", "active", "=", "true", ";", "return", "pagesConfig",...
Enable a single Item @param $section @returns {*}
[ "Enable", "a", "single", "Item" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/src/scripts/services/Pages.js#L22-L28
train
BrowserSync/browser-sync
packages/browser-sync-ui/src/scripts/services/Pages.js
function () { if ($location.path() === "/") { return pagesConfig["overview"]; } var match; angular.forEach(pagesConfig, function (item) { if (item.path === $location.path()) { match = item; } ...
javascript
function () { if ($location.path() === "/") { return pagesConfig["overview"]; } var match; angular.forEach(pagesConfig, function (item) { if (item.path === $location.path()) { match = item; } ...
[ "function", "(", ")", "{", "if", "(", "$location", ".", "path", "(", ")", "===", "\"/\"", ")", "{", "return", "pagesConfig", "[", "\"overview\"", "]", ";", "}", "var", "match", ";", "angular", ".", "forEach", "(", "pagesConfig", ",", "function", "(", ...
Get the current section based on the path @returns {*}
[ "Get", "the", "current", "section", "based", "on", "the", "path" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/src/scripts/services/Pages.js#L43-L54
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/async.js
function (ui, done) { Object.keys(ui.defaultPlugins).forEach(function (key) { ui.pluginManager.get(key)(ui, ui.bs); }); done(); }
javascript
function (ui, done) { Object.keys(ui.defaultPlugins).forEach(function (key) { ui.pluginManager.get(key)(ui, ui.bs); }); done(); }
[ "function", "(", "ui", ",", "done", ")", "{", "Object", ".", "keys", "(", "ui", ".", "defaultPlugins", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "ui", ".", "pluginManager", ".", "get", "(", "key", ")", "(", "ui", ",", "ui", ".",...
Run default plugins @param ui @param done
[ "Run", "default", "plugins" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/async.js#L158-L163
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/async.js
function (ui, done) { var bs = ui.bs; ui.clients.on("connection", function (client) { client.emit("ui:connection", ui.options.toJS()); ui.options.get("clientFiles").map(function (item) { if (item.get("active")) { ui.addElement(client, item....
javascript
function (ui, done) { var bs = ui.bs; ui.clients.on("connection", function (client) { client.emit("ui:connection", ui.options.toJS()); ui.options.get("clientFiles").map(function (item) { if (item.get("active")) { ui.addElement(client, item....
[ "function", "(", "ui", ",", "done", ")", "{", "var", "bs", "=", "ui", ".", "bs", ";", "ui", ".", "clients", ".", "on", "(", "\"connection\"", ",", "function", "(", "client", ")", "{", "client", ".", "emit", "(", "\"ui:connection\"", ",", "ui", ".",...
The most important event is the initial connection where the options are received from the socket @param ui @param done
[ "The", "most", "important", "event", "is", "the", "initial", "connection", "where", "the", "options", "are", "received", "from", "the", "socket" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/async.js#L170-L208
train
BrowserSync/browser-sync
packages/browser-sync/lib/file-watcher.js
function(event, path) { emitter.emit("file:changed", { event: event, path: path, namespace: namespace }); }
javascript
function(event, path) { emitter.emit("file:changed", { event: event, path: path, namespace: namespace }); }
[ "function", "(", "event", ",", "path", ")", "{", "emitter", ".", "emit", "(", "\"file:changed\"", ",", "{", "event", ":", "event", ",", "path", ":", "path", ",", "namespace", ":", "namespace", "}", ")", ";", "}" ]
Default CB when not given @param event @param path
[ "Default", "CB", "when", "not", "given" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/file-watcher.js#L23-L29
train
BrowserSync/browser-sync
packages/browser-sync/lib/index.js
noop
function noop(name) { return function() { var args = Array.prototype.slice.call(arguments); if (singleton) { return singleton[name].apply(singleton, args); } else { if (publicUtils.isStreamArg(name, args)) { return new PassThrough({ objectMode: true })...
javascript
function noop(name) { return function() { var args = Array.prototype.slice.call(arguments); if (singleton) { return singleton[name].apply(singleton, args); } else { if (publicUtils.isStreamArg(name, args)) { return new PassThrough({ objectMode: true })...
[ "function", "noop", "(", "name", ")", "{", "return", "function", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "if", "(", "singleton", ")", "{", "return", "singleton", "[", "name"...
Helper to allow methods to be called on the module export before there's a running instance @param {String} name @returns {Function}
[ "Helper", "to", "allow", "methods", "to", "be", "called", "on", "the", "module", "export", "before", "there", "s", "a", "running", "instance" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/index.js#L220-L231
train
BrowserSync/browser-sync
packages/browser-sync/lib/index.js
getSingle
function getSingle(name) { if (instances.length) { var match = instances.filter(function(item) { return item.name === name; }); if (match.length) { return match[0]; } } return false; }
javascript
function getSingle(name) { if (instances.length) { var match = instances.filter(function(item) { return item.name === name; }); if (match.length) { return match[0]; } } return false; }
[ "function", "getSingle", "(", "name", ")", "{", "if", "(", "instances", ".", "length", ")", "{", "var", "match", "=", "instances", ".", "filter", "(", "function", "(", "item", ")", "{", "return", "item", ".", "name", "===", "name", ";", "}", ")", "...
Get a single instance by name @param {String} name @returns {Object|Boolean}
[ "Get", "a", "single", "instance", "by", "name" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/index.js#L286-L296
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/plugins/network-throttle/network-throttle.js
getUrls
function getUrls (opts) { var list = []; var bsLocal = require("url").parse(opts.urls.local); list.push([bsLocal.protocol + "//", bsLocal.hostname, ":", opts.port].join("")); if (opts.urls.external) { var external = require("url").parse(opts.urls.external); list.push([bsLocal.prot...
javascript
function getUrls (opts) { var list = []; var bsLocal = require("url").parse(opts.urls.local); list.push([bsLocal.protocol + "//", bsLocal.hostname, ":", opts.port].join("")); if (opts.urls.external) { var external = require("url").parse(opts.urls.external); list.push([bsLocal.prot...
[ "function", "getUrls", "(", "opts", ")", "{", "var", "list", "=", "[", "]", ";", "var", "bsLocal", "=", "require", "(", "\"url\"", ")", ".", "parse", "(", "opts", ".", "urls", ".", "local", ")", ";", "list", ".", "push", "(", "[", "bsLocal", ".",...
Get local + external urls with a different port @param opts @returns {List<T>|List<any>}
[ "Get", "local", "+", "external", "urls", "with", "a", "different", "port" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/plugins/network-throttle/network-throttle.js#L146-L160
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/plugins/history/history.js
function (current, temp) { if (!Immutable.is(current, temp)) { validUrls = temp; methods.sendUpdatedUrls(validUrls); } }
javascript
function (current, temp) { if (!Immutable.is(current, temp)) { validUrls = temp; methods.sendUpdatedUrls(validUrls); } }
[ "function", "(", "current", ",", "temp", ")", "{", "if", "(", "!", "Immutable", ".", "is", "(", "current", ",", "temp", ")", ")", "{", "validUrls", "=", "temp", ";", "methods", ".", "sendUpdatedUrls", "(", "validUrls", ")", ";", "}", "}" ]
Only send to UI if list changed @param current @param temp
[ "Only", "send", "to", "UI", "if", "list", "changed" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/plugins/history/history.js#L21-L26
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/plugins/history/history.js
function (data) { var temp = addPath(validUrls, url.parse(data.href), bs.options.get("mode")); methods.sendUpdatedIfChanged(validUrls, temp, ui.socket); }
javascript
function (data) { var temp = addPath(validUrls, url.parse(data.href), bs.options.get("mode")); methods.sendUpdatedIfChanged(validUrls, temp, ui.socket); }
[ "function", "(", "data", ")", "{", "var", "temp", "=", "addPath", "(", "validUrls", ",", "url", ".", "parse", "(", "data", ".", "href", ")", ",", "bs", ".", "options", ".", "get", "(", "\"mode\"", ")", ")", ";", "methods", ".", "sendUpdatedIfChanged"...
Add a new path @param data
[ "Add", "a", "new", "path" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/plugins/history/history.js#L46-L49
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/plugins/history/history.js
function (data) { var temp = removePath(validUrls, data.path); methods.sendUpdatedIfChanged(validUrls, temp, ui.socket); }
javascript
function (data) { var temp = removePath(validUrls, data.path); methods.sendUpdatedIfChanged(validUrls, temp, ui.socket); }
[ "function", "(", "data", ")", "{", "var", "temp", "=", "removePath", "(", "validUrls", ",", "data", ".", "path", ")", ";", "methods", ".", "sendUpdatedIfChanged", "(", "validUrls", ",", "temp", ",", "ui", ".", "socket", ")", ";", "}" ]
Remove a path @param data
[ "Remove", "a", "path" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/plugins/history/history.js#L54-L57
train
BrowserSync/browser-sync
packages/browser-sync/lib/server/proxy-utils.js
rewriteCookies
function rewriteCookies(rawCookie) { var objCookie = (function() { // simple parse function (does not remove quotes) var obj = {}; var pairs = rawCookie.split(/; */); pairs.forEach(function(pair) { var eqIndex = pair.indexOf("="); // skip things that don't l...
javascript
function rewriteCookies(rawCookie) { var objCookie = (function() { // simple parse function (does not remove quotes) var obj = {}; var pairs = rawCookie.split(/; */); pairs.forEach(function(pair) { var eqIndex = pair.indexOf("="); // skip things that don't l...
[ "function", "rewriteCookies", "(", "rawCookie", ")", "{", "var", "objCookie", "=", "(", "function", "(", ")", "{", "// simple parse function (does not remove quotes)", "var", "obj", "=", "{", "}", ";", "var", "pairs", "=", "rawCookie", ".", "split", "(", "/", ...
Remove the domain from any cookies. @param rawCookie @returns {string}
[ "Remove", "the", "domain", "from", "any", "cookies", "." ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/server/proxy-utils.js#L122-L156
train
BrowserSync/browser-sync
packages/browser-sync/lib/server/proxy-server.js
applyFns
function applyFns(name, fns) { if (!List.isList(fns)) fns = [fns]; proxy.on(name, function() { var args = arguments; fns.forEach(function(fn) { if (typeof fn === "function") { fn.apply(null, args); } }); }); ...
javascript
function applyFns(name, fns) { if (!List.isList(fns)) fns = [fns]; proxy.on(name, function() { var args = arguments; fns.forEach(function(fn) { if (typeof fn === "function") { fn.apply(null, args); } }); }); ...
[ "function", "applyFns", "(", "name", ",", "fns", ")", "{", "if", "(", "!", "List", ".", "isList", "(", "fns", ")", ")", "fns", "=", "[", "fns", "]", ";", "proxy", ".", "on", "(", "name", ",", "function", "(", ")", "{", "var", "args", "=", "ar...
Apply functions to proxy events @param {string} name - the name of the http-proxy event @param {Array} fns - functions to call on each event
[ "Apply", "functions", "to", "proxy", "events" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/server/proxy-server.js#L127-L137
train
BrowserSync/browser-sync
packages/browser-sync/lib/sockets.js
handleConnection
function handleConnection(client) { // set ghostmode callbacks if (bs.options.get("ghostMode")) { addGhostMode(client); } client.emit("connection", bs.options.toJS()); //todo - trim the amount of options sent to clients emitter.emit("client:connected", { ...
javascript
function handleConnection(client) { // set ghostmode callbacks if (bs.options.get("ghostMode")) { addGhostMode(client); } client.emit("connection", bs.options.toJS()); //todo - trim the amount of options sent to clients emitter.emit("client:connected", { ...
[ "function", "handleConnection", "(", "client", ")", "{", "// set ghostmode callbacks", "if", "(", "bs", ".", "options", ".", "get", "(", "\"ghostMode\"", ")", ")", "{", "addGhostMode", "(", "client", ")", ";", "}", "client", ".", "emit", "(", "\"connection\"...
Handle each new connection @param {Object} client
[ "Handle", "each", "new", "connection" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/sockets.js#L54-L65
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/hooks.js
function (hooks, ui) { var config = hooks .map(transformConfig) .reduce(createConfigItem, {}); return { /** * pagesConfig - This is the angular configuration such as routes */ pagesConfig: configTmpl .replace("%w...
javascript
function (hooks, ui) { var config = hooks .map(transformConfig) .reduce(createConfigItem, {}); return { /** * pagesConfig - This is the angular configuration such as routes */ pagesConfig: configTmpl .replace("%w...
[ "function", "(", "hooks", ",", "ui", ")", "{", "var", "config", "=", "hooks", ".", "map", "(", "transformConfig", ")", ".", "reduce", "(", "createConfigItem", ",", "{", "}", ")", ";", "return", "{", "/**\n * pagesConfig - This is the angular configur...
Create the url config for each section of the ui @param hooks @param ui
[ "Create", "the", "url", "config", "for", "each", "section", "of", "the", "ui" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/hooks.js#L23-L51
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/hooks.js
function (hooks) { var obj = {}; hooks.forEach(function (elements) { elements.forEach(function (item) { if (!obj[item.name]) { obj[item.name] = item; } }); }); return obj; }
javascript
function (hooks) { var obj = {}; hooks.forEach(function (elements) { elements.forEach(function (item) { if (!obj[item.name]) { obj[item.name] = item; } }); }); return obj; }
[ "function", "(", "hooks", ")", "{", "var", "obj", "=", "{", "}", ";", "hooks", ".", "forEach", "(", "function", "(", "elements", ")", "{", "elements", ".", "forEach", "(", "function", "(", "item", ")", "{", "if", "(", "!", "obj", "[", "item", "."...
Allow plugins to register toggle-able elements @param hooks @returns {{}}
[ "Allow", "plugins", "to", "register", "toggle", "-", "able", "elements" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/hooks.js#L148-L158
train
BrowserSync/browser-sync
packages/browser-sync/lib/server/utils.js
function(app, options) { return { server: (function() { var httpModule = serverUtils.getHttpModule(options); if ( options.get("scheme") === "https" || options.get("httpModule") === "http2" ) { ...
javascript
function(app, options) { return { server: (function() { var httpModule = serverUtils.getHttpModule(options); if ( options.get("scheme") === "https" || options.get("httpModule") === "http2" ) { ...
[ "function", "(", "app", ",", "options", ")", "{", "return", "{", "server", ":", "(", "function", "(", ")", "{", "var", "httpModule", "=", "serverUtils", ".", "getHttpModule", "(", "options", ")", ";", "if", "(", "options", ".", "get", "(", "\"scheme\""...
Get either http or https server or use the httpModule provided in options if present
[ "Get", "either", "http", "or", "https", "server", "or", "use", "the", "httpModule", "provided", "in", "options", "if", "present" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/server/utils.js#L86-L103
train
BrowserSync/browser-sync
packages/browser-sync/lib/public/public-utils.js
function(name, args) { if (name === "stream") { return true; } if (name !== "reload") { return false; } var firstArg = args[0]; /** * If here, it's reload with args */ if (_.isObject(firstArg)) { if (!Array....
javascript
function(name, args) { if (name === "stream") { return true; } if (name !== "reload") { return false; } var firstArg = args[0]; /** * If here, it's reload with args */ if (_.isObject(firstArg)) { if (!Array....
[ "function", "(", "name", ",", "args", ")", "{", "if", "(", "name", "===", "\"stream\"", ")", "{", "return", "true", ";", "}", "if", "(", "name", "!==", "\"reload\"", ")", "{", "return", "false", ";", "}", "var", "firstArg", "=", "args", "[", "0", ...
This code handles the switch between .reload & .stream since 2.6.0 @param name @param args @returns {boolean}
[ "This", "code", "handles", "the", "switch", "between", ".", "reload", "&", ".", "stream", "since", "2", ".", "6", ".", "0" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/public/public-utils.js#L42-L63
train
BrowserSync/browser-sync
packages/browser-sync/lib/async.js
function(bs, done) { utils.getPorts(bs.options, function(err, port) { if (err) { return utils.fail(true, err, bs.cb); } bs.debug("Found a free port: {magenta:%s", port); done(null, { options: { port: port ...
javascript
function(bs, done) { utils.getPorts(bs.options, function(err, port) { if (err) { return utils.fail(true, err, bs.cb); } bs.debug("Found a free port: {magenta:%s", port); done(null, { options: { port: port ...
[ "function", "(", "bs", ",", "done", ")", "{", "utils", ".", "getPorts", "(", "bs", ".", "options", ",", "function", "(", "err", ",", "port", ")", "{", "if", "(", "err", ")", "{", "return", "utils", ".", "fail", "(", "true", ",", "err", ",", "bs...
BrowserSync needs at least 1 free port. It will check the one provided in config and keep incrementing until an available one is found. @param {BrowserSync} bs @param {Function} done
[ "BrowserSync", "needs", "at", "least", "1", "free", "port", ".", "It", "will", "check", "the", "one", "provided", "in", "config", "and", "keep", "incrementing", "until", "an", "available", "one", "is", "found", "." ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/async.js#L18-L30
train
BrowserSync/browser-sync
packages/browser-sync/lib/async.js
function(bs, done) { /** * An extra port is not needed in snippet/server mode */ if (bs.options.get("mode") !== "proxy") { return done(); } /** * Web socket support is disabled by default */ if (!bs.options.getIn(["proxy", "ws"])) ...
javascript
function(bs, done) { /** * An extra port is not needed in snippet/server mode */ if (bs.options.get("mode") !== "proxy") { return done(); } /** * Web socket support is disabled by default */ if (!bs.options.getIn(["proxy", "ws"])) ...
[ "function", "(", "bs", ",", "done", ")", "{", "/**\n * An extra port is not needed in snippet/server mode\n */", "if", "(", "bs", ".", "options", ".", "get", "(", "\"mode\"", ")", "!==", "\"proxy\"", ")", "{", "return", "done", "(", ")", ";", "}"...
If the running mode is proxy, we'll use a separate port for the Browsersync web-socket server. This is to eliminate any issues with trying to proxy web sockets through to the users server. @param bs @param done
[ "If", "the", "running", "mode", "is", "proxy", "we", "ll", "use", "a", "separate", "port", "for", "the", "Browsersync", "web", "-", "socket", "server", ".", "This", "is", "to", "eliminate", "any", "issues", "with", "trying", "to", "proxy", "web", "socket...
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/async.js#L38-L78
train
BrowserSync/browser-sync
packages/browser-sync/lib/async.js
function(bs, done) { var plugins = bs.options .get("plugins") .map(pluginUtils.resolvePlugin) .map(pluginUtils.requirePlugin); plugins.forEach(function(plugin) { if (plugin.get("errors").size) { return logPluginError(plugin); }...
javascript
function(bs, done) { var plugins = bs.options .get("plugins") .map(pluginUtils.resolvePlugin) .map(pluginUtils.requirePlugin); plugins.forEach(function(plugin) { if (plugin.get("errors").size) { return logPluginError(plugin); }...
[ "function", "(", "bs", ",", "done", ")", "{", "var", "plugins", "=", "bs", ".", "options", ".", "get", "(", "\"plugins\"", ")", ".", "map", "(", "pluginUtils", ".", "resolvePlugin", ")", ".", "map", "(", "pluginUtils", ".", "requirePlugin", ")", ";", ...
Try to load plugins that were given in options @param {BrowserSync} bs @param {Function} done
[ "Try", "to", "load", "plugins", "that", "were", "given", "in", "options" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/async.js#L119-L140
train
BrowserSync/browser-sync
packages/browser-sync/lib/internal-events.js
function(data) { var mode = bs.options.get("mode"); var open = bs.options.get("open"); if ( mode === "proxy" || mode === "server" || open === "ui" || open === "ui-external" ) { utils.openBrow...
javascript
function(data) { var mode = bs.options.get("mode"); var open = bs.options.get("open"); if ( mode === "proxy" || mode === "server" || open === "ui" || open === "ui-external" ) { utils.openBrow...
[ "function", "(", "data", ")", "{", "var", "mode", "=", "bs", ".", "options", ".", "get", "(", "\"mode\"", ")", ";", "var", "open", "=", "bs", ".", "options", ".", "get", "(", "\"open\"", ")", ";", "if", "(", "mode", "===", "\"proxy\"", "||", "mod...
Things that happened after the service is running @param data
[ "Things", "that", "happened", "after", "the", "service", "is", "running" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/internal-events.js#L35-L52
train
BrowserSync/browser-sync
packages/browser-sync/lib/internal-events.js
function(data) { if (data.active) { bs.pluginManager.enablePlugin(data.name); } else { bs.pluginManager.disablePlugin(data.name); } bs.setOption("userPlugins", bs.getUserPlugins()); }
javascript
function(data) { if (data.active) { bs.pluginManager.enablePlugin(data.name); } else { bs.pluginManager.disablePlugin(data.name); } bs.setOption("userPlugins", bs.getUserPlugins()); }
[ "function", "(", "data", ")", "{", "if", "(", "data", ".", "active", ")", "{", "bs", ".", "pluginManager", ".", "enablePlugin", "(", "data", ".", "name", ")", ";", "}", "else", "{", "bs", ".", "pluginManager", ".", "disablePlugin", "(", "data", ".", ...
Plugin configuration setting @param data
[ "Plugin", "configuration", "setting" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/internal-events.js#L66-L73
train
BrowserSync/browser-sync
packages/browser-sync-client/index.js
setHeaders
function setHeaders(res, body) { res.setHeader("Cache-Control", "public, max-age=0"); res.setHeader("Content-Type", "text/javascript"); res.setHeader("ETag", etag(body)); }
javascript
function setHeaders(res, body) { res.setHeader("Cache-Control", "public, max-age=0"); res.setHeader("Content-Type", "text/javascript"); res.setHeader("ETag", etag(body)); }
[ "function", "setHeaders", "(", "res", ",", "body", ")", "{", "res", ".", "setHeader", "(", "\"Cache-Control\"", ",", "\"public, max-age=0\"", ")", ";", "res", ".", "setHeader", "(", "\"Content-Type\"", ",", "\"text/javascript\"", ")", ";", "res", ".", "setHead...
Set headers on the response @param {Object} res @param {String} body
[ "Set", "headers", "on", "the", "response" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-client/index.js#L27-L31
train
BrowserSync/browser-sync
packages/browser-sync-client/index.js
init
function init(options, requestBody, type) { /** * If the user asked for a file, simply return the string. */ if (type && type === "file") { return processItems(requestBody); } /** * Otherwise return a function to be used a middleware */ return function(req, res) { ...
javascript
function init(options, requestBody, type) { /** * If the user asked for a file, simply return the string. */ if (type && type === "file") { return processItems(requestBody); } /** * Otherwise return a function to be used a middleware */ return function(req, res) { ...
[ "function", "init", "(", "options", ",", "requestBody", ",", "type", ")", "{", "/**\n * If the user asked for a file, simply return the string.\n */", "if", "(", "type", "&&", "type", "===", "\"file\"", ")", "{", "return", "processItems", "(", "requestBody", "...
Public method for returning either a middleware fn or the content as a string @param {Object} options @param requestBody @param {String} type - either `file` or `middleware` @returns {*}
[ "Public", "method", "for", "returning", "either", "a", "middleware", "fn", "or", "the", "content", "as", "a", "string" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-client/index.js#L73-L113
train
BrowserSync/browser-sync
packages/browser-sync/lib/browser-sync.js
setOptions
function setOptions(bs, options) { /** * If multiple options were set, act on the immutable map * in an efficient way */ if (Object.keys(options).length > 1) { bs.setMany(function(item) { Object.keys(options).forEach(function(key) { item.set(key, options[key]);...
javascript
function setOptions(bs, options) { /** * If multiple options were set, act on the immutable map * in an efficient way */ if (Object.keys(options).length > 1) { bs.setMany(function(item) { Object.keys(options).forEach(function(key) { item.set(key, options[key]);...
[ "function", "setOptions", "(", "bs", ",", "options", ")", "{", "/**\n * If multiple options were set, act on the immutable map\n * in an efficient way\n */", "if", "(", "Object", ".", "keys", "(", "options", ")", ".", "length", ">", "1", ")", "{", "bs", "....
Update the options Map @param bs @param options
[ "Update", "the", "options", "Map" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/browser-sync.js#L201-L218
train
BrowserSync/browser-sync
packages/browser-sync/lib/browser-sync.js
tasksComplete
function tasksComplete(bs) { return function(err) { if (err) { bs.logger.setOnce("useLevelPrefixes", true).error(err.message); } /** * Set active flag */ bs.active = true; /** * @deprecated */ bs.events.emit("init", bs...
javascript
function tasksComplete(bs) { return function(err) { if (err) { bs.logger.setOnce("useLevelPrefixes", true).error(err.message); } /** * Set active flag */ bs.active = true; /** * @deprecated */ bs.events.emit("init", bs...
[ "function", "tasksComplete", "(", "bs", ")", "{", "return", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "bs", ".", "logger", ".", "setOnce", "(", "\"useLevelPrefixes\"", ",", "true", ")", ".", "error", "(", "err", ".", "message", ")...
At this point, ALL async tasks have completed @param {BrowserSync} bs @returns {Function}
[ "At", "this", "point", "ALL", "async", "tasks", "have", "completed" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync/lib/browser-sync.js#L225-L267
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/UI.js
taskRunner
function taskRunner (ui) { return function (item, cb) { ui.logger.debug("Starting Step: " + item.step); /** * Give each step access to the UI Instance */ item.fn(ui, function (err, out) { if (err) { return cb(err); } if...
javascript
function taskRunner (ui) { return function (item, cb) { ui.logger.debug("Starting Step: " + item.step); /** * Give each step access to the UI Instance */ item.fn(ui, function (err, out) { if (err) { return cb(err); } if...
[ "function", "taskRunner", "(", "ui", ")", "{", "return", "function", "(", "item", ",", "cb", ")", "{", "ui", ".", "logger", ".", "debug", "(", "\"Starting Step: \"", "+", "item", ".", "step", ")", ";", "/**\n * Give each step access to the UI Instance\n ...
Run each setup task in sequence @param ui @returns {Function}
[ "Run", "each", "setup", "task", "in", "sequence" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/UI.js#L175-L195
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/UI.js
handleOut
function handleOut (ui, out) { if (out.options) { Object.keys(out.options).forEach(function (key) { ui.options = ui.options.set(key, out.options[key]); }); } if (out.optionsIn) { out.optionsIn.forEach(function (item) { ui.options = ui.options.setIn(item.path...
javascript
function handleOut (ui, out) { if (out.options) { Object.keys(out.options).forEach(function (key) { ui.options = ui.options.set(key, out.options[key]); }); } if (out.optionsIn) { out.optionsIn.forEach(function (item) { ui.options = ui.options.setIn(item.path...
[ "function", "handleOut", "(", "ui", ",", "out", ")", "{", "if", "(", "out", ".", "options", ")", "{", "Object", ".", "keys", "(", "out", ".", "options", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "ui", ".", "options", "=", "ui", ...
Setup tasks may return options or instance properties to be set @param {UI} ui @param {Object} out
[ "Setup", "tasks", "may", "return", "options", "or", "instance", "properties", "to", "be", "set" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/UI.js#L202-L221
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/UI.js
tasksComplete
function tasksComplete (ui) { return function (err) { /** * Log any error according to BrowserSync's Logging level */ if (err) { ui.logger.setOnce("useLevelPrefixes", true).error(err.message || err); } /** * Running event */ ...
javascript
function tasksComplete (ui) { return function (err) { /** * Log any error according to BrowserSync's Logging level */ if (err) { ui.logger.setOnce("useLevelPrefixes", true).error(err.message || err); } /** * Running event */ ...
[ "function", "tasksComplete", "(", "ui", ")", "{", "return", "function", "(", "err", ")", "{", "/**\n * Log any error according to BrowserSync's Logging level\n */", "if", "(", "err", ")", "{", "ui", ".", "logger", ".", "setOnce", "(", "\"useLevelPrefix...
All async tasks complete at this point @param ui
[ "All", "async", "tasks", "complete", "at", "this", "point" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/UI.js#L227-L248
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/plugins/connections/lib/connections.js
decorateClients
function decorateClients(clients, clientsInfo) { return clients.map(function (item) { clientsInfo.forEach(function (client) { if (client.id === item.id) { item.data = client.data; return false; } }); return item; }); }
javascript
function decorateClients(clients, clientsInfo) { return clients.map(function (item) { clientsInfo.forEach(function (client) { if (client.id === item.id) { item.data = client.data; return false; } }); return item; }); }
[ "function", "decorateClients", "(", "clients", ",", "clientsInfo", ")", "{", "return", "clients", ".", "map", "(", "function", "(", "item", ")", "{", "clientsInfo", ".", "forEach", "(", "function", "(", "client", ")", "{", "if", "(", "client", ".", "id",...
Use heart-beated data to decorate clients @param clients @param clientsInfo @returns {*}
[ "Use", "heart", "-", "beated", "data", "to", "decorate", "clients" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/plugins/connections/lib/connections.js#L88-L98
train
BrowserSync/browser-sync
packages/browser-sync-ui/lib/resolve-plugins.js
resolvePluginFiles
function resolvePluginFiles (collection, relPath) { return Immutable.fromJS(collection.reduce(function (all, item) { var full = path.join(relPath, item); if (fs.existsSync(full)) { all[full] = fs.readFileSync(full, "utf8"); } return all; }, {})); }
javascript
function resolvePluginFiles (collection, relPath) { return Immutable.fromJS(collection.reduce(function (all, item) { var full = path.join(relPath, item); if (fs.existsSync(full)) { all[full] = fs.readFileSync(full, "utf8"); } return all; }, {})); }
[ "function", "resolvePluginFiles", "(", "collection", ",", "relPath", ")", "{", "return", "Immutable", ".", "fromJS", "(", "collection", ".", "reduce", "(", "function", "(", "all", ",", "item", ")", "{", "var", "full", "=", "path", ".", "join", "(", "relP...
Read & store a file from a plugin @param {Array|Immutable.List} collection @param {String} relPath @returns {any}
[ "Read", "&", "store", "a", "file", "from", "a", "plugin" ]
6dd2d560f9afd0daa1188a797d55165f4e2a5763
https://github.com/BrowserSync/browser-sync/blob/6dd2d560f9afd0daa1188a797d55165f4e2a5763/packages/browser-sync-ui/lib/resolve-plugins.js#L109-L117
train
smooth-code/svgr
packages/hast-util-to-babel-ast/src/stringToObjectStyle.js
formatKey
function formatKey(key) { key = key.toLowerCase() // Don't capitalize -ms- prefix if (/^-ms-/.test(key)) key = key.substr(1) return t.identifier(hyphenToCamelCase(key)) }
javascript
function formatKey(key) { key = key.toLowerCase() // Don't capitalize -ms- prefix if (/^-ms-/.test(key)) key = key.substr(1) return t.identifier(hyphenToCamelCase(key)) }
[ "function", "formatKey", "(", "key", ")", "{", "key", "=", "key", ".", "toLowerCase", "(", ")", "// Don't capitalize -ms- prefix", "if", "(", "/", "^-ms-", "/", ".", "test", "(", "key", ")", ")", "key", "=", "key", ".", "substr", "(", "1", ")", "retu...
Format style key into JSX style object key. @param {string} key @return {string}
[ "Format", "style", "key", "into", "JSX", "style", "object", "key", "." ]
94fd1fa09066c0d65e9867a281879d1f085dc69e
https://github.com/smooth-code/svgr/blob/94fd1fa09066c0d65e9867a281879d1f085dc69e/packages/hast-util-to-babel-ast/src/stringToObjectStyle.js#L22-L27
train
smooth-code/svgr
packages/hast-util-to-babel-ast/src/stringToObjectStyle.js
formatValue
function formatValue(value) { if (isNumeric(value)) return t.numericLiteral(Number(value)) if (isConvertiblePixelValue(value)) return t.numericLiteral(Number(trimEnd(value, 'px'))) return t.stringLiteral(value) }
javascript
function formatValue(value) { if (isNumeric(value)) return t.numericLiteral(Number(value)) if (isConvertiblePixelValue(value)) return t.numericLiteral(Number(trimEnd(value, 'px'))) return t.stringLiteral(value) }
[ "function", "formatValue", "(", "value", ")", "{", "if", "(", "isNumeric", "(", "value", ")", ")", "return", "t", ".", "numericLiteral", "(", "Number", "(", "value", ")", ")", "if", "(", "isConvertiblePixelValue", "(", "value", ")", ")", "return", "t", ...
Format style value into JSX style object value. @param {string} key @return {string}
[ "Format", "style", "value", "into", "JSX", "style", "object", "value", "." ]
94fd1fa09066c0d65e9867a281879d1f085dc69e
https://github.com/smooth-code/svgr/blob/94fd1fa09066c0d65e9867a281879d1f085dc69e/packages/hast-util-to-babel-ast/src/stringToObjectStyle.js#L35-L40
train
smooth-code/svgr
packages/hast-util-to-babel-ast/src/stringToObjectStyle.js
stringToObjectStyle
function stringToObjectStyle(rawStyle) { const entries = rawStyle.split(';') const properties = [] let index = -1 while (++index < entries.length) { const entry = entries[index] const style = entry.trim() const firstColon = style.indexOf(':') const value = style.substr(firstColon + 1).trim() ...
javascript
function stringToObjectStyle(rawStyle) { const entries = rawStyle.split(';') const properties = [] let index = -1 while (++index < entries.length) { const entry = entries[index] const style = entry.trim() const firstColon = style.indexOf(':') const value = style.substr(firstColon + 1).trim() ...
[ "function", "stringToObjectStyle", "(", "rawStyle", ")", "{", "const", "entries", "=", "rawStyle", ".", "split", "(", "';'", ")", "const", "properties", "=", "[", "]", "let", "index", "=", "-", "1", "while", "(", "++", "index", "<", "entries", ".", "le...
Handle parsing of inline styles. @param {string} rawStyle @returns {object}
[ "Handle", "parsing", "of", "inline", "styles", "." ]
94fd1fa09066c0d65e9867a281879d1f085dc69e
https://github.com/smooth-code/svgr/blob/94fd1fa09066c0d65e9867a281879d1f085dc69e/packages/hast-util-to-babel-ast/src/stringToObjectStyle.js#L48-L67
train
dfahlander/Dexie.js
samples/remote-sync/websocket/WebSocketSyncServer.js
function (table, key, obj, clientIdentity) { // Create table if it doesnt exist: db.tables[table] = db.tables[table] || {}; // Put the obj into to table db.tables[table][key] = obj; // Register the change: db.changes.push({ rev: ++d...
javascript
function (table, key, obj, clientIdentity) { // Create table if it doesnt exist: db.tables[table] = db.tables[table] || {}; // Put the obj into to table db.tables[table][key] = obj; // Register the change: db.changes.push({ rev: ++d...
[ "function", "(", "table", ",", "key", ",", "obj", ",", "clientIdentity", ")", "{", "// Create table if it doesnt exist:", "db", ".", "tables", "[", "table", "]", "=", "db", ".", "tables", "[", "table", "]", "||", "{", "}", ";", "// Put the obj into to table"...
Subscribers to when database got changes. Used by server connections to be able to push out changes to their clients as they occur.
[ "Subscribers", "to", "when", "database", "got", "changes", ".", "Used", "by", "server", "connections", "to", "be", "able", "to", "push", "out", "changes", "to", "their", "clients", "as", "they", "occur", "." ]
80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8
https://github.com/dfahlander/Dexie.js/blob/80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8/samples/remote-sync/websocket/WebSocketSyncServer.js#L43-L58
train
dfahlander/Dexie.js
samples/remote-sync/websocket/WebSocketSyncServer.js
sendAnyChanges
function sendAnyChanges() { // Get all changes after syncedRevision that was not performed by the client we're talkin' to. var changes = db.changes.filter(function (change) { return change.rev > syncedRevision && change.source !== conn.clientIdentity; }); // Compact chang...
javascript
function sendAnyChanges() { // Get all changes after syncedRevision that was not performed by the client we're talkin' to. var changes = db.changes.filter(function (change) { return change.rev > syncedRevision && change.source !== conn.clientIdentity; }); // Compact chang...
[ "function", "sendAnyChanges", "(", ")", "{", "// Get all changes after syncedRevision that was not performed by the client we're talkin' to.", "var", "changes", "=", "db", ".", "changes", ".", "filter", "(", "function", "(", "change", ")", "{", "return", "change", ".", ...
Used when sending changes to client. Only send changes above syncedRevision since client is already in sync with syncedRevision.
[ "Used", "when", "sending", "changes", "to", "client", ".", "Only", "send", "changes", "above", "syncedRevision", "since", "client", "is", "already", "in", "sync", "with", "syncedRevision", "." ]
80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8
https://github.com/dfahlander/Dexie.js/blob/80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8/samples/remote-sync/websocket/WebSocketSyncServer.js#L141-L159
train
dfahlander/Dexie.js
src/helpers/promise.js
function (callback, args) { microtickQueue.push([callback, args]); if (needsNewPhysicalTick) { schedulePhysicalTick(); needsNewPhysicalTick = false; } }
javascript
function (callback, args) { microtickQueue.push([callback, args]); if (needsNewPhysicalTick) { schedulePhysicalTick(); needsNewPhysicalTick = false; } }
[ "function", "(", "callback", ",", "args", ")", "{", "microtickQueue", ".", "push", "(", "[", "callback", ",", "args", "]", ")", ";", "if", "(", "needsNewPhysicalTick", ")", "{", "schedulePhysicalTick", "(", ")", ";", "needsNewPhysicalTick", "=", "false", "...
Configurable through Promise.scheduler. Don't export because it would be unsafe to let unknown code call it unless they do try..catch within their callback. This function can be retrieved through getter of Promise.scheduler though, but users must not do Promise.scheduler = myFuncThatThrowsException
[ "Configurable", "through", "Promise", ".", "scheduler", ".", "Don", "t", "export", "because", "it", "would", "be", "unsafe", "to", "let", "unknown", "code", "call", "it", "unless", "they", "do", "try", "..", "catch", "within", "their", "callback", ".", "Th...
80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8
https://github.com/dfahlander/Dexie.js/blob/80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8/src/helpers/promise.js#L99-L105
train
dfahlander/Dexie.js
samples/remote-sync/websocket/websocketserver-shim.js
EmulatedWebSocketServerFactory
function EmulatedWebSocketServerFactory() { this.createServer = function (connectCallback) { var server = { _connect: function (socket) { var conn = { _client: socket, _listeners: { "text": [], "close": [] }, ...
javascript
function EmulatedWebSocketServerFactory() { this.createServer = function (connectCallback) { var server = { _connect: function (socket) { var conn = { _client: socket, _listeners: { "text": [], "close": [] }, ...
[ "function", "EmulatedWebSocketServerFactory", "(", ")", "{", "this", ".", "createServer", "=", "function", "(", "connectCallback", ")", "{", "var", "server", "=", "{", "_connect", ":", "function", "(", "socket", ")", "{", "var", "conn", "=", "{", "_client", ...
To be able to test both server and client in a browser, emulate a WebSocketServer in the browser, and replace the WebSocket api with an emulated WebSocket that communicates with emulated WebSocketServer.
[ "To", "be", "able", "to", "test", "both", "server", "and", "client", "in", "a", "browser", "emulate", "a", "WebSocketServer", "in", "the", "browser", "and", "replace", "the", "WebSocket", "api", "with", "an", "emulated", "WebSocket", "that", "communicates", ...
80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8
https://github.com/dfahlander/Dexie.js/blob/80b53e4df4ec82e5902d12eb8f3db5369b9bd6a8/samples/remote-sync/websocket/websocketserver-shim.js#L15-L58
train
bda-research/node-crawler
lib/crawler.js
getCharset
function getCharset(str){ var charset = (str && str.match(/charset=['"]?([\w.-]+)/i) || [0, null])[1]; return charset && charset.replace(/:\d{4}$|[^0-9a-z]/g, '') == 'gb2312' ? 'gbk' : charset; }
javascript
function getCharset(str){ var charset = (str && str.match(/charset=['"]?([\w.-]+)/i) || [0, null])[1]; return charset && charset.replace(/:\d{4}$|[^0-9a-z]/g, '') == 'gb2312' ? 'gbk' : charset; }
[ "function", "getCharset", "(", "str", ")", "{", "var", "charset", "=", "(", "str", "&&", "str", ".", "match", "(", "/", "charset=['\"]?([\\w.-]+)", "/", "i", ")", "||", "[", "0", ",", "null", "]", ")", "[", "1", "]", ";", "return", "charset", "&&",...
Browsers treat gb2312 as gbk, but iconv-lite not. Replace gb2312 with gbk, in order to parse the pages which say gb2312 but actually are gbk.
[ "Browsers", "treat", "gb2312", "as", "gbk", "but", "iconv", "-", "lite", "not", ".", "Replace", "gb2312", "with", "gbk", "in", "order", "to", "parse", "the", "pages", "which", "say", "gb2312", "but", "actually", "are", "gbk", "." ]
9b77f9a8fa995cb431c7cbf5c033c0856583746b
https://github.com/bda-research/node-crawler/blob/9b77f9a8fa995cb431c7cbf5c033c0856583746b/lib/crawler.js#L439-L442
train
marmelab/gremlins.js
examples/touch/hammer.js
extend
function extend(dest, src, merge) { for(var key in src) { if(dest[key] !== undefined && merge) { continue; } dest[key] = src[key]; } return dest; }
javascript
function extend(dest, src, merge) { for(var key in src) { if(dest[key] !== undefined && merge) { continue; } dest[key] = src[key]; } return dest; }
[ "function", "extend", "(", "dest", ",", "src", ",", "merge", ")", "{", "for", "(", "var", "key", "in", "src", ")", "{", "if", "(", "dest", "[", "key", "]", "!==", "undefined", "&&", "merge", ")", "{", "continue", ";", "}", "dest", "[", "key", "...
extend method, also used for cloning when dest is an empty object @param {Object} dest @param {Object} src @parm {Boolean} merge do a merge @returns {Object} dest
[ "extend", "method", "also", "used", "for", "cloning", "when", "dest", "is", "an", "empty", "object" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L126-L134
train
marmelab/gremlins.js
examples/touch/hammer.js
getVelocity
function getVelocity(delta_time, delta_x, delta_y) { return { x: Math.abs(delta_x / delta_time) || 0, y: Math.abs(delta_y / delta_time) || 0 }; }
javascript
function getVelocity(delta_time, delta_x, delta_y) { return { x: Math.abs(delta_x / delta_time) || 0, y: Math.abs(delta_y / delta_time) || 0 }; }
[ "function", "getVelocity", "(", "delta_time", ",", "delta_x", ",", "delta_y", ")", "{", "return", "{", "x", ":", "Math", ".", "abs", "(", "delta_x", "/", "delta_time", ")", "||", "0", ",", "y", ":", "Math", ".", "abs", "(", "delta_y", "/", "delta_tim...
calculate the velocity between two points @param {Number} delta_time @param {Number} delta_x @param {Number} delta_y @returns {Object} velocity
[ "calculate", "the", "velocity", "between", "two", "points" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L231-L236
train
marmelab/gremlins.js
examples/touch/hammer.js
toggleDefaultBehavior
function toggleDefaultBehavior(element, css_props, toggle) { if(!css_props || !element || !element.style) { return; } // with css properties for modern browsers Utils.each(['webkit', 'moz', 'Moz', 'ms', 'o', ''], function setStyle(vendor) { Utils.each(css_props, function(value, prop) { ...
javascript
function toggleDefaultBehavior(element, css_props, toggle) { if(!css_props || !element || !element.style) { return; } // with css properties for modern browsers Utils.each(['webkit', 'moz', 'Moz', 'ms', 'o', ''], function setStyle(vendor) { Utils.each(css_props, function(value, prop) { ...
[ "function", "toggleDefaultBehavior", "(", "element", ",", "css_props", ",", "toggle", ")", "{", "if", "(", "!", "css_props", "||", "!", "element", "||", "!", "element", ".", "style", ")", "{", "return", ";", "}", "// with css properties for modern browsers", "...
toggle browser default behavior with css props @param {HtmlElement} element @param {Object} css_props @param {Boolean} toggle
[ "toggle", "browser", "default", "behavior", "with", "css", "props" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L328-L357
train
marmelab/gremlins.js
examples/touch/hammer.js
dispose
function dispose() { var i, eh; // undo all changes made by stop_browser_behavior if(this.options.stop_browser_behavior) { Utils.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, true); } // unbind all custom event handlers for(i=-1; (eh=this.eventHandlers[++i]);) {...
javascript
function dispose() { var i, eh; // undo all changes made by stop_browser_behavior if(this.options.stop_browser_behavior) { Utils.toggleDefaultBehavior(this.element, this.options.stop_browser_behavior, true); } // unbind all custom event handlers for(i=-1; (eh=this.eventHandlers[++i]);) {...
[ "function", "dispose", "(", ")", "{", "var", "i", ",", "eh", ";", "// undo all changes made by stop_browser_behavior", "if", "(", "this", ".", "options", ".", "stop_browser_behavior", ")", "{", "Utils", ".", "toggleDefaultBehavior", "(", "this", ".", "element", ...
dispose this hammer instance @returns {Hammer.Instance}
[ "dispose", "this", "hammer", "instance" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L490-L508
train
marmelab/gremlins.js
examples/touch/hammer.js
collectEventData
function collectEventData(element, eventType, touches, ev) { // find out pointerType var pointerType = POINTER_TOUCH; if(Utils.inStr(ev.type, 'mouse') || PointerEvent.matchType(POINTER_MOUSE, ev)) { pointerType = POINTER_MOUSE; } return { center : Utils.getCenter(touches), tim...
javascript
function collectEventData(element, eventType, touches, ev) { // find out pointerType var pointerType = POINTER_TOUCH; if(Utils.inStr(ev.type, 'mouse') || PointerEvent.matchType(POINTER_MOUSE, ev)) { pointerType = POINTER_MOUSE; } return { center : Utils.getCenter(touches), tim...
[ "function", "collectEventData", "(", "element", ",", "eventType", ",", "touches", ",", "ev", ")", "{", "// find out pointerType", "var", "pointerType", "=", "POINTER_TOUCH", ";", "if", "(", "Utils", ".", "inStr", "(", "ev", ".", "type", ",", "'mouse'", ")", ...
collect event data for Hammer js @param {HTMLElement} element @param {String} eventType like EVENT_MOVE @param {Object} eventData
[ "collect", "event", "data", "for", "Hammer", "js" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L726-L768
train
marmelab/gremlins.js
examples/touch/hammer.js
getInterimData
function getInterimData(ev) { var lastEvent = this.current.lastEvent , angle , direction; // end events (e.g. dragend) don't have useful values for interimDirection & interimAngle // because the previous event has exactly the same coordinates // so for end events, take the previous values o...
javascript
function getInterimData(ev) { var lastEvent = this.current.lastEvent , angle , direction; // end events (e.g. dragend) don't have useful values for interimDirection & interimAngle // because the previous event has exactly the same coordinates // so for end events, take the previous values o...
[ "function", "getInterimData", "(", "ev", ")", "{", "var", "lastEvent", "=", "this", ".", "current", ".", "lastEvent", ",", "angle", ",", "direction", ";", "// end events (e.g. dragend) don't have useful values for interimDirection & interimAngle", "// because the previous eve...
calculate interim angle and direction @param {Object} ev
[ "calculate", "interim", "angle", "and", "direction" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/hammer.js#L987-L1007
train
marmelab/gremlins.js
examples/touch/main.js
round
function round(float, digits) { if(digits == null) { return Math.round(float); } var round = 10 * digits; return Math.round(float * round) / round; }
javascript
function round(float, digits) { if(digits == null) { return Math.round(float); } var round = 10 * digits; return Math.round(float * round) / round; }
[ "function", "round", "(", "float", ",", "digits", ")", "{", "if", "(", "digits", "==", "null", ")", "{", "return", "Math", ".", "round", "(", "float", ")", ";", "}", "var", "round", "=", "10", "*", "digits", ";", "return", "Math", ".", "round", "...
round to 1 digit @param float @param [digits] @returns {number}
[ "round", "to", "1", "digit" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/main.js#L35-L41
train
marmelab/gremlins.js
examples/touch/main.js
logHammerEvent
function logHammerEvent(ev) { if(!ev.gesture) { return; } // store last event, that should might match the gremlin if(ev.gesture.eventType == 'end') { testLogger.lastEvent = ev; } // highlight gesture var event_el = getLogElement('gesture', ev.type); event_el.className = 'active'; for(var i =...
javascript
function logHammerEvent(ev) { if(!ev.gesture) { return; } // store last event, that should might match the gremlin if(ev.gesture.eventType == 'end') { testLogger.lastEvent = ev; } // highlight gesture var event_el = getLogElement('gesture', ev.type); event_el.className = 'active'; for(var i =...
[ "function", "logHammerEvent", "(", "ev", ")", "{", "if", "(", "!", "ev", ".", "gesture", ")", "{", "return", ";", "}", "// store last event, that should might match the gremlin", "if", "(", "ev", ".", "gesture", ".", "eventType", "==", "'end'", ")", "{", "te...
highlight the triggered event and update the log values @param ev
[ "highlight", "the", "triggered", "event", "and", "update", "the", "log", "values" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/touch/main.js#L48-L81
train
marmelab/gremlins.js
examples/TodoMVC/bower_components/backbone/backbone.js
function(attrs, options) { if (!options.validate || !this.validate) return true; attrs = _.extend({}, this.attributes, attrs); var error = this.validationError = this.validate(attrs, options) || null; if (!error) return true; this.trigger('invalid', this, error, _.extend(options, {validati...
javascript
function(attrs, options) { if (!options.validate || !this.validate) return true; attrs = _.extend({}, this.attributes, attrs); var error = this.validationError = this.validate(attrs, options) || null; if (!error) return true; this.trigger('invalid', this, error, _.extend(options, {validati...
[ "function", "(", "attrs", ",", "options", ")", "{", "if", "(", "!", "options", ".", "validate", "||", "!", "this", ".", "validate", ")", "return", "true", ";", "attrs", "=", "_", ".", "extend", "(", "{", "}", ",", "this", ".", "attributes", ",", ...
Run validation against the next complete set of model attributes, returning `true` if all is well. Otherwise, fire an `"invalid"` event.
[ "Run", "validation", "against", "the", "next", "complete", "set", "of", "model", "attributes", "returning", "true", "if", "all", "is", "well", ".", "Otherwise", "fire", "an", "invalid", "event", "." ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/TodoMVC/bower_components/backbone/backbone.js#L559-L566
train
marmelab/gremlins.js
examples/TodoMVC/bower_components/backbone/backbone.js
function(models, options) { return this.set(models, _.extend({merge: false}, options, addOptions)); }
javascript
function(models, options) { return this.set(models, _.extend({merge: false}, options, addOptions)); }
[ "function", "(", "models", ",", "options", ")", "{", "return", "this", ".", "set", "(", "models", ",", "_", ".", "extend", "(", "{", "merge", ":", "false", "}", ",", "options", ",", "addOptions", ")", ")", ";", "}" ]
Add a model, or list of models to the set.
[ "Add", "a", "model", "or", "list", "of", "models", "to", "the", "set", "." ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/examples/TodoMVC/bower_components/backbone/backbone.js#L631-L633
train
marmelab/gremlins.js
src/mogwais/gizmo.js
incrementNbErrors
function incrementNbErrors() { nbErrors++; if (nbErrors == config.maxErrors) { horde.stop(); if (!config.logger) return; window.setTimeout(function() { // display the mogwai error after the caught error ...
javascript
function incrementNbErrors() { nbErrors++; if (nbErrors == config.maxErrors) { horde.stop(); if (!config.logger) return; window.setTimeout(function() { // display the mogwai error after the caught error ...
[ "function", "incrementNbErrors", "(", ")", "{", "nbErrors", "++", ";", "if", "(", "nbErrors", "==", "config", ".", "maxErrors", ")", "{", "horde", ".", "stop", "(", ")", ";", "if", "(", "!", "config", ".", "logger", ")", "return", ";", "window", ".",...
this is exceptional - don't use 'this' for mogwais in general
[ "this", "is", "exceptional", "-", "don", "t", "use", "this", "for", "mogwais", "in", "general" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/mogwais/gizmo.js#L45-L55
train
marmelab/gremlins.js
src/utils/executeInSeries.js
executeInSeries
function executeInSeries(callbacks, args, context, done) { var nbArguments = args.length; callbacks = callbacks.slice(0); // clone the array to avoid modifying the original var iterator = function(callbacks, args) { if (!callbacks.length) { return typeof done === 'fu...
javascript
function executeInSeries(callbacks, args, context, done) { var nbArguments = args.length; callbacks = callbacks.slice(0); // clone the array to avoid modifying the original var iterator = function(callbacks, args) { if (!callbacks.length) { return typeof done === 'fu...
[ "function", "executeInSeries", "(", "callbacks", ",", "args", ",", "context", ",", "done", ")", "{", "var", "nbArguments", "=", "args", ".", "length", ";", "callbacks", "=", "callbacks", ".", "slice", "(", "0", ")", ";", "// clone the array to avoid modifying ...
Execute a list of functions one after the other. Functions can be asynchronous or asynchronous, they will always be executed in the order of the list. @param {Function[]} callbacks - The functions to execute @param {Array} args - The arguments passed to each function @param {Object|null} context - The object the func...
[ "Execute", "a", "list", "of", "functions", "one", "after", "the", "other", "." ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/utils/executeInSeries.js#L15-L38
train
marmelab/gremlins.js
src/utils/executeInSeries.js
function(callbacks, args) { if (!callbacks.length) { return typeof done === 'function' ? done() : true; } var callback = callbacks.shift(); callback.apply(context, args); // Is the callback synchronous ? if (callback.length === nb...
javascript
function(callbacks, args) { if (!callbacks.length) { return typeof done === 'function' ? done() : true; } var callback = callbacks.shift(); callback.apply(context, args); // Is the callback synchronous ? if (callback.length === nb...
[ "function", "(", "callbacks", ",", "args", ")", "{", "if", "(", "!", "callbacks", ".", "length", ")", "{", "return", "typeof", "done", "===", "'function'", "?", "done", "(", ")", ":", "true", ";", "}", "var", "callback", "=", "callbacks", ".", "shift...
clone the array to avoid modifying the original
[ "clone", "the", "array", "to", "avoid", "modifying", "the", "original" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/utils/executeInSeries.js#L19-L31
train
marmelab/gremlins.js
src/vendor/chance.js
initOptions
function initOptions(options, defaults) { options || (options = {}); if (!defaults) { return options; } for (var i in defaults) { if (typeof options[i] === 'undefined') { options[i] = defaults[i]; } } return options; ...
javascript
function initOptions(options, defaults) { options || (options = {}); if (!defaults) { return options; } for (var i in defaults) { if (typeof options[i] === 'undefined') { options[i] = defaults[i]; } } return options; ...
[ "function", "initOptions", "(", "options", ",", "defaults", ")", "{", "options", "||", "(", "options", "=", "{", "}", ")", ";", "if", "(", "!", "defaults", ")", "{", "return", "options", ";", "}", "for", "(", "var", "i", "in", "defaults", ")", "{",...
Random helper functions
[ "Random", "helper", "functions" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/vendor/chance.js#L37-L48
train
marmelab/gremlins.js
src/species/toucher.js
triggerTouch
function triggerTouch(touches, element, type) { var touchlist = [], event = document.createEvent('Event'); event.initEvent('touch' + type, true, true); touchlist.identifiedTouch = touchlist.item = function(index) { return this[index] || {}; ...
javascript
function triggerTouch(touches, element, type) { var touchlist = [], event = document.createEvent('Event'); event.initEvent('touch' + type, true, true); touchlist.identifiedTouch = touchlist.item = function(index) { return this[index] || {}; ...
[ "function", "triggerTouch", "(", "touches", ",", "element", ",", "type", ")", "{", "var", "touchlist", "=", "[", "]", ",", "event", "=", "document", ".", "createEvent", "(", "'Event'", ")", ";", "event", ".", "initEvent", "(", "'touch'", "+", "type", "...
trigger a touchevent @param touches @param element @param type
[ "trigger", "a", "touchevent" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/species/toucher.js#L147-L178
train
marmelab/gremlins.js
src/species/toucher.js
tap
function tap(position, element, done) { var touches = getTouches(position, 1); var gesture = { duration: config.randomizer.integer({ min: 20, max: 700 }) }; triggerTouch(touches, element, 'start'); setTimeout(function(...
javascript
function tap(position, element, done) { var touches = getTouches(position, 1); var gesture = { duration: config.randomizer.integer({ min: 20, max: 700 }) }; triggerTouch(touches, element, 'start'); setTimeout(function(...
[ "function", "tap", "(", "position", ",", "element", ",", "done", ")", "{", "var", "touches", "=", "getTouches", "(", "position", ",", "1", ")", ";", "var", "gesture", "=", "{", "duration", ":", "config", ".", "randomizer", ".", "integer", "(", "{", "...
tap, like a click event, only 1 touch could also be a slow tap, that could turn out to be a hold
[ "tap", "like", "a", "click", "event", "only", "1", "touch", "could", "also", "be", "a", "slow", "tap", "that", "could", "turn", "out", "to", "be", "a", "hold" ]
2735fa5253cbefcb8848ea40825a6426fc04c398
https://github.com/marmelab/gremlins.js/blob/2735fa5253cbefcb8848ea40825a6426fc04c398/src/species/toucher.js#L227-L239
train