id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
34,600
cedx/lcov.js
example/main.js
formatReport
function formatReport() { // eslint-disable-line no-unused-vars const lineCoverage = new LineCoverage(2, 2, [ new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'), new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w') ]); const record = new Record('/home/cedx/lcov.js/fixture.js', { functions: new FunctionCoverage(1, 1), lines: lineCoverage }); const report = new Report('Example', [record]); console.log(report.toString()); }
javascript
function formatReport() { // eslint-disable-line no-unused-vars const lineCoverage = new LineCoverage(2, 2, [ new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'), new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w') ]); const record = new Record('/home/cedx/lcov.js/fixture.js', { functions: new FunctionCoverage(1, 1), lines: lineCoverage }); const report = new Report('Example', [record]); console.log(report.toString()); }
[ "function", "formatReport", "(", ")", "{", "// eslint-disable-line no-unused-vars", "const", "lineCoverage", "=", "new", "LineCoverage", "(", "2", ",", "2", ",", "[", "new", "LineData", "(", "6", ",", "2", ",", "'PF4Rz2r7RTliO9u6bZ7h6g'", ")", ",", "new", "Lin...
Formats coverage data as LCOV report.
[ "Formats", "coverage", "data", "as", "LCOV", "report", "." ]
63a56e188478753fe3b8c12721b8a19f858258c4
https://github.com/cedx/lcov.js/blob/63a56e188478753fe3b8c12721b8a19f858258c4/example/main.js#L5-L18
34,601
cedx/lcov.js
example/main.js
parseReport
async function parseReport() { // eslint-disable-line no-unused-vars try { const coverage = await promises.readFile('lcov.info', 'utf8'); const report = Report.fromCoverage(coverage); console.log(`The coverage report contains ${report.records.length} records:`); console.log(report.toJSON()); } catch (error) { console.log(`An error occurred: ${error.message}`); } }
javascript
async function parseReport() { // eslint-disable-line no-unused-vars try { const coverage = await promises.readFile('lcov.info', 'utf8'); const report = Report.fromCoverage(coverage); console.log(`The coverage report contains ${report.records.length} records:`); console.log(report.toJSON()); } catch (error) { console.log(`An error occurred: ${error.message}`); } }
[ "async", "function", "parseReport", "(", ")", "{", "// eslint-disable-line no-unused-vars", "try", "{", "const", "coverage", "=", "await", "promises", ".", "readFile", "(", "'lcov.info'", ",", "'utf8'", ")", ";", "const", "report", "=", "Report", ".", "fromCover...
Parses a LCOV report to coverage data.
[ "Parses", "a", "LCOV", "report", "to", "coverage", "data", "." ]
63a56e188478753fe3b8c12721b8a19f858258c4
https://github.com/cedx/lcov.js/blob/63a56e188478753fe3b8c12721b8a19f858258c4/example/main.js#L21-L32
34,602
reklatsmasters/saslprep
lib/util.js
range
function range(from, to) { // TODO: make this inlined. const list = new Array(to - from + 1); for (let i = 0; i < list.length; i += 1) { list[i] = from + i; } return list; }
javascript
function range(from, to) { // TODO: make this inlined. const list = new Array(to - from + 1); for (let i = 0; i < list.length; i += 1) { list[i] = from + i; } return list; }
[ "function", "range", "(", "from", ",", "to", ")", "{", "// TODO: make this inlined.", "const", "list", "=", "new", "Array", "(", "to", "-", "from", "+", "1", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "list", ".", "length", ";", "...
Create an array of numbers. @param {number} from @param {number} to @returns {number[]}
[ "Create", "an", "array", "of", "numbers", "." ]
4ad8884b461a6a8e496d6e648ad5da0a1b43cb42
https://github.com/reklatsmasters/saslprep/blob/4ad8884b461a6a8e496d6e648ad5da0a1b43cb42/lib/util.js#L9-L17
34,603
jpodwys/cache-service-cache-module
cacheModule.js
setupBrowserStorage
function setupBrowserStorage(){ if(browser || storageMock){ if(storageMock){ store = storageMock; storageKey = 'cache-module-storage-mock'; } else{ var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null; store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false; storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null; } if(store){ var db = store.getItem(storageKey); try { cache = JSON.parse(db) || cache; } catch (err) { /* Do nothing */ } } // If storageType is set but store is not, the desired storage mechanism was not available else if(storageType){ log(true, 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.'); } } }
javascript
function setupBrowserStorage(){ if(browser || storageMock){ if(storageMock){ store = storageMock; storageKey = 'cache-module-storage-mock'; } else{ var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null; store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false; storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null; } if(store){ var db = store.getItem(storageKey); try { cache = JSON.parse(db) || cache; } catch (err) { /* Do nothing */ } } // If storageType is set but store is not, the desired storage mechanism was not available else if(storageType){ log(true, 'Browser storage is not supported by this browser. Defaulting to an in-memory cache.'); } } }
[ "function", "setupBrowserStorage", "(", ")", "{", "if", "(", "browser", "||", "storageMock", ")", "{", "if", "(", "storageMock", ")", "{", "store", "=", "storageMock", ";", "storageKey", "=", "'cache-module-storage-mock'", ";", "}", "else", "{", "var", "stor...
Enable browser storage if desired and available
[ "Enable", "browser", "storage", "if", "desired", "and", "available" ]
d81b4efe255922d0a2cd678eee745e96ac8a11c1
https://github.com/jpodwys/cache-service-cache-module/blob/d81b4efe255922d0a2cd678eee745e96ac8a11c1/cacheModule.js#L191-L213
34,604
jpodwys/cache-service-cache-module
cacheModule.js
overwriteBrowserStorage
function overwriteBrowserStorage(){ if((browser && store) || storageMock){ var db = cache; try { db = JSON.stringify(db); store.setItem(storageKey, db); } catch (err) { /* Do nothing */ } } }
javascript
function overwriteBrowserStorage(){ if((browser && store) || storageMock){ var db = cache; try { db = JSON.stringify(db); store.setItem(storageKey, db); } catch (err) { /* Do nothing */ } } }
[ "function", "overwriteBrowserStorage", "(", ")", "{", "if", "(", "(", "browser", "&&", "store", ")", "||", "storageMock", ")", "{", "var", "db", "=", "cache", ";", "try", "{", "db", "=", "JSON", ".", "stringify", "(", "db", ")", ";", "store", ".", ...
Overwrite namespaced browser storage with current cache
[ "Overwrite", "namespaced", "browser", "storage", "with", "current", "cache" ]
d81b4efe255922d0a2cd678eee745e96ac8a11c1
https://github.com/jpodwys/cache-service-cache-module/blob/d81b4efe255922d0a2cd678eee745e96ac8a11c1/cacheModule.js#L218-L226
34,605
jpodwys/cache-service-cache-module
cacheModule.js
handleRefreshResponse
function handleRefreshResponse (key, data, err, response) { if(!err) { this.set(key, response, (data.lifeSpan / 1000), data.refresh, function(){}); } }
javascript
function handleRefreshResponse (key, data, err, response) { if(!err) { this.set(key, response, (data.lifeSpan / 1000), data.refresh, function(){}); } }
[ "function", "handleRefreshResponse", "(", "key", ",", "data", ",", "err", ",", "response", ")", "{", "if", "(", "!", "err", ")", "{", "this", ".", "set", "(", "key", ",", "response", ",", "(", "data", ".", "lifeSpan", "/", "1000", ")", ",", "data",...
Handle the refresh callback from the consumer, save the data to redis. @param {string} key The key used to save. @param {Object} data refresh keys data. @param {Error|null} err consumer callback failure. @param {*} response The consumer response.
[ "Handle", "the", "refresh", "callback", "from", "the", "consumer", "save", "the", "data", "to", "redis", "." ]
d81b4efe255922d0a2cd678eee745e96ac8a11c1
https://github.com/jpodwys/cache-service-cache-module/blob/d81b4efe255922d0a2cd678eee745e96ac8a11c1/cacheModule.js#L270-L274
34,606
jpodwys/cache-service-cache-module
cacheModule.js
log
function log(isError, message, data){ if(self.verbose || isError){ if(data) console.log(self.type + ': ' + message, data); else console.log(self.type + message); } }
javascript
function log(isError, message, data){ if(self.verbose || isError){ if(data) console.log(self.type + ': ' + message, data); else console.log(self.type + message); } }
[ "function", "log", "(", "isError", ",", "message", ",", "data", ")", "{", "if", "(", "self", ".", "verbose", "||", "isError", ")", "{", "if", "(", "data", ")", "console", ".", "log", "(", "self", ".", "type", "+", "': '", "+", "message", ",", "da...
Error logging logic @param {boolean} isError @param {string} message @param {object} data
[ "Error", "logging", "logic" ]
d81b4efe255922d0a2cd678eee745e96ac8a11c1
https://github.com/jpodwys/cache-service-cache-module/blob/d81b4efe255922d0a2cd678eee745e96ac8a11c1/cacheModule.js#L303-L308
34,607
Nicklason/node-bptf-listings
lib/webrequest.js
WebRequest
function WebRequest (options, callback) { request(options, function (err, response, body) { if (err) { return callback(err); } callback(null, body); }); }
javascript
function WebRequest (options, callback) { request(options, function (err, response, body) { if (err) { return callback(err); } callback(null, body); }); }
[ "function", "WebRequest", "(", "options", ",", "callback", ")", "{", "request", "(", "options", ",", "function", "(", "err", ",", "response", ",", "body", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "callbac...
Sends a request to the Steam api @param {object} options Request options @param {function} callback Function to call when done
[ "Sends", "a", "request", "to", "the", "Steam", "api" ]
8ed38a4e2457603ec2941991e8af924531e8389b
https://github.com/Nicklason/node-bptf-listings/blob/8ed38a4e2457603ec2941991e8af924531e8389b/lib/webrequest.js#L10-L18
34,608
glennjones/microformat-shiv
microformat-shiv.js
function(options) { var out = this.formatEmpty(), data = [], rels; this.init(); options = (options)? options : {}; this.mergeOptions(options); this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ this.errors.push(this.noContentErr); }else{ // only parse h-* microformats if we need to // this is added to speed up parsing if(this.hasMicroformats(this.rootNode, options)){ this.prepareDOM( options ); if(this.options.filters.length > 0){ // parse flat list of items var newRootNode = this.findFilterNodes(this.rootNode, this.options.filters); data = this.walkRoot(newRootNode); }else{ // parse whole document from root data = this.walkRoot(this.rootNode); } out.items = data; // don't clear-up DOM if it was cloned if(modules.domUtils.canCloneDocument(this.document) === false){ this.clearUpDom(this.rootNode); } } // find any rels if(this.findRels){ rels = this.findRels(this.rootNode); out.rels = rels.rels; out['rel-urls'] = rels['rel-urls']; } } if(this.errors.length > 0){ return this.formatError(); } return out; }
javascript
function(options) { var out = this.formatEmpty(), data = [], rels; this.init(); options = (options)? options : {}; this.mergeOptions(options); this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ this.errors.push(this.noContentErr); }else{ // only parse h-* microformats if we need to // this is added to speed up parsing if(this.hasMicroformats(this.rootNode, options)){ this.prepareDOM( options ); if(this.options.filters.length > 0){ // parse flat list of items var newRootNode = this.findFilterNodes(this.rootNode, this.options.filters); data = this.walkRoot(newRootNode); }else{ // parse whole document from root data = this.walkRoot(this.rootNode); } out.items = data; // don't clear-up DOM if it was cloned if(modules.domUtils.canCloneDocument(this.document) === false){ this.clearUpDom(this.rootNode); } } // find any rels if(this.findRels){ rels = this.findRels(this.rootNode); out.rels = rels.rels; out['rel-urls'] = rels['rel-urls']; } } if(this.errors.length > 0){ return this.formatError(); } return out; }
[ "function", "(", "options", ")", "{", "var", "out", "=", "this", ".", "formatEmpty", "(", ")", ",", "data", "=", "[", "]", ",", "rels", ";", "this", ".", "init", "(", ")", ";", "options", "=", "(", "options", ")", "?", "options", ":", "{", "}",...
internal parse function @param {Object} options @return {Object}
[ "internal", "parse", "function" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L70-L119
34,609
glennjones/microformat-shiv
microformat-shiv.js
function(node, options) { this.init(); options = (options)? options : {}; if(node){ return this.getParentTreeWalk(node, options); }else{ this.errors.push(this.noContentErr); return this.formatError(); } }
javascript
function(node, options) { this.init(); options = (options)? options : {}; if(node){ return this.getParentTreeWalk(node, options); }else{ this.errors.push(this.noContentErr); return this.formatError(); } }
[ "function", "(", "node", ",", "options", ")", "{", "this", ".", "init", "(", ")", ";", "options", "=", "(", "options", ")", "?", "options", ":", "{", "}", ";", "if", "(", "node", ")", "{", "return", "this", ".", "getParentTreeWalk", "(", "node", ...
parse to get parent microformat of passed node @param {DOM Node} node @param {Object} options @return {Object}
[ "parse", "to", "get", "parent", "microformat", "of", "passed", "node" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L129-L139
34,610
glennjones/microformat-shiv
microformat-shiv.js
function( options ) { var out = {}, items, classItems, x, i; this.init(); options = (options)? options : {}; this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ return {'errors': [this.noContentErr]}; }else{ items = this.findRootNodes( this.rootNode, true ); i = items.length; while(i--) { classItems = modules.domUtils.getAttributeList(items[i], 'class'); x = classItems.length; while(x--) { // find v2 names if(modules.utils.startWith( classItems[x], 'h-' )){ this.appendCount(classItems[x], 1, out); } // find v1 names for(var key in modules.maps) { // dont double count if v1 and v2 roots are present if(modules.maps[key].root === classItems[x] && classItems.indexOf(key) === -1) { this.appendCount(key, 1, out); } } } } var relCount = this.countRels( this.rootNode ); if(relCount > 0){ out.rels = relCount; } return out; } }
javascript
function( options ) { var out = {}, items, classItems, x, i; this.init(); options = (options)? options : {}; this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ return {'errors': [this.noContentErr]}; }else{ items = this.findRootNodes( this.rootNode, true ); i = items.length; while(i--) { classItems = modules.domUtils.getAttributeList(items[i], 'class'); x = classItems.length; while(x--) { // find v2 names if(modules.utils.startWith( classItems[x], 'h-' )){ this.appendCount(classItems[x], 1, out); } // find v1 names for(var key in modules.maps) { // dont double count if v1 and v2 roots are present if(modules.maps[key].root === classItems[x] && classItems.indexOf(key) === -1) { this.appendCount(key, 1, out); } } } } var relCount = this.countRels( this.rootNode ); if(relCount > 0){ out.rels = relCount; } return out; } }
[ "function", "(", "options", ")", "{", "var", "out", "=", "{", "}", ",", "items", ",", "classItems", ",", "x", ",", "i", ";", "this", ".", "init", "(", ")", ";", "options", "=", "(", "options", ")", "?", "options", ":", "{", "}", ";", "this", ...
get the count of microformats @param {DOM Node} rootNode @return {Int}
[ "get", "the", "count", "of", "microformats" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L148-L190
34,611
glennjones/microformat-shiv
microformat-shiv.js
function( node, options ) { var classes, i; if(!node){ return false; } // if documemt gets topmost node node = modules.domUtils.getTopMostNode( node ); // look for h-* microformats classes = this.getUfClassNames(node); if(options && options.filters && modules.utils.isArray(options.filters)){ i = options.filters.length; while(i--) { if(classes.root.indexOf(options.filters[i]) > -1){ return true; } } return false; }else{ return (classes.root.length > 0); } }
javascript
function( node, options ) { var classes, i; if(!node){ return false; } // if documemt gets topmost node node = modules.domUtils.getTopMostNode( node ); // look for h-* microformats classes = this.getUfClassNames(node); if(options && options.filters && modules.utils.isArray(options.filters)){ i = options.filters.length; while(i--) { if(classes.root.indexOf(options.filters[i]) > -1){ return true; } } return false; }else{ return (classes.root.length > 0); } }
[ "function", "(", "node", ",", "options", ")", "{", "var", "classes", ",", "i", ";", "if", "(", "!", "node", ")", "{", "return", "false", ";", "}", "// if documemt gets topmost node", "node", "=", "modules", ".", "domUtils", ".", "getTopMostNode", "(", "n...
does a node have a class that marks it as a microformats root @param {DOM Node} node @param {Objecte} options @return {Boolean}
[ "does", "a", "node", "have", "a", "class", "that", "marks", "it", "as", "a", "microformats", "root" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L200-L224
34,612
glennjones/microformat-shiv
microformat-shiv.js
function( node, options ) { var items, i; if(!node){ return false; } // if browser based documemt get topmost node node = modules.domUtils.getTopMostNode( node ); // returns all microformat roots items = this.findRootNodes( node, true ); if(options && options.filters && modules.utils.isArray(options.filters)){ i = items.length; while(i--) { if( this.isMicroformat( items[i], options ) ){ return true; } } return false; }else{ return (items.length > 0); } }
javascript
function( node, options ) { var items, i; if(!node){ return false; } // if browser based documemt get topmost node node = modules.domUtils.getTopMostNode( node ); // returns all microformat roots items = this.findRootNodes( node, true ); if(options && options.filters && modules.utils.isArray(options.filters)){ i = items.length; while(i--) { if( this.isMicroformat( items[i], options ) ){ return true; } } return false; }else{ return (items.length > 0); } }
[ "function", "(", "node", ",", "options", ")", "{", "var", "items", ",", "i", ";", "if", "(", "!", "node", ")", "{", "return", "false", ";", "}", "// if browser based documemt get topmost node", "node", "=", "modules", ".", "domUtils", ".", "getTopMostNode", ...
does a node or its children have microformats @param {DOM Node} node @param {Objecte} options @return {Boolean}
[ "does", "a", "node", "or", "its", "children", "have", "microformats" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L234-L258
34,613
glennjones/microformat-shiv
microformat-shiv.js
function( maps ){ maps.forEach(function(map){ if(map && map.root && map.name && map.properties){ modules.maps[map.name] = JSON.parse(JSON.stringify(map)); } }); }
javascript
function( maps ){ maps.forEach(function(map){ if(map && map.root && map.name && map.properties){ modules.maps[map.name] = JSON.parse(JSON.stringify(map)); } }); }
[ "function", "(", "maps", ")", "{", "maps", ".", "forEach", "(", "function", "(", "map", ")", "{", "if", "(", "map", "&&", "map", ".", "root", "&&", "map", ".", "name", "&&", "map", ".", "properties", ")", "{", "modules", ".", "maps", "[", "map", ...
add a new v1 mapping object to parser @param {Array} maps
[ "add", "a", "new", "v1", "mapping", "object", "to", "parser" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L266-L272
34,614
glennjones/microformat-shiv
microformat-shiv.js
function (node, options, recursive) { options = (options)? options : {}; // recursive calls if (recursive === undefined) { if (node.parentNode && node.nodeName !== 'HTML'){ return this.getParentTreeWalk(node.parentNode, options, true); }else{ return this.formatEmpty(); } } if (node !== null && node !== undefined && node.parentNode) { if (this.isMicroformat( node, options )) { // if we have a match return microformat options.node = node; return this.get( options ); }else{ return this.getParentTreeWalk(node.parentNode, options, true); } }else{ return this.formatEmpty(); } }
javascript
function (node, options, recursive) { options = (options)? options : {}; // recursive calls if (recursive === undefined) { if (node.parentNode && node.nodeName !== 'HTML'){ return this.getParentTreeWalk(node.parentNode, options, true); }else{ return this.formatEmpty(); } } if (node !== null && node !== undefined && node.parentNode) { if (this.isMicroformat( node, options )) { // if we have a match return microformat options.node = node; return this.get( options ); }else{ return this.getParentTreeWalk(node.parentNode, options, true); } }else{ return this.formatEmpty(); } }
[ "function", "(", "node", ",", "options", ",", "recursive", ")", "{", "options", "=", "(", "options", ")", "?", "options", ":", "{", "}", ";", "// recursive calls", "if", "(", "recursive", "===", "undefined", ")", "{", "if", "(", "node", ".", "parentNod...
internal parse to get parent microformats by walking up the tree @param {DOM Node} node @param {Object} options @param {Int} recursive @return {Object}
[ "internal", "parse", "to", "get", "parent", "microformats", "by", "walking", "up", "the", "tree" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L283-L305
34,615
glennjones/microformat-shiv
microformat-shiv.js
function( options ){ var baseTag, href; // use current document to define baseUrl, try/catch needed for IE10+ error try { if (!options.baseUrl && this.document && this.document.location) { this.options.baseUrl = this.document.location.href; } } catch (e) { // there is no alt action } // find base tag to set baseUrl baseTag = modules.domUtils.querySelector(this.document,'base'); if(baseTag) { href = modules.domUtils.getAttribute(baseTag, 'href'); if(href){ this.options.baseUrl = href; } } // get path to rootNode // then clone document // then reset the rootNode to its cloned version in a new document var path, newDocument, newRootNode; path = modules.domUtils.getNodePath(this.rootNode); newDocument = modules.domUtils.cloneDocument(this.document); newRootNode = modules.domUtils.getNodeByPath(newDocument, path); // check results as early IE fails if(newDocument && newRootNode){ this.document = newDocument; this.rootNode = newRootNode; } // add includes if(this.addIncludes){ this.addIncludes( this.document ); } return (this.rootNode && this.document); }
javascript
function( options ){ var baseTag, href; // use current document to define baseUrl, try/catch needed for IE10+ error try { if (!options.baseUrl && this.document && this.document.location) { this.options.baseUrl = this.document.location.href; } } catch (e) { // there is no alt action } // find base tag to set baseUrl baseTag = modules.domUtils.querySelector(this.document,'base'); if(baseTag) { href = modules.domUtils.getAttribute(baseTag, 'href'); if(href){ this.options.baseUrl = href; } } // get path to rootNode // then clone document // then reset the rootNode to its cloned version in a new document var path, newDocument, newRootNode; path = modules.domUtils.getNodePath(this.rootNode); newDocument = modules.domUtils.cloneDocument(this.document); newRootNode = modules.domUtils.getNodeByPath(newDocument, path); // check results as early IE fails if(newDocument && newRootNode){ this.document = newDocument; this.rootNode = newRootNode; } // add includes if(this.addIncludes){ this.addIncludes( this.document ); } return (this.rootNode && this.document); }
[ "function", "(", "options", ")", "{", "var", "baseTag", ",", "href", ";", "// use current document to define baseUrl, try/catch needed for IE10+ error", "try", "{", "if", "(", "!", "options", ".", "baseUrl", "&&", "this", ".", "document", "&&", "this", ".", "docum...
prepares DOM before the parse begins @param {Object} options @return {Boolean}
[ "prepares", "DOM", "before", "the", "parse", "begins" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L327-L373
34,616
glennjones/microformat-shiv
microformat-shiv.js
function(rootNode, filters) { if(modules.utils.isString(filters)){ filters = [filters]; } var newRootNode = modules.domUtils.createNode('div'), items = this.findRootNodes(rootNode, true), i = 0, x = 0, y = 0; // add v1 names y = filters.length; while (y--) { if(this.getMapping(filters[y])){ var v1Name = this.getMapping(filters[y]).root; filters.push(v1Name); } } if(items){ i = items.length; while(x < i) { // append matching nodes into newRootNode y = filters.length; while (y--) { if(modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])){ var clone = modules.domUtils.clone(items[x]); modules.domUtils.appendChild(newRootNode, clone); break; } } x++; } } return newRootNode; }
javascript
function(rootNode, filters) { if(modules.utils.isString(filters)){ filters = [filters]; } var newRootNode = modules.domUtils.createNode('div'), items = this.findRootNodes(rootNode, true), i = 0, x = 0, y = 0; // add v1 names y = filters.length; while (y--) { if(this.getMapping(filters[y])){ var v1Name = this.getMapping(filters[y]).root; filters.push(v1Name); } } if(items){ i = items.length; while(x < i) { // append matching nodes into newRootNode y = filters.length; while (y--) { if(modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])){ var clone = modules.domUtils.clone(items[x]); modules.domUtils.appendChild(newRootNode, clone); break; } } x++; } } return newRootNode; }
[ "function", "(", "rootNode", ",", "filters", ")", "{", "if", "(", "modules", ".", "utils", ".", "isString", "(", "filters", ")", ")", "{", "filters", "=", "[", "filters", "]", ";", "}", "var", "newRootNode", "=", "modules", ".", "domUtils", ".", "cre...
find microformats of a given type and return node structures
[ "find", "microformats", "of", "a", "given", "type", "and", "return", "node", "structures" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L403-L439
34,617
glennjones/microformat-shiv
microformat-shiv.js
function(name, count, out){ if(out[name]){ out[name] = out[name] + count; }else{ out[name] = count; } }
javascript
function(name, count, out){ if(out[name]){ out[name] = out[name] + count; }else{ out[name] = count; } }
[ "function", "(", "name", ",", "count", ",", "out", ")", "{", "if", "(", "out", "[", "name", "]", ")", "{", "out", "[", "name", "]", "=", "out", "[", "name", "]", "+", "count", ";", "}", "else", "{", "out", "[", "name", "]", "=", "count", ";...
appends data to output object for count @param {string} name @param {Int} count @param {Object}
[ "appends", "data", "to", "output", "object", "for", "count" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L449-L455
34,618
glennjones/microformat-shiv
microformat-shiv.js
function(uf, filters) { var i; if(modules.utils.isArray(filters) && filters.length > 0) { i = filters.length; while(i--) { if(uf.type[0] === filters[i]) { return true; } } return false; } else { return true; } }
javascript
function(uf, filters) { var i; if(modules.utils.isArray(filters) && filters.length > 0) { i = filters.length; while(i--) { if(uf.type[0] === filters[i]) { return true; } } return false; } else { return true; } }
[ "function", "(", "uf", ",", "filters", ")", "{", "var", "i", ";", "if", "(", "modules", ".", "utils", ".", "isArray", "(", "filters", ")", "&&", "filters", ".", "length", ">", "0", ")", "{", "i", "=", "filters", ".", "length", ";", "while", "(", ...
is the microformats type in the filter list @param {Object} uf @param {Array} filters @return {Boolean}
[ "is", "the", "microformats", "type", "in", "the", "filter", "list" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L465-L479
34,619
glennjones/microformat-shiv
microformat-shiv.js
function(rootNode, includeRoot) { var arr = null, out = [], classList = [], items, x, i, y, key; // build an array of v1 root names for(key in modules.maps) { if (modules.maps.hasOwnProperty(key)) { classList.push(modules.maps[key].root); } } // get all elements that have a class attribute includeRoot = (includeRoot) ? includeRoot : false; if(includeRoot && rootNode.parentNode) { arr = modules.domUtils.getNodesByAttribute(rootNode.parentNode, 'class'); } else { arr = modules.domUtils.getNodesByAttribute(rootNode, 'class'); } // loop elements that have a class attribute x = 0; i = arr.length; while(x < i) { items = modules.domUtils.getAttributeList(arr[x], 'class'); // loop classes on an element y = items.length; while(y--) { // match v1 root names if(classList.indexOf(items[y]) > -1) { out.push(arr[x]); break; } // match v2 root name prefix if(modules.utils.startWith(items[y], 'h-')) { out.push(arr[x]); break; } } x++; } return out; }
javascript
function(rootNode, includeRoot) { var arr = null, out = [], classList = [], items, x, i, y, key; // build an array of v1 root names for(key in modules.maps) { if (modules.maps.hasOwnProperty(key)) { classList.push(modules.maps[key].root); } } // get all elements that have a class attribute includeRoot = (includeRoot) ? includeRoot : false; if(includeRoot && rootNode.parentNode) { arr = modules.domUtils.getNodesByAttribute(rootNode.parentNode, 'class'); } else { arr = modules.domUtils.getNodesByAttribute(rootNode, 'class'); } // loop elements that have a class attribute x = 0; i = arr.length; while(x < i) { items = modules.domUtils.getAttributeList(arr[x], 'class'); // loop classes on an element y = items.length; while(y--) { // match v1 root names if(classList.indexOf(items[y]) > -1) { out.push(arr[x]); break; } // match v2 root name prefix if(modules.utils.startWith(items[y], 'h-')) { out.push(arr[x]); break; } } x++; } return out; }
[ "function", "(", "rootNode", ",", "includeRoot", ")", "{", "var", "arr", "=", "null", ",", "out", "=", "[", "]", ",", "classList", "=", "[", "]", ",", "items", ",", "x", ",", "i", ",", "y", ",", "key", ";", "// build an array of v1 root names", "for"...
finds all microformat roots in a rootNode @param {DOM Node} rootNode @param {Boolean} includeRoot @return {Array}
[ "finds", "all", "microformat", "roots", "in", "a", "rootNode" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L489-L541
34,620
glennjones/microformat-shiv
microformat-shiv.js
function(node){ var context = this, children = [], child, classes, items = [], out = []; classes = this.getUfClassNames(node); // if it is a root microformat node if(classes && classes.root.length > 0){ items = this.walkTree(node); if(items.length > 0){ out = out.concat(items); } }else{ // check if there are children and one of the children has a root microformat children = modules.domUtils.getChildren( node ); if(children && children.length > 0 && this.findRootNodes(node, true).length > -1){ for (var i = 0; i < children.length; i++) { child = children[i]; items = context.walkRoot(child); if(items.length > 0){ out = out.concat(items); } } } } return out; }
javascript
function(node){ var context = this, children = [], child, classes, items = [], out = []; classes = this.getUfClassNames(node); // if it is a root microformat node if(classes && classes.root.length > 0){ items = this.walkTree(node); if(items.length > 0){ out = out.concat(items); } }else{ // check if there are children and one of the children has a root microformat children = modules.domUtils.getChildren( node ); if(children && children.length > 0 && this.findRootNodes(node, true).length > -1){ for (var i = 0; i < children.length; i++) { child = children[i]; items = context.walkRoot(child); if(items.length > 0){ out = out.concat(items); } } } } return out; }
[ "function", "(", "node", ")", "{", "var", "context", "=", "this", ",", "children", "=", "[", "]", ",", "child", ",", "classes", ",", "items", "=", "[", "]", ",", "out", "=", "[", "]", ";", "classes", "=", "this", ".", "getUfClassNames", "(", "nod...
starts the tree walk to find microformats @param {DOM Node} node @return {Array}
[ "starts", "the", "tree", "walk", "to", "find", "microformats" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L550-L580
34,621
glennjones/microformat-shiv
microformat-shiv.js
function(node) { var classes, out = [], obj, itemRootID; // loop roots found on one element classes = this.getUfClassNames(node); if(classes && classes.root.length && classes.root.length > 0){ this.rootID++; itemRootID = this.rootID; obj = this.createUfObject(classes.root, classes.typeVersion); this.walkChildren(node, obj, classes.root, itemRootID, classes); if(this.impliedRules){ this.impliedRules(node, obj, classes); } if(this.options.lang === true){ var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang'); if(lang){ obj.lang = lang; } } out.push( this.cleanUfObject(obj) ); } return out; }
javascript
function(node) { var classes, out = [], obj, itemRootID; // loop roots found on one element classes = this.getUfClassNames(node); if(classes && classes.root.length && classes.root.length > 0){ this.rootID++; itemRootID = this.rootID; obj = this.createUfObject(classes.root, classes.typeVersion); this.walkChildren(node, obj, classes.root, itemRootID, classes); if(this.impliedRules){ this.impliedRules(node, obj, classes); } if(this.options.lang === true){ var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang'); if(lang){ obj.lang = lang; } } out.push( this.cleanUfObject(obj) ); } return out; }
[ "function", "(", "node", ")", "{", "var", "classes", ",", "out", "=", "[", "]", ",", "obj", ",", "itemRootID", ";", "// loop roots found on one element", "classes", "=", "this", ".", "getUfClassNames", "(", "node", ")", ";", "if", "(", "classes", "&&", "...
starts the tree walking for a single microformat @param {DOM Node} node @return {Array}
[ "starts", "the", "tree", "walking", "for", "a", "single", "microformat" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L589-L619
34,622
glennjones/microformat-shiv
microformat-shiv.js
function(node, className, uf) { var value = ''; if(modules.utils.startWith(className, 'p-')) { value = this.getPValue(node, true); } if(modules.utils.startWith(className, 'e-')) { value = this.getEValue(node); } if(modules.utils.startWith(className, 'u-')) { value = this.getUValue(node, true); } if(modules.utils.startWith(className, 'dt-')) { value = this.getDTValue(node, className, uf, true); } return value; }
javascript
function(node, className, uf) { var value = ''; if(modules.utils.startWith(className, 'p-')) { value = this.getPValue(node, true); } if(modules.utils.startWith(className, 'e-')) { value = this.getEValue(node); } if(modules.utils.startWith(className, 'u-')) { value = this.getUValue(node, true); } if(modules.utils.startWith(className, 'dt-')) { value = this.getDTValue(node, className, uf, true); } return value; }
[ "function", "(", "node", ",", "className", ",", "uf", ")", "{", "var", "value", "=", "''", ";", "if", "(", "modules", ".", "utils", ".", "startWith", "(", "className", ",", "'p-'", ")", ")", "{", "value", "=", "this", ".", "getPValue", "(", "node",...
gets the value of a property from a node @param {DOM Node} node @param {String} className @param {Object} uf @return {String || Object}
[ "gets", "the", "value", "of", "a", "property", "from", "a", "node" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L796-L815
34,623
glennjones/microformat-shiv
microformat-shiv.js
function(node, valueParse) { var out = ''; if(valueParse) { out = this.getValueClass(node, 'p'); } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value'); } if(node.name === 'br' || node.name === 'hr') { out = ''; } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['img', 'area'], 'alt'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } return(out) ? out : ''; }
javascript
function(node, valueParse) { var out = ''; if(valueParse) { out = this.getValueClass(node, 'p'); } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value'); } if(node.name === 'br' || node.name === 'hr') { out = ''; } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['img', 'area'], 'alt'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } return(out) ? out : ''; }
[ "function", "(", "node", ",", "valueParse", ")", "{", "var", "out", "=", "''", ";", "if", "(", "valueParse", ")", "{", "out", "=", "this", ".", "getValueClass", "(", "node", ",", "'p'", ")", ";", "}", "if", "(", "!", "out", "&&", "valueParse", ")...
gets the value of a node which contains a 'p-' property @param {DOM Node} node @param {Boolean} valueParse @return {String}
[ "gets", "the", "value", "of", "a", "node", "which", "contains", "a", "p", "-", "property" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L825-L856
34,624
glennjones/microformat-shiv
microformat-shiv.js
function(node) { var out = {value: '', html: ''}; this.expandURLs(node, 'src', this.options.baseUrl); this.expandURLs(node, 'href', this.options.baseUrl); out.value = modules.text.parse(this.document, node, this.options.textFormat); out.html = modules.html.parse(node); if(this.options.lang === true){ var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang'); if(lang){ out.lang = lang; } } return out; }
javascript
function(node) { var out = {value: '', html: ''}; this.expandURLs(node, 'src', this.options.baseUrl); this.expandURLs(node, 'href', this.options.baseUrl); out.value = modules.text.parse(this.document, node, this.options.textFormat); out.html = modules.html.parse(node); if(this.options.lang === true){ var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang'); if(lang){ out.lang = lang; } } return out; }
[ "function", "(", "node", ")", "{", "var", "out", "=", "{", "value", ":", "''", ",", "html", ":", "''", "}", ";", "this", ".", "expandURLs", "(", "node", ",", "'src'", ",", "this", ".", "options", ".", "baseUrl", ")", ";", "this", ".", "expandURLs...
gets the value of a node which contains the 'e-' property @param {DOM Node} node @return {Object}
[ "gets", "the", "value", "of", "a", "node", "which", "contains", "the", "e", "-", "property" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L865-L883
34,625
glennjones/microformat-shiv
microformat-shiv.js
function(node, valueParse) { var out = ''; if(valueParse) { out = this.getValueClass(node, 'u'); } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['a', 'area'], 'href'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['img','audio','video','source'], 'src'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['video'], 'poster'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data'); } // if we have no protocol separator, turn relative url to absolute url if(out && out !== '' && out.indexOf('://') === -1) { out = modules.url.resolve(out, this.options.baseUrl); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } return(out) ? out : ''; }
javascript
function(node, valueParse) { var out = ''; if(valueParse) { out = this.getValueClass(node, 'u'); } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['a', 'area'], 'href'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['img','audio','video','source'], 'src'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['video'], 'poster'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data'); } // if we have no protocol separator, turn relative url to absolute url if(out && out !== '' && out.indexOf('://') === -1) { out = modules.url.resolve(out, this.options.baseUrl); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } return(out) ? out : ''; }
[ "function", "(", "node", ",", "valueParse", ")", "{", "var", "out", "=", "''", ";", "if", "(", "valueParse", ")", "{", "out", "=", "this", ".", "getValueClass", "(", "node", ",", "'u'", ")", ";", "}", "if", "(", "!", "out", "&&", "valueParse", ")...
gets the value of a node which contains the 'u-' property @param {DOM Node} node @param {Boolean} valueParse @return {String}
[ "gets", "the", "value", "of", "a", "node", "which", "contains", "the", "u", "-", "property" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L893-L937
34,626
glennjones/microformat-shiv
microformat-shiv.js
function(node, className, uf, valueParse) { var out = '', fromValue = false; if(valueParse) { out = this.getValueClass(node, 'dt'); if(out){ fromValue = true; } } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['time', 'ins', 'del'], 'datetime'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data', 'input'], 'value'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } if(out) { var format = (fromValue)? 'microformat2' : this.options.dateFormat; if(modules.dates.isDuration(out)) { // just duration return out; } else if(modules.dates.isTime(out)) { // just time or time+timezone if(uf) { uf.times.push([className, modules.dates.parseAmPmTime(out, format)]); } return modules.dates.parseAmPmTime(out, format); } else { // returns a date - microformat profile if(uf) { uf.dates.push([className, new modules.ISODate(out).toString( format )]); } return new modules.ISODate(out).toString( format ); } } else { return ''; } }
javascript
function(node, className, uf, valueParse) { var out = '', fromValue = false; if(valueParse) { out = this.getValueClass(node, 'dt'); if(out){ fromValue = true; } } if(!out && valueParse) { out = this.getValueTitle(node); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['time', 'ins', 'del'], 'datetime'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title'); } if(!out) { out = modules.domUtils.getAttrValFromTagList(node, ['data', 'input'], 'value'); } if(!out) { out = modules.text.parse(this.document, node, this.options.textFormat); } if(out) { var format = (fromValue)? 'microformat2' : this.options.dateFormat; if(modules.dates.isDuration(out)) { // just duration return out; } else if(modules.dates.isTime(out)) { // just time or time+timezone if(uf) { uf.times.push([className, modules.dates.parseAmPmTime(out, format)]); } return modules.dates.parseAmPmTime(out, format); } else { // returns a date - microformat profile if(uf) { uf.dates.push([className, new modules.ISODate(out).toString( format )]); } return new modules.ISODate(out).toString( format ); } } else { return ''; } }
[ "function", "(", "node", ",", "className", ",", "uf", ",", "valueParse", ")", "{", "var", "out", "=", "''", ",", "fromValue", "=", "false", ";", "if", "(", "valueParse", ")", "{", "out", "=", "this", ".", "getValueClass", "(", "node", ",", "'dt'", ...
gets the value of a node which contains the 'dt-' property @param {DOM Node} node @param {String} className @param {Object} uf @param {Boolean} valueParse @return {String}
[ "gets", "the", "value", "of", "a", "node", "which", "contains", "the", "dt", "-", "property" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L949-L1001
34,627
glennjones/microformat-shiv
microformat-shiv.js
function(node, id, propertyName) { if(this.hasRootID(node, id, propertyName) === false){ var rootids = []; if(modules.domUtils.hasAttribute(node,'rootids')){ rootids = modules.domUtils.getAttributeList(node,'rootids'); } rootids.push('id' + id + '-' + propertyName); modules.domUtils.setAttribute(node, 'rootids', rootids.join(' ')); } }
javascript
function(node, id, propertyName) { if(this.hasRootID(node, id, propertyName) === false){ var rootids = []; if(modules.domUtils.hasAttribute(node,'rootids')){ rootids = modules.domUtils.getAttributeList(node,'rootids'); } rootids.push('id' + id + '-' + propertyName); modules.domUtils.setAttribute(node, 'rootids', rootids.join(' ')); } }
[ "function", "(", "node", ",", "id", ",", "propertyName", ")", "{", "if", "(", "this", ".", "hasRootID", "(", "node", ",", "id", ",", "propertyName", ")", "===", "false", ")", "{", "var", "rootids", "=", "[", "]", ";", "if", "(", "modules", ".", "...
appends a new rootid to a given node @param {DOM Node} node @param {String} id @param {String} propertyName
[ "appends", "a", "new", "rootid", "to", "a", "given", "node" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1011-L1020
34,628
glennjones/microformat-shiv
microformat-shiv.js
function(node, id, propertyName) { var rootids = []; if(!modules.domUtils.hasAttribute(node,'rootids')){ return false; } else { rootids = modules.domUtils.getAttributeList(node, 'rootids'); return (rootids.indexOf('id' + id + '-' + propertyName) > -1); } }
javascript
function(node, id, propertyName) { var rootids = []; if(!modules.domUtils.hasAttribute(node,'rootids')){ return false; } else { rootids = modules.domUtils.getAttributeList(node, 'rootids'); return (rootids.indexOf('id' + id + '-' + propertyName) > -1); } }
[ "function", "(", "node", ",", "id", ",", "propertyName", ")", "{", "var", "rootids", "=", "[", "]", ";", "if", "(", "!", "modules", ".", "domUtils", ".", "hasAttribute", "(", "node", ",", "'rootids'", ")", ")", "{", "return", "false", ";", "}", "el...
does a given node already have a rootid @param {DOM Node} node @param {String} id @param {String} propertyName @return {Boolean}
[ "does", "a", "given", "node", "already", "have", "a", "rootid" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1031-L1039
34,629
glennjones/microformat-shiv
microformat-shiv.js
function(node, propertyType) { var context = this, children = [], out = [], child, x, i; children = modules.domUtils.getChildren( node ); x = 0; i = children.length; while(x < i) { child = children[x]; var value = null; if(modules.domUtils.hasAttributeValue(child, 'class', 'value')) { switch(propertyType) { case 'p': value = context.getPValue(child, false); break; case 'u': value = context.getUValue(child, false); break; case 'dt': value = context.getDTValue(child, '', null, false); break; } if(value) { out.push(modules.utils.trim(value)); } } x++; } if(out.length > 0) { if(propertyType === 'p') { return modules.text.parseText( this.document, out.join(''), this.options.textFormat); } if(propertyType === 'u') { return out.join(''); } if(propertyType === 'dt') { var format = 'microformat2'; return modules.dates.concatFragments(out,format).toString(format); } } else { return null; } }
javascript
function(node, propertyType) { var context = this, children = [], out = [], child, x, i; children = modules.domUtils.getChildren( node ); x = 0; i = children.length; while(x < i) { child = children[x]; var value = null; if(modules.domUtils.hasAttributeValue(child, 'class', 'value')) { switch(propertyType) { case 'p': value = context.getPValue(child, false); break; case 'u': value = context.getUValue(child, false); break; case 'dt': value = context.getDTValue(child, '', null, false); break; } if(value) { out.push(modules.utils.trim(value)); } } x++; } if(out.length > 0) { if(propertyType === 'p') { return modules.text.parseText( this.document, out.join(''), this.options.textFormat); } if(propertyType === 'u') { return out.join(''); } if(propertyType === 'dt') { var format = 'microformat2'; return modules.dates.concatFragments(out,format).toString(format); } } else { return null; } }
[ "function", "(", "node", ",", "propertyType", ")", "{", "var", "context", "=", "this", ",", "children", "=", "[", "]", ",", "out", "=", "[", "]", ",", "child", ",", "x", ",", "i", ";", "children", "=", "modules", ".", "domUtils", ".", "getChildren"...
gets the text of any child nodes with a class value @param {DOM Node} node @param {String} propertyName @return {String || null}
[ "gets", "the", "text", "of", "any", "child", "nodes", "with", "a", "class", "value" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1050-L1097
34,630
glennjones/microformat-shiv
microformat-shiv.js
function(node) { var out = [], items, i, x; items = modules.domUtils.getNodesByAttributeValue(node, 'class', 'value-title'); x = 0; i = items.length; while(x < i) { if(modules.domUtils.hasAttribute(items[x], 'title')) { out.push(modules.domUtils.getAttribute(items[x], 'title')); } x++; } return out.join(''); }
javascript
function(node) { var out = [], items, i, x; items = modules.domUtils.getNodesByAttributeValue(node, 'class', 'value-title'); x = 0; i = items.length; while(x < i) { if(modules.domUtils.hasAttribute(items[x], 'title')) { out.push(modules.domUtils.getAttribute(items[x], 'title')); } x++; } return out.join(''); }
[ "function", "(", "node", ")", "{", "var", "out", "=", "[", "]", ",", "items", ",", "i", ",", "x", ";", "items", "=", "modules", ".", "domUtils", ".", "getNodesByAttributeValue", "(", "node", ",", "'class'", ",", "'value-title'", ")", ";", "x", "=", ...
returns a single string of the 'title' attr from all the child nodes with the class 'value-title' @param {DOM Node} node @return {String}
[ "returns", "a", "single", "string", "of", "the", "title", "attr", "from", "all", "the", "child", "nodes", "with", "the", "class", "value", "-", "title" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1107-L1123
34,631
glennjones/microformat-shiv
microformat-shiv.js
function(name) { var key; for(key in modules.maps) { if(modules.maps[key].root === name || key === name) { return modules.maps[key]; } } return null; }
javascript
function(name) { var key; for(key in modules.maps) { if(modules.maps[key].root === name || key === name) { return modules.maps[key]; } } return null; }
[ "function", "(", "name", ")", "{", "var", "key", ";", "for", "(", "key", "in", "modules", ".", "maps", ")", "{", "if", "(", "modules", ".", "maps", "[", "key", "]", ".", "root", "===", "name", "||", "key", "===", "name", ")", "{", "return", "mo...
given a v1 or v2 root name, return mapping object @param {String} name @return {Object || null}
[ "given", "a", "v1", "or", "v2", "root", "name", "return", "mapping", "object" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1300-L1308
34,632
glennjones/microformat-shiv
microformat-shiv.js
function(names, typeVersion, value) { var out = {}; // is more than just whitespace if(value && modules.utils.isOnlyWhiteSpace(value) === false) { out.value = value; } // add type i.e. ["h-card", "h-org"] if(modules.utils.isArray(names)) { out.type = names; } else { out.type = [names]; } out.properties = {}; // metadata properties for parsing out.typeVersion = typeVersion; out.times = []; out.dates = []; out.altValue = null; return out; }
javascript
function(names, typeVersion, value) { var out = {}; // is more than just whitespace if(value && modules.utils.isOnlyWhiteSpace(value) === false) { out.value = value; } // add type i.e. ["h-card", "h-org"] if(modules.utils.isArray(names)) { out.type = names; } else { out.type = [names]; } out.properties = {}; // metadata properties for parsing out.typeVersion = typeVersion; out.times = []; out.dates = []; out.altValue = null; return out; }
[ "function", "(", "names", ",", "typeVersion", ",", "value", ")", "{", "var", "out", "=", "{", "}", ";", "// is more than just whitespace", "if", "(", "value", "&&", "modules", ".", "utils", ".", "isOnlyWhiteSpace", "(", "value", ")", "===", "false", ")", ...
creates a blank microformats object @param {String} name @param {String} value @return {Object}
[ "creates", "a", "blank", "microformats", "object" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1351-L1372
34,633
glennjones/microformat-shiv
microformat-shiv.js
function( microformat ) { delete microformat.times; delete microformat.dates; delete microformat.typeVersion; delete microformat.altValue; return microformat; }
javascript
function( microformat ) { delete microformat.times; delete microformat.dates; delete microformat.typeVersion; delete microformat.altValue; return microformat; }
[ "function", "(", "microformat", ")", "{", "delete", "microformat", ".", "times", ";", "delete", "microformat", ".", "dates", ";", "delete", "microformat", ".", "typeVersion", ";", "delete", "microformat", ".", "altValue", ";", "return", "microformat", ";", "}"...
removes unwanted microformats property before output @param {Object} microformat
[ "removes", "unwanted", "microformats", "property", "before", "output" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1380-L1386
34,634
glennjones/microformat-shiv
microformat-shiv.js
function(text) { var i; i = this.propertyPrefixes.length; while(i--) { var prefix = this.propertyPrefixes[i]; if(modules.utils.startWith(text, prefix) && modules.utils.isLowerCase(text)) { text = text.substr(prefix.length); } } return text; }
javascript
function(text) { var i; i = this.propertyPrefixes.length; while(i--) { var prefix = this.propertyPrefixes[i]; if(modules.utils.startWith(text, prefix) && modules.utils.isLowerCase(text)) { text = text.substr(prefix.length); } } return text; }
[ "function", "(", "text", ")", "{", "var", "i", ";", "i", "=", "this", ".", "propertyPrefixes", ".", "length", ";", "while", "(", "i", "--", ")", "{", "var", "prefix", "=", "this", ".", "propertyPrefixes", "[", "i", "]", ";", "if", "(", "modules", ...
removes microformat property prefixes from text @param {String} text @return {String}
[ "removes", "microformat", "property", "prefixes", "from", "text" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1396-L1407
34,635
glennjones/microformat-shiv
microformat-shiv.js
function(node, attrName, baseUrl){ var i, nodes, attr; nodes = modules.domUtils.getNodesByAttribute(node, attrName); i = nodes.length; while (i--) { try{ // the url parser can blow up if the format is not right attr = modules.domUtils.getAttribute(nodes[i], attrName); if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) { //attr = urlParser.resolve(baseUrl, attr); attr = modules.url.resolve(attr, baseUrl); modules.domUtils.setAttribute(nodes[i], attrName, attr); } }catch(err){ // do nothing - convert only the urls we can, leave the rest as they are } } }
javascript
function(node, attrName, baseUrl){ var i, nodes, attr; nodes = modules.domUtils.getNodesByAttribute(node, attrName); i = nodes.length; while (i--) { try{ // the url parser can blow up if the format is not right attr = modules.domUtils.getAttribute(nodes[i], attrName); if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) { //attr = urlParser.resolve(baseUrl, attr); attr = modules.url.resolve(attr, baseUrl); modules.domUtils.setAttribute(nodes[i], attrName, attr); } }catch(err){ // do nothing - convert only the urls we can, leave the rest as they are } } }
[ "function", "(", "node", ",", "attrName", ",", "baseUrl", ")", "{", "var", "i", ",", "nodes", ",", "attr", ";", "nodes", "=", "modules", ".", "domUtils", ".", "getNodesByAttribute", "(", "node", ",", "attrName", ")", ";", "i", "=", "nodes", ".", "len...
expands all relative URLs to absolute ones where it can @param {DOM Node} node @param {String} attrName @param {String} baseUrl
[ "expands", "all", "relative", "URLs", "to", "absolute", "ones", "where", "it", "can" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1417-L1437
34,636
glennjones/microformat-shiv
microformat-shiv.js
function(options) { var key; for(key in options) { if(options.hasOwnProperty(key)) { this.options[key] = options[key]; } } }
javascript
function(options) { var key; for(key in options) { if(options.hasOwnProperty(key)) { this.options[key] = options[key]; } } }
[ "function", "(", "options", ")", "{", "var", "key", ";", "for", "(", "key", "in", "options", ")", "{", "if", "(", "options", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "this", ".", "options", "[", "key", "]", "=", "options", "[", "key", "]...
merges passed and default options -single level clone of properties @param {Object} options
[ "merges", "passed", "and", "default", "options", "-", "single", "level", "clone", "of", "properties" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1446-L1453
34,637
glennjones/microformat-shiv
microformat-shiv.js
function(rootNode){ var arr, i; arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids'); i = arr.length; while(i--) { modules.domUtils.removeAttribute(arr[i],'rootids'); } }
javascript
function(rootNode){ var arr, i; arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids'); i = arr.length; while(i--) { modules.domUtils.removeAttribute(arr[i],'rootids'); } }
[ "function", "(", "rootNode", ")", "{", "var", "arr", ",", "i", ";", "arr", "=", "modules", ".", "domUtils", ".", "getNodesByAttribute", "(", "rootNode", ",", "'rootids'", ")", ";", "i", "=", "arr", ".", "length", ";", "while", "(", "i", "--", ")", ...
removes all rootid attributes @param {DOM Node} rootNode
[ "removes", "all", "rootid", "attributes" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1461-L1470
34,638
glennjones/microformat-shiv
microformat-shiv.js
function( text ) { if(text && this.isString(text)){ return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, ''); }else{ return ''; } }
javascript
function( text ) { if(text && this.isString(text)){ return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, ''); }else{ return ''; } }
[ "function", "(", "text", ")", "{", "if", "(", "text", "&&", "this", ".", "isString", "(", "text", ")", ")", "{", "return", "(", "text", ".", "trim", "(", ")", ")", "?", "text", ".", "trim", "(", ")", ":", "text", ".", "replace", "(", "/", "^\...
removes spaces at front and back of text @param {String} text @return {String}
[ "removes", "spaces", "at", "front", "and", "back", "of", "text" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2321-L2327
34,639
glennjones/microformat-shiv
microformat-shiv.js
function( text, index, character ) { if(text && text.length > index){ return text.substr(0, index) + character + text.substr(index+character.length); }else{ return text; } }
javascript
function( text, index, character ) { if(text && text.length > index){ return text.substr(0, index) + character + text.substr(index+character.length); }else{ return text; } }
[ "function", "(", "text", ",", "index", ",", "character", ")", "{", "if", "(", "text", "&&", "text", ".", "length", ">", "index", ")", "{", "return", "text", ".", "substr", "(", "0", ",", "index", ")", "+", "character", "+", "text", ".", "substr", ...
replaces a character in text @param {String} text @param {Int} index @param {String} character @return {String}
[ "replaces", "a", "character", "in", "text" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2338-L2344
34,640
glennjones/microformat-shiv
microformat-shiv.js
function( text ){ if(text && text.length){ var i = text.length, x = 0; // turn all whitespace chars at end into spaces while (i--) { if(this.isOnlyWhiteSpace(text[i])){ text = this.replaceCharAt( text, i, ' ' ); }else{ break; } } // turn all whitespace chars at start into spaces i = text.length; while (x < i) { if(this.isOnlyWhiteSpace(text[x])){ text = this.replaceCharAt( text, i, ' ' ); }else{ break; } x++; } } return this.trim(text); }
javascript
function( text ){ if(text && text.length){ var i = text.length, x = 0; // turn all whitespace chars at end into spaces while (i--) { if(this.isOnlyWhiteSpace(text[i])){ text = this.replaceCharAt( text, i, ' ' ); }else{ break; } } // turn all whitespace chars at start into spaces i = text.length; while (x < i) { if(this.isOnlyWhiteSpace(text[x])){ text = this.replaceCharAt( text, i, ' ' ); }else{ break; } x++; } } return this.trim(text); }
[ "function", "(", "text", ")", "{", "if", "(", "text", "&&", "text", ".", "length", ")", "{", "var", "i", "=", "text", ".", "length", ",", "x", "=", "0", ";", "// turn all whitespace chars at end into spaces", "while", "(", "i", "--", ")", "{", "if", ...
removes whitespace, tabs and returns from start and end of text @param {String} text @return {String}
[ "removes", "whitespace", "tabs", "and", "returns", "from", "start", "and", "end", "of", "text" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2353-L2379
34,641
glennjones/microformat-shiv
microformat-shiv.js
function(property, reverse) { reverse = (reverse) ? -1 : 1; return function (a, b) { a = a[property]; b = b[property]; if (a < b) { return reverse * -1; } if (a > b) { return reverse * 1; } return 0; }; }
javascript
function(property, reverse) { reverse = (reverse) ? -1 : 1; return function (a, b) { a = a[property]; b = b[property]; if (a < b) { return reverse * -1; } if (a > b) { return reverse * 1; } return 0; }; }
[ "function", "(", "property", ",", "reverse", ")", "{", "reverse", "=", "(", "reverse", ")", "?", "-", "1", ":", "1", ";", "return", "function", "(", "a", ",", "b", ")", "{", "a", "=", "a", "[", "property", "]", ";", "b", "=", "b", "[", "prope...
a sort function - to sort objects in an array by a given property @param {String} property @param {Boolean} reverse @return {Int}
[ "a", "sort", "function", "-", "to", "sort", "objects", "in", "an", "array", "by", "a", "given", "property" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2428-L2441
34,642
glennjones/microformat-shiv
microformat-shiv.js
function () { if (typeof DOMParser === undefined) { try { return Components.classes["@mozilla.org/xmlextras/domparser;1"] .createInstance(Components.interfaces.nsIDOMParser); } catch (e) { return; } } else { return new DOMParser(); } }
javascript
function () { if (typeof DOMParser === undefined) { try { return Components.classes["@mozilla.org/xmlextras/domparser;1"] .createInstance(Components.interfaces.nsIDOMParser); } catch (e) { return; } } else { return new DOMParser(); } }
[ "function", "(", ")", "{", "if", "(", "typeof", "DOMParser", "===", "undefined", ")", "{", "try", "{", "return", "Components", ".", "classes", "[", "\"@mozilla.org/xmlextras/domparser;1\"", "]", ".", "createInstance", "(", "Components", ".", "interfaces", ".", ...
gets DOMParser object @return {Object || undefined}
[ "gets", "DOMParser", "object" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2458-L2469
34,643
glennjones/microformat-shiv
microformat-shiv.js
function(node, attributeName) { var out = [], attList; attList = node.getAttribute(attributeName); if(attList && attList !== '') { if(attList.indexOf(' ') > -1) { out = attList.split(' '); } else { out.push(attList); } } return out; }
javascript
function(node, attributeName) { var out = [], attList; attList = node.getAttribute(attributeName); if(attList && attList !== '') { if(attList.indexOf(' ') > -1) { out = attList.split(' '); } else { out.push(attList); } } return out; }
[ "function", "(", "node", ",", "attributeName", ")", "{", "var", "out", "=", "[", "]", ",", "attList", ";", "attList", "=", "node", ".", "getAttribute", "(", "attributeName", ")", ";", "if", "(", "attList", "&&", "attList", "!==", "''", ")", "{", "if"...
get value of a Node attribute as an array @param {DOM Node} node @param {String} attributeName @return {Array}
[ "get", "value", "of", "a", "Node", "attribute", "as", "an", "array" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2671-L2684
34,644
glennjones/microformat-shiv
microformat-shiv.js
function(rootNode, name, value) { var arr = [], x = 0, i, out = []; arr = this.getNodesByAttribute(rootNode, name); if(arr) { i = arr.length; while(x < i) { if(this.hasAttributeValue(arr[x], name, value)) { out.push(arr[x]); } x++; } } return out; }
javascript
function(rootNode, name, value) { var arr = [], x = 0, i, out = []; arr = this.getNodesByAttribute(rootNode, name); if(arr) { i = arr.length; while(x < i) { if(this.hasAttributeValue(arr[x], name, value)) { out.push(arr[x]); } x++; } } return out; }
[ "function", "(", "rootNode", ",", "name", ",", "value", ")", "{", "var", "arr", "=", "[", "]", ",", "x", "=", "0", ",", "i", ",", "out", "=", "[", "]", ";", "arr", "=", "this", ".", "getNodesByAttribute", "(", "rootNode", ",", "name", ")", ";",...
gets all child nodes with a given attribute containing a given value @param {DOM Node} node @param {String} attributeName @return {DOM NodeList}
[ "gets", "all", "child", "nodes", "with", "a", "given", "attribute", "containing", "a", "given", "value" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2707-L2724
34,645
glennjones/microformat-shiv
microformat-shiv.js
function(node, tagNames, attributeName) { var i = tagNames.length; while(i--) { if(node.tagName.toLowerCase() === tagNames[i]) { var attrValue = this.getAttribute(node, attributeName); if(attrValue && attrValue !== '') { return attrValue; } } } return null; }
javascript
function(node, tagNames, attributeName) { var i = tagNames.length; while(i--) { if(node.tagName.toLowerCase() === tagNames[i]) { var attrValue = this.getAttribute(node, attributeName); if(attrValue && attrValue !== '') { return attrValue; } } } return null; }
[ "function", "(", "node", ",", "tagNames", ",", "attributeName", ")", "{", "var", "i", "=", "tagNames", ".", "length", ";", "while", "(", "i", "--", ")", "{", "if", "(", "node", ".", "tagName", ".", "toLowerCase", "(", ")", "===", "tagNames", "[", "...
gets attribute value from controlled list of tags @param {Array} tagNames @param {String} attributeName @return {String || null}
[ "gets", "attribute", "value", "from", "controlled", "list", "of", "tags" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2734-L2746
34,646
glennjones/microformat-shiv
microformat-shiv.js
function(node, tagNames){ var i = tagNames.length; while(i--) { if(node.tagName.toLowerCase() === tagNames[i]) { return true; } } return false; }
javascript
function(node, tagNames){ var i = tagNames.length; while(i--) { if(node.tagName.toLowerCase() === tagNames[i]) { return true; } } return false; }
[ "function", "(", "node", ",", "tagNames", ")", "{", "var", "i", "=", "tagNames", ".", "length", ";", "while", "(", "i", "--", ")", "{", "if", "(", "node", ".", "tagName", ".", "toLowerCase", "(", ")", "===", "tagNames", "[", "i", "]", ")", "{", ...
is a node one of a list of tags @param {DOM Node} rootNode @param {Array} tagNames @return {Boolean}
[ "is", "a", "node", "one", "of", "a", "list", "of", "tags" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2818-L2826
34,647
glennjones/microformat-shiv
microformat-shiv.js
function(node) { var newNode = node.cloneNode(true); if(this.hasAttribute(node, 'id')){ this.removeAttribute(node, 'id') } return newNode; }
javascript
function(node) { var newNode = node.cloneNode(true); if(this.hasAttribute(node, 'id')){ this.removeAttribute(node, 'id') } return newNode; }
[ "function", "(", "node", ")", "{", "var", "newNode", "=", "node", ".", "cloneNode", "(", "true", ")", ";", "if", "(", "this", ".", "hasAttribute", "(", "node", ",", "'id'", ")", ")", "{", "this", ".", "removeAttribute", "(", "node", ",", "'id'", ")...
abstracts DOM cloneNode @param {DOM Node} node @return {DOM Node}
[ "abstracts", "DOM", "cloneNode" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2862-L2868
34,648
glennjones/microformat-shiv
microformat-shiv.js
function(node, tagNames) { for (var i = 0; i < tagNames.length; i++) { if(node.getElementsByTagName){ var elements = node.getElementsByTagName(tagNames[i]); while (elements[0]) { elements[0].parentNode.removeChild(elements[0]) } } } return node; }
javascript
function(node, tagNames) { for (var i = 0; i < tagNames.length; i++) { if(node.getElementsByTagName){ var elements = node.getElementsByTagName(tagNames[i]); while (elements[0]) { elements[0].parentNode.removeChild(elements[0]) } } } return node; }
[ "function", "(", "node", ",", "tagNames", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "tagNames", ".", "length", ";", "i", "++", ")", "{", "if", "(", "node", ".", "getElementsByTagName", ")", "{", "var", "elements", "=", "node", "....
removes all the descendant tags by name @param {DOM Node} node @param {Array} tagNames @return {DOM Node}
[ "removes", "all", "the", "descendant", "tags", "by", "name" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2878-L2888
34,649
glennjones/microformat-shiv
microformat-shiv.js
function( node ){ var nodeStr = node.outerHTML, attrs = []; for (var i = 0; i < node.attributes.length; i++) { var attr = node.attributes[i]; attr.indexNum = nodeStr.indexOf(attr.name); attrs.push( attr ); } return attrs.sort( modules.utils.sortObjects( 'indexNum' ) ); }
javascript
function( node ){ var nodeStr = node.outerHTML, attrs = []; for (var i = 0; i < node.attributes.length; i++) { var attr = node.attributes[i]; attr.indexNum = nodeStr.indexOf(attr.name); attrs.push( attr ); } return attrs.sort( modules.utils.sortObjects( 'indexNum' ) ); }
[ "function", "(", "node", ")", "{", "var", "nodeStr", "=", "node", ".", "outerHTML", ",", "attrs", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "node", ".", "attributes", ".", "length", ";", "i", "++", ")", "{", "var", ...
gets the attributes of a node - ordered by sequence in html @param {DOM Node} node @return {Array}
[ "gets", "the", "attributes", "of", "a", "node", "-", "ordered", "by", "sequence", "in", "html" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2912-L2923
34,650
glennjones/microformat-shiv
microformat-shiv.js
function( document ){ var newNode, newDocument = null; if( this.canCloneDocument( document )){ newDocument = document.implementation.createHTMLDocument(''); newNode = newDocument.importNode( document.documentElement, true ); newDocument.replaceChild(newNode, newDocument.querySelector('html')); } return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document; }
javascript
function( document ){ var newNode, newDocument = null; if( this.canCloneDocument( document )){ newDocument = document.implementation.createHTMLDocument(''); newNode = newDocument.importNode( document.documentElement, true ); newDocument.replaceChild(newNode, newDocument.querySelector('html')); } return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document; }
[ "function", "(", "document", ")", "{", "var", "newNode", ",", "newDocument", "=", "null", ";", "if", "(", "this", ".", "canCloneDocument", "(", "document", ")", ")", "{", "newDocument", "=", "document", ".", "implementation", ".", "createHTMLDocument", "(", ...
clones a DOM document @param {DOM Document} document @return {DOM Document}
[ "clones", "a", "DOM", "document" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2945-L2955
34,651
glennjones/microformat-shiv
microformat-shiv.js
function (node) { var parent = node.parentNode, i = -1, child; while (parent && (child = parent.childNodes[++i])){ if (child === node){ return i; } } return -1; }
javascript
function (node) { var parent = node.parentNode, i = -1, child; while (parent && (child = parent.childNodes[++i])){ if (child === node){ return i; } } return -1; }
[ "function", "(", "node", ")", "{", "var", "parent", "=", "node", ".", "parentNode", ",", "i", "=", "-", "1", ",", "child", ";", "while", "(", "parent", "&&", "(", "child", "=", "parent", ".", "childNodes", "[", "++", "i", "]", ")", ")", "{", "i...
get the child index of a node. Used to create a node path @param {DOM Node} node @return {Int}
[ "get", "the", "child", "index", "of", "a", "node", ".", "Used", "to", "create", "a", "node", "path" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2975-L2985
34,652
glennjones/microformat-shiv
microformat-shiv.js
function (document, path) { var node = document.documentElement, i = 0, index; while ((index = path[++i]) > -1){ node = node.childNodes[index]; } return node; }
javascript
function (document, path) { var node = document.documentElement, i = 0, index; while ((index = path[++i]) > -1){ node = node.childNodes[index]; } return node; }
[ "function", "(", "document", ",", "path", ")", "{", "var", "node", "=", "document", ".", "documentElement", ",", "i", "=", "0", ",", "index", ";", "while", "(", "(", "index", "=", "path", "[", "++", "i", "]", ")", ">", "-", "1", ")", "{", "node...
get a node from a path. @param {DOM document} document @param {Array} path @return {DOM Node}
[ "get", "a", "node", "from", "a", "path", "." ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3039-L3047
34,653
glennjones/microformat-shiv
microformat-shiv.js
function( tagName, text ){ var node = this.document.createElement(tagName); node.innerHTML = text; return node; }
javascript
function( tagName, text ){ var node = this.document.createElement(tagName); node.innerHTML = text; return node; }
[ "function", "(", "tagName", ",", "text", ")", "{", "var", "node", "=", "this", ".", "document", ".", "createElement", "(", "tagName", ")", ";", "node", ".", "innerHTML", "=", "text", ";", "return", "node", ";", "}" ]
create a node with text content @param {String} tagName @param {String} text @return {DOM node}
[ "create", "a", "node", "with", "text", "content" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3079-L3083
34,654
glennjones/microformat-shiv
microformat-shiv.js
function(){ //this._domParser = new DOMParser(); this._domParser = modules.domUtils.getDOMParser(); // do not use a head tag it does not work with IE9 this._html = '<base id="base" href=""></base><a id="link" href=""></a>'; this._nodes = this._domParser.parseFromString( this._html, 'text/html' ); this._baseNode = modules.domUtils.getElementById(this._nodes,'base'); this._linkNode = modules.domUtils.getElementById(this._nodes,'link'); }
javascript
function(){ //this._domParser = new DOMParser(); this._domParser = modules.domUtils.getDOMParser(); // do not use a head tag it does not work with IE9 this._html = '<base id="base" href=""></base><a id="link" href=""></a>'; this._nodes = this._domParser.parseFromString( this._html, 'text/html' ); this._baseNode = modules.domUtils.getElementById(this._nodes,'base'); this._linkNode = modules.domUtils.getElementById(this._nodes,'link'); }
[ "function", "(", ")", "{", "//this._domParser = new DOMParser();", "this", ".", "_domParser", "=", "modules", ".", "domUtils", ".", "getDOMParser", "(", ")", ";", "// do not use a head tag it does not work with IE9", "this", ".", "_html", "=", "'<base id=\"base\" href=\"\...
creates DOM objects needed to resolve URLs
[ "creates", "DOM", "objects", "needed", "to", "resolve", "URLs" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3096-L3104
34,655
glennjones/microformat-shiv
microformat-shiv.js
function(url, baseUrl) { // use modern URL web API where we can if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1){ // this try catch is required as IE has an URL object but no constuctor support // http://glennjones.net/articles/the-problem-with-window-url try { var resolved = new URL(url, baseUrl).toString(); // deal with early Webkit not throwing an error - for Safari if(resolved === '[object URL]'){ resolved = URI.resolve(baseUrl, url); } return resolved; }catch(e){ // otherwise fallback to DOM if(this._domParser === undefined){ this.init(); } // do not use setAttribute it does not work with IE9 this._baseNode.href = baseUrl; this._linkNode.href = url; // dont use getAttribute as it returns orginal value not resolved return this._linkNode.href; } }else{ if(modules.utils.isString(url)){ return url; } return ''; } }
javascript
function(url, baseUrl) { // use modern URL web API where we can if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1){ // this try catch is required as IE has an URL object but no constuctor support // http://glennjones.net/articles/the-problem-with-window-url try { var resolved = new URL(url, baseUrl).toString(); // deal with early Webkit not throwing an error - for Safari if(resolved === '[object URL]'){ resolved = URI.resolve(baseUrl, url); } return resolved; }catch(e){ // otherwise fallback to DOM if(this._domParser === undefined){ this.init(); } // do not use setAttribute it does not work with IE9 this._baseNode.href = baseUrl; this._linkNode.href = url; // dont use getAttribute as it returns orginal value not resolved return this._linkNode.href; } }else{ if(modules.utils.isString(url)){ return url; } return ''; } }
[ "function", "(", "url", ",", "baseUrl", ")", "{", "// use modern URL web API where we can", "if", "(", "modules", ".", "utils", ".", "isString", "(", "url", ")", "&&", "modules", ".", "utils", ".", "isString", "(", "baseUrl", ")", "&&", "url", ".", "indexO...
resolves url to absolute version using baseUrl @param {String} url @param {String} baseUrl @return {String}
[ "resolves", "url", "to", "absolute", "version", "using", "baseUrl" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3114-L3145
34,656
glennjones/microformat-shiv
microformat-shiv.js
function() { switch( this.format.toLowerCase() ) { case 'microformat2': this.sep = ' '; this.dsep = '-'; this.tsep = ':'; this.tzsep = ''; this.tzZulu = 'Z'; break; case 'rfc3339': this.sep = 'T'; this.dsep = ''; this.tsep = ''; this.tzsep = ''; this.tzZulu = 'Z'; break; case 'w3c': this.sep = 'T'; this.dsep = '-'; this.tsep = ':'; this.tzsep = ':'; this.tzZulu = 'Z'; break; case 'html5': this.sep = ' '; this.dsep = '-'; this.tsep = ':'; this.tzsep = ':'; this.tzZulu = 'Z'; break; default: // auto - defined by format of input string this.sep = this.autoProfile.sep; this.dsep = this.autoProfile.dsep; this.tsep = this.autoProfile.tsep; this.tzsep = this.autoProfile.tzsep; this.tzZulu = this.autoProfile.tzZulu; } }
javascript
function() { switch( this.format.toLowerCase() ) { case 'microformat2': this.sep = ' '; this.dsep = '-'; this.tsep = ':'; this.tzsep = ''; this.tzZulu = 'Z'; break; case 'rfc3339': this.sep = 'T'; this.dsep = ''; this.tsep = ''; this.tzsep = ''; this.tzZulu = 'Z'; break; case 'w3c': this.sep = 'T'; this.dsep = '-'; this.tsep = ':'; this.tzsep = ':'; this.tzZulu = 'Z'; break; case 'html5': this.sep = ' '; this.dsep = '-'; this.tsep = ':'; this.tzsep = ':'; this.tzZulu = 'Z'; break; default: // auto - defined by format of input string this.sep = this.autoProfile.sep; this.dsep = this.autoProfile.dsep; this.tsep = this.autoProfile.tsep; this.tzsep = this.autoProfile.tzsep; this.tzZulu = this.autoProfile.tzZulu; } }
[ "function", "(", ")", "{", "switch", "(", "this", ".", "format", ".", "toLowerCase", "(", ")", ")", "{", "case", "'microformat2'", ":", "this", ".", "sep", "=", "' '", ";", "this", ".", "dsep", "=", "'-'", ";", "this", ".", "tsep", "=", "':'", ";...
set the current profile to W3C Note, RFC 3339, HTML5, or auto profile
[ "set", "the", "current", "profile", "to", "W3C", "Note", "RFC", "3339", "HTML5", "or", "auto", "profile" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3544-L3582
34,657
glennjones/microformat-shiv
microformat-shiv.js
function( text ) { if(modules.utils.isString( text )){ text = text.toLowerCase(); if(modules.utils.startWith(text, 'p') ){ return true; } } return false; }
javascript
function( text ) { if(modules.utils.isString( text )){ text = text.toLowerCase(); if(modules.utils.startWith(text, 'p') ){ return true; } } return false; }
[ "function", "(", "text", ")", "{", "if", "(", "modules", ".", "utils", ".", "isString", "(", "text", ")", ")", "{", "text", "=", "text", ".", "toLowerCase", "(", ")", ";", "if", "(", "modules", ".", "utils", ".", "startWith", "(", "text", ",", "'...
simple test of whether ISO date string is a duration i.e. PY17M or PW12 @param {String} text @return {Boolean}
[ "simple", "test", "of", "whether", "ISO", "date", "string", "is", "a", "duration", "i", ".", "e", ".", "PY17M", "or", "PW12" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3672-L3680
34,658
glennjones/microformat-shiv
microformat-shiv.js
function(date, time, format) { var isodate = new modules.ISODate(date, format), isotime = new modules.ISODate(); isotime.parseTime(this.parseAmPmTime(time), format); if(isodate.hasFullDate() && isotime.hasTime()) { isodate.tH = isotime.tH; isodate.tM = isotime.tM; isodate.tS = isotime.tS; isodate.tD = isotime.tD; return isodate; } else { if(isodate.hasFullDate()){ return isodate; } return new modules.ISODate(); } }
javascript
function(date, time, format) { var isodate = new modules.ISODate(date, format), isotime = new modules.ISODate(); isotime.parseTime(this.parseAmPmTime(time), format); if(isodate.hasFullDate() && isotime.hasTime()) { isodate.tH = isotime.tH; isodate.tM = isotime.tM; isodate.tS = isotime.tS; isodate.tD = isotime.tD; return isodate; } else { if(isodate.hasFullDate()){ return isodate; } return new modules.ISODate(); } }
[ "function", "(", "date", ",", "time", ",", "format", ")", "{", "var", "isodate", "=", "new", "modules", ".", "ISODate", "(", "date", ",", "format", ")", ",", "isotime", "=", "new", "modules", ".", "ISODate", "(", ")", ";", "isotime", ".", "parseTime"...
overlays a time on a date to return the union of the two @param {String} date @param {String} time @param {String} format ( Modules.ISODate profile format ) @return {Object} Modules.ISODate
[ "overlays", "a", "time", "on", "a", "date", "to", "return", "the", "union", "of", "the", "two" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3777-L3794
34,659
glennjones/microformat-shiv
microformat-shiv.js
function (arr, format) { var out = new modules.ISODate(), i = 0, value = ''; // if the fragment already contains a full date just return it once if(arr[0].toUpperCase().match('T')) { return new modules.ISODate(arr[0], format); }else{ for(i = 0; i < arr.length; i++) { value = arr[i]; // date pattern if( value.charAt(4) === '-' && out.hasFullDate() === false ){ out.parseDate(value); } // time pattern if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) { // split time and timezone var items = this.splitTimeAndZone(value); value = items[0]; // parse any use of am/pm value = this.parseAmPmTime(value); out.parseTime(value); // parse any timezone if(items.length > 1){ out.parseTimeZone(items[1], format); } } // timezone pattern if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') { if( out.hasTimeZone() === false ){ out.parseTimeZone(value); } } } // alway imply minutes if(out.tM === -1){ out.tM = '00'; } return out; } }
javascript
function (arr, format) { var out = new modules.ISODate(), i = 0, value = ''; // if the fragment already contains a full date just return it once if(arr[0].toUpperCase().match('T')) { return new modules.ISODate(arr[0], format); }else{ for(i = 0; i < arr.length; i++) { value = arr[i]; // date pattern if( value.charAt(4) === '-' && out.hasFullDate() === false ){ out.parseDate(value); } // time pattern if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) { // split time and timezone var items = this.splitTimeAndZone(value); value = items[0]; // parse any use of am/pm value = this.parseAmPmTime(value); out.parseTime(value); // parse any timezone if(items.length > 1){ out.parseTimeZone(items[1], format); } } // timezone pattern if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') { if( out.hasTimeZone() === false ){ out.parseTimeZone(value); } } } // alway imply minutes if(out.tM === -1){ out.tM = '00'; } return out; } }
[ "function", "(", "arr", ",", "format", ")", "{", "var", "out", "=", "new", "modules", ".", "ISODate", "(", ")", ",", "i", "=", "0", ",", "value", "=", "''", ";", "// if the fragment already contains a full date just return it once", "if", "(", "arr", "[", ...
concatenate an array of date and time text fragments to create an ISODate object used for microformat value and value-title rules @param {Array} arr ( Array of Strings ) @param {String} format ( Modules.ISODate profile format ) @return {Object} Modules.ISODate
[ "concatenate", "an", "array", "of", "date", "and", "time", "text", "fragments", "to", "create", "an", "ISODate", "object", "used", "for", "microformat", "value", "and", "value", "-", "title", "rules" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3805-L3852
34,660
glennjones/microformat-shiv
microformat-shiv.js
function ( text ){ var out = [text], chars = ['-','+','z','Z'], i = chars.length; while (i--) { if(text.indexOf(chars[i]) > -1){ out[0] = text.slice( 0, text.indexOf(chars[i]) ); out.push( text.slice( text.indexOf(chars[i]) ) ); break; } } return out; }
javascript
function ( text ){ var out = [text], chars = ['-','+','z','Z'], i = chars.length; while (i--) { if(text.indexOf(chars[i]) > -1){ out[0] = text.slice( 0, text.indexOf(chars[i]) ); out.push( text.slice( text.indexOf(chars[i]) ) ); break; } } return out; }
[ "function", "(", "text", ")", "{", "var", "out", "=", "[", "text", "]", ",", "chars", "=", "[", "'-'", ",", "'+'", ",", "'z'", ",", "'Z'", "]", ",", "i", "=", "chars", ".", "length", ";", "while", "(", "i", "--", ")", "{", "if", "(", "text"...
parses text by splitting it into an array of time and timezone strings @param {String} text @return {Array} Modules.ISODate
[ "parses", "text", "by", "splitting", "it", "into", "an", "array", "of", "time", "and", "timezone", "strings" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3861-L3874
34,661
glennjones/microformat-shiv
microformat-shiv.js
function(doc, node, textFormat){ var out; this.textFormat = (textFormat)? textFormat : this.textFormat; if(this.textFormat === 'normalised'){ out = this.walkTreeForText( node ); if(out !== undefined){ return this.normalise( doc, out ); }else{ return ''; } }else{ var clonedNode = modules.domUtils.clone(node); var trimmedNode = modules.domUtils.removeDescendantsByTagName( clonedNode, this.excludeTags ); return this.formatText( doc, modules.domUtils.textContent(trimmedNode), this.textFormat ); } }
javascript
function(doc, node, textFormat){ var out; this.textFormat = (textFormat)? textFormat : this.textFormat; if(this.textFormat === 'normalised'){ out = this.walkTreeForText( node ); if(out !== undefined){ return this.normalise( doc, out ); }else{ return ''; } }else{ var clonedNode = modules.domUtils.clone(node); var trimmedNode = modules.domUtils.removeDescendantsByTagName( clonedNode, this.excludeTags ); return this.formatText( doc, modules.domUtils.textContent(trimmedNode), this.textFormat ); } }
[ "function", "(", "doc", ",", "node", ",", "textFormat", ")", "{", "var", "out", ";", "this", ".", "textFormat", "=", "(", "textFormat", ")", "?", "textFormat", ":", "this", ".", "textFormat", ";", "if", "(", "this", ".", "textFormat", "===", "'normalis...
parses the text from the DOM Node @param {DOM Node} node @param {String} textFormat @return {String}
[ "parses", "the", "text", "from", "the", "DOM", "Node" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3902-L3918
34,662
glennjones/microformat-shiv
microformat-shiv.js
function( doc, text, textFormat ){ var node = modules.domUtils.createNodeWithText( 'div', text ); return this.parse( doc, node, textFormat ); }
javascript
function( doc, text, textFormat ){ var node = modules.domUtils.createNodeWithText( 'div', text ); return this.parse( doc, node, textFormat ); }
[ "function", "(", "doc", ",", "text", ",", "textFormat", ")", "{", "var", "node", "=", "modules", ".", "domUtils", ".", "createNodeWithText", "(", "'div'", ",", "text", ")", ";", "return", "this", ".", "parse", "(", "doc", ",", "node", ",", "textFormat"...
parses the text from a html string @param {DOM Document} doc @param {String} text @param {String} textFormat @return {String}
[ "parses", "the", "text", "from", "a", "html", "string" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3929-L3932
34,663
glennjones/microformat-shiv
microformat-shiv.js
function( doc, text, textFormat ){ this.textFormat = (textFormat)? textFormat : this.textFormat; if(text){ var out = text if(this.textFormat === 'whitespacetrimmed') { out = modules.utils.trimWhitespace( out ); } return out; }else{ return ''; } }
javascript
function( doc, text, textFormat ){ this.textFormat = (textFormat)? textFormat : this.textFormat; if(text){ var out = text if(this.textFormat === 'whitespacetrimmed') { out = modules.utils.trimWhitespace( out ); } return out; }else{ return ''; } }
[ "function", "(", "doc", ",", "text", ",", "textFormat", ")", "{", "this", ".", "textFormat", "=", "(", "textFormat", ")", "?", "textFormat", ":", "this", ".", "textFormat", ";", "if", "(", "text", ")", "{", "var", "out", "=", "text", "if", "(", "th...
parses the text from a html string - only for whitespace or whitespacetrimmed formats @param {String} text @param {String} textFormat @return {String}
[ "parses", "the", "text", "from", "a", "html", "string", "-", "only", "for", "whitespace", "or", "whitespacetrimmed", "formats" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3942-L3953
34,664
glennjones/microformat-shiv
microformat-shiv.js
function( doc, text ){ text = text.replace( /&nbsp;/g, ' ') ; // exchanges html entity for space into space char text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces text = modules.domUtils.decodeEntities( doc, text ); // decode HTML entities text = text.replace( '–', '-' ); // correct dash decoding return modules.utils.trim( text ); }
javascript
function( doc, text ){ text = text.replace( /&nbsp;/g, ' ') ; // exchanges html entity for space into space char text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces text = modules.domUtils.decodeEntities( doc, text ); // decode HTML entities text = text.replace( '–', '-' ); // correct dash decoding return modules.utils.trim( text ); }
[ "function", "(", "doc", ",", "text", ")", "{", "text", "=", "text", ".", "replace", "(", "/", "&nbsp;", "/", "g", ",", "' '", ")", ";", "// exchanges html entity for space into space char", "text", "=", "modules", ".", "utils", ".", "collapseWhiteSpace", "("...
normalises whitespace in given text @param {String} text @return {String}
[ "normalises", "whitespace", "in", "given", "text" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3962-L3968
34,665
glennjones/microformat-shiv
microformat-shiv.js
function( node ) { var out = '', j = 0; if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){ return out; } // if node is a text node get its text if(node.nodeType && node.nodeType === 3){ out += modules.domUtils.getElementText( node ); } // get the text of the child nodes if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForText( node.childNodes[j] ); if(text !== undefined){ out += text; } } } // if it's a block level tag add an additional space at the end if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){ out += ' '; } return (out === '')? undefined : out ; }
javascript
function( node ) { var out = '', j = 0; if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){ return out; } // if node is a text node get its text if(node.nodeType && node.nodeType === 3){ out += modules.domUtils.getElementText( node ); } // get the text of the child nodes if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForText( node.childNodes[j] ); if(text !== undefined){ out += text; } } } // if it's a block level tag add an additional space at the end if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){ out += ' '; } return (out === '')? undefined : out ; }
[ "function", "(", "node", ")", "{", "var", "out", "=", "''", ",", "j", "=", "0", ";", "if", "(", "node", ".", "tagName", "&&", "this", ".", "excludeTags", ".", "indexOf", "(", "node", ".", "tagName", ".", "toLowerCase", "(", ")", ")", ">", "-", ...
walks DOM tree parsing the text from DOM Nodes @param {DOM Node} node @return {String}
[ "walks", "DOM", "tree", "parsing", "the", "text", "from", "DOM", "Nodes" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3977-L4006
34,666
glennjones/microformat-shiv
microformat-shiv.js
function( node ){ var out = '', j = 0; // we do not want the outer container if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForHtml( node.childNodes[j] ); if(text !== undefined){ out += text; } } } return out; }
javascript
function( node ){ var out = '', j = 0; // we do not want the outer container if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForHtml( node.childNodes[j] ); if(text !== undefined){ out += text; } } } return out; }
[ "function", "(", "node", ")", "{", "var", "out", "=", "''", ",", "j", "=", "0", ";", "// we do not want the outer container", "if", "(", "node", ".", "childNodes", "&&", "node", ".", "childNodes", ".", "length", ">", "0", ")", "{", "for", "(", "j", "...
parse the html string from DOM Node @param {DOM Node} node @return {String}
[ "parse", "the", "html", "string", "from", "DOM", "Node" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L4023-L4038
34,667
glennjones/microformat-shiv
microformat-shiv.js
function( node ) { var out = '', j = 0; // if node is a text node get its text if(node.nodeType && node.nodeType === 3){ //out += modules.domUtils.getElementText( node ); var containerNode = modules.domUtils.createNode('div'); modules.domUtils.appendChild(containerNode, modules.domUtils.clone(node)); out += modules.domUtils.innerHTML(containerNode); } // exclude text which has been added with include pattern - if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){ // begin tag out += '<' + node.tagName.toLowerCase(); // add attributes var attrs = modules.domUtils.getOrderedAttributes(node); for (j = 0; j < attrs.length; j++) { out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"'; } if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){ out += '>'; } // get the text of the child nodes if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForHtml( node.childNodes[j] ); if(text !== undefined){ out += text; } } } // end tag if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){ out += ' />'; }else{ out += '</' + node.tagName.toLowerCase() + '>'; } } return (out === '')? undefined : out; }
javascript
function( node ) { var out = '', j = 0; // if node is a text node get its text if(node.nodeType && node.nodeType === 3){ //out += modules.domUtils.getElementText( node ); var containerNode = modules.domUtils.createNode('div'); modules.domUtils.appendChild(containerNode, modules.domUtils.clone(node)); out += modules.domUtils.innerHTML(containerNode); } // exclude text which has been added with include pattern - if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){ // begin tag out += '<' + node.tagName.toLowerCase(); // add attributes var attrs = modules.domUtils.getOrderedAttributes(node); for (j = 0; j < attrs.length; j++) { out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"'; } if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){ out += '>'; } // get the text of the child nodes if(node.childNodes && node.childNodes.length > 0){ for (j = 0; j < node.childNodes.length; j++) { var text = this.walkTreeForHtml( node.childNodes[j] ); if(text !== undefined){ out += text; } } } // end tag if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){ out += ' />'; }else{ out += '</' + node.tagName.toLowerCase() + '>'; } } return (out === '')? undefined : out; }
[ "function", "(", "node", ")", "{", "var", "out", "=", "''", ",", "j", "=", "0", ";", "// if node is a text node get its text", "if", "(", "node", ".", "nodeType", "&&", "node", ".", "nodeType", "===", "3", ")", "{", "//out += modules.domUtils.getElementText( n...
walks the DOM tree parsing the html string from the nodes @param {DOM Document} doc @param {DOM Node} node @return {String}
[ "walks", "the", "DOM", "tree", "parsing", "the", "html", "string", "from", "the", "nodes" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L4048-L4097
34,668
seandmurray/aws_athena_client
lib/request.js
validateQuery
function validateQuery(query) { Assert.ok(((query) && ((typeof query) === 'object')), 'The Query object was not set?'); Assert.ok(((query.QueryString) && ((typeof query.QueryString) === 'string')), 'The query string was not set?'); Assert.ok(((query.ResultConfiguration) && ((typeof query.ResultConfiguration) === 'object')), 'The result configuation in the query object was not set?'); Assert.ok(((query.ResultConfiguration.OutputLocation) && ((typeof query.ResultConfiguration.OutputLocation) === 'string')), 'The output location of the result configuration in the query object was not set?'); return query; }
javascript
function validateQuery(query) { Assert.ok(((query) && ((typeof query) === 'object')), 'The Query object was not set?'); Assert.ok(((query.QueryString) && ((typeof query.QueryString) === 'string')), 'The query string was not set?'); Assert.ok(((query.ResultConfiguration) && ((typeof query.ResultConfiguration) === 'object')), 'The result configuation in the query object was not set?'); Assert.ok(((query.ResultConfiguration.OutputLocation) && ((typeof query.ResultConfiguration.OutputLocation) === 'string')), 'The output location of the result configuration in the query object was not set?'); return query; }
[ "function", "validateQuery", "(", "query", ")", "{", "Assert", ".", "ok", "(", "(", "(", "query", ")", "&&", "(", "(", "typeof", "query", ")", "===", "'object'", ")", ")", ",", "'The Query object was not set?'", ")", ";", "Assert", ".", "ok", "(", "(",...
Fails if the minium set of values are not in a request.
[ "Fails", "if", "the", "minium", "set", "of", "values", "are", "not", "in", "a", "request", "." ]
31a33755748fed78d8e15fa90dd723bd6f441f74
https://github.com/seandmurray/aws_athena_client/blob/31a33755748fed78d8e15fa90dd723bd6f441f74/lib/request.js#L82-L92
34,669
christophermina/connect-couchbase
lib/connect-couchbase.js
CouchbaseStore
function CouchbaseStore(options) { var self = this; options = options || {}; Store.call(this, options); this.prefix = null == options.prefix ? 'sess:' : options.prefix; var connectOptions = {}; if (options.hasOwnProperty("host")) { connectOptions.host = options.host; } else if (options.hasOwnProperty("hosts")) { connectOptions.host = options.hosts; } if (options.hasOwnProperty("username")) { connectOptions.username = options.username; } if (options.hasOwnProperty("password")) { connectOptions.password = options.password; } if (options.hasOwnProperty("bucket")) { connectOptions.bucket = options.bucket; } if (options.hasOwnProperty("cachefile")) { connectOptions.cachefile = options.cachefile; } if (options.hasOwnProperty("connectionTimeout")) { connectOptions.connectionTimeout = options.connectionTimeout; } if (options.hasOwnProperty("operationTimeout")) { connectOptions.operationTimeout = options.operationTimeout; } if (options.hasOwnProperty("db")) { connectOptions.db = options.db; // DB Instance } if ( typeof(connectOptions.db) != 'undefined' ) { this.client = connectOptions.db; } else { var Couchbase = require('couchbase'); var cluster = new Couchbase.Cluster(connectOptions.host); var bucket = connectOptions.bucket; var prefix = this.prefix; this.queryAll = Couchbase.N1qlQuery.fromString('SELECT `' + bucket + '`.* FROM `' + bucket + '` WHERE SUBSTR(META(`' + bucket + '`).id, 0, ' + prefix.length + ') = "' + prefix + '"'); this.client = cluster.openBucket(connectOptions.bucket, connectOptions.password, function(err) { if (err) { console.log("Could not connect to couchbase with bucket: " + connectOptions.bucket); self.emit('disconnect', err); } else { self.emit('connect'); } }); } this.client.connectionTimeout = connectOptions.connectionTimeout || 10000; this.client.operationTimeout = connectOptions.operationTimeout || 10000; this.ttl = options.ttl || null; }
javascript
function CouchbaseStore(options) { var self = this; options = options || {}; Store.call(this, options); this.prefix = null == options.prefix ? 'sess:' : options.prefix; var connectOptions = {}; if (options.hasOwnProperty("host")) { connectOptions.host = options.host; } else if (options.hasOwnProperty("hosts")) { connectOptions.host = options.hosts; } if (options.hasOwnProperty("username")) { connectOptions.username = options.username; } if (options.hasOwnProperty("password")) { connectOptions.password = options.password; } if (options.hasOwnProperty("bucket")) { connectOptions.bucket = options.bucket; } if (options.hasOwnProperty("cachefile")) { connectOptions.cachefile = options.cachefile; } if (options.hasOwnProperty("connectionTimeout")) { connectOptions.connectionTimeout = options.connectionTimeout; } if (options.hasOwnProperty("operationTimeout")) { connectOptions.operationTimeout = options.operationTimeout; } if (options.hasOwnProperty("db")) { connectOptions.db = options.db; // DB Instance } if ( typeof(connectOptions.db) != 'undefined' ) { this.client = connectOptions.db; } else { var Couchbase = require('couchbase'); var cluster = new Couchbase.Cluster(connectOptions.host); var bucket = connectOptions.bucket; var prefix = this.prefix; this.queryAll = Couchbase.N1qlQuery.fromString('SELECT `' + bucket + '`.* FROM `' + bucket + '` WHERE SUBSTR(META(`' + bucket + '`).id, 0, ' + prefix.length + ') = "' + prefix + '"'); this.client = cluster.openBucket(connectOptions.bucket, connectOptions.password, function(err) { if (err) { console.log("Could not connect to couchbase with bucket: " + connectOptions.bucket); self.emit('disconnect', err); } else { self.emit('connect'); } }); } this.client.connectionTimeout = connectOptions.connectionTimeout || 10000; this.client.operationTimeout = connectOptions.operationTimeout || 10000; this.ttl = options.ttl || null; }
[ "function", "CouchbaseStore", "(", "options", ")", "{", "var", "self", "=", "this", ";", "options", "=", "options", "||", "{", "}", ";", "Store", ".", "call", "(", "this", ",", "options", ")", ";", "this", ".", "prefix", "=", "null", "==", "options",...
Initialize CouchbaseStore with the given `options`. @param {Object} options { host: 127.0.0.1:8091 (default) -- Can be one or more address:ports, separated by semi-colon, or an array username: '', -- Should be same as bucket name, if provided password: '', bucket: 'default' (default) cachefile: '' ttl: 86400, prefix: 'sess', operationTimeout:2000, connectionTimeout:2000, } @api public
[ "Initialize", "CouchbaseStore", "with", "the", "given", "options", "." ]
fe011702ec8fa72fdf088556324dc46ed879518b
https://github.com/christophermina/connect-couchbase/blob/fe011702ec8fa72fdf088556324dc46ed879518b/lib/connect-couchbase.js#L64-L139
34,670
lhkbob/eve-swagger-js
dist/util/type-generator/namespace.js
getRouteNamespaces
function getRouteNamespaces(spec) { let names = new Map(); for (let id of spec.routeIDs) { let [namespace, explicit] = Namespace.forRoute(spec.route(id)); namespace.log.push(`Route ${id} maps to ${namespace.fullName} (explicit = ${explicit})`); names.set(id, [namespace, explicit]); } return names; }
javascript
function getRouteNamespaces(spec) { let names = new Map(); for (let id of spec.routeIDs) { let [namespace, explicit] = Namespace.forRoute(spec.route(id)); namespace.log.push(`Route ${id} maps to ${namespace.fullName} (explicit = ${explicit})`); names.set(id, [namespace, explicit]); } return names; }
[ "function", "getRouteNamespaces", "(", "spec", ")", "{", "let", "names", "=", "new", "Map", "(", ")", ";", "for", "(", "let", "id", "of", "spec", ".", "routeIDs", ")", "{", "let", "[", "namespace", ",", "explicit", "]", "=", "Namespace", ".", "forRou...
Generate the names for all route ids in the specification
[ "Generate", "the", "names", "for", "all", "route", "ids", "in", "the", "specification" ]
1353126546b988dd4811fc4256c94f4d96f26c37
https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/namespace.js#L302-L310
34,671
pubfood/pubfood
src/provider/bidprovider.js
BidProvider
function BidProvider(bidDelegate) { if (this.init_) { this.init_(); } var delegate = bidDelegate || {}; this.name = delegate.name || ''; this.bidDelegate = delegate; this.enabled_ = true; this.timeout_ = delegate && delegate.timeout ? delegate.timeout : 0; }
javascript
function BidProvider(bidDelegate) { if (this.init_) { this.init_(); } var delegate = bidDelegate || {}; this.name = delegate.name || ''; this.bidDelegate = delegate; this.enabled_ = true; this.timeout_ = delegate && delegate.timeout ? delegate.timeout : 0; }
[ "function", "BidProvider", "(", "bidDelegate", ")", "{", "if", "(", "this", ".", "init_", ")", "{", "this", ".", "init_", "(", ")", ";", "}", "var", "delegate", "=", "bidDelegate", "||", "{", "}", ";", "this", ".", "name", "=", "delegate", ".", "na...
BidProvider implements bidding partner requests. @class @param {BidDelegate} delegate the delegate object that implements [libUri()]{@link pubfood#provider.BidProvider#libUri}, [init()]{@link pubfood#provider.BidProvider#init} and [refresh()]{@link pubfood#provider.BidProvider#refresh} @property {string} name the name of the provider @augments PubfoodObject @augments PubfoodProvider @memberof pubfood#provider
[ "BidProvider", "implements", "bidding", "partner", "requests", "." ]
be666e922d92f86fd1542e7c43f81126a9301771
https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/provider/bidprovider.js#L22-L31
34,672
tim-evans/ember-pop-over
addon/mixins/scroll_sandbox.js
mouseWheel
function mouseWheel(evt) { let oevt = evt.originalEvent; let delta = 0; let deltaY = 0; let deltaX = 0; if (oevt.wheelDelta) { delta = oevt.wheelDelta / 120; } if (oevt.detail) { delta = oevt.detail / -3; } deltaY = delta; if (oevt.hasOwnProperty) { // Gecko if (oevt.hasOwnProperty('axis') && oevt.axis === oevt.HORIZONTAL_AXIS) { deltaY = 0; deltaX = -1 * delta; } // Webkit if (oevt.hasOwnProperty('wheelDeltaY')) { deltaY = oevt.wheelDeltaY / +120; } if (oevt.hasOwnProperty('wheelDeltaX')) { deltaX = oevt.wheelDeltaX / -120; } } evt.wheelDeltaX = deltaX; evt.wheelDeltaY = deltaY; return this.mouseWheel(evt); }
javascript
function mouseWheel(evt) { let oevt = evt.originalEvent; let delta = 0; let deltaY = 0; let deltaX = 0; if (oevt.wheelDelta) { delta = oevt.wheelDelta / 120; } if (oevt.detail) { delta = oevt.detail / -3; } deltaY = delta; if (oevt.hasOwnProperty) { // Gecko if (oevt.hasOwnProperty('axis') && oevt.axis === oevt.HORIZONTAL_AXIS) { deltaY = 0; deltaX = -1 * delta; } // Webkit if (oevt.hasOwnProperty('wheelDeltaY')) { deltaY = oevt.wheelDeltaY / +120; } if (oevt.hasOwnProperty('wheelDeltaX')) { deltaX = oevt.wheelDeltaX / -120; } } evt.wheelDeltaX = deltaX; evt.wheelDeltaY = deltaY; return this.mouseWheel(evt); }
[ "function", "mouseWheel", "(", "evt", ")", "{", "let", "oevt", "=", "evt", ".", "originalEvent", ";", "let", "delta", "=", "0", ";", "let", "deltaY", "=", "0", ";", "let", "deltaX", "=", "0", ";", "if", "(", "oevt", ".", "wheelDelta", ")", "{", "...
Normalize mouseWheel events
[ "Normalize", "mouseWheel", "events" ]
79b4b59a9d81c4929cfd38d83ee6b01c36184eef
https://github.com/tim-evans/ember-pop-over/blob/79b4b59a9d81c4929cfd38d83ee6b01c36184eef/addon/mixins/scroll_sandbox.js#L7-L42
34,673
pubfood/pubfood
src/mediator/auctionmediator.js
AuctionMediator
function AuctionMediator(config) { if (this.init_) { this.init_(); } /** @property {boolean} prefix if false, do not add bid provider name to bid targeting key. Default: true */ this.prefix = config && config.hasOwnProperty('prefix') ? config.prefix : true; // store slots by name for easy lookup this.slotMap = {}; this.bidProviders = {}; this.auctionProvider = null; this.auctionRun = {}; this.timeout_ = AuctionMediator.NO_TIMEOUT; this.trigger_ = null; this.bidAssembler = new BidAssembler(); this.requestAssembler = new RequestAssembler(); this.auctionIdx_ = 0; this.doneCallbackOffset_ = AuctionMediator.DEFAULT_DONE_CALLBACK_OFFSET; this.omitDefaultBidKey_ = false; this.throwErrors_ = false; Event.setAuctionId(this.getAuctionId()); }
javascript
function AuctionMediator(config) { if (this.init_) { this.init_(); } /** @property {boolean} prefix if false, do not add bid provider name to bid targeting key. Default: true */ this.prefix = config && config.hasOwnProperty('prefix') ? config.prefix : true; // store slots by name for easy lookup this.slotMap = {}; this.bidProviders = {}; this.auctionProvider = null; this.auctionRun = {}; this.timeout_ = AuctionMediator.NO_TIMEOUT; this.trigger_ = null; this.bidAssembler = new BidAssembler(); this.requestAssembler = new RequestAssembler(); this.auctionIdx_ = 0; this.doneCallbackOffset_ = AuctionMediator.DEFAULT_DONE_CALLBACK_OFFSET; this.omitDefaultBidKey_ = false; this.throwErrors_ = false; Event.setAuctionId(this.getAuctionId()); }
[ "function", "AuctionMediator", "(", "config", ")", "{", "if", "(", "this", ".", "init_", ")", "{", "this", ".", "init_", "(", ")", ";", "}", "/** @property {boolean} prefix if false, do not add bid provider name to bid targeting key. Default: true */", "this", ".", "pre...
AuctionMediator coordiates requests to Publisher Ad Servers. @class @memberof pubfood#mediator @private
[ "AuctionMediator", "coordiates", "requests", "to", "Publisher", "Ad", "Servers", "." ]
be666e922d92f86fd1542e7c43f81126a9301771
https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/mediator/auctionmediator.js#L25-L46
34,674
glennjones/microformat-shiv
examples/firefox/lib/main.js
getTabData
function getTabData(url){ var key, data; key = urlToKey(url); obj = tabData[key]; return (obj)? obj : {data: {}, url: url}; }
javascript
function getTabData(url){ var key, data; key = urlToKey(url); obj = tabData[key]; return (obj)? obj : {data: {}, url: url}; }
[ "function", "getTabData", "(", "url", ")", "{", "var", "key", ",", "data", ";", "key", "=", "urlToKey", "(", "url", ")", ";", "obj", "=", "tabData", "[", "key", "]", ";", "return", "(", "obj", ")", "?", "obj", ":", "{", "data", ":", "{", "}", ...
get data from object store
[ "get", "data", "from", "object", "store" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/examples/firefox/lib/main.js#L91-L98
34,675
glennjones/microformat-shiv
examples/firefox/lib/main.js
appendTabData
function appendTabData(json){ var key; if(!getTabData(json.url).data.items){ key = urlToKey(json.url); tabData[key] = json; } }
javascript
function appendTabData(json){ var key; if(!getTabData(json.url).data.items){ key = urlToKey(json.url); tabData[key] = json; } }
[ "function", "appendTabData", "(", "json", ")", "{", "var", "key", ";", "if", "(", "!", "getTabData", "(", "json", ".", "url", ")", ".", "data", ".", "items", ")", "{", "key", "=", "urlToKey", "(", "json", ".", "url", ")", ";", "tabData", "[", "ke...
append data to the object store
[ "append", "data", "to", "the", "object", "store" ]
90c5ea5e43ae95fc460aef79f8c19832c6f1dc26
https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/examples/firefox/lib/main.js#L101-L108
34,676
deitch/smtp-tester
lib/index.js
buildEmail
function buildEmail(envelope, data) { return simpleParser(data) .then(function(parsedEmail) { const sender = envelope.mailFrom.address; const receivers = envelope.rcptTo .map(recipient => [ recipient.address, true ]) .reduce(tupleToObject, {}); const headers = [ ... parsedEmail.headers ] .map(readHeader) .reduce(tupleToObject, {}); const email = { sender, receivers, data, headers, body: parsedEmail.text, html: parsedEmail.html, attachments: parsedEmail.attachments }; return email; }); }
javascript
function buildEmail(envelope, data) { return simpleParser(data) .then(function(parsedEmail) { const sender = envelope.mailFrom.address; const receivers = envelope.rcptTo .map(recipient => [ recipient.address, true ]) .reduce(tupleToObject, {}); const headers = [ ... parsedEmail.headers ] .map(readHeader) .reduce(tupleToObject, {}); const email = { sender, receivers, data, headers, body: parsedEmail.text, html: parsedEmail.html, attachments: parsedEmail.attachments }; return email; }); }
[ "function", "buildEmail", "(", "envelope", ",", "data", ")", "{", "return", "simpleParser", "(", "data", ")", ".", "then", "(", "function", "(", "parsedEmail", ")", "{", "const", "sender", "=", "envelope", ".", "mailFrom", ".", "address", ";", "const", "...
Resolves to the email object handlers receive.
[ "Resolves", "to", "the", "email", "object", "handlers", "receive", "." ]
02a150809efda61127344d56a332780b8f830d18
https://github.com/deitch/smtp-tester/blob/02a150809efda61127344d56a332780b8f830d18/lib/index.js#L113-L137
34,677
hegemonic/catharsis
catharsis.js
prepareFrozenObject
function prepareFrozenObject(obj, expr, {jsdoc}) { Object.defineProperty(obj, 'jsdoc', { value: jsdoc === true ? jsdoc : false }); if (expr) { Object.defineProperty(obj, 'typeExpression', { value: expr }); } return Object.freeze(obj); }
javascript
function prepareFrozenObject(obj, expr, {jsdoc}) { Object.defineProperty(obj, 'jsdoc', { value: jsdoc === true ? jsdoc : false }); if (expr) { Object.defineProperty(obj, 'typeExpression', { value: expr }); } return Object.freeze(obj); }
[ "function", "prepareFrozenObject", "(", "obj", ",", "expr", ",", "{", "jsdoc", "}", ")", "{", "Object", ".", "defineProperty", "(", "obj", ",", "'jsdoc'", ",", "{", "value", ":", "jsdoc", "===", "true", "?", "jsdoc", ":", "false", "}", ")", ";", "if"...
Add non-enumerable properties to a result object, then freeze it.
[ "Add", "non", "-", "enumerable", "properties", "to", "a", "result", "object", "then", "freeze", "it", "." ]
b4a29feee5bbeffa512eaf997f8e5480c0d2476f
https://github.com/hegemonic/catharsis/blob/b4a29feee5bbeffa512eaf997f8e5480c0d2476f/catharsis.js#L67-L79
34,678
lhkbob/eve-swagger-js
dist/util/type-generator/exportable-type.js
isSchema
function isSchema(blob) { // A schema will have one of these return blob.properties !== undefined || blob.enum !== undefined || blob.items !== undefined || blob.type !== undefined; }
javascript
function isSchema(blob) { // A schema will have one of these return blob.properties !== undefined || blob.enum !== undefined || blob.items !== undefined || blob.type !== undefined; }
[ "function", "isSchema", "(", "blob", ")", "{", "// A schema will have one of these", "return", "blob", ".", "properties", "!==", "undefined", "||", "blob", ".", "enum", "!==", "undefined", "||", "blob", ".", "items", "!==", "undefined", "||", "blob", ".", "typ...
The official swagger type spec makes it a little bit of a pain to work with the wrappers around type definitions.
[ "The", "official", "swagger", "type", "spec", "makes", "it", "a", "little", "bit", "of", "a", "pain", "to", "work", "with", "the", "wrappers", "around", "type", "definitions", "." ]
1353126546b988dd4811fc4256c94f4d96f26c37
https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/exportable-type.js#L876-L880
34,679
groupon/nlm
lib/git/ensure-tag.js
ensureTag
function ensureTag(cwd, tag) { if (tag === 'v0.0.0') { // There is no such thing (most likely) return null; } const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag); try { return fs.readFileSync(tagFile); } catch (error) { if (error.code !== 'ENOENT') { throw error; } return fetchTag(cwd, tag); } }
javascript
function ensureTag(cwd, tag) { if (tag === 'v0.0.0') { // There is no such thing (most likely) return null; } const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag); try { return fs.readFileSync(tagFile); } catch (error) { if (error.code !== 'ENOENT') { throw error; } return fetchTag(cwd, tag); } }
[ "function", "ensureTag", "(", "cwd", ",", "tag", ")", "{", "if", "(", "tag", "===", "'v0.0.0'", ")", "{", "// There is no such thing (most likely)", "return", "null", ";", "}", "const", "tagFile", "=", "path", ".", "join", "(", "cwd", ",", "'.git'", ",", ...
Ensure that a tag was fetched from the remote DotCI only fetches the ref that is currently being built. We need the last version tag to determine the changes. This checks if a tag exists locally. If it doesn't, it will fetch the tag from `origin`.
[ "Ensure", "that", "a", "tag", "was", "fetched", "from", "the", "remote" ]
f9bf02954b5d27b83d26c37a07312d922843b892
https://github.com/groupon/nlm/blob/f9bf02954b5d27b83d26c37a07312d922843b892/lib/git/ensure-tag.js#L52-L67
34,680
reklatsmasters/saslprep
generate-code-points.js
traverse
function traverse(bits, src) { for (const code of src.keys()) { bits.set(code, true); } const buffer = bits.toBuffer(); return Buffer.concat([createSize(buffer), buffer]); }
javascript
function traverse(bits, src) { for (const code of src.keys()) { bits.set(code, true); } const buffer = bits.toBuffer(); return Buffer.concat([createSize(buffer), buffer]); }
[ "function", "traverse", "(", "bits", ",", "src", ")", "{", "for", "(", "const", "code", "of", "src", ".", "keys", "(", ")", ")", "{", "bits", ".", "set", "(", "code", ",", "true", ")", ";", "}", "const", "buffer", "=", "bits", ".", "toBuffer", ...
Iterare over code points and convert it into an buffer. @param {bitfield} bits @param {Array} src @returns {Buffer}
[ "Iterare", "over", "code", "points", "and", "convert", "it", "into", "an", "buffer", "." ]
4ad8884b461a6a8e496d6e648ad5da0a1b43cb42
https://github.com/reklatsmasters/saslprep/blob/4ad8884b461a6a8e496d6e648ad5da0a1b43cb42/generate-code-points.js#L20-L27
34,681
pubfood/pubfood
src/pubfood.js
function(pfo) { var bidProviders = pfo.getBidProviders(); // check for core api method calls for (var apiMethod in pfo.requiredApiCalls) { if (pfo.requiredApiCalls[apiMethod] === 0) { pfo.configErrors.push('"' + apiMethod + '" was not called'); } } // validate through all the slots bid provider var slots = pfo.getSlots(); for (var i = 0; i < slots.length; i++) { for (var k = 0; k < slots[i].bidProviders.length; k++) { var providerName = slots[i].bidProviders[k]; // make sure there's config for each bid provider if (!bidProviders[providerName]) { pfo.configErrors.push('No configuration found for bid provider "' + providerName + '"'); } } } return { hasError: pfo.configErrors.length > 0, details: pfo.configErrors }; }
javascript
function(pfo) { var bidProviders = pfo.getBidProviders(); // check for core api method calls for (var apiMethod in pfo.requiredApiCalls) { if (pfo.requiredApiCalls[apiMethod] === 0) { pfo.configErrors.push('"' + apiMethod + '" was not called'); } } // validate through all the slots bid provider var slots = pfo.getSlots(); for (var i = 0; i < slots.length; i++) { for (var k = 0; k < slots[i].bidProviders.length; k++) { var providerName = slots[i].bidProviders[k]; // make sure there's config for each bid provider if (!bidProviders[providerName]) { pfo.configErrors.push('No configuration found for bid provider "' + providerName + '"'); } } } return { hasError: pfo.configErrors.length > 0, details: pfo.configErrors }; }
[ "function", "(", "pfo", ")", "{", "var", "bidProviders", "=", "pfo", ".", "getBidProviders", "(", ")", ";", "// check for core api method calls", "for", "(", "var", "apiMethod", "in", "pfo", ".", "requiredApiCalls", ")", "{", "if", "(", "pfo", ".", "required...
validate the api configurations @param {object} pfo a the pubfood object @private @return {{hasError: boolean, details: string[]}}
[ "validate", "the", "api", "configurations" ]
be666e922d92f86fd1542e7c43f81126a9301771
https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/pubfood.js#L44-L70
34,682
pubfood/pubfood
src/model/slot.js
Slot
function Slot(name, elementId) { if (this.init_) { this.init_(); } this.name = name; this.elementId = elementId; this.bidProviders = []; this.sizes = []; }
javascript
function Slot(name, elementId) { if (this.init_) { this.init_(); } this.name = name; this.elementId = elementId; this.bidProviders = []; this.sizes = []; }
[ "function", "Slot", "(", "name", ",", "elementId", ")", "{", "if", "(", "this", ".", "init_", ")", "{", "this", ".", "init_", "(", ")", ";", "}", "this", ".", "name", "=", "name", ";", "this", ".", "elementId", "=", "elementId", ";", "this", ".",...
Slot contains a definition of a publisher ad unit. @class @param {string} name the slot name @param {string} elementId target DOM element id for the slot @augments PubfoodObject @memberof pubfood#model
[ "Slot", "contains", "a", "definition", "of", "a", "publisher", "ad", "unit", "." ]
be666e922d92f86fd1542e7c43f81126a9301771
https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/model/slot.js#L20-L28
34,683
strongloop/strong-mq
lib/adapters/stomp.js
encode
function encode(body) { // Handles 3 cases // - body is utf8 string // - body is instance of Buffer // - body is an object and its JSON representation is sent // Does not handle the case for streaming bodies. // Returns buffer. if (typeof(body) == 'string') { return [new Buffer(body, 'utf8')]; } else if (body instanceof Buffer) { return [body]; } else { var jsonBody = JSON.stringify(body); return [new Buffer(jsonBody, 'utf8'), 'application/json']; } }
javascript
function encode(body) { // Handles 3 cases // - body is utf8 string // - body is instance of Buffer // - body is an object and its JSON representation is sent // Does not handle the case for streaming bodies. // Returns buffer. if (typeof(body) == 'string') { return [new Buffer(body, 'utf8')]; } else if (body instanceof Buffer) { return [body]; } else { var jsonBody = JSON.stringify(body); return [new Buffer(jsonBody, 'utf8'), 'application/json']; } }
[ "function", "encode", "(", "body", ")", "{", "// Handles 3 cases", "// - body is utf8 string", "// - body is instance of Buffer", "// - body is an object and its JSON representation is sent", "// Does not handle the case for streaming bodies.", "// Returns buffer.", "if", "(", "typeof", ...
either encode msg as json, and return encoded msg and content-type value, or use string value and return null content-type @return [contentType, buffer] Note: implementation ripped out of node-amqp XXX should this be merged to STOMP? if so, could be optional, triggered only if body is not a string/buffer, and if header has no content-type.
[ "either", "encode", "msg", "as", "json", "and", "return", "encoded", "msg", "and", "content", "-", "type", "value", "or", "use", "string", "value", "and", "return", "null", "content", "-", "type" ]
f46709850ce218168a2b45e2006e5ae55cf8e01b
https://github.com/strongloop/strong-mq/blob/f46709850ce218168a2b45e2006e5ae55cf8e01b/lib/adapters/stomp.js#L191-L206
34,684
lhkbob/eve-swagger-js
dist/util/esi-api.js
buildSimpleExample
function buildSimpleExample(type, example) { // The values in schemaOrType refer to the type names of Swagger types if (type === 'string') { return typeof example === 'string' ? example : ''; } else if (type === 'integer' || type === 'float' || type === 'number') { return typeof example === 'number' ? example : 0; } else if (type === 'boolean') { return typeof example === 'boolean' ? example : false; } else if (type === 'array') { return Array.isArray(example) ? example : []; } else if (type === 'object') { return typeof example === 'object' ? example : {}; } else { return null; } }
javascript
function buildSimpleExample(type, example) { // The values in schemaOrType refer to the type names of Swagger types if (type === 'string') { return typeof example === 'string' ? example : ''; } else if (type === 'integer' || type === 'float' || type === 'number') { return typeof example === 'number' ? example : 0; } else if (type === 'boolean') { return typeof example === 'boolean' ? example : false; } else if (type === 'array') { return Array.isArray(example) ? example : []; } else if (type === 'object') { return typeof example === 'object' ? example : {}; } else { return null; } }
[ "function", "buildSimpleExample", "(", "type", ",", "example", ")", "{", "// The values in schemaOrType refer to the type names of Swagger types", "if", "(", "type", "===", "'string'", ")", "{", "return", "typeof", "example", "===", "'string'", "?", "example", ":", "'...
Implementation functions for constructing and validating dynamic objects with the types defined in the spec.
[ "Implementation", "functions", "for", "constructing", "and", "validating", "dynamic", "objects", "with", "the", "types", "defined", "in", "the", "spec", "." ]
1353126546b988dd4811fc4256c94f4d96f26c37
https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/esi-api.js#L19-L39
34,685
lhkbob/eve-swagger-js
dist/util/type-generator/get-type-name.js
getTypeName
function getTypeName(namespace, type) { let namespaceName = namespace.fullName; let finalName; for (let title of type.titles) { let name = titleToTypeName(namespaceName, title); if (finalName) { if (name[1]) { // An explicit type name, so make sure it isn't masking anything if (finalName[1] && name[0] !== finalName[0]) { // Previous explicit name from another title is different throw new Error(title + '\'s override to ' + name[0] + ' would shadow explicit name of ' + finalName[0]); } // Otherwise take this name since it either is the same, or overrides // a non-explicit name finalName = name; } else if (!finalName[1] && name[0].length < finalName[0].length) { // Take the shorter of the generated names finalName = name; } } else { // First valid name finalName = name; } } if (finalName) { return finalName; } else { throw new Error('Unable to generate typename for ' + type.titles[0]); } }
javascript
function getTypeName(namespace, type) { let namespaceName = namespace.fullName; let finalName; for (let title of type.titles) { let name = titleToTypeName(namespaceName, title); if (finalName) { if (name[1]) { // An explicit type name, so make sure it isn't masking anything if (finalName[1] && name[0] !== finalName[0]) { // Previous explicit name from another title is different throw new Error(title + '\'s override to ' + name[0] + ' would shadow explicit name of ' + finalName[0]); } // Otherwise take this name since it either is the same, or overrides // a non-explicit name finalName = name; } else if (!finalName[1] && name[0].length < finalName[0].length) { // Take the shorter of the generated names finalName = name; } } else { // First valid name finalName = name; } } if (finalName) { return finalName; } else { throw new Error('Unable to generate typename for ' + type.titles[0]); } }
[ "function", "getTypeName", "(", "namespace", ",", "type", ")", "{", "let", "namespaceName", "=", "namespace", ".", "fullName", ";", "let", "finalName", ";", "for", "(", "let", "title", "of", "type", ".", "titles", ")", "{", "let", "name", "=", "titleToTy...
No typings associated
[ "No", "typings", "associated" ]
1353126546b988dd4811fc4256c94f4d96f26c37
https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/get-type-name.js#L5-L38
34,686
reklatsmasters/saslprep
lib/memory-code-points.js
read
function read() { const size = memory.readUInt32BE(offset); offset += 4; const codepoints = memory.slice(offset, offset + size); offset += size; return bitfield({ buffer: codepoints }); }
javascript
function read() { const size = memory.readUInt32BE(offset); offset += 4; const codepoints = memory.slice(offset, offset + size); offset += size; return bitfield({ buffer: codepoints }); }
[ "function", "read", "(", ")", "{", "const", "size", "=", "memory", ".", "readUInt32BE", "(", "offset", ")", ";", "offset", "+=", "4", ";", "const", "codepoints", "=", "memory", ".", "slice", "(", "offset", ",", "offset", "+", "size", ")", ";", "offse...
Loads each code points sequence from buffer. @returns {bitfield}
[ "Loads", "each", "code", "points", "sequence", "from", "buffer", "." ]
4ad8884b461a6a8e496d6e648ad5da0a1b43cb42
https://github.com/reklatsmasters/saslprep/blob/4ad8884b461a6a8e496d6e648ad5da0a1b43cb42/lib/memory-code-points.js#L15-L23
34,687
mbanting/metalsmith-prismic
lib/index.js
processRetrievedContent
function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) { if (content.results != null && content.results.length > 0) { var queryMetadata = filePrismicMetadata[queryKey]; for (var i = 0; i < content.results.length; i++) { var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx); filePrismicMetadata[queryKey].results.push(result); } } }
javascript
function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) { if (content.results != null && content.results.length > 0) { var queryMetadata = filePrismicMetadata[queryKey]; for (var i = 0; i < content.results.length; i++) { var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx); filePrismicMetadata[queryKey].results.push(result); } } }
[ "function", "processRetrievedContent", "(", "content", ",", "filePrismicMetadata", ",", "queryKey", ",", "ctx", ")", "{", "if", "(", "content", ".", "results", "!=", "null", "&&", "content", ".", "results", ".", "length", ">", "0", ")", "{", "var", "queryM...
processes the retrieved content and adds it to the metadata
[ "processes", "the", "retrieved", "content", "and", "adds", "it", "to", "the", "metadata" ]
f5b55568f68ee11975b36ddeaee3e55f9c8e4740
https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L192-L200
34,688
mbanting/metalsmith-prismic
lib/index.js
processRetrievedDocument
function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) { // add the complete result except for the data fragments var result = _.omit(document, 'fragments'); result.data = {}; // process the data fragments, invoking helpers to make the data more usable if (document.fragments != null && Object.keys(document.fragments).length > 0) { for (var fragmentFullName in document.fragments) { // strip the document type from the fragment name var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1); var fragment = document.fragments[fragmentFullName]; result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]); } } return result; }
javascript
function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) { // add the complete result except for the data fragments var result = _.omit(document, 'fragments'); result.data = {}; // process the data fragments, invoking helpers to make the data more usable if (document.fragments != null && Object.keys(document.fragments).length > 0) { for (var fragmentFullName in document.fragments) { // strip the document type from the fragment name var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1); var fragment = document.fragments[fragmentFullName]; result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]); } } return result; }
[ "function", "processRetrievedDocument", "(", "document", ",", "filePrismicMetadata", ",", "queryKey", ",", "ctx", ")", "{", "// add the complete result except for the data fragments", "var", "result", "=", "_", ".", "omit", "(", "document", ",", "'fragments'", ")", ";...
processes and return single retrieved document
[ "processes", "and", "return", "single", "retrieved", "document" ]
f5b55568f68ee11975b36ddeaee3e55f9c8e4740
https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L203-L221
34,689
mbanting/metalsmith-prismic
lib/index.js
generateCollectionFiles
function generateCollectionFiles(fileName, collectionQuery, callback, ctx) { if (collectionQuery != null) { var file = files[fileName]; var newFiles = {}; var fileExtension = file.prismic[collectionQuery].collection.fileExtension; var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:""; // for every result in the collection query for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) { // clone the file and replace the original collectionQuery results with the current result var newFile = clone(file); newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]]; // add the filename to the ctx object to make it available for use in the linkResolver function ctx.path = fileName; // use the linkResolver to generate the filename removing the leading slash if present newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile; } delete files[fileName]; _.extend(files, newFiles); } callback(); }
javascript
function generateCollectionFiles(fileName, collectionQuery, callback, ctx) { if (collectionQuery != null) { var file = files[fileName]; var newFiles = {}; var fileExtension = file.prismic[collectionQuery].collection.fileExtension; var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:""; // for every result in the collection query for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) { // clone the file and replace the original collectionQuery results with the current result var newFile = clone(file); newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]]; // add the filename to the ctx object to make it available for use in the linkResolver function ctx.path = fileName; // use the linkResolver to generate the filename removing the leading slash if present newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile; } delete files[fileName]; _.extend(files, newFiles); } callback(); }
[ "function", "generateCollectionFiles", "(", "fileName", ",", "collectionQuery", ",", "callback", ",", "ctx", ")", "{", "if", "(", "collectionQuery", "!=", "null", ")", "{", "var", "file", "=", "files", "[", "fileName", "]", ";", "var", "newFiles", "=", "{"...
if any of the queries are designated the collection query, then generate a file for each of the results
[ "if", "any", "of", "the", "queries", "are", "designated", "the", "collection", "query", "then", "generate", "a", "file", "for", "each", "of", "the", "results" ]
f5b55568f68ee11975b36ddeaee3e55f9c8e4740
https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L310-L335
34,690
strongloop/strong-mq
lib/adapters/native/broker.js
_final
function _final() { var self = this; cluster.removeListener('fork', self._onFork); cluster.removeListener('disconnect', self._onDisconnect); }
javascript
function _final() { var self = this; cluster.removeListener('fork', self._onFork); cluster.removeListener('disconnect', self._onDisconnect); }
[ "function", "_final", "(", ")", "{", "var", "self", "=", "this", ";", "cluster", ".", "removeListener", "(", "'fork'", ",", "self", ".", "_onFork", ")", ";", "cluster", ".", "removeListener", "(", "'disconnect'", ",", "self", ".", "_onDisconnect", ")", "...
Not normally called, but we might need something like it in tests to reset state back to initial.
[ "Not", "normally", "called", "but", "we", "might", "need", "something", "like", "it", "in", "tests", "to", "reset", "state", "back", "to", "initial", "." ]
f46709850ce218168a2b45e2006e5ae55cf8e01b
https://github.com/strongloop/strong-mq/blob/f46709850ce218168a2b45e2006e5ae55cf8e01b/lib/adapters/native/broker.js#L74-L79
34,691
Nicklason/node-bptf-listings
index.js
Listings
function Listings (options) { options = options || {}; EventEmitter.call(this); this.accessToken = options.accessToken; this.steamid64 = options.steamid64; this.waitTime = options.waitTime || 1000; this.cap = -1; this.promotes = -1; this.listings = []; this.actions = { create: [], remove: [] }; this.items = options.items || new Items({ apiKey: options.apiKey }); this.ready = false; }
javascript
function Listings (options) { options = options || {}; EventEmitter.call(this); this.accessToken = options.accessToken; this.steamid64 = options.steamid64; this.waitTime = options.waitTime || 1000; this.cap = -1; this.promotes = -1; this.listings = []; this.actions = { create: [], remove: [] }; this.items = options.items || new Items({ apiKey: options.apiKey }); this.ready = false; }
[ "function", "Listings", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "accessToken", "=", "options", ".", "accessToken", ";", "this", ".", "steamid64", "=", "o...
Creates a new instance of bptf-listings @class @param {object} options Optional settings
[ "Creates", "a", "new", "instance", "of", "bptf", "-", "listings" ]
8ed38a4e2457603ec2941991e8af924531e8389b
https://github.com/Nicklason/node-bptf-listings/blob/8ed38a4e2457603ec2941991e8af924531e8389b/index.js#L19-L41
34,692
polygonplanet/Chiffon
chiffon.js
function() { switch (this.type) { case _Numeric: case _String: case _RegularExpression: case _Boolean: case _Null: return this.parseLiteral(); case _Identifier: return this.parseIdentifier(); case _Keyword: return this.parsePrimaryKeywordExpression(); case _Punctuator: return this.parsePrimaryPunctuatorExpression(); case _Template: return this.parseTemplateLiteral(); default: this.unexpected(); } }
javascript
function() { switch (this.type) { case _Numeric: case _String: case _RegularExpression: case _Boolean: case _Null: return this.parseLiteral(); case _Identifier: return this.parseIdentifier(); case _Keyword: return this.parsePrimaryKeywordExpression(); case _Punctuator: return this.parsePrimaryPunctuatorExpression(); case _Template: return this.parseTemplateLiteral(); default: this.unexpected(); } }
[ "function", "(", ")", "{", "switch", "(", "this", ".", "type", ")", "{", "case", "_Numeric", ":", "case", "_String", ":", "case", "_RegularExpression", ":", "case", "_Boolean", ":", "case", "_Null", ":", "return", "this", ".", "parseLiteral", "(", ")", ...
ECMA-262 12.2 Primary Expression
[ "ECMA", "-", "262", "12", ".", "2", "Primary", "Expression" ]
4adb7066aff6b58b60b1b72995a216b334421b84
https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L1267-L1286
34,693
polygonplanet/Chiffon
chiffon.js
function(allowIn) { var node = this.startNode(_SequenceExpression); var expr = this.parseAssignmentExpression(allowIn); if (this.value !== ',') { return expr; } var exprs = [expr]; do { this.next(); exprs[exprs.length] = this.parseAssignmentExpression(allowIn); } while (this.value === ','); node.expressions = exprs; return this.finishNode(node); }
javascript
function(allowIn) { var node = this.startNode(_SequenceExpression); var expr = this.parseAssignmentExpression(allowIn); if (this.value !== ',') { return expr; } var exprs = [expr]; do { this.next(); exprs[exprs.length] = this.parseAssignmentExpression(allowIn); } while (this.value === ','); node.expressions = exprs; return this.finishNode(node); }
[ "function", "(", "allowIn", ")", "{", "var", "node", "=", "this", ".", "startNode", "(", "_SequenceExpression", ")", ";", "var", "expr", "=", "this", ".", "parseAssignmentExpression", "(", "allowIn", ")", ";", "if", "(", "this", ".", "value", "!==", "','...
ECMA-262 A.2 Expressions
[ "ECMA", "-", "262", "A", ".", "2", "Expressions" ]
4adb7066aff6b58b60b1b72995a216b334421b84
https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L1520-L1536
34,694
polygonplanet/Chiffon
chiffon.js
function() { var node = this.startNode(_IfStatement); this.expect('if'); this.expect('('); var expr = this.parseExpression(true); this.expect(')'); var consequent = this.parseStatement(); var alternate = null; if (this.value === 'else') { this.next(); alternate = this.parseStatement(); } node.test = expr; node.consequent = consequent; node.alternate = alternate; return this.finishNode(node); }
javascript
function() { var node = this.startNode(_IfStatement); this.expect('if'); this.expect('('); var expr = this.parseExpression(true); this.expect(')'); var consequent = this.parseStatement(); var alternate = null; if (this.value === 'else') { this.next(); alternate = this.parseStatement(); } node.test = expr; node.consequent = consequent; node.alternate = alternate; return this.finishNode(node); }
[ "function", "(", ")", "{", "var", "node", "=", "this", ".", "startNode", "(", "_IfStatement", ")", ";", "this", ".", "expect", "(", "'if'", ")", ";", "this", ".", "expect", "(", "'('", ")", ";", "var", "expr", "=", "this", ".", "parseExpression", "...
ECMA-262 13 Statements and Declarations
[ "ECMA", "-", "262", "13", "Statements", "and", "Declarations" ]
4adb7066aff6b58b60b1b72995a216b334421b84
https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L2198-L2217
34,695
lhkbob/eve-swagger-js
dist/src/internal/names.js
getNames
function getNames(agent, category, ids) { return _getNames(agent, category, ids).then(array => { let map = new Map(); for (let n of array) { map.set(n.id, n.name); } return map; }); }
javascript
function getNames(agent, category, ids) { return _getNames(agent, category, ids).then(array => { let map = new Map(); for (let n of array) { map.set(n.id, n.name); } return map; }); }
[ "function", "getNames", "(", "agent", ",", "category", ",", "ids", ")", "{", "return", "_getNames", "(", "agent", ",", "category", ",", "ids", ")", ".", "then", "(", "array", "=>", "{", "let", "map", "=", "new", "Map", "(", ")", ";", "for", "(", ...
Look up the names of a set of ids, restricted to a particular name category. This utility function automatically splits large arrays of ids into lists of 500 elements and then recombines the results. It also maps the response data from the internal ESI representation into a more useful Map from id to name. @param agent The agent making requests @param category The category of names to look up @param ids The list of ids to resolve, should not contain duplicates @returns Promise resolving to a Map from id to name
[ "Look", "up", "the", "names", "of", "a", "set", "of", "ids", "restricted", "to", "a", "particular", "name", "category", ".", "This", "utility", "function", "automatically", "splits", "large", "arrays", "of", "ids", "into", "lists", "of", "500", "elements", ...
1353126546b988dd4811fc4256c94f4d96f26c37
https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/src/internal/names.js#L14-L22
34,696
nathanhammond/ember-route-alias
addon/initializers/route-alias.js
createAlias
function createAlias() { Ember.RouterDSL.prototype.alias = function(aliasRoute, aliasPath, aliasTarget) { Ember.assert('You must create a route prior to creating an alias.', this.handlers || this.intercepting); Ember.assert('The alias target must exist before attempting to alias it.', this.handlers[aliasTarget]); // Grab a reference to the arguments passed in for the original route. let [options, callback] = this.handlers[aliasTarget]; options.path = aliasPath; this.intercepting.push({ aliasRoute, aliasTarget }); this.route(aliasRoute, options, callback); }; }
javascript
function createAlias() { Ember.RouterDSL.prototype.alias = function(aliasRoute, aliasPath, aliasTarget) { Ember.assert('You must create a route prior to creating an alias.', this.handlers || this.intercepting); Ember.assert('The alias target must exist before attempting to alias it.', this.handlers[aliasTarget]); // Grab a reference to the arguments passed in for the original route. let [options, callback] = this.handlers[aliasTarget]; options.path = aliasPath; this.intercepting.push({ aliasRoute, aliasTarget }); this.route(aliasRoute, options, callback); }; }
[ "function", "createAlias", "(", ")", "{", "Ember", ".", "RouterDSL", ".", "prototype", ".", "alias", "=", "function", "(", "aliasRoute", ",", "aliasPath", ",", "aliasTarget", ")", "{", "Ember", ".", "assert", "(", "'You must create a route prior to creating an ali...
Sets up our magic alias function.
[ "Sets", "up", "our", "magic", "alias", "function", "." ]
e1f39cd775662b6e5dbae1654b8584902f8f44e2
https://github.com/nathanhammond/ember-route-alias/blob/e1f39cd775662b6e5dbae1654b8584902f8f44e2/addon/initializers/route-alias.js#L16-L29
34,697
nathanhammond/ember-route-alias
addon/initializers/route-alias.js
patchRoute
function patchRoute(lookup) { // Save off the original method in scope of the prototype modifications. let originalRouteMethod = Ember.RouterDSL.prototype.route; // We need to do a few things before and after the original route function. Ember.RouterDSL.prototype.route = function(name, options, callback) { Ember.assert('You may not include a "." in your route name.', !~name.indexOf('.')); // Method signature identification from the original method. if (arguments.length === 2 && typeof options === 'function') { callback = options; options = {}; } if (arguments.length === 1) { options = {}; } // Save off a reference to the original arguments in a reachable scope. // This is so later calls to `alias` have something to find. if (!this.handlers) { this.handlers = {}; } this.handlers[name] = [ options, callback ]; // For storing the root of the aliased route. if (!this.intercepting) { this.intercepting = []; } // So, we're "recursing" through a structure, but we can sneak in by wrapping the invoked function. if (this.intercepting.length) { // Make the callback modify the DSL generated for nested routes. // Necessary so they can register themselves. // Propogate the original interception information forward. var currentIntercepting = this.intercepting[this.intercepting.length - 1]; let interceptingCallback = function() { this.intercepting = [currentIntercepting]; callback.call(this); }; // Figure out how many routes we created. let originalLength = [].concat.apply([], this.matches).length; originalRouteMethod.call(this, name, options, callback ? interceptingCallback : undefined); let newMatches = [].concat.apply([], this.matches); let newLength = newMatches.length; // Add each of them to the lookup. for (let i = originalLength; i < newLength; i += 3) { let intermediate = newMatches[i + 1].split('.'); let qualifiedAliasRoute = intermediate.join('/'); let qualifiedTargetRoute = qualifiedAliasRoute.replace(currentIntercepting.aliasRoute, currentIntercepting.aliasTarget); if (qualifiedAliasRoute !== qualifiedTargetRoute) { lookup[qualifiedAliasRoute] = qualifiedTargetRoute; } else { // For index routes we need to try again with the base intercepting object. let isIndex = intermediate.pop().indexOf('index') === 0; qualifiedTargetRoute = qualifiedAliasRoute.replace(this.intercepting[0].aliasRoute, this.intercepting[0].aliasTarget); if (isIndex && qualifiedAliasRoute !== qualifiedTargetRoute) { lookup[qualifiedAliasRoute] = qualifiedTargetRoute; } } } } else { originalRouteMethod.call(this, name, options, callback); } }; }
javascript
function patchRoute(lookup) { // Save off the original method in scope of the prototype modifications. let originalRouteMethod = Ember.RouterDSL.prototype.route; // We need to do a few things before and after the original route function. Ember.RouterDSL.prototype.route = function(name, options, callback) { Ember.assert('You may not include a "." in your route name.', !~name.indexOf('.')); // Method signature identification from the original method. if (arguments.length === 2 && typeof options === 'function') { callback = options; options = {}; } if (arguments.length === 1) { options = {}; } // Save off a reference to the original arguments in a reachable scope. // This is so later calls to `alias` have something to find. if (!this.handlers) { this.handlers = {}; } this.handlers[name] = [ options, callback ]; // For storing the root of the aliased route. if (!this.intercepting) { this.intercepting = []; } // So, we're "recursing" through a structure, but we can sneak in by wrapping the invoked function. if (this.intercepting.length) { // Make the callback modify the DSL generated for nested routes. // Necessary so they can register themselves. // Propogate the original interception information forward. var currentIntercepting = this.intercepting[this.intercepting.length - 1]; let interceptingCallback = function() { this.intercepting = [currentIntercepting]; callback.call(this); }; // Figure out how many routes we created. let originalLength = [].concat.apply([], this.matches).length; originalRouteMethod.call(this, name, options, callback ? interceptingCallback : undefined); let newMatches = [].concat.apply([], this.matches); let newLength = newMatches.length; // Add each of them to the lookup. for (let i = originalLength; i < newLength; i += 3) { let intermediate = newMatches[i + 1].split('.'); let qualifiedAliasRoute = intermediate.join('/'); let qualifiedTargetRoute = qualifiedAliasRoute.replace(currentIntercepting.aliasRoute, currentIntercepting.aliasTarget); if (qualifiedAliasRoute !== qualifiedTargetRoute) { lookup[qualifiedAliasRoute] = qualifiedTargetRoute; } else { // For index routes we need to try again with the base intercepting object. let isIndex = intermediate.pop().indexOf('index') === 0; qualifiedTargetRoute = qualifiedAliasRoute.replace(this.intercepting[0].aliasRoute, this.intercepting[0].aliasTarget); if (isIndex && qualifiedAliasRoute !== qualifiedTargetRoute) { lookup[qualifiedAliasRoute] = qualifiedTargetRoute; } } } } else { originalRouteMethod.call(this, name, options, callback); } }; }
[ "function", "patchRoute", "(", "lookup", ")", "{", "// Save off the original method in scope of the prototype modifications.", "let", "originalRouteMethod", "=", "Ember", ".", "RouterDSL", ".", "prototype", ".", "route", ";", "// We need to do a few things before and after the or...
Patches the RouterDSL route function to work with aliases.
[ "Patches", "the", "RouterDSL", "route", "function", "to", "work", "with", "aliases", "." ]
e1f39cd775662b6e5dbae1654b8584902f8f44e2
https://github.com/nathanhammond/ember-route-alias/blob/e1f39cd775662b6e5dbae1654b8584902f8f44e2/addon/initializers/route-alias.js#L32-L98
34,698
ethjs/ethjs-account
src/index.js
getAddress
function getAddress(addressInput) { var address = addressInput; // eslint-disable-line var result = null; // eslint-disable-line if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); } // Missing the 0x prefix if (address.substring(0, 2) !== '0x' && address.substring(0, 2) !== 'XE') { address = `0x${address}`; } if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { result = getChecksumAddress(address); // It is a checksummed address with a bad checksum if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { throw new Error('[ethjs-account] invalid address checksum'); } // Maybe ICAP? (we only support direct mode) } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..'); /* // It is an ICAP address with a bad checksum if (address.substring(2, 4) !== ibanChecksum(address)) { throw new Error('invalid address icap checksum'); } result = (new BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = '0' + result; } result = getChecksumAddress('0x' + result); */ } else { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); } return result; }
javascript
function getAddress(addressInput) { var address = addressInput; // eslint-disable-line var result = null; // eslint-disable-line if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); } // Missing the 0x prefix if (address.substring(0, 2) !== '0x' && address.substring(0, 2) !== 'XE') { address = `0x${address}`; } if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { result = getChecksumAddress(address); // It is a checksummed address with a bad checksum if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { throw new Error('[ethjs-account] invalid address checksum'); } // Maybe ICAP? (we only support direct mode) } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..'); /* // It is an ICAP address with a bad checksum if (address.substring(2, 4) !== ibanChecksum(address)) { throw new Error('invalid address icap checksum'); } result = (new BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = '0' + result; } result = getChecksumAddress('0x' + result); */ } else { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); } return result; }
[ "function", "getAddress", "(", "addressInput", ")", "{", "var", "address", "=", "addressInput", ";", "// eslint-disable-line", "var", "result", "=", "null", ";", "// eslint-disable-line", "if", "(", "typeof", "(", "address", ")", "!==", "'string'", ")", "{", "...
Get the address from a public key @method getAddress @param {String} addressInput @returns {String} output the string is a hex string
[ "Get", "the", "address", "from", "a", "public", "key" ]
7cbdd667a8c21c8546436650d17bcc9735d7d6bb
https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L25-L62
34,699
ethjs/ethjs-account
src/index.js
privateToPublic
function privateToPublic(privateKey) { if (typeof privateKey !== 'string') { throw new Error(`[ethjs-account] private key must be type String, got ${typeof(privateKey)}`); } if (!privateKey.match(/^(0x)?[0-9a-fA-F]{64}$/)) { throw new Error('[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.'); } const privateKeyBuffer = new Buffer(stripHexPrefix(privateKey), 'hex'); return (new Buffer(secp256k1.keyFromPrivate(privateKeyBuffer).getPublic(false, 'hex'), 'hex')).slice(1); }
javascript
function privateToPublic(privateKey) { if (typeof privateKey !== 'string') { throw new Error(`[ethjs-account] private key must be type String, got ${typeof(privateKey)}`); } if (!privateKey.match(/^(0x)?[0-9a-fA-F]{64}$/)) { throw new Error('[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.'); } const privateKeyBuffer = new Buffer(stripHexPrefix(privateKey), 'hex'); return (new Buffer(secp256k1.keyFromPrivate(privateKeyBuffer).getPublic(false, 'hex'), 'hex')).slice(1); }
[ "function", "privateToPublic", "(", "privateKey", ")", "{", "if", "(", "typeof", "privateKey", "!==", "'string'", ")", "{", "throw", "new", "Error", "(", "`", "${", "typeof", "(", "privateKey", ")", "}", "`", ")", ";", "}", "if", "(", "!", "privateKey"...
Returns the public key for this private key. @method privateToPublic @param {String} privateKey a valid private key hex @returns {Object} publicKey the sepk 160 byte public key for this private key
[ "Returns", "the", "public", "key", "for", "this", "private", "key", "." ]
7cbdd667a8c21c8546436650d17bcc9735d7d6bb
https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L72-L78