id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
34,400
Lightstreamer/Lightstreamer-lib-node-adapter
lib/metadataprotocol.js
readTableInfo
function readTableInfo(tokens, skipSelector) { var tableInfo = {}; tableInfo.winIndex = protocol.decodeInteger(tokens[1]); tableInfo.pubModes = protocol.decodePubModes(tokens[3]); tableInfo.groupName = protocol.decodeString(tokens[5]); tableInfo.schemaName = protocol.decodeString(tokens[7]); tableInfo.firstItemIndex = protocol.decodeInteger(tokens[9]); tableInfo.lastItemIndex = protocol.decodeInteger(tokens[11]); if (!skipSelector) tableInfo.selector = protocol.decodeString(tokens[13]); return tableInfo; }
javascript
function readTableInfo(tokens, skipSelector) { var tableInfo = {}; tableInfo.winIndex = protocol.decodeInteger(tokens[1]); tableInfo.pubModes = protocol.decodePubModes(tokens[3]); tableInfo.groupName = protocol.decodeString(tokens[5]); tableInfo.schemaName = protocol.decodeString(tokens[7]); tableInfo.firstItemIndex = protocol.decodeInteger(tokens[9]); tableInfo.lastItemIndex = protocol.decodeInteger(tokens[11]); if (!skipSelector) tableInfo.selector = protocol.decodeString(tokens[13]); return tableInfo; }
[ "function", "readTableInfo", "(", "tokens", ",", "skipSelector", ")", "{", "var", "tableInfo", "=", "{", "}", ";", "tableInfo", ".", "winIndex", "=", "protocol", ".", "decodeInteger", "(", "tokens", "[", "1", "]", ")", ";", "tableInfo", ".", "pubModes", ...
Decode a table info part of a notify tables or notify MPN subscription request. @param {Array} tokens the table info part of the message already tokenized @return {Object} the decoded table info @private
[ "Decode", "a", "table", "info", "part", "of", "a", "notify", "tables", "or", "notify", "MPN", "subscription", "request", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L812-L823
34,401
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprotocol.js
function(requestId, exceptionMessage, exceptionType) { if (exceptionType === "data") { return protocol.implodeMessage(requestId, dataMethods.DATA_INIT, exceptions.DATA, protocol.encodeString(exceptionMessage)); } else { return protocol.implodeMessage(requestId, dataMethods.DATA_INIT, exceptions.GENERIC, protocol.encodeString(exceptionMessage)); } }
javascript
function(requestId, exceptionMessage, exceptionType) { if (exceptionType === "data") { return protocol.implodeMessage(requestId, dataMethods.DATA_INIT, exceptions.DATA, protocol.encodeString(exceptionMessage)); } else { return protocol.implodeMessage(requestId, dataMethods.DATA_INIT, exceptions.GENERIC, protocol.encodeString(exceptionMessage)); } }
[ "function", "(", "requestId", ",", "exceptionMessage", ",", "exceptionType", ")", "{", "if", "(", "exceptionType", "===", "\"data\"", ")", "{", "return", "protocol", ".", "implodeMessage", "(", "requestId", ",", "dataMethods", ".", "DATA_INIT", ",", "exceptions"...
Encodes an unsuccessful initialization reply. @param {String} requestId the originating request id @param {String} exceptionMessage the exception message @param {String} [exceptionType] the exception type. Allowed values: data @return {String} the encoded message @private
[ "Encodes", "an", "unsuccessful", "initialization", "reply", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprotocol.js#L45-L53
34,402
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprotocol.js
function(requestId, exceptionMessage, exceptionType) { if (exceptionType === "subscription") { return protocol.implodeMessage(requestId, dataMethods.UNSUBSCRIBE, exceptions.SUBSCRIPTION, protocol.encodeString(exceptionMessage)); } else { return protocol.implodeMessage(requestId, dataMethods.UNSUBSCRIBE, exceptions.GENERIC, protocol.encodeString(exceptionMessage)); } }
javascript
function(requestId, exceptionMessage, exceptionType) { if (exceptionType === "subscription") { return protocol.implodeMessage(requestId, dataMethods.UNSUBSCRIBE, exceptions.SUBSCRIPTION, protocol.encodeString(exceptionMessage)); } else { return protocol.implodeMessage(requestId, dataMethods.UNSUBSCRIBE, exceptions.GENERIC, protocol.encodeString(exceptionMessage)); } }
[ "function", "(", "requestId", ",", "exceptionMessage", ",", "exceptionType", ")", "{", "if", "(", "exceptionType", "===", "\"subscription\"", ")", "{", "return", "protocol", ".", "implodeMessage", "(", "requestId", ",", "dataMethods", ".", "UNSUBSCRIBE", ",", "e...
Encodes an unsuccessful unsubscribe reply. @param {String} requestId the originating request id @param {String} exceptionMessage the exception message @param {String} [exceptionType] the exception type. Allowed values: subscription @return {String} the encoded message @private
[ "Encodes", "an", "unsuccessful", "unsubscribe", "reply", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprotocol.js#L101-L109
34,403
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprotocol.js
function(exception){ return protocol.implodeMessage(protocol.timestamp(), dataMethods.FAILURE, exceptions.GENERIC, protocol.encodeString(exception)); }
javascript
function(exception){ return protocol.implodeMessage(protocol.timestamp(), dataMethods.FAILURE, exceptions.GENERIC, protocol.encodeString(exception)); }
[ "function", "(", "exception", ")", "{", "return", "protocol", ".", "implodeMessage", "(", "protocol", ".", "timestamp", "(", ")", ",", "dataMethods", ".", "FAILURE", ",", "exceptions", ".", "GENERIC", ",", "protocol", ".", "encodeString", "(", "exception", "...
Encodes an failure message to be sent to the proxy. @param {String} exception error message @return {String} the encoded message @private
[ "Encodes", "an", "failure", "message", "to", "be", "sent", "to", "the", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprotocol.js#L117-L120
34,404
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprotocol.js
function(requestId, itemName) { return protocol.implodeMessage(protocol.timestamp(), dataMethods.END_OF_SNAPSHOT, types.STRING, protocol.encodeString(itemName), types.STRING, requestId); }
javascript
function(requestId, itemName) { return protocol.implodeMessage(protocol.timestamp(), dataMethods.END_OF_SNAPSHOT, types.STRING, protocol.encodeString(itemName), types.STRING, requestId); }
[ "function", "(", "requestId", ",", "itemName", ")", "{", "return", "protocol", ".", "implodeMessage", "(", "protocol", ".", "timestamp", "(", ")", ",", "dataMethods", ".", "END_OF_SNAPSHOT", ",", "types", ".", "STRING", ",", "protocol", ".", "encodeString", ...
Encodes an end of snapshot message for a particular item to be sent to the proxy. @param {String} requestId the originating request id @param {String} itemName the item name @return {String} the encoded message @private
[ "Encodes", "an", "end", "of", "snapshot", "message", "for", "a", "particular", "item", "to", "be", "sent", "to", "the", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprotocol.js#L129-L133
34,405
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprotocol.js
function(requestId, itemName, isSnapshot, data) { return protocol.implodeMessage(protocol.timestamp(), dataMethods.UPDATE_BY_MAP, types.STRING, protocol.encodeString(itemName), types.STRING, requestId, types.BOOLEAN, protocol.encodeBoolean(isSnapshot), protocol.implodeData(data)); }
javascript
function(requestId, itemName, isSnapshot, data) { return protocol.implodeMessage(protocol.timestamp(), dataMethods.UPDATE_BY_MAP, types.STRING, protocol.encodeString(itemName), types.STRING, requestId, types.BOOLEAN, protocol.encodeBoolean(isSnapshot), protocol.implodeData(data)); }
[ "function", "(", "requestId", ",", "itemName", ",", "isSnapshot", ",", "data", ")", "{", "return", "protocol", ".", "implodeMessage", "(", "protocol", ".", "timestamp", "(", ")", ",", "dataMethods", ".", "UPDATE_BY_MAP", ",", "types", ".", "STRING", ",", "...
Encodes an update for a particular item to be sent to the proxy. @param {String} requestId the originating request id @param {String} itemName the item name @param {Boolean} isSnapshot if the data is a complete snapshot @param {Object} data a flat associative array built using simple primitive data types that represents the update record @return {String} the encoded message @private
[ "Encodes", "an", "update", "for", "a", "particular", "item", "to", "be", "sent", "to", "the", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprotocol.js#L158-L164
34,406
jiahaog/Revenant
lib/navigation.js
openPage
function openPage(url, callback, options) { // set up default values const MAX_RETRIES = 5; if (options) { var maxAttempts = options['retries'] || MAX_RETRIES; var flags = options['flags']; } else { maxAttempts = MAX_RETRIES; flags = []; } // finds an unused port so that if we queue up multiple phantom instances sequentially with async // the exception EADDRINUSE will not be triggered because phantom runs on a separate process (I think) findUnusedPort(function (port) { // creates new Phantom instance var phantomOptions = { onStdout: function (data) { // uncomment this to print the phantom stdout to the console //return console.log('PHANTOM STDOUT: ' + data); }, port: port }; if (helpers.platformIsWindows()) { phantomOptions['dnodeOpts'] = { weak: false } } var doAfterCreate = function(ph) { // create a new page ph.createPage(function (page) { // sets a user agent // somehow this causes the stdout for the browser to be printed to the console, so we temporarily disable // setting of the user agent. page.set('settings.userAgent', USER_AGENT); // SOMEHOW commenting this out stops the random phantomjs assertion error // set up the log to print errors //page.set('onResourceError', function (resourceError) { // page.set('errorReason', resourceError); //}); async.retry( maxAttempts, function (callback) { page.open(url, function (status) { if (status === "fail") { page.get('errorReason', function (errorReason) { if (errorReason) { var errorReasonString = JSON.stringify(errorReason); } else { errorReasonString = ''; } callback('Failed to open: ' + url + ' REASON: ' + errorReasonString, [undefined, ph]); }); } else { // success // check if url is valid here, so that the phantom process and page is returned if (!url) { callback('Url is not valid', [page, ph]); return; } // success, execute callback callback(null, [page, ph]); } }); }, function (error, results) { callback(error, results[0], results[1]); } ) }); }; var phantomParams = flags.concat([phantomOptions, doAfterCreate]); phantom.create.apply(this, phantomParams); }); }
javascript
function openPage(url, callback, options) { // set up default values const MAX_RETRIES = 5; if (options) { var maxAttempts = options['retries'] || MAX_RETRIES; var flags = options['flags']; } else { maxAttempts = MAX_RETRIES; flags = []; } // finds an unused port so that if we queue up multiple phantom instances sequentially with async // the exception EADDRINUSE will not be triggered because phantom runs on a separate process (I think) findUnusedPort(function (port) { // creates new Phantom instance var phantomOptions = { onStdout: function (data) { // uncomment this to print the phantom stdout to the console //return console.log('PHANTOM STDOUT: ' + data); }, port: port }; if (helpers.platformIsWindows()) { phantomOptions['dnodeOpts'] = { weak: false } } var doAfterCreate = function(ph) { // create a new page ph.createPage(function (page) { // sets a user agent // somehow this causes the stdout for the browser to be printed to the console, so we temporarily disable // setting of the user agent. page.set('settings.userAgent', USER_AGENT); // SOMEHOW commenting this out stops the random phantomjs assertion error // set up the log to print errors //page.set('onResourceError', function (resourceError) { // page.set('errorReason', resourceError); //}); async.retry( maxAttempts, function (callback) { page.open(url, function (status) { if (status === "fail") { page.get('errorReason', function (errorReason) { if (errorReason) { var errorReasonString = JSON.stringify(errorReason); } else { errorReasonString = ''; } callback('Failed to open: ' + url + ' REASON: ' + errorReasonString, [undefined, ph]); }); } else { // success // check if url is valid here, so that the phantom process and page is returned if (!url) { callback('Url is not valid', [page, ph]); return; } // success, execute callback callback(null, [page, ph]); } }); }, function (error, results) { callback(error, results[0], results[1]); } ) }); }; var phantomParams = flags.concat([phantomOptions, doAfterCreate]); phantom.create.apply(this, phantomParams); }); }
[ "function", "openPage", "(", "url", ",", "callback", ",", "options", ")", "{", "// set up default values", "const", "MAX_RETRIES", "=", "5", ";", "if", "(", "options", ")", "{", "var", "maxAttempts", "=", "options", "[", "'retries'", "]", "||", "MAX_RETRIES"...
Callback that holds a result @callback pageResultCallback @param error @param page @param ph @param [result] Persistently opens a page until the number of max retries have been reached @param {string} url @param {pageCallback} callback what to do on the page. The status of the page open will be passed in @param {Object} [options] Options to configure how the page will be opened @param {Array} [options.flags] Flags which will be passed to the PhantomJS process @param {int} [options.retries] Number of times PhantomJS will try to open a page
[ "Callback", "that", "holds", "a", "result" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/navigation.js#L51-L139
34,407
jiahaog/Revenant
lib/navigation.js
navigateToUrl
function navigateToUrl(page, ph, url, callback) { var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(function (url) { try { window.location.href = url; } catch (exception) { return exception; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error); if (error) { callback(error); return; } callback(); }, url); }, function (callback) { checks.pageHasChanged(page, oldUrl, function (error) { callback(error); }); } ], function (error) { callback(error, page, ph); }); }
javascript
function navigateToUrl(page, ph, url, callback) { var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(function (url) { try { window.location.href = url; } catch (exception) { return exception; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error); if (error) { callback(error); return; } callback(); }, url); }, function (callback) { checks.pageHasChanged(page, oldUrl, function (error) { callback(error); }); } ], function (error) { callback(error, page, ph); }); }
[ "function", "navigateToUrl", "(", "page", ",", "ph", ",", "url", ",", "callback", ")", "{", "var", "oldUrl", ";", "async", ".", "waterfall", "(", "[", "function", "(", "callback", ")", "{", "page", ".", "get", "(", "'url'", ",", "function", "(", "url...
Navigates to another url using the same page @param page @param ph @param {string} url @param {pageCallback} callback
[ "Navigates", "to", "another", "url", "using", "the", "same", "page" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/navigation.js#L148-L185
34,408
thinkjs/think-cache
cache.js
thinkCache
function thinkCache(name, value, config) { assert(name && helper.isString(name), 'cache.name must be a string'); if (config) { config = helper.parseAdapterConfig(this.config('cache'), config); } else { config = helper.parseAdapterConfig(this.config('cache')); } const Handle = config.handle; assert(helper.isFunction(Handle), 'cache.handle must be a function'); delete config.handle; const instance = new Handle(config); // delete cache if (value === null) { return Promise.resolve(instance.delete(name)); } // get cache if (value === undefined) { return debounceInstance.debounce(name, () => { return instance.get(name); }); } // get cache when value is function if (helper.isFunction(value)) { return debounceInstance.debounce(name, () => { let cacheData; return instance.get(name).then(data => { if (data === undefined) { return value(name); } cacheData = data; }).then(data => { if (data !== undefined) { cacheData = data; return instance.set(name, data); } }).then(() => { return cacheData; }); }); } // set cache return Promise.resolve(instance.set(name, value)); }
javascript
function thinkCache(name, value, config) { assert(name && helper.isString(name), 'cache.name must be a string'); if (config) { config = helper.parseAdapterConfig(this.config('cache'), config); } else { config = helper.parseAdapterConfig(this.config('cache')); } const Handle = config.handle; assert(helper.isFunction(Handle), 'cache.handle must be a function'); delete config.handle; const instance = new Handle(config); // delete cache if (value === null) { return Promise.resolve(instance.delete(name)); } // get cache if (value === undefined) { return debounceInstance.debounce(name, () => { return instance.get(name); }); } // get cache when value is function if (helper.isFunction(value)) { return debounceInstance.debounce(name, () => { let cacheData; return instance.get(name).then(data => { if (data === undefined) { return value(name); } cacheData = data; }).then(data => { if (data !== undefined) { cacheData = data; return instance.set(name, data); } }).then(() => { return cacheData; }); }); } // set cache return Promise.resolve(instance.set(name, value)); }
[ "function", "thinkCache", "(", "name", ",", "value", ",", "config", ")", "{", "assert", "(", "name", "&&", "helper", ".", "isString", "(", "name", ")", ",", "'cache.name must be a string'", ")", ";", "if", "(", "config", ")", "{", "config", "=", "helper"...
cache manage can not be defined a arrow function, because has `this` in it. @param {String} name @param {Mixed} value @param {String|Object} config
[ "cache", "manage", "can", "not", "be", "defined", "a", "arrow", "function", "because", "has", "this", "in", "it", "." ]
a4a86ead9af0e927500e2a5435da3a5ef49993a3
https://github.com/thinkjs/think-cache/blob/a4a86ead9af0e927500e2a5435da3a5ef49993a3/cache.js#L14-L57
34,409
GeekyAnts/reazy
dist/reazy-generator/generators/web-app/index.js
findCreateReactApp
function findCreateReactApp() { var done = this.async(); var spinner = ora('Finding create-react-app').start(); checkCommmand('create-react-app', function (isInstalled) { if (!isInstalled) { spinner.fail('Missing create-react-app - \'npm install -g create-react-app\''); process.exit(1); } spinner.succeed('Found create-react-app'); done(); }); }
javascript
function findCreateReactApp() { var done = this.async(); var spinner = ora('Finding create-react-app').start(); checkCommmand('create-react-app', function (isInstalled) { if (!isInstalled) { spinner.fail('Missing create-react-app - \'npm install -g create-react-app\''); process.exit(1); } spinner.succeed('Found create-react-app'); done(); }); }
[ "function", "findCreateReactApp", "(", ")", "{", "var", "done", "=", "this", ".", "async", "(", ")", ";", "var", "spinner", "=", "ora", "(", "'Finding create-react-app'", ")", ".", "start", "(", ")", ";", "checkCommmand", "(", "'create-react-app'", ",", "f...
Check for react-native.
[ "Check", "for", "react", "-", "native", "." ]
c1e2da22645a8c12902e5e39197382a72ad00af7
https://github.com/GeekyAnts/reazy/blob/c1e2da22645a8c12902e5e39197382a72ad00af7/dist/reazy-generator/generators/web-app/index.js#L51-L64
34,410
cam-inc/esr
index.js
resolvePathname
function resolvePathname(to) { var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var toParts = to && to.split('/') || []; var fromParts = from && from.split('/') || []; var isToAbs = to && isAbsolute(to); var isFromAbs = from && isAbsolute(from); var mustEndAbs = isToAbs || isFromAbs; if (to && isAbsolute(to)) { // to is absolute fromParts = toParts; } else if (toParts.length) { // to is relative, drop the filename fromParts.pop(); fromParts = fromParts.concat(toParts); } if (!fromParts.length) { return '/'; } var hasTrailingSlash = void 0; if (fromParts.length) { var last = fromParts[fromParts.length - 1]; hasTrailingSlash = last === '.' || last === '..' || last === ''; } else { hasTrailingSlash = false; } var up = 0; for (var i = fromParts.length; i >= 0; i--) { var part = fromParts[i]; if (part === '.') { spliceOne(fromParts, i); } else if (part === '..') { spliceOne(fromParts, i); up++; } else if (up) { spliceOne(fromParts, i); up--; } } if (!mustEndAbs) { for (; up--; up) { fromParts.unshift('..'); } }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) { fromParts.unshift(''); } var result = fromParts.join('/'); if (hasTrailingSlash && result.substr(-1) !== '/') { result += '/'; } return result; }
javascript
function resolvePathname(to) { var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var toParts = to && to.split('/') || []; var fromParts = from && from.split('/') || []; var isToAbs = to && isAbsolute(to); var isFromAbs = from && isAbsolute(from); var mustEndAbs = isToAbs || isFromAbs; if (to && isAbsolute(to)) { // to is absolute fromParts = toParts; } else if (toParts.length) { // to is relative, drop the filename fromParts.pop(); fromParts = fromParts.concat(toParts); } if (!fromParts.length) { return '/'; } var hasTrailingSlash = void 0; if (fromParts.length) { var last = fromParts[fromParts.length - 1]; hasTrailingSlash = last === '.' || last === '..' || last === ''; } else { hasTrailingSlash = false; } var up = 0; for (var i = fromParts.length; i >= 0; i--) { var part = fromParts[i]; if (part === '.') { spliceOne(fromParts, i); } else if (part === '..') { spliceOne(fromParts, i); up++; } else if (up) { spliceOne(fromParts, i); up--; } } if (!mustEndAbs) { for (; up--; up) { fromParts.unshift('..'); } }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) { fromParts.unshift(''); } var result = fromParts.join('/'); if (hasTrailingSlash && result.substr(-1) !== '/') { result += '/'; } return result; }
[ "function", "resolvePathname", "(", "to", ")", "{", "var", "from", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "''", ";", "var", "toParts", "=", "to", "&&", ...
This implementation is based heavily on node's url.parse
[ "This", "implementation", "is", "based", "heavily", "on", "node", "s", "url", ".", "parse" ]
b7a6580f86736d667371dbbce3a5da072f543320
https://github.com/cam-inc/esr/blob/b7a6580f86736d667371dbbce3a5da072f543320/index.js#L808-L861
34,411
erha19/eslint-plugin-weex
lib/utils/casing.js
kebabCase
function kebabCase (str) { return str .replace(/([a-z])([A-Z])/g, match => match[0] + '-' + match[1]) .replace(invalidChars, '-') .toLowerCase() }
javascript
function kebabCase (str) { return str .replace(/([a-z])([A-Z])/g, match => match[0] + '-' + match[1]) .replace(invalidChars, '-') .toLowerCase() }
[ "function", "kebabCase", "(", "str", ")", "{", "return", "str", ".", "replace", "(", "/", "([a-z])([A-Z])", "/", "g", ",", "match", "=>", "match", "[", "0", "]", "+", "'-'", "+", "match", "[", "1", "]", ")", ".", "replace", "(", "invalidChars", ","...
Convert text to kebab-case @param {string} str Text to be converted @return {string}
[ "Convert", "text", "to", "kebab", "-", "case" ]
2f7db1812fe66a529c3dc68fd2d22e9e7962d51e
https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/casing.js#L10-L15
34,412
erha19/eslint-plugin-weex
lib/utils/casing.js
snakeCase
function snakeCase (str) { return str .replace(/([a-z])([A-Z])/g, match => match[0] + '_' + match[1]) .replace(invalidChars, '_') .toLowerCase() }
javascript
function snakeCase (str) { return str .replace(/([a-z])([A-Z])/g, match => match[0] + '_' + match[1]) .replace(invalidChars, '_') .toLowerCase() }
[ "function", "snakeCase", "(", "str", ")", "{", "return", "str", ".", "replace", "(", "/", "([a-z])([A-Z])", "/", "g", ",", "match", "=>", "match", "[", "0", "]", "+", "'_'", "+", "match", "[", "1", "]", ")", ".", "replace", "(", "invalidChars", ","...
Convert text to snake_case @param {string} str Text to be converted @return {string}
[ "Convert", "text", "to", "snake_case" ]
2f7db1812fe66a529c3dc68fd2d22e9e7962d51e
https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/casing.js#L22-L27
34,413
leandrob/wstrust-client
lib/wsTrustClient.js
parseRstr
function parseRstr(rstr){ var startOfAssertion = rstr.indexOf('<Assertion '); var endOfAssertion = rstr.indexOf('</Assertion>') + '</Assertion>'.length; var token = rstr.substring(startOfAssertion, endOfAssertion); return token; }
javascript
function parseRstr(rstr){ var startOfAssertion = rstr.indexOf('<Assertion '); var endOfAssertion = rstr.indexOf('</Assertion>') + '</Assertion>'.length; var token = rstr.substring(startOfAssertion, endOfAssertion); return token; }
[ "function", "parseRstr", "(", "rstr", ")", "{", "var", "startOfAssertion", "=", "rstr", ".", "indexOf", "(", "'<Assertion '", ")", ";", "var", "endOfAssertion", "=", "rstr", ".", "indexOf", "(", "'</Assertion>'", ")", "+", "'</Assertion>'", ".", "length", ";...
Parses the RequestSecurityTokenResponse
[ "Parses", "the", "RequestSecurityTokenResponse" ]
1885276aaf234c5747c043250ca3ef40927c3e9e
https://github.com/leandrob/wstrust-client/blob/1885276aaf234c5747c043250ca3ef40927c3e9e/lib/wsTrustClient.js#L57-L62
34,414
erha19/eslint-plugin-weex
lib/rules/vue/require-default-prop.js
propHasDefault
function propHasDefault (prop) { const propDefaultNode = prop.value.properties .find(p => p.key && p.key.name === 'default') return Boolean(propDefaultNode) }
javascript
function propHasDefault (prop) { const propDefaultNode = prop.value.properties .find(p => p.key && p.key.name === 'default') return Boolean(propDefaultNode) }
[ "function", "propHasDefault", "(", "prop", ")", "{", "const", "propDefaultNode", "=", "prop", ".", "value", ".", "properties", ".", "find", "(", "p", "=>", "p", ".", "key", "&&", "p", ".", "key", ".", "name", "===", "'default'", ")", "return", "Boolean...
Checks if the passed prop has a default value @param {Property} prop - Property AST node for a single prop @return {boolean}
[ "Checks", "if", "the", "passed", "prop", "has", "a", "default", "value" ]
2f7db1812fe66a529c3dc68fd2d22e9e7962d51e
https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/require-default-prop.js#L51-L56
34,415
reelyactive/hlc-server
web/apps/hello-infrastructure/js/hello-infrastructure.js
updateDisplayCount
function updateDisplayCount() { let visibleCount = 0; let totalCount = Object.keys(receivers).length; let trs = Array.from(tbody.getElementsByTagName('tr')); trs.forEach(function(tr) { if(tr.style.display === '') { visibleCount++; } }); displayCount.value = visibleCount + ' of ' + totalCount; }
javascript
function updateDisplayCount() { let visibleCount = 0; let totalCount = Object.keys(receivers).length; let trs = Array.from(tbody.getElementsByTagName('tr')); trs.forEach(function(tr) { if(tr.style.display === '') { visibleCount++; } }); displayCount.value = visibleCount + ' of ' + totalCount; }
[ "function", "updateDisplayCount", "(", ")", "{", "let", "visibleCount", "=", "0", ";", "let", "totalCount", "=", "Object", ".", "keys", "(", "receivers", ")", ".", "length", ";", "let", "trs", "=", "Array", ".", "from", "(", "tbody", ".", "getElementsByT...
Update display count
[ "Update", "display", "count" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-infrastructure/js/hello-infrastructure.js#L114-L125
34,416
reelyactive/hlc-server
web/apps/hello-infrastructure/js/hello-infrastructure.js
sortReceiversAndHighlight
function sortReceiversAndHighlight(receiverSignature) { let trs = Array.from(tbody.getElementsByTagName('tr')); let sortedFragment = document.createDocumentFragment(); trs.sort(sortFunction); trs.forEach(function(tr) { if(tr.id === receiverSignature) { tr.setAttribute('class', 'monospace animated-highlight-reelyactive'); } else { tr.setAttribute('class', 'monospace'); } sortedFragment.appendChild(tr); }); tbody.appendChild(sortedFragment); }
javascript
function sortReceiversAndHighlight(receiverSignature) { let trs = Array.from(tbody.getElementsByTagName('tr')); let sortedFragment = document.createDocumentFragment(); trs.sort(sortFunction); trs.forEach(function(tr) { if(tr.id === receiverSignature) { tr.setAttribute('class', 'monospace animated-highlight-reelyactive'); } else { tr.setAttribute('class', 'monospace'); } sortedFragment.appendChild(tr); }); tbody.appendChild(sortedFragment); }
[ "function", "sortReceiversAndHighlight", "(", "receiverSignature", ")", "{", "let", "trs", "=", "Array", ".", "from", "(", "tbody", ".", "getElementsByTagName", "(", "'tr'", ")", ")", ";", "let", "sortedFragment", "=", "document", ".", "createDocumentFragment", ...
Sort the receivers in the table, highlighting the given receiver
[ "Sort", "the", "receivers", "in", "the", "table", "highlighting", "the", "given", "receiver" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-infrastructure/js/hello-infrastructure.js#L128-L145
34,417
clux/modul8
examples/npm/output.js
function(ev, callback, context) { var calls = this._callbacks || (this._callbacks = {}); var list = calls[ev] || (calls[ev] = []); list.push([callback, context]); return this; }
javascript
function(ev, callback, context) { var calls = this._callbacks || (this._callbacks = {}); var list = calls[ev] || (calls[ev] = []); list.push([callback, context]); return this; }
[ "function", "(", "ev", ",", "callback", ",", "context", ")", "{", "var", "calls", "=", "this", ".", "_callbacks", "||", "(", "this", ".", "_callbacks", "=", "{", "}", ")", ";", "var", "list", "=", "calls", "[", "ev", "]", "||", "(", "calls", "[",...
Bind an event, specified by a string name, `ev`, to a `callback` function. Passing `"all"` will bind the callback to all events fired.
[ "Bind", "an", "event", "specified", "by", "a", "string", "name", "ev", "to", "a", "callback", "function", ".", "Passing", "all", "will", "bind", "the", "callback", "to", "all", "events", "fired", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L1601-L1606
34,418
clux/modul8
examples/npm/output.js
function(ev, callback) { var calls; if (!ev) { this._callbacks = {}; } else if (calls = this._callbacks) { if (!callback) { calls[ev] = []; } else { var list = calls[ev]; if (!list) return this; for (var i = 0, l = list.length; i < l; i++) { if (list[i] && callback === list[i][0]) { list[i] = null; break; } } } } return this; }
javascript
function(ev, callback) { var calls; if (!ev) { this._callbacks = {}; } else if (calls = this._callbacks) { if (!callback) { calls[ev] = []; } else { var list = calls[ev]; if (!list) return this; for (var i = 0, l = list.length; i < l; i++) { if (list[i] && callback === list[i][0]) { list[i] = null; break; } } } } return this; }
[ "function", "(", "ev", ",", "callback", ")", "{", "var", "calls", ";", "if", "(", "!", "ev", ")", "{", "this", ".", "_callbacks", "=", "{", "}", ";", "}", "else", "if", "(", "calls", "=", "this", ".", "_callbacks", ")", "{", "if", "(", "!", "...
Remove one or many callbacks. If `callback` is null, removes all callbacks for the event. If `ev` is null, removes all bound callbacks for all events.
[ "Remove", "one", "or", "many", "callbacks", ".", "If", "callback", "is", "null", "removes", "all", "callbacks", "for", "the", "event", ".", "If", "ev", "is", "null", "removes", "all", "bound", "callbacks", "for", "all", "events", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L1611-L1630
34,419
clux/modul8
examples/npm/output.js
function(eventName) { var list, calls, ev, callback, args; var both = 2; if (!(calls = this._callbacks)) return this; while (both--) { ev = both ? eventName : 'all'; if (list = calls[ev]) { for (var i = 0, l = list.length; i < l; i++) { if (!(callback = list[i])) { list.splice(i, 1); i--; l--; } else { args = both ? Array.prototype.slice.call(arguments, 1) : arguments; callback[0].apply(callback[1] || this, args); } } } } return this; }
javascript
function(eventName) { var list, calls, ev, callback, args; var both = 2; if (!(calls = this._callbacks)) return this; while (both--) { ev = both ? eventName : 'all'; if (list = calls[ev]) { for (var i = 0, l = list.length; i < l; i++) { if (!(callback = list[i])) { list.splice(i, 1); i--; l--; } else { args = both ? Array.prototype.slice.call(arguments, 1) : arguments; callback[0].apply(callback[1] || this, args); } } } } return this; }
[ "function", "(", "eventName", ")", "{", "var", "list", ",", "calls", ",", "ev", ",", "callback", ",", "args", ";", "var", "both", "=", "2", ";", "if", "(", "!", "(", "calls", "=", "this", ".", "_callbacks", ")", ")", "return", "this", ";", "while...
Trigger an event, firing all bound callbacks. Callbacks are passed the same arguments as `trigger` is, apart from the event name. Listening for `"all"` passes the true event name as the first argument.
[ "Trigger", "an", "event", "firing", "all", "bound", "callbacks", ".", "Callbacks", "are", "passed", "the", "same", "arguments", "as", "trigger", "is", "apart", "from", "the", "event", "name", ".", "Listening", "for", "all", "passes", "the", "true", "event", ...
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L1635-L1653
34,420
clux/modul8
examples/npm/output.js
function(options) { options || (options = {}); if (this.isNew()) return this.trigger('destroy', this, this.collection, options); var model = this; var success = options.success; options.success = function(resp) { model.trigger('destroy', model, model.collection, options); if (success) success(model, resp); }; options.error = wrapError(options.error, model, options); return (this.sync || Backbone.sync).call(this, 'delete', this, options); }
javascript
function(options) { options || (options = {}); if (this.isNew()) return this.trigger('destroy', this, this.collection, options); var model = this; var success = options.success; options.success = function(resp) { model.trigger('destroy', model, model.collection, options); if (success) success(model, resp); }; options.error = wrapError(options.error, model, options); return (this.sync || Backbone.sync).call(this, 'delete', this, options); }
[ "function", "(", "options", ")", "{", "options", "||", "(", "options", "=", "{", "}", ")", ";", "if", "(", "this", ".", "isNew", "(", ")", ")", "return", "this", ".", "trigger", "(", "'destroy'", ",", "this", ",", "this", ".", "collection", ",", ...
Destroy this model on the server if it was already persisted. Upon success, the model is removed from its collection, if it has one.
[ "Destroy", "this", "model", "on", "the", "server", "if", "it", "was", "already", "persisted", ".", "Upon", "success", "the", "model", "is", "removed", "from", "its", "collection", "if", "it", "has", "one", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L1840-L1851
34,421
clux/modul8
examples/npm/output.js
function(models, options) { if (_.isArray(models)) { for (var i = 0, l = models.length; i < l; i++) { this._remove(models[i], options); } } else { this._remove(models, options); } return this; }
javascript
function(models, options) { if (_.isArray(models)) { for (var i = 0, l = models.length; i < l; i++) { this._remove(models[i], options); } } else { this._remove(models, options); } return this; }
[ "function", "(", "models", ",", "options", ")", "{", "if", "(", "_", ".", "isArray", "(", "models", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "models", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "this...
Remove a model, or a list of models from the set. Pass silent to avoid firing the `removed` event for every model removed.
[ "Remove", "a", "model", "or", "a", "list", "of", "models", "from", "the", "set", ".", "Pass", "silent", "to", "avoid", "firing", "the", "removed", "event", "for", "every", "model", "removed", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L1988-L1997
34,422
clux/modul8
examples/npm/output.js
function(models, options) { models || (models = []); options || (options = {}); this.each(this._removeReference); this._reset(); this.add(models, {silent: true}); if (!options.silent) this.trigger('reset', this, options); return this; }
javascript
function(models, options) { models || (models = []); options || (options = {}); this.each(this._removeReference); this._reset(); this.add(models, {silent: true}); if (!options.silent) this.trigger('reset', this, options); return this; }
[ "function", "(", "models", ",", "options", ")", "{", "models", "||", "(", "models", "=", "[", "]", ")", ";", "options", "||", "(", "options", "=", "{", "}", ")", ";", "this", ".", "each", "(", "this", ".", "_removeReference", ")", ";", "this", "....
When you have more items than you want to add or remove individually, you can reset the entire set with a new list of models, without firing any `added` or `removed` events. Fires `reset` when finished.
[ "When", "you", "have", "more", "items", "than", "you", "want", "to", "add", "or", "remove", "individually", "you", "can", "reset", "the", "entire", "set", "with", "a", "new", "list", "of", "models", "without", "firing", "any", "added", "or", "removed", "...
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2033-L2041
34,423
clux/modul8
examples/npm/output.js
function(model, options) { var coll = this; options || (options = {}); model = this._prepareModel(model, options); if (!model) return false; var success = options.success; options.success = function(nextModel, resp, xhr) { coll.add(nextModel, options); if (success) success(nextModel, resp, xhr); }; model.save(null, options); return model; }
javascript
function(model, options) { var coll = this; options || (options = {}); model = this._prepareModel(model, options); if (!model) return false; var success = options.success; options.success = function(nextModel, resp, xhr) { coll.add(nextModel, options); if (success) success(nextModel, resp, xhr); }; model.save(null, options); return model; }
[ "function", "(", "model", ",", "options", ")", "{", "var", "coll", "=", "this", ";", "options", "||", "(", "options", "=", "{", "}", ")", ";", "model", "=", "this", ".", "_prepareModel", "(", "model", ",", "options", ")", ";", "if", "(", "!", "mo...
Create a new instance of a model in this collection. After the model has been created on the server, it will be added to the collection. Returns the model, or 'false' if validation on a new model fails.
[ "Create", "a", "new", "instance", "of", "a", "model", "in", "this", "collection", ".", "After", "the", "model", "has", "been", "created", "on", "the", "server", "it", "will", "be", "added", "to", "the", "collection", ".", "Returns", "the", "model", "or",...
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2061-L2073
34,424
clux/modul8
examples/npm/output.js
function(model, options) { if (!(model instanceof Backbone.Model)) { var attrs = model; model = new this.model(attrs, {collection: this}); if (model.validate && !model._performValidation(attrs, options)) model = false; } else if (!model.collection) { model.collection = this; } return model; }
javascript
function(model, options) { if (!(model instanceof Backbone.Model)) { var attrs = model; model = new this.model(attrs, {collection: this}); if (model.validate && !model._performValidation(attrs, options)) model = false; } else if (!model.collection) { model.collection = this; } return model; }
[ "function", "(", "model", ",", "options", ")", "{", "if", "(", "!", "(", "model", "instanceof", "Backbone", ".", "Model", ")", ")", "{", "var", "attrs", "=", "model", ";", "model", "=", "new", "this", ".", "model", "(", "attrs", ",", "{", "collecti...
Prepare a model to be added to this collection
[ "Prepare", "a", "model", "to", "be", "added", "to", "this", "collection" ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2097-L2106
34,425
clux/modul8
examples/npm/output.js
function(model, options) { options || (options = {}); model = this.getByCid(model) || this.get(model); if (!model) return null; delete this._byId[model.id]; delete this._byCid[model.cid]; this.models.splice(this.indexOf(model), 1); this.length--; if (!options.silent) model.trigger('remove', model, this, options); this._removeReference(model); return model; }
javascript
function(model, options) { options || (options = {}); model = this.getByCid(model) || this.get(model); if (!model) return null; delete this._byId[model.id]; delete this._byCid[model.cid]; this.models.splice(this.indexOf(model), 1); this.length--; if (!options.silent) model.trigger('remove', model, this, options); this._removeReference(model); return model; }
[ "function", "(", "model", ",", "options", ")", "{", "options", "||", "(", "options", "=", "{", "}", ")", ";", "model", "=", "this", ".", "getByCid", "(", "model", ")", "||", "this", ".", "get", "(", "model", ")", ";", "if", "(", "!", "model", "...
Internal implementation of removing a single model from the set, updating hash indexes for `id` and `cid` lookups.
[ "Internal", "implementation", "of", "removing", "a", "single", "model", "from", "the", "set", "updating", "hash", "indexes", "for", "id", "and", "cid", "lookups", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2131-L2142
34,426
clux/modul8
examples/npm/output.js
function(fragment, triggerRoute) { var frag = (fragment || '').replace(hashStrip, ''); if (this.fragment == frag || this.fragment == decodeURIComponent(frag)) return; if (this._hasPushState) { var loc = window.location; if (frag.indexOf(this.options.root) != 0) frag = this.options.root + frag; this.fragment = frag; window.history.pushState({}, document.title, loc.protocol + '//' + loc.host + frag); } else { window.location.hash = this.fragment = frag; if (this.iframe && (frag != this.getFragment(this.iframe.location.hash))) { this.iframe.document.open().close(); this.iframe.location.hash = frag; } } if (triggerRoute) this.loadUrl(fragment); }
javascript
function(fragment, triggerRoute) { var frag = (fragment || '').replace(hashStrip, ''); if (this.fragment == frag || this.fragment == decodeURIComponent(frag)) return; if (this._hasPushState) { var loc = window.location; if (frag.indexOf(this.options.root) != 0) frag = this.options.root + frag; this.fragment = frag; window.history.pushState({}, document.title, loc.protocol + '//' + loc.host + frag); } else { window.location.hash = this.fragment = frag; if (this.iframe && (frag != this.getFragment(this.iframe.location.hash))) { this.iframe.document.open().close(); this.iframe.location.hash = frag; } } if (triggerRoute) this.loadUrl(fragment); }
[ "function", "(", "fragment", ",", "triggerRoute", ")", "{", "var", "frag", "=", "(", "fragment", "||", "''", ")", ".", "replace", "(", "hashStrip", ",", "''", ")", ";", "if", "(", "this", ".", "fragment", "==", "frag", "||", "this", ".", "fragment", ...
Save a fragment into the hash history. You are responsible for properly URL-encoding the fragment in advance. This does not trigger a `hashchange` event.
[ "Save", "a", "fragment", "into", "the", "hash", "history", ".", "You", "are", "responsible", "for", "properly", "URL", "-", "encoding", "the", "fragment", "in", "advance", ".", "This", "does", "not", "trigger", "a", "hashchange", "event", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2384-L2400
34,427
clux/modul8
examples/npm/output.js
function(object) { if (!(object && object.url)) return null; return _.isFunction(object.url) ? object.url() : object.url; }
javascript
function(object) { if (!(object && object.url)) return null; return _.isFunction(object.url) ? object.url() : object.url; }
[ "function", "(", "object", ")", "{", "if", "(", "!", "(", "object", "&&", "object", ".", "url", ")", ")", "return", "null", ";", "return", "_", ".", "isFunction", "(", "object", ".", "url", ")", "?", "object", ".", "url", "(", ")", ":", "object",...
Helper function to get a URL from a Model or Collection as a property or as a function.
[ "Helper", "function", "to", "get", "a", "URL", "from", "a", "Model", "or", "Collection", "as", "a", "property", "or", "as", "a", "function", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2662-L2665
34,428
clux/modul8
examples/npm/output.js
function(string) { return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;'); }
javascript
function(string) { return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;'); }
[ "function", "(", "string", ")", "{", "return", "string", ".", "replace", "(", "/", "&(?!\\w+;|#\\d+;|#x[\\da-f]+;)", "/", "gi", ",", "'&amp;'", ")", ".", "replace", "(", "/", "<", "/", "g", ",", "'&lt;'", ")", ".", "replace", "(", "/", ">", "/", "g",...
Helper function to escape a string for HTML rendering.
[ "Helper", "function", "to", "escape", "a", "string", "for", "HTML", "rendering", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L2684-L2686
34,429
clux/modul8
examples/npm/output.js
eq
function eq(a, b, stack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. if (a === b) return a !== 0 || 1 / a == 1 / b; // A strict comparison is necessary because `null == undefined`. if (a == null || b == null) return a === b; // Unwrap any wrapped objects. if (a._chain) a = a._wrapped; if (b._chain) b = b._wrapped; // Invoke a custom `isEqual` method if one is provided. if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b); if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a); // Compare `[[Class]]` names. var className = toString.call(a); if (className != toString.call(b)) return false; switch (className) { // Strings, numbers, dates, and booleans are compared by value. case '[object String]': // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is // equivalent to `new String("5")`. return a == String(b); case '[object Number]': // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for // other numeric values. return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a == +b; // RegExps are compared by their source patterns and flags. case '[object RegExp]': return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; } if (typeof a != 'object' || typeof b != 'object') return false; // Assume equality for cyclic structures. The algorithm for detecting cyclic // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. var length = stack.length; while (length--) { // Linear search. Performance is inversely proportional to the number of // unique nested structures. if (stack[length] == a) return true; } // Add the first object to the stack of traversed objects. stack.push(a); var size = 0, result = true; // Recursively compare objects and arrays. if (className == '[object Array]') { // Compare array lengths to determine if a deep comparison is necessary. size = a.length; result = size == b.length; if (result) { // Deep compare the contents, ignoring non-numeric properties. while (size--) { // Ensure commutative equality for sparse arrays. if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break; } } } else { // Objects with different constructors are not equivalent. if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false; // Deep compare objects. for (var key in a) { if (hasOwnProperty.call(a, key)) { // Count the expected number of properties. size++; // Deep compare each member. if (!(result = hasOwnProperty.call(b, key) && eq(a[key], b[key], stack))) break; } } // Ensure that both objects contain the same number of properties. if (result) { for (key in b) { if (hasOwnProperty.call(b, key) && !(size--)) break; } result = !size; } } // Remove the first object from the stack of traversed objects. stack.pop(); return result; }
javascript
function eq(a, b, stack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. if (a === b) return a !== 0 || 1 / a == 1 / b; // A strict comparison is necessary because `null == undefined`. if (a == null || b == null) return a === b; // Unwrap any wrapped objects. if (a._chain) a = a._wrapped; if (b._chain) b = b._wrapped; // Invoke a custom `isEqual` method if one is provided. if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b); if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a); // Compare `[[Class]]` names. var className = toString.call(a); if (className != toString.call(b)) return false; switch (className) { // Strings, numbers, dates, and booleans are compared by value. case '[object String]': // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is // equivalent to `new String("5")`. return a == String(b); case '[object Number]': // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for // other numeric values. return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a == +b; // RegExps are compared by their source patterns and flags. case '[object RegExp]': return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; } if (typeof a != 'object' || typeof b != 'object') return false; // Assume equality for cyclic structures. The algorithm for detecting cyclic // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. var length = stack.length; while (length--) { // Linear search. Performance is inversely proportional to the number of // unique nested structures. if (stack[length] == a) return true; } // Add the first object to the stack of traversed objects. stack.push(a); var size = 0, result = true; // Recursively compare objects and arrays. if (className == '[object Array]') { // Compare array lengths to determine if a deep comparison is necessary. size = a.length; result = size == b.length; if (result) { // Deep compare the contents, ignoring non-numeric properties. while (size--) { // Ensure commutative equality for sparse arrays. if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break; } } } else { // Objects with different constructors are not equivalent. if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false; // Deep compare objects. for (var key in a) { if (hasOwnProperty.call(a, key)) { // Count the expected number of properties. size++; // Deep compare each member. if (!(result = hasOwnProperty.call(b, key) && eq(a[key], b[key], stack))) break; } } // Ensure that both objects contain the same number of properties. if (result) { for (key in b) { if (hasOwnProperty.call(b, key) && !(size--)) break; } result = !size; } } // Remove the first object from the stack of traversed objects. stack.pop(); return result; }
[ "function", "eq", "(", "a", ",", "b", ",", "stack", ")", "{", "// Identical objects are equal. `0 === -0`, but they aren't identical.", "// See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.", "if", "(", "a", "===", "b", ")", "return", "a", ...
Internal recursive comparison function.
[ "Internal", "recursive", "comparison", "function", "." ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/examples/npm/output.js#L3365-L3450
34,430
reelyactive/hlc-server
web/apps/hello-tracking/js/hello-tracking.js
updateNode
function updateNode(node, content, append) { append = append || false; while(!append && node.firstChild) { node.removeChild(node.firstChild); } if(content instanceof Element) { node.appendChild(content); } else if(content instanceof Array) { content.forEach(function(element) { node.appendChild(element); }); } else { node.textContent = content; } }
javascript
function updateNode(node, content, append) { append = append || false; while(!append && node.firstChild) { node.removeChild(node.firstChild); } if(content instanceof Element) { node.appendChild(content); } else if(content instanceof Array) { content.forEach(function(element) { node.appendChild(element); }); } else { node.textContent = content; } }
[ "function", "updateNode", "(", "node", ",", "content", ",", "append", ")", "{", "append", "=", "append", "||", "false", ";", "while", "(", "!", "append", "&&", "node", ".", "firstChild", ")", "{", "node", ".", "removeChild", "(", "node", ".", "firstChi...
Update the given node with the given content
[ "Update", "the", "given", "node", "with", "the", "given", "content" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-tracking/js/hello-tracking.js#L118-L136
34,431
reelyactive/hlc-server
web/apps/hello-tracking/js/hello-tracking.js
prepareEvents
function prepareEvents(raddec) { let elements = []; raddec.events.forEach(function(event) { let i = document.createElement('i'); let space = document.createTextNode(' '); i.setAttribute('class', EVENT_ICONS[event]); elements.push(i); elements.push(space); }); return elements; }
javascript
function prepareEvents(raddec) { let elements = []; raddec.events.forEach(function(event) { let i = document.createElement('i'); let space = document.createTextNode(' '); i.setAttribute('class', EVENT_ICONS[event]); elements.push(i); elements.push(space); }); return elements; }
[ "function", "prepareEvents", "(", "raddec", ")", "{", "let", "elements", "=", "[", "]", ";", "raddec", ".", "events", ".", "forEach", "(", "function", "(", "event", ")", "{", "let", "i", "=", "document", ".", "createElement", "(", "'i'", ")", ";", "l...
Prepare the event icons
[ "Prepare", "the", "event", "icons" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-tracking/js/hello-tracking.js#L139-L151
34,432
reelyactive/hlc-server
web/apps/hello-tracking/js/hello-tracking.js
prepareRecDecPac
function prepareRecDecPac(raddec) { let maxNumberOfDecodings = 0; raddec.rssiSignature.forEach(function(signature) { if(signature.numberOfDecodings > maxNumberOfDecodings) { maxNumberOfDecodings = signature.numberOfDecodings; } }); return raddec.rssiSignature.length + RDPS + maxNumberOfDecodings + RDPS + raddec.packets.length; }
javascript
function prepareRecDecPac(raddec) { let maxNumberOfDecodings = 0; raddec.rssiSignature.forEach(function(signature) { if(signature.numberOfDecodings > maxNumberOfDecodings) { maxNumberOfDecodings = signature.numberOfDecodings; } }); return raddec.rssiSignature.length + RDPS + maxNumberOfDecodings + RDPS + raddec.packets.length; }
[ "function", "prepareRecDecPac", "(", "raddec", ")", "{", "let", "maxNumberOfDecodings", "=", "0", ";", "raddec", ".", "rssiSignature", ".", "forEach", "(", "function", "(", "signature", ")", "{", "if", "(", "signature", ".", "numberOfDecodings", ">", "maxNumbe...
Prepare the receivers-decodings-packets string
[ "Prepare", "the", "receivers", "-", "decodings", "-", "packets", "string" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-tracking/js/hello-tracking.js#L154-L165
34,433
reelyactive/hlc-server
web/apps/hello-tracking/js/hello-tracking.js
sortRaddecsAndHighlight
function sortRaddecsAndHighlight(transmitterId) { let trs = Array.from(tbody.getElementsByTagName('tr')); let sortedFragment = document.createDocumentFragment(); trs.sort(sortFunction); trs.forEach(function(tr) { if(tr.id === transmitterId) { tr.setAttribute('class', 'monospace animated-highlight-reelyactive'); } else { tr.setAttribute('class', 'monospace'); } sortedFragment.appendChild(tr); }); tbody.appendChild(sortedFragment); }
javascript
function sortRaddecsAndHighlight(transmitterId) { let trs = Array.from(tbody.getElementsByTagName('tr')); let sortedFragment = document.createDocumentFragment(); trs.sort(sortFunction); trs.forEach(function(tr) { if(tr.id === transmitterId) { tr.setAttribute('class', 'monospace animated-highlight-reelyactive'); } else { tr.setAttribute('class', 'monospace'); } sortedFragment.appendChild(tr); }); tbody.appendChild(sortedFragment); }
[ "function", "sortRaddecsAndHighlight", "(", "transmitterId", ")", "{", "let", "trs", "=", "Array", ".", "from", "(", "tbody", ".", "getElementsByTagName", "(", "'tr'", ")", ")", ";", "let", "sortedFragment", "=", "document", ".", "createDocumentFragment", "(", ...
Sort the raddecs in the table, highlighting the given transmitterId
[ "Sort", "the", "raddecs", "in", "the", "table", "highlighting", "the", "given", "transmitterId" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-tracking/js/hello-tracking.js#L193-L210
34,434
runspired/ember-mobiletouch
addon/utils/prevent-ghost-clicks.js
makeGhostBuster
function makeGhostBuster() { var coordinates = []; var threshold = 25; var timeout = 2500; // no touch support if(!mobileDetection.is()) { return { add : function(){}, remove : function(){} }; } /** * prevent clicks if they're in a registered XY region * @param {MouseEvent} event */ function preventGhostClick(event) { var ev = event.originalEvent || event; //don't prevent fastclicks if (ev.fastclick) { return true; } for (var i = 0; i < coordinates.length; i++) { var x = coordinates[i][0]; var y = coordinates[i][1]; // within the range, so prevent the click if (Math.abs(ev.clientX - x) < threshold && Math.abs(ev.clientY - y) < threshold) { event.stopPropagation(); event.stopImmediatePropagation(); event.preventDefault(); return false; } } } /** * reset the coordinates array */ function resetCoordinates() { coordinates = []; } /** * remove the first coordinates set from the array */ function popCoordinates() { coordinates.splice(0, 1); } /** * if it is an final touchend, we want to register it's place * @param {TouchEvent} event */ function registerCoordinates(event) { var ev = event.originalEvent || event; // It seems that touchend is the cause for derived events like 'change' for // checkboxes. Since we're creating fastclicks, which will also cause 'change' // events to fire, we need to prevent default on touchend events, which has // the effect of not causing these derived events to be created. I am not // sure if this has any other negative consequences. ev.preventDefault(); // touchend is triggered on every releasing finger // changed touches always contain the removed touches on a touchend // the touches object might contain these also at some browsers (firefox os) // so touches - changedTouches will be 0 or lower, like -1, on the final touchend if(ev.touches.length - ev.changedTouches.length <= 0) { var touch = ev.changedTouches[0]; coordinates.push([touch.clientX, touch.clientY]); setTimeout(popCoordinates, timeout); } } /** * prevent click events for the given element * @param {EventTarget} $element jQuery object */ return { add : Ember.run.bind(this, function ($element) { $element.on("touchstart.ghost-click-buster", resetCoordinates); $element.on("touchend.ghost-click-buster", registerCoordinates); // register the click buster on with the selector, '*', which will // cause it to fire on the first element that gets clicked on so that // if this is a ghost click it will get killed immediately. $element.on("click.ghost-click-buster", '*', preventGhostClick); }), remove : Ember.run.bind(this, function ($element) { $element.off('.ghost-click-buster'); }) }; }
javascript
function makeGhostBuster() { var coordinates = []; var threshold = 25; var timeout = 2500; // no touch support if(!mobileDetection.is()) { return { add : function(){}, remove : function(){} }; } /** * prevent clicks if they're in a registered XY region * @param {MouseEvent} event */ function preventGhostClick(event) { var ev = event.originalEvent || event; //don't prevent fastclicks if (ev.fastclick) { return true; } for (var i = 0; i < coordinates.length; i++) { var x = coordinates[i][0]; var y = coordinates[i][1]; // within the range, so prevent the click if (Math.abs(ev.clientX - x) < threshold && Math.abs(ev.clientY - y) < threshold) { event.stopPropagation(); event.stopImmediatePropagation(); event.preventDefault(); return false; } } } /** * reset the coordinates array */ function resetCoordinates() { coordinates = []; } /** * remove the first coordinates set from the array */ function popCoordinates() { coordinates.splice(0, 1); } /** * if it is an final touchend, we want to register it's place * @param {TouchEvent} event */ function registerCoordinates(event) { var ev = event.originalEvent || event; // It seems that touchend is the cause for derived events like 'change' for // checkboxes. Since we're creating fastclicks, which will also cause 'change' // events to fire, we need to prevent default on touchend events, which has // the effect of not causing these derived events to be created. I am not // sure if this has any other negative consequences. ev.preventDefault(); // touchend is triggered on every releasing finger // changed touches always contain the removed touches on a touchend // the touches object might contain these also at some browsers (firefox os) // so touches - changedTouches will be 0 or lower, like -1, on the final touchend if(ev.touches.length - ev.changedTouches.length <= 0) { var touch = ev.changedTouches[0]; coordinates.push([touch.clientX, touch.clientY]); setTimeout(popCoordinates, timeout); } } /** * prevent click events for the given element * @param {EventTarget} $element jQuery object */ return { add : Ember.run.bind(this, function ($element) { $element.on("touchstart.ghost-click-buster", resetCoordinates); $element.on("touchend.ghost-click-buster", registerCoordinates); // register the click buster on with the selector, '*', which will // cause it to fire on the first element that gets clicked on so that // if this is a ghost click it will get killed immediately. $element.on("click.ghost-click-buster", '*', preventGhostClick); }), remove : Ember.run.bind(this, function ($element) { $element.off('.ghost-click-buster'); }) }; }
[ "function", "makeGhostBuster", "(", ")", "{", "var", "coordinates", "=", "[", "]", ";", "var", "threshold", "=", "25", ";", "var", "timeout", "=", "2500", ";", "// no touch support", "if", "(", "!", "mobileDetection", ".", "is", "(", ")", ")", "{", "re...
Prevent click events after a touchend. Inspired/copy-paste from this article of Google by Ryan Fioravanti https://developers.google.com/mobile/articles/fast_buttons#ghost USAGE: Prevent the click event for an certain element ```` PreventGhostClick($element); ````
[ "Prevent", "click", "events", "after", "a", "touchend", "." ]
65790013838776430bd55ee980bc9137711f8c36
https://github.com/runspired/ember-mobiletouch/blob/65790013838776430bd55ee980bc9137711f8c36/addon/utils/prevent-ghost-clicks.js#L17-L110
34,435
runspired/ember-mobiletouch
addon/utils/prevent-ghost-clicks.js
registerCoordinates
function registerCoordinates(event) { var ev = event.originalEvent || event; // It seems that touchend is the cause for derived events like 'change' for // checkboxes. Since we're creating fastclicks, which will also cause 'change' // events to fire, we need to prevent default on touchend events, which has // the effect of not causing these derived events to be created. I am not // sure if this has any other negative consequences. ev.preventDefault(); // touchend is triggered on every releasing finger // changed touches always contain the removed touches on a touchend // the touches object might contain these also at some browsers (firefox os) // so touches - changedTouches will be 0 or lower, like -1, on the final touchend if(ev.touches.length - ev.changedTouches.length <= 0) { var touch = ev.changedTouches[0]; coordinates.push([touch.clientX, touch.clientY]); setTimeout(popCoordinates, timeout); } }
javascript
function registerCoordinates(event) { var ev = event.originalEvent || event; // It seems that touchend is the cause for derived events like 'change' for // checkboxes. Since we're creating fastclicks, which will also cause 'change' // events to fire, we need to prevent default on touchend events, which has // the effect of not causing these derived events to be created. I am not // sure if this has any other negative consequences. ev.preventDefault(); // touchend is triggered on every releasing finger // changed touches always contain the removed touches on a touchend // the touches object might contain these also at some browsers (firefox os) // so touches - changedTouches will be 0 or lower, like -1, on the final touchend if(ev.touches.length - ev.changedTouches.length <= 0) { var touch = ev.changedTouches[0]; coordinates.push([touch.clientX, touch.clientY]); setTimeout(popCoordinates, timeout); } }
[ "function", "registerCoordinates", "(", "event", ")", "{", "var", "ev", "=", "event", ".", "originalEvent", "||", "event", ";", "// It seems that touchend is the cause for derived events like 'change' for", "// checkboxes. Since we're creating fastclicks, which will also cause 'chang...
if it is an final touchend, we want to register it's place @param {TouchEvent} event
[ "if", "it", "is", "an", "final", "touchend", "we", "want", "to", "register", "it", "s", "place" ]
65790013838776430bd55ee980bc9137711f8c36
https://github.com/runspired/ember-mobiletouch/blob/65790013838776430bd55ee980bc9137711f8c36/addon/utils/prevent-ghost-clicks.js#L70-L89
34,436
erha19/eslint-plugin-weex
eslint-internal-rules/require-meta-docs-url.js
getKeyName
function getKeyName (property) { if (!property.computed && property.key.type === 'Identifier') { return property.key.name } if (property.key.type === 'Literal') { return '' + property.key.value } if (property.key.type === 'TemplateLiteral' && property.key.quasis.length === 1) { return property.key.quasis[0].value.cooked } return null }
javascript
function getKeyName (property) { if (!property.computed && property.key.type === 'Identifier') { return property.key.name } if (property.key.type === 'Literal') { return '' + property.key.value } if (property.key.type === 'TemplateLiteral' && property.key.quasis.length === 1) { return property.key.quasis[0].value.cooked } return null }
[ "function", "getKeyName", "(", "property", ")", "{", "if", "(", "!", "property", ".", "computed", "&&", "property", ".", "key", ".", "type", "===", "'Identifier'", ")", "{", "return", "property", ".", "key", ".", "name", "}", "if", "(", "property", "."...
Gets the key name of a Property, if it can be determined statically. @param {ASTNode} node The `Property` node @returns {string|null} The key name, or `null` if the name cannot be determined statically.
[ "Gets", "the", "key", "name", "of", "a", "Property", "if", "it", "can", "be", "determined", "statically", "." ]
2f7db1812fe66a529c3dc68fd2d22e9e7962d51e
https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/eslint-internal-rules/require-meta-docs-url.js#L37-L48
34,437
erha19/eslint-plugin-weex
eslint-internal-rules/require-meta-docs-url.js
getRuleInfo
function getRuleInfo (ast) { const INTERESTING_KEYS = new Set(['create', 'meta']) let exportsVarOverridden = false let exportsIsFunction = false const exportNodes = ast.body .filter(statement => statement.type === 'ExpressionStatement') .map(statement => statement.expression) .filter(expression => expression.type === 'AssignmentExpression') .filter(expression => expression.left.type === 'MemberExpression') .reduce((currentExports, node) => { if ( node.left.object.type === 'Identifier' && node.left.object.name === 'module' && node.left.property.type === 'Identifier' && node.left.property.name === 'exports' ) { exportsVarOverridden = true if (isNormalFunctionExpression(node.right)) { // Check `module.exports = function () {}` exportsIsFunction = true return { create: node.right, meta: null } } else if (node.right.type === 'ObjectExpression') { // Check `module.exports = { create: function () {}, meta: {} }` exportsIsFunction = false return node.right.properties.reduce((parsedProps, prop) => { const keyValue = getKeyName(prop) if (INTERESTING_KEYS.has(keyValue)) { parsedProps[keyValue] = prop.value } return parsedProps }, {}) } return {} } else if ( !exportsIsFunction && node.left.object.type === 'MemberExpression' && node.left.object.object.type === 'Identifier' && node.left.object.object.name === 'module' && node.left.object.property.type === 'Identifier' && node.left.object.property.name === 'exports' && node.left.property.type === 'Identifier' && INTERESTING_KEYS.has(node.left.property.name) ) { // Check `module.exports.create = () => {}` currentExports[node.left.property.name] = node.right } else if ( !exportsVarOverridden && node.left.object.type === 'Identifier' && node.left.object.name === 'exports' && node.left.property.type === 'Identifier' && INTERESTING_KEYS.has(node.left.property.name) ) { // Check `exports.create = () => {}` currentExports[node.left.property.name] = node.right } return currentExports }, {}) return Object.prototype.hasOwnProperty.call(exportNodes, 'create') && isNormalFunctionExpression(exportNodes.create) ? Object.assign({ isNewStyle: !exportsIsFunction, meta: null }, exportNodes) : null }
javascript
function getRuleInfo (ast) { const INTERESTING_KEYS = new Set(['create', 'meta']) let exportsVarOverridden = false let exportsIsFunction = false const exportNodes = ast.body .filter(statement => statement.type === 'ExpressionStatement') .map(statement => statement.expression) .filter(expression => expression.type === 'AssignmentExpression') .filter(expression => expression.left.type === 'MemberExpression') .reduce((currentExports, node) => { if ( node.left.object.type === 'Identifier' && node.left.object.name === 'module' && node.left.property.type === 'Identifier' && node.left.property.name === 'exports' ) { exportsVarOverridden = true if (isNormalFunctionExpression(node.right)) { // Check `module.exports = function () {}` exportsIsFunction = true return { create: node.right, meta: null } } else if (node.right.type === 'ObjectExpression') { // Check `module.exports = { create: function () {}, meta: {} }` exportsIsFunction = false return node.right.properties.reduce((parsedProps, prop) => { const keyValue = getKeyName(prop) if (INTERESTING_KEYS.has(keyValue)) { parsedProps[keyValue] = prop.value } return parsedProps }, {}) } return {} } else if ( !exportsIsFunction && node.left.object.type === 'MemberExpression' && node.left.object.object.type === 'Identifier' && node.left.object.object.name === 'module' && node.left.object.property.type === 'Identifier' && node.left.object.property.name === 'exports' && node.left.property.type === 'Identifier' && INTERESTING_KEYS.has(node.left.property.name) ) { // Check `module.exports.create = () => {}` currentExports[node.left.property.name] = node.right } else if ( !exportsVarOverridden && node.left.object.type === 'Identifier' && node.left.object.name === 'exports' && node.left.property.type === 'Identifier' && INTERESTING_KEYS.has(node.left.property.name) ) { // Check `exports.create = () => {}` currentExports[node.left.property.name] = node.right } return currentExports }, {}) return Object.prototype.hasOwnProperty.call(exportNodes, 'create') && isNormalFunctionExpression(exportNodes.create) ? Object.assign({ isNewStyle: !exportsIsFunction, meta: null }, exportNodes) : null }
[ "function", "getRuleInfo", "(", "ast", ")", "{", "const", "INTERESTING_KEYS", "=", "new", "Set", "(", "[", "'create'", ",", "'meta'", "]", ")", "let", "exportsVarOverridden", "=", "false", "let", "exportsIsFunction", "=", "false", "const", "exportNodes", "=", ...
Performs static analysis on an AST to try to determine the final value of `module.exports`. @param {ASTNode} ast The `Program` AST node @returns {Object} An object with keys `meta`, `create`, and `isNewStyle`. `meta` and `create` correspond to the AST nodes for the final values of `module.exports.meta` and `module.exports.create`. `isNewStyle` will be `true` if `module.exports` is an object, and `false` if module.exports is just the `create` function. If no valid ESLint rule info can be extracted from the file, the return value will be `null`.
[ "Performs", "static", "analysis", "on", "an", "AST", "to", "try", "to", "determine", "the", "final", "value", "of", "module", ".", "exports", "." ]
2f7db1812fe66a529c3dc68fd2d22e9e7962d51e
https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/eslint-internal-rules/require-meta-docs-url.js#L58-L118
34,438
jiahaog/Revenant
lib/helpers/helpers.js
cookieToHeader
function cookieToHeader(cookies) { const SEPARATOR = '; '; return cookies.reduce(function (previous, current) { return previous + current.name + '=' + current.value + SEPARATOR; }, ''); }
javascript
function cookieToHeader(cookies) { const SEPARATOR = '; '; return cookies.reduce(function (previous, current) { return previous + current.name + '=' + current.value + SEPARATOR; }, ''); }
[ "function", "cookieToHeader", "(", "cookies", ")", "{", "const", "SEPARATOR", "=", "'; '", ";", "return", "cookies", ".", "reduce", "(", "function", "(", "previous", ",", "current", ")", "{", "return", "previous", "+", "current", ".", "name", "+", "'='", ...
Transforms an array of cookies objects into a request header @param cookies {array} @returns {string}
[ "Transforms", "an", "array", "of", "cookies", "objects", "into", "a", "request", "header" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/helpers/helpers.js#L32-L37
34,439
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
updateQuery
function updateQuery() { let query = {}; switch(queryTemplates.value) { case '0': // All raddecs query = { "size": 10, "query": { "match_all": {} }, "_source": [ "transmitterId", "transmitterIdType", "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '1': // Specific transmitterId query = { "size": 10, "query": { "term": { "transmitterId": "" } }, "_source": [ "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets", "packets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '2': // Prefix transmitterId query = { "size": 10, "query": { "prefix": { "transmitterId": "" } }, "_source": [ "transmitterId", "transmitterIdType", "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '3': // Aggregate receiverId query = { "size": 0, "aggs" : { "receivers" : { "terms" : { "field" : "receiverId.keyword", "order" : { "_count" : "desc" }, "size": 12 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; case '4': // Aggregate rec/dec/pac query = { "size": 0, "aggs" : { "numberOfReceivers" : { "histogram" : { "field" : "numberOfReceivers", "interval" : 1 } }, "numberOfDecodings" : { "histogram" : { "field" : "numberOfDecodings", "interval" : 1, "min_doc_count" : 1 } }, "numberOfDistinctPackets" : { "histogram" : { "field" : "numberOfDistinctPackets", "interval" : 1 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; case '5': // Auto-date histogram query = { "size": 0, "aggs" : { "periods" : { "auto_date_histogram" : { "field" : "timestamp", "buckets" : 12 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; } queryBox.rows = countNumberOfLines(queryBox.value); parseQuery(); }
javascript
function updateQuery() { let query = {}; switch(queryTemplates.value) { case '0': // All raddecs query = { "size": 10, "query": { "match_all": {} }, "_source": [ "transmitterId", "transmitterIdType", "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '1': // Specific transmitterId query = { "size": 10, "query": { "term": { "transmitterId": "" } }, "_source": [ "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets", "packets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '2': // Prefix transmitterId query = { "size": 10, "query": { "prefix": { "transmitterId": "" } }, "_source": [ "transmitterId", "transmitterIdType", "receiverId", "receiverIdType", "rssi", "timestamp", "numberOfDecodings", "numberOfReceivers", "numberOfPackets" ] }; queryBox.value = JSON.stringify(query, null, 2); break; case '3': // Aggregate receiverId query = { "size": 0, "aggs" : { "receivers" : { "terms" : { "field" : "receiverId.keyword", "order" : { "_count" : "desc" }, "size": 12 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; case '4': // Aggregate rec/dec/pac query = { "size": 0, "aggs" : { "numberOfReceivers" : { "histogram" : { "field" : "numberOfReceivers", "interval" : 1 } }, "numberOfDecodings" : { "histogram" : { "field" : "numberOfDecodings", "interval" : 1, "min_doc_count" : 1 } }, "numberOfDistinctPackets" : { "histogram" : { "field" : "numberOfDistinctPackets", "interval" : 1 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; case '5': // Auto-date histogram query = { "size": 0, "aggs" : { "periods" : { "auto_date_histogram" : { "field" : "timestamp", "buckets" : 12 } } } }; queryBox.value = JSON.stringify(query, null, 2); break; } queryBox.rows = countNumberOfLines(queryBox.value); parseQuery(); }
[ "function", "updateQuery", "(", ")", "{", "let", "query", "=", "{", "}", ";", "switch", "(", "queryTemplates", ".", "value", ")", "{", "case", "'0'", ":", "// All raddecs", "query", "=", "{", "\"size\"", ":", "10", ",", "\"query\"", ":", "{", "\"match_...
Update the query JSON based on the selected template
[ "Update", "the", "query", "JSON", "based", "on", "the", "selected", "template" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L44-L139
34,440
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
parseQuery
function parseQuery() { let query = {}; try { query = JSON.parse(queryBox.value); } catch(error) { queryError.textContent = 'Query must be valid JSON'; hide(queryButton); hide(queryResults); show(queryError); return null; } hide(queryError); show(queryButton); return query; }
javascript
function parseQuery() { let query = {}; try { query = JSON.parse(queryBox.value); } catch(error) { queryError.textContent = 'Query must be valid JSON'; hide(queryButton); hide(queryResults); show(queryError); return null; } hide(queryError); show(queryButton); return query; }
[ "function", "parseQuery", "(", ")", "{", "let", "query", "=", "{", "}", ";", "try", "{", "query", "=", "JSON", ".", "parse", "(", "queryBox", ".", "value", ")", ";", "}", "catch", "(", "error", ")", "{", "queryError", ".", "textContent", "=", "'Que...
Parse the query as typed in the box and confirm it is valid JSON
[ "Parse", "the", "query", "as", "typed", "in", "the", "box", "and", "confirm", "it", "is", "valid", "JSON" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L142-L157
34,441
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
handleQuery
function handleQuery() { let query = parseQuery(); let url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ELASTICSEARCH_INTERFACE_ROUTE; let httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if(httpRequest.readyState === XMLHttpRequest.DONE) { if(httpRequest.status === 200) { let response = JSON.parse(httpRequest.responseText); updateResults(response); updateHits(response); updateAggregations(response); show(queryResults); } else { queryError.textContent = 'Query returned status ' + httpRequest.status + '. Is Elasticsearch connected and running?'; hide(queryResults); hide(queryButton); show(queryError); } } }; httpRequest.open('POST', url); httpRequest.setRequestHeader('Content-Type', 'application/json'); httpRequest.setRequestHeader('Accept', 'application/json'); httpRequest.send(JSON.stringify(query)); }
javascript
function handleQuery() { let query = parseQuery(); let url = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + ELASTICSEARCH_INTERFACE_ROUTE; let httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if(httpRequest.readyState === XMLHttpRequest.DONE) { if(httpRequest.status === 200) { let response = JSON.parse(httpRequest.responseText); updateResults(response); updateHits(response); updateAggregations(response); show(queryResults); } else { queryError.textContent = 'Query returned status ' + httpRequest.status + '. Is Elasticsearch connected and running?'; hide(queryResults); hide(queryButton); show(queryError); } } }; httpRequest.open('POST', url); httpRequest.setRequestHeader('Content-Type', 'application/json'); httpRequest.setRequestHeader('Accept', 'application/json'); httpRequest.send(JSON.stringify(query)); }
[ "function", "handleQuery", "(", ")", "{", "let", "query", "=", "parseQuery", "(", ")", ";", "let", "url", "=", "window", ".", "location", ".", "protocol", "+", "'//'", "+", "window", ".", "location", ".", "hostname", "+", "':'", "+", "window", ".", "...
Handle the current Elasticsearch query
[ "Handle", "the", "current", "Elasticsearch", "query" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L160-L189
34,442
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
updateResults
function updateResults(response) { responseHits.textContent = response.hits.total; responseTime.textContent = response.took; }
javascript
function updateResults(response) { responseHits.textContent = response.hits.total; responseTime.textContent = response.took; }
[ "function", "updateResults", "(", "response", ")", "{", "responseHits", ".", "textContent", "=", "response", ".", "hits", ".", "total", ";", "responseTime", ".", "textContent", "=", "response", ".", "took", ";", "}" ]
Update the results
[ "Update", "the", "results" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L192-L195
34,443
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
updateHits
function updateHits(response) { if(!response.hits.hasOwnProperty('hits') || (response.hits.hits.length === 0)) { hide(hitsCard); } else { show(hitsCard); hitsBox.textContent = JSON.stringify(response.hits.hits, null, 2); } }
javascript
function updateHits(response) { if(!response.hits.hasOwnProperty('hits') || (response.hits.hits.length === 0)) { hide(hitsCard); } else { show(hitsCard); hitsBox.textContent = JSON.stringify(response.hits.hits, null, 2); } }
[ "function", "updateHits", "(", "response", ")", "{", "if", "(", "!", "response", ".", "hits", ".", "hasOwnProperty", "(", "'hits'", ")", "||", "(", "response", ".", "hits", ".", "hits", ".", "length", "===", "0", ")", ")", "{", "hide", "(", "hitsCard...
Update the hits
[ "Update", "the", "hits" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L198-L207
34,444
reelyactive/hlc-server
web/apps/hello-elasticsearch/js/hello-elasticsearch.js
updateAggregations
function updateAggregations(response) { if(response.hasOwnProperty('aggregations')) { aggregationsBox.textContent = JSON.stringify(response.aggregations, null, 2); show(aggregationsCard); } else { hide(aggregationsCard); } }
javascript
function updateAggregations(response) { if(response.hasOwnProperty('aggregations')) { aggregationsBox.textContent = JSON.stringify(response.aggregations, null, 2); show(aggregationsCard); } else { hide(aggregationsCard); } }
[ "function", "updateAggregations", "(", "response", ")", "{", "if", "(", "response", ".", "hasOwnProperty", "(", "'aggregations'", ")", ")", "{", "aggregationsBox", ".", "textContent", "=", "JSON", ".", "stringify", "(", "response", ".", "aggregations", ",", "n...
Update the aggregations
[ "Update", "the", "aggregations" ]
6e20593440557264449d67ce0edf5c3f6aefb81e
https://github.com/reelyactive/hlc-server/blob/6e20593440557264449d67ce0edf5c3f6aefb81e/web/apps/hello-elasticsearch/js/hello-elasticsearch.js#L210-L219
34,445
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
implodeArray
function implodeArray(tokens) { var message = "", i, l; l = tokens.length; for (i = 0; i < l; i++) { message += (i > 0 ? globals.SEP : "") + tokens[i]; } return message; }
javascript
function implodeArray(tokens) { var message = "", i, l; l = tokens.length; for (i = 0; i < l; i++) { message += (i > 0 ? globals.SEP : "") + tokens[i]; } return message; }
[ "function", "implodeArray", "(", "tokens", ")", "{", "var", "message", "=", "\"\"", ",", "i", ",", "l", ";", "l", "=", "tokens", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "message", "+=", "("...
Concatenates the array in a pipe-delimited string @param {Array} tokens to be concatenated @return {String} the pipe-delimited string @private
[ "Concatenates", "the", "array", "in", "a", "pipe", "-", "delimited", "string" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L41-L48
34,446
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
implodeData
function implodeData(data) { var dataArray = [], field; for(field in data) { dataArray.push(types.STRING); dataArray.push(encodeString(field)); dataArray.push(types.STRING); dataArray.push(encodeString(data[field])); } return implodeArray(dataArray); }
javascript
function implodeData(data) { var dataArray = [], field; for(field in data) { dataArray.push(types.STRING); dataArray.push(encodeString(field)); dataArray.push(types.STRING); dataArray.push(encodeString(data[field])); } return implodeArray(dataArray); }
[ "function", "implodeData", "(", "data", ")", "{", "var", "dataArray", "=", "[", "]", ",", "field", ";", "for", "(", "field", "in", "data", ")", "{", "dataArray", ".", "push", "(", "types", ".", "STRING", ")", ";", "dataArray", ".", "push", "(", "en...
Concatenates the associative array in a pipe-delimited string in the following form FIELD_TYPE_STRING|key|FIELD_TYPE_STRING|value. Values are encoded as strings. @param {Array} data an associative array @return {String} the pipe-delimited string @private
[ "Concatenates", "the", "associative", "array", "in", "a", "pipe", "-", "delimited", "string", "in", "the", "following", "form", "FIELD_TYPE_STRING|key|FIELD_TYPE_STRING|value", ".", "Values", "are", "encoded", "as", "strings", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L59-L68
34,447
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
implodeDataArray
function implodeDataArray(data) { var dataArray = [], i, l; l = data.length; for(i = 0; i < l; i++) { dataArray.push(types.STRING); dataArray.push(encodeString(data[i])); } return implodeArray(dataArray); }
javascript
function implodeDataArray(data) { var dataArray = [], i, l; l = data.length; for(i = 0; i < l; i++) { dataArray.push(types.STRING); dataArray.push(encodeString(data[i])); } return implodeArray(dataArray); }
[ "function", "implodeDataArray", "(", "data", ")", "{", "var", "dataArray", "=", "[", "]", ",", "i", ",", "l", ";", "l", "=", "data", ".", "length", ";", "for", "(", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "dataArray", "."...
Concatenates the array values in a pipe-delimited string in the following form FIELD_TYPE_STRING|value. Values are encoded as strings. @param {Array} data fields to be encoded @return {String} the pipe-delimited string @private
[ "Concatenates", "the", "array", "values", "in", "a", "pipe", "-", "delimited", "string", "in", "the", "following", "form", "FIELD_TYPE_STRING|value", ".", "Values", "are", "encoded", "as", "strings", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L79-L87
34,448
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
encodeString
function encodeString(string) { //it actually accepts any kind of object as input if (string === null) { return values.NULL; } else if (string === "") { return values.EMPTY; } else {//0 false undefined NaN will pass from here return encodeURIComponent(string) .replace(/%20/g, "+"); } }
javascript
function encodeString(string) { //it actually accepts any kind of object as input if (string === null) { return values.NULL; } else if (string === "") { return values.EMPTY; } else {//0 false undefined NaN will pass from here return encodeURIComponent(string) .replace(/%20/g, "+"); } }
[ "function", "encodeString", "(", "string", ")", "{", "//it actually accepts any kind of object as input", "if", "(", "string", "===", "null", ")", "{", "return", "values", ".", "NULL", ";", "}", "else", "if", "(", "string", "===", "\"\"", ")", "{", "return", ...
Encodes a string according to the ARI protocol. @param {String} string input @return {String} output @private
[ "Encodes", "a", "string", "according", "to", "the", "ARI", "protocol", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L168-L178
34,449
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
decodeString
function decodeString (string) { if (string === values.EMPTY) { return ""; } else if (string === values.NULL) { return null; } else { return decodeURIComponent( string.replace(/\+/g,"%20")); } }
javascript
function decodeString (string) { if (string === values.EMPTY) { return ""; } else if (string === values.NULL) { return null; } else { return decodeURIComponent( string.replace(/\+/g,"%20")); } }
[ "function", "decodeString", "(", "string", ")", "{", "if", "(", "string", "===", "values", ".", "EMPTY", ")", "{", "return", "\"\"", ";", "}", "else", "if", "(", "string", "===", "values", ".", "NULL", ")", "{", "return", "null", ";", "}", "else", ...
Decodes a string according to the ARI protocol. @param {String} string input @return {String} output @private
[ "Decodes", "a", "string", "according", "to", "the", "ARI", "protocol", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L187-L196
34,450
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
encodeInteger
function encodeInteger(value) { if (value === null) { return values.NULL; } else if (!isNaN(value) && parseInt(value)==value) { return value + ""; } else { throw new Error('Invalid integer value "' + value + '"'); } }
javascript
function encodeInteger(value) { if (value === null) { return values.NULL; } else if (!isNaN(value) && parseInt(value)==value) { return value + ""; } else { throw new Error('Invalid integer value "' + value + '"'); } }
[ "function", "encodeInteger", "(", "value", ")", "{", "if", "(", "value", "===", "null", ")", "{", "return", "values", ".", "NULL", ";", "}", "else", "if", "(", "!", "isNaN", "(", "value", ")", "&&", "parseInt", "(", "value", ")", "==", "value", ")"...
Encodes an integer according to the ARI protocol. @param {Number} value input @return {String} output @private
[ "Encodes", "an", "integer", "according", "to", "the", "ARI", "protocol", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L220-L228
34,451
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
encodeDouble
function encodeDouble(value) { if (value === null) { return values.NULL; } else if (!isNaN(value)) { return value + ""; } else { throw new Error('Invalid double value "' + value + '"'); } }
javascript
function encodeDouble(value) { if (value === null) { return values.NULL; } else if (!isNaN(value)) { return value + ""; } else { throw new Error('Invalid double value "' + value + '"'); } }
[ "function", "encodeDouble", "(", "value", ")", "{", "if", "(", "value", "===", "null", ")", "{", "return", "values", ".", "NULL", ";", "}", "else", "if", "(", "!", "isNaN", "(", "value", ")", ")", "{", "return", "value", "+", "\"\"", ";", "}", "e...
Encodes a float according to the ARI protocol. @param {Number} value input @return {String} output @private
[ "Encodes", "a", "float", "according", "to", "the", "ARI", "protocol", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L237-L245
34,452
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
encodeMetadataException
function encodeMetadataException(type) { if (type === "metadata") { return exceptions.METADATA; } else if (type === "access") { return exceptions.ACCESS; } else if (type === "credits") { return exceptions.CREDITS; } else if (type === "conflictingSession") { return exceptions.CONFLICTING_SESSION; } else if (type === "items") { return exceptions.ITEMS; } else if (type === "schema") { return exceptions.SCHEMA; } else if (type === "notification") { return exceptions.NOTIFICATION; } else { return exceptions.GENERIC; } }
javascript
function encodeMetadataException(type) { if (type === "metadata") { return exceptions.METADATA; } else if (type === "access") { return exceptions.ACCESS; } else if (type === "credits") { return exceptions.CREDITS; } else if (type === "conflictingSession") { return exceptions.CONFLICTING_SESSION; } else if (type === "items") { return exceptions.ITEMS; } else if (type === "schema") { return exceptions.SCHEMA; } else if (type === "notification") { return exceptions.NOTIFICATION; } else { return exceptions.GENERIC; } }
[ "function", "encodeMetadataException", "(", "type", ")", "{", "if", "(", "type", "===", "\"metadata\"", ")", "{", "return", "exceptions", ".", "METADATA", ";", "}", "else", "if", "(", "type", "===", "\"access\"", ")", "{", "return", "exceptions", ".", "ACC...
Encodes a metadata exception type. @param {Boolean} type input @return {String} output @private
[ "Encodes", "a", "metadata", "exception", "type", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L265-L283
34,453
Lightstreamer/Lightstreamer-lib-node-adapter
lib/protocol.js
parse
function parse(data, initExpected) { var lines, i, last; data = tail + data; data = data.replace(/\r*\n+/g, "\n"); lines = data.split("\n"); last = lines.length - 1; for (i = 0; i < last; i++) { messages.push(read(lines[i], initExpected)); } tail = lines[lines.length - 1]; }
javascript
function parse(data, initExpected) { var lines, i, last; data = tail + data; data = data.replace(/\r*\n+/g, "\n"); lines = data.split("\n"); last = lines.length - 1; for (i = 0; i < last; i++) { messages.push(read(lines[i], initExpected)); } tail = lines[lines.length - 1]; }
[ "function", "parse", "(", "data", ",", "initExpected", ")", "{", "var", "lines", ",", "i", ",", "last", ";", "data", "=", "tail", "+", "data", ";", "data", "=", "data", ".", "replace", "(", "/", "\\r*\\n+", "/", "g", ",", "\"\\n\"", ")", ";", "li...
Parsa new data. @param {String} data New data from the stream
[ "Parsa", "new", "data", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/protocol.js#L310-L320
34,454
clux/modul8
lib/bundler.js
bundleApp
function bundleApp(codeList, ns, domload, compile, before, npmTree, o) { var l = [] , usedBuiltIns = npmTree._builtIns , len = 0; delete npmTree._builtIns; // 1. construct the global namespace object l.push("window." + ns + " = {data:{}, path:{}};"); // 2. attach path code to the namespace object so that require.js can efficiently resolve paths l.push('\n// include npm::path'); var pathCode = read(join(builtInDir, 'path.posix.js')); l.push('(function (exports) {\n ' + pathCode + '\n}(window.' + ns + '.path));'); // 3. pull in serialized data Object.keys(o.data).forEach(function (name) { return l.push(ns + ".data." + name + " = " + o.data[name] + ";"); }); // 4. attach require code var config = { namespace : ns , domains : Object.keys(o.domains) // TODO: remove npm from here , arbiters : o.arbiters , logging : o.logLevel , npmTree : npmTree , builtIns : builtIns , slash : '/' //TODO: figure out if different types can coexist, if so, determine in resolver, and on client }; l.push(anonWrap(read(join(dir, 'require.js')) .replace(/VERSION/, JSON.parse(read(join(dir, '..', 'package.json'))).version) .replace(/REQUIRECONFIG/, JSON.stringify(config)) )); // 5. include CommonJS compatible code in the order they have to be defined var defineWrap = function (exportName, domain, code) { return ns + ".define('" + exportName + "','" + domain + "',function (require, module, exports) {\n" + code + "\n});"; }; // 6. harvest function splits code into app and non-app code and defineWraps var harvest = function (onlyMain) { codeList.forEach(function (pair) { var dom = pair[0] , file = pair[1] , basename = file.split('.')[0]; if ((dom === 'app') !== onlyMain) { return; } var code = before(compile(join(o.domains[dom], file))); l.push(defineWrap(basename, dom, code)); }); }; // 7.a) include required builtIns l.push("\n// node builtins\n"); len = l.length; usedBuiltIns.forEach(function (b) { if (b === 'path') { // already included return; } l.push(defineWrap(b, 'npm', read(join(builtInDir, b + '.js')))); }); if (l.length === len) { l.pop(); } // 7.b) include modules not on the app domain l.push("\n// shared code\n"); len = l.length; harvest(false); if (l.length === len) { l.pop(); } // 7.c) include modules on the app domain, and wait for domloader if set l.push("\n// app code - safety wrapped\n\n"); domload(harvest(true)); // 8. use a closure to encapsulate the private internal data and APIs return anonWrap(l.join('\n')); }
javascript
function bundleApp(codeList, ns, domload, compile, before, npmTree, o) { var l = [] , usedBuiltIns = npmTree._builtIns , len = 0; delete npmTree._builtIns; // 1. construct the global namespace object l.push("window." + ns + " = {data:{}, path:{}};"); // 2. attach path code to the namespace object so that require.js can efficiently resolve paths l.push('\n// include npm::path'); var pathCode = read(join(builtInDir, 'path.posix.js')); l.push('(function (exports) {\n ' + pathCode + '\n}(window.' + ns + '.path));'); // 3. pull in serialized data Object.keys(o.data).forEach(function (name) { return l.push(ns + ".data." + name + " = " + o.data[name] + ";"); }); // 4. attach require code var config = { namespace : ns , domains : Object.keys(o.domains) // TODO: remove npm from here , arbiters : o.arbiters , logging : o.logLevel , npmTree : npmTree , builtIns : builtIns , slash : '/' //TODO: figure out if different types can coexist, if so, determine in resolver, and on client }; l.push(anonWrap(read(join(dir, 'require.js')) .replace(/VERSION/, JSON.parse(read(join(dir, '..', 'package.json'))).version) .replace(/REQUIRECONFIG/, JSON.stringify(config)) )); // 5. include CommonJS compatible code in the order they have to be defined var defineWrap = function (exportName, domain, code) { return ns + ".define('" + exportName + "','" + domain + "',function (require, module, exports) {\n" + code + "\n});"; }; // 6. harvest function splits code into app and non-app code and defineWraps var harvest = function (onlyMain) { codeList.forEach(function (pair) { var dom = pair[0] , file = pair[1] , basename = file.split('.')[0]; if ((dom === 'app') !== onlyMain) { return; } var code = before(compile(join(o.domains[dom], file))); l.push(defineWrap(basename, dom, code)); }); }; // 7.a) include required builtIns l.push("\n// node builtins\n"); len = l.length; usedBuiltIns.forEach(function (b) { if (b === 'path') { // already included return; } l.push(defineWrap(b, 'npm', read(join(builtInDir, b + '.js')))); }); if (l.length === len) { l.pop(); } // 7.b) include modules not on the app domain l.push("\n// shared code\n"); len = l.length; harvest(false); if (l.length === len) { l.pop(); } // 7.c) include modules on the app domain, and wait for domloader if set l.push("\n// app code - safety wrapped\n\n"); domload(harvest(true)); // 8. use a closure to encapsulate the private internal data and APIs return anonWrap(l.join('\n')); }
[ "function", "bundleApp", "(", "codeList", ",", "ns", ",", "domload", ",", "compile", ",", "before", ",", "npmTree", ",", "o", ")", "{", "var", "l", "=", "[", "]", ",", "usedBuiltIns", "=", "npmTree", ".", "_builtIns", ",", "len", "=", "0", ";", "de...
main application packager
[ "main", "application", "packager" ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/lib/bundler.js#L58-L139
34,455
clux/modul8
lib/bundler.js
function (onlyMain) { codeList.forEach(function (pair) { var dom = pair[0] , file = pair[1] , basename = file.split('.')[0]; if ((dom === 'app') !== onlyMain) { return; } var code = before(compile(join(o.domains[dom], file))); l.push(defineWrap(basename, dom, code)); }); }
javascript
function (onlyMain) { codeList.forEach(function (pair) { var dom = pair[0] , file = pair[1] , basename = file.split('.')[0]; if ((dom === 'app') !== onlyMain) { return; } var code = before(compile(join(o.domains[dom], file))); l.push(defineWrap(basename, dom, code)); }); }
[ "function", "(", "onlyMain", ")", "{", "codeList", ".", "forEach", "(", "function", "(", "pair", ")", "{", "var", "dom", "=", "pair", "[", "0", "]", ",", "file", "=", "pair", "[", "1", "]", ",", "basename", "=", "file", ".", "split", "(", "'.'", ...
6. harvest function splits code into app and non-app code and defineWraps
[ "6", ".", "harvest", "function", "splits", "code", "into", "app", "and", "non", "-", "app", "code", "and", "defineWraps" ]
dd2809a5de14ec339660c584b0c0ec8309be2097
https://github.com/clux/modul8/blob/dd2809a5de14ec339660c584b0c0ec8309be2097/lib/bundler.js#L99-L110
34,456
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
subscribe
function subscribe(message) { reply(proto.writeSubscribe(message.id)); subscritions[message.itemName] = message.id; if (!isSnapshotAvailable(message.itemName)) { notify(proto.writeEndOfSnapshot(message.id, message.itemName)); } dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
javascript
function subscribe(message) { reply(proto.writeSubscribe(message.id)); subscritions[message.itemName] = message.id; if (!isSnapshotAvailable(message.itemName)) { notify(proto.writeEndOfSnapshot(message.id, message.itemName)); } dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
[ "function", "subscribe", "(", "message", ")", "{", "reply", "(", "proto", ".", "writeSubscribe", "(", "message", ".", "id", ")", ")", ";", "subscritions", "[", "message", ".", "itemName", "]", "=", "message", ".", "id", ";", "if", "(", "!", "isSnapshot...
Sends a subscribe reply @param {Object} message the decoded request message @private
[ "Sends", "a", "subscribe", "reply" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L125-L133
34,457
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
subscribeError
function subscribeError(message, exceptionMessage, exceptionType) { reply(proto.writeSubscribeException( message.id, exceptionMessage, exceptionType)); dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
javascript
function subscribeError(message, exceptionMessage, exceptionType) { reply(proto.writeSubscribeException( message.id, exceptionMessage, exceptionType)); dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
[ "function", "subscribeError", "(", "message", ",", "exceptionMessage", ",", "exceptionType", ")", "{", "reply", "(", "proto", ".", "writeSubscribeException", "(", "message", ".", "id", ",", "exceptionMessage", ",", "exceptionType", ")", ")", ";", "dequeueSubUnsubR...
Sends a subscribe error reply @param {Object} message the decoded request message @private
[ "Sends", "a", "subscribe", "error", "reply" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L141-L146
34,458
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
unsubscribe
function unsubscribe(message) { reply(proto.writeUnsubscribe(message.id)); subscritions[message.itemName] = undefined; dequeueSubUnsubRequest(message.itemName); handleLateSubUnsubRequests(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
javascript
function unsubscribe(message) { reply(proto.writeUnsubscribe(message.id)); subscritions[message.itemName] = undefined; dequeueSubUnsubRequest(message.itemName); handleLateSubUnsubRequests(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
[ "function", "unsubscribe", "(", "message", ")", "{", "reply", "(", "proto", ".", "writeUnsubscribe", "(", "message", ".", "id", ")", ")", ";", "subscritions", "[", "message", ".", "itemName", "]", "=", "undefined", ";", "dequeueSubUnsubRequest", "(", "messag...
Sends an unsubscribe reply @param {Object} message the decoded request message @private
[ "Sends", "an", "unsubscribe", "reply" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L154-L160
34,459
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
unsubscribeError
function unsubscribeError(message, exceptionMessage, exceptionType) { reply(proto.writeUnsubscribeException( message.id, exceptionMessage, exceptionType)); dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
javascript
function unsubscribeError(message, exceptionMessage, exceptionType) { reply(proto.writeUnsubscribeException( message.id, exceptionMessage, exceptionType)); dequeueSubUnsubRequest(message.itemName); fireFirstSubUnsubEvent(message.itemName); }
[ "function", "unsubscribeError", "(", "message", ",", "exceptionMessage", ",", "exceptionType", ")", "{", "reply", "(", "proto", ".", "writeUnsubscribeException", "(", "message", ".", "id", ",", "exceptionMessage", ",", "exceptionType", ")", ")", ";", "dequeueSubUn...
Sends an unsubscribe error reply @param {Object} message the decoded request message @private
[ "Sends", "an", "unsubscribe", "error", "reply" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L168-L173
34,460
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
fireFirstSubUnsubEvent
function fireFirstSubUnsubEvent(itemName) { if (subUnsubQueue[itemName].length > 0) { request = subUnsubQueue[itemName][0]; that.emit(request.message.verb, itemName, request.response); } }
javascript
function fireFirstSubUnsubEvent(itemName) { if (subUnsubQueue[itemName].length > 0) { request = subUnsubQueue[itemName][0]; that.emit(request.message.verb, itemName, request.response); } }
[ "function", "fireFirstSubUnsubEvent", "(", "itemName", ")", "{", "if", "(", "subUnsubQueue", "[", "itemName", "]", ".", "length", ">", "0", ")", "{", "request", "=", "subUnsubQueue", "[", "itemName", "]", "[", "0", "]", ";", "that", ".", "emit", "(", "...
Fire the first event in the queue @param {String} itemName the item name @private
[ "Fire", "the", "first", "event", "in", "the", "queue" ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L206-L211
34,461
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
function(message) { if (that.listeners(message.verb).length) { var successHandler = function(msg) { reply(proto.writeInit(msg.id)); }; var errorHandler = function(msg, exceptionMessage, exceptionType) { reply(proto.writeInitException(msg.id, exceptionMessage, exceptionType)); }; var response = new DataResponse(message, successHandler, errorHandler); that.emit("init", message, response); } else { reply(proto.writeInit(message.id)); } }
javascript
function(message) { if (that.listeners(message.verb).length) { var successHandler = function(msg) { reply(proto.writeInit(msg.id)); }; var errorHandler = function(msg, exceptionMessage, exceptionType) { reply(proto.writeInitException(msg.id, exceptionMessage, exceptionType)); }; var response = new DataResponse(message, successHandler, errorHandler); that.emit("init", message, response); } else { reply(proto.writeInit(message.id)); } }
[ "function", "(", "message", ")", "{", "if", "(", "that", ".", "listeners", "(", "message", ".", "verb", ")", ".", "length", ")", "{", "var", "successHandler", "=", "function", "(", "msg", ")", "{", "reply", "(", "proto", ".", "writeInit", "(", "msg",...
Handles an initialization request creating a DataResponse Object and emitting the subscribe event. If the handler is not defined, just writes an ack response. @param {Object} message the incoming request associative array @private
[ "Handles", "an", "initialization", "request", "creating", "a", "DataResponse", "Object", "and", "emitting", "the", "subscribe", "event", ".", "If", "the", "handler", "is", "not", "defined", "just", "writes", "an", "ack", "response", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L245-L258
34,462
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
function(message) { var response = new DataResponse(message, subscribe, subscribeError); if (queueSubUnsubRequest(message, response) === 1) { fireFirstSubUnsubEvent(message.itemName); } else { that.emit("subscribeInQueue", message.itemName); } }
javascript
function(message) { var response = new DataResponse(message, subscribe, subscribeError); if (queueSubUnsubRequest(message, response) === 1) { fireFirstSubUnsubEvent(message.itemName); } else { that.emit("subscribeInQueue", message.itemName); } }
[ "function", "(", "message", ")", "{", "var", "response", "=", "new", "DataResponse", "(", "message", ",", "subscribe", ",", "subscribeError", ")", ";", "if", "(", "queueSubUnsubRequest", "(", "message", ",", "response", ")", "===", "1", ")", "{", "fireFirs...
Handles a subscribe request creating a DataResponse Object and emitting the subscribe event. @param {Object} message the incoming request associative array @private
[ "Handles", "a", "subscribe", "request", "creating", "a", "DataResponse", "Object", "and", "emitting", "the", "subscribe", "event", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L266-L273
34,463
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
function(message) { var response = new DataResponse(message, unsubscribe, unsubscribeError); if (queueSubUnsubRequest(message, response) === 1) { fireFirstSubUnsubEvent(message.itemName); } else { that.emit("unsubscribeInQueue", message.itemName); } }
javascript
function(message) { var response = new DataResponse(message, unsubscribe, unsubscribeError); if (queueSubUnsubRequest(message, response) === 1) { fireFirstSubUnsubEvent(message.itemName); } else { that.emit("unsubscribeInQueue", message.itemName); } }
[ "function", "(", "message", ")", "{", "var", "response", "=", "new", "DataResponse", "(", "message", ",", "unsubscribe", ",", "unsubscribeError", ")", ";", "if", "(", "queueSubUnsubRequest", "(", "message", ",", "response", ")", "===", "1", ")", "{", "fire...
Handles an unsubscribe request creating a DataResponse Object and emitting the unsubscribe event. @param {Object} message the incoming request associative array @private
[ "Handles", "an", "unsubscribe", "request", "creating", "a", "DataResponse", "Object", "and", "emitting", "the", "unsubscribe", "event", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L281-L288
34,464
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
update
function update(itemName, isSnapshot, data) { var message, id = getIdFromItemName(itemName); message = proto.writeUpdate(id, itemName, isSnapshot, data); notify(message); return that; }
javascript
function update(itemName, isSnapshot, data) { var message, id = getIdFromItemName(itemName); message = proto.writeUpdate(id, itemName, isSnapshot, data); notify(message); return that; }
[ "function", "update", "(", "itemName", ",", "isSnapshot", ",", "data", ")", "{", "var", "message", ",", "id", "=", "getIdFromItemName", "(", "itemName", ")", ";", "message", "=", "proto", ".", "writeUpdate", "(", "id", ",", "itemName", ",", "isSnapshot", ...
Sends an update for a particular item to the remote LS proxy. @param {String} itemName the item name @param {Boolean} isSnapshot is it a snapshot? @param {Object} data an associative array of strings that represents the data to be published
[ "Sends", "an", "update", "for", "a", "particular", "item", "to", "the", "remote", "LS", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L299-L304
34,465
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
endOfSnapshot
function endOfSnapshot(itemName) { var message, id = getIdFromItemName(itemName); message = proto.writeEndOfSnapshot(id, itemName); notify(message); return that; }
javascript
function endOfSnapshot(itemName) { var message, id = getIdFromItemName(itemName); message = proto.writeEndOfSnapshot(id, itemName); notify(message); return that; }
[ "function", "endOfSnapshot", "(", "itemName", ")", "{", "var", "message", ",", "id", "=", "getIdFromItemName", "(", "itemName", ")", ";", "message", "=", "proto", ".", "writeEndOfSnapshot", "(", "id", ",", "itemName", ")", ";", "notify", "(", "message", ")...
Sends an end of snapshot message for a particular item to the remote LS proxy. @param {String} itemName the item name
[ "Sends", "an", "end", "of", "snapshot", "message", "for", "a", "particular", "item", "to", "the", "remote", "LS", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L311-L316
34,466
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
clearSnapshot
function clearSnapshot(itemName) { var message, id = getIdFromItemName(itemName); message = proto.writeClearSnapshot(id, itemName); notify(message); return that; }
javascript
function clearSnapshot(itemName) { var message, id = getIdFromItemName(itemName); message = proto.writeClearSnapshot(id, itemName); notify(message); return that; }
[ "function", "clearSnapshot", "(", "itemName", ")", "{", "var", "message", ",", "id", "=", "getIdFromItemName", "(", "itemName", ")", ";", "message", "=", "proto", ".", "writeClearSnapshot", "(", "id", ",", "itemName", ")", ";", "notify", "(", "message", ")...
Sends a clear snapshot message for a particular item to the remote LS proxy. @param {String} itemName the item name
[ "Sends", "a", "clear", "snapshot", "message", "for", "a", "particular", "item", "to", "the", "remote", "LS", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L323-L328
34,467
Lightstreamer/Lightstreamer-lib-node-adapter
lib/dataprovider.js
failure
function failure(exception) { var message; message = proto.writeFailure(exception); notify(message); return that; }
javascript
function failure(exception) { var message; message = proto.writeFailure(exception); notify(message); return that; }
[ "function", "failure", "(", "exception", ")", "{", "var", "message", ";", "message", "=", "proto", ".", "writeFailure", "(", "exception", ")", ";", "notify", "(", "message", ")", ";", "return", "that", ";", "}" ]
Sends a failure message to the remote LS proxy. @param {String} exception the exception message
[ "Sends", "a", "failure", "message", "to", "the", "remote", "LS", "proxy", "." ]
5fa5dbf983e169b7b0204eaa360c0d1c446d9b00
https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/dataprovider.js#L335-L340
34,468
MeldCE/json-crud
src/spec/unit/common.js
function (array1, array2) { if (array1.length !== array2.length) { return false; } // Clone the second array array2 = array2.concat(); let i; for (i = 0; i < array1.length; i++) { let index = array2.indexOf(array1[i]); if (index === -1) { return false; } array2.splice(index, 1); } if (array2.length === 0) { return true; } return false; }
javascript
function (array1, array2) { if (array1.length !== array2.length) { return false; } // Clone the second array array2 = array2.concat(); let i; for (i = 0; i < array1.length; i++) { let index = array2.indexOf(array1[i]); if (index === -1) { return false; } array2.splice(index, 1); } if (array2.length === 0) { return true; } return false; }
[ "function", "(", "array1", ",", "array2", ")", "{", "if", "(", "array1", ".", "length", "!==", "array2", ".", "length", ")", "{", "return", "false", ";", "}", "// Clone the second array", "array2", "=", "array2", ".", "concat", "(", ")", ";", "let", "i...
Checks if two arrays have the same values in them, not worrying about order @param array1 First array to check @param array2 Second array to check @returns {boolean} True is the arrays contain the same values
[ "Checks", "if", "two", "arrays", "have", "the", "same", "values", "in", "them", "not", "worrying", "about", "order" ]
524d0f95dc72b73db4c4571fc03a4d2b30676057
https://github.com/MeldCE/json-crud/blob/524d0f95dc72b73db4c4571fc03a4d2b30676057/src/spec/unit/common.js#L13-L38
34,469
jiahaog/Revenant
lib/actions.js
changeDropdownIndex
function changeDropdownIndex(page, ph, selectorAndIndex, callback) { page.evaluate(function (selectorAndIndex) { try { var selector = selectorAndIndex[0]; var index = selectorAndIndex[1]; var element = document.querySelector(selector); element.selectedIndex = index; // event is needed because listeners to the change do not react to // programmatic changes var event = document.createEvent('Event'); event.initEvent('change', true, false); element.dispatchEvent(event); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndIndex); }
javascript
function changeDropdownIndex(page, ph, selectorAndIndex, callback) { page.evaluate(function (selectorAndIndex) { try { var selector = selectorAndIndex[0]; var index = selectorAndIndex[1]; var element = document.querySelector(selector); element.selectedIndex = index; // event is needed because listeners to the change do not react to // programmatic changes var event = document.createEvent('Event'); event.initEvent('change', true, false); element.dispatchEvent(event); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndIndex); }
[ "function", "changeDropdownIndex", "(", "page", ",", "ph", ",", "selectorAndIndex", ",", "callback", ")", "{", "page", ".", "evaluate", "(", "function", "(", "selectorAndIndex", ")", "{", "try", "{", "var", "selector", "=", "selectorAndIndex", "[", "0", "]",...
Change the dropdown index of a dropdown box @param page @param ph @param {array} selectorAndIndex index 0 - selector index 1 - value @param {pageCallback} callback
[ "Change", "the", "dropdown", "index", "of", "a", "dropdown", "box" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/actions.js#L16-L42
34,470
jiahaog/Revenant
lib/actions.js
clickElement
function clickElement(page, ph, selectorAndOptions, callback) { var selector = selectorAndOptions[0]; var options = selectorAndOptions[1]; function clickSelector(selector) { try { var button = document.querySelector(selector); var ev = document.createEvent("MouseEvent"); ev.initMouseEvent( "click", true /* bubble */, true /* cancelable */, window, null, 0, 0, 0, 0, /* coordinates */ false, false, false, false, /* modifier keys */ 0 /*left*/, null ); button.dispatchEvent(ev); } catch (error) { return error } } var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(clickSelector, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } checks.ajaxCallback(page, ph, oldUrl, options, callback); }, selector); } ], function (error, page, ph) { callback(error, page, ph); }); }
javascript
function clickElement(page, ph, selectorAndOptions, callback) { var selector = selectorAndOptions[0]; var options = selectorAndOptions[1]; function clickSelector(selector) { try { var button = document.querySelector(selector); var ev = document.createEvent("MouseEvent"); ev.initMouseEvent( "click", true /* bubble */, true /* cancelable */, window, null, 0, 0, 0, 0, /* coordinates */ false, false, false, false, /* modifier keys */ 0 /*left*/, null ); button.dispatchEvent(ev); } catch (error) { return error } } var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(clickSelector, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } checks.ajaxCallback(page, ph, oldUrl, options, callback); }, selector); } ], function (error, page, ph) { callback(error, page, ph); }); }
[ "function", "clickElement", "(", "page", ",", "ph", ",", "selectorAndOptions", ",", "callback", ")", "{", "var", "selector", "=", "selectorAndOptions", "[", "0", "]", ";", "var", "options", "=", "selectorAndOptions", "[", "1", "]", ";", "function", "clickSel...
Clicks a css selector on the page @param page @param ph @param {array} selectorAndOptions Index 0 - {string} selector CSS Selector Index 1 - {int} options 0 – callback immediately 1 – expect ajax, callback when the dom changes 2 – expect page navigation, callback when the url changes and document is ready @param {pageCallback} callback
[ "Clicks", "a", "css", "selector", "on", "the", "page" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/actions.js#L55-L101
34,471
jiahaog/Revenant
lib/actions.js
setCheckboxState
function setCheckboxState(page, ph, selectorAndState, callback) { page.evaluate(function (selectorAndState) { try { var selector = selectorAndState[0]; var state = selectorAndState[1]; var element = document.querySelector(selector); element.checked = state; // event is needed because listeners to the change do not react to // programmatic changes var event = document.createEvent('Event'); event.initEvent('change', true, false); element.dispatchEvent(event); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndState); }
javascript
function setCheckboxState(page, ph, selectorAndState, callback) { page.evaluate(function (selectorAndState) { try { var selector = selectorAndState[0]; var state = selectorAndState[1]; var element = document.querySelector(selector); element.checked = state; // event is needed because listeners to the change do not react to // programmatic changes var event = document.createEvent('Event'); event.initEvent('change', true, false); element.dispatchEvent(event); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndState); }
[ "function", "setCheckboxState", "(", "page", ",", "ph", ",", "selectorAndState", ",", "callback", ")", "{", "page", ".", "evaluate", "(", "function", "(", "selectorAndState", ")", "{", "try", "{", "var", "selector", "=", "selectorAndState", "[", "0", "]", ...
Sets the state of a checkbox @param page @param ph @param {Array} selectorAndState index 0 - {string} selector index 1 - {boolean} state @param {pageCallback} callback
[ "Sets", "the", "state", "of", "a", "checkbox" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/actions.js#L111-L136
34,472
jiahaog/Revenant
lib/actions.js
fillForm
function fillForm(page, ph, selectorAndValue, callback) { page.evaluate(function (selectorAndValue) { try { var selector = selectorAndValue[0]; var value = selectorAndValue[1]; document.querySelector(selector).value = value; return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndValue); }
javascript
function fillForm(page, ph, selectorAndValue, callback) { page.evaluate(function (selectorAndValue) { try { var selector = selectorAndValue[0]; var value = selectorAndValue[1]; document.querySelector(selector).value = value; return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error, page, ph); return; } callback(null, page, ph); }, selectorAndValue); }
[ "function", "fillForm", "(", "page", ",", "ph", ",", "selectorAndValue", ",", "callback", ")", "{", "page", ".", "evaluate", "(", "function", "(", "selectorAndValue", ")", "{", "try", "{", "var", "selector", "=", "selectorAndValue", "[", "0", "]", ";", "...
Fills a form on the page @param page @param ph @param {Array} selectorAndValue index 0 - {string} selector index 1 - {string} value @param {pageCallback} callback
[ "Fills", "a", "form", "on", "the", "page" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/actions.js#L146-L164
34,473
jiahaog/Revenant
lib/actions.js
submitForm
function submitForm(page, ph, callback) { var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(function () { try { document.forms[0].submit(); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error); return; } callback() }); }, function (callback) { checks.pageHasChanged(page, oldUrl, function (error) { callback(error); }); } ], function (error) { callback(error, page, ph); }); }
javascript
function submitForm(page, ph, callback) { var oldUrl; async.waterfall([ function (callback) { page.get('url', function (url) { oldUrl = url; callback(); }); }, function (callback) { page.evaluate(function () { try { document.forms[0].submit(); return null; } catch (error) { return error; } }, function (error) { // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph); if (error) { callback(error); return; } callback() }); }, function (callback) { checks.pageHasChanged(page, oldUrl, function (error) { callback(error); }); } ], function (error) { callback(error, page, ph); }); }
[ "function", "submitForm", "(", "page", ",", "ph", ",", "callback", ")", "{", "var", "oldUrl", ";", "async", ".", "waterfall", "(", "[", "function", "(", "callback", ")", "{", "page", ".", "get", "(", "'url'", ",", "function", "(", "url", ")", "{", ...
Submits a form on the page @param page @param ph @param {pageCallback} callback
[ "Submits", "a", "form", "on", "the", "page" ]
562dd4e7a6bacb9c8b51c1344a5e336545177516
https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/actions.js#L172-L205
34,474
jaruba/multipass-torrent
stremio-addon/addon.js
validate
function validate(args) { var meta = args.query; if (! (args.query || args.infoHash)) return { code: 0, message: "query/infoHash required" }; if (meta && !meta.imdb_id) return { code: 1, message: "imdb_id required" }; if (meta && (meta.type == "series" && !(meta.hasOwnProperty("episode") && meta.hasOwnProperty("season")))) return { code: 2, message: "season and episode required for series type" }; return false; }
javascript
function validate(args) { var meta = args.query; if (! (args.query || args.infoHash)) return { code: 0, message: "query/infoHash required" }; if (meta && !meta.imdb_id) return { code: 1, message: "imdb_id required" }; if (meta && (meta.type == "series" && !(meta.hasOwnProperty("episode") && meta.hasOwnProperty("season")))) return { code: 2, message: "season and episode required for series type" }; return false; }
[ "function", "validate", "(", "args", ")", "{", "var", "meta", "=", "args", ".", "query", ";", "if", "(", "!", "(", "args", ".", "query", "||", "args", ".", "infoHash", ")", ")", "return", "{", "code", ":", "0", ",", "message", ":", "\"query/infoHas...
Basic validation of args
[ "Basic", "validation", "of", "args" ]
3cfa821760d956d3d104af04365c2a9d85226a9f
https://github.com/jaruba/multipass-torrent/blob/3cfa821760d956d3d104af04365c2a9d85226a9f/stremio-addon/addon.js#L64-L71
34,475
Blackening999/passport-linkedin-token-oauth2
lib/passport-linkedin-token-oauth2/strategy.js
LinkedinTokenStrategy
function LinkedinTokenStrategy(options, verify) { options = options || {} options.authorizationURL = options.authorizationURL || 'https://www.linkedin.com'; options.tokenURL = options.tokenURL || 'https://www.linkedin.com/uas/oauth2/accessToken'; options.scopeSeparator = options.scopeSeparator || ','; this._passReqToCallback = options.passReqToCallback; OAuth2Strategy.call(this, options, verify); this.profileUrl = options.profileURL || 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,public-profile-url)?format=json'; this.name = 'linkedin-token'; }
javascript
function LinkedinTokenStrategy(options, verify) { options = options || {} options.authorizationURL = options.authorizationURL || 'https://www.linkedin.com'; options.tokenURL = options.tokenURL || 'https://www.linkedin.com/uas/oauth2/accessToken'; options.scopeSeparator = options.scopeSeparator || ','; this._passReqToCallback = options.passReqToCallback; OAuth2Strategy.call(this, options, verify); this.profileUrl = options.profileURL || 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,public-profile-url)?format=json'; this.name = 'linkedin-token'; }
[ "function", "LinkedinTokenStrategy", "(", "options", ",", "verify", ")", "{", "options", "=", "options", "||", "{", "}", "options", ".", "authorizationURL", "=", "options", ".", "authorizationURL", "||", "'https://www.linkedin.com'", ";", "options", ".", "tokenURL...
`LinkedinTokenStrategy` constructor. The Linkedin authentication strategy authenticates requests by delegating to Linkedin using the OAuth 2.0 protocol. And accepts only access_tokens. Specialy designed for client-side flow (implicit grant flow) Applications must supply a `verify` callback which accepts an `accessToken`, `refreshToken` and service-specific `profile`, and then calls the `done` callback supplying a `user`, which should be set to `false` if the credentials are not valid. If an exception occured, `err` should be set. Options: - `clientID` your Linkedin application's App ID - `clientSecret` your Linkedin application's App Secret Examples: passport.use(new LinkedinTokenStrategy({ clientID: '123-456-789', clientSecret: 'shhh-its-a-secret' }, function(accessToken, refreshToken, profile, done) { User.findOrCreate(..., function (err, user) { done(err, user); }); } )); @param {Object} options @param {Function} verify @api public
[ "LinkedinTokenStrategy", "constructor", "." ]
d3d3c8bce5eaae2f8f0c962748fa3dbc03891c64
https://github.com/Blackening999/passport-linkedin-token-oauth2/blob/d3d3c8bce5eaae2f8f0c962748fa3dbc03891c64/lib/passport-linkedin-token-oauth2/strategy.js#L43-L54
34,476
SkidX/tweene
src/tween-pro.js
getProperty
function getProperty(style, name) { if(style[name] !== void 0) { return [name, style[name]]; } if(name in propertyNames) { return [propertyNames[name], style[propertyNames[name]]]; } name = name.substr(0, 1).toUpperCase() + name.substr(1); var prefixes = ['webkit', 'moz', 'ms', 'o'], fullName; for(var i = 0, end = prefixes.length; i < end; i++) { fullName = prefixes[i] + name; if(style[fullName] !== void 0) { propertyNames[name] = fullName; return [fullName, style[fullName]]; } } return [name, void 0]; }
javascript
function getProperty(style, name) { if(style[name] !== void 0) { return [name, style[name]]; } if(name in propertyNames) { return [propertyNames[name], style[propertyNames[name]]]; } name = name.substr(0, 1).toUpperCase() + name.substr(1); var prefixes = ['webkit', 'moz', 'ms', 'o'], fullName; for(var i = 0, end = prefixes.length; i < end; i++) { fullName = prefixes[i] + name; if(style[fullName] !== void 0) { propertyNames[name] = fullName; return [fullName, style[fullName]]; } } return [name, void 0]; }
[ "function", "getProperty", "(", "style", ",", "name", ")", "{", "if", "(", "style", "[", "name", "]", "!==", "void", "0", ")", "{", "return", "[", "name", ",", "style", "[", "name", "]", "]", ";", "}", "if", "(", "name", "in", "propertyNames", ")...
Get style real name and value, checking for browser prefixes if needed @param {object} style @param {string} name @returns {array} - return [realName, value]
[ "Get", "style", "real", "name", "and", "value", "checking", "for", "browser", "prefixes", "if", "needed" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tween-pro.js#L25-L47
34,477
jaredhanson/jsonb
lib/index.js
parse
function parse(str, options) { var obj = options.object || 'obj' , space = options.pretty ? 2 : 0 , space = options.spaces ? options.spaces : space , js = str; return '' + 'var ' + obj + ' = factory();\n' + (options.self ? 'var self = locals || {};\n' + js : 'with (locals || {}) {\n' + js + '\n}\n') + 'return JSON.stringify(' + obj + ', null, ' + space + ')'; }
javascript
function parse(str, options) { var obj = options.object || 'obj' , space = options.pretty ? 2 : 0 , space = options.spaces ? options.spaces : space , js = str; return '' + 'var ' + obj + ' = factory();\n' + (options.self ? 'var self = locals || {};\n' + js : 'with (locals || {}) {\n' + js + '\n}\n') + 'return JSON.stringify(' + obj + ', null, ' + space + ')'; }
[ "function", "parse", "(", "str", ",", "options", ")", "{", "var", "obj", "=", "options", ".", "object", "||", "'obj'", ",", "space", "=", "options", ".", "pretty", "?", "2", ":", "0", ",", "space", "=", "options", ".", "spaces", "?", "options", "."...
Parse the given `str` of JSON builder and return a function body. @param {String} str @param {Object} options @return {String} @api private
[ "Parse", "the", "given", "str", "of", "JSON", "builder", "and", "return", "a", "function", "body", "." ]
f629a3da2fdda115581fb70f5dc67175401e70b9
https://github.com/jaredhanson/jsonb/blob/f629a3da2fdda115581fb70f5dc67175401e70b9/lib/index.js#L65-L77
34,478
manifoldco/node-signature
lib/verifier.js
Verifier
function Verifier(givenMasterKey) { var masterKey = givenMasterKey || MASTER_KEY; if (!masterKey) { throw new errors.ValidationFailed('invalid master key'); } this.masterKey = base64url.toBuffer(masterKey); }
javascript
function Verifier(givenMasterKey) { var masterKey = givenMasterKey || MASTER_KEY; if (!masterKey) { throw new errors.ValidationFailed('invalid master key'); } this.masterKey = base64url.toBuffer(masterKey); }
[ "function", "Verifier", "(", "givenMasterKey", ")", "{", "var", "masterKey", "=", "givenMasterKey", "||", "MASTER_KEY", ";", "if", "(", "!", "masterKey", ")", "{", "throw", "new", "errors", ".", "ValidationFailed", "(", "'invalid master key'", ")", ";", "}", ...
Create a new verifier instance for the given master key @constructor @param {string} masterKey - Master key base64url string
[ "Create", "a", "new", "verifier", "instance", "for", "the", "given", "master", "key" ]
15f8cedf442f1b4cde8476b42481b69fb0972ce3
https://github.com/manifoldco/node-signature/blob/15f8cedf442f1b4cde8476b42481b69fb0972ce3/lib/verifier.js#L22-L28
34,479
SkidX/tweene
src/tweene.js
inArray
function inArray(array, search) { if(!isArray(array)) { throw 'expected an array as first param'; } if(array.indexOf) { return array.indexOf(search); } for(var i = 0, end = array.length; i < end; i++) { if(array[i] === search) { return i; } } return -1; }
javascript
function inArray(array, search) { if(!isArray(array)) { throw 'expected an array as first param'; } if(array.indexOf) { return array.indexOf(search); } for(var i = 0, end = array.length; i < end; i++) { if(array[i] === search) { return i; } } return -1; }
[ "function", "inArray", "(", "array", ",", "search", ")", "{", "if", "(", "!", "isArray", "(", "array", ")", ")", "{", "throw", "'expected an array as first param'", ";", "}", "if", "(", "array", ".", "indexOf", ")", "{", "return", "array", ".", "indexOf"...
simplified version of Array.indexOf polyfill
[ "simplified", "version", "of", "Array", ".", "indexOf", "polyfill" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L283-L303
34,480
SkidX/tweene
src/tweene.js
toArray
function toArray(args, pos) { if(pos === void 0) { pos = 0; } return Array.prototype.slice.call(args, pos); }
javascript
function toArray(args, pos) { if(pos === void 0) { pos = 0; } return Array.prototype.slice.call(args, pos); }
[ "function", "toArray", "(", "args", ",", "pos", ")", "{", "if", "(", "pos", "===", "void", "0", ")", "{", "pos", "=", "0", ";", "}", "return", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "args", ",", "pos", ")", ";", "}" ]
used to convert arguments to real array
[ "used", "to", "convert", "arguments", "to", "real", "array" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L307-L314
34,481
SkidX/tweene
src/tweene.js
convertTime
function convertTime(value, fromUnit, toUnit) { if(fromUnit != toUnit && value !== 0) { return value * (toUnit == 's'? 0.001 : 1000); } return value; }
javascript
function convertTime(value, fromUnit, toUnit) { if(fromUnit != toUnit && value !== 0) { return value * (toUnit == 's'? 0.001 : 1000); } return value; }
[ "function", "convertTime", "(", "value", ",", "fromUnit", ",", "toUnit", ")", "{", "if", "(", "fromUnit", "!=", "toUnit", "&&", "value", "!==", "0", ")", "{", "return", "value", "*", "(", "toUnit", "==", "'s'", "?", "0.001", ":", "1000", ")", ";", ...
convert time from seconds to milliseconds and vice versa @param {number} value @param {string} fromUnit - 's' | 'ms' @param {string} toUnit - 's' | 'ms' @returns {Number}
[ "convert", "time", "from", "seconds", "to", "milliseconds", "and", "vice", "versa" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L325-L332
34,482
SkidX/tweene
src/tweene.js
compoundMapping
function compoundMapping(name, value) { var parts, nameParts, prefix, suffix, dirs, values = {}, easing, i; if(isArray(value)) { value = value[0]; easing = value[1]; } else { easing = null; } parts = String(value).split(/\s+/); switch(parts.length) { case 1: parts = [parts[0], parts[0], parts[0], parts[0]]; break; case 2: parts = [parts[0], parts[1], parts[0], parts[1]]; break; case 3: parts = [parts[0], parts[1], parts[2], parts[1]]; break; } nameParts = decamelize(name).split('-'); prefix = nameParts[0]; suffix = nameParts.length > 1? nameParts[1].substr(0, 1).toUpperCase() + nameParts[1].substr(1) : ''; dirs = name == 'borderRadius'? radiusDirections : compoundDirections; for(i = 0; i < 4; i++) { values[prefix + dirs[i] + suffix] = easing? [parts[i], easing] : parts[i]; } return values; }
javascript
function compoundMapping(name, value) { var parts, nameParts, prefix, suffix, dirs, values = {}, easing, i; if(isArray(value)) { value = value[0]; easing = value[1]; } else { easing = null; } parts = String(value).split(/\s+/); switch(parts.length) { case 1: parts = [parts[0], parts[0], parts[0], parts[0]]; break; case 2: parts = [parts[0], parts[1], parts[0], parts[1]]; break; case 3: parts = [parts[0], parts[1], parts[2], parts[1]]; break; } nameParts = decamelize(name).split('-'); prefix = nameParts[0]; suffix = nameParts.length > 1? nameParts[1].substr(0, 1).toUpperCase() + nameParts[1].substr(1) : ''; dirs = name == 'borderRadius'? radiusDirections : compoundDirections; for(i = 0; i < 4; i++) { values[prefix + dirs[i] + suffix] = easing? [parts[i], easing] : parts[i]; } return values; }
[ "function", "compoundMapping", "(", "name", ",", "value", ")", "{", "var", "parts", ",", "nameParts", ",", "prefix", ",", "suffix", ",", "dirs", ",", "values", "=", "{", "}", ",", "easing", ",", "i", ";", "if", "(", "isArray", "(", "value", ")", ")...
take as input compound properties defined as a space separated string of values and return the list of single value properties padding: 5 => paddingTop: 5, paddingRight: 5, paddingBottom: 5, paddingLeft: 5 border-width: 2px 1px => borderTopWidth: 2px, borderRightWidth: 1px, borderBottomWidth: 2px, borderLeftWidth: 1px @param {string} name @param {string} value @returns {object}
[ "take", "as", "input", "compound", "properties", "defined", "as", "a", "space", "separated", "string", "of", "values", "and", "return", "the", "list", "of", "single", "value", "properties" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L386-L419
34,483
SkidX/tweene
src/tweene.js
transformMapping
function transformMapping(name, value) { var easing, dirs = ['X', 'Y', 'Z'], values = {}, parts, baseName; if(isArray(value)) { value = value[0]; easing = value[1]; } else { easing = null; } parts = String(value).split(/\s*,\s*/); baseName = name.indexOf('3') !== -1? name.substr(0, name.length - 2) : name; if(name == 'rotate3d') { if(parts.length == 4) { dirs = [parts[0] == '1'? 'X' : (parts[1] == '1'? 'Y' : 'Z')]; parts[0] = parts[3]; } else { throw 'invalid rotate 3d value'; } } else { switch(parts.length) { // for rotations, a single value is passed as Z-value, while for other transforms it is applied to X and Y case 1: parts = baseName == 'rotate' || baseName == 'rotation'? [null, null, parts[0]] : [parts[0], parts[0], null]; break; case 2: parts = [parts[0], parts[1], null]; break; } } for(var i = 0; i < dirs.length; i++) { if(parts[i] !== null) { values[baseName + dirs[i]] = easing? [parts[i], easing] : parts[i]; } } return values; }
javascript
function transformMapping(name, value) { var easing, dirs = ['X', 'Y', 'Z'], values = {}, parts, baseName; if(isArray(value)) { value = value[0]; easing = value[1]; } else { easing = null; } parts = String(value).split(/\s*,\s*/); baseName = name.indexOf('3') !== -1? name.substr(0, name.length - 2) : name; if(name == 'rotate3d') { if(parts.length == 4) { dirs = [parts[0] == '1'? 'X' : (parts[1] == '1'? 'Y' : 'Z')]; parts[0] = parts[3]; } else { throw 'invalid rotate 3d value'; } } else { switch(parts.length) { // for rotations, a single value is passed as Z-value, while for other transforms it is applied to X and Y case 1: parts = baseName == 'rotate' || baseName == 'rotation'? [null, null, parts[0]] : [parts[0], parts[0], null]; break; case 2: parts = [parts[0], parts[1], null]; break; } } for(var i = 0; i < dirs.length; i++) { if(parts[i] !== null) { values[baseName + dirs[i]] = easing? [parts[i], easing] : parts[i]; } } return values; }
[ "function", "transformMapping", "(", "name", ",", "value", ")", "{", "var", "easing", ",", "dirs", "=", "[", "'X'", ",", "'Y'", ",", "'Z'", "]", ",", "values", "=", "{", "}", ",", "parts", ",", "baseName", ";", "if", "(", "isArray", "(", "value", ...
split commpound transform values scale: 1.2 => scaleX: 1.2, scaleY: 1.2 rotate3d: 30, 60, 40 => rotateX: 30, rotateY: 60, rotateZ: 40 @param {string} name @param {string} value @returns {object}
[ "split", "commpound", "transform", "values" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L432-L484
34,484
SkidX/tweene
src/tweene.js
parseSpeed
function parseSpeed(value) { if(value in speeds) { value = speeds[value]; } value = parseFloat(value); if(isNaN(value) || !value || value <= 0) { value = 1; } return value; }
javascript
function parseSpeed(value) { if(value in speeds) { value = speeds[value]; } value = parseFloat(value); if(isNaN(value) || !value || value <= 0) { value = 1; } return value; }
[ "function", "parseSpeed", "(", "value", ")", "{", "if", "(", "value", "in", "speeds", ")", "{", "value", "=", "speeds", "[", "value", "]", ";", "}", "value", "=", "parseFloat", "(", "value", ")", ";", "if", "(", "isNaN", "(", "value", ")", "||", ...
accept a speed name shortcuts or a number and give back an acceptable positive value. Fallback to 1 if value is out of valid range @param {string|number} value @returns {number}
[ "accept", "a", "speed", "name", "shortcuts", "or", "a", "number", "and", "give", "back", "an", "acceptable", "positive", "value", ".", "Fallback", "to", "1", "if", "value", "is", "out", "of", "valid", "range" ]
86f941f7b3f3cff566f90ebb570b674fc640488b
https://github.com/SkidX/tweene/blob/86f941f7b3f3cff566f90ebb570b674fc640488b/src/tweene.js#L517-L530
34,485
hyperstart/hyperapp-devtools
dist/hyperapp-devtools.es.js
get
function get(target, path) { var result = target; for (var i = 0; i < path.length; i++) { result = result ? result[path[i]] : result; } return result; }
javascript
function get(target, path) { var result = target; for (var i = 0; i < path.length; i++) { result = result ? result[path[i]] : result; } return result; }
[ "function", "get", "(", "target", ",", "path", ")", "{", "var", "result", "=", "target", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "path", ".", "length", ";", "i", "++", ")", "{", "result", "=", "result", "?", "result", "[", "path",...
Get the value at the given path in the given target, or undefined if path doesn't exists.
[ "Get", "the", "value", "at", "the", "given", "path", "in", "the", "given", "target", "or", "undefined", "if", "path", "doesn", "t", "exists", "." ]
08abd1ad56fd7719bcb967c204881150ba07be70
https://github.com/hyperstart/hyperapp-devtools/blob/08abd1ad56fd7719bcb967c204881150ba07be70/dist/hyperapp-devtools.es.js#L810-L816
34,486
jrburke/adapt-pkg-main
index.js
findOneJsInArray
function findOneJsInArray(ary) { var found, count = 0; ary.forEach(function(entry) { if (jsExtRegExp.test(entry)) { count += 1; found = entry; } }); return count === 1 ? found : null; }
javascript
function findOneJsInArray(ary) { var found, count = 0; ary.forEach(function(entry) { if (jsExtRegExp.test(entry)) { count += 1; found = entry; } }); return count === 1 ? found : null; }
[ "function", "findOneJsInArray", "(", "ary", ")", "{", "var", "found", ",", "count", "=", "0", ";", "ary", ".", "forEach", "(", "function", "(", "entry", ")", "{", "if", "(", "jsExtRegExp", ".", "test", "(", "entry", ")", ")", "{", "count", "+=", "1...
Given an array of file paths, only return a value if there is only one that ends in a .js extension.
[ "Given", "an", "array", "of", "file", "paths", "only", "return", "a", "value", "if", "there", "is", "only", "one", "that", "ends", "in", "a", ".", "js", "extension", "." ]
fe5e208ec3c61f0efee2593ecd3d9107935490ff
https://github.com/jrburke/adapt-pkg-main/blob/fe5e208ec3c61f0efee2593ecd3d9107935490ff/index.js#L43-L54
34,487
manifoldco/node-signature
lib/errors.js
InvalidSignature
function InvalidSignature(reason) { Error.captureStackTrace(this, this.constructor); this.type = 'unauthorized'; this.statusCode = 401; this.message = 'Invalid request signature'; this.reason = reason; }
javascript
function InvalidSignature(reason) { Error.captureStackTrace(this, this.constructor); this.type = 'unauthorized'; this.statusCode = 401; this.message = 'Invalid request signature'; this.reason = reason; }
[ "function", "InvalidSignature", "(", "reason", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "this", ".", "constructor", ")", ";", "this", ".", "type", "=", "'unauthorized'", ";", "this", ".", "statusCode", "=", "401", ";", "this", ".", ...
InvalidSignature returns the proper status code and type
[ "InvalidSignature", "returns", "the", "proper", "status", "code", "and", "type" ]
15f8cedf442f1b4cde8476b42481b69fb0972ce3
https://github.com/manifoldco/node-signature/blob/15f8cedf442f1b4cde8476b42481b69fb0972ce3/lib/errors.js#L9-L15
34,488
manifoldco/node-signature
lib/errors.js
ValidationFailed
function ValidationFailed(reason) { Error.captureStackTrace(this, this.constructor); this.type = 'bad_request'; this.statusCode = 400; this.message = 'Request validation failed'; this.reason = reason; }
javascript
function ValidationFailed(reason) { Error.captureStackTrace(this, this.constructor); this.type = 'bad_request'; this.statusCode = 400; this.message = 'Request validation failed'; this.reason = reason; }
[ "function", "ValidationFailed", "(", "reason", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "this", ".", "constructor", ")", ";", "this", ".", "type", "=", "'bad_request'", ";", "this", ".", "statusCode", "=", "400", ";", "this", ".", "...
ValidationFailed returns the proper status code and type
[ "ValidationFailed", "returns", "the", "proper", "status", "code", "and", "type" ]
15f8cedf442f1b4cde8476b42481b69fb0972ce3
https://github.com/manifoldco/node-signature/blob/15f8cedf442f1b4cde8476b42481b69fb0972ce3/lib/errors.js#L23-L29
34,489
manifoldco/node-signature
lib/signature.js
Signature
function Signature(req, buf) { this.req = req; this.rawBody = buf || req.rawBody; this.xSignature = (req.headers['x-signature'] || '').split(' '); this.signature = base64url.toBuffer(this.xSignature[0] || ''); this.publicKey = base64url.toBuffer(this.xSignature[1] || ''); this.endorsement = base64url.toBuffer(this.xSignature[2] || ''); this.date = Date.parse(req.headers.date); }
javascript
function Signature(req, buf) { this.req = req; this.rawBody = buf || req.rawBody; this.xSignature = (req.headers['x-signature'] || '').split(' '); this.signature = base64url.toBuffer(this.xSignature[0] || ''); this.publicKey = base64url.toBuffer(this.xSignature[1] || ''); this.endorsement = base64url.toBuffer(this.xSignature[2] || ''); this.date = Date.parse(req.headers.date); }
[ "function", "Signature", "(", "req", ",", "buf", ")", "{", "this", ".", "req", "=", "req", ";", "this", ".", "rawBody", "=", "buf", "||", "req", ".", "rawBody", ";", "this", ".", "xSignature", "=", "(", "req", ".", "headers", "[", "'x-signature'", ...
5 minutes Create a new signature instance for the given request @constructor @param {object} req - Request object
[ "5", "minutes", "Create", "a", "new", "signature", "instance", "for", "the", "given", "request" ]
15f8cedf442f1b4cde8476b42481b69fb0972ce3
https://github.com/manifoldco/node-signature/blob/15f8cedf442f1b4cde8476b42481b69fb0972ce3/lib/signature.js#L22-L32
34,490
olalonde/proof-of-solvency
lib/index.js
function (cb) { get(SOLVENCY_SERVER + domain, function (roots) { roots = roots || []; roots.forEach(function (root) { files.push({ path: 'root', type: 'root', content: root }); }); cb(); }); }
javascript
function (cb) { get(SOLVENCY_SERVER + domain, function (roots) { roots = roots || []; roots.forEach(function (root) { files.push({ path: 'root', type: 'root', content: root }); }); cb(); }); }
[ "function", "(", "cb", ")", "{", "get", "(", "SOLVENCY_SERVER", "+", "domain", ",", "function", "(", "roots", ")", "{", "roots", "=", "roots", "||", "[", "]", ";", "roots", ".", "forEach", "(", "function", "(", "root", ")", "{", "files", ".", "push...
Fetch liability roots using solvency server The server is used as a proxy to make sure we don't get served custom root.
[ "Fetch", "liability", "roots", "using", "solvency", "server", "The", "server", "is", "used", "as", "a", "proxy", "to", "make", "sure", "we", "don", "t", "get", "served", "custom", "root", "." ]
d7ee19075eac3b523b9fe5f463e147811d57231c
https://github.com/olalonde/proof-of-solvency/blob/d7ee19075eac3b523b9fe5f463e147811d57231c/lib/index.js#L70-L78
34,491
olalonde/proof-of-solvency
lib/index.js
function (cb) { files.forEach(function (file) { var proof = file.content; if (!proof) return; if (!proof.id) { errors.push(file.path + ' has no ID property.'); return; } res[proof.id] = res[proof.id] || {}; res[proof.id][file.type] = proof; }); cb(); }
javascript
function (cb) { files.forEach(function (file) { var proof = file.content; if (!proof) return; if (!proof.id) { errors.push(file.path + ' has no ID property.'); return; } res[proof.id] = res[proof.id] || {}; res[proof.id][file.type] = proof; }); cb(); }
[ "function", "(", "cb", ")", "{", "files", ".", "forEach", "(", "function", "(", "file", ")", "{", "var", "proof", "=", "file", ".", "content", ";", "if", "(", "!", "proof", ")", "return", ";", "if", "(", "!", "proof", ".", "id", ")", "{", "erro...
Group files by ID and set on result
[ "Group", "files", "by", "ID", "and", "set", "on", "result" ]
d7ee19075eac3b523b9fe5f463e147811d57231c
https://github.com/olalonde/proof-of-solvency/blob/d7ee19075eac3b523b9fe5f463e147811d57231c/lib/index.js#L80-L92
34,492
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
throttle
function throttle(fn, timeout) { var timer = null; return function () { if (!timer) { timer = setTimeout(function() { fn(); timer = null; }, timeout); } }; }
javascript
function throttle(fn, timeout) { var timer = null; return function () { if (!timer) { timer = setTimeout(function() { fn(); timer = null; }, timeout); } }; }
[ "function", "throttle", "(", "fn", ",", "timeout", ")", "{", "var", "timer", "=", "null", ";", "return", "function", "(", ")", "{", "if", "(", "!", "timer", ")", "{", "timer", "=", "setTimeout", "(", "function", "(", ")", "{", "fn", "(", ")", ";"...
Throttles a function and delays its executiong, so it's only called at most once within a given time period. @param {Function} fn The function to throttle. @param {number} timeout The amount of time that must pass before the function can be called again. @return {Function} The throttled function.
[ "Throttles", "a", "function", "and", "delays", "its", "executiong", "so", "it", "s", "only", "called", "at", "most", "once", "within", "a", "given", "time", "period", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L556-L566
34,493
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
addEvent
function addEvent(node, event, fn, opt_useCapture) { if (typeof node.addEventListener == 'function') { node.addEventListener(event, fn, opt_useCapture || false); } else if (typeof node.attachEvent == 'function') { node.attachEvent('on' + event, fn); } }
javascript
function addEvent(node, event, fn, opt_useCapture) { if (typeof node.addEventListener == 'function') { node.addEventListener(event, fn, opt_useCapture || false); } else if (typeof node.attachEvent == 'function') { node.attachEvent('on' + event, fn); } }
[ "function", "addEvent", "(", "node", ",", "event", ",", "fn", ",", "opt_useCapture", ")", "{", "if", "(", "typeof", "node", ".", "addEventListener", "==", "'function'", ")", "{", "node", ".", "addEventListener", "(", "event", ",", "fn", ",", "opt_useCaptur...
Adds an event handler to a DOM node ensuring cross-browser compatibility. @param {Node} node The DOM node to add the event handler to. @param {string} event The event name. @param {Function} fn The event handler to add. @param {boolean} opt_useCapture Optionally adds the even to the capture phase. Note: this only works in modern browsers.
[ "Adds", "an", "event", "handler", "to", "a", "DOM", "node", "ensuring", "cross", "-", "browser", "compatibility", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L577-L584
34,494
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
removeEvent
function removeEvent(node, event, fn, opt_useCapture) { if (typeof node.removeEventListener == 'function') { node.removeEventListener(event, fn, opt_useCapture || false); } else if (typeof node.detatchEvent == 'function') { node.detatchEvent('on' + event, fn); } }
javascript
function removeEvent(node, event, fn, opt_useCapture) { if (typeof node.removeEventListener == 'function') { node.removeEventListener(event, fn, opt_useCapture || false); } else if (typeof node.detatchEvent == 'function') { node.detatchEvent('on' + event, fn); } }
[ "function", "removeEvent", "(", "node", ",", "event", ",", "fn", ",", "opt_useCapture", ")", "{", "if", "(", "typeof", "node", ".", "removeEventListener", "==", "'function'", ")", "{", "node", ".", "removeEventListener", "(", "event", ",", "fn", ",", "opt_...
Removes a previously added event handler from a DOM node. @param {Node} node The DOM node to remove the event handler from. @param {string} event The event name. @param {Function} fn The event handler to remove. @param {boolean} opt_useCapture If the event handler was added with this flag set to true, it should be set to true here in order to remove it.
[ "Removes", "a", "previously", "added", "event", "handler", "from", "a", "DOM", "node", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L595-L602
34,495
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
computeRectIntersection
function computeRectIntersection(rect1, rect2) { var top = Math.max(rect1.top, rect2.top); var bottom = Math.min(rect1.bottom, rect2.bottom); var left = Math.max(rect1.left, rect2.left); var right = Math.min(rect1.right, rect2.right); var width = right - left; var height = bottom - top; return (width >= 0 && height >= 0) && { top: top, bottom: bottom, left: left, right: right, width: width, height: height }; }
javascript
function computeRectIntersection(rect1, rect2) { var top = Math.max(rect1.top, rect2.top); var bottom = Math.min(rect1.bottom, rect2.bottom); var left = Math.max(rect1.left, rect2.left); var right = Math.min(rect1.right, rect2.right); var width = right - left; var height = bottom - top; return (width >= 0 && height >= 0) && { top: top, bottom: bottom, left: left, right: right, width: width, height: height }; }
[ "function", "computeRectIntersection", "(", "rect1", ",", "rect2", ")", "{", "var", "top", "=", "Math", ".", "max", "(", "rect1", ".", "top", ",", "rect2", ".", "top", ")", ";", "var", "bottom", "=", "Math", ".", "min", "(", "rect1", ".", "bottom", ...
Returns the intersection between two rect objects. @param {Object} rect1 The first rect. @param {Object} rect2 The second rect. @return {?Object} The intersection rect or undefined if no intersection is found.
[ "Returns", "the", "intersection", "between", "two", "rect", "objects", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L612-L628
34,496
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
getBoundingClientRect
function getBoundingClientRect(el) { var rect; try { rect = el.getBoundingClientRect(); } catch (err) { // Ignore Windows 7 IE11 "Unspecified error" // https://github.com/WICG/IntersectionObserver/pull/205 } if (!rect) return getEmptyRect(); // Older IE if (!(rect.width && rect.height)) { rect = { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left, width: rect.right - rect.left, height: rect.bottom - rect.top }; } return rect; }
javascript
function getBoundingClientRect(el) { var rect; try { rect = el.getBoundingClientRect(); } catch (err) { // Ignore Windows 7 IE11 "Unspecified error" // https://github.com/WICG/IntersectionObserver/pull/205 } if (!rect) return getEmptyRect(); // Older IE if (!(rect.width && rect.height)) { rect = { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left, width: rect.right - rect.left, height: rect.bottom - rect.top }; } return rect; }
[ "function", "getBoundingClientRect", "(", "el", ")", "{", "var", "rect", ";", "try", "{", "rect", "=", "el", ".", "getBoundingClientRect", "(", ")", ";", "}", "catch", "(", "err", ")", "{", "// Ignore Windows 7 IE11 \"Unspecified error\"", "// https://github.com/W...
Shims the native getBoundingClientRect for compatibility with older IE. @param {Element} el The element whose bounding rect to get. @return {Object} The (possibly shimmed) rect of the element.
[ "Shims", "the", "native", "getBoundingClientRect", "for", "compatibility", "with", "older", "IE", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L636-L660
34,497
wildhaber/gluebert
src/polyfills/resources/IntersectionObserverPolyfill.js
getParentNode
function getParentNode(node) { var parent = node.parentNode; if (parent && parent.nodeType == 11 && parent.host) { // If the parent is a shadow root, return the host element. return parent.host; } return parent; }
javascript
function getParentNode(node) { var parent = node.parentNode; if (parent && parent.nodeType == 11 && parent.host) { // If the parent is a shadow root, return the host element. return parent.host; } return parent; }
[ "function", "getParentNode", "(", "node", ")", "{", "var", "parent", "=", "node", ".", "parentNode", ";", "if", "(", "parent", "&&", "parent", ".", "nodeType", "==", "11", "&&", "parent", ".", "host", ")", "{", "// If the parent is a shadow root, return the ho...
Gets the parent node of an element or its host element if the parent node is a shadow root. @param {Node} node The node whose parent to get. @return {Node|null} The parent node or null if no parent exists.
[ "Gets", "the", "parent", "node", "of", "an", "element", "or", "its", "host", "element", "if", "the", "parent", "node", "is", "a", "shadow", "root", "." ]
b17d38a69fd006f22d5864ce27caa85a012ca4dd
https://github.com/wildhaber/gluebert/blob/b17d38a69fd006f22d5864ce27caa85a012ca4dd/src/polyfills/resources/IntersectionObserverPolyfill.js#L703-L711
34,498
TeaEntityLab/fpEs
fp.js
compact
function compact(list,typ) { if(arguments.length === 1) { if (Array.isArray(list)) { // if the only one param is an array return list.filter(x=>x); } else { // Curry it manually typ = list; return function (list) {return compact(list, typ)}; } } return list.filter(x=> typeof x === typeof typ); }
javascript
function compact(list,typ) { if(arguments.length === 1) { if (Array.isArray(list)) { // if the only one param is an array return list.filter(x=>x); } else { // Curry it manually typ = list; return function (list) {return compact(list, typ)}; } } return list.filter(x=> typeof x === typeof typ); }
[ "function", "compact", "(", "list", ",", "typ", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "if", "(", "Array", ".", "isArray", "(", "list", ")", ")", "{", "// if the only one param is an array", "return", "list", ".", "filter"...
Returns truthy values from an array. When typ is supplied, returns new array of specified type
[ "Returns", "truthy", "values", "from", "an", "array", ".", "When", "typ", "is", "supplied", "returns", "new", "array", "of", "specified", "type" ]
bc64fe46162583de31d340d3cb832c3e15e42f45
https://github.com/TeaEntityLab/fpEs/blob/bc64fe46162583de31d340d3cb832c3e15e42f45/fp.js#L191-L203
34,499
TeaEntityLab/fpEs
fp.js
drop
function drop(list,dropCount=1,direction="left",fn=null) { // If the first argument is not kind of `array`-like. if (!(list && Array.isArray(list))) { // Manually currying let args = arguments; return (list) => drop(list, ...args); } if(dropCount === 0 && !fn) { return Array.prototype.slice.call(list, 0) }; if(arguments.length === 1 || direction === "left") { if (!fn) { return Array.prototype.slice.call(list, +dropCount); } return (Array.prototype.slice.call(list, +dropCount)).filter(x=>fn(x)); } if(direction === "right"){ if(!fn) { return Array.prototype.slice.call(list, 0, list.length-(+dropCount)); } if(dropCount === 0) {return (Array.prototype.slice.call(list, 0)).filter(x=>fn(x))}; return (Array.prototype.slice.call(list, 0, list.length-(+dropCount))).filter(x=>fn(x)); } }
javascript
function drop(list,dropCount=1,direction="left",fn=null) { // If the first argument is not kind of `array`-like. if (!(list && Array.isArray(list))) { // Manually currying let args = arguments; return (list) => drop(list, ...args); } if(dropCount === 0 && !fn) { return Array.prototype.slice.call(list, 0) }; if(arguments.length === 1 || direction === "left") { if (!fn) { return Array.prototype.slice.call(list, +dropCount); } return (Array.prototype.slice.call(list, +dropCount)).filter(x=>fn(x)); } if(direction === "right"){ if(!fn) { return Array.prototype.slice.call(list, 0, list.length-(+dropCount)); } if(dropCount === 0) {return (Array.prototype.slice.call(list, 0)).filter(x=>fn(x))}; return (Array.prototype.slice.call(list, 0, list.length-(+dropCount))).filter(x=>fn(x)); } }
[ "function", "drop", "(", "list", ",", "dropCount", "=", "1", ",", "direction", "=", "\"left\"", ",", "fn", "=", "null", ")", "{", "// If the first argument is not kind of `array`-like.", "if", "(", "!", "(", "list", "&&", "Array", ".", "isArray", "(", "list"...
Drops specified number of values from array either through left or right. Uses passed in function to filter remaining array after values dropped. Default dropCount = 1
[ "Drops", "specified", "number", "of", "values", "from", "array", "either", "through", "left", "or", "right", ".", "Uses", "passed", "in", "function", "to", "filter", "remaining", "array", "after", "values", "dropped", ".", "Default", "dropCount", "=", "1" ]
bc64fe46162583de31d340d3cb832c3e15e42f45
https://github.com/TeaEntityLab/fpEs/blob/bc64fe46162583de31d340d3cb832c3e15e42f45/fp.js#L241-L269