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
35,000
MrSlide/parseSRT
src/parse-srt.js
lastNonEmptyLine
function lastNonEmptyLine (linesArray) { let idx = linesArray.length - 1 while (idx >= 0 && !linesArray[idx]) { idx-- } return idx }
javascript
function lastNonEmptyLine (linesArray) { let idx = linesArray.length - 1 while (idx >= 0 && !linesArray[idx]) { idx-- } return idx }
[ "function", "lastNonEmptyLine", "(", "linesArray", ")", "{", "let", "idx", "=", "linesArray", ".", "length", "-", "1", "while", "(", "idx", ">=", "0", "&&", "!", "linesArray", "[", "idx", "]", ")", "{", "idx", "--", "}", "return", "idx", "}" ]
Get the last non empty line number. @private @param {Array<String>} linesArray - All the lines. @return {Number} - The number of the last non empty line.
[ "Get", "the", "last", "non", "empty", "line", "number", "." ]
a643978ca81590496ab3e9a471256b7efe04ffe3
https://github.com/MrSlide/parseSRT/blob/a643978ca81590496ab3e9a471256b7efe04ffe3/src/parse-srt.js#L69-L77
35,001
GoblinDBRocks/GoblinDB
lib/storage/filesystem.js
writeToFile
function writeToFile(file) { if (!writeQueue[file]) { return; } // If not already saving then save, but using the object we make sure to take only // the last changes. // Truncate - https://stackoverflow.com/questions/35178903/overwrite-a-file-in-node-js fs.truncate(file, err => { const beforeSaveVersion = writeQueue[file].version; fse.outputJson(file, writeQueue[file].db, err => { // Something has been saved while the filesystem was writing to file then // save again if (beforeSaveVersion !== writeQueue[file].version) { writeToFile(file); } resolveAllWriteQueueCallbacks(file, err); delete writeQueue[file]; }); }); }
javascript
function writeToFile(file) { if (!writeQueue[file]) { return; } // If not already saving then save, but using the object we make sure to take only // the last changes. // Truncate - https://stackoverflow.com/questions/35178903/overwrite-a-file-in-node-js fs.truncate(file, err => { const beforeSaveVersion = writeQueue[file].version; fse.outputJson(file, writeQueue[file].db, err => { // Something has been saved while the filesystem was writing to file then // save again if (beforeSaveVersion !== writeQueue[file].version) { writeToFile(file); } resolveAllWriteQueueCallbacks(file, err); delete writeQueue[file]; }); }); }
[ "function", "writeToFile", "(", "file", ")", "{", "if", "(", "!", "writeQueue", "[", "file", "]", ")", "{", "return", ";", "}", "// If not already saving then save, but using the object we make sure to take only", "// the last changes.", "// Truncate - https://stackoverflow.c...
Save db data to a file from the write queue. @param {string} file File path. @returns {void} Nothing
[ "Save", "db", "data", "to", "a", "file", "from", "the", "write", "queue", "." ]
82e479396f49e5f2aa0b6bef0af91f1f187578ba
https://github.com/GoblinDBRocks/GoblinDB/blob/82e479396f49e5f2aa0b6bef0af91f1f187578ba/lib/storage/filesystem.js#L67-L88
35,002
GoblinDBRocks/GoblinDB
lib/storage/filesystem.js
resolveAllWriteQueueCallbacks
function resolveAllWriteQueueCallbacks(file, error) { writeQueue[file].callbacks.forEach(cb => cb(error)); }
javascript
function resolveAllWriteQueueCallbacks(file, error) { writeQueue[file].callbacks.forEach(cb => cb(error)); }
[ "function", "resolveAllWriteQueueCallbacks", "(", "file", ",", "error", ")", "{", "writeQueue", "[", "file", "]", ".", "callbacks", ".", "forEach", "(", "cb", "=>", "cb", "(", "error", ")", ")", ";", "}" ]
Internal. Call to every callback of a the write queue for a file. @param {string} file File path . @param {string} error Error message or null. @returns {void} Nothing.
[ "Internal", ".", "Call", "to", "every", "callback", "of", "a", "the", "write", "queue", "for", "a", "file", "." ]
82e479396f49e5f2aa0b6bef0af91f1f187578ba
https://github.com/GoblinDBRocks/GoblinDB/blob/82e479396f49e5f2aa0b6bef0af91f1f187578ba/lib/storage/filesystem.js#L120-L122
35,003
monotonee/escape-regex-string
index.js
escapeRegexString
function escapeRegexString(unescapedString, escapeCharsRegex) { // Validate arguments. if (Object.prototype.toString.call(unescapedString) !== '[object String]') { throw new TypeError('Argument 1 should be a string.'); } if (escapeCharsRegex === undefined) { escapeCharsRegex = defaultEscapeCharsRegex; } else if (Object.prototype.toString.call(escapeCharsRegex) !== '[object RegExp]') { throw new TypeError('Argument 2 should be a RegExp object.'); } // Escape the string. return unescapedString.replace(escapeCharsRegex, '\\$&'); }
javascript
function escapeRegexString(unescapedString, escapeCharsRegex) { // Validate arguments. if (Object.prototype.toString.call(unescapedString) !== '[object String]') { throw new TypeError('Argument 1 should be a string.'); } if (escapeCharsRegex === undefined) { escapeCharsRegex = defaultEscapeCharsRegex; } else if (Object.prototype.toString.call(escapeCharsRegex) !== '[object RegExp]') { throw new TypeError('Argument 2 should be a RegExp object.'); } // Escape the string. return unescapedString.replace(escapeCharsRegex, '\\$&'); }
[ "function", "escapeRegexString", "(", "unescapedString", ",", "escapeCharsRegex", ")", "{", "// Validate arguments.", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "unescapedString", ")", "!==", "'[object String]'", ")", "{", "throw", "...
Escape a string literal for use as an argument in the standard RegExp constructor. @alias module:escape-regex-string @param {string} unescapedString - The string containing a regex pattern to be escaped. @param {RegExp} [escapeCharsRegex] - An optional RegEx pattern containing a set of characters to escape. If not passed, value will be set to default. @return {string} - The escaped regex pattern string. @throws {TypeError} - Arguments must be correct type. @property {RegExp} defaultEscapeCharsRegex - A read-only property that contains the default escape character RegExp instance. The value of this property is the value used when the optional second argument is omitted in a call to {@link module:escape-regex-string}.
[ "Escape", "a", "string", "literal", "for", "use", "as", "an", "argument", "in", "the", "standard", "RegExp", "constructor", "." ]
9f46a7e4bb6b3b40bcd487005947235fdeaa84c6
https://github.com/monotonee/escape-regex-string/blob/9f46a7e4bb6b3b40bcd487005947235fdeaa84c6/index.js#L26-L39
35,004
observing/argh
index.js
parse
function parse(argv) { argv = argv || process.argv.slice(2); /** * This is where the actual parsing happens, we can use array#reduce to * iterate over the arguments and change it to an object. We can easily bail * out of the loop by destroying `argv` array. * * @param {Object} argh The object that stores the parsed arguments * @param {String} option The command line flag * @param {Number} index The position of the flag in argv's * @param {Array} argv The argument variables * @returns {Object} argh, the parsed commands * @api private */ return argv.reduce(function parser(argh, option, index, argv) { var next = argv[index + 1] , value , data; // // Special case, -- indicates that it should stop parsing the options and // store everything in a "special" key. // if (option === '--') { // // By splicing the argv array, we also cancel the reduce as there are no // more options to parse. // argh.argv = argh.argv || []; argh.argv = argh.argv.concat(argv.splice(index + 1)); return argh; } if (data = /^--?(?:no|disable)-(.*)/.exec(option)) { // // --no-<key> indicates that this is a boolean value. // insert(argh, data[1], false, option); } else if (data = /^-(?!-)(.*)/.exec(option)) { insert(argh, data[1], true, option); } else if (data = /^--([^=]+)=["']?([\s!#$%&\x28-\x7e]+)["']?$/.exec(option)) { // // --foo="bar" and --foo=bar are alternate styles to --foo bar. // insert(argh, data[1], data[2], option); } else if (data = /^--(.*)/.exec(option)) { // // Check if this was a bool argument // if (!next || next.charAt(0) === '-' || (value = /^true|false$/.test(next))) { insert(argh, data[1], value ? argv.splice(index + 1, 1)[0] : true, option); } else { value = argv.splice(index + 1, 1)[0]; insert(argh, data[1], value, option); } } else { // // This argument is not prefixed. // if (!argh.argv) argh.argv = []; argh.argv.push(option); } return argh; }, Object.create(null)); }
javascript
function parse(argv) { argv = argv || process.argv.slice(2); /** * This is where the actual parsing happens, we can use array#reduce to * iterate over the arguments and change it to an object. We can easily bail * out of the loop by destroying `argv` array. * * @param {Object} argh The object that stores the parsed arguments * @param {String} option The command line flag * @param {Number} index The position of the flag in argv's * @param {Array} argv The argument variables * @returns {Object} argh, the parsed commands * @api private */ return argv.reduce(function parser(argh, option, index, argv) { var next = argv[index + 1] , value , data; // // Special case, -- indicates that it should stop parsing the options and // store everything in a "special" key. // if (option === '--') { // // By splicing the argv array, we also cancel the reduce as there are no // more options to parse. // argh.argv = argh.argv || []; argh.argv = argh.argv.concat(argv.splice(index + 1)); return argh; } if (data = /^--?(?:no|disable)-(.*)/.exec(option)) { // // --no-<key> indicates that this is a boolean value. // insert(argh, data[1], false, option); } else if (data = /^-(?!-)(.*)/.exec(option)) { insert(argh, data[1], true, option); } else if (data = /^--([^=]+)=["']?([\s!#$%&\x28-\x7e]+)["']?$/.exec(option)) { // // --foo="bar" and --foo=bar are alternate styles to --foo bar. // insert(argh, data[1], data[2], option); } else if (data = /^--(.*)/.exec(option)) { // // Check if this was a bool argument // if (!next || next.charAt(0) === '-' || (value = /^true|false$/.test(next))) { insert(argh, data[1], value ? argv.splice(index + 1, 1)[0] : true, option); } else { value = argv.splice(index + 1, 1)[0]; insert(argh, data[1], value, option); } } else { // // This argument is not prefixed. // if (!argh.argv) argh.argv = []; argh.argv.push(option); } return argh; }, Object.create(null)); }
[ "function", "parse", "(", "argv", ")", "{", "argv", "=", "argv", "||", "process", ".", "argv", ".", "slice", "(", "2", ")", ";", "/**\n * This is where the actual parsing happens, we can use array#reduce to\n * iterate over the arguments and change it to an object. We can e...
Argv is a extremely light weight options parser for Node.js it's been built for just one single purpose, parsing arguments. It does nothing more than that. @param {Array} argv The arguments that need to be parsed, defaults to process.argv @returns {Object} Parsed arguments. @api public
[ "Argv", "is", "a", "extremely", "light", "weight", "options", "parser", "for", "Node", ".", "js", "it", "s", "been", "built", "for", "just", "one", "single", "purpose", "parsing", "arguments", ".", "It", "does", "nothing", "more", "than", "that", "." ]
74ed701a7214ad581efe3303ea65cf71998308ac
https://github.com/observing/argh/blob/74ed701a7214ad581efe3303ea65cf71998308ac/index.js#L12-L78
35,005
observing/argh
index.js
insert
function insert(argh, key, value, option) { // // Automatic value conversion. This makes sure we store the correct "type" // if ('string' === typeof value && !isNaN(+value)) value = +value; if (value === 'true' || value === 'false') value = value === 'true'; var single = option.charAt(1) !== '-' , properties = key.split('.') , position = argh; if (single && key.length > 1) return key.split('').forEach(function short(char) { insert(argh, char, value, option); }); // // We don't have any deeply nested properties, so we should just bail out // early enough so we don't have to do any processing // if (!properties.length) return argh[key] = value; while (properties.length) { var property = properties.shift(); if (properties.length) { if ('object' !== typeof position[property] && !Array.isArray(position[property])) { position[property] = Object.create(null); } } else { position[property] = value; } position = position[property]; } }
javascript
function insert(argh, key, value, option) { // // Automatic value conversion. This makes sure we store the correct "type" // if ('string' === typeof value && !isNaN(+value)) value = +value; if (value === 'true' || value === 'false') value = value === 'true'; var single = option.charAt(1) !== '-' , properties = key.split('.') , position = argh; if (single && key.length > 1) return key.split('').forEach(function short(char) { insert(argh, char, value, option); }); // // We don't have any deeply nested properties, so we should just bail out // early enough so we don't have to do any processing // if (!properties.length) return argh[key] = value; while (properties.length) { var property = properties.shift(); if (properties.length) { if ('object' !== typeof position[property] && !Array.isArray(position[property])) { position[property] = Object.create(null); } } else { position[property] = value; } position = position[property]; } }
[ "function", "insert", "(", "argh", ",", "key", ",", "value", ",", "option", ")", "{", "//", "// Automatic value conversion. This makes sure we store the correct \"type\"", "//", "if", "(", "'string'", "===", "typeof", "value", "&&", "!", "isNaN", "(", "+", "value"...
Inserts the value in the argh object @param {Object} argh The object where we store the values @param {String} key The received command line flag @param {String} value The command line flag's value @param {String} option The actual option @api private
[ "Inserts", "the", "value", "in", "the", "argh", "object" ]
74ed701a7214ad581efe3303ea65cf71998308ac
https://github.com/observing/argh/blob/74ed701a7214ad581efe3303ea65cf71998308ac/index.js#L89-L123
35,006
Clever-Labs/seo-checker
src/index.js
function(url, callback) { // Check if user input protocol if (url.indexOf('http://') < 0 && url.indexOf('https://') < 0) { // TODO: Turn this into its own function url = 'http://' + url; } // Make request and fire callback request.get(url.toLowerCase(), function(error, response, body) { if (!error && response.statusCode === 200) { return callback(body); } return callback(false); }); }
javascript
function(url, callback) { // Check if user input protocol if (url.indexOf('http://') < 0 && url.indexOf('https://') < 0) { // TODO: Turn this into its own function url = 'http://' + url; } // Make request and fire callback request.get(url.toLowerCase(), function(error, response, body) { if (!error && response.statusCode === 200) { return callback(body); } return callback(false); }); }
[ "function", "(", "url", ",", "callback", ")", "{", "// Check if user input protocol", "if", "(", "url", ".", "indexOf", "(", "'http://'", ")", "<", "0", "&&", "url", ".", "indexOf", "(", "'https://'", ")", "<", "0", ")", "{", "// TODO: Turn this into its own...
Load HTML for a single URL Use this to fetch the contents of a single URL then pass the result to the `meta` function or any other code that can parse or transform the response body of an HTTP request. `url` [String] - URL of page to read `callback` [Function] - Function to call on completion Returns the response body of an HTTP request as a string
[ "Load", "HTML", "for", "a", "single", "URL" ]
11501c9e4a90cd014dcded8961528e3948b8930e
https://github.com/Clever-Labs/seo-checker/blob/11501c9e4a90cd014dcded8961528e3948b8930e/src/index.js#L26-L40
35,007
Clever-Labs/seo-checker
src/index.js
function(body) { var $ = cheerio.load(body), page = {}; // Meta signals page.title = $('title').text() || null; page.description = $('meta[name=description]').attr('content') || null; page.author = $('meta[name=author]').attr('content') || null; page.keywords = $('meta[name=keywords]').attr('content') || null; // Heading signals var h1s = 0; $('h1').each(function() { h1s++; }); page.heading1 = $('body h1:first-child').text().trim().replace('\n', ''); page.totalHeadings = h1s; // Accessibility signals var totalImgs = 0, accessibleImgs = 0; $('img').each(function(index) { totalImgs++; if ($(this).attr('alt') || $(this).attr('title')) { accessibleImgs++; } }); page.imgAccessibility = (accessibleImgs / totalImgs) * 100; return page; }
javascript
function(body) { var $ = cheerio.load(body), page = {}; // Meta signals page.title = $('title').text() || null; page.description = $('meta[name=description]').attr('content') || null; page.author = $('meta[name=author]').attr('content') || null; page.keywords = $('meta[name=keywords]').attr('content') || null; // Heading signals var h1s = 0; $('h1').each(function() { h1s++; }); page.heading1 = $('body h1:first-child').text().trim().replace('\n', ''); page.totalHeadings = h1s; // Accessibility signals var totalImgs = 0, accessibleImgs = 0; $('img').each(function(index) { totalImgs++; if ($(this).attr('alt') || $(this).attr('title')) { accessibleImgs++; } }); page.imgAccessibility = (accessibleImgs / totalImgs) * 100; return page; }
[ "function", "(", "body", ")", "{", "var", "$", "=", "cheerio", ".", "load", "(", "body", ")", ",", "page", "=", "{", "}", ";", "// Meta signals", "page", ".", "title", "=", "$", "(", "'title'", ")", ".", "text", "(", ")", "||", "null", ";", "pa...
Parse meta data from an HTTP response body `body` [String] - The HTML of a web page to parse Returns an object containing data related to the SEO signals of the page that was parsed. Pass the result to another function to determine an "SEO score".
[ "Parse", "meta", "data", "from", "an", "HTTP", "response", "body" ]
11501c9e4a90cd014dcded8961528e3948b8930e
https://github.com/Clever-Labs/seo-checker/blob/11501c9e4a90cd014dcded8961528e3948b8930e/src/index.js#L51-L80
35,008
Clever-Labs/seo-checker
src/index.js
function(url, options, callback) { var crawler = Crawler.crawl(url.toLowerCase()), opts = options || {}, maxPages = opts.maxPages || 10, parsedPages = [], // Store parsed pages in this array seoParser = this.meta, // Reference to `meta` method to call during crawl crawlResults = []; // Store results in this array and then return it to caller // Crawler settings crawler.interval = opts.interval || 250; // Time between spooling up new requests crawler.maxDepth = opts.depth || 2; // Maximum deptch of crawl crawler.maxConcurrency = opts.concurrency || 2; // Number of processes to spawn at a time crawler.timeout = opts.timeout || 1000; // Milliseconds to wait for server to send headers crawler.downloadUnsupported = opts.unsupported || false; // Save resources by only downloading files Simple Crawler can parse // The user agent string to provide - Be cool and don't trick people crawler.userAgent = opts.useragent || 'SEO Checker v1 (https://github.com/Clever-Labs/seo-checker)'; // Only fetch HTML! You should always set this option unless you have a good reason not to if (opts.htmlOnly === true) { // Being explicit about truthy values here var htmlCondition = crawler.addFetchCondition(function(parsedURL) { return !parsedURL.path.match(/\.jpg|jpeg|png|gif|js|txt|css|pdf$/i); }); } crawler.on('fetchcomplete', function(queueItem, responseBuffer, response) { if (queueItem.stateData.code === 200) { crawlResults.push({ url: queueItem.url, body: responseBuffer.toString() }); } if (crawlResults.length >= maxPages) { this.stop(); // Stop the crawler crawlResults.forEach(function(page, index, results) { parsedPages.push({url: page.url, results: seoParser(page.body)}); }); if (!callback) { return parsedPages; } else { callback(parsedPages); } } }); }
javascript
function(url, options, callback) { var crawler = Crawler.crawl(url.toLowerCase()), opts = options || {}, maxPages = opts.maxPages || 10, parsedPages = [], // Store parsed pages in this array seoParser = this.meta, // Reference to `meta` method to call during crawl crawlResults = []; // Store results in this array and then return it to caller // Crawler settings crawler.interval = opts.interval || 250; // Time between spooling up new requests crawler.maxDepth = opts.depth || 2; // Maximum deptch of crawl crawler.maxConcurrency = opts.concurrency || 2; // Number of processes to spawn at a time crawler.timeout = opts.timeout || 1000; // Milliseconds to wait for server to send headers crawler.downloadUnsupported = opts.unsupported || false; // Save resources by only downloading files Simple Crawler can parse // The user agent string to provide - Be cool and don't trick people crawler.userAgent = opts.useragent || 'SEO Checker v1 (https://github.com/Clever-Labs/seo-checker)'; // Only fetch HTML! You should always set this option unless you have a good reason not to if (opts.htmlOnly === true) { // Being explicit about truthy values here var htmlCondition = crawler.addFetchCondition(function(parsedURL) { return !parsedURL.path.match(/\.jpg|jpeg|png|gif|js|txt|css|pdf$/i); }); } crawler.on('fetchcomplete', function(queueItem, responseBuffer, response) { if (queueItem.stateData.code === 200) { crawlResults.push({ url: queueItem.url, body: responseBuffer.toString() }); } if (crawlResults.length >= maxPages) { this.stop(); // Stop the crawler crawlResults.forEach(function(page, index, results) { parsedPages.push({url: page.url, results: seoParser(page.body)}); }); if (!callback) { return parsedPages; } else { callback(parsedPages); } } }); }
[ "function", "(", "url", ",", "options", ",", "callback", ")", "{", "var", "crawler", "=", "Crawler", ".", "crawl", "(", "url", ".", "toLowerCase", "(", ")", ")", ",", "opts", "=", "options", "||", "{", "}", ",", "maxPages", "=", "opts", ".", "maxPa...
Generate SEO data for multiple pages of a site at once `url` [String] - The URL to begin the crawl `options` [Object] - Options to pass to the crawler. Uses a subset of the `simplecrawler` lib's options: - `maxPages` [Number] - The max number of pages to crawl (defaults to 10) - `interval` [Number] - Delay between each request for a new page - `maxDepth` [Number] - Depth of crawl. See simplecrawler docs for an explanation - `maxConcurrency` [Number] - Number of processes to spawn at a time - `timeout` [Number] - Time to wait for a server response before moving on - `downloadUnsupported` [Boolean] - Determines whether crawler downloads files it cannot parse - `userAgent` [String] - The UA string to send with requests - `htmlOnly` [Boolean] - Tells crawler not to crawl any non-HTML text/html pages. This is a required option and has no default Returns an array of objects containing SEO data and URL. Example return value: [{ url: 'http://example.com/page1.html', results: { <results object identical to signature of this.meta()'s return value> } }]
[ "Generate", "SEO", "data", "for", "multiple", "pages", "of", "a", "site", "at", "once" ]
11501c9e4a90cd014dcded8961528e3948b8930e
https://github.com/Clever-Labs/seo-checker/blob/11501c9e4a90cd014dcded8961528e3948b8930e/src/index.js#L103-L143
35,009
TourCMS/node-tourcms
node-tourcms.js
apiResponded
function apiResponded(apiResponse) { // Convert XML to JS object var parser = new xml2js.Parser({explicitArray:false}); parser.parseString(apiResponse, function (err, result) { // If the method processes the response, give it back // Otherwise call the original callback if(typeof a.processor !== 'undefined') a.processor(result.response, a.callback); else a.callback(result.response); }); }
javascript
function apiResponded(apiResponse) { // Convert XML to JS object var parser = new xml2js.Parser({explicitArray:false}); parser.parseString(apiResponse, function (err, result) { // If the method processes the response, give it back // Otherwise call the original callback if(typeof a.processor !== 'undefined') a.processor(result.response, a.callback); else a.callback(result.response); }); }
[ "function", "apiResponded", "(", "apiResponse", ")", "{", "// Convert XML to JS object", "var", "parser", "=", "new", "xml2js", ".", "Parser", "(", "{", "explicitArray", ":", "false", "}", ")", ";", "parser", ".", "parseString", "(", "apiResponse", ",", "funct...
Process API response
[ "Process", "API", "response" ]
1d23ff7ba4ed6fcda5e84f2018d27129efec4978
https://github.com/TourCMS/node-tourcms/blob/1d23ff7ba4ed6fcda5e84f2018d27129efec4978/node-tourcms.js#L87-L101
35,010
Bitcoin-com/wormhole-sdk
examples/data-retrieval/token-info-from-tx/token-info-from-tx.js
getTxInfo
async function getTxInfo() { const retVal = await Wormhole.DataRetrieval.transaction(TXID) console.log(`Info from TXID ${TXID}: ${JSON.stringify(retVal, null, 2)}`) }
javascript
async function getTxInfo() { const retVal = await Wormhole.DataRetrieval.transaction(TXID) console.log(`Info from TXID ${TXID}: ${JSON.stringify(retVal, null, 2)}`) }
[ "async", "function", "getTxInfo", "(", ")", "{", "const", "retVal", "=", "await", "Wormhole", ".", "DataRetrieval", ".", "transaction", "(", "TXID", ")", "console", ".", "log", "(", "`", "${", "TXID", "}", "${", "JSON", ".", "stringify", "(", "retVal", ...
Get Token info from the TX.
[ "Get", "Token", "info", "from", "the", "TX", "." ]
13dd35295b0b3a6bb84e895f96c978cbb906193b
https://github.com/Bitcoin-com/wormhole-sdk/blob/13dd35295b0b3a6bb84e895f96c978cbb906193b/examples/data-retrieval/token-info-from-tx/token-info-from-tx.js#L20-L24
35,011
qixotic/s3-to-logstore
index.js
function(data, prefix) { prefix = prefix || ''; var row = Object.keys(data).map(function(key) { if (typeof data[key] !== 'object') { return util.format('%s%s="%s"', prefix, key, data[key]); } // Flatten this nested object. return _reformat(data[key], key + '.'); }); return row.join(' '); }
javascript
function(data, prefix) { prefix = prefix || ''; var row = Object.keys(data).map(function(key) { if (typeof data[key] !== 'object') { return util.format('%s%s="%s"', prefix, key, data[key]); } // Flatten this nested object. return _reformat(data[key], key + '.'); }); return row.join(' '); }
[ "function", "(", "data", ",", "prefix", ")", "{", "prefix", "=", "prefix", "||", "''", ";", "var", "row", "=", "Object", ".", "keys", "(", "data", ")", ".", "map", "(", "function", "(", "key", ")", "{", "if", "(", "typeof", "data", "[", "key", ...
data - json object representation of a log line. prefix - string to prefix a key with. Used in flattening nested objects. Returns a single string of concatenated key=value pairs.
[ "data", "-", "json", "object", "representation", "of", "a", "log", "line", ".", "prefix", "-", "string", "to", "prefix", "a", "key", "with", ".", "Used", "in", "flattening", "nested", "objects", ".", "Returns", "a", "single", "string", "of", "concatenated"...
5b29d237f2d9bd3f996f281488f62ccfe3f1888b
https://github.com/qixotic/s3-to-logstore/blob/5b29d237f2d9bd3f996f281488f62ccfe3f1888b/index.js#L13-L23
35,012
frank198/pomelo-upgrade
template/web-server/public/js/lib/socket.io.js
Socket
function Socket (options) { this.options = { port: 80 , secure: false , document: 'document' in global ? document : false , resource: 'socket.io' , transports: io.transports , 'connect timeout': 10000 , 'try multiple transports': true , 'reconnect': true , 'reconnection delay': 500 , 'reconnection limit': Infinity , 'reopen delay': 3000 , 'max reconnection attempts': 10 , 'sync disconnect on unload': true , 'auto connect': true , 'flash policy port': 10843 }; io.util.merge(this.options, options); this.connected = false; this.open = false; this.connecting = false; this.reconnecting = false; this.namespaces = {}; this.buffer = []; this.doBuffer = false; if (this.options['sync disconnect on unload'] && (!this.isXDomain() || io.util.ua.hasCORS)) { var self = this; io.util.on(global, 'unload', function () { self.disconnectSync(); }, false); } if (this.options['auto connect']) { this.connect(); } }
javascript
function Socket (options) { this.options = { port: 80 , secure: false , document: 'document' in global ? document : false , resource: 'socket.io' , transports: io.transports , 'connect timeout': 10000 , 'try multiple transports': true , 'reconnect': true , 'reconnection delay': 500 , 'reconnection limit': Infinity , 'reopen delay': 3000 , 'max reconnection attempts': 10 , 'sync disconnect on unload': true , 'auto connect': true , 'flash policy port': 10843 }; io.util.merge(this.options, options); this.connected = false; this.open = false; this.connecting = false; this.reconnecting = false; this.namespaces = {}; this.buffer = []; this.doBuffer = false; if (this.options['sync disconnect on unload'] && (!this.isXDomain() || io.util.ua.hasCORS)) { var self = this; io.util.on(global, 'unload', function () { self.disconnectSync(); }, false); } if (this.options['auto connect']) { this.connect(); } }
[ "function", "Socket", "(", "options", ")", "{", "this", ".", "options", "=", "{", "port", ":", "80", ",", "secure", ":", "false", ",", "document", ":", "'document'", "in", "global", "?", "document", ":", "false", ",", "resource", ":", "'socket.io'", ",...
Create a new `Socket.IO client` which can establish a persistent connection with a Socket.IO enabled server. @api public
[ "Create", "a", "new", "Socket", ".", "IO", "client", "which", "can", "establish", "a", "persistent", "connection", "with", "a", "Socket", ".", "IO", "enabled", "server", "." ]
6d56e02d0e61b3ffd05bd69a2337ec3a4ed9b0e5
https://github.com/frank198/pomelo-upgrade/blob/6d56e02d0e61b3ffd05bd69a2337ec3a4ed9b0e5/template/web-server/public/js/lib/socket.io.js#L1491-L1532
35,013
Urigo/meteor-native-packages
packages/ddp-client/stub_stream.js
function (name, callback) { var self = this; if (!self.callbacks[name]) self.callbacks[name] = [callback]; else self.callbacks[name].push(callback); }
javascript
function (name, callback) { var self = this; if (!self.callbacks[name]) self.callbacks[name] = [callback]; else self.callbacks[name].push(callback); }
[ "function", "(", "name", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "callbacks", "[", "name", "]", ")", "self", ".", "callbacks", "[", "name", "]", "=", "[", "callback", "]", ";", "else", "self", ".",...
Methods from Stream
[ "Methods", "from", "Stream" ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/stub_stream.js#L11-L18
35,014
Urigo/meteor-native-packages
packages/ddp-client/stub_stream.js
function (data) { var self = this; if (typeof data === 'object') { data = EJSON.stringify(data); } _.each(self.callbacks['message'], function (cb) { cb(data); }); }
javascript
function (data) { var self = this; if (typeof data === 'object') { data = EJSON.stringify(data); } _.each(self.callbacks['message'], function (cb) { cb(data); }); }
[ "function", "(", "data", ")", "{", "var", "self", "=", "this", ";", "if", "(", "typeof", "data", "===", "'object'", ")", "{", "data", "=", "EJSON", ".", "stringify", "(", "data", ")", ";", "}", "_", ".", "each", "(", "self", ".", "callbacks", "["...
Methods for tests
[ "Methods", "for", "tests" ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/stub_stream.js#L38-L48
35,015
Collaborne/gulp-polymer-build-utils
integrated-build.js
build
function build(config) { return lazypipe() .pipe(() => polymerBuild(config)) .pipe(() => addCspCompliance()) .pipe(() => addCacheBusting()) .pipe(() => optimizeAssets()) .pipe(() => injectCustomElementsEs5Adapter()); }
javascript
function build(config) { return lazypipe() .pipe(() => polymerBuild(config)) .pipe(() => addCspCompliance()) .pipe(() => addCacheBusting()) .pipe(() => optimizeAssets()) .pipe(() => injectCustomElementsEs5Adapter()); }
[ "function", "build", "(", "config", ")", "{", "return", "lazypipe", "(", ")", ".", "pipe", "(", "(", ")", "=>", "polymerBuild", "(", "config", ")", ")", ".", "pipe", "(", "(", ")", "=>", "addCspCompliance", "(", ")", ")", ".", "pipe", "(", "(", "...
Best practice build pipeline. This only only chains up the various build steps. @param {Object} config Content of polymer.json @return
[ "Best", "practice", "build", "pipeline", ".", "This", "only", "only", "chains", "up", "the", "various", "build", "steps", "." ]
76f83ea018f726a9e4390444deef65dbe9dde1ff
https://github.com/Collaborne/gulp-polymer-build-utils/blob/76f83ea018f726a9e4390444deef65dbe9dde1ff/integrated-build.js#L16-L23
35,016
Urigo/meteor-native-packages
packages/ddp-server/stream_server.js
function (callback) { var self = this; self.registration_callbacks.push(callback); _.each(self.all_sockets(), function (socket) { callback(socket); }); }
javascript
function (callback) { var self = this; self.registration_callbacks.push(callback); _.each(self.all_sockets(), function (socket) { callback(socket); }); }
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "self", ".", "registration_callbacks", ".", "push", "(", "callback", ")", ";", "_", ".", "each", "(", "self", ".", "all_sockets", "(", ")", ",", "function", "(", "socket", ")", "...
call my callback when a new socket connects. also call it for all current connections.
[ "call", "my", "callback", "when", "a", "new", "socket", "connects", ".", "also", "call", "it", "for", "all", "current", "connections", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/stream_server.js#L106-L112
35,017
Urigo/meteor-native-packages
packages/ddp-server/stream_server.js
function(request /*, moreArguments */) { // Store arguments for use within the closure below var args = arguments; // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while // preserving query string. var parsedUrl = url.parse(request.url); if (parsedUrl.pathname === pathPrefix + '/websocket' || parsedUrl.pathname === pathPrefix + '/websocket/') { parsedUrl.pathname = self.prefix + '/websocket'; request.url = url.format(parsedUrl); } _.each(oldHttpServerListeners, function(oldListener) { oldListener.apply(httpServer, args); }); }
javascript
function(request /*, moreArguments */) { // Store arguments for use within the closure below var args = arguments; // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while // preserving query string. var parsedUrl = url.parse(request.url); if (parsedUrl.pathname === pathPrefix + '/websocket' || parsedUrl.pathname === pathPrefix + '/websocket/') { parsedUrl.pathname = self.prefix + '/websocket'; request.url = url.format(parsedUrl); } _.each(oldHttpServerListeners, function(oldListener) { oldListener.apply(httpServer, args); }); }
[ "function", "(", "request", "/*, moreArguments */", ")", "{", "// Store arguments for use within the closure below", "var", "args", "=", "arguments", ";", "// Rewrite /websocket and /websocket/ urls to /sockjs/websocket while", "// preserving query string.", "var", "parsedUrl", "=", ...
request and upgrade have different arguments passed but we only care about the first one which is always request
[ "request", "and", "upgrade", "have", "different", "arguments", "passed", "but", "we", "only", "care", "about", "the", "first", "one", "which", "is", "always", "request" ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/stream_server.js#L136-L151
35,018
a8m/agile
dist/agile.js
add
function add(object) { var args = Array.prototype.slice.call(arguments, 1); //loop through all over the arguments forEach(args, function(value, i) { switch(typeof object) { case 'object': isArray(object) ? object.push(value) : extend(object, isObject(value) ? value : creObject(i, value)); break; case 'string': object += isString(value) ? value : ''; break; case 'number': object += isNumber(value) ? value : 0; } }); return object; }
javascript
function add(object) { var args = Array.prototype.slice.call(arguments, 1); //loop through all over the arguments forEach(args, function(value, i) { switch(typeof object) { case 'object': isArray(object) ? object.push(value) : extend(object, isObject(value) ? value : creObject(i, value)); break; case 'string': object += isString(value) ? value : ''; break; case 'number': object += isNumber(value) ? value : 0; } }); return object; }
[ "function", "add", "(", "object", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "//loop through all over the arguments", "forEach", "(", "args", ",", "function", "(", "value", ",",...
these methods is kind of common methods for chaining wrappers @description add methods get an object extend(based on type) and return it. @param object @returns {*} @example add(1,2) ==> 3 add([],1) ==> [1] add('f','g') ==> 'fg' add({}, {a:1}) ==> {a:1}
[ "these", "methods", "is", "kind", "of", "common", "methods", "for", "chaining", "wrappers" ]
fcf3f8667e44c621bcdc3065c3a03b29e16851eb
https://github.com/a8m/agile/blob/fcf3f8667e44c621bcdc3065c3a03b29e16851eb/dist/agile.js#L938-L956
35,019
a8m/agile
dist/agile.js
runInContext
function runInContext(context) { // Node.js return (typeof module === "object" && module && module.exports === context) ? module.exports = agile // Browsers : context[(context._) ? 'agile' : '_'] = agile; }
javascript
function runInContext(context) { // Node.js return (typeof module === "object" && module && module.exports === context) ? module.exports = agile // Browsers : context[(context._) ? 'agile' : '_'] = agile; }
[ "function", "runInContext", "(", "context", ")", "{", "// Node.js", "return", "(", "typeof", "module", "===", "\"object\"", "&&", "module", "&&", "module", ".", "exports", "===", "context", ")", "?", "module", ".", "exports", "=", "agile", "// Browsers", ":"...
Expose agile.js
[ "Expose", "agile", ".", "js" ]
fcf3f8667e44c621bcdc3065c3a03b29e16851eb
https://github.com/a8m/agile/blob/fcf3f8667e44c621bcdc3065c3a03b29e16851eb/dist/agile.js#L2708-L2714
35,020
arccoza/postcss-if-media
index.js
processIfValues
function processIfValues(css, result, rule, decl, queries) { var query = null; var re = /(.*)\s+(?:\?if|\?)\s+media\s+(.*)/; var re2 = /\s/g; var hash = null; // Check if we're working with comments. var match = decl.value ? decl.value.match(re) : decl.text.match(re); // console.log(match) if(match && match[1] && match[2]) { if(decl.value) decl.value = match[1]; else decl.text = match[1]; hash = match[2].replace(re2, ''); if(!queries[hash]) { queries[hash] = { arg: match[2], sel: rule.selector, props: [] } } queries[hash].props.push({name: decl.prop, value: match[1], query: match[2], hash: hash, decl: decl}); } else decl.warn(result, 'Appears to be a malformed `?if media` query -> ' + decl); }
javascript
function processIfValues(css, result, rule, decl, queries) { var query = null; var re = /(.*)\s+(?:\?if|\?)\s+media\s+(.*)/; var re2 = /\s/g; var hash = null; // Check if we're working with comments. var match = decl.value ? decl.value.match(re) : decl.text.match(re); // console.log(match) if(match && match[1] && match[2]) { if(decl.value) decl.value = match[1]; else decl.text = match[1]; hash = match[2].replace(re2, ''); if(!queries[hash]) { queries[hash] = { arg: match[2], sel: rule.selector, props: [] } } queries[hash].props.push({name: decl.prop, value: match[1], query: match[2], hash: hash, decl: decl}); } else decl.warn(result, 'Appears to be a malformed `?if media` query -> ' + decl); }
[ "function", "processIfValues", "(", "css", ",", "result", ",", "rule", ",", "decl", ",", "queries", ")", "{", "var", "query", "=", "null", ";", "var", "re", "=", "/", "(.*)\\s+(?:\\?if|\\?)\\s+media\\s+(.*)", "/", ";", "var", "re2", "=", "/", "\\s", "/",...
Extract the values and add them to the list of queries. Props are grouped by their queries, so that they appear in the same @media block later.
[ "Extract", "the", "values", "and", "add", "them", "to", "the", "list", "of", "queries", ".", "Props", "are", "grouped", "by", "their", "queries", "so", "that", "they", "appear", "in", "the", "same" ]
bdd4997231547cb5a82eca64c33aaec1f472c6a6
https://github.com/arccoza/postcss-if-media/blob/bdd4997231547cb5a82eca64c33aaec1f472c6a6/index.js#L77-L104
35,021
arccoza/postcss-if-media
index.js
createAtRules
function createAtRules(css, rule, queries) { var parent = rule.parent; var prev = rule; for(var k in queries) { var q = queries[k]; var at = postcss.atRule({name: 'media', params: q.arg, source: rule.source}); var qr = postcss.rule ({selector: q.sel, source: rule.source}); at.append(qr); for (var i = 0; i < q.props.length; i++) { var prop = q.props[i]; qr.append(prop.decl.remove()); }; // Again we keep track of the previous insert and insert after it, to maintain the original order // and CSS specificity. parent.insertAfter(prev, at); prev = at; } }
javascript
function createAtRules(css, rule, queries) { var parent = rule.parent; var prev = rule; for(var k in queries) { var q = queries[k]; var at = postcss.atRule({name: 'media', params: q.arg, source: rule.source}); var qr = postcss.rule ({selector: q.sel, source: rule.source}); at.append(qr); for (var i = 0; i < q.props.length; i++) { var prop = q.props[i]; qr.append(prop.decl.remove()); }; // Again we keep track of the previous insert and insert after it, to maintain the original order // and CSS specificity. parent.insertAfter(prev, at); prev = at; } }
[ "function", "createAtRules", "(", "css", ",", "rule", ",", "queries", ")", "{", "var", "parent", "=", "rule", ".", "parent", ";", "var", "prev", "=", "rule", ";", "for", "(", "var", "k", "in", "queries", ")", "{", "var", "q", "=", "queries", "[", ...
The previously extracted inline queries and their associated properties are used to create @media rules below(to maintain CSS specificity) the parent rule.
[ "The", "previously", "extracted", "inline", "queries", "and", "their", "associated", "properties", "are", "used", "to", "create" ]
bdd4997231547cb5a82eca64c33aaec1f472c6a6
https://github.com/arccoza/postcss-if-media/blob/bdd4997231547cb5a82eca64c33aaec1f472c6a6/index.js#L108-L130
35,022
medialab/sandcrawler
phantom/bindings.js
getContent
function getContent() { var h = pageInformation.response.headers || {}; if (/json/.test(h['content-type'])) { try { return JSON.parse(page.plainText); } catch (e) { return page.content; } } else { return page.content; } }
javascript
function getContent() { var h = pageInformation.response.headers || {}; if (/json/.test(h['content-type'])) { try { return JSON.parse(page.plainText); } catch (e) { return page.content; } } else { return page.content; } }
[ "function", "getContent", "(", ")", "{", "var", "h", "=", "pageInformation", ".", "response", ".", "headers", "||", "{", "}", ";", "if", "(", "/", "json", "/", ".", "test", "(", "h", "[", "'content-type'", "]", ")", ")", "{", "try", "{", "return", ...
Helpers Get correct page content
[ "Helpers", "Get", "correct", "page", "content" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L159-L172
35,023
medialab/sandcrawler
phantom/bindings.js
wrapFailure
function wrapFailure(reason) { var res = { fail: true, url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status }; if (reason) res.reason = reason; if (pageInformation.error) res.error = pageInformation.error; return res; }
javascript
function wrapFailure(reason) { var res = { fail: true, url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status }; if (reason) res.reason = reason; if (pageInformation.error) res.error = pageInformation.error; return res; }
[ "function", "wrapFailure", "(", "reason", ")", "{", "var", "res", "=", "{", "fail", ":", "true", ",", "url", ":", "page", ".", "url", ",", "body", ":", "getContent", "(", ")", ",", "headers", ":", "pageInformation", ".", "response", ".", "headers", "...
Wrapping response helper
[ "Wrapping", "response", "helper" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L175-L191
35,024
medialab/sandcrawler
phantom/bindings.js
wrapSuccess
function wrapSuccess(result) { return { url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status, error: result.error ? helpers.serializeError(result.error) : null, data: result.data }; }
javascript
function wrapSuccess(result) { return { url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status, error: result.error ? helpers.serializeError(result.error) : null, data: result.data }; }
[ "function", "wrapSuccess", "(", "result", ")", "{", "return", "{", "url", ":", "page", ".", "url", ",", "body", ":", "getContent", "(", ")", ",", "headers", ":", "pageInformation", ".", "response", ".", "headers", ",", "status", ":", "pageInformation", "...
Wrapping success helper
[ "Wrapping", "success", "helper" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L194-L203
35,025
medialab/sandcrawler
phantom/bindings.js
function(status) { // Page is now opened pageInformation.isOpened = true; pageInformation.status = status; // Failing if (status !== 'success') { parent.replyTo(callId, wrapFailure('fail')); return cleanup(); } // Wrong status code if (!pageInformation.response.status || pageInformation.response.status >= 400) { parent.replyTo(callId, wrapFailure('status')); return cleanup(); } // Waiting for body to load page.evaluateAsync(function() { var interval = setInterval(function() { if (document.readyState === 'complete' || document.readyState === 'interactive') { clearInterval(interval); window.callPhantom({ head: 'documentReady', body: true, passphrase: 'detoo' }); } }, 30); }); }
javascript
function(status) { // Page is now opened pageInformation.isOpened = true; pageInformation.status = status; // Failing if (status !== 'success') { parent.replyTo(callId, wrapFailure('fail')); return cleanup(); } // Wrong status code if (!pageInformation.response.status || pageInformation.response.status >= 400) { parent.replyTo(callId, wrapFailure('status')); return cleanup(); } // Waiting for body to load page.evaluateAsync(function() { var interval = setInterval(function() { if (document.readyState === 'complete' || document.readyState === 'interactive') { clearInterval(interval); window.callPhantom({ head: 'documentReady', body: true, passphrase: 'detoo' }); } }, 30); }); }
[ "function", "(", "status", ")", "{", "// Page is now opened", "pageInformation", ".", "isOpened", "=", "true", ";", "pageInformation", ".", "status", "=", "status", ";", "// Failing", "if", "(", "status", "!==", "'success'", ")", "{", "parent", ".", "replyTo",...
When page load is finished
[ "When", "page", "load", "is", "finished" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L395-L426
35,026
icelab/draft-js-ast-exporter
src/processor.js
processBlockContent
function processBlockContent (block, contentState, options) { const entityModifiers = options.entityModifiers || {} let text = block.getText() // Cribbed from sstur’s implementation in draft-js-export-html // https://github.com/sstur/draft-js-export-html/blob/master/src/stateToHTML.js#L222 let charMetaList = block.getCharacterList() let entityPieces = getEntityRanges(text, charMetaList) // Map over the block’s entities const entities = entityPieces.map(([entityKey, stylePieces]) => { let entity = entityKey ? contentState.getEntity(entityKey) : null // Extract the inline element const inline = stylePieces.map(([text, style]) => { return [ 'inline', [ style.toJS().map((s) => s), text, ], ] }) // Nest within an entity if there’s data if (entity) { const type = entity.getType() const mutability = entity.getMutability() let data = entity.getData() // Run the entity data through a modifier if one exists const modifier = entityModifiers[type] if (modifier) { data = modifier(data) } return [ [ 'entity', [ type, entityKey, mutability, data, inline, ], ], ] } else { return inline } }) // Flatten the result return entities.reduce((a, b) => { return a.concat(b) }, []) }
javascript
function processBlockContent (block, contentState, options) { const entityModifiers = options.entityModifiers || {} let text = block.getText() // Cribbed from sstur’s implementation in draft-js-export-html // https://github.com/sstur/draft-js-export-html/blob/master/src/stateToHTML.js#L222 let charMetaList = block.getCharacterList() let entityPieces = getEntityRanges(text, charMetaList) // Map over the block’s entities const entities = entityPieces.map(([entityKey, stylePieces]) => { let entity = entityKey ? contentState.getEntity(entityKey) : null // Extract the inline element const inline = stylePieces.map(([text, style]) => { return [ 'inline', [ style.toJS().map((s) => s), text, ], ] }) // Nest within an entity if there’s data if (entity) { const type = entity.getType() const mutability = entity.getMutability() let data = entity.getData() // Run the entity data through a modifier if one exists const modifier = entityModifiers[type] if (modifier) { data = modifier(data) } return [ [ 'entity', [ type, entityKey, mutability, data, inline, ], ], ] } else { return inline } }) // Flatten the result return entities.reduce((a, b) => { return a.concat(b) }, []) }
[ "function", "processBlockContent", "(", "block", ",", "contentState", ",", "options", ")", "{", "const", "entityModifiers", "=", "options", ".", "entityModifiers", "||", "{", "}", "let", "text", "=", "block", ".", "getText", "(", ")", "// Cribbed from sstur’s im...
Process the content of a ContentBlock into appropriate abstract syntax tree nodes based on their type @param {ContentBlock} block @param {ContentState} contentState The draft-js ContentState object containing this block @param {Object} options.entityModifier Map of functions for modifying entity data as it’s exported @return {Array} List of block’s child nodes
[ "Process", "the", "content", "of", "a", "ContentBlock", "into", "appropriate", "abstract", "syntax", "tree", "nodes", "based", "on", "their", "type" ]
f4745a8a3ca94b51474f21fedc0f92dbbdafd828
https://github.com/icelab/draft-js-ast-exporter/blob/f4745a8a3ca94b51474f21fedc0f92dbbdafd828/src/processor.js#L14-L70
35,027
icelab/draft-js-ast-exporter
src/processor.js
processBlocks
function processBlocks (blocks, contentState, options = {}) { // Track block context let context = context || [] let currentContext = context let lastBlock = null let lastProcessed = null let parents = [] // Procedurally process individual blocks blocks.forEach(processBlock) /** * Process an individual block * @param {ContentBlock} block An individual ContentBlock instance * @return {Array} A abstract syntax tree node representing a block and its * children */ function processBlock (block) { const type = block.getType() const key = block.getKey() const data = (block.getData) ? block.getData().toJS() : {} const output = [ 'block', [ type, key, processBlockContent(block, contentState, options), data, ], ] // Push into context (or not) based on depth. This means either the top-level // context array, or the `children` of a previous block // This block is deeper if (lastBlock && block.getDepth() > lastBlock.getDepth()) { // Extract reference object from flat context // parents.push(lastProcessed) // (mutating) currentContext = lastProcessed[dataSchema.block.children] } else if (lastBlock && block.getDepth() < lastBlock.getDepth() && block.getDepth() > 0) { // This block is shallower (but not at the root). We want to find the last // block that is one level shallower than this one to append it to let parent = parents[block.getDepth() - 1] currentContext = parent[dataSchema.block.children] } else if (block.getDepth() === 0) { // Reset the parent context if we reach the top level parents = [] currentContext = context } currentContext.push(output) lastProcessed = output[1] // Store a reference to the last block at any given depth parents[block.getDepth()] = lastProcessed lastBlock = block } return context }
javascript
function processBlocks (blocks, contentState, options = {}) { // Track block context let context = context || [] let currentContext = context let lastBlock = null let lastProcessed = null let parents = [] // Procedurally process individual blocks blocks.forEach(processBlock) /** * Process an individual block * @param {ContentBlock} block An individual ContentBlock instance * @return {Array} A abstract syntax tree node representing a block and its * children */ function processBlock (block) { const type = block.getType() const key = block.getKey() const data = (block.getData) ? block.getData().toJS() : {} const output = [ 'block', [ type, key, processBlockContent(block, contentState, options), data, ], ] // Push into context (or not) based on depth. This means either the top-level // context array, or the `children` of a previous block // This block is deeper if (lastBlock && block.getDepth() > lastBlock.getDepth()) { // Extract reference object from flat context // parents.push(lastProcessed) // (mutating) currentContext = lastProcessed[dataSchema.block.children] } else if (lastBlock && block.getDepth() < lastBlock.getDepth() && block.getDepth() > 0) { // This block is shallower (but not at the root). We want to find the last // block that is one level shallower than this one to append it to let parent = parents[block.getDepth() - 1] currentContext = parent[dataSchema.block.children] } else if (block.getDepth() === 0) { // Reset the parent context if we reach the top level parents = [] currentContext = context } currentContext.push(output) lastProcessed = output[1] // Store a reference to the last block at any given depth parents[block.getDepth()] = lastProcessed lastBlock = block } return context }
[ "function", "processBlocks", "(", "blocks", ",", "contentState", ",", "options", "=", "{", "}", ")", "{", "// Track block context", "let", "context", "=", "context", "||", "[", "]", "let", "currentContext", "=", "context", "let", "lastBlock", "=", "null", "l...
Convert the content from a series of draft-js blocks into an abstract syntax tree @param {Array} blocks @param {ContentState} contentState The draft-js ContentState object containing the blocks @param {Object} options @return {Array} An abstract syntax tree representing a draft-js content state
[ "Convert", "the", "content", "from", "a", "series", "of", "draft", "-", "js", "blocks", "into", "an", "abstract", "syntax", "tree" ]
f4745a8a3ca94b51474f21fedc0f92dbbdafd828
https://github.com/icelab/draft-js-ast-exporter/blob/f4745a8a3ca94b51474f21fedc0f92dbbdafd828/src/processor.js#L81-L138
35,028
Geta/NestedObjectAssign
webpack.config.js
getBaseConfig
function getBaseConfig(isProd) { // get library details from JSON config var libraryDesc = require('./package.json').library; var libraryEntryPoint = path.join('src', libraryDesc.entry); // generate webpack base config return { entry: path.join(__dirname, libraryEntryPoint), output: { // ommitted - will be filled according to target env }, module: { preLoaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "eslint-loader"} ], loaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "babel-loader"}, ] }, eslint: { configFile: './.eslintrc' }, resolve: { root: path.resolve('./src'), extensions: ['', '.js'] }, devtool: isProd ? null : '#eval-source-map', debug: !isProd, plugins: isProd ? [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}), new UglifyJsPlugin({ minimize: true }) // Prod plugins here ] : [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}}) // Dev plugins here ] }; }
javascript
function getBaseConfig(isProd) { // get library details from JSON config var libraryDesc = require('./package.json').library; var libraryEntryPoint = path.join('src', libraryDesc.entry); // generate webpack base config return { entry: path.join(__dirname, libraryEntryPoint), output: { // ommitted - will be filled according to target env }, module: { preLoaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "eslint-loader"} ], loaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "babel-loader"}, ] }, eslint: { configFile: './.eslintrc' }, resolve: { root: path.resolve('./src'), extensions: ['', '.js'] }, devtool: isProd ? null : '#eval-source-map', debug: !isProd, plugins: isProd ? [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}), new UglifyJsPlugin({ minimize: true }) // Prod plugins here ] : [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}}) // Dev plugins here ] }; }
[ "function", "getBaseConfig", "(", "isProd", ")", "{", "// get library details from JSON config", "var", "libraryDesc", "=", "require", "(", "'./package.json'", ")", ".", "library", ";", "var", "libraryEntryPoint", "=", "path", ".", "join", "(", "'src'", ",", "libr...
Build base config @param {Boolean} isProd [description] @return {[type]} [description]
[ "Build", "base", "config" ]
f63a28f1a285af31c7479a5abba88ffd5d2cb39d
https://github.com/Geta/NestedObjectAssign/blob/f63a28f1a285af31c7479a5abba88ffd5d2cb39d/webpack.config.js#L67-L105
35,029
jadrake75/odata-filter-parser
src/odata-parser.js
function (config) { if (!config) { config = {}; } this.subject = config.subject; this.value = config.value; this.operator = (config.operator) ? config.operator : Operators.EQUALS; return this; }
javascript
function (config) { if (!config) { config = {}; } this.subject = config.subject; this.value = config.value; this.operator = (config.operator) ? config.operator : Operators.EQUALS; return this; }
[ "function", "(", "config", ")", "{", "if", "(", "!", "config", ")", "{", "config", "=", "{", "}", ";", "}", "this", ".", "subject", "=", "config", ".", "subject", ";", "this", ".", "value", "=", "config", ".", "value", ";", "this", ".", "operator...
Predicate is the basic model construct of the odata expression @param config @returns {Predicate} @constructor
[ "Predicate", "is", "the", "basic", "model", "construct", "of", "the", "odata", "expression" ]
f8e6e354bdedafe611d7fe82d5fced65ad33e19e
https://github.com/jadrake75/odata-filter-parser/blob/f8e6e354bdedafe611d7fe82d5fced65ad33e19e/src/odata-parser.js#L61-L69
35,030
Urigo/meteor-native-packages
packages/ddp-client/livedata_connection.js
function () { var self = this; if (!self._waitingForQuiescence()) self._flushBufferedWrites(); _.each(self._stores, function (s) { s.saveOriginals(); }); }
javascript
function () { var self = this; if (!self._waitingForQuiescence()) self._flushBufferedWrites(); _.each(self._stores, function (s) { s.saveOriginals(); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "_waitingForQuiescence", "(", ")", ")", "self", ".", "_flushBufferedWrites", "(", ")", ";", "_", ".", "each", "(", "self", ".", "_stores", ",", "function", "(", ...
Before calling a method stub, prepare all stores to track changes and allow _retrieveAndStoreOriginals to get the original versions of changed documents.
[ "Before", "calling", "a", "method", "stub", "prepare", "all", "stores", "to", "track", "changes", "and", "allow", "_retrieveAndStoreOriginals", "to", "get", "the", "original", "versions", "of", "changed", "documents", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/livedata_connection.js#L975-L982
35,031
Urigo/meteor-native-packages
packages/ddp-client/livedata_connection.js
function() { var self = this; if (_.isEmpty(self._outstandingMethodBlocks)) return; _.each(self._outstandingMethodBlocks[0].methods, function (m) { m.sendMessage(); }); }
javascript
function() { var self = this; if (_.isEmpty(self._outstandingMethodBlocks)) return; _.each(self._outstandingMethodBlocks[0].methods, function (m) { m.sendMessage(); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "_", ".", "isEmpty", "(", "self", ".", "_outstandingMethodBlocks", ")", ")", "return", ";", "_", ".", "each", "(", "self", ".", "_outstandingMethodBlocks", "[", "0", "]", ".", "me...
Sends messages for all the methods in the first block in _outstandingMethodBlocks.
[ "Sends", "messages", "for", "all", "the", "methods", "in", "the", "first", "block", "in", "_outstandingMethodBlocks", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/livedata_connection.js#L1662-L1669
35,032
jaredhanson/passport-fitbit
lib/errors/apierror.js
APIError
function APIError(message, type, field) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'APIError'; this.message = message; this.type = type; this.field = field; }
javascript
function APIError(message, type, field) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'APIError'; this.message = message; this.type = type; this.field = field; }
[ "function", "APIError", "(", "message", ",", "type", ",", "field", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "Error", ".", "captureStackTrace", "(", "this", ",", "arguments", ".", "callee", ")", ";", "this", ".", "name", "=", "'APIError'",...
`APIError` error. @constructor @param {string} [message] @param {string} [type] @param {string} [field] @access public
[ "APIError", "error", "." ]
68f730ac5a834163aeb9c33f8885888de45f0a7d
https://github.com/jaredhanson/passport-fitbit/blob/68f730ac5a834163aeb9c33f8885888de45f0a7d/lib/errors/apierror.js#L10-L17
35,033
Urigo/meteor-native-packages
linker.js
linkPackages
function linkPackages(dstPacksDir) { if (!dstPacksDir) { dstPacksDir = Path.resolve(rootDir, "packages"); } else { dstPacksDir = Path.resolve(cwd, dstPacksDir); } // Ensure destination dir try { Fs.mkdirSync(dstPacksDir); } catch (_) {} var packNames = Fs.readdirSync(srcPacksDir); // Ensure symlinks packNames.forEach(function (packName) { var dstPackDir = Path.resolve(dstPacksDir, packName); var linkPath = Path.relative(dstPacksDir, Path.resolve(srcPacksDir, packName)); try { Fs.symlinkSync(linkPath, dstPackDir); } catch (_) {} }); console.log(); console.log("Packages have been successfully linked at:") console.log(); console.log(" " + dstPacksDir); console.log(); }
javascript
function linkPackages(dstPacksDir) { if (!dstPacksDir) { dstPacksDir = Path.resolve(rootDir, "packages"); } else { dstPacksDir = Path.resolve(cwd, dstPacksDir); } // Ensure destination dir try { Fs.mkdirSync(dstPacksDir); } catch (_) {} var packNames = Fs.readdirSync(srcPacksDir); // Ensure symlinks packNames.forEach(function (packName) { var dstPackDir = Path.resolve(dstPacksDir, packName); var linkPath = Path.relative(dstPacksDir, Path.resolve(srcPacksDir, packName)); try { Fs.symlinkSync(linkPath, dstPackDir); } catch (_) {} }); console.log(); console.log("Packages have been successfully linked at:") console.log(); console.log(" " + dstPacksDir); console.log(); }
[ "function", "linkPackages", "(", "dstPacksDir", ")", "{", "if", "(", "!", "dstPacksDir", ")", "{", "dstPacksDir", "=", "Path", ".", "resolve", "(", "rootDir", ",", "\"packages\"", ")", ";", "}", "else", "{", "dstPacksDir", "=", "Path", ".", "resolve", "(...
Creates a symlink for each native package. @param dstPacksDir - Synlinks' output dir. Defaults to 'packages' dir.
[ "Creates", "a", "symlink", "for", "each", "native", "package", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/linker.js#L14-L46
35,034
zotero/zotero-api-node
lib/stream.js
Stream
function Stream(options) { /** * Whether or not the Stream was initialized as * a single- or multi-key stream. * * @property multi * @type Boolean */ reader(this, 'multi', !(options && options.apiKey)); if (!this.multi) { options.headers = options.headers || {}; options.headers['Zotero-API-Key'] = options.apiKey; delete options.apiKey; } Client.call(this, options); /** * @property retry * @type Object */ reader(this, 'retry', { delay: Stream.DEFAULT_RETRY }); /** * @property idle * @type Object */ reader(this, 'idle', { ping: Stream.IDLE_TIMEOUT, pong: Stream.IDLE_TIMEOUT / 2 }); /** * @property subscriptions * @type Subscriptions */ this.subscriptions = new Subscriptions(); this.open = this.open.bind(this); this.opened = this.opened.bind(this); this.closed = this.closed.bind(this); this.ping = this.ping.bind(this); this.pong = this.pong.bind(this); this.receive = this.receive.bind(this); this.error = this.error.bind(this); this.open(); }
javascript
function Stream(options) { /** * Whether or not the Stream was initialized as * a single- or multi-key stream. * * @property multi * @type Boolean */ reader(this, 'multi', !(options && options.apiKey)); if (!this.multi) { options.headers = options.headers || {}; options.headers['Zotero-API-Key'] = options.apiKey; delete options.apiKey; } Client.call(this, options); /** * @property retry * @type Object */ reader(this, 'retry', { delay: Stream.DEFAULT_RETRY }); /** * @property idle * @type Object */ reader(this, 'idle', { ping: Stream.IDLE_TIMEOUT, pong: Stream.IDLE_TIMEOUT / 2 }); /** * @property subscriptions * @type Subscriptions */ this.subscriptions = new Subscriptions(); this.open = this.open.bind(this); this.opened = this.opened.bind(this); this.closed = this.closed.bind(this); this.ping = this.ping.bind(this); this.pong = this.pong.bind(this); this.receive = this.receive.bind(this); this.error = this.error.bind(this); this.open(); }
[ "function", "Stream", "(", "options", ")", "{", "/**\n * Whether or not the Stream was initialized as\n * a single- or multi-key stream.\n *\n * @property multi\n * @type Boolean\n */", "reader", "(", "this", ",", "'multi'", ",", "!", "(", "options", "&&", "options", ...
Connects to the Zotero Streaming API by establishing a WebSocket connection. @class Stream @constructor @extends Client @param {Object} options
[ "Connects", "to", "the", "Zotero", "Streaming", "API", "by", "establishing", "a", "WebSocket", "connection", "." ]
df5b03cb6b66580efa52aaa22735b0058fbfdf8d
https://github.com/zotero/zotero-api-node/blob/df5b03cb6b66580efa52aaa22735b0058fbfdf8d/lib/stream.js#L52-L104
35,035
lukeed/dom-selection
dist/dom-selection.es.js
getRange
function getRange(sel) { sel = sel || getSelection(); return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; }
javascript
function getRange(sel) { sel = sel || getSelection(); return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; }
[ "function", "getRange", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "return", "sel", ".", "rangeCount", ">", "0", "?", "sel", ".", "getRangeAt", "(", "0", ")", ":", "null", ";", "}" ]
Get a Selection's Range @see http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376 @param {Selection} sel @return {Range|null}
[ "Get", "a", "Selection", "s", "Range" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L36-L39
35,036
lukeed/dom-selection
dist/dom-selection.es.js
setRange
function setRange(saved, sel) { if (!saved) { return; } // will make new selection, if unset sel = sel || getSelection(); sel.removeAllRanges(); sel.addRange(saved); }
javascript
function setRange(saved, sel) { if (!saved) { return; } // will make new selection, if unset sel = sel || getSelection(); sel.removeAllRanges(); sel.addRange(saved); }
[ "function", "setRange", "(", "saved", ",", "sel", ")", "{", "if", "(", "!", "saved", ")", "{", "return", ";", "}", "// will make new selection, if unset", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "sel", ".", "removeAllRanges", "(", ")", ";...
Restore a Selection Range @see http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376 @param {Range} saved @param {Selection} sel
[ "Restore", "a", "Selection", "Range" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L47-L53
35,037
lukeed/dom-selection
dist/dom-selection.es.js
getRect
function getRect(sel) { sel = sel || getSelection(); if (!sel.rangeCount) { return false; } var range = sel.getRangeAt(0).cloneRange(); // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works var rects = range.getClientRects ? range.getClientRects() : []; for (var i = 0; i < rects.length; ++i) { var rect = rects[i]; if (rect.left && rect.top && rect.right && rect.bottom) { return { // Modern browsers return floating-point numbers left: parseInt(rect.left, 10), top: parseInt(rect.top, 10), width: parseInt(rect.right - rect.left, 10), height: parseInt(rect.bottom - rect.top, 10) }; } } return false; }
javascript
function getRect(sel) { sel = sel || getSelection(); if (!sel.rangeCount) { return false; } var range = sel.getRangeAt(0).cloneRange(); // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works var rects = range.getClientRects ? range.getClientRects() : []; for (var i = 0; i < rects.length; ++i) { var rect = rects[i]; if (rect.left && rect.top && rect.right && rect.bottom) { return { // Modern browsers return floating-point numbers left: parseInt(rect.left, 10), top: parseInt(rect.top, 10), width: parseInt(rect.right - rect.left, 10), height: parseInt(rect.bottom - rect.top, 10) }; } } return false; }
[ "function", "getRect", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "!", "sel", ".", "rangeCount", ")", "{", "return", "false", ";", "}", "var", "range", "=", "sel", ".", "getRangeAt", "(", "0", ")", "....
Get a Selection Rectangle @see http://stackoverflow.com/questions/12603397/calculate-width-height-of-the-selected-text-javascript @see http://stackoverflow.com/questions/6846230/coordinates-of-selected-text-in-browser-page @param {Selection} sel @return {Object|Boolean}
[ "Get", "a", "Selection", "Rectangle" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L62-L84
35,038
lukeed/dom-selection
dist/dom-selection.es.js
getNodes
function getNodes(sel) { var range = getRange(sel); if (!range) { return []; } var node = range.startContainer; var endNode = range.endContainer; // Special case for a range that is contained within a single node if (node === endNode) { return [node]; } // Iterate nodes until we hit the end container var nodes = []; while (node && node !== endNode) { nodes.push(node = nextNode(node)); } // Add partially selected nodes at the start of the range node = range.startContainer; while (node && node !== range.commonAncestorContainer) { nodes.unshift(node); node = node.parentNode; } return nodes; }
javascript
function getNodes(sel) { var range = getRange(sel); if (!range) { return []; } var node = range.startContainer; var endNode = range.endContainer; // Special case for a range that is contained within a single node if (node === endNode) { return [node]; } // Iterate nodes until we hit the end container var nodes = []; while (node && node !== endNode) { nodes.push(node = nextNode(node)); } // Add partially selected nodes at the start of the range node = range.startContainer; while (node && node !== range.commonAncestorContainer) { nodes.unshift(node); node = node.parentNode; } return nodes; }
[ "function", "getNodes", "(", "sel", ")", "{", "var", "range", "=", "getRange", "(", "sel", ")", ";", "if", "(", "!", "range", ")", "{", "return", "[", "]", ";", "}", "var", "node", "=", "range", ".", "startContainer", ";", "var", "endNode", "=", ...
Get all Nodes within a Selection. @see http://stackoverflow.com/questions/7781963/js-get-array-of-all-selected-nodes-in-contenteditable-div @param {Selection} sel @return {Array}
[ "Get", "all", "Nodes", "within", "a", "Selection", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L92-L116
35,039
lukeed/dom-selection
dist/dom-selection.es.js
getHTML
function getHTML(sel) { sel = sel || getSelection(); if (!sel.rangeCount || sel.isCollapsed) { return null; } var len = sel.rangeCount; var container = doc.createElement('div'); for (var i = 0; i < len; ++i) { container.appendChild(sel.getRangeAt(i).cloneContents()); } return container.innerHTML; }
javascript
function getHTML(sel) { sel = sel || getSelection(); if (!sel.rangeCount || sel.isCollapsed) { return null; } var len = sel.rangeCount; var container = doc.createElement('div'); for (var i = 0; i < len; ++i) { container.appendChild(sel.getRangeAt(i).cloneContents()); } return container.innerHTML; }
[ "function", "getHTML", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "!", "sel", ".", "rangeCount", "||", "sel", ".", "isCollapsed", ")", "{", "return", "null", ";", "}", "var", "len", "=", "sel", ".", "...
Get the inner HTML content of a selection. @see http://stackoverflow.com/questions/4652734/return-html-from-a-user-selected-text/4652824#4652824 @param {Selection} sel @return {String}
[ "Get", "the", "inner", "HTML", "content", "of", "a", "selection", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L124-L136
35,040
lukeed/dom-selection
dist/dom-selection.es.js
isWithin
function isWithin(container, sel) { sel = sel || getSelection(); return container.contains(sel.anchorNode) && container.contains(sel.focusNode); }
javascript
function isWithin(container, sel) { sel = sel || getSelection(); return container.contains(sel.anchorNode) && container.contains(sel.focusNode); }
[ "function", "isWithin", "(", "container", ",", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "return", "container", ".", "contains", "(", "sel", ".", "anchorNode", ")", "&&", "container", ".", "contains", "(", "sel", ".", "fo...
Is the Selection within given container Node? @param {Node} container The container node @param {Selection} sel @return {Boolean}
[ "Is", "the", "Selection", "within", "given", "container", "Node?" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L170-L173
35,041
lukeed/dom-selection
dist/dom-selection.es.js
getCaretWord
function getCaretWord(sel) { sel = sel || getSelection(); var rng = getRange(sel); expandToWord(sel); var str = sel.toString(); // range? // Restore selection setRange(rng); return str; }
javascript
function getCaretWord(sel) { sel = sel || getSelection(); var rng = getRange(sel); expandToWord(sel); var str = sel.toString(); // range? // Restore selection setRange(rng); return str; }
[ "function", "getCaretWord", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "var", "rng", "=", "getRange", "(", "sel", ")", ";", "expandToWord", "(", "sel", ")", ";", "var", "str", "=", "sel", ".", "toString", "(", ")"...
Get the full word that the Caret is within. @see http://stackoverflow.com/questions/11247737/how-can-i-get-the-word-that-the-caret-is-upon-inside-a-contenteditable-div @param {Selection} sel @return {String}
[ "Get", "the", "full", "word", "that", "the", "Caret", "is", "within", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L211-L219
35,042
lukeed/dom-selection
dist/dom-selection.es.js
isBackwards
function isBackwards(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } // Detect if selection is backwards var range = doc.createRange(); range.setStart(sel.anchorNode, sel.anchorOffset); range.setEnd(sel.focusNode, sel.focusOffset); range.detach(); // if `collapsed` then it's backwards return range.collapsed; }
javascript
function isBackwards(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } // Detect if selection is backwards var range = doc.createRange(); range.setStart(sel.anchorNode, sel.anchorOffset); range.setEnd(sel.focusNode, sel.focusOffset); range.detach(); // if `collapsed` then it's backwards return range.collapsed; }
[ "function", "isBackwards", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "isCollapsed", "(", "sel", ")", ")", "{", "return", ";", "}", "// Detect if selection is backwards", "var", "range", "=", "doc", ".", "cre...
Detect the direction of the Selection @param {Selection} sel @return {Boolean}
[ "Detect", "the", "direction", "of", "the", "Selection" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L226-L238
35,043
lukeed/dom-selection
dist/dom-selection.es.js
snapSelected
function snapSelected(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } var end = sel.focusNode; var off = sel.focusOffset; var dir = ['forward', 'backward']; isBackwards(sel) && dir.reverse(); // modify() works on the focus of the selection sel.collapse(sel.anchorNode, sel.anchorOffset); sel.modify('move', dir[0], 'character'); sel.modify('move', dir[1], 'word'); sel.extend(end, off); sel.modify('extend', dir[1], 'character'); sel.modify('extend', dir[0], 'word'); }
javascript
function snapSelected(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } var end = sel.focusNode; var off = sel.focusOffset; var dir = ['forward', 'backward']; isBackwards(sel) && dir.reverse(); // modify() works on the focus of the selection sel.collapse(sel.anchorNode, sel.anchorOffset); sel.modify('move', dir[0], 'character'); sel.modify('move', dir[1], 'word'); sel.extend(end, off); sel.modify('extend', dir[1], 'character'); sel.modify('extend', dir[0], 'word'); }
[ "function", "snapSelected", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "isCollapsed", "(", "sel", ")", ")", "{", "return", ";", "}", "var", "end", "=", "sel", ".", "focusNode", ";", "var", "off", "=", ...
Snap the Selection to encompass all partially-selected words. @see http://stackoverflow.com/questions/7380190/select-whole-word-with-getselection @param {Selection} sel
[ "Snap", "the", "Selection", "to", "encompass", "all", "partially", "-", "selected", "words", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L245-L262
35,044
Urigo/meteor-native-packages
packages/ddp-server/writefence.js
function () { var self = this; if (self === DDPServer._CurrentWriteFence.get()) throw Error("Can't arm the current fence"); self.armed = true; self._maybeFire(); }
javascript
function () { var self = this; if (self === DDPServer._CurrentWriteFence.get()) throw Error("Can't arm the current fence"); self.armed = true; self._maybeFire(); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", "===", "DDPServer", ".", "_CurrentWriteFence", ".", "get", "(", ")", ")", "throw", "Error", "(", "\"Can't arm the current fence\"", ")", ";", "self", ".", "armed", "=", "true"...
Arm the fence. Once the fence is armed, and there are no more uncommitted writes, it will activate.
[ "Arm", "the", "fence", ".", "Once", "the", "fence", "is", "armed", "and", "there", "are", "no", "more", "uncommitted", "writes", "it", "will", "activate", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/writefence.js#L55-L61
35,045
Urigo/meteor-native-packages
packages/ddp-server/writefence.js
function () { var self = this; var future = new Future; self.onAllCommitted(function () { future['return'](); }); self.arm(); future.wait(); }
javascript
function () { var self = this; var future = new Future; self.onAllCommitted(function () { future['return'](); }); self.arm(); future.wait(); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "future", "=", "new", "Future", ";", "self", ".", "onAllCommitted", "(", "function", "(", ")", "{", "future", "[", "'return'", "]", "(", ")", ";", "}", ")", ";", "self", ".", "arm...
Convenience function. Arms the fence, then blocks until it fires.
[ "Convenience", "function", ".", "Arms", "the", "fence", "then", "blocks", "until", "it", "fires", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/writefence.js#L84-L92
35,046
bitinn/vdom-parser
index.js
createNode
function createNode(el, attr) { // html comment is not currently supported by virtual-dom if (el.nodeType === 3) { return createVirtualTextNode(el); // cdata or doctype is not currently supported by virtual-dom } else if (el.nodeType === 1 || el.nodeType === 9) { return createVirtualDomNode(el, attr); } // default to empty text node return new VText(''); }
javascript
function createNode(el, attr) { // html comment is not currently supported by virtual-dom if (el.nodeType === 3) { return createVirtualTextNode(el); // cdata or doctype is not currently supported by virtual-dom } else if (el.nodeType === 1 || el.nodeType === 9) { return createVirtualDomNode(el, attr); } // default to empty text node return new VText(''); }
[ "function", "createNode", "(", "el", ",", "attr", ")", "{", "// html comment is not currently supported by virtual-dom", "if", "(", "el", ".", "nodeType", "===", "3", ")", "{", "return", "createVirtualTextNode", "(", "el", ")", ";", "// cdata or doctype is not current...
Create vdom from dom node @param Object el DOM element @param String attr Attribute name that contains vdom key @return Object VNode or VText
[ "Create", "vdom", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L73-L85
35,047
bitinn/vdom-parser
index.js
createVirtualDomNode
function createVirtualDomNode(el, attr) { var ns = el.namespaceURI !== HTML_NAMESPACE ? el.namespaceURI : null; var key = attr && el.getAttribute(attr) ? el.getAttribute(attr) : null; return new VNode( el.tagName , createProperties(el) , createChildren(el, attr) , key , ns ); }
javascript
function createVirtualDomNode(el, attr) { var ns = el.namespaceURI !== HTML_NAMESPACE ? el.namespaceURI : null; var key = attr && el.getAttribute(attr) ? el.getAttribute(attr) : null; return new VNode( el.tagName , createProperties(el) , createChildren(el, attr) , key , ns ); }
[ "function", "createVirtualDomNode", "(", "el", ",", "attr", ")", "{", "var", "ns", "=", "el", ".", "namespaceURI", "!==", "HTML_NAMESPACE", "?", "el", ".", "namespaceURI", ":", "null", ";", "var", "key", "=", "attr", "&&", "el", ".", "getAttribute", "(",...
Create vnode from dom node @param Object el DOM element @param String attr Attribute name that contains vdom key @return Object VNode
[ "Create", "vnode", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L104-L115
35,048
bitinn/vdom-parser
index.js
createChildren
function createChildren(el, attr) { var children = []; for (var i = 0; i < el.childNodes.length; i++) { children.push(createNode(el.childNodes[i], attr)); }; return children; }
javascript
function createChildren(el, attr) { var children = []; for (var i = 0; i < el.childNodes.length; i++) { children.push(createNode(el.childNodes[i], attr)); }; return children; }
[ "function", "createChildren", "(", "el", ",", "attr", ")", "{", "var", "children", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "el", ".", "childNodes", ".", "length", ";", "i", "++", ")", "{", "children", ".", "push", "...
Recursively create vdom @param Object el Parent element @param String attr Attribute name that contains vdom key @return Array Child vnode or vtext
[ "Recursively", "create", "vdom" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L124-L131
35,049
bitinn/vdom-parser
index.js
createProperties
function createProperties(el) { var properties = {}; if (!el.hasAttributes()) { return properties; } var ns; if (el.namespaceURI && el.namespaceURI !== HTML_NAMESPACE) { ns = el.namespaceURI; } var attr; for (var i = 0; i < el.attributes.length; i++) { // use built in css style parsing if(el.attributes[i].name == 'style'){ attr = createStyleProperty(el); } else if (ns) { attr = createPropertyNS(el.attributes[i]); } else { attr = createProperty(el.attributes[i]); } // special case, namespaced attribute, use properties.foobar if (attr.ns) { properties[attr.name] = { namespace: attr.ns , value: attr.value }; // special case, use properties.attributes.foobar } else if (attr.isAttr) { // init attributes object only when necessary if (!properties.attributes) { properties.attributes = {} } properties.attributes[attr.name] = attr.value; // default case, use properties.foobar } else { properties[attr.name] = attr.value; } }; return properties; }
javascript
function createProperties(el) { var properties = {}; if (!el.hasAttributes()) { return properties; } var ns; if (el.namespaceURI && el.namespaceURI !== HTML_NAMESPACE) { ns = el.namespaceURI; } var attr; for (var i = 0; i < el.attributes.length; i++) { // use built in css style parsing if(el.attributes[i].name == 'style'){ attr = createStyleProperty(el); } else if (ns) { attr = createPropertyNS(el.attributes[i]); } else { attr = createProperty(el.attributes[i]); } // special case, namespaced attribute, use properties.foobar if (attr.ns) { properties[attr.name] = { namespace: attr.ns , value: attr.value }; // special case, use properties.attributes.foobar } else if (attr.isAttr) { // init attributes object only when necessary if (!properties.attributes) { properties.attributes = {} } properties.attributes[attr.name] = attr.value; // default case, use properties.foobar } else { properties[attr.name] = attr.value; } }; return properties; }
[ "function", "createProperties", "(", "el", ")", "{", "var", "properties", "=", "{", "}", ";", "if", "(", "!", "el", ".", "hasAttributes", "(", ")", ")", "{", "return", "properties", ";", "}", "var", "ns", ";", "if", "(", "el", ".", "namespaceURI", ...
Create properties from dom node @param Object el DOM element @return Object Node properties and attributes
[ "Create", "properties", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L139-L185
35,050
bitinn/vdom-parser
index.js
createProperty
function createProperty(attr) { var name, value, isAttr; // using a map to find the correct case of property name if (propertyMap[attr.name]) { name = propertyMap[attr.name]; } else { name = attr.name; } // special cases for data attribute, we default to properties.attributes.data if (name.indexOf('data-') === 0 || name.indexOf('aria-') === 0) { value = attr.value; isAttr = true; } else { value = attr.value; } return { name: name , value: value , isAttr: isAttr || false }; }
javascript
function createProperty(attr) { var name, value, isAttr; // using a map to find the correct case of property name if (propertyMap[attr.name]) { name = propertyMap[attr.name]; } else { name = attr.name; } // special cases for data attribute, we default to properties.attributes.data if (name.indexOf('data-') === 0 || name.indexOf('aria-') === 0) { value = attr.value; isAttr = true; } else { value = attr.value; } return { name: name , value: value , isAttr: isAttr || false }; }
[ "function", "createProperty", "(", "attr", ")", "{", "var", "name", ",", "value", ",", "isAttr", ";", "// using a map to find the correct case of property name", "if", "(", "propertyMap", "[", "attr", ".", "name", "]", ")", "{", "name", "=", "propertyMap", "[", ...
Create property from dom attribute @param Object attr DOM attribute @return Object Normalized attribute
[ "Create", "property", "from", "dom", "attribute" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L193-L215
35,051
bitinn/vdom-parser
index.js
createPropertyNS
function createPropertyNS(attr) { var name, value; return { name: attr.name , value: attr.value , ns: namespaceMap[attr.name] || '' }; }
javascript
function createPropertyNS(attr) { var name, value; return { name: attr.name , value: attr.value , ns: namespaceMap[attr.name] || '' }; }
[ "function", "createPropertyNS", "(", "attr", ")", "{", "var", "name", ",", "value", ";", "return", "{", "name", ":", "attr", ".", "name", ",", "value", ":", "attr", ".", "value", ",", "ns", ":", "namespaceMap", "[", "attr", ".", "name", "]", "||", ...
Create namespaced property from dom attribute @param Object attr DOM attribute @return Object Normalized attribute
[ "Create", "namespaced", "property", "from", "dom", "attribute" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L223-L231
35,052
bitinn/vdom-parser
index.js
createStyleProperty
function createStyleProperty(el) { var style = el.style; var output = {}; for (var i = 0; i < style.length; ++i) { var item = style.item(i); output[item] = String(style[item]); // hack to workaround browser inconsistency with url() if (output[item].indexOf('url') > -1) { output[item] = output[item].replace(/\"/g, '') } } return { name: 'style', value: output }; }
javascript
function createStyleProperty(el) { var style = el.style; var output = {}; for (var i = 0; i < style.length; ++i) { var item = style.item(i); output[item] = String(style[item]); // hack to workaround browser inconsistency with url() if (output[item].indexOf('url') > -1) { output[item] = output[item].replace(/\"/g, '') } } return { name: 'style', value: output }; }
[ "function", "createStyleProperty", "(", "el", ")", "{", "var", "style", "=", "el", ".", "style", ";", "var", "output", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "style", ".", "length", ";", "++", "i", ")", "{", "var",...
Create style property from dom node @param Object el DOM node @return Object Normalized attribute
[ "Create", "style", "property", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L239-L251
35,053
IronCoreLabs/ironnode
build.js
tagRepo
function tagRepo(version) { if (SHOULD_PUBLISH) { shell.exec(`git tag ${version}`); shell.exec("git push origin --tags"); } else { console.log(`\n\nWould publish git tag as version ${version}.`); } }
javascript
function tagRepo(version) { if (SHOULD_PUBLISH) { shell.exec(`git tag ${version}`); shell.exec("git push origin --tags"); } else { console.log(`\n\nWould publish git tag as version ${version}.`); } }
[ "function", "tagRepo", "(", "version", ")", "{", "if", "(", "SHOULD_PUBLISH", ")", "{", "shell", ".", "exec", "(", "`", "${", "version", "}", "`", ")", ";", "shell", ".", "exec", "(", "\"git push origin --tags\"", ")", ";", "}", "else", "{", "console",...
Tag the repo with the current version that we're publishing
[ "Tag", "the", "repo", "with", "the", "current", "version", "that", "we", "re", "publishing" ]
a0c69398c75230720c4a825426d2a73925ea9053
https://github.com/IronCoreLabs/ironnode/blob/a0c69398c75230720c4a825426d2a73925ea9053/build.js#L50-L57
35,054
IronCoreLabs/ironnode
build.js
ensureNoChangesOnMasterBeforePublish
function ensureNoChangesOnMasterBeforePublish() { //Let users try the build script as long as they're not doing an actual publish if (!SHOULD_PUBLISH) { return true; } shell.exec("git fetch origin", {silent: true}); const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true}); if (currentBranch.stdout.trim() !== "master") { shell.echo("Modules can only be deployed off 'master' branch."); shell.exit(-1); } const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true}); if (changesOnBranch.stdout.trim() !== "") { shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?"); shell.exit(-1); } const localChanges = shell.exec("git status --porcelain", {silent: true}); if (localChanges.stdout.trim() !== "") { shell.echo("This git repository is has uncommitted files. Publish aborted!"); shell.exit(-1); } }
javascript
function ensureNoChangesOnMasterBeforePublish() { //Let users try the build script as long as they're not doing an actual publish if (!SHOULD_PUBLISH) { return true; } shell.exec("git fetch origin", {silent: true}); const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true}); if (currentBranch.stdout.trim() !== "master") { shell.echo("Modules can only be deployed off 'master' branch."); shell.exit(-1); } const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true}); if (changesOnBranch.stdout.trim() !== "") { shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?"); shell.exit(-1); } const localChanges = shell.exec("git status --porcelain", {silent: true}); if (localChanges.stdout.trim() !== "") { shell.echo("This git repository is has uncommitted files. Publish aborted!"); shell.exit(-1); } }
[ "function", "ensureNoChangesOnMasterBeforePublish", "(", ")", "{", "//Let users try the build script as long as they're not doing an actual publish", "if", "(", "!", "SHOULD_PUBLISH", ")", "{", "return", "true", ";", "}", "shell", ".", "exec", "(", "\"git fetch origin\"", "...
Ensure that we're in a pristine, up-to-date repo and on the master branch before allowing user to continue. Only does verification if user is actually trying to perform an NPM publish
[ "Ensure", "that", "we", "re", "in", "a", "pristine", "up", "-", "to", "-", "date", "repo", "and", "on", "the", "master", "branch", "before", "allowing", "user", "to", "continue", ".", "Only", "does", "verification", "if", "user", "is", "actually", "tryin...
a0c69398c75230720c4a825426d2a73925ea9053
https://github.com/IronCoreLabs/ironnode/blob/a0c69398c75230720c4a825426d2a73925ea9053/build.js#L63-L88
35,055
mjk/uber-rush
lib/Quote.js
Quote
function Quote(options) { var self = this; events.EventEmitter.call(self); this.quote_id = options.quote_id; this.start_time = new Date(parseInt(options.start_time,10)*1000); this.end_time = new Date(parseInt(options.end_time,10)*1000); this.fee = parseFloat(options.fee); this.currency_code = options.currency_code; if (options.pickup_eta) this.pickup_eta = parseInt(options.pickup_eta, 10); if (options.dropoff_eta) this.dropoff_eta = parseInt(options.dropoff_eta, 10); this.pickup_date = this.pickup_eta ? new Date(Date.now() + this.pickup_eta*60*1000) : null; this.dropoff_date = this.dropoff_eta ? new Date(Date.now() + this.dropoff_eta*60*1000) : null; }
javascript
function Quote(options) { var self = this; events.EventEmitter.call(self); this.quote_id = options.quote_id; this.start_time = new Date(parseInt(options.start_time,10)*1000); this.end_time = new Date(parseInt(options.end_time,10)*1000); this.fee = parseFloat(options.fee); this.currency_code = options.currency_code; if (options.pickup_eta) this.pickup_eta = parseInt(options.pickup_eta, 10); if (options.dropoff_eta) this.dropoff_eta = parseInt(options.dropoff_eta, 10); this.pickup_date = this.pickup_eta ? new Date(Date.now() + this.pickup_eta*60*1000) : null; this.dropoff_date = this.dropoff_eta ? new Date(Date.now() + this.dropoff_eta*60*1000) : null; }
[ "function", "Quote", "(", "options", ")", "{", "var", "self", "=", "this", ";", "events", ".", "EventEmitter", ".", "call", "(", "self", ")", ";", "this", ".", "quote_id", "=", "options", ".", "quote_id", ";", "this", ".", "start_time", "=", "new", "...
A delivery quote. @param quote_id string The ID of the quote. @param estimated_at integer Unix timestamp of the time this quote was generated. @param start_time integer Unix timestamp of the start of the delivery window. @param end_time integer Unix timestamp of the end of the delivery window. @param fee float The fee of the delivery. @param currency_code string The currency code of the delivery fee. The currency code follows the ISO 4217 standard. @param pickup_eta integer The eta to pickup for this quote in minutes. Only applies to on­demand deliveries. @param dropoff_eta integer The eta to dropoff for this quote in minutes. Only applies to on­demand deliveries.
[ "A", "delivery", "quote", "." ]
3c43b2e8e1da428dd49e1a516f3c1588756c4576
https://github.com/mjk/uber-rush/blob/3c43b2e8e1da428dd49e1a516f3c1588756c4576/lib/Quote.js#L23-L38
35,056
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, userId, text, callback) { send(null, conversationId, utils.messageText('user_id', userId, text), callback); }
javascript
function(conversationId, userId, text, callback) { send(null, conversationId, utils.messageText('user_id', userId, text), callback); }
[ "function", "(", "conversationId", ",", "userId", ",", "text", ",", "callback", ")", "{", "send", "(", "null", ",", "conversationId", ",", "utils", ".", "messageText", "(", "'user_id'", ",", "userId", ",", "text", ")", ",", "callback", ")", ";", "}" ]
Send a plain text message from `userId` @param {String} conversationId Conversation ID @param {String} userId User ID @param {String} text Message text @param {Function} callback Callback function
[ "Send", "a", "plain", "text", "message", "from", "userId" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L41-L43
35,057
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, name, text, callback) { send(null, conversationId, utils.messageText('name', name, text), callback); }
javascript
function(conversationId, name, text, callback) { send(null, conversationId, utils.messageText('name', name, text), callback); }
[ "function", "(", "conversationId", ",", "name", ",", "text", ",", "callback", ")", "{", "send", "(", "null", ",", "conversationId", ",", "utils", ".", "messageText", "(", "'name'", ",", "name", ",", "text", ")", ",", "callback", ")", ";", "}" ]
Send a plain text message from `name` @param {String} conversationId Conversation ID @param {String} name Sender name @param {String} text Message text @param {Function} callback Callback function
[ "Send", "a", "plain", "text", "message", "from", "name" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L53-L55
35,058
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, params, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.messages.cid)); utils.debug('Message getAll: ' + conversationId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/conversations/' + conversationId + '/messages' + queryParams }, callback); }
javascript
function(conversationId, params, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.messages.cid)); utils.debug('Message getAll: ' + conversationId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/conversations/' + conversationId + '/messages' + queryParams }, callback); }
[ "function", "(", "conversationId", ",", "params", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", "."...
Retrieve messages in a conversation @param {String} conversationId Conversation ID @param {String} [params] Query parameters @param {Function} callback Callback function
[ "Retrieve", "messages", "in", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L64-L76
35,059
layerhq/node-layer-api
lib/resources/messages.js
function(messageId, conversationId, callback) { if (!messageId) return callback(new Error(utils.i18n.messages.mid)); messageId = utils.toUUID(messageId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); conversationId = utils.toUUID(conversationId); utils.debug('Message get: ' + messageId + ', ' + conversationId); request.get({ path: '/conversations/' + conversationId + '/messages/' + messageId }, callback); }
javascript
function(messageId, conversationId, callback) { if (!messageId) return callback(new Error(utils.i18n.messages.mid)); messageId = utils.toUUID(messageId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); conversationId = utils.toUUID(conversationId); utils.debug('Message get: ' + messageId + ', ' + conversationId); request.get({ path: '/conversations/' + conversationId + '/messages/' + messageId }, callback); }
[ "function", "(", "messageId", ",", "conversationId", ",", "callback", ")", "{", "if", "(", "!", "messageId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "mid", ")", ")", ";", "messageId", "=", "utils...
Retrieve a message in a conversation @param {String} messageId Message ID @param {String} conversationId Conversation ID @param {Function} callback Callback function
[ "Retrieve", "a", "message", "in", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L85-L94
35,060
layerhq/node-layer-api
lib/resources/messages.js
function(userId, messageId, callback) { if (!userId) return callback(new Error(utils.i18n.messages.userId)); messageId = utils.toUUID(messageId); if (!messageId) return callback(new Error(utils.i18n.messages.mid)); utils.debug('Message getFromUser: ' + userId + ', ' + messageId); request.get({ path: '/users/' + querystring.escape(userId) + '/messages/' + messageId }, callback); }
javascript
function(userId, messageId, callback) { if (!userId) return callback(new Error(utils.i18n.messages.userId)); messageId = utils.toUUID(messageId); if (!messageId) return callback(new Error(utils.i18n.messages.mid)); utils.debug('Message getFromUser: ' + userId + ', ' + messageId); request.get({ path: '/users/' + querystring.escape(userId) + '/messages/' + messageId }, callback); }
[ "function", "(", "userId", ",", "messageId", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "userId", ")", ")", ";", "messageId", "=", "utils", "."...
Retrieve a message in a conversation from a user @param {String} userId User ID @param {String} messageId Message ID @param {Function} callback Callback function
[ "Retrieve", "a", "message", "in", "a", "conversation", "from", "a", "user" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L126-L135
35,061
medialab/sandcrawler
src/spider.js
retryJob
function retryJob(job, when) { when = when || 'later'; // Reaching maxRetries? if (job.req.retries >= this.options.maxRetries) return; // Dropping from remains delete this.remains[job.id]; // Request job.req.retries++; job.state.retrying = true; // Adding to the queue again this.queue[when === 'now' ? 'unshift' : 'push'](job); this.emit('job:retry', job, when); }
javascript
function retryJob(job, when) { when = when || 'later'; // Reaching maxRetries? if (job.req.retries >= this.options.maxRetries) return; // Dropping from remains delete this.remains[job.id]; // Request job.req.retries++; job.state.retrying = true; // Adding to the queue again this.queue[when === 'now' ? 'unshift' : 'push'](job); this.emit('job:retry', job, when); }
[ "function", "retryJob", "(", "job", ",", "when", ")", "{", "when", "=", "when", "||", "'later'", ";", "// Reaching maxRetries?", "if", "(", "job", ".", "req", ".", "retries", ">=", "this", ".", "options", ".", "maxRetries", ")", "return", ";", "// Droppi...
Retrying a job
[ "Retrying", "a", "job" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L241-L259
35,062
medialab/sandcrawler
src/spider.js
beforeScraping
function beforeScraping(job, callback) { return async.applyEachSeries( this.middlewares.beforeScraping, job.req, callback ); }
javascript
function beforeScraping(job, callback) { return async.applyEachSeries( this.middlewares.beforeScraping, job.req, callback ); }
[ "function", "beforeScraping", "(", "job", ",", "callback", ")", "{", "return", "async", ".", "applyEachSeries", "(", "this", ".", "middlewares", ".", "beforeScraping", ",", "job", ".", "req", ",", "callback", ")", ";", "}" ]
Applying beforeScraping middlewares
[ "Applying", "beforeScraping", "middlewares" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L262-L268
35,063
medialab/sandcrawler
src/spider.js
afterScraping
function afterScraping(job, callback) { return async.applyEachSeries( this.middlewares.afterScraping, job.req, job.res, callback ); }
javascript
function afterScraping(job, callback) { return async.applyEachSeries( this.middlewares.afterScraping, job.req, job.res, callback ); }
[ "function", "afterScraping", "(", "job", ",", "callback", ")", "{", "return", "async", ".", "applyEachSeries", "(", "this", ".", "middlewares", ".", "afterScraping", ",", "job", ".", "req", ",", "job", ".", "res", ",", "callback", ")", ";", "}" ]
Applying afterScraping middlewares
[ "Applying", "afterScraping", "middlewares" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L276-L282
35,064
medialab/sandcrawler
src/spider.js
iterate
function iterate() { var lastJob = this.lastJob || {}, feed = this.iterator.call(this, this.index, lastJob.req, lastJob.res); if (feed) this.addUrl(feed); }
javascript
function iterate() { var lastJob = this.lastJob || {}, feed = this.iterator.call(this, this.index, lastJob.req, lastJob.res); if (feed) this.addUrl(feed); }
[ "function", "iterate", "(", ")", "{", "var", "lastJob", "=", "this", ".", "lastJob", "||", "{", "}", ",", "feed", "=", "this", ".", "iterator", ".", "call", "(", "this", ",", "this", ".", "index", ",", "lastJob", ".", "req", ",", "lastJob", ".", ...
Perform an iteration
[ "Perform", "an", "iteration" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L292-L298
35,065
medialab/sandcrawler
src/spider.js
addUrl
function addUrl(when, feed) { if (!types.check(feed, 'feed') && !types.check(feed, ['feed'])) throw Error('sandcrawler.spider.url(s): wrong argument.'); var a = !(feed instanceof Array) ? [feed] : feed, c = !this.state.running ? this.initialBuffer.length : this.index, job, i, l; for (i = 0, l = a.length; i < l; i++) { job = createJob(a[i]); // Don't add if already at limit if (this.options.limit && c >= this.options.limit) break; if (!this.state.running) { this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job); } else { this.queue[when === 'later' ? 'push' : 'unshift'](job); this.emit('job:add', job); } } return this; }
javascript
function addUrl(when, feed) { if (!types.check(feed, 'feed') && !types.check(feed, ['feed'])) throw Error('sandcrawler.spider.url(s): wrong argument.'); var a = !(feed instanceof Array) ? [feed] : feed, c = !this.state.running ? this.initialBuffer.length : this.index, job, i, l; for (i = 0, l = a.length; i < l; i++) { job = createJob(a[i]); // Don't add if already at limit if (this.options.limit && c >= this.options.limit) break; if (!this.state.running) { this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job); } else { this.queue[when === 'later' ? 'push' : 'unshift'](job); this.emit('job:add', job); } } return this; }
[ "function", "addUrl", "(", "when", ",", "feed", ")", "{", "if", "(", "!", "types", ".", "check", "(", "feed", ",", "'feed'", ")", "&&", "!", "types", ".", "check", "(", "feed", ",", "[", "'feed'", "]", ")", ")", "throw", "Error", "(", "'sandcrawl...
Feeding the spider
[ "Feeding", "the", "spider" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L426-L453
35,066
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( a, order, prop, prop2 ) { var out = []; var i=0, ien=order.length; // Could have the test in the loop for slightly smaller code, but speed // is essential here if ( prop2 !== undefined ) { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ][ prop2 ] ); } } else { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ] ); } } return out; }
javascript
function ( a, order, prop, prop2 ) { var out = []; var i=0, ien=order.length; // Could have the test in the loop for slightly smaller code, but speed // is essential here if ( prop2 !== undefined ) { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ][ prop2 ] ); } } else { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ] ); } } return out; }
[ "function", "(", "a", ",", "order", ",", "prop", ",", "prop2", ")", "{", "var", "out", "=", "[", "]", ";", "var", "i", "=", "0", ",", "ien", "=", "order", ".", "length", ";", "// Could have the test in the loop for slightly smaller code, but speed\r", "// is...
Basically the same as _pluck, but rather than looping over `a` we use `order` as the indexes to pick from `a`
[ "Basically", "the", "same", "as", "_pluck", "but", "rather", "than", "looping", "over", "a", "we", "use", "order", "as", "the", "indexes", "to", "pick", "from", "a" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L179-L198
35,067
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( src ) { // A faster unique method is to use object keys to identify used values, // but this doesn't work with arrays or objects, which we must also // consider. See jsperf.com/compare-array-unique-versions/4 for more // information. var out = [], val, i, ien=src.length, j, k=0; again: for ( i=0 ; i<ien ; i++ ) { val = src[i]; for ( j=0 ; j<k ; j++ ) { if ( out[j] === val ) { continue again; } } out.push( val ); k++; } return out; }
javascript
function ( src ) { // A faster unique method is to use object keys to identify used values, // but this doesn't work with arrays or objects, which we must also // consider. See jsperf.com/compare-array-unique-versions/4 for more // information. var out = [], val, i, ien=src.length, j, k=0; again: for ( i=0 ; i<ien ; i++ ) { val = src[i]; for ( j=0 ; j<k ; j++ ) { if ( out[j] === val ) { continue again; } } out.push( val ); k++; } return out; }
[ "function", "(", "src", ")", "{", "// A faster unique method is to use object keys to identify used values,\r", "// but this doesn't work with arrays or objects, which we must also\r", "// consider. See jsperf.com/compare-array-unique-versions/4 for more\r", "// information.\r", "var", "out", ...
Find the unique elements in a source array. @param {array} src Source array @return {array} Array of unique items @ignore
[ "Find", "the", "unique", "elements", "in", "a", "source", "array", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L235-L261
35,068
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnHungarianMap
function _fnHungarianMap ( o ) { var hungarian = 'a aa ao as b fn i m o s ', match, newKey, map = {}; $.each( o, function (key, val) { match = key.match(/^([^A-Z]+?)([A-Z])/); if ( match && hungarian.indexOf(match[1]+' ') !== -1 ) { newKey = key.replace( match[0], match[2].toLowerCase() ); map[ newKey ] = key; if ( match[1] === 'o' ) { _fnHungarianMap( o[key] ); } } } ); o._hungarianMap = map; }
javascript
function _fnHungarianMap ( o ) { var hungarian = 'a aa ao as b fn i m o s ', match, newKey, map = {}; $.each( o, function (key, val) { match = key.match(/^([^A-Z]+?)([A-Z])/); if ( match && hungarian.indexOf(match[1]+' ') !== -1 ) { newKey = key.replace( match[0], match[2].toLowerCase() ); map[ newKey ] = key; if ( match[1] === 'o' ) { _fnHungarianMap( o[key] ); } } } ); o._hungarianMap = map; }
[ "function", "_fnHungarianMap", "(", "o", ")", "{", "var", "hungarian", "=", "'a aa ao as b fn i m o s '", ",", "match", ",", "newKey", ",", "map", "=", "{", "}", ";", "$", ".", "each", "(", "o", ",", "function", "(", "key", ",", "val", ")", "{", "mat...
Create a mapping object that allows camel case parameters to be looked up for their Hungarian counterparts. The mapping is stored in a private parameter called `_hungarianMap` which can be accessed on the source object. @param {object} o @memberof DataTable#oApi
[ "Create", "a", "mapping", "object", "that", "allows", "camel", "case", "parameters", "to", "be", "looked", "up", "for", "their", "Hungarian", "counterparts", ".", "The", "mapping", "is", "stored", "in", "a", "private", "parameter", "called", "_hungarianMap", "...
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L272-L296
35,069
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCamelToHungarian
function _fnCamelToHungarian ( src, user, force ) { if ( ! src._hungarianMap ) { _fnHungarianMap( src ); } var hungarianKey; $.each( user, function (key, val) { hungarianKey = src._hungarianMap[ key ]; if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) ) { user[hungarianKey] = user[ key ]; if ( hungarianKey.charAt(0) === 'o' ) { _fnCamelToHungarian( src[hungarianKey], user[key] ); } } } ); }
javascript
function _fnCamelToHungarian ( src, user, force ) { if ( ! src._hungarianMap ) { _fnHungarianMap( src ); } var hungarianKey; $.each( user, function (key, val) { hungarianKey = src._hungarianMap[ key ]; if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) ) { user[hungarianKey] = user[ key ]; if ( hungarianKey.charAt(0) === 'o' ) { _fnCamelToHungarian( src[hungarianKey], user[key] ); } } } ); }
[ "function", "_fnCamelToHungarian", "(", "src", ",", "user", ",", "force", ")", "{", "if", "(", "!", "src", ".", "_hungarianMap", ")", "{", "_fnHungarianMap", "(", "src", ")", ";", "}", "var", "hungarianKey", ";", "$", ".", "each", "(", "user", ",", "...
Convert from camel case parameters to Hungarian, based on a Hungarian map created by _fnHungarianMap. @param {object} src The model object which holds all parameters that can be mapped. @param {object} user The object to convert from camel case to Hungarian. @param {boolean} force When set to `true`, properties which already have a Hungarian value in the `user` object will be overwritten. Otherwise they won't be. @memberof DataTable#oApi
[ "Convert", "from", "camel", "case", "parameters", "to", "Hungarian", "based", "on", "a", "Hungarian", "map", "created", "by", "_fnHungarianMap", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L310-L332
35,070
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnLanguageCompat
function _fnLanguageCompat( oLanguage ) { var oDefaults = DataTable.defaults.oLanguage; var zeroRecords = oLanguage.sZeroRecords; /* Backwards compatibility - if there is no sEmptyTable given, then use the same as * sZeroRecords - assuming that is given. */ if ( !oLanguage.sEmptyTable && zeroRecords && oDefaults.sEmptyTable === "No data available in table" ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' ); } /* Likewise with loading records */ if ( !oLanguage.sLoadingRecords && zeroRecords && oDefaults.sLoadingRecords === "Loading..." ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' ); } }
javascript
function _fnLanguageCompat( oLanguage ) { var oDefaults = DataTable.defaults.oLanguage; var zeroRecords = oLanguage.sZeroRecords; /* Backwards compatibility - if there is no sEmptyTable given, then use the same as * sZeroRecords - assuming that is given. */ if ( !oLanguage.sEmptyTable && zeroRecords && oDefaults.sEmptyTable === "No data available in table" ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' ); } /* Likewise with loading records */ if ( !oLanguage.sLoadingRecords && zeroRecords && oDefaults.sLoadingRecords === "Loading..." ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' ); } }
[ "function", "_fnLanguageCompat", "(", "oLanguage", ")", "{", "var", "oDefaults", "=", "DataTable", ".", "defaults", ".", "oLanguage", ";", "var", "zeroRecords", "=", "oLanguage", ".", "sZeroRecords", ";", "/* Backwards compatibility - if there is no sEmptyTable given, the...
Language compatibility - when certain options are given, and others aren't, we need to duplicate the values over, in order to provide backwards compatibility with older language files. @param {object} oSettings dataTables settings object @memberof DataTable#oApi
[ "Language", "compatibility", "-", "when", "certain", "options", "are", "given", "and", "others", "aren", "t", "we", "need", "to", "duplicate", "the", "values", "over", "in", "order", "to", "provide", "backwards", "compatibility", "with", "older", "language", "...
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L342-L362
35,071
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( o, knew, old ) { if ( o[ knew ] !== undefined ) { o[ old ] = o[ knew ]; } }
javascript
function ( o, knew, old ) { if ( o[ knew ] !== undefined ) { o[ old ] = o[ knew ]; } }
[ "function", "(", "o", ",", "knew", ",", "old", ")", "{", "if", "(", "o", "[", "knew", "]", "!==", "undefined", ")", "{", "o", "[", "old", "]", "=", "o", "[", "knew", "]", ";", "}", "}" ]
Map one parameter onto another @param {object} o Object to map @param {*} knew The new parameter name @param {*} old The old parameter name
[ "Map", "one", "parameter", "onto", "another" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L371-L375
35,072
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCompatOpts
function _fnCompatOpts ( init ) { _fnCompatMap( init, 'ordering', 'bSort' ); _fnCompatMap( init, 'orderMulti', 'bSortMulti' ); _fnCompatMap( init, 'orderClasses', 'bSortClasses' ); _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' ); _fnCompatMap( init, 'order', 'aaSorting' ); _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' ); _fnCompatMap( init, 'paging', 'bPaginate' ); _fnCompatMap( init, 'pagingType', 'sPaginationType' ); _fnCompatMap( init, 'pageLength', 'iDisplayLength' ); _fnCompatMap( init, 'searching', 'bFilter' ); }
javascript
function _fnCompatOpts ( init ) { _fnCompatMap( init, 'ordering', 'bSort' ); _fnCompatMap( init, 'orderMulti', 'bSortMulti' ); _fnCompatMap( init, 'orderClasses', 'bSortClasses' ); _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' ); _fnCompatMap( init, 'order', 'aaSorting' ); _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' ); _fnCompatMap( init, 'paging', 'bPaginate' ); _fnCompatMap( init, 'pagingType', 'sPaginationType' ); _fnCompatMap( init, 'pageLength', 'iDisplayLength' ); _fnCompatMap( init, 'searching', 'bFilter' ); }
[ "function", "_fnCompatOpts", "(", "init", ")", "{", "_fnCompatMap", "(", "init", ",", "'ordering'", ",", "'bSort'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderMulti'", ",", "'bSortMulti'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderClasses'", ...
Provide backwards compatibility for the main DT options. Note that the new options are mapped onto the old parameters, so this is an external interface change only. @param {object} init Object to map
[ "Provide", "backwards", "compatibility", "for", "the", "main", "DT", "options", ".", "Note", "that", "the", "new", "options", "are", "mapped", "onto", "the", "old", "parameters", "so", "this", "is", "an", "external", "interface", "change", "only", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L384-L396
35,073
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCompatCols
function _fnCompatCols ( init ) { _fnCompatMap( init, 'orderable', 'bSortable' ); _fnCompatMap( init, 'orderData', 'aDataSort' ); _fnCompatMap( init, 'orderSequence', 'asSorting' ); _fnCompatMap( init, 'orderDataType', 'sortDataType' ); }
javascript
function _fnCompatCols ( init ) { _fnCompatMap( init, 'orderable', 'bSortable' ); _fnCompatMap( init, 'orderData', 'aDataSort' ); _fnCompatMap( init, 'orderSequence', 'asSorting' ); _fnCompatMap( init, 'orderDataType', 'sortDataType' ); }
[ "function", "_fnCompatCols", "(", "init", ")", "{", "_fnCompatMap", "(", "init", ",", "'orderable'", ",", "'bSortable'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderData'", ",", "'aDataSort'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderSequence'...
Provide backwards compatibility for column options. Note that the new options are mapped onto the old parameters, so this is an external interface change only. @param {object} init Object to map
[ "Provide", "backwards", "compatibility", "for", "column", "options", ".", "Note", "that", "the", "new", "options", "are", "mapped", "onto", "the", "old", "parameters", "so", "this", "is", "an", "external", "interface", "change", "only", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L405-L411
35,074
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnBrowserDetect
function _fnBrowserDetect( settings ) { var browser = settings.oBrowser; // Scrolling feature / quirks detection var n = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, height: 1, width: 1, overflow: 'hidden' } ) .append( $('<div/>') .css( { position: 'absolute', top: 1, left: 1, width: 100, overflow: 'scroll' } ) .append( $('<div class="test"/>') .css( { width: '100%', height: 10 } ) ) ) .appendTo( 'body' ); var test = n.find('.test'); // IE6/7 will oversize a width 100% element inside a scrolling element, to // include the width of the scrollbar, while other browsers ensure the inner // element is contained without forcing scrolling browser.bScrollOversize = test[0].offsetWidth === 100; // In rtl text layout, some browsers (most, but not all) will place the // scrollbar on the left, rather than the right. browser.bScrollbarLeft = test.offset().left !== 1; n.remove(); }
javascript
function _fnBrowserDetect( settings ) { var browser = settings.oBrowser; // Scrolling feature / quirks detection var n = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, height: 1, width: 1, overflow: 'hidden' } ) .append( $('<div/>') .css( { position: 'absolute', top: 1, left: 1, width: 100, overflow: 'scroll' } ) .append( $('<div class="test"/>') .css( { width: '100%', height: 10 } ) ) ) .appendTo( 'body' ); var test = n.find('.test'); // IE6/7 will oversize a width 100% element inside a scrolling element, to // include the width of the scrollbar, while other browsers ensure the inner // element is contained without forcing scrolling browser.bScrollOversize = test[0].offsetWidth === 100; // In rtl text layout, some browsers (most, but not all) will place the // scrollbar on the left, rather than the right. browser.bScrollbarLeft = test.offset().left !== 1; n.remove(); }
[ "function", "_fnBrowserDetect", "(", "settings", ")", "{", "var", "browser", "=", "settings", ".", "oBrowser", ";", "// Scrolling feature / quirks detection\r", "var", "n", "=", "$", "(", "'<div/>'", ")", ".", "css", "(", "{", "position", ":", "'absolute'", ",...
Browser feature detection for capabilities, quirks @param {object} settings dataTables settings object @memberof DataTable#oApi
[ "Browser", "feature", "detection", "for", "capabilities", "quirks" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L419-L464
35,075
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetColumns
function _fnGetColumns( oSettings, sParam ) { var a = []; $.map( oSettings.aoColumns, function(val, i) { if ( val[sParam] ) { a.push( i ); } } ); return a; }
javascript
function _fnGetColumns( oSettings, sParam ) { var a = []; $.map( oSettings.aoColumns, function(val, i) { if ( val[sParam] ) { a.push( i ); } } ); return a; }
[ "function", "_fnGetColumns", "(", "oSettings", ",", "sParam", ")", "{", "var", "a", "=", "[", "]", ";", "$", ".", "map", "(", "oSettings", ".", "aoColumns", ",", "function", "(", "val", ",", "i", ")", "{", "if", "(", "val", "[", "sParam", "]", ")...
Get an array of column indexes that match a given property @param {object} oSettings dataTables settings object @param {string} sParam Parameter in aoColumns to look for - typically bVisible or bSearchable @returns {array} Array of indexes with matched properties @memberof DataTable#oApi
[ "Get", "an", "array", "of", "column", "indexes", "that", "match", "a", "given", "property" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L701-L712
35,076
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnApplyColumnDefs
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn ) { var i, iLen, j, jLen, k, kLen, def; // Column definitions with aTargets if ( aoColDefs ) { /* Loop over the definitions array - loop in reverse so first instance has priority */ for ( i=aoColDefs.length-1 ; i>=0 ; i-- ) { def = aoColDefs[i]; /* Each definition can target multiple columns, as it is an array */ var aTargets = def.targets !== undefined ? def.targets : def.aTargets; if ( ! $.isArray( aTargets ) ) { aTargets = [ aTargets ]; } for ( j=0, jLen=aTargets.length ; j<jLen ; j++ ) { if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 ) { /* Add columns that we don't yet know about */ while( oSettings.aoColumns.length <= aTargets[j] ) { _fnAddColumn( oSettings ); } /* Integer, basic index */ fn( aTargets[j], def ); } else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 ) { /* Negative integer, right to left column counting */ fn( oSettings.aoColumns.length+aTargets[j], def ); } else if ( typeof aTargets[j] === 'string' ) { /* Class name matching on TH element */ for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ ) { if ( aTargets[j] == "_all" || $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) ) { fn( k, def ); } } } } } } // Statically defined columns array if ( aoCols ) { for ( i=0, iLen=aoCols.length ; i<iLen ; i++ ) { fn( i, aoCols[i] ); } } }
javascript
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn ) { var i, iLen, j, jLen, k, kLen, def; // Column definitions with aTargets if ( aoColDefs ) { /* Loop over the definitions array - loop in reverse so first instance has priority */ for ( i=aoColDefs.length-1 ; i>=0 ; i-- ) { def = aoColDefs[i]; /* Each definition can target multiple columns, as it is an array */ var aTargets = def.targets !== undefined ? def.targets : def.aTargets; if ( ! $.isArray( aTargets ) ) { aTargets = [ aTargets ]; } for ( j=0, jLen=aTargets.length ; j<jLen ; j++ ) { if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 ) { /* Add columns that we don't yet know about */ while( oSettings.aoColumns.length <= aTargets[j] ) { _fnAddColumn( oSettings ); } /* Integer, basic index */ fn( aTargets[j], def ); } else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 ) { /* Negative integer, right to left column counting */ fn( oSettings.aoColumns.length+aTargets[j], def ); } else if ( typeof aTargets[j] === 'string' ) { /* Class name matching on TH element */ for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ ) { if ( aTargets[j] == "_all" || $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) ) { fn( k, def ); } } } } } } // Statically defined columns array if ( aoCols ) { for ( i=0, iLen=aoCols.length ; i<iLen ; i++ ) { fn( i, aoCols[i] ); } } }
[ "function", "_fnApplyColumnDefs", "(", "oSettings", ",", "aoColDefs", ",", "aoCols", ",", "fn", ")", "{", "var", "i", ",", "iLen", ",", "j", ",", "jLen", ",", "k", ",", "kLen", ",", "def", ";", "// Column definitions with aTargets\r", "if", "(", "aoColDefs...
Take the column definitions and static columns arrays and calculate how they relate to column indexes. The callback function will then apply the definition found for a column to a suitable configuration object. @param {object} oSettings dataTables settings object @param {array} aoColDefs The aoColumnDefs array that is to be applied @param {array} aoCols The aoColumns array that defines columns individually @param {function} fn Callback function - takes two parameters, the calculated column index and the definition for that column. @memberof DataTable#oApi
[ "Take", "the", "column", "definitions", "and", "static", "columns", "arrays", "and", "calculate", "how", "they", "relate", "to", "column", "indexes", ".", "The", "callback", "function", "will", "then", "apply", "the", "definition", "found", "for", "a", "column...
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L779-L843
35,077
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetCellData
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) { var oCol = oSettings.aoColumns[iCol]; var oData = oSettings.aoData[iRow]._aData; var sData = oCol.fnGetData( oData, sSpecific ); if ( sData === undefined ) { if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null ) { _fnLog( oSettings, 0, "Requested unknown parameter "+ (typeof oCol.mData=='function' ? '{function}' : "'"+oCol.mData+"'")+ " for row "+iRow, 4 ); oSettings.iDrawError = oSettings.iDraw; } return oCol.sDefaultContent; } /* When the data source is null, we can use default column data */ if ( (sData === oData || sData === null) && oCol.sDefaultContent !== null ) { sData = oCol.sDefaultContent; } else if ( typeof sData === 'function' ) { // If the data source is a function, then we run it and use the return return sData(); } if ( sData === null && sSpecific == 'display' ) { return ''; } return sData; }
javascript
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) { var oCol = oSettings.aoColumns[iCol]; var oData = oSettings.aoData[iRow]._aData; var sData = oCol.fnGetData( oData, sSpecific ); if ( sData === undefined ) { if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null ) { _fnLog( oSettings, 0, "Requested unknown parameter "+ (typeof oCol.mData=='function' ? '{function}' : "'"+oCol.mData+"'")+ " for row "+iRow, 4 ); oSettings.iDrawError = oSettings.iDraw; } return oCol.sDefaultContent; } /* When the data source is null, we can use default column data */ if ( (sData === oData || sData === null) && oCol.sDefaultContent !== null ) { sData = oCol.sDefaultContent; } else if ( typeof sData === 'function' ) { // If the data source is a function, then we run it and use the return return sData(); } if ( sData === null && sSpecific == 'display' ) { return ''; } return sData; }
[ "function", "_fnGetCellData", "(", "oSettings", ",", "iRow", ",", "iCol", ",", "sSpecific", ")", "{", "var", "oCol", "=", "oSettings", ".", "aoColumns", "[", "iCol", "]", ";", "var", "oData", "=", "oSettings", ".", "aoData", "[", "iRow", "]", ".", "_aD...
Get the data for a given cell from the internal cache, taking into account data mapping @param {object} oSettings dataTables settings object @param {int} iRow aoData row id @param {int} iCol Column index @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort') @returns {*} Cell data @memberof DataTable#oApi
[ "Get", "the", "data", "for", "a", "given", "cell", "from", "the", "internal", "cache", "taking", "into", "account", "data", "mapping" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L978-L1012
35,078
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnInvalidateRow
function _fnInvalidateRow( settings, rowIdx, src, column ) { var row = settings.aoData[ rowIdx ]; var i, ien; // Are we reading last data from DOM or the data object? if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) { // Read the data from the DOM row._aData = _fnGetRowElements( settings, row.nTr ).data; } else { // Reading from data object, update the DOM var cells = row.anCells; for ( i=0, ien=cells.length ; i<ien ; i++ ) { cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' ); } } row._aSortData = null; row._aFilterData = null; // Invalidate the type for a specific column (if given) or all columns since // the data might have changed var cols = settings.aoColumns; if ( column !== undefined ) { cols[ column ].sType = null; } else { for ( i=0, ien=cols.length ; i<ien ; i++ ) { cols[i].sType = null; } } // Update DataTables special `DT_*` attributes for the row _fnRowAttributes( row ); }
javascript
function _fnInvalidateRow( settings, rowIdx, src, column ) { var row = settings.aoData[ rowIdx ]; var i, ien; // Are we reading last data from DOM or the data object? if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) { // Read the data from the DOM row._aData = _fnGetRowElements( settings, row.nTr ).data; } else { // Reading from data object, update the DOM var cells = row.anCells; for ( i=0, ien=cells.length ; i<ien ; i++ ) { cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' ); } } row._aSortData = null; row._aFilterData = null; // Invalidate the type for a specific column (if given) or all columns since // the data might have changed var cols = settings.aoColumns; if ( column !== undefined ) { cols[ column ].sType = null; } else { for ( i=0, ien=cols.length ; i<ien ; i++ ) { cols[i].sType = null; } } // Update DataTables special `DT_*` attributes for the row _fnRowAttributes( row ); }
[ "function", "_fnInvalidateRow", "(", "settings", ",", "rowIdx", ",", "src", ",", "column", ")", "{", "var", "row", "=", "settings", ".", "aoData", "[", "rowIdx", "]", ";", "var", "i", ",", "ien", ";", "// Are we reading last data from DOM or the data object?\r",...
Mark cached data as invalid such that a re-read of the data will occur when the cached data is next requested. Also update from the data source object. @param {object} settings DataTables settings object @param {int} rowIdx Row index to invalidate @memberof DataTable#oApi @todo For the modularisation of v1.11 this will need to become a callback, so the sort and filter methods can subscribe to it. That will required initialisation options for sorting, which is why it is not already baked in
[ "Mark", "cached", "data", "as", "invalid", "such", "that", "a", "re", "-", "read", "of", "the", "data", "will", "occur", "when", "the", "cached", "data", "is", "next", "requested", ".", "Also", "update", "from", "the", "data", "source", "object", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L1346-L1382
35,079
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetRowElements
function _fnGetRowElements( settings, row ) { var d = [], tds = [], td = row.firstChild, name, col, o, i=0, contents, columns = settings.aoColumns; var attr = function ( str, data, td ) { if ( typeof str === 'string' ) { var idx = str.indexOf('@'); if ( idx !== -1 ) { var src = str.substring( idx+1 ); o[ '@'+src ] = td.getAttribute( src ); } } }; while ( td ) { name = td.nodeName.toUpperCase(); if ( name == "TD" || name == "TH" ) { col = columns[i]; contents = $.trim(td.innerHTML); if ( col && col._bAttrSrc ) { o = { display: contents }; attr( col.mData.sort, o, td ); attr( col.mData.type, o, td ); attr( col.mData.filter, o, td ); d.push( o ); } else { d.push( contents ); } tds.push( td ); i++; } td = td.nextSibling; } return { data: d, cells: tds }; }
javascript
function _fnGetRowElements( settings, row ) { var d = [], tds = [], td = row.firstChild, name, col, o, i=0, contents, columns = settings.aoColumns; var attr = function ( str, data, td ) { if ( typeof str === 'string' ) { var idx = str.indexOf('@'); if ( idx !== -1 ) { var src = str.substring( idx+1 ); o[ '@'+src ] = td.getAttribute( src ); } } }; while ( td ) { name = td.nodeName.toUpperCase(); if ( name == "TD" || name == "TH" ) { col = columns[i]; contents = $.trim(td.innerHTML); if ( col && col._bAttrSrc ) { o = { display: contents }; attr( col.mData.sort, o, td ); attr( col.mData.type, o, td ); attr( col.mData.filter, o, td ); d.push( o ); } else { d.push( contents ); } tds.push( td ); i++; } td = td.nextSibling; } return { data: d, cells: tds }; }
[ "function", "_fnGetRowElements", "(", "settings", ",", "row", ")", "{", "var", "d", "=", "[", "]", ",", "tds", "=", "[", "]", ",", "td", "=", "row", ".", "firstChild", ",", "name", ",", "col", ",", "o", ",", "i", "=", "0", ",", "contents", ",",...
Build a data source object from an HTML row, reading the contents of the cells that are in the row. @param {object} settings DataTables settings object @param {node} TR element from which to read data @returns {object} Object with two parameters: `data` the data read, in document order, and `cells` and array of nodes (they can be useful to the caller, so rather than needing a second traversal to get them, just return them from here). @memberof DataTable#oApi
[ "Build", "a", "data", "source", "object", "from", "an", "HTML", "row", "reading", "the", "contents", "of", "the", "cells", "that", "are", "in", "the", "row", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L1397-L1450
35,080
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnBuildAjax
function _fnBuildAjax( oSettings, data, fn ) { // Compatibility with 1.9-, allow fnServerData and event to manipulate _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] ); // Convert to object based for 1.10+ if using the old scheme if ( data && data.__legacy ) { var tmp = {}; var rbracket = /(.*?)\[\]$/; $.each( data, function (key, val) { var match = val.name.match(rbracket); if ( match ) { // Support for arrays var name = match[0]; if ( ! tmp[ name ] ) { tmp[ name ] = []; } tmp[ name ].push( val.value ); } else { tmp[val.name] = val.value; } } ); data = tmp; } var ajaxData; var ajax = oSettings.ajax; var instance = oSettings.oInstance; if ( $.isPlainObject( ajax ) && ajax.data ) { ajaxData = ajax.data; var newData = $.isFunction( ajaxData ) ? ajaxData( data ) : // fn can manipulate data or return an object ajaxData; // object or array to merge // If the function returned an object, use that alone data = $.isFunction( ajaxData ) && newData ? newData : $.extend( true, data, newData ); // Remove the data property as we've resolved it already and don't want // jQuery to do it again (it is restored at the end of the function) delete ajax.data; } var baseAjax = { "data": data, "success": function (json) { var error = json.error || json.sError; if ( error ) { oSettings.oApi._fnLog( oSettings, 0, error ); } oSettings.json = json; _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); fn( json ); }, "dataType": "json", "cache": false, "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { var log = oSettings.oApi._fnLog; if ( error == "parsererror" ) { log( oSettings, 0, 'Invalid JSON response', 1 ); } else { log( oSettings, 0, 'Ajax error', 7 ); } } }; if ( oSettings.fnServerData ) { // DataTables 1.9- compatibility oSettings.fnServerData.call( instance, oSettings.sAjaxSource, data, fn, oSettings ); } else if ( oSettings.sAjaxSource || typeof ajax === 'string' ) { // DataTables 1.9- compatibility oSettings.jqXHR = $.ajax( $.extend( baseAjax, { url: ajax || oSettings.sAjaxSource } ) ); } else if ( $.isFunction( ajax ) ) { // Is a function - let the caller define what needs to be done oSettings.jqXHR = ajax.call( instance, data, fn, oSettings ); } else { // Object to extend the base settings oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) ); // Restore for next time around ajax.data = ajaxData; } }
javascript
function _fnBuildAjax( oSettings, data, fn ) { // Compatibility with 1.9-, allow fnServerData and event to manipulate _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] ); // Convert to object based for 1.10+ if using the old scheme if ( data && data.__legacy ) { var tmp = {}; var rbracket = /(.*?)\[\]$/; $.each( data, function (key, val) { var match = val.name.match(rbracket); if ( match ) { // Support for arrays var name = match[0]; if ( ! tmp[ name ] ) { tmp[ name ] = []; } tmp[ name ].push( val.value ); } else { tmp[val.name] = val.value; } } ); data = tmp; } var ajaxData; var ajax = oSettings.ajax; var instance = oSettings.oInstance; if ( $.isPlainObject( ajax ) && ajax.data ) { ajaxData = ajax.data; var newData = $.isFunction( ajaxData ) ? ajaxData( data ) : // fn can manipulate data or return an object ajaxData; // object or array to merge // If the function returned an object, use that alone data = $.isFunction( ajaxData ) && newData ? newData : $.extend( true, data, newData ); // Remove the data property as we've resolved it already and don't want // jQuery to do it again (it is restored at the end of the function) delete ajax.data; } var baseAjax = { "data": data, "success": function (json) { var error = json.error || json.sError; if ( error ) { oSettings.oApi._fnLog( oSettings, 0, error ); } oSettings.json = json; _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); fn( json ); }, "dataType": "json", "cache": false, "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { var log = oSettings.oApi._fnLog; if ( error == "parsererror" ) { log( oSettings, 0, 'Invalid JSON response', 1 ); } else { log( oSettings, 0, 'Ajax error', 7 ); } } }; if ( oSettings.fnServerData ) { // DataTables 1.9- compatibility oSettings.fnServerData.call( instance, oSettings.sAjaxSource, data, fn, oSettings ); } else if ( oSettings.sAjaxSource || typeof ajax === 'string' ) { // DataTables 1.9- compatibility oSettings.jqXHR = $.ajax( $.extend( baseAjax, { url: ajax || oSettings.sAjaxSource } ) ); } else if ( $.isFunction( ajax ) ) { // Is a function - let the caller define what needs to be done oSettings.jqXHR = ajax.call( instance, data, fn, oSettings ); } else { // Object to extend the base settings oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) ); // Restore for next time around ajax.data = ajaxData; } }
[ "function", "_fnBuildAjax", "(", "oSettings", ",", "data", ",", "fn", ")", "{", "// Compatibility with 1.9-, allow fnServerData and event to manipulate\r", "_fnCallbackFire", "(", "oSettings", ",", "'aoServerParams'", ",", "'serverParams'", ",", "[", "data", "]", ")", "...
Create an Ajax call based on the table's settings, taking into account that parameters can have multiple forms, and backwards compatibility. @param {object} oSettings dataTables settings object @param {array} data Data to send to the server, required by DataTables - may be augmented by developer callbacks @param {function} fn Callback function to run when data is obtained
[ "Create", "an", "Ajax", "call", "based", "on", "the", "table", "s", "settings", "taking", "into", "account", "that", "parameters", "can", "have", "multiple", "forms", "and", "backwards", "compatibility", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L2199-L2304
35,081
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnAjaxDataSrc
function _fnAjaxDataSrc ( oSettings, json ) { var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ? oSettings.ajax.dataSrc : oSettings.sAjaxDataProp; // Compatibility with 1.9-. // Compatibility with 1.9-. In order to read from aaData, check if the // default has been changed, if not, check for aaData if ( dataSrc === 'data' ) { return json.aaData || json[dataSrc]; } return dataSrc !== "" ? _fnGetObjectDataFn( dataSrc )( json ) : json; }
javascript
function _fnAjaxDataSrc ( oSettings, json ) { var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ? oSettings.ajax.dataSrc : oSettings.sAjaxDataProp; // Compatibility with 1.9-. // Compatibility with 1.9-. In order to read from aaData, check if the // default has been changed, if not, check for aaData if ( dataSrc === 'data' ) { return json.aaData || json[dataSrc]; } return dataSrc !== "" ? _fnGetObjectDataFn( dataSrc )( json ) : json; }
[ "function", "_fnAjaxDataSrc", "(", "oSettings", ",", "json", ")", "{", "var", "dataSrc", "=", "$", ".", "isPlainObject", "(", "oSettings", ".", "ajax", ")", "&&", "oSettings", ".", "ajax", ".", "dataSrc", "!==", "undefined", "?", "oSettings", ".", "ajax", ...
Get the data from the JSON data source to use for drawing a table. Using `_fnGetObjectDataFn` allows the data to be sourced from a property of the source object, or from a processing function. @param {object} oSettings dataTables settings object @param {object} json Data source object / array from the server @return {array} Array of data to use
[ "Get", "the", "data", "from", "the", "JSON", "data", "source", "to", "use", "for", "drawing", "a", "table", ".", "Using", "_fnGetObjectDataFn", "allows", "the", "data", "to", "be", "sourced", "from", "a", "property", "of", "the", "source", "object", "or", ...
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L2494-L2509
35,082
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function(nSizer) { var style = nSizer.style; style.paddingTop = "0"; style.paddingBottom = "0"; style.borderTopWidth = "0"; style.borderBottomWidth = "0"; style.height = 0; }
javascript
function(nSizer) { var style = nSizer.style; style.paddingTop = "0"; style.paddingBottom = "0"; style.borderTopWidth = "0"; style.borderBottomWidth = "0"; style.height = 0; }
[ "function", "(", "nSizer", ")", "{", "var", "style", "=", "nSizer", ".", "style", ";", "style", ".", "paddingTop", "=", "\"0\"", ";", "style", ".", "paddingBottom", "=", "\"0\"", ";", "style", ".", "borderTopWidth", "=", "\"0\"", ";", "style", ".", "bo...
Given that this is such a monster function, a lot of variables are use to try and keep the minimised size as small as possible
[ "Given", "that", "this", "is", "such", "a", "monster", "function", "a", "lot", "of", "variables", "are", "use", "to", "try", "and", "keep", "the", "minimised", "size", "as", "small", "as", "possible" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L3473-L3480
35,083
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnScrollingWidthAdjust
function _fnScrollingWidthAdjust ( settings, n ) { var scroll = settings.oScroll; if ( scroll.sX || scroll.sY ) { // When y-scrolling only, we want to remove the width of the scroll bar // so the table + scroll bar will fit into the area available, otherwise // we fix the table at its current size with no adjustment var correction = ! scroll.sX ? scroll.iBarWidth : 0; n.style.width = _fnStringToCss( $(n).outerWidth() - correction ); } }
javascript
function _fnScrollingWidthAdjust ( settings, n ) { var scroll = settings.oScroll; if ( scroll.sX || scroll.sY ) { // When y-scrolling only, we want to remove the width of the scroll bar // so the table + scroll bar will fit into the area available, otherwise // we fix the table at its current size with no adjustment var correction = ! scroll.sX ? scroll.iBarWidth : 0; n.style.width = _fnStringToCss( $(n).outerWidth() - correction ); } }
[ "function", "_fnScrollingWidthAdjust", "(", "settings", ",", "n", ")", "{", "var", "scroll", "=", "settings", ".", "oScroll", ";", "if", "(", "scroll", ".", "sX", "||", "scroll", ".", "sY", ")", "{", "// When y-scrolling only, we want to remove the width of the sc...
Adjust a table's width to take account of vertical scroll bar @param {object} oSettings dataTables settings object @param {node} n table node @memberof DataTable#oApi
[ "Adjust", "a", "table", "s", "width", "to", "take", "account", "of", "vertical", "scroll", "bar" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L3986-L3997
35,084
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnScrollBarWidth
function _fnScrollBarWidth () { // On first run a static variable is set, since this is only needed once. // Subsequent runs will just use the previously calculated value if ( ! DataTable.__scrollbarWidth ) { var inner = $('<p/>').css( { width: '100%', height: 200, padding: 0 } )[0]; var outer = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, width: 200, height: 150, padding: 0, overflow: 'hidden', visibility: 'hidden' } ) .append( inner ) .appendTo( 'body' ); var w1 = inner.offsetWidth; outer.css( 'overflow', 'scroll' ); var w2 = inner.offsetWidth; if ( w1 === w2 ) { w2 = outer[0].clientWidth; } outer.remove(); DataTable.__scrollbarWidth = w1 - w2; } return DataTable.__scrollbarWidth; }
javascript
function _fnScrollBarWidth () { // On first run a static variable is set, since this is only needed once. // Subsequent runs will just use the previously calculated value if ( ! DataTable.__scrollbarWidth ) { var inner = $('<p/>').css( { width: '100%', height: 200, padding: 0 } )[0]; var outer = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, width: 200, height: 150, padding: 0, overflow: 'hidden', visibility: 'hidden' } ) .append( inner ) .appendTo( 'body' ); var w1 = inner.offsetWidth; outer.css( 'overflow', 'scroll' ); var w2 = inner.offsetWidth; if ( w1 === w2 ) { w2 = outer[0].clientWidth; } outer.remove(); DataTable.__scrollbarWidth = w1 - w2; } return DataTable.__scrollbarWidth; }
[ "function", "_fnScrollBarWidth", "(", ")", "{", "// On first run a static variable is set, since this is only needed once.\r", "// Subsequent runs will just use the previously calculated value\r", "if", "(", "!", "DataTable", ".", "__scrollbarWidth", ")", "{", "var", "inner", "=", ...
Get the width of a scroll bar in this browser being used @returns {int} width in pixels @memberof DataTable#oApi
[ "Get", "the", "width", "of", "a", "scroll", "bar", "in", "this", "browser", "being", "used" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4076-L4115
35,085
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnSortListener
function _fnSortListener ( settings, colIdx, append, callback ) { var col = settings.aoColumns[ colIdx ]; var sorting = settings.aaSorting; var asSorting = col.asSorting; var nextSortIdx; var next = function ( a ) { var idx = a._idx; if ( idx === undefined ) { idx = $.inArray( a[1], asSorting ); } return idx+1 >= asSorting.length ? 0 : idx+1; }; // If appending the sort then we are multi-column sorting if ( append && settings.oFeatures.bSortMulti ) { // Are we already doing some kind of sort on this column? var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') ); if ( sortIdx !== -1 ) { // Yes, modify the sort nextSortIdx = next( sorting[sortIdx] ); sorting[sortIdx][1] = asSorting[ nextSortIdx ]; sorting[sortIdx]._idx = nextSortIdx; } else { // No sort on this column yet sorting.push( [ colIdx, asSorting[0], 0 ] ); sorting[sorting.length-1]._idx = 0; } } else if ( sorting.length && sorting[0][0] == colIdx ) { // Single column - already sorting on this column, modify the sort nextSortIdx = next( sorting[0] ); sorting.length = 1; sorting[0][1] = asSorting[ nextSortIdx ]; sorting[0]._idx = nextSortIdx; } else { // Single column - sort only on this column sorting.length = 0; sorting.push( [ colIdx, asSorting[0] ] ); sorting[0]._idx = 0; } // Run the sort by calling a full redraw _fnReDraw( settings ); // callback used for async user interaction if ( typeof callback == 'function' ) { callback( settings ); } }
javascript
function _fnSortListener ( settings, colIdx, append, callback ) { var col = settings.aoColumns[ colIdx ]; var sorting = settings.aaSorting; var asSorting = col.asSorting; var nextSortIdx; var next = function ( a ) { var idx = a._idx; if ( idx === undefined ) { idx = $.inArray( a[1], asSorting ); } return idx+1 >= asSorting.length ? 0 : idx+1; }; // If appending the sort then we are multi-column sorting if ( append && settings.oFeatures.bSortMulti ) { // Are we already doing some kind of sort on this column? var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') ); if ( sortIdx !== -1 ) { // Yes, modify the sort nextSortIdx = next( sorting[sortIdx] ); sorting[sortIdx][1] = asSorting[ nextSortIdx ]; sorting[sortIdx]._idx = nextSortIdx; } else { // No sort on this column yet sorting.push( [ colIdx, asSorting[0], 0 ] ); sorting[sorting.length-1]._idx = 0; } } else if ( sorting.length && sorting[0][0] == colIdx ) { // Single column - already sorting on this column, modify the sort nextSortIdx = next( sorting[0] ); sorting.length = 1; sorting[0][1] = asSorting[ nextSortIdx ]; sorting[0]._idx = nextSortIdx; } else { // Single column - sort only on this column sorting.length = 0; sorting.push( [ colIdx, asSorting[0] ] ); sorting[0]._idx = 0; } // Run the sort by calling a full redraw _fnReDraw( settings ); // callback used for async user interaction if ( typeof callback == 'function' ) { callback( settings ); } }
[ "function", "_fnSortListener", "(", "settings", ",", "colIdx", ",", "append", ",", "callback", ")", "{", "var", "col", "=", "settings", ".", "aoColumns", "[", "colIdx", "]", ";", "var", "sorting", "=", "settings", ".", "aaSorting", ";", "var", "asSorting",...
Function to run on user sort request @param {object} settings dataTables settings object @param {node} attachTo node to attach the handler to @param {int} colIdx column sorting index @param {boolean} [append=false] Append the requested sort to the existing sort if true (i.e. multi-column sort) @param {function} [callback] callback function @memberof DataTable#oApi
[ "Function", "to", "run", "on", "user", "sort", "request" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4362-L4417
35,086
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnLoadState
function _fnLoadState ( oSettings, oInit ) { var i, ien; var columns = oSettings.aoColumns; if ( !oSettings.oFeatures.bStateSave ) { return; } var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; } /* Allow custom and plug-in manipulation functions to alter the saved data set and * cancelling of loading by returning false */ var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] ); if ( $.inArray( false, abStateLoad ) !== -1 ) { return; } /* Reject old data */ if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { return; } // Number of columns have changed - all bets are off, no restore of settings if ( columns.length !== oData.aoSearchCols.length ) { return; } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); /* Restore key features */ oSettings._iDisplayStart = oData.iStart; oSettings.iInitDisplayStart = oData.iStart; oSettings._iDisplayLength = oData.iLength; oSettings.aaSorting = []; var savedSort = oData.aaSorting; for ( i=0, ien=savedSort.length ; i<ien ; i++ ) { oSettings.aaSorting.push( savedSort[i][0] >= columns.length ? [ 0, savedSort[i][1] ] : savedSort[i] ); } /* Search filtering */ $.extend( oSettings.oPreviousSearch, oData.oSearch ); $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols ); /* Column visibility state */ for ( i=0, ien=oData.abVisCols.length ; i<ien ; i++ ) { columns[i].bVisible = oData.abVisCols[i]; } _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] ); }
javascript
function _fnLoadState ( oSettings, oInit ) { var i, ien; var columns = oSettings.aoColumns; if ( !oSettings.oFeatures.bStateSave ) { return; } var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; } /* Allow custom and plug-in manipulation functions to alter the saved data set and * cancelling of loading by returning false */ var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] ); if ( $.inArray( false, abStateLoad ) !== -1 ) { return; } /* Reject old data */ if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { return; } // Number of columns have changed - all bets are off, no restore of settings if ( columns.length !== oData.aoSearchCols.length ) { return; } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); /* Restore key features */ oSettings._iDisplayStart = oData.iStart; oSettings.iInitDisplayStart = oData.iStart; oSettings._iDisplayLength = oData.iLength; oSettings.aaSorting = []; var savedSort = oData.aaSorting; for ( i=0, ien=savedSort.length ; i<ien ; i++ ) { oSettings.aaSorting.push( savedSort[i][0] >= columns.length ? [ 0, savedSort[i][1] ] : savedSort[i] ); } /* Search filtering */ $.extend( oSettings.oPreviousSearch, oData.oSearch ); $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols ); /* Column visibility state */ for ( i=0, ien=oData.abVisCols.length ; i<ien ; i++ ) { columns[i].bVisible = oData.abVisCols[i]; } _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] ); }
[ "function", "_fnLoadState", "(", "oSettings", ",", "oInit", ")", "{", "var", "i", ",", "ien", ";", "var", "columns", "=", "oSettings", ".", "aoColumns", ";", "if", "(", "!", "oSettings", ".", "oFeatures", ".", "bStateSave", ")", "{", "return", ";", "}"...
Attempt to load a saved table state @param {object} oSettings dataTables settings object @param {object} oInit DataTables init object so we can override settings @memberof DataTable#oApi
[ "Attempt", "to", "load", "a", "saved", "table", "state" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4572-L4634
35,087
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( mixed ) { var idx, jq; var settings = DataTable.settings; var tables = $.map( settings, function (el, i) { return el.nTable; } ); if ( mixed.nTable && mixed.oApi ) { // DataTables settings object return [ mixed ]; } else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) { // Table node idx = $.inArray( mixed, tables ); return idx !== -1 ? [ settings[idx] ] : null; } else if ( typeof mixed === 'string' ) { // jQuery selector jq = $(mixed); } else if ( mixed instanceof $ ) { // jQuery object (also DataTables instance) jq = mixed; } if ( jq ) { return jq.map( function(i) { idx = $.inArray( this, tables ); return idx !== -1 ? settings[idx] : null; } ); } }
javascript
function ( mixed ) { var idx, jq; var settings = DataTable.settings; var tables = $.map( settings, function (el, i) { return el.nTable; } ); if ( mixed.nTable && mixed.oApi ) { // DataTables settings object return [ mixed ]; } else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) { // Table node idx = $.inArray( mixed, tables ); return idx !== -1 ? [ settings[idx] ] : null; } else if ( typeof mixed === 'string' ) { // jQuery selector jq = $(mixed); } else if ( mixed instanceof $ ) { // jQuery object (also DataTables instance) jq = mixed; } if ( jq ) { return jq.map( function(i) { idx = $.inArray( this, tables ); return idx !== -1 ? settings[idx] : null; } ); } }
[ "function", "(", "mixed", ")", "{", "var", "idx", ",", "jq", ";", "var", "settings", "=", "DataTable", ".", "settings", ";", "var", "tables", "=", "$", ".", "map", "(", "settings", ",", "function", "(", "el", ",", "i", ")", "{", "return", "el", "...
Abstraction for `context` parameter of the `Api` constructor to allow it to take several different forms for ease of use. Each of the input parameter types will be converted to a DataTables settings object where possible. @param {string|node|jQuery|object} mixed DataTable identifier. Can be one of: * `string` - jQuery selector. Any DataTables' matching the given selector with be found and used. * `node` - `TABLE` node which has already been formed into a DataTable. * `jQuery` - A jQuery object of `TABLE` nodes. * `object` - DataTables settings object @return {array|null} Matching DataTables settings objects. `null` or `undefined` is returned if no matching DataTable is found. @ignore
[ "Abstraction", "for", "context", "parameter", "of", "the", "Api", "constructor", "to", "allow", "it", "to", "take", "several", "different", "forms", "for", "ease", "of", "use", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6339-L6371
35,088
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( fn ) { if ( __arrayProto.forEach ) { // Where possible, use the built-in forEach __arrayProto.forEach.call( this, fn, this ); } else { // Compatibility for browsers without EMCA-252-5 (JS 1.6) for ( var i=0, ien=this.length ; i<ien; i++ ) { // In strict mode the execution scope is the passed value fn.call( this, this[i], i, this ); } } return this; }
javascript
function ( fn ) { if ( __arrayProto.forEach ) { // Where possible, use the built-in forEach __arrayProto.forEach.call( this, fn, this ); } else { // Compatibility for browsers without EMCA-252-5 (JS 1.6) for ( var i=0, ien=this.length ; i<ien; i++ ) { // In strict mode the execution scope is the passed value fn.call( this, this[i], i, this ); } } return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "__arrayProto", ".", "forEach", ")", "{", "// Where possible, use the built-in forEach\r", "__arrayProto", ".", "forEach", ".", "call", "(", "this", ",", "fn", ",", "this", ")", ";", "}", "else", "{", "// Compatibi...
array of table settings objects
[ "array", "of", "table", "settings", "objects" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6491-L6506
35,089
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( flatten, type, fn ) { var a = [], ret, i, ien, j, jen, context = this.context, rows, items, item, selector = this.selector; // Argument shifting if ( typeof flatten === 'string' ) { fn = type; type = flatten; flatten = false; } for ( i=0, ien=context.length ; i<ien ; i++ ) { if ( type === 'table' ) { ret = fn( context[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'columns' || type === 'rows' ) { // this has same length as context - one entry for each table ret = fn( context[i], this[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) { // columns and rows share the same structure. // 'this' is an array of column indexes for each context items = this[i]; if ( type === 'column-rows' ) { rows = _selector_row_indexes( context[i], selector.opts ); } for ( j=0, jen=items.length ; j<jen ; j++ ) { item = items[j]; if ( type === 'cell' ) { ret = fn( context[i], item.row, item.column, i, j ); } else { ret = fn( context[i], item, i, j, rows ); } if ( ret !== undefined ) { a.push( ret ); } } } } if ( a.length ) { var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a ); var apiSelector = api.selector; apiSelector.rows = selector.rows; apiSelector.cols = selector.cols; apiSelector.opts = selector.opts; return api; } return this; }
javascript
function ( flatten, type, fn ) { var a = [], ret, i, ien, j, jen, context = this.context, rows, items, item, selector = this.selector; // Argument shifting if ( typeof flatten === 'string' ) { fn = type; type = flatten; flatten = false; } for ( i=0, ien=context.length ; i<ien ; i++ ) { if ( type === 'table' ) { ret = fn( context[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'columns' || type === 'rows' ) { // this has same length as context - one entry for each table ret = fn( context[i], this[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) { // columns and rows share the same structure. // 'this' is an array of column indexes for each context items = this[i]; if ( type === 'column-rows' ) { rows = _selector_row_indexes( context[i], selector.opts ); } for ( j=0, jen=items.length ; j<jen ; j++ ) { item = items[j]; if ( type === 'cell' ) { ret = fn( context[i], item.row, item.column, i, j ); } else { ret = fn( context[i], item, i, j, rows ); } if ( ret !== undefined ) { a.push( ret ); } } } } if ( a.length ) { var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a ); var apiSelector = api.selector; apiSelector.rows = selector.rows; apiSelector.cols = selector.cols; apiSelector.opts = selector.opts; return api; } return this; }
[ "function", "(", "flatten", ",", "type", ",", "fn", ")", "{", "var", "a", "=", "[", "]", ",", "ret", ",", "i", ",", "ien", ",", "j", ",", "jen", ",", "context", "=", "this", ".", "context", ",", "rows", ",", "items", ",", "item", ",", "select...
Internal only at the moment - relax?
[ "Internal", "only", "at", "the", "moment", "-", "relax?" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6550-L6616
35,090
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( selector, a ) { // Integer is used to pick out a table by index if ( typeof selector === 'number' ) { return [ a[ selector ] ]; } // Perform a jQuery selector on the table nodes var nodes = $.map( a, function (el, i) { return el.nTable; } ); return $(nodes) .filter( selector ) .map( function (i) { // Need to translate back from the table node to the settings var idx = $.inArray( this, nodes ); return a[ idx ]; } ) .toArray(); }
javascript
function ( selector, a ) { // Integer is used to pick out a table by index if ( typeof selector === 'number' ) { return [ a[ selector ] ]; } // Perform a jQuery selector on the table nodes var nodes = $.map( a, function (el, i) { return el.nTable; } ); return $(nodes) .filter( selector ) .map( function (i) { // Need to translate back from the table node to the settings var idx = $.inArray( this, nodes ); return a[ idx ]; } ) .toArray(); }
[ "function", "(", "selector", ",", "a", ")", "{", "// Integer is used to pick out a table by index\r", "if", "(", "typeof", "selector", "===", "'number'", ")", "{", "return", "[", "a", "[", "selector", "]", "]", ";", "}", "// Perform a jQuery selector on the table no...
Selector for HTML tables. Apply the given selector to the give array of DataTables settings objects. @param {string|integer} [selector] jQuery selector string or integer @param {array} Array of DataTables settings objects to be filtered @return {array} @ignore
[ "Selector", "for", "HTML", "tables", ".", "Apply", "the", "given", "selector", "to", "the", "give", "array", "of", "DataTables", "settings", "objects", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6923-L6943
35,091
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function () { var len = this._iDisplayLength, start = this._iDisplayStart, calc = start + len, records = this.aiDisplay.length, features = this.oFeatures, paginate = features.bPaginate; if ( features.bServerSide ) { return paginate === false || len === -1 ? start + records : Math.min( start+len, this._iRecordsDisplay ); } else { return ! paginate || calc>records || len===-1 ? records : calc; } }
javascript
function () { var len = this._iDisplayLength, start = this._iDisplayStart, calc = start + len, records = this.aiDisplay.length, features = this.oFeatures, paginate = features.bPaginate; if ( features.bServerSide ) { return paginate === false || len === -1 ? start + records : Math.min( start+len, this._iRecordsDisplay ); } else { return ! paginate || calc>records || len===-1 ? records : calc; } }
[ "function", "(", ")", "{", "var", "len", "=", "this", ".", "_iDisplayLength", ",", "start", "=", "this", ".", "_iDisplayStart", ",", "calc", "=", "start", "+", "len", ",", "records", "=", "this", ".", "aiDisplay", ".", "length", ",", "features", "=", ...
Get the display end point - aiDisplay index @type function
[ "Get", "the", "display", "end", "point", "-", "aiDisplay", "index" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L12783-L12803
35,092
layerhq/node-layer-api
lib/resources/identities.js
function(userId, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identities get: ' + userId); request.get({ path: '/users/' + userId + '/identity' }, callback); }
javascript
function(userId, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identities get: ' + userId); request.get({ path: '/users/' + userId + '/identity' }, callback); }
[ "function", "(", "userId", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "identities", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Identities get: '", ...
Retrieve an Identity @param {String} userId User ID @param {Function} callback Callback function
[ "Retrieve", "an", "Identity" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/identities.js#L38-L45
35,093
layerhq/node-layer-api
lib/resources/identities.js
function(userId, properties, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identity edit: ' + userId); request.patch({ path: '/users/' + userId + '/identity', body: Object.keys(properties).map(function(propertyName) { return { operation: 'set', property: propertyName, value: properties[propertyName] }; }) }, callback || utils.nop); }
javascript
function(userId, properties, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identity edit: ' + userId); request.patch({ path: '/users/' + userId + '/identity', body: Object.keys(properties).map(function(propertyName) { return { operation: 'set', property: propertyName, value: properties[propertyName] }; }) }, callback || utils.nop); }
[ "function", "(", "userId", ",", "properties", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "identities", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "...
Edit Identity properties. @param {String} userId User ID @param {Object} properties Hash of properties to update @param {Function} callback Callback function
[ "Edit", "Identity", "properties", "." ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/identities.js#L54-L68
35,094
altairstudios/nodeserver
core/workers/node.js
function(website) { var self = this; var scriptPath = path.dirname(website.script); var script = ''; var port = website.port; if(website.absoluteScript === false) { scriptPath = process.cwd() + '/' + path.dirname(website.script); } script = path.basename(website.script); var env = JSON.parse(JSON.stringify(process.env)); env.PORT = port; var spawnOptions = { env: env, cwd: scriptPath, stdio: 'pipe', detached: false }; var child = childProcess.spawn(process.execPath, [script], spawnOptions); website.process = child; website.processStatus = 'start'; child.stderr.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'error'); }); child.stdout.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'log'); }); child.on('exit', function(code, signal) { website.writeLog('cgi spawn ' + child.pid + ' "exit" event (code ' + code + ') (signal ' + signal + ') (status ' + website.processStatus + ')', 'log'); if(website.processStatus == 'stop') { website.processStatus = 'end'; } else { website.processStatus = 'end'; self.start(website); } }); website.operations = { stop: function() { website.processStatus = 'stop'; child.kill('SIGINT'); }, reboot: function() { website.processStatus = 'stop'; child.kill('SIGINT'); website.operations.stop(); website.operations.start(); }, start: function() { self.start(website); } }; }
javascript
function(website) { var self = this; var scriptPath = path.dirname(website.script); var script = ''; var port = website.port; if(website.absoluteScript === false) { scriptPath = process.cwd() + '/' + path.dirname(website.script); } script = path.basename(website.script); var env = JSON.parse(JSON.stringify(process.env)); env.PORT = port; var spawnOptions = { env: env, cwd: scriptPath, stdio: 'pipe', detached: false }; var child = childProcess.spawn(process.execPath, [script], spawnOptions); website.process = child; website.processStatus = 'start'; child.stderr.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'error'); }); child.stdout.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'log'); }); child.on('exit', function(code, signal) { website.writeLog('cgi spawn ' + child.pid + ' "exit" event (code ' + code + ') (signal ' + signal + ') (status ' + website.processStatus + ')', 'log'); if(website.processStatus == 'stop') { website.processStatus = 'end'; } else { website.processStatus = 'end'; self.start(website); } }); website.operations = { stop: function() { website.processStatus = 'stop'; child.kill('SIGINT'); }, reboot: function() { website.processStatus = 'stop'; child.kill('SIGINT'); website.operations.stop(); website.operations.start(); }, start: function() { self.start(website); } }; }
[ "function", "(", "website", ")", "{", "var", "self", "=", "this", ";", "var", "scriptPath", "=", "path", ".", "dirname", "(", "website", ".", "script", ")", ";", "var", "script", "=", "''", ";", "var", "port", "=", "website", ".", "port", ";", "if"...
Start the nodejs process. Spawn the proccess and listen on a port @param {Website} website Website to start
[ "Start", "the", "nodejs", "process", ".", "Spawn", "the", "proccess", "and", "listen", "on", "a", "port" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/core/workers/node.js#L16-L77
35,095
elidoran/comma-number
lib/index.js
commaNumber
function commaNumber(inputNumber, optionalSeparator, optionalDecimalChar) { // we'll strip off and hold the decimal value to reattach later. // we'll hold both the `number` value and `stringNumber` value. let number, stringNumber, decimal // default `separator` is a comma const separator = optionalSeparator || ',' // default `decimalChar` is a period const decimalChar = optionalDecimalChar || '.' switch (typeof inputNumber) { case 'string': // if there aren't enough digits to need separators then return it // NOTE: some numbers which are too small will get passed this // when they have decimal values which make them too long here. // but, the number value check after this switch will catch it. if (inputNumber.length < (inputNumber[0] === '-' ? 5 : 4)) { return inputNumber } // remember it as a string in `stringNumber` and convert to a Number stringNumber = inputNumber // if they're not using the Node standard decimal char then replace it // before converting. number = decimalChar !== '.' ? Number(stringNumber.replace(decimalChar, '.')) : Number(stringNumber) break // convert to a string. // NOTE: don't check if the number is too small before converting // because we'll need to return `stringNumber` anyway. case 'number': stringNumber = String(inputNumber) number = inputNumber break // return invalid type as-is default: return inputNumber } // when it doesn't need a separator or isn't a number then return it if ((-1000 < number && number < 1000) || isNaN(number) || !isFinite(number)) { return stringNumber } // strip off decimal value to append to the final result at the bottom let decimalIndex = stringNumber.lastIndexOf(decimalChar) if (decimalIndex > -1) { decimal = stringNumber.slice(decimalIndex) stringNumber = stringNumber.slice(0, -decimal.length) } // else { // decimal = null // } // finally, parse the string and add in separators stringNumber = parse(stringNumber, separator) // if there's a decimal value add it back on the end. // NOTE: we sliced() it off including the decimalChar, so it's good. return decimal ? stringNumber + decimal : stringNumber }
javascript
function commaNumber(inputNumber, optionalSeparator, optionalDecimalChar) { // we'll strip off and hold the decimal value to reattach later. // we'll hold both the `number` value and `stringNumber` value. let number, stringNumber, decimal // default `separator` is a comma const separator = optionalSeparator || ',' // default `decimalChar` is a period const decimalChar = optionalDecimalChar || '.' switch (typeof inputNumber) { case 'string': // if there aren't enough digits to need separators then return it // NOTE: some numbers which are too small will get passed this // when they have decimal values which make them too long here. // but, the number value check after this switch will catch it. if (inputNumber.length < (inputNumber[0] === '-' ? 5 : 4)) { return inputNumber } // remember it as a string in `stringNumber` and convert to a Number stringNumber = inputNumber // if they're not using the Node standard decimal char then replace it // before converting. number = decimalChar !== '.' ? Number(stringNumber.replace(decimalChar, '.')) : Number(stringNumber) break // convert to a string. // NOTE: don't check if the number is too small before converting // because we'll need to return `stringNumber` anyway. case 'number': stringNumber = String(inputNumber) number = inputNumber break // return invalid type as-is default: return inputNumber } // when it doesn't need a separator or isn't a number then return it if ((-1000 < number && number < 1000) || isNaN(number) || !isFinite(number)) { return stringNumber } // strip off decimal value to append to the final result at the bottom let decimalIndex = stringNumber.lastIndexOf(decimalChar) if (decimalIndex > -1) { decimal = stringNumber.slice(decimalIndex) stringNumber = stringNumber.slice(0, -decimal.length) } // else { // decimal = null // } // finally, parse the string and add in separators stringNumber = parse(stringNumber, separator) // if there's a decimal value add it back on the end. // NOTE: we sliced() it off including the decimalChar, so it's good. return decimal ? stringNumber + decimal : stringNumber }
[ "function", "commaNumber", "(", "inputNumber", ",", "optionalSeparator", ",", "optionalDecimalChar", ")", "{", "// we'll strip off and hold the decimal value to reattach later.", "// we'll hold both the `number` value and `stringNumber` value.", "let", "number", ",", "stringNumber", ...
return a string with the provided number formatted with commas. can specify either a Number or a String.
[ "return", "a", "string", "with", "the", "provided", "number", "formatted", "with", "commas", ".", "can", "specify", "either", "a", "Number", "or", "a", "String", "." ]
4aaca601ec6a69b56b61d1fb104c191b1848aadc
https://github.com/elidoran/comma-number/blob/4aaca601ec6a69b56b61d1fb104c191b1848aadc/lib/index.js#L5-L74
35,096
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function () { var coming = F.coming; if (!coming || false === F.trigger('onCancel')) { return; } F.hideLoading(); if (F.ajaxLoad) { F.ajaxLoad.abort(); } F.ajaxLoad = null; if (F.imgPreload) { F.imgPreload.onload = F.imgPreload.onerror = null; } if (coming.wrap) { coming.wrap.stop(true, true).trigger('onReset').remove(); } F.coming = null; // If the first item has been canceled, then clear everything if (!F.current) { F._afterZoomOut( coming ); } }
javascript
function () { var coming = F.coming; if (!coming || false === F.trigger('onCancel')) { return; } F.hideLoading(); if (F.ajaxLoad) { F.ajaxLoad.abort(); } F.ajaxLoad = null; if (F.imgPreload) { F.imgPreload.onload = F.imgPreload.onerror = null; } if (coming.wrap) { coming.wrap.stop(true, true).trigger('onReset').remove(); } F.coming = null; // If the first item has been canceled, then clear everything if (!F.current) { F._afterZoomOut( coming ); } }
[ "function", "(", ")", "{", "var", "coming", "=", "F", ".", "coming", ";", "if", "(", "!", "coming", "||", "false", "===", "F", ".", "trigger", "(", "'onCancel'", ")", ")", "{", "return", ";", "}", "F", ".", "hideLoading", "(", ")", ";", "if", "...
Cancel image loading or abort ajax request
[ "Cancel", "image", "loading", "or", "abort", "ajax", "request" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L363-L392
35,097
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.next; } F.jumpto(current.index + 1, direction, 'next'); } }
javascript
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.next; } F.jumpto(current.index + 1, direction, 'next'); } }
[ "function", "(", "direction", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "current", ")", "{", "if", "(", "!", "isString", "(", "direction", ")", ")", "{", "direction", "=", "current", ".", "direction", ".", "next", ";", "...
Navigate to next gallery item
[ "Navigate", "to", "next", "gallery", "item" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L473-L483
35,098
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.prev; } F.jumpto(current.index - 1, direction, 'prev'); } }
javascript
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.prev; } F.jumpto(current.index - 1, direction, 'prev'); } }
[ "function", "(", "direction", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "current", ")", "{", "if", "(", "!", "isString", "(", "direction", ")", ")", "{", "direction", "=", "current", ".", "direction", ".", "prev", ";", "...
Navigate to previous gallery item
[ "Navigate", "to", "previous", "gallery", "item" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L486-L496
35,099
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( index, direction, router ) { var current = F.current; if (!current) { return; } index = getScalar(index); F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; F.router = router || 'jumpto'; if (current.loop) { if (index < 0) { index = current.group.length + (index % current.group.length); } index = index % current.group.length; } if (current.group[ index ] !== undefined) { F.cancel(); F._start(index); } }
javascript
function ( index, direction, router ) { var current = F.current; if (!current) { return; } index = getScalar(index); F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; F.router = router || 'jumpto'; if (current.loop) { if (index < 0) { index = current.group.length + (index % current.group.length); } index = index % current.group.length; } if (current.group[ index ] !== undefined) { F.cancel(); F._start(index); } }
[ "function", "(", "index", ",", "direction", ",", "router", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "!", "current", ")", "{", "return", ";", "}", "index", "=", "getScalar", "(", "index", ")", ";", "F", ".", "direction",...
Navigate to gallery item by index
[ "Navigate", "to", "gallery", "item", "by", "index" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L499-L524