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
47,600
twolfson/value-mapper
lib/value-mapper.js
function (val) { // Keep track of aliases used var aliasesUsed = [], aliasesNotFound = [], that = this; // Map the value through the middlewares var middlewares = this.middlewares; middlewares.forEach(function mapMiddlewareValue (fn) { // Process the value through middleware var valObj = fn.call(that, val); // Save the results val = valObj.value; aliasesUsed.push.apply(aliasesUsed, valObj.aliasesUsed); aliasesNotFound.push.apply(aliasesNotFound, valObj.aliasesNotFound); }); // Return the value return { value: val, aliasesUsed: aliasesUsed, aliasesNotFound: aliasesNotFound }; }
javascript
function (val) { // Keep track of aliases used var aliasesUsed = [], aliasesNotFound = [], that = this; // Map the value through the middlewares var middlewares = this.middlewares; middlewares.forEach(function mapMiddlewareValue (fn) { // Process the value through middleware var valObj = fn.call(that, val); // Save the results val = valObj.value; aliasesUsed.push.apply(aliasesUsed, valObj.aliasesUsed); aliasesNotFound.push.apply(aliasesNotFound, valObj.aliasesNotFound); }); // Return the value return { value: val, aliasesUsed: aliasesUsed, aliasesNotFound: aliasesNotFound }; }
[ "function", "(", "val", ")", "{", "// Keep track of aliases used", "var", "aliasesUsed", "=", "[", "]", ",", "aliasesNotFound", "=", "[", "]", ",", "that", "=", "this", ";", "// Map the value through the middlewares", "var", "middlewares", "=", "this", ".", "middlewares", ";", "middlewares", ".", "forEach", "(", "function", "mapMiddlewareValue", "(", "fn", ")", "{", "// Process the value through middleware", "var", "valObj", "=", "fn", ".", "call", "(", "that", ",", "val", ")", ";", "// Save the results", "val", "=", "valObj", ".", "value", ";", "aliasesUsed", ".", "push", ".", "apply", "(", "aliasesUsed", ",", "valObj", ".", "aliasesUsed", ")", ";", "aliasesNotFound", ".", "push", ".", "apply", "(", "aliasesNotFound", ",", "valObj", ".", "aliasesNotFound", ")", ";", "}", ")", ";", "// Return the value", "return", "{", "value", ":", "val", ",", "aliasesUsed", ":", "aliasesUsed", ",", "aliasesNotFound", ":", "aliasesNotFound", "}", ";", "}" ]
Resolve values of values via middleware
[ "Resolve", "values", "of", "values", "via", "middleware" ]
956cfa193e02b6c4ae0e607b14eea41a15b7331d
https://github.com/twolfson/value-mapper/blob/956cfa193e02b6c4ae0e607b14eea41a15b7331d/lib/value-mapper.js#L45-L69
47,601
twolfson/value-mapper
lib/value-mapper.js
function (key) { // Look up the normal value var val = this.input[key]; // Save the key for reference var _key = this.key; this.key = key; // Map our value through the middlewares val = this.process(val); // Restore the original key this.key = _key; // Return the value return val; }
javascript
function (key) { // Look up the normal value var val = this.input[key]; // Save the key for reference var _key = this.key; this.key = key; // Map our value through the middlewares val = this.process(val); // Restore the original key this.key = _key; // Return the value return val; }
[ "function", "(", "key", ")", "{", "// Look up the normal value", "var", "val", "=", "this", ".", "input", "[", "key", "]", ";", "// Save the key for reference", "var", "_key", "=", "this", ".", "key", ";", "this", ".", "key", "=", "key", ";", "// Map our value through the middlewares", "val", "=", "this", ".", "process", "(", "val", ")", ";", "// Restore the original key", "this", ".", "key", "=", "_key", ";", "// Return the value", "return", "val", ";", "}" ]
Resolve the value of a key @param {String} key Name to lookup value by @returns {Object} retObj Container for value and meta information @returns {Mixed} retObj.value Aliased, mapped, and flattened copy of `key` @returns {String[]} retObj.aliasesUsed Array of aliased keys used while looking up @returns {String[]} retObj.aliasesNotFound Array of aliased not found while looking up
[ "Resolve", "the", "value", "of", "a", "key" ]
956cfa193e02b6c4ae0e607b14eea41a15b7331d
https://github.com/twolfson/value-mapper/blob/956cfa193e02b6c4ae0e607b14eea41a15b7331d/lib/value-mapper.js#L79-L95
47,602
Illyism/markade
lib/render.js
render
function render(content) { var deferred = q.defer(); var blockType = "normal"; var lines = content.split("\n"); var blocks = {}; for (var i=0; i<lines.length; i++) { var line = lines[i]; if (line.substr(0,1) == "@") { blockType = line.substr(1).trim(); if (blockType === "end") blockType = "normal"; continue; } if (blocks[blockType]) blocks[blockType] += line + "\n"; else blocks[blockType] = line + "\n"; } for (var key in blocks) { if (blocks.hasOwnProperty(key)) { try { blocks[key] = metaMarked(blocks[key]); } catch(err) { return deferred.reject(new Error(err)); } } deferred.resolve(blocks); } return deferred.promise; }
javascript
function render(content) { var deferred = q.defer(); var blockType = "normal"; var lines = content.split("\n"); var blocks = {}; for (var i=0; i<lines.length; i++) { var line = lines[i]; if (line.substr(0,1) == "@") { blockType = line.substr(1).trim(); if (blockType === "end") blockType = "normal"; continue; } if (blocks[blockType]) blocks[blockType] += line + "\n"; else blocks[blockType] = line + "\n"; } for (var key in blocks) { if (blocks.hasOwnProperty(key)) { try { blocks[key] = metaMarked(blocks[key]); } catch(err) { return deferred.reject(new Error(err)); } } deferred.resolve(blocks); } return deferred.promise; }
[ "function", "render", "(", "content", ")", "{", "var", "deferred", "=", "q", ".", "defer", "(", ")", ";", "var", "blockType", "=", "\"normal\"", ";", "var", "lines", "=", "content", ".", "split", "(", "\"\\n\"", ")", ";", "var", "blocks", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "lines", ".", "length", ";", "i", "++", ")", "{", "var", "line", "=", "lines", "[", "i", "]", ";", "if", "(", "line", ".", "substr", "(", "0", ",", "1", ")", "==", "\"@\"", ")", "{", "blockType", "=", "line", ".", "substr", "(", "1", ")", ".", "trim", "(", ")", ";", "if", "(", "blockType", "===", "\"end\"", ")", "blockType", "=", "\"normal\"", ";", "continue", ";", "}", "if", "(", "blocks", "[", "blockType", "]", ")", "blocks", "[", "blockType", "]", "+=", "line", "+", "\"\\n\"", ";", "else", "blocks", "[", "blockType", "]", "=", "line", "+", "\"\\n\"", ";", "}", "for", "(", "var", "key", "in", "blocks", ")", "{", "if", "(", "blocks", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "try", "{", "blocks", "[", "key", "]", "=", "metaMarked", "(", "blocks", "[", "key", "]", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "deferred", ".", "reject", "(", "new", "Error", "(", "err", ")", ")", ";", "}", "}", "deferred", ".", "resolve", "(", "blocks", ")", ";", "}", "return", "deferred", ".", "promise", ";", "}" ]
Catch all the blocks encapsulated in blocks with `key` as key. and make an object based on this to be used in the templates. ``` @ key # Normal Markdown content @ end ```
[ "Catch", "all", "the", "blocks", "encapsulated", "in", "blocks", "with", "key", "as", "key", ".", "and", "make", "an", "object", "based", "on", "this", "to", "be", "used", "in", "the", "templates", "." ]
fa2a4b45084b468a8ed0eca9499ade65e2568052
https://github.com/Illyism/markade/blob/fa2a4b45084b468a8ed0eca9499ade65e2568052/lib/render.js#L41-L73
47,603
Illyism/markade
lib/render.js
splitInput
function splitInput(str) { if (str.slice(0, 3) !== '---') return; var matcher = /\n(\.{3}|-{3})/g; var metaEnd = matcher.exec(str); return metaEnd && [str.slice(0, metaEnd.index), str.slice(matcher.lastIndex)]; }
javascript
function splitInput(str) { if (str.slice(0, 3) !== '---') return; var matcher = /\n(\.{3}|-{3})/g; var metaEnd = matcher.exec(str); return metaEnd && [str.slice(0, metaEnd.index), str.slice(matcher.lastIndex)]; }
[ "function", "splitInput", "(", "str", ")", "{", "if", "(", "str", ".", "slice", "(", "0", ",", "3", ")", "!==", "'---'", ")", "return", ";", "var", "matcher", "=", "/", "\\n(\\.{3}|-{3})", "/", "g", ";", "var", "metaEnd", "=", "matcher", ".", "exec", "(", "str", ")", ";", "return", "metaEnd", "&&", "[", "str", ".", "slice", "(", "0", ",", "metaEnd", ".", "index", ")", ",", "str", ".", "slice", "(", "matcher", ".", "lastIndex", ")", "]", ";", "}" ]
Splits the given string into a meta section and a markdown section if a meta section is present, else returns null
[ "Splits", "the", "given", "string", "into", "a", "meta", "section", "and", "a", "markdown", "section", "if", "a", "meta", "section", "is", "present", "else", "returns", "null" ]
fa2a4b45084b468a8ed0eca9499ade65e2568052
https://github.com/Illyism/markade/blob/fa2a4b45084b468a8ed0eca9499ade65e2568052/lib/render.js#L101-L108
47,604
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function( range ) { range.collapsed = ( range.startContainer && range.endContainer && range.startContainer.equals( range.endContainer ) && range.startOffset == range.endOffset ); }
javascript
function( range ) { range.collapsed = ( range.startContainer && range.endContainer && range.startContainer.equals( range.endContainer ) && range.startOffset == range.endOffset ); }
[ "function", "(", "range", ")", "{", "range", ".", "collapsed", "=", "(", "range", ".", "startContainer", "&&", "range", ".", "endContainer", "&&", "range", ".", "startContainer", ".", "equals", "(", "range", ".", "endContainer", ")", "&&", "range", ".", "startOffset", "==", "range", ".", "endOffset", ")", ";", "}" ]
Updates the "collapsed" property for the given range object.
[ "Updates", "the", "collapsed", "property", "for", "the", "given", "range", "object", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L94-L101
47,605
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function( mergeThen ) { var docFrag = new CKEDITOR.dom.documentFragment( this.document ); if ( !this.collapsed ) execContentsAction( this, 1, docFrag, mergeThen ); return docFrag; }
javascript
function( mergeThen ) { var docFrag = new CKEDITOR.dom.documentFragment( this.document ); if ( !this.collapsed ) execContentsAction( this, 1, docFrag, mergeThen ); return docFrag; }
[ "function", "(", "mergeThen", ")", "{", "var", "docFrag", "=", "new", "CKEDITOR", ".", "dom", ".", "documentFragment", "(", "this", ".", "document", ")", ";", "if", "(", "!", "this", ".", "collapsed", ")", "execContentsAction", "(", "this", ",", "1", ",", "docFrag", ",", "mergeThen", ")", ";", "return", "docFrag", ";", "}" ]
The content nodes of the range are cloned and added to a document fragment, meanwhile they're removed permanently from the DOM tree. @param {Boolean} [mergeThen] Merge any splitted elements result in DOM true due to partial selection.
[ "The", "content", "nodes", "of", "the", "range", "are", "cloned", "and", "added", "to", "a", "document", "fragment", "meanwhile", "they", "re", "removed", "permanently", "from", "the", "DOM", "tree", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L466-L474
47,606
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function( normalized ) { var startContainer = this.startContainer, endContainer = this.endContainer; var startOffset = this.startOffset, endOffset = this.endOffset; var collapsed = this.collapsed; var child, previous; // If there is no range then get out of here. // It happens on initial load in Safari #962 and if the editor it's // hidden also in Firefox if ( !startContainer || !endContainer ) return { start : 0, end : 0 }; if ( normalized ) { // Find out if the start is pointing to a text node that will // be normalized. if ( startContainer.type == CKEDITOR.NODE_ELEMENT ) { child = startContainer.getChild( startOffset ); // In this case, move the start information to that text // node. if ( child && child.type == CKEDITOR.NODE_TEXT && startOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { startContainer = child; startOffset = 0; } // Get the normalized offset. if ( child && child.type == CKEDITOR.NODE_ELEMENT ) startOffset = child.getIndex( 1 ); } // Normalize the start. while ( startContainer.type == CKEDITOR.NODE_TEXT && ( previous = startContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { startContainer = previous; startOffset += previous.getLength(); } // Process the end only if not normalized. if ( !collapsed ) { // Find out if the start is pointing to a text node that // will be normalized. if ( endContainer.type == CKEDITOR.NODE_ELEMENT ) { child = endContainer.getChild( endOffset ); // In this case, move the start information to that // text node. if ( child && child.type == CKEDITOR.NODE_TEXT && endOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { endContainer = child; endOffset = 0; } // Get the normalized offset. if ( child && child.type == CKEDITOR.NODE_ELEMENT ) endOffset = child.getIndex( 1 ); } // Normalize the end. while ( endContainer.type == CKEDITOR.NODE_TEXT && ( previous = endContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { endContainer = previous; endOffset += previous.getLength(); } } } return { start : startContainer.getAddress( normalized ), end : collapsed ? null : endContainer.getAddress( normalized ), startOffset : startOffset, endOffset : endOffset, normalized : normalized, collapsed : collapsed, is2 : true // It's a createBookmark2 bookmark. }; }
javascript
function( normalized ) { var startContainer = this.startContainer, endContainer = this.endContainer; var startOffset = this.startOffset, endOffset = this.endOffset; var collapsed = this.collapsed; var child, previous; // If there is no range then get out of here. // It happens on initial load in Safari #962 and if the editor it's // hidden also in Firefox if ( !startContainer || !endContainer ) return { start : 0, end : 0 }; if ( normalized ) { // Find out if the start is pointing to a text node that will // be normalized. if ( startContainer.type == CKEDITOR.NODE_ELEMENT ) { child = startContainer.getChild( startOffset ); // In this case, move the start information to that text // node. if ( child && child.type == CKEDITOR.NODE_TEXT && startOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { startContainer = child; startOffset = 0; } // Get the normalized offset. if ( child && child.type == CKEDITOR.NODE_ELEMENT ) startOffset = child.getIndex( 1 ); } // Normalize the start. while ( startContainer.type == CKEDITOR.NODE_TEXT && ( previous = startContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { startContainer = previous; startOffset += previous.getLength(); } // Process the end only if not normalized. if ( !collapsed ) { // Find out if the start is pointing to a text node that // will be normalized. if ( endContainer.type == CKEDITOR.NODE_ELEMENT ) { child = endContainer.getChild( endOffset ); // In this case, move the start information to that // text node. if ( child && child.type == CKEDITOR.NODE_TEXT && endOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { endContainer = child; endOffset = 0; } // Get the normalized offset. if ( child && child.type == CKEDITOR.NODE_ELEMENT ) endOffset = child.getIndex( 1 ); } // Normalize the end. while ( endContainer.type == CKEDITOR.NODE_TEXT && ( previous = endContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { endContainer = previous; endOffset += previous.getLength(); } } } return { start : startContainer.getAddress( normalized ), end : collapsed ? null : endContainer.getAddress( normalized ), startOffset : startOffset, endOffset : endOffset, normalized : normalized, collapsed : collapsed, is2 : true // It's a createBookmark2 bookmark. }; }
[ "function", "(", "normalized", ")", "{", "var", "startContainer", "=", "this", ".", "startContainer", ",", "endContainer", "=", "this", ".", "endContainer", ";", "var", "startOffset", "=", "this", ".", "startOffset", ",", "endOffset", "=", "this", ".", "endOffset", ";", "var", "collapsed", "=", "this", ".", "collapsed", ";", "var", "child", ",", "previous", ";", "// If there is no range then get out of here.\r", "// It happens on initial load in Safari #962 and if the editor it's\r", "// hidden also in Firefox\r", "if", "(", "!", "startContainer", "||", "!", "endContainer", ")", "return", "{", "start", ":", "0", ",", "end", ":", "0", "}", ";", "if", "(", "normalized", ")", "{", "// Find out if the start is pointing to a text node that will\r", "// be normalized.\r", "if", "(", "startContainer", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "child", "=", "startContainer", ".", "getChild", "(", "startOffset", ")", ";", "// In this case, move the start information to that text\r", "// node.\r", "if", "(", "child", "&&", "child", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", "&&", "startOffset", ">", "0", "&&", "child", ".", "getPrevious", "(", ")", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "startContainer", "=", "child", ";", "startOffset", "=", "0", ";", "}", "// Get the normalized offset.\r", "if", "(", "child", "&&", "child", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", ")", "startOffset", "=", "child", ".", "getIndex", "(", "1", ")", ";", "}", "// Normalize the start.\r", "while", "(", "startContainer", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", "&&", "(", "previous", "=", "startContainer", ".", "getPrevious", "(", ")", ")", "&&", "previous", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "startContainer", "=", "previous", ";", "startOffset", "+=", "previous", ".", "getLength", "(", ")", ";", "}", "// Process the end only if not normalized.\r", "if", "(", "!", "collapsed", ")", "{", "// Find out if the start is pointing to a text node that\r", "// will be normalized.\r", "if", "(", "endContainer", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "child", "=", "endContainer", ".", "getChild", "(", "endOffset", ")", ";", "// In this case, move the start information to that\r", "// text node.\r", "if", "(", "child", "&&", "child", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", "&&", "endOffset", ">", "0", "&&", "child", ".", "getPrevious", "(", ")", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "endContainer", "=", "child", ";", "endOffset", "=", "0", ";", "}", "// Get the normalized offset.\r", "if", "(", "child", "&&", "child", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", ")", "endOffset", "=", "child", ".", "getIndex", "(", "1", ")", ";", "}", "// Normalize the end.\r", "while", "(", "endContainer", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", "&&", "(", "previous", "=", "endContainer", ".", "getPrevious", "(", ")", ")", "&&", "previous", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "endContainer", "=", "previous", ";", "endOffset", "+=", "previous", ".", "getLength", "(", ")", ";", "}", "}", "}", "return", "{", "start", ":", "startContainer", ".", "getAddress", "(", "normalized", ")", ",", "end", ":", "collapsed", "?", "null", ":", "endContainer", ".", "getAddress", "(", "normalized", ")", ",", "startOffset", ":", "startOffset", ",", "endOffset", ":", "endOffset", ",", "normalized", ":", "normalized", ",", "collapsed", ":", "collapsed", ",", "is2", ":", "true", "// It's a createBookmark2 bookmark.\r", "}", ";", "}" ]
Creates a "non intrusive" and "mutation sensible" bookmark. This kind of bookmark should be used only when the DOM is supposed to remain stable after its creation. @param {Boolean} [normalized] Indicates that the bookmark must normalized. When normalized, the successive text nodes are considered a single node. To sucessful load a normalized bookmark, the DOM tree must be also normalized before calling moveToBookmark. @returns {Object} An object representing the bookmark.
[ "Creates", "a", "non", "intrusive", "and", "mutation", "sensible", "bookmark", ".", "This", "kind", "of", "bookmark", "should", "be", "used", "only", "when", "the", "DOM", "is", "supposed", "to", "remain", "stable", "after", "its", "creation", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L558-L650
47,607
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function() { var container = this.startContainer; var offset = this.startOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setStartBefore( container ); else if ( offset >= container.getLength() ) this.setStartAfter( container ); } container = this.endContainer; offset = this.endOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setEndBefore( container ); else if ( offset >= container.getLength() ) this.setEndAfter( container ); } }
javascript
function() { var container = this.startContainer; var offset = this.startOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setStartBefore( container ); else if ( offset >= container.getLength() ) this.setStartAfter( container ); } container = this.endContainer; offset = this.endOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setEndBefore( container ); else if ( offset >= container.getLength() ) this.setEndAfter( container ); } }
[ "function", "(", ")", "{", "var", "container", "=", "this", ".", "startContainer", ";", "var", "offset", "=", "this", ".", "startOffset", ";", "if", "(", "container", ".", "type", "!=", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "if", "(", "!", "offset", ")", "this", ".", "setStartBefore", "(", "container", ")", ";", "else", "if", "(", "offset", ">=", "container", ".", "getLength", "(", ")", ")", "this", ".", "setStartAfter", "(", "container", ")", ";", "}", "container", "=", "this", ".", "endContainer", ";", "offset", "=", "this", ".", "endOffset", ";", "if", "(", "container", ".", "type", "!=", "CKEDITOR", ".", "NODE_ELEMENT", ")", "{", "if", "(", "!", "offset", ")", "this", ".", "setEndBefore", "(", "container", ")", ";", "else", "if", "(", "offset", ">=", "container", ".", "getLength", "(", ")", ")", "this", ".", "setEndAfter", "(", "container", ")", ";", "}", "}" ]
Transforms the startContainer and endContainer properties from text nodes to element nodes, whenever possible. This is actually possible if either of the boundary containers point to a text node, and its offset is set to zero, or after the last char in the node.
[ "Transforms", "the", "startContainer", "and", "endContainer", "properties", "from", "text", "nodes", "to", "element", "nodes", "whenever", "possible", ".", "This", "is", "actually", "possible", "if", "either", "of", "the", "boundary", "containers", "point", "to", "a", "text", "node", "and", "its", "offset", "is", "set", "to", "zero", "or", "after", "the", "last", "char", "in", "the", "node", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L783-L806
47,608
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function() { var startNode = this.startContainer, endNode = this.endContainer; if ( startNode.is && startNode.is( 'span' ) && startNode.data( 'cke-bookmark' ) ) this.setStartAt( startNode, CKEDITOR.POSITION_BEFORE_START ); if ( endNode && endNode.is && endNode.is( 'span' ) && endNode.data( 'cke-bookmark' ) ) this.setEndAt( endNode, CKEDITOR.POSITION_AFTER_END ); }
javascript
function() { var startNode = this.startContainer, endNode = this.endContainer; if ( startNode.is && startNode.is( 'span' ) && startNode.data( 'cke-bookmark' ) ) this.setStartAt( startNode, CKEDITOR.POSITION_BEFORE_START ); if ( endNode && endNode.is && endNode.is( 'span' ) && endNode.data( 'cke-bookmark' ) ) this.setEndAt( endNode, CKEDITOR.POSITION_AFTER_END ); }
[ "function", "(", ")", "{", "var", "startNode", "=", "this", ".", "startContainer", ",", "endNode", "=", "this", ".", "endContainer", ";", "if", "(", "startNode", ".", "is", "&&", "startNode", ".", "is", "(", "'span'", ")", "&&", "startNode", ".", "data", "(", "'cke-bookmark'", ")", ")", "this", ".", "setStartAt", "(", "startNode", ",", "CKEDITOR", ".", "POSITION_BEFORE_START", ")", ";", "if", "(", "endNode", "&&", "endNode", ".", "is", "&&", "endNode", ".", "is", "(", "'span'", ")", "&&", "endNode", ".", "data", "(", "'cke-bookmark'", ")", ")", "this", ".", "setEndAt", "(", "endNode", ",", "CKEDITOR", ".", "POSITION_AFTER_END", ")", ";", "}" ]
Move the range out of bookmark nodes if they'd been the container.
[ "Move", "the", "range", "out", "of", "bookmark", "nodes", "if", "they", "d", "been", "the", "container", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L811-L822
47,609
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function( element, checkType ) { var checkStart = ( checkType == CKEDITOR.START ); // Create a copy of this range, so we can manipulate it for our checks. var walkerRange = this.clone(); // Collapse the range at the proper size. walkerRange.collapse( checkStart ); // Expand the range to element boundary. walkerRange[ checkStart ? 'setStartAt' : 'setEndAt' ] ( element, checkStart ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_BEFORE_END ); // Create the walker, which will check if we have anything useful // in the range. var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = elementBoundaryEval; return walker[ checkStart ? 'checkBackward' : 'checkForward' ](); }
javascript
function( element, checkType ) { var checkStart = ( checkType == CKEDITOR.START ); // Create a copy of this range, so we can manipulate it for our checks. var walkerRange = this.clone(); // Collapse the range at the proper size. walkerRange.collapse( checkStart ); // Expand the range to element boundary. walkerRange[ checkStart ? 'setStartAt' : 'setEndAt' ] ( element, checkStart ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_BEFORE_END ); // Create the walker, which will check if we have anything useful // in the range. var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = elementBoundaryEval; return walker[ checkStart ? 'checkBackward' : 'checkForward' ](); }
[ "function", "(", "element", ",", "checkType", ")", "{", "var", "checkStart", "=", "(", "checkType", "==", "CKEDITOR", ".", "START", ")", ";", "// Create a copy of this range, so we can manipulate it for our checks.\r", "var", "walkerRange", "=", "this", ".", "clone", "(", ")", ";", "// Collapse the range at the proper size.\r", "walkerRange", ".", "collapse", "(", "checkStart", ")", ";", "// Expand the range to element boundary.\r", "walkerRange", "[", "checkStart", "?", "'setStartAt'", ":", "'setEndAt'", "]", "(", "element", ",", "checkStart", "?", "CKEDITOR", ".", "POSITION_AFTER_START", ":", "CKEDITOR", ".", "POSITION_BEFORE_END", ")", ";", "// Create the walker, which will check if we have anything useful\r", "// in the range.\r", "var", "walker", "=", "new", "CKEDITOR", ".", "dom", ".", "walker", "(", "walkerRange", ")", ";", "walker", ".", "evaluator", "=", "elementBoundaryEval", ";", "return", "walker", "[", "checkStart", "?", "'checkBackward'", ":", "'checkForward'", "]", "(", ")", ";", "}" ]
Check whether a range boundary is at the inner boundary of a given element. @param {CKEDITOR.dom.element} element The target element to check. @param {Number} checkType The boundary to check for both the range and the element. It can be CKEDITOR.START or CKEDITOR.END. @returns {Boolean} "true" if the range boundary is at the inner boundary of the element.
[ "Check", "whether", "a", "range", "boundary", "is", "at", "the", "inner", "boundary", "of", "a", "given", "element", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L1779-L1799
47,610
saggiyogesh/nodeportal
public/ckeditor/_source/core/dom/range.js
function() { var startContainer = this.startContainer, startOffset = this.startOffset; // If the starting node is a text node, and non-empty before the offset, // then we're surely not at the start of block. if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT ) { var textBefore = CKEDITOR.tools.ltrim( startContainer.substring( 0, startOffset ) ); if ( textBefore.length ) return false; } // Antecipate the trim() call here, so the walker will not make // changes to the DOM, which would not get reflected into this // range otherwise. this.trim(); // We need to grab the block element holding the start boundary, so // let's use an element path for it. var path = new CKEDITOR.dom.elementPath( this.startContainer ); // Creates a range starting at the block start until the range start. var walkerRange = this.clone(); walkerRange.collapse( true ); walkerRange.setStartAt( path.block || path.blockLimit, CKEDITOR.POSITION_AFTER_START ); var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = getCheckStartEndBlockEvalFunction( true ); return walker.checkBackward(); }
javascript
function() { var startContainer = this.startContainer, startOffset = this.startOffset; // If the starting node is a text node, and non-empty before the offset, // then we're surely not at the start of block. if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT ) { var textBefore = CKEDITOR.tools.ltrim( startContainer.substring( 0, startOffset ) ); if ( textBefore.length ) return false; } // Antecipate the trim() call here, so the walker will not make // changes to the DOM, which would not get reflected into this // range otherwise. this.trim(); // We need to grab the block element holding the start boundary, so // let's use an element path for it. var path = new CKEDITOR.dom.elementPath( this.startContainer ); // Creates a range starting at the block start until the range start. var walkerRange = this.clone(); walkerRange.collapse( true ); walkerRange.setStartAt( path.block || path.blockLimit, CKEDITOR.POSITION_AFTER_START ); var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = getCheckStartEndBlockEvalFunction( true ); return walker.checkBackward(); }
[ "function", "(", ")", "{", "var", "startContainer", "=", "this", ".", "startContainer", ",", "startOffset", "=", "this", ".", "startOffset", ";", "// If the starting node is a text node, and non-empty before the offset,\r", "// then we're surely not at the start of block.\r", "if", "(", "startOffset", "&&", "startContainer", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "var", "textBefore", "=", "CKEDITOR", ".", "tools", ".", "ltrim", "(", "startContainer", ".", "substring", "(", "0", ",", "startOffset", ")", ")", ";", "if", "(", "textBefore", ".", "length", ")", "return", "false", ";", "}", "// Antecipate the trim() call here, so the walker will not make\r", "// changes to the DOM, which would not get reflected into this\r", "// range otherwise.\r", "this", ".", "trim", "(", ")", ";", "// We need to grab the block element holding the start boundary, so\r", "// let's use an element path for it.\r", "var", "path", "=", "new", "CKEDITOR", ".", "dom", ".", "elementPath", "(", "this", ".", "startContainer", ")", ";", "// Creates a range starting at the block start until the range start.\r", "var", "walkerRange", "=", "this", ".", "clone", "(", ")", ";", "walkerRange", ".", "collapse", "(", "true", ")", ";", "walkerRange", ".", "setStartAt", "(", "path", ".", "block", "||", "path", ".", "blockLimit", ",", "CKEDITOR", ".", "POSITION_AFTER_START", ")", ";", "var", "walker", "=", "new", "CKEDITOR", ".", "dom", ".", "walker", "(", "walkerRange", ")", ";", "walker", ".", "evaluator", "=", "getCheckStartEndBlockEvalFunction", "(", "true", ")", ";", "return", "walker", ".", "checkBackward", "(", ")", ";", "}" ]
Calls to this function may produce changes to the DOM. The range may be updated to reflect such changes.
[ "Calls", "to", "this", "function", "may", "produce", "changes", "to", "the", "DOM", ".", "The", "range", "may", "be", "updated", "to", "reflect", "such", "changes", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/range.js#L1803-L1835
47,611
shlomiassaf/resty-stone
example/customTypeHandlers/cloudinaryimage.js
authorizedHandler
function authorizedHandler(value) { if (! value) return value; delete value.public_id; delete value.version; delete value.signature; delete value.resource_type; return value; }
javascript
function authorizedHandler(value) { if (! value) return value; delete value.public_id; delete value.version; delete value.signature; delete value.resource_type; return value; }
[ "function", "authorizedHandler", "(", "value", ")", "{", "if", "(", "!", "value", ")", "return", "value", ";", "delete", "value", ".", "public_id", ";", "delete", "value", ".", "version", ";", "delete", "value", ".", "signature", ";", "delete", "value", ".", "resource_type", ";", "return", "value", ";", "}" ]
Handles CloudinaryImage instances for authorized requests.
[ "Handles", "CloudinaryImage", "instances", "for", "authorized", "requests", "." ]
9ab093272ea7b68c6fe0aba45384206571896295
https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/example/customTypeHandlers/cloudinaryimage.js#L20-L29
47,612
coderaiser/ponse
lib/ponse.js
sendFile
function sendFile(params) { const p = params; checkParams(params); fs.lstat(p.name, (error, stat) => { if (error) return sendError(error, params); const isGzip = isGZIP(p.request) && p.gzip; const time = stat.mtime.toUTCString(); const length = stat.size; const range = getRange(p.request, length); if (range) assign(p, { range, status: RANGE }); assign(p, { time }); if (!isGzip) p.length = length; setHeader(params); const options = { gzip : isGzip, range, }; files.pipe(p.name, p.response, options).catch((error) => { sendError(error, params); }); }); }
javascript
function sendFile(params) { const p = params; checkParams(params); fs.lstat(p.name, (error, stat) => { if (error) return sendError(error, params); const isGzip = isGZIP(p.request) && p.gzip; const time = stat.mtime.toUTCString(); const length = stat.size; const range = getRange(p.request, length); if (range) assign(p, { range, status: RANGE }); assign(p, { time }); if (!isGzip) p.length = length; setHeader(params); const options = { gzip : isGzip, range, }; files.pipe(p.name, p.response, options).catch((error) => { sendError(error, params); }); }); }
[ "function", "sendFile", "(", "params", ")", "{", "const", "p", "=", "params", ";", "checkParams", "(", "params", ")", ";", "fs", ".", "lstat", "(", "p", ".", "name", ",", "(", "error", ",", "stat", ")", "=>", "{", "if", "(", "error", ")", "return", "sendError", "(", "error", ",", "params", ")", ";", "const", "isGzip", "=", "isGZIP", "(", "p", ".", "request", ")", "&&", "p", ".", "gzip", ";", "const", "time", "=", "stat", ".", "mtime", ".", "toUTCString", "(", ")", ";", "const", "length", "=", "stat", ".", "size", ";", "const", "range", "=", "getRange", "(", "p", ".", "request", ",", "length", ")", ";", "if", "(", "range", ")", "assign", "(", "p", ",", "{", "range", ",", "status", ":", "RANGE", "}", ")", ";", "assign", "(", "p", ",", "{", "time", "}", ")", ";", "if", "(", "!", "isGzip", ")", "p", ".", "length", "=", "length", ";", "setHeader", "(", "params", ")", ";", "const", "options", "=", "{", "gzip", ":", "isGzip", ",", "range", ",", "}", ";", "files", ".", "pipe", "(", "p", ".", "name", ",", "p", ".", "response", ",", "options", ")", ".", "catch", "(", "(", "error", ")", "=>", "{", "sendError", "(", "error", ",", "params", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
send file to client thru pipe and gzip it if client support
[ "send", "file", "to", "client", "thru", "pipe", "and", "gzip", "it", "if", "client", "support" ]
0bea0b55304553a6b44254daffe178bb90fbe60b
https://github.com/coderaiser/ponse/blob/0bea0b55304553a6b44254daffe178bb90fbe60b/lib/ponse.js#L200-L238
47,613
coderaiser/ponse
lib/ponse.js
sendError
function sendError(error, params) { checkParams(params); params.status = FILE_NOT_FOUND; const data = error.message || String(error); logError(error.stack); send(data, params); }
javascript
function sendError(error, params) { checkParams(params); params.status = FILE_NOT_FOUND; const data = error.message || String(error); logError(error.stack); send(data, params); }
[ "function", "sendError", "(", "error", ",", "params", ")", "{", "checkParams", "(", "params", ")", ";", "params", ".", "status", "=", "FILE_NOT_FOUND", ";", "const", "data", "=", "error", ".", "message", "||", "String", "(", "error", ")", ";", "logError", "(", "error", ".", "stack", ")", ";", "send", "(", "data", ",", "params", ")", ";", "}" ]
send error response
[ "send", "error", "response" ]
0bea0b55304553a6b44254daffe178bb90fbe60b
https://github.com/coderaiser/ponse/blob/0bea0b55304553a6b44254daffe178bb90fbe60b/lib/ponse.js#L243-L253
47,614
coderaiser/ponse
lib/ponse.js
redirect
function redirect(url, response) { const header = { 'Location': url }; assert(url, 'url could not be empty!'); assert(response, 'response could not be empty!'); fillHeader(header, response); response.statusCode = MOVED_PERMANENTLY; response.end(); }
javascript
function redirect(url, response) { const header = { 'Location': url }; assert(url, 'url could not be empty!'); assert(response, 'response could not be empty!'); fillHeader(header, response); response.statusCode = MOVED_PERMANENTLY; response.end(); }
[ "function", "redirect", "(", "url", ",", "response", ")", "{", "const", "header", "=", "{", "'Location'", ":", "url", "}", ";", "assert", "(", "url", ",", "'url could not be empty!'", ")", ";", "assert", "(", "response", ",", "'response could not be empty!'", ")", ";", "fillHeader", "(", "header", ",", "response", ")", ";", "response", ".", "statusCode", "=", "MOVED_PERMANENTLY", ";", "response", ".", "end", "(", ")", ";", "}" ]
redirect to another URL
[ "redirect", "to", "another", "URL" ]
0bea0b55304553a6b44254daffe178bb90fbe60b
https://github.com/coderaiser/ponse/blob/0bea0b55304553a6b44254daffe178bb90fbe60b/lib/ponse.js#L318-L329
47,615
jhermsmeier/node-speech
lib/distance/levenshtein.js
levenshtein
function levenshtein( source, target ) { var s = source.length var t = target.length if( s === 0 ) return t if( t === 0 ) return s var i, k, matrix = [] for( i = 0; i <= t; i++ ) { matrix[i] = [ i ] } for( k = 0; k <= s; k++ ) matrix[0][k] = k for( i = 1; i <= t; i++ ) { for( k = 1; k <= s; k++ ) { ( target.charAt( i - 1 ) === source.charAt( k - 1 ) ) ? matrix[i][k] = matrix[ i - 1 ][ k - 1 ] : matrix[i][k] = Math.min( matrix[ i - 1 ][ k - 1 ] + 1, Math.min( matrix[i][ k - 1 ] + 1, matrix[ i - 1 ][k] + 1 ) ) } } return matrix[t][s] }
javascript
function levenshtein( source, target ) { var s = source.length var t = target.length if( s === 0 ) return t if( t === 0 ) return s var i, k, matrix = [] for( i = 0; i <= t; i++ ) { matrix[i] = [ i ] } for( k = 0; k <= s; k++ ) matrix[0][k] = k for( i = 1; i <= t; i++ ) { for( k = 1; k <= s; k++ ) { ( target.charAt( i - 1 ) === source.charAt( k - 1 ) ) ? matrix[i][k] = matrix[ i - 1 ][ k - 1 ] : matrix[i][k] = Math.min( matrix[ i - 1 ][ k - 1 ] + 1, Math.min( matrix[i][ k - 1 ] + 1, matrix[ i - 1 ][k] + 1 ) ) } } return matrix[t][s] }
[ "function", "levenshtein", "(", "source", ",", "target", ")", "{", "var", "s", "=", "source", ".", "length", "var", "t", "=", "target", ".", "length", "if", "(", "s", "===", "0", ")", "return", "t", "if", "(", "t", "===", "0", ")", "return", "s", "var", "i", ",", "k", ",", "matrix", "=", "[", "]", "for", "(", "i", "=", "0", ";", "i", "<=", "t", ";", "i", "++", ")", "{", "matrix", "[", "i", "]", "=", "[", "i", "]", "}", "for", "(", "k", "=", "0", ";", "k", "<=", "s", ";", "k", "++", ")", "matrix", "[", "0", "]", "[", "k", "]", "=", "k", "for", "(", "i", "=", "1", ";", "i", "<=", "t", ";", "i", "++", ")", "{", "for", "(", "k", "=", "1", ";", "k", "<=", "s", ";", "k", "++", ")", "{", "(", "target", ".", "charAt", "(", "i", "-", "1", ")", "===", "source", ".", "charAt", "(", "k", "-", "1", ")", ")", "?", "matrix", "[", "i", "]", "[", "k", "]", "=", "matrix", "[", "i", "-", "1", "]", "[", "k", "-", "1", "]", ":", "matrix", "[", "i", "]", "[", "k", "]", "=", "Math", ".", "min", "(", "matrix", "[", "i", "-", "1", "]", "[", "k", "-", "1", "]", "+", "1", ",", "Math", ".", "min", "(", "matrix", "[", "i", "]", "[", "k", "-", "1", "]", "+", "1", ",", "matrix", "[", "i", "-", "1", "]", "[", "k", "]", "+", "1", ")", ")", "}", "}", "return", "matrix", "[", "t", "]", "[", "s", "]", "}" ]
Computes the Levenshtein distance between two sequences. @param {String} source @param {String} target @return {Number} distance
[ "Computes", "the", "Levenshtein", "distance", "between", "two", "sequences", "." ]
984c4dd6e2fe640c01267f10e3804ef81391e73a
https://github.com/jhermsmeier/node-speech/blob/984c4dd6e2fe640c01267f10e3804ef81391e73a/lib/distance/levenshtein.js#L10-L43
47,616
saggiyogesh/nodeportal
public/ckeditor/_source/core/resourcemanager.js
function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( ( external && external.dir ) || this.basePath + name + '/' ); }
javascript
function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( ( external && external.dir ) || this.basePath + name + '/' ); }
[ "function", "(", "name", ")", "{", "var", "external", "=", "this", ".", "externals", "[", "name", "]", ";", "return", "CKEDITOR", ".", "getUrl", "(", "(", "external", "&&", "external", ".", "dir", ")", "||", "this", ".", "basePath", "+", "name", "+", "'/'", ")", ";", "}" ]
Get the folder path for a specific loaded resource. @param {String} name The resource name. @type String @example alert( <b>CKEDITOR.plugins.getPath( 'sample' )</b> ); // "&lt;editor path&gt;/plugins/sample/"
[ "Get", "the", "folder", "path", "for", "a", "specific", "loaded", "resource", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/resourcemanager.js#L112-L116
47,617
saggiyogesh/nodeportal
public/ckeditor/_source/core/resourcemanager.js
function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( this.getPath( name ) + ( ( external && ( typeof external.file == 'string' ) ) ? external.file : this.fileName + '.js' ) ); }
javascript
function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( this.getPath( name ) + ( ( external && ( typeof external.file == 'string' ) ) ? external.file : this.fileName + '.js' ) ); }
[ "function", "(", "name", ")", "{", "var", "external", "=", "this", ".", "externals", "[", "name", "]", ";", "return", "CKEDITOR", ".", "getUrl", "(", "this", ".", "getPath", "(", "name", ")", "+", "(", "(", "external", "&&", "(", "typeof", "external", ".", "file", "==", "'string'", ")", ")", "?", "external", ".", "file", ":", "this", ".", "fileName", "+", "'.js'", ")", ")", ";", "}" ]
Get the file path for a specific loaded resource. @param {String} name The resource name. @type String @example alert( <b>CKEDITOR.plugins.getFilePath( 'sample' )</b> ); // "&lt;editor path&gt;/plugins/sample/plugin.js"
[ "Get", "the", "file", "path", "for", "a", "specific", "loaded", "resource", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/resourcemanager.js#L125-L131
47,618
saggiyogesh/nodeportal
public/ckeditor/_source/core/resourcemanager.js
function( names, path, fileName ) { names = names.split( ',' ); for ( var i = 0 ; i < names.length ; i++ ) { var name = names[ i ]; this.externals[ name ] = { dir : path, file : fileName }; } }
javascript
function( names, path, fileName ) { names = names.split( ',' ); for ( var i = 0 ; i < names.length ; i++ ) { var name = names[ i ]; this.externals[ name ] = { dir : path, file : fileName }; } }
[ "function", "(", "names", ",", "path", ",", "fileName", ")", "{", "names", "=", "names", ".", "split", "(", "','", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "names", ".", "length", ";", "i", "++", ")", "{", "var", "name", "=", "names", "[", "i", "]", ";", "this", ".", "externals", "[", "name", "]", "=", "{", "dir", ":", "path", ",", "file", ":", "fileName", "}", ";", "}", "}" ]
Registers one or more resources to be loaded from an external path instead of the core base path. @param {String} names The resource names, separated by commas. @param {String} path The path of the folder containing the resource. @param {String} [fileName] The resource file name. If not provided, the default name is used; If provided with a empty string, will implicitly indicates that {@param path} is already the full path. @example // Loads a plugin from '/myplugin/samples/plugin.js'. CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' ); @example // Loads a plugin from '/myplugin/samples/my_plugin.js'. CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' ); @example // Loads a plugin from '/myplugin/samples/my_plugin.js'. CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js', '' );
[ "Registers", "one", "or", "more", "resources", "to", "be", "loaded", "from", "an", "external", "path", "instead", "of", "the", "core", "base", "path", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/resourcemanager.js#L151-L164
47,619
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
postProcessList
function postProcessList( list ) { var children = list.children, child, attrs, count = list.children.length, match, mergeStyle, styleTypeRegexp = /list-style-type:(.*?)(?:;|$)/, stylesFilter = CKEDITOR.plugins.pastefromword.filters.stylesFilter; attrs = list.attributes; if ( styleTypeRegexp.exec( attrs.style ) ) return; for ( var i = 0; i < count; i++ ) { child = children[ i ]; if ( child.attributes.value && Number( child.attributes.value ) == i + 1 ) delete child.attributes.value; match = styleTypeRegexp.exec( child.attributes.style ); if ( match ) { if ( match[ 1 ] == mergeStyle || !mergeStyle ) mergeStyle = match[ 1 ]; else { mergeStyle = null; break; } } } if ( mergeStyle ) { for ( i = 0; i < count; i++ ) { attrs = children[ i ].attributes; attrs.style && ( attrs.style = stylesFilter( [ [ 'list-style-type'] ] )( attrs.style ) || '' ); } list.addStyle( 'list-style-type', mergeStyle ); } }
javascript
function postProcessList( list ) { var children = list.children, child, attrs, count = list.children.length, match, mergeStyle, styleTypeRegexp = /list-style-type:(.*?)(?:;|$)/, stylesFilter = CKEDITOR.plugins.pastefromword.filters.stylesFilter; attrs = list.attributes; if ( styleTypeRegexp.exec( attrs.style ) ) return; for ( var i = 0; i < count; i++ ) { child = children[ i ]; if ( child.attributes.value && Number( child.attributes.value ) == i + 1 ) delete child.attributes.value; match = styleTypeRegexp.exec( child.attributes.style ); if ( match ) { if ( match[ 1 ] == mergeStyle || !mergeStyle ) mergeStyle = match[ 1 ]; else { mergeStyle = null; break; } } } if ( mergeStyle ) { for ( i = 0; i < count; i++ ) { attrs = children[ i ].attributes; attrs.style && ( attrs.style = stylesFilter( [ [ 'list-style-type'] ] )( attrs.style ) || '' ); } list.addStyle( 'list-style-type', mergeStyle ); } }
[ "function", "postProcessList", "(", "list", ")", "{", "var", "children", "=", "list", ".", "children", ",", "child", ",", "attrs", ",", "count", "=", "list", ".", "children", ".", "length", ",", "match", ",", "mergeStyle", ",", "styleTypeRegexp", "=", "/", "list-style-type:(.*?)(?:;|$)", "/", ",", "stylesFilter", "=", "CKEDITOR", ".", "plugins", ".", "pastefromword", ".", "filters", ".", "stylesFilter", ";", "attrs", "=", "list", ".", "attributes", ";", "if", "(", "styleTypeRegexp", ".", "exec", "(", "attrs", ".", "style", ")", ")", "return", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "child", "=", "children", "[", "i", "]", ";", "if", "(", "child", ".", "attributes", ".", "value", "&&", "Number", "(", "child", ".", "attributes", ".", "value", ")", "==", "i", "+", "1", ")", "delete", "child", ".", "attributes", ".", "value", ";", "match", "=", "styleTypeRegexp", ".", "exec", "(", "child", ".", "attributes", ".", "style", ")", ";", "if", "(", "match", ")", "{", "if", "(", "match", "[", "1", "]", "==", "mergeStyle", "||", "!", "mergeStyle", ")", "mergeStyle", "=", "match", "[", "1", "]", ";", "else", "{", "mergeStyle", "=", "null", ";", "break", ";", "}", "}", "}", "if", "(", "mergeStyle", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "attrs", "=", "children", "[", "i", "]", ".", "attributes", ";", "attrs", ".", "style", "&&", "(", "attrs", ".", "style", "=", "stylesFilter", "(", "[", "[", "'list-style-type'", "]", "]", ")", "(", "attrs", ".", "style", ")", "||", "''", ")", ";", "}", "list", ".", "addStyle", "(", "'list-style-type'", ",", "mergeStyle", ")", ";", "}", "}" ]
1. move consistent list item styles up to list root. 2. clear out unnecessary list item numbering.
[ "1", ".", "move", "consistent", "list", "item", "styles", "up", "to", "list", "root", ".", "2", ".", "clear", "out", "unnecessary", "list", "item", "numbering", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L123-L169
47,620
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
fromRoman
function fromRoman( str ) { str = str.toUpperCase(); var l = romans.length, retVal = 0; for ( var i = 0; i < l; ++i ) { for ( var j = romans[i], k = j[1].length; str.substr( 0, k ) == j[1]; str = str.substr( k ) ) retVal += j[ 0 ]; } return retVal; }
javascript
function fromRoman( str ) { str = str.toUpperCase(); var l = romans.length, retVal = 0; for ( var i = 0; i < l; ++i ) { for ( var j = romans[i], k = j[1].length; str.substr( 0, k ) == j[1]; str = str.substr( k ) ) retVal += j[ 0 ]; } return retVal; }
[ "function", "fromRoman", "(", "str", ")", "{", "str", "=", "str", ".", "toUpperCase", "(", ")", ";", "var", "l", "=", "romans", ".", "length", ",", "retVal", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "++", "i", ")", "{", "for", "(", "var", "j", "=", "romans", "[", "i", "]", ",", "k", "=", "j", "[", "1", "]", ".", "length", ";", "str", ".", "substr", "(", "0", ",", "k", ")", "==", "j", "[", "1", "]", ";", "str", "=", "str", ".", "substr", "(", "k", ")", ")", "retVal", "+=", "j", "[", "0", "]", ";", "}", "return", "retVal", ";", "}" ]
Convert roman numbering back to decimal.
[ "Convert", "roman", "numbering", "back", "to", "decimal", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L184-L194
47,621
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
fromAlphabet
function fromAlphabet( str ) { str = str.toUpperCase(); var l = alpahbets.length, retVal = 1; for ( var x = 1; str.length > 0; x *= l ) { retVal += alpahbets.indexOf( str.charAt( str.length - 1 ) ) * x; str = str.substr( 0, str.length - 1 ); } return retVal; }
javascript
function fromAlphabet( str ) { str = str.toUpperCase(); var l = alpahbets.length, retVal = 1; for ( var x = 1; str.length > 0; x *= l ) { retVal += alpahbets.indexOf( str.charAt( str.length - 1 ) ) * x; str = str.substr( 0, str.length - 1 ); } return retVal; }
[ "function", "fromAlphabet", "(", "str", ")", "{", "str", "=", "str", ".", "toUpperCase", "(", ")", ";", "var", "l", "=", "alpahbets", ".", "length", ",", "retVal", "=", "1", ";", "for", "(", "var", "x", "=", "1", ";", "str", ".", "length", ">", "0", ";", "x", "*=", "l", ")", "{", "retVal", "+=", "alpahbets", ".", "indexOf", "(", "str", ".", "charAt", "(", "str", ".", "length", "-", "1", ")", ")", "*", "x", ";", "str", "=", "str", ".", "substr", "(", "0", ",", "str", ".", "length", "-", "1", ")", ";", "}", "return", "retVal", ";", "}" ]
Convert alphabet numbering back to decimal.
[ "Convert", "alphabet", "numbering", "back", "to", "decimal", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L197-L207
47,622
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
function ( styleDefiniton, variables ) { return function( element ) { var styleDef = variables ? new CKEDITOR.style( styleDefiniton, variables )._.definition : styleDefiniton; element.name = styleDef.element; CKEDITOR.tools.extend( element.attributes, CKEDITOR.tools.clone( styleDef.attributes ) ); element.addStyle( CKEDITOR.style.getStyleText( styleDef ) ); }; }
javascript
function ( styleDefiniton, variables ) { return function( element ) { var styleDef = variables ? new CKEDITOR.style( styleDefiniton, variables )._.definition : styleDefiniton; element.name = styleDef.element; CKEDITOR.tools.extend( element.attributes, CKEDITOR.tools.clone( styleDef.attributes ) ); element.addStyle( CKEDITOR.style.getStyleText( styleDef ) ); }; }
[ "function", "(", "styleDefiniton", ",", "variables", ")", "{", "return", "function", "(", "element", ")", "{", "var", "styleDef", "=", "variables", "?", "new", "CKEDITOR", ".", "style", "(", "styleDefiniton", ",", "variables", ")", ".", "_", ".", "definition", ":", "styleDefiniton", ";", "element", ".", "name", "=", "styleDef", ".", "element", ";", "CKEDITOR", ".", "tools", ".", "extend", "(", "element", ".", "attributes", ",", "CKEDITOR", ".", "tools", ".", "clone", "(", "styleDef", ".", "attributes", ")", ")", ";", "element", ".", "addStyle", "(", "CKEDITOR", ".", "style", ".", "getStyleText", "(", "styleDef", ")", ")", ";", "}", ";", "}" ]
Migrate the element by decorate styles on it. @param styleDefiniton @param variables
[ "Migrate", "the", "element", "by", "decorate", "styles", "on", "it", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L687-L699
47,623
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
function( styleDefinition, variableName ) { var elementMigrateFilter = this.elementMigrateFilter; return function( value, element ) { // Build an stylish element first. var styleElement = new CKEDITOR.htmlParser.element( null ), variables = {}; variables[ variableName ] = value; elementMigrateFilter( styleDefinition, variables )( styleElement ); // Place the new element inside the existing span. styleElement.children = element.children; element.children = [ styleElement ]; }; }
javascript
function( styleDefinition, variableName ) { var elementMigrateFilter = this.elementMigrateFilter; return function( value, element ) { // Build an stylish element first. var styleElement = new CKEDITOR.htmlParser.element( null ), variables = {}; variables[ variableName ] = value; elementMigrateFilter( styleDefinition, variables )( styleElement ); // Place the new element inside the existing span. styleElement.children = element.children; element.children = [ styleElement ]; }; }
[ "function", "(", "styleDefinition", ",", "variableName", ")", "{", "var", "elementMigrateFilter", "=", "this", ".", "elementMigrateFilter", ";", "return", "function", "(", "value", ",", "element", ")", "{", "// Build an stylish element first.\r", "var", "styleElement", "=", "new", "CKEDITOR", ".", "htmlParser", ".", "element", "(", "null", ")", ",", "variables", "=", "{", "}", ";", "variables", "[", "variableName", "]", "=", "value", ";", "elementMigrateFilter", "(", "styleDefinition", ",", "variables", ")", "(", "styleElement", ")", ";", "// Place the new element inside the existing span.\r", "styleElement", ".", "children", "=", "element", ".", "children", ";", "element", ".", "children", "=", "[", "styleElement", "]", ";", "}", ";", "}" ]
Migrate styles by creating a new nested stylish element. @param styleDefinition
[ "Migrate", "styles", "by", "creating", "a", "new", "nested", "stylish", "element", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L705-L721
47,624
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/pastefromword/filter/default.js
function( element ) { if ( CKEDITOR.env.gecko ) { // Grab only the style definition section. var styleDefSection = element.onlyChild().value.match( /\/\* Style Definitions \*\/([\s\S]*?)\/\*/ ), styleDefText = styleDefSection && styleDefSection[ 1 ], rules = {}; // Storing the parsed result. if ( styleDefText ) { styleDefText // Remove line-breaks. .replace(/[\n\r]/g,'') // Extract selectors and style properties. .replace( /(.+?)\{(.+?)\}/g, function( rule, selectors, styleBlock ) { selectors = selectors.split( ',' ); var length = selectors.length, selector; for ( var i = 0; i < length; i++ ) { // Assume MS-Word mostly generate only simple // selector( [Type selector][Class selector]). CKEDITOR.tools.trim( selectors[ i ] ) .replace( /^(\w+)(\.[\w-]+)?$/g, function( match, tagName, className ) { tagName = tagName || '*'; className = className.substring( 1, className.length ); // Reject MS-Word Normal styles. if ( className.match( /MsoNormal/ ) ) return; if ( !rules[ tagName ] ) rules[ tagName ] = {}; if ( className ) rules[ tagName ][ className ] = styleBlock; else rules[ tagName ] = styleBlock; } ); } }); filters.applyStyleFilter = function( element ) { var name = rules[ '*' ] ? '*' : element.name, className = element.attributes && element.attributes[ 'class' ], style; if ( name in rules ) { style = rules[ name ]; if ( typeof style == 'object' ) style = style[ className ]; // Maintain style rules priorities. style && element.addStyle( style, true ); } }; } } return false; }
javascript
function( element ) { if ( CKEDITOR.env.gecko ) { // Grab only the style definition section. var styleDefSection = element.onlyChild().value.match( /\/\* Style Definitions \*\/([\s\S]*?)\/\*/ ), styleDefText = styleDefSection && styleDefSection[ 1 ], rules = {}; // Storing the parsed result. if ( styleDefText ) { styleDefText // Remove line-breaks. .replace(/[\n\r]/g,'') // Extract selectors and style properties. .replace( /(.+?)\{(.+?)\}/g, function( rule, selectors, styleBlock ) { selectors = selectors.split( ',' ); var length = selectors.length, selector; for ( var i = 0; i < length; i++ ) { // Assume MS-Word mostly generate only simple // selector( [Type selector][Class selector]). CKEDITOR.tools.trim( selectors[ i ] ) .replace( /^(\w+)(\.[\w-]+)?$/g, function( match, tagName, className ) { tagName = tagName || '*'; className = className.substring( 1, className.length ); // Reject MS-Word Normal styles. if ( className.match( /MsoNormal/ ) ) return; if ( !rules[ tagName ] ) rules[ tagName ] = {}; if ( className ) rules[ tagName ][ className ] = styleBlock; else rules[ tagName ] = styleBlock; } ); } }); filters.applyStyleFilter = function( element ) { var name = rules[ '*' ] ? '*' : element.name, className = element.attributes && element.attributes[ 'class' ], style; if ( name in rules ) { style = rules[ name ]; if ( typeof style == 'object' ) style = style[ className ]; // Maintain style rules priorities. style && element.addStyle( style, true ); } }; } } return false; }
[ "function", "(", "element", ")", "{", "if", "(", "CKEDITOR", ".", "env", ".", "gecko", ")", "{", "// Grab only the style definition section.\r", "var", "styleDefSection", "=", "element", ".", "onlyChild", "(", ")", ".", "value", ".", "match", "(", "/", "\\/\\* Style Definitions \\*\\/([\\s\\S]*?)\\/\\*", "/", ")", ",", "styleDefText", "=", "styleDefSection", "&&", "styleDefSection", "[", "1", "]", ",", "rules", "=", "{", "}", ";", "// Storing the parsed result.\r", "if", "(", "styleDefText", ")", "{", "styleDefText", "// Remove line-breaks.\r", ".", "replace", "(", "/", "[\\n\\r]", "/", "g", ",", "''", ")", "// Extract selectors and style properties.\r", ".", "replace", "(", "/", "(.+?)\\{(.+?)\\}", "/", "g", ",", "function", "(", "rule", ",", "selectors", ",", "styleBlock", ")", "{", "selectors", "=", "selectors", ".", "split", "(", "','", ")", ";", "var", "length", "=", "selectors", ".", "length", ",", "selector", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "// Assume MS-Word mostly generate only simple\r", "// selector( [Type selector][Class selector]).\r", "CKEDITOR", ".", "tools", ".", "trim", "(", "selectors", "[", "i", "]", ")", ".", "replace", "(", "/", "^(\\w+)(\\.[\\w-]+)?$", "/", "g", ",", "function", "(", "match", ",", "tagName", ",", "className", ")", "{", "tagName", "=", "tagName", "||", "'*'", ";", "className", "=", "className", ".", "substring", "(", "1", ",", "className", ".", "length", ")", ";", "// Reject MS-Word Normal styles.\r", "if", "(", "className", ".", "match", "(", "/", "MsoNormal", "/", ")", ")", "return", ";", "if", "(", "!", "rules", "[", "tagName", "]", ")", "rules", "[", "tagName", "]", "=", "{", "}", ";", "if", "(", "className", ")", "rules", "[", "tagName", "]", "[", "className", "]", "=", "styleBlock", ";", "else", "rules", "[", "tagName", "]", "=", "styleBlock", ";", "}", ")", ";", "}", "}", ")", ";", "filters", ".", "applyStyleFilter", "=", "function", "(", "element", ")", "{", "var", "name", "=", "rules", "[", "'*'", "]", "?", "'*'", ":", "element", ".", "name", ",", "className", "=", "element", ".", "attributes", "&&", "element", ".", "attributes", "[", "'class'", "]", ",", "style", ";", "if", "(", "name", "in", "rules", ")", "{", "style", "=", "rules", "[", "name", "]", ";", "if", "(", "typeof", "style", "==", "'object'", ")", "style", "=", "style", "[", "className", "]", ";", "// Maintain style rules priorities.\r", "style", "&&", "element", ".", "addStyle", "(", "style", ",", "true", ")", ";", "}", "}", ";", "}", "}", "return", "false", ";", "}" ]
We'll drop any style sheet, but Firefox conclude certain styles in a single style element, which are required to be changed into inline ones.
[ "We", "ll", "drop", "any", "style", "sheet", "but", "Firefox", "conclude", "certain", "styles", "in", "a", "single", "style", "element", "which", "are", "required", "to", "be", "changed", "into", "inline", "ones", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/pastefromword/filter/default.js#L855-L917
47,625
mdreizin/webpack-config-stream
lib/initStream.js
initStream
function initStream(options) { if (!_.isObject(options)) { options = {}; } return through.obj(function(chunk, enc, cb) { var compilerOptions = chunk[FIELD_NAME] || {}; compilerOptions = _.merge(compilerOptions, options); if (options.progress === true) { compilerOptions.progress = progressCallback; } chunk[FIELD_NAME] = compilerOptions; cb(null, chunk); }); }
javascript
function initStream(options) { if (!_.isObject(options)) { options = {}; } return through.obj(function(chunk, enc, cb) { var compilerOptions = chunk[FIELD_NAME] || {}; compilerOptions = _.merge(compilerOptions, options); if (options.progress === true) { compilerOptions.progress = progressCallback; } chunk[FIELD_NAME] = compilerOptions; cb(null, chunk); }); }
[ "function", "initStream", "(", "options", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "options", ")", ")", "{", "options", "=", "{", "}", ";", "}", "return", "through", ".", "obj", "(", "function", "(", "chunk", ",", "enc", ",", "cb", ")", "{", "var", "compilerOptions", "=", "chunk", "[", "FIELD_NAME", "]", "||", "{", "}", ";", "compilerOptions", "=", "_", ".", "merge", "(", "compilerOptions", ",", "options", ")", ";", "if", "(", "options", ".", "progress", "===", "true", ")", "{", "compilerOptions", ".", "progress", "=", "progressCallback", ";", "}", "chunk", "[", "FIELD_NAME", "]", "=", "compilerOptions", ";", "cb", "(", "null", ",", "chunk", ")", ";", "}", ")", ";", "}" ]
Helps to init `webpack` compiler. Can be piped. @function @alias initStream @param {Object=} options @param {Boolean} [options.useMemoryFs=false] - Uses {@link https://github.com/webpack/memory-fs memory-fs} for `compiler.outputFileSystem`. Prevents writing of emitted files to file system. `gulp.dest()` can be used. `gulp.dest()` is resolved relative to {@link https://github.com/webpack/docs/wiki/configuration#outputpath output.path} if it is set; otherwise, it is resolved relative to {@link https://github.com/gulpjs/gulp/blob/master/docs/API.md#optionsbase options.base} (by default, the path of `gulpfile.js`). @param {Boolean} [options.progress=false] - Adds ability to track compilation progress. @returns {Stream}
[ "Helps", "to", "init", "webpack", "compiler", ".", "Can", "be", "piped", "." ]
f8424f97837a224bc07cc18a03ecf649d708e924
https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/initStream.js#L23-L41
47,626
shlomiassaf/resty-stone
lib/models/BaseTypeHandler.js
BaseTypeHandler
function BaseTypeHandler(ksTypeName, handlers) { this.ksTypeName = ksTypeName; if ("function" === typeof handlers) { this.handlers = {default: handlers}; } else { this.handlers = _.extend({}, handlers); } }
javascript
function BaseTypeHandler(ksTypeName, handlers) { this.ksTypeName = ksTypeName; if ("function" === typeof handlers) { this.handlers = {default: handlers}; } else { this.handlers = _.extend({}, handlers); } }
[ "function", "BaseTypeHandler", "(", "ksTypeName", ",", "handlers", ")", "{", "this", ".", "ksTypeName", "=", "ksTypeName", ";", "if", "(", "\"function\"", "===", "typeof", "handlers", ")", "{", "this", ".", "handlers", "=", "{", "default", ":", "handlers", "}", ";", "}", "else", "{", "this", ".", "handlers", "=", "_", ".", "extend", "(", "{", "}", ",", "handlers", ")", ";", "}", "}" ]
Handles transformation of keystone field types. @param ksTypeName The name of the field @param handlers an object with profile/handler pairs or a single function that will be the default profile handler. @constructor
[ "Handles", "transformation", "of", "keystone", "field", "types", "." ]
9ab093272ea7b68c6fe0aba45384206571896295
https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/lib/models/BaseTypeHandler.js#L10-L20
47,627
fvsch/gulp-task-maker
feedback.js
onExit
function onExit() { if (!onExit.done) { if (options.strict !== true) showLoadingErrors() if (options.debug === true) showDebugInfo() } onExit.done = true }
javascript
function onExit() { if (!onExit.done) { if (options.strict !== true) showLoadingErrors() if (options.debug === true) showDebugInfo() } onExit.done = true }
[ "function", "onExit", "(", ")", "{", "if", "(", "!", "onExit", ".", "done", ")", "{", "if", "(", "options", ".", "strict", "!==", "true", ")", "showLoadingErrors", "(", ")", "if", "(", "options", ".", "debug", "===", "true", ")", "showDebugInfo", "(", ")", "}", "onExit", ".", "done", "=", "true", "}" ]
Show saved errors if things went wrong
[ "Show", "saved", "errors", "if", "things", "went", "wrong" ]
20ab4245f2d75174786ad140793e9438c025d546
https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/feedback.js#L25-L31
47,628
fvsch/gulp-task-maker
feedback.js
showDebugInfo
function showDebugInfo() { customLog(`gulp-task-maker options:\n${util.inspect(options)}`) for (const data of scripts) { const info = { callback: data.callback, configs: data.normalizedConfigs, errors: data.errors } customLog( `gulp-task-maker script '${data.name}':\n${util.inspect(info, { depth: 6 })}` ) } }
javascript
function showDebugInfo() { customLog(`gulp-task-maker options:\n${util.inspect(options)}`) for (const data of scripts) { const info = { callback: data.callback, configs: data.normalizedConfigs, errors: data.errors } customLog( `gulp-task-maker script '${data.name}':\n${util.inspect(info, { depth: 6 })}` ) } }
[ "function", "showDebugInfo", "(", ")", "{", "customLog", "(", "`", "\\n", "${", "util", ".", "inspect", "(", "options", ")", "}", "`", ")", "for", "(", "const", "data", "of", "scripts", ")", "{", "const", "info", "=", "{", "callback", ":", "data", ".", "callback", ",", "configs", ":", "data", ".", "normalizedConfigs", ",", "errors", ":", "data", ".", "errors", "}", "customLog", "(", "`", "${", "data", ".", "name", "}", "\\n", "${", "util", ".", "inspect", "(", "info", ",", "{", "depth", ":", "6", "}", ")", "}", "`", ")", "}", "}" ]
Get debug info such as the current options and GTM state @return {object}
[ "Get", "debug", "info", "such", "as", "the", "current", "options", "and", "GTM", "state" ]
20ab4245f2d75174786ad140793e9438c025d546
https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/feedback.js#L37-L51
47,629
fvsch/gulp-task-maker
feedback.js
handleError
function handleError(err, store) { if (err && !err.plugin) { err.plugin = 'gulp-task-maker' } if (Array.isArray(store)) { store.push(err) } else { showError(err) } }
javascript
function handleError(err, store) { if (err && !err.plugin) { err.plugin = 'gulp-task-maker' } if (Array.isArray(store)) { store.push(err) } else { showError(err) } }
[ "function", "handleError", "(", "err", ",", "store", ")", "{", "if", "(", "err", "&&", "!", "err", ".", "plugin", ")", "{", "err", ".", "plugin", "=", "'gulp-task-maker'", "}", "if", "(", "Array", ".", "isArray", "(", "store", ")", ")", "{", "store", ".", "push", "(", "err", ")", "}", "else", "{", "showError", "(", "err", ")", "}", "}" ]
Store an error for later, log it instantly or throw if in strict mode @param {object} err - error object @param {Array} [store] - where to store the error for later
[ "Store", "an", "error", "for", "later", "log", "it", "instantly", "or", "throw", "if", "in", "strict", "mode" ]
20ab4245f2d75174786ad140793e9438c025d546
https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/feedback.js#L58-L67
47,630
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/horizontalrule/plugin.js
function( editor ) { var hr = editor.document.createElement( 'hr' ), range = new CKEDITOR.dom.range( editor.document ); editor.insertElement( hr ); // If there's nothing or a non-editable block followed by, establish a new paragraph // to make sure cursor is not trapped. range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END ); var next = hr.getNext(); if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() ) range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); range.select(); }
javascript
function( editor ) { var hr = editor.document.createElement( 'hr' ), range = new CKEDITOR.dom.range( editor.document ); editor.insertElement( hr ); // If there's nothing or a non-editable block followed by, establish a new paragraph // to make sure cursor is not trapped. range.moveToPosition( hr, CKEDITOR.POSITION_AFTER_END ); var next = hr.getNext(); if ( !next || next.type == CKEDITOR.NODE_ELEMENT && !next.isEditable() ) range.fixBlock( true, editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ); range.select(); }
[ "function", "(", "editor", ")", "{", "var", "hr", "=", "editor", ".", "document", ".", "createElement", "(", "'hr'", ")", ",", "range", "=", "new", "CKEDITOR", ".", "dom", ".", "range", "(", "editor", ".", "document", ")", ";", "editor", ".", "insertElement", "(", "hr", ")", ";", "// If there's nothing or a non-editable block followed by, establish a new paragraph\r", "// to make sure cursor is not trapped.\r", "range", ".", "moveToPosition", "(", "hr", ",", "CKEDITOR", ".", "POSITION_AFTER_END", ")", ";", "var", "next", "=", "hr", ".", "getNext", "(", ")", ";", "if", "(", "!", "next", "||", "next", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", "&&", "!", "next", ".", "isEditable", "(", ")", ")", "range", ".", "fixBlock", "(", "true", ",", "editor", ".", "config", ".", "enterMode", "==", "CKEDITOR", ".", "ENTER_DIV", "?", "'div'", ":", "'p'", ")", ";", "range", ".", "select", "(", ")", ";", "}" ]
The undo snapshot will be handled by 'insertElement'.
[ "The", "undo", "snapshot", "will", "be", "handled", "by", "insertElement", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/horizontalrule/plugin.js#L15-L30
47,631
levilindsey/physx
src/util/src/geometry.js
findSquaredDistanceBetweenSegments
function findSquaredDistanceBetweenSegments(segmentA, segmentB) { findClosestPointsFromSegmentToSegment(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB, segmentA, segmentB); return vec3.squaredDistance(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB); }
javascript
function findSquaredDistanceBetweenSegments(segmentA, segmentB) { findClosestPointsFromSegmentToSegment(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB, segmentA, segmentB); return vec3.squaredDistance(_segmentDistance_tmpVecA, _segmentDistance_tmpVecB); }
[ "function", "findSquaredDistanceBetweenSegments", "(", "segmentA", ",", "segmentB", ")", "{", "findClosestPointsFromSegmentToSegment", "(", "_segmentDistance_tmpVecA", ",", "_segmentDistance_tmpVecB", ",", "segmentA", ",", "segmentB", ")", ";", "return", "vec3", ".", "squaredDistance", "(", "_segmentDistance_tmpVecA", ",", "_segmentDistance_tmpVecB", ")", ";", "}" ]
Finds the minimum squared distance between two line segments. @param {LineSegment} segmentA @param {LineSegment} segmentB @returns {number}
[ "Finds", "the", "minimum", "squared", "distance", "between", "two", "line", "segments", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L16-L20
47,632
levilindsey/physx
src/util/src/geometry.js
findSquaredDistanceFromSegmentToPoint
function findSquaredDistanceFromSegmentToPoint(segment, point) { findClosestPointOnSegmentToPoint(_segmentDistance_tmpVecA, segment, point); return vec3.squaredDistance(_segmentDistance_tmpVecA, point); }
javascript
function findSquaredDistanceFromSegmentToPoint(segment, point) { findClosestPointOnSegmentToPoint(_segmentDistance_tmpVecA, segment, point); return vec3.squaredDistance(_segmentDistance_tmpVecA, point); }
[ "function", "findSquaredDistanceFromSegmentToPoint", "(", "segment", ",", "point", ")", "{", "findClosestPointOnSegmentToPoint", "(", "_segmentDistance_tmpVecA", ",", "segment", ",", "point", ")", ";", "return", "vec3", ".", "squaredDistance", "(", "_segmentDistance_tmpVecA", ",", "point", ")", ";", "}" ]
Finds the minimum squared distance between a line segment and a point. @param {LineSegment} segment @param {vec3} point @returns {number}
[ "Finds", "the", "minimum", "squared", "distance", "between", "a", "line", "segment", "and", "a", "point", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L29-L32
47,633
levilindsey/physx
src/util/src/geometry.js
findPoiBetweenSegmentAndPlaneRegion
function findPoiBetweenSegmentAndPlaneRegion(poi, segment, planeVertex1, planeVertex2, planeVertex3, planeVertex4) { return findPoiBetweenSegmentAndTriangle(poi, segment, planeVertex1, planeVertex2, planeVertex3) || findPoiBetweenSegmentAndTriangle(poi, segment, planeVertex1, planeVertex3, planeVertex4); }
javascript
function findPoiBetweenSegmentAndPlaneRegion(poi, segment, planeVertex1, planeVertex2, planeVertex3, planeVertex4) { return findPoiBetweenSegmentAndTriangle(poi, segment, planeVertex1, planeVertex2, planeVertex3) || findPoiBetweenSegmentAndTriangle(poi, segment, planeVertex1, planeVertex3, planeVertex4); }
[ "function", "findPoiBetweenSegmentAndPlaneRegion", "(", "poi", ",", "segment", ",", "planeVertex1", ",", "planeVertex2", ",", "planeVertex3", ",", "planeVertex4", ")", "{", "return", "findPoiBetweenSegmentAndTriangle", "(", "poi", ",", "segment", ",", "planeVertex1", ",", "planeVertex2", ",", "planeVertex3", ")", "||", "findPoiBetweenSegmentAndTriangle", "(", "poi", ",", "segment", ",", "planeVertex1", ",", "planeVertex3", ",", "planeVertex4", ")", ";", "}" ]
Finds the point of intersection between a line segment and a coplanar quadrilateral. This assumes the region is not degenerate (has non-zero side lengths). @param {vec3} poi Output param. Null if there is no intersection. @param {LineSegment} segment @param {vec3} planeVertex1 @param {vec3} planeVertex2 @param {vec3} planeVertex3 @param {vec3} planeVertex4 @returns {boolean} True if there is an intersection.
[ "Finds", "the", "point", "of", "intersection", "between", "a", "line", "segment", "and", "a", "coplanar", "quadrilateral", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L116-L120
47,634
levilindsey/physx
src/util/src/geometry.js
findPoiBetweenSegmentAndTriangle
function findPoiBetweenSegmentAndTriangle(poi, segment, triangleVertex1, triangleVertex2, triangleVertex3) { // // Find the point of intersection between the segment and the triangle's plane. // // First triangle edge. vec3.subtract(_tmpVec1, triangleVertex2, triangleVertex1); // Second triangle edge. vec3.subtract(_tmpVec2, triangleVertex3, triangleVertex1); // Triangle normal. vec3.cross(_tmpVec3, _tmpVec1, _tmpVec2); // Triangle to segment. vec3.subtract(_tmpVec4, segment.start, triangleVertex1); const normalToSegmentProj = vec3.dot(_tmpVec3, segment.dir); if (normalToSegmentProj < EPSILON && normalToSegmentProj > -EPSILON) { // The line segment is parallel to the triangle. return false; } const normalToDiffProj = -vec3.dot(_tmpVec3, _tmpVec4); const segmentNormalizedDistance = normalToDiffProj / normalToSegmentProj; if (segmentNormalizedDistance < 0 || segmentNormalizedDistance > 1) { // The line segment ends before intersecting the plane. return false; } vec3.scaleAndAdd(poi, segment.start, segment.dir, segmentNormalizedDistance); // // Determine whether the point of intersection lies within the triangle. // const edge1DotEdge1 = vec3.dot(_tmpVec1, _tmpVec1); const edge1DotEdge2 = vec3.dot(_tmpVec1, _tmpVec2); const edge2DotEdge2 = vec3.dot(_tmpVec2, _tmpVec2); // Triangle to point of intersection. vec3.subtract(_tmpVec3, poi, triangleVertex1); const diffDotEdge1 = vec3.dot(_tmpVec3, _tmpVec1); const diffDotEdge2 = vec3.dot(_tmpVec3, _tmpVec2); const denominator = edge1DotEdge2 * edge1DotEdge2 - edge1DotEdge1 * edge2DotEdge2; // Check the triangle's parametric coordinates. const s = (edge1DotEdge2 * diffDotEdge2 - edge2DotEdge2 * diffDotEdge1) / denominator; if (s < 0 || s > 1) { return false; } const t = (edge1DotEdge2 * diffDotEdge1 - edge1DotEdge1 * diffDotEdge2) / denominator; if (t < 0 || s + t > 1) { return false; } return true; }
javascript
function findPoiBetweenSegmentAndTriangle(poi, segment, triangleVertex1, triangleVertex2, triangleVertex3) { // // Find the point of intersection between the segment and the triangle's plane. // // First triangle edge. vec3.subtract(_tmpVec1, triangleVertex2, triangleVertex1); // Second triangle edge. vec3.subtract(_tmpVec2, triangleVertex3, triangleVertex1); // Triangle normal. vec3.cross(_tmpVec3, _tmpVec1, _tmpVec2); // Triangle to segment. vec3.subtract(_tmpVec4, segment.start, triangleVertex1); const normalToSegmentProj = vec3.dot(_tmpVec3, segment.dir); if (normalToSegmentProj < EPSILON && normalToSegmentProj > -EPSILON) { // The line segment is parallel to the triangle. return false; } const normalToDiffProj = -vec3.dot(_tmpVec3, _tmpVec4); const segmentNormalizedDistance = normalToDiffProj / normalToSegmentProj; if (segmentNormalizedDistance < 0 || segmentNormalizedDistance > 1) { // The line segment ends before intersecting the plane. return false; } vec3.scaleAndAdd(poi, segment.start, segment.dir, segmentNormalizedDistance); // // Determine whether the point of intersection lies within the triangle. // const edge1DotEdge1 = vec3.dot(_tmpVec1, _tmpVec1); const edge1DotEdge2 = vec3.dot(_tmpVec1, _tmpVec2); const edge2DotEdge2 = vec3.dot(_tmpVec2, _tmpVec2); // Triangle to point of intersection. vec3.subtract(_tmpVec3, poi, triangleVertex1); const diffDotEdge1 = vec3.dot(_tmpVec3, _tmpVec1); const diffDotEdge2 = vec3.dot(_tmpVec3, _tmpVec2); const denominator = edge1DotEdge2 * edge1DotEdge2 - edge1DotEdge1 * edge2DotEdge2; // Check the triangle's parametric coordinates. const s = (edge1DotEdge2 * diffDotEdge2 - edge2DotEdge2 * diffDotEdge1) / denominator; if (s < 0 || s > 1) { return false; } const t = (edge1DotEdge2 * diffDotEdge1 - edge1DotEdge1 * diffDotEdge2) / denominator; if (t < 0 || s + t > 1) { return false; } return true; }
[ "function", "findPoiBetweenSegmentAndTriangle", "(", "poi", ",", "segment", ",", "triangleVertex1", ",", "triangleVertex2", ",", "triangleVertex3", ")", "{", "//", "// Find the point of intersection between the segment and the triangle's plane.", "//", "// First triangle edge.", "vec3", ".", "subtract", "(", "_tmpVec1", ",", "triangleVertex2", ",", "triangleVertex1", ")", ";", "// Second triangle edge.", "vec3", ".", "subtract", "(", "_tmpVec2", ",", "triangleVertex3", ",", "triangleVertex1", ")", ";", "// Triangle normal.", "vec3", ".", "cross", "(", "_tmpVec3", ",", "_tmpVec1", ",", "_tmpVec2", ")", ";", "// Triangle to segment.", "vec3", ".", "subtract", "(", "_tmpVec4", ",", "segment", ".", "start", ",", "triangleVertex1", ")", ";", "const", "normalToSegmentProj", "=", "vec3", ".", "dot", "(", "_tmpVec3", ",", "segment", ".", "dir", ")", ";", "if", "(", "normalToSegmentProj", "<", "EPSILON", "&&", "normalToSegmentProj", ">", "-", "EPSILON", ")", "{", "// The line segment is parallel to the triangle.", "return", "false", ";", "}", "const", "normalToDiffProj", "=", "-", "vec3", ".", "dot", "(", "_tmpVec3", ",", "_tmpVec4", ")", ";", "const", "segmentNormalizedDistance", "=", "normalToDiffProj", "/", "normalToSegmentProj", ";", "if", "(", "segmentNormalizedDistance", "<", "0", "||", "segmentNormalizedDistance", ">", "1", ")", "{", "// The line segment ends before intersecting the plane.", "return", "false", ";", "}", "vec3", ".", "scaleAndAdd", "(", "poi", ",", "segment", ".", "start", ",", "segment", ".", "dir", ",", "segmentNormalizedDistance", ")", ";", "//", "// Determine whether the point of intersection lies within the triangle.", "//", "const", "edge1DotEdge1", "=", "vec3", ".", "dot", "(", "_tmpVec1", ",", "_tmpVec1", ")", ";", "const", "edge1DotEdge2", "=", "vec3", ".", "dot", "(", "_tmpVec1", ",", "_tmpVec2", ")", ";", "const", "edge2DotEdge2", "=", "vec3", ".", "dot", "(", "_tmpVec2", ",", "_tmpVec2", ")", ";", "// Triangle to point of intersection.", "vec3", ".", "subtract", "(", "_tmpVec3", ",", "poi", ",", "triangleVertex1", ")", ";", "const", "diffDotEdge1", "=", "vec3", ".", "dot", "(", "_tmpVec3", ",", "_tmpVec1", ")", ";", "const", "diffDotEdge2", "=", "vec3", ".", "dot", "(", "_tmpVec3", ",", "_tmpVec2", ")", ";", "const", "denominator", "=", "edge1DotEdge2", "*", "edge1DotEdge2", "-", "edge1DotEdge1", "*", "edge2DotEdge2", ";", "// Check the triangle's parametric coordinates.", "const", "s", "=", "(", "edge1DotEdge2", "*", "diffDotEdge2", "-", "edge2DotEdge2", "*", "diffDotEdge1", ")", "/", "denominator", ";", "if", "(", "s", "<", "0", "||", "s", ">", "1", ")", "{", "return", "false", ";", "}", "const", "t", "=", "(", "edge1DotEdge2", "*", "diffDotEdge1", "-", "edge1DotEdge1", "*", "diffDotEdge2", ")", "/", "denominator", ";", "if", "(", "t", "<", "0", "||", "s", "+", "t", ">", "1", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Finds the point of intersection between a line segment and a triangle. This assumes the triangle is not degenerate (has non-zero side lengths). ---------------------------------------------------------------------------- Originally based on Dan Sunday's algorithms at http://geomalgorithms.com/a06-_intersect-2.html. Copyright 2001 softSurfer, 2012 Dan Sunday This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for their application. ---------------------------------------------------------------------------- @param {vec3} poi Output param. Null if there is no intersection. @param {LineSegment} segment @param {vec3} triangleVertex1 @param {vec3} triangleVertex2 @param {vec3} triangleVertex3 @returns {boolean} True if there is an intersection.
[ "Finds", "the", "point", "of", "intersection", "between", "a", "line", "segment", "and", "a", "triangle", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L145-L201
47,635
levilindsey/physx
src/util/src/geometry.js
findClosestPointsFromSegmentToSegment
function findClosestPointsFromSegmentToSegment(closestA, closestB, segmentA, segmentB) { const {distA, distB} = findClosestPointsFromLineToLine( segmentA.start, segmentA.dir, segmentB.start, segmentB.dir); const isDistAInBounds = distA >= 0 && distA <= 1; const isDistBInBounds = distB >= 0 && distB <= 1; if (isDistAInBounds) { if (isDistBInBounds) { // The distances along both line segments are within bounds. vec3.scaleAndAdd(closestA, segmentA.start, segmentA.dir, distA); vec3.scaleAndAdd(closestB, segmentB.start, segmentB.dir, distB); } else { // Only the distance along the first line segment is within bounds. if (distB < 0) { vec3.copy(closestB, segmentB.start); } else { vec3.copy(closestB, segmentB.end); } findClosestPointOnSegmentToPoint(closestA, segmentA, closestB); } } else { if (isDistBInBounds) { // Only the distance along the second line segment is within bounds. if (distA < 0) { vec3.copy(closestA, segmentA.start); } else { vec3.copy(closestA, segmentA.end); } findClosestPointOnSegmentToPoint(closestB, segmentB, closestA); } else { // Neither of the distances along either line segment are within bounds. if (distA < 0) { vec3.copy(closestA, segmentA.start); } else { vec3.copy(closestA, segmentA.end); } if (distB < 0) { vec3.copy(closestB, segmentB.start); } else { vec3.copy(closestB, segmentB.end); } const altClosestA = vec3.create(); const altClosestB = vec3.create(); findClosestPointOnSegmentToPoint(altClosestA, segmentA, closestB); findClosestPointOnSegmentToPoint(altClosestB, segmentB, closestA); if (vec3.squaredDistance(altClosestA, closestB) < vec3.squaredDistance(altClosestB, closestA)) { vec3.copy(closestA, altClosestA); } else { vec3.copy(closestB, altClosestB); } } } }
javascript
function findClosestPointsFromSegmentToSegment(closestA, closestB, segmentA, segmentB) { const {distA, distB} = findClosestPointsFromLineToLine( segmentA.start, segmentA.dir, segmentB.start, segmentB.dir); const isDistAInBounds = distA >= 0 && distA <= 1; const isDistBInBounds = distB >= 0 && distB <= 1; if (isDistAInBounds) { if (isDistBInBounds) { // The distances along both line segments are within bounds. vec3.scaleAndAdd(closestA, segmentA.start, segmentA.dir, distA); vec3.scaleAndAdd(closestB, segmentB.start, segmentB.dir, distB); } else { // Only the distance along the first line segment is within bounds. if (distB < 0) { vec3.copy(closestB, segmentB.start); } else { vec3.copy(closestB, segmentB.end); } findClosestPointOnSegmentToPoint(closestA, segmentA, closestB); } } else { if (isDistBInBounds) { // Only the distance along the second line segment is within bounds. if (distA < 0) { vec3.copy(closestA, segmentA.start); } else { vec3.copy(closestA, segmentA.end); } findClosestPointOnSegmentToPoint(closestB, segmentB, closestA); } else { // Neither of the distances along either line segment are within bounds. if (distA < 0) { vec3.copy(closestA, segmentA.start); } else { vec3.copy(closestA, segmentA.end); } if (distB < 0) { vec3.copy(closestB, segmentB.start); } else { vec3.copy(closestB, segmentB.end); } const altClosestA = vec3.create(); const altClosestB = vec3.create(); findClosestPointOnSegmentToPoint(altClosestA, segmentA, closestB); findClosestPointOnSegmentToPoint(altClosestB, segmentB, closestA); if (vec3.squaredDistance(altClosestA, closestB) < vec3.squaredDistance(altClosestB, closestA)) { vec3.copy(closestA, altClosestA); } else { vec3.copy(closestB, altClosestB); } } } }
[ "function", "findClosestPointsFromSegmentToSegment", "(", "closestA", ",", "closestB", ",", "segmentA", ",", "segmentB", ")", "{", "const", "{", "distA", ",", "distB", "}", "=", "findClosestPointsFromLineToLine", "(", "segmentA", ".", "start", ",", "segmentA", ".", "dir", ",", "segmentB", ".", "start", ",", "segmentB", ".", "dir", ")", ";", "const", "isDistAInBounds", "=", "distA", ">=", "0", "&&", "distA", "<=", "1", ";", "const", "isDistBInBounds", "=", "distB", ">=", "0", "&&", "distB", "<=", "1", ";", "if", "(", "isDistAInBounds", ")", "{", "if", "(", "isDistBInBounds", ")", "{", "// The distances along both line segments are within bounds.", "vec3", ".", "scaleAndAdd", "(", "closestA", ",", "segmentA", ".", "start", ",", "segmentA", ".", "dir", ",", "distA", ")", ";", "vec3", ".", "scaleAndAdd", "(", "closestB", ",", "segmentB", ".", "start", ",", "segmentB", ".", "dir", ",", "distB", ")", ";", "}", "else", "{", "// Only the distance along the first line segment is within bounds.", "if", "(", "distB", "<", "0", ")", "{", "vec3", ".", "copy", "(", "closestB", ",", "segmentB", ".", "start", ")", ";", "}", "else", "{", "vec3", ".", "copy", "(", "closestB", ",", "segmentB", ".", "end", ")", ";", "}", "findClosestPointOnSegmentToPoint", "(", "closestA", ",", "segmentA", ",", "closestB", ")", ";", "}", "}", "else", "{", "if", "(", "isDistBInBounds", ")", "{", "// Only the distance along the second line segment is within bounds.", "if", "(", "distA", "<", "0", ")", "{", "vec3", ".", "copy", "(", "closestA", ",", "segmentA", ".", "start", ")", ";", "}", "else", "{", "vec3", ".", "copy", "(", "closestA", ",", "segmentA", ".", "end", ")", ";", "}", "findClosestPointOnSegmentToPoint", "(", "closestB", ",", "segmentB", ",", "closestA", ")", ";", "}", "else", "{", "// Neither of the distances along either line segment are within bounds.", "if", "(", "distA", "<", "0", ")", "{", "vec3", ".", "copy", "(", "closestA", ",", "segmentA", ".", "start", ")", ";", "}", "else", "{", "vec3", ".", "copy", "(", "closestA", ",", "segmentA", ".", "end", ")", ";", "}", "if", "(", "distB", "<", "0", ")", "{", "vec3", ".", "copy", "(", "closestB", ",", "segmentB", ".", "start", ")", ";", "}", "else", "{", "vec3", ".", "copy", "(", "closestB", ",", "segmentB", ".", "end", ")", ";", "}", "const", "altClosestA", "=", "vec3", ".", "create", "(", ")", ";", "const", "altClosestB", "=", "vec3", ".", "create", "(", ")", ";", "findClosestPointOnSegmentToPoint", "(", "altClosestA", ",", "segmentA", ",", "closestB", ")", ";", "findClosestPointOnSegmentToPoint", "(", "altClosestB", ",", "segmentB", ",", "closestA", ")", ";", "if", "(", "vec3", ".", "squaredDistance", "(", "altClosestA", ",", "closestB", ")", "<", "vec3", ".", "squaredDistance", "(", "altClosestB", ",", "closestA", ")", ")", "{", "vec3", ".", "copy", "(", "closestA", ",", "altClosestA", ")", ";", "}", "else", "{", "vec3", ".", "copy", "(", "closestB", ",", "altClosestB", ")", ";", "}", "}", "}", "}" ]
Finds the closest position on one line segment to the other line segment, and vice versa. ---------------------------------------------------------------------------- Originally based on Jukka Jylänki's algorithm at https://github.com/juj/MathGeoLib/blob/ff2d348a167008c831ae304483b824647f71fbf6/src/Geometry/LineSegment.cpp. Copyright 2011 Jukka Jylänki Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---------------------------------------------------------------------------- @param {vec3} closestA Output param. @param {vec3} closestB Output param. @param {LineSegment} segmentA @param {LineSegment} segmentB
[ "Finds", "the", "closest", "position", "on", "one", "line", "segment", "to", "the", "other", "line", "segment", "and", "vice", "versa", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L266-L324
47,636
levilindsey/physx
src/util/src/geometry.js
findClosestPointOnSegmentToPoint
function findClosestPointOnSegmentToPoint(closestPoint, segment, point) { const dirSquaredLength = vec3.squaredLength(segment.dir); if (!dirSquaredLength) { // The point is at the segment start. vec3.copy(closestPoint, segment.start); } else { // Calculate the projection of the point onto the line extending through the segment. vec3.subtract(_tmpVec1, point, segment.start); const t = vec3.dot(_tmpVec1, segment.dir) / dirSquaredLength; if (t < 0) { // The point projects beyond the segment start. vec3.copy(closestPoint, segment.start); } else if (t > 1) { // The point projects beyond the segment end. vec3.copy(closestPoint, segment.end); } else { // The point projects between the start and end of the segment. vec3.scaleAndAdd(closestPoint, segment.start, segment.dir, t); } } }
javascript
function findClosestPointOnSegmentToPoint(closestPoint, segment, point) { const dirSquaredLength = vec3.squaredLength(segment.dir); if (!dirSquaredLength) { // The point is at the segment start. vec3.copy(closestPoint, segment.start); } else { // Calculate the projection of the point onto the line extending through the segment. vec3.subtract(_tmpVec1, point, segment.start); const t = vec3.dot(_tmpVec1, segment.dir) / dirSquaredLength; if (t < 0) { // The point projects beyond the segment start. vec3.copy(closestPoint, segment.start); } else if (t > 1) { // The point projects beyond the segment end. vec3.copy(closestPoint, segment.end); } else { // The point projects between the start and end of the segment. vec3.scaleAndAdd(closestPoint, segment.start, segment.dir, t); } } }
[ "function", "findClosestPointOnSegmentToPoint", "(", "closestPoint", ",", "segment", ",", "point", ")", "{", "const", "dirSquaredLength", "=", "vec3", ".", "squaredLength", "(", "segment", ".", "dir", ")", ";", "if", "(", "!", "dirSquaredLength", ")", "{", "// The point is at the segment start.", "vec3", ".", "copy", "(", "closestPoint", ",", "segment", ".", "start", ")", ";", "}", "else", "{", "// Calculate the projection of the point onto the line extending through the segment.", "vec3", ".", "subtract", "(", "_tmpVec1", ",", "point", ",", "segment", ".", "start", ")", ";", "const", "t", "=", "vec3", ".", "dot", "(", "_tmpVec1", ",", "segment", ".", "dir", ")", "/", "dirSquaredLength", ";", "if", "(", "t", "<", "0", ")", "{", "// The point projects beyond the segment start.", "vec3", ".", "copy", "(", "closestPoint", ",", "segment", ".", "start", ")", ";", "}", "else", "if", "(", "t", ">", "1", ")", "{", "// The point projects beyond the segment end.", "vec3", ".", "copy", "(", "closestPoint", ",", "segment", ".", "end", ")", ";", "}", "else", "{", "// The point projects between the start and end of the segment.", "vec3", ".", "scaleAndAdd", "(", "closestPoint", ",", "segment", ".", "start", ",", "segment", ".", "dir", ",", "t", ")", ";", "}", "}", "}" ]
Finds the closest position on a line segment to a point. ---------------------------------------------------------------------------- Originally based on Jukka Jylänki's algorithm at https://github.com/juj/MathGeoLib/blob/ff2d348a167008c831ae304483b824647f71fbf6/src/Geometry/LineSegment.cpp. Copyright 2011 Jukka Jylänki Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---------------------------------------------------------------------------- @param {vec3} closestPoint Output param. @param {LineSegment} segment @param {vec3} point @private
[ "Finds", "the", "closest", "position", "on", "a", "line", "segment", "to", "a", "point", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L353-L375
47,637
levilindsey/physx
src/util/src/geometry.js
findClosestPointsFromLineToLine
function findClosestPointsFromLineToLine(startA, dirA, startB, dirB) { vec3.subtract(_tmpVec1, startA, startB); const dirBDotDirAToB = vec3.dot(dirB, _tmpVec1); const dirADotDirAToB = vec3.dot(dirA, _tmpVec1); const sqrLenDirB = vec3.squaredLength(dirB); const sqrLenDirA = vec3.squaredLength(dirA); const dirADotDirB = vec3.dot(dirA, dirB); const denominator = sqrLenDirA * sqrLenDirB - dirADotDirB * dirADotDirB; const distA = denominator < EPSILON ? 0 : (dirADotDirB * dirBDotDirAToB - sqrLenDirB * dirADotDirAToB) / denominator; const distB = (dirBDotDirAToB + dirADotDirB * distA) / sqrLenDirB; return { distA: distA, distB: distB }; }
javascript
function findClosestPointsFromLineToLine(startA, dirA, startB, dirB) { vec3.subtract(_tmpVec1, startA, startB); const dirBDotDirAToB = vec3.dot(dirB, _tmpVec1); const dirADotDirAToB = vec3.dot(dirA, _tmpVec1); const sqrLenDirB = vec3.squaredLength(dirB); const sqrLenDirA = vec3.squaredLength(dirA); const dirADotDirB = vec3.dot(dirA, dirB); const denominator = sqrLenDirA * sqrLenDirB - dirADotDirB * dirADotDirB; const distA = denominator < EPSILON ? 0 : (dirADotDirB * dirBDotDirAToB - sqrLenDirB * dirADotDirAToB) / denominator; const distB = (dirBDotDirAToB + dirADotDirB * distA) / sqrLenDirB; return { distA: distA, distB: distB }; }
[ "function", "findClosestPointsFromLineToLine", "(", "startA", ",", "dirA", ",", "startB", ",", "dirB", ")", "{", "vec3", ".", "subtract", "(", "_tmpVec1", ",", "startA", ",", "startB", ")", ";", "const", "dirBDotDirAToB", "=", "vec3", ".", "dot", "(", "dirB", ",", "_tmpVec1", ")", ";", "const", "dirADotDirAToB", "=", "vec3", ".", "dot", "(", "dirA", ",", "_tmpVec1", ")", ";", "const", "sqrLenDirB", "=", "vec3", ".", "squaredLength", "(", "dirB", ")", ";", "const", "sqrLenDirA", "=", "vec3", ".", "squaredLength", "(", "dirA", ")", ";", "const", "dirADotDirB", "=", "vec3", ".", "dot", "(", "dirA", ",", "dirB", ")", ";", "const", "denominator", "=", "sqrLenDirA", "*", "sqrLenDirB", "-", "dirADotDirB", "*", "dirADotDirB", ";", "const", "distA", "=", "denominator", "<", "EPSILON", "?", "0", ":", "(", "dirADotDirB", "*", "dirBDotDirAToB", "-", "sqrLenDirB", "*", "dirADotDirAToB", ")", "/", "denominator", ";", "const", "distB", "=", "(", "dirBDotDirAToB", "+", "dirADotDirB", "*", "distA", ")", "/", "sqrLenDirB", ";", "return", "{", "distA", ":", "distA", ",", "distB", ":", "distB", "}", ";", "}" ]
Finds the closest position on one line to the other line, and vice versa. The positions are represented as scalar-value distances from the "start" positions of each line. These are scaled according to the given direction vectors. ---------------------------------------------------------------------------- Originally based on Jukka Jylänki's algorithm at https://github.com/juj/MathGeoLib/blob/ff2d348a167008c831ae304483b824647f71fbf6/src/Geometry/Line.cpp. Copyright 2011 Jukka Jylänki Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---------------------------------------------------------------------------- @param {vec3} startA The start position of line A. @param {vec3} dirA The (unnormalized) direction of line A. Cannot be zero. @param {vec3} startB The start position of line B. @param {vec3} dirB The (unnormalized) direction of line B. Cannot be zero. @returns {{distA: Number, distB: Number}}
[ "Finds", "the", "closest", "position", "on", "one", "line", "to", "the", "other", "line", "and", "vice", "versa", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/util/src/geometry.js#L408-L429
47,638
levilindsey/physx
src/collisions/src/collision-handler.js
handleCollisionsForJob
function handleCollisionsForJob(job, elapsedTime, physicsParams) { const collidable = job.collidable; // Clear any previous collision info. collidable.previousCollisions = collidable.collisions; collidable.collisions = []; // Find all colliding collidables. const collidingCollidables = findIntersectingCollidablesForCollidable(collidable); // Store the time of collision for each collision. const collisions = _recordCollisions(collidable, collidingCollidables, elapsedTime); // Calculate the points of contact for each collision. _calculatePointsOfContact(collisions); // Collision resolution. _resolveCollisions(collisions, physicsParams); }
javascript
function handleCollisionsForJob(job, elapsedTime, physicsParams) { const collidable = job.collidable; // Clear any previous collision info. collidable.previousCollisions = collidable.collisions; collidable.collisions = []; // Find all colliding collidables. const collidingCollidables = findIntersectingCollidablesForCollidable(collidable); // Store the time of collision for each collision. const collisions = _recordCollisions(collidable, collidingCollidables, elapsedTime); // Calculate the points of contact for each collision. _calculatePointsOfContact(collisions); // Collision resolution. _resolveCollisions(collisions, physicsParams); }
[ "function", "handleCollisionsForJob", "(", "job", ",", "elapsedTime", ",", "physicsParams", ")", "{", "const", "collidable", "=", "job", ".", "collidable", ";", "// Clear any previous collision info.", "collidable", ".", "previousCollisions", "=", "collidable", ".", "collisions", ";", "collidable", ".", "collisions", "=", "[", "]", ";", "// Find all colliding collidables.", "const", "collidingCollidables", "=", "findIntersectingCollidablesForCollidable", "(", "collidable", ")", ";", "// Store the time of collision for each collision.", "const", "collisions", "=", "_recordCollisions", "(", "collidable", ",", "collidingCollidables", ",", "elapsedTime", ")", ";", "// Calculate the points of contact for each collision.", "_calculatePointsOfContact", "(", "collisions", ")", ";", "// Collision resolution.", "_resolveCollisions", "(", "collisions", ",", "physicsParams", ")", ";", "}" ]
This module defines a collision pipeline. These functions will detect collisions between collidable bodies and update their momenta in response to the collisions. - Consists of an efficient broad-phase collision detection step followed by a precise narrow-phase step. - Calculates the position, surface normal, and time of each contact. - Calculates the impulse of a collision and updates the bodies' linear and angular momenta in response. - Applies Coulomb friction to colliding bodies. - Sub-divides the time step to more precisely determine when and where a collision occurs. - Supports multiple collisions with a single body in a single time step. - Efficiently supports bodies coming to rest against each other. - Bodies will never penetrate one another. - This does not address the tunnelling problem. That is, it is possible for two fast-moving bodies to pass through each other as long as they did not intersect each other during any time step. - This only supports collisions between certain types of shapes. Fortunately, this set provides reasonable approximations for most other shapes. The supported types of shapes are: spheres, capsules, AABBs, and OBBs. ## Objects that come to rest An important efficiency improvement is to not process objects through the physics engine pipeline after they have come to rest. The isAtRest field indicates when a body has come to rest. isAtRest is set to true after a physics frame is finished if the collisions, forces, position, and orientation of a job have not changed from the previous to the current state. isAtRest is set to false from two possible events: after a physics frame is finished if the collisions have changed from the previous to the current state, or when a force is added to removed from the job. ## Collision calculations do not consider velocity Collision detection works by waiting until two bodies intersect. However, because time frames are not infinitely small, when an intersection is detected, it's already past the exact instance of collision. To alleviate problems from this, the velocity of each body can be considered when calculating the collision time, position, and contact normal. However, taking velocity into account makes the contact calculations much more complex, so we do not consider velocity in our calculations. A notable consequence of this is that the calculated contact normals can be incorrect. Consider the following moving squares. At time t2 they are found to have collided. The calculated contact point will be somewhere within the intersection of the corners. But the calculated contact normal will point upwards, while the true contact normal should point to the right. This is because the contact calculations do not consider velocity and instead only consider the shallowest direction of overlap. // Time t1 +------------+ | | | | <-- | B | | | +------------+ | | | | +------------+ | | | A | --> | | | | +------------+ // Time t2 +------------+ | | | | | B | | | +------------+ | | +-----|------+ | | | A | | | | | +------------+ Detect and handle any collisions between a given job and all other collidable bodies. @param {CollidablePhysicsJob} job @param {DOMHighResTimeStamp} elapsedTime @param {PhysicsConfig} physicsParams
[ "This", "module", "defines", "a", "collision", "pipeline", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L99-L117
47,639
levilindsey/physx
src/collisions/src/collision-handler.js
checkThatNoObjectsCollide
function checkThatNoObjectsCollide() { // Broad-phase collision detection (pairs whose bounding volumes intersect). let collisions = collidableStore.getPossibleCollisionsForAllCollidables(); // Narrow-phase collision detection (pairs that actually intersect). collisions = _detectPreciseCollisionsFromCollisions(collisions); collisions.forEach(collision => { console.warn('Objects still intersect after collision resolution', collision); }); }
javascript
function checkThatNoObjectsCollide() { // Broad-phase collision detection (pairs whose bounding volumes intersect). let collisions = collidableStore.getPossibleCollisionsForAllCollidables(); // Narrow-phase collision detection (pairs that actually intersect). collisions = _detectPreciseCollisionsFromCollisions(collisions); collisions.forEach(collision => { console.warn('Objects still intersect after collision resolution', collision); }); }
[ "function", "checkThatNoObjectsCollide", "(", ")", "{", "// Broad-phase collision detection (pairs whose bounding volumes intersect).", "let", "collisions", "=", "collidableStore", ".", "getPossibleCollisionsForAllCollidables", "(", ")", ";", "// Narrow-phase collision detection (pairs that actually intersect).", "collisions", "=", "_detectPreciseCollisionsFromCollisions", "(", "collisions", ")", ";", "collisions", ".", "forEach", "(", "collision", "=>", "{", "console", ".", "warn", "(", "'Objects still intersect after collision resolution'", ",", "collision", ")", ";", "}", ")", ";", "}" ]
Logs a warning message for any pair of objects that intersect.
[ "Logs", "a", "warning", "message", "for", "any", "pair", "of", "objects", "that", "intersect", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L147-L157
47,640
levilindsey/physx
src/collisions/src/collision-handler.js
_recordCollisions
function _recordCollisions(collidable, collidingCollidables, elapsedTime) { return collidingCollidables.map(other => { const collision = { collidableA: collidable, collidableB: other, time: elapsedTime }; // Record the fact that these objects collided (the ModelController may want to handle this). collision.collidableA.collisions.push(collision); collision.collidableB.collisions.push(collision); return collision; }); }
javascript
function _recordCollisions(collidable, collidingCollidables, elapsedTime) { return collidingCollidables.map(other => { const collision = { collidableA: collidable, collidableB: other, time: elapsedTime }; // Record the fact that these objects collided (the ModelController may want to handle this). collision.collidableA.collisions.push(collision); collision.collidableB.collisions.push(collision); return collision; }); }
[ "function", "_recordCollisions", "(", "collidable", ",", "collidingCollidables", ",", "elapsedTime", ")", "{", "return", "collidingCollidables", ".", "map", "(", "other", "=>", "{", "const", "collision", "=", "{", "collidableA", ":", "collidable", ",", "collidableB", ":", "other", ",", "time", ":", "elapsedTime", "}", ";", "// Record the fact that these objects collided (the ModelController may want to handle this).", "collision", ".", "collidableA", ".", "collisions", ".", "push", "(", "collision", ")", ";", "collision", ".", "collidableB", ".", "collisions", ".", "push", "(", "collision", ")", ";", "return", "collision", ";", "}", ")", ";", "}" ]
Create collision objects that record the time of collision and the collidables in the collision. Also record references to these collisions on the collidables. @param {Collidable} collidable @param {Array.<Collidable>} collidingCollidables @param {DOMHighResTimeStamp} elapsedTime @returns {Array.<Collision>} @private
[ "Create", "collision", "objects", "that", "record", "the", "time", "of", "collision", "and", "the", "collidables", "in", "the", "collision", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L170-L184
47,641
levilindsey/physx
src/collisions/src/collision-handler.js
_detectPreciseCollisionsFromCollisions
function _detectPreciseCollisionsFromCollisions(collisions) { return collisions.filter(collision => { // TODO: // - Use temporal bisection with discrete sub-time steps to find time of collision (use // x-vs-y-specific intersection detection methods). // - Make sure the collision object is set up with the "previousState" from the sub-step // before collision and the time from the sub-step after collision (determined from the // previous temporal bisection search...) return detectIntersection(collision.collidableA, collision.collidableB); }); }
javascript
function _detectPreciseCollisionsFromCollisions(collisions) { return collisions.filter(collision => { // TODO: // - Use temporal bisection with discrete sub-time steps to find time of collision (use // x-vs-y-specific intersection detection methods). // - Make sure the collision object is set up with the "previousState" from the sub-step // before collision and the time from the sub-step after collision (determined from the // previous temporal bisection search...) return detectIntersection(collision.collidableA, collision.collidableB); }); }
[ "function", "_detectPreciseCollisionsFromCollisions", "(", "collisions", ")", "{", "return", "collisions", ".", "filter", "(", "collision", "=>", "{", "// TODO:", "// - Use temporal bisection with discrete sub-time steps to find time of collision (use", "// x-vs-y-specific intersection detection methods).", "// - Make sure the collision object is set up with the \"previousState\" from the sub-step", "// before collision and the time from the sub-step after collision (determined from the", "// previous temporal bisection search...)", "return", "detectIntersection", "(", "collision", ".", "collidableA", ",", "collision", ".", "collidableB", ")", ";", "}", ")", ";", "}" ]
Narrow-phase collision detection. Given a list of possible collision pairs, filter out which pairs are actually colliding. @param {Array.<Collision>} collisions @returns {Array.<Collision>} @private
[ "Narrow", "-", "phase", "collision", "detection", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L195-L206
47,642
levilindsey/physx
src/collisions/src/collision-handler.js
_resolveCollisions
function _resolveCollisions(collisions, physicsParams) { collisions.forEach(collision => { // If neither physics job needs the standard collision restitution, then don't do it. if (_notifyPhysicsJobsOfCollision(collision)) { if (collision.collidableA.physicsJob && collision.collidableB.physicsJob) { // Neither of the collidables is stationary. _resolveCollision(collision, physicsParams); } else { // One of the two collidables is stationary. _resolveCollisionWithStationaryObject(collision, physicsParams); } } }); }
javascript
function _resolveCollisions(collisions, physicsParams) { collisions.forEach(collision => { // If neither physics job needs the standard collision restitution, then don't do it. if (_notifyPhysicsJobsOfCollision(collision)) { if (collision.collidableA.physicsJob && collision.collidableB.physicsJob) { // Neither of the collidables is stationary. _resolveCollision(collision, physicsParams); } else { // One of the two collidables is stationary. _resolveCollisionWithStationaryObject(collision, physicsParams); } } }); }
[ "function", "_resolveCollisions", "(", "collisions", ",", "physicsParams", ")", "{", "collisions", ".", "forEach", "(", "collision", "=>", "{", "// If neither physics job needs the standard collision restitution, then don't do it.", "if", "(", "_notifyPhysicsJobsOfCollision", "(", "collision", ")", ")", "{", "if", "(", "collision", ".", "collidableA", ".", "physicsJob", "&&", "collision", ".", "collidableB", ".", "physicsJob", ")", "{", "// Neither of the collidables is stationary.", "_resolveCollision", "(", "collision", ",", "physicsParams", ")", ";", "}", "else", "{", "// One of the two collidables is stationary.", "_resolveCollisionWithStationaryObject", "(", "collision", ",", "physicsParams", ")", ";", "}", "}", "}", ")", ";", "}" ]
Updates the linear and angular momenta of each body in response to its collision. @param {Array.<Collision>} collisions @param {PhysicsConfig} physicsParams @private
[ "Updates", "the", "linear", "and", "angular", "momenta", "of", "each", "body", "in", "response", "to", "its", "collision", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L248-L261
47,643
levilindsey/physx
src/collisions/src/collision-handler.js
_resolveCollision
function _resolveCollision(collision, physicsParams) { const collidableA = collision.collidableA; const collidableB = collision.collidableB; const previousStateA = collidableA.physicsJob.previousState; const previousStateB = collidableB.physicsJob.previousState; const nextStateA = collidableA.physicsJob.currentState; const nextStateB = collidableB.physicsJob.currentState; const centerA = collidableA.centerOfMass; const centerB = collidableB.centerOfMass; const contactPoint = collision.contactPoint; const contactPointOffsetA = tmpVec3; vec3.subtract(contactPointOffsetA, contactPoint, centerA); const contactPointOffsetB = tmpVec4; vec3.subtract(contactPointOffsetB, contactPoint, centerB); // // Calculate the relative velocity of the bodies at the point of contact. // // We use the velocity from the previous state, since it is the velocity that led to the // collision. // const velocityA = tmpVec1; vec3.cross(tmpVec1, previousStateA.angularVelocity, contactPointOffsetA); vec3.add(velocityA, previousStateA.velocity, tmpVec1); const velocityB = tmpVec2; vec3.cross(tmpVec2, previousStateB.angularVelocity, contactPointOffsetB); vec3.add(velocityB, previousStateB.velocity, tmpVec2); const relativeVelocity = vec3.create(); vec3.subtract(relativeVelocity, velocityB, velocityA); if (vec3.dot(relativeVelocity, collision.contactNormal) >= 0) { // If the relative velocity is not pointing against the normal, then the normal was calculated // incorrectly (this is likely due to the time step being too large and the fact that our // contact calculations don't consider velocity). So update the contact normal to be in the // direction of the relative velocity. // TODO: Check that this works as expected. // console.warn('Non-collision because objects are moving away from each other.'); vec3.copy(collision.contactNormal, relativeVelocity); vec3.normalize(collision.contactNormal, collision.contactNormal); vec3.negate(collision.contactNormal, collision.contactNormal); } _applyImpulseFromCollision(collision, relativeVelocity, contactPointOffsetA, contactPointOffsetB, physicsParams); // NOTE: This state reversion is only applied to collidableA. This assumes that only A is moving // during this iteration of the collision pipeline. // Revert to the position and orientation from immediately before the collision. vec3.copy(nextStateA.position, previousStateA.position); quat.copy(nextStateA.orientation, previousStateA.orientation); // Also revert the collidables' position and orientation. collidableA.position = previousStateA.position; collidableA.orientation = previousStateA.orientation; nextStateA.updateDependentFields(); nextStateB.updateDependentFields(); }
javascript
function _resolveCollision(collision, physicsParams) { const collidableA = collision.collidableA; const collidableB = collision.collidableB; const previousStateA = collidableA.physicsJob.previousState; const previousStateB = collidableB.physicsJob.previousState; const nextStateA = collidableA.physicsJob.currentState; const nextStateB = collidableB.physicsJob.currentState; const centerA = collidableA.centerOfMass; const centerB = collidableB.centerOfMass; const contactPoint = collision.contactPoint; const contactPointOffsetA = tmpVec3; vec3.subtract(contactPointOffsetA, contactPoint, centerA); const contactPointOffsetB = tmpVec4; vec3.subtract(contactPointOffsetB, contactPoint, centerB); // // Calculate the relative velocity of the bodies at the point of contact. // // We use the velocity from the previous state, since it is the velocity that led to the // collision. // const velocityA = tmpVec1; vec3.cross(tmpVec1, previousStateA.angularVelocity, contactPointOffsetA); vec3.add(velocityA, previousStateA.velocity, tmpVec1); const velocityB = tmpVec2; vec3.cross(tmpVec2, previousStateB.angularVelocity, contactPointOffsetB); vec3.add(velocityB, previousStateB.velocity, tmpVec2); const relativeVelocity = vec3.create(); vec3.subtract(relativeVelocity, velocityB, velocityA); if (vec3.dot(relativeVelocity, collision.contactNormal) >= 0) { // If the relative velocity is not pointing against the normal, then the normal was calculated // incorrectly (this is likely due to the time step being too large and the fact that our // contact calculations don't consider velocity). So update the contact normal to be in the // direction of the relative velocity. // TODO: Check that this works as expected. // console.warn('Non-collision because objects are moving away from each other.'); vec3.copy(collision.contactNormal, relativeVelocity); vec3.normalize(collision.contactNormal, collision.contactNormal); vec3.negate(collision.contactNormal, collision.contactNormal); } _applyImpulseFromCollision(collision, relativeVelocity, contactPointOffsetA, contactPointOffsetB, physicsParams); // NOTE: This state reversion is only applied to collidableA. This assumes that only A is moving // during this iteration of the collision pipeline. // Revert to the position and orientation from immediately before the collision. vec3.copy(nextStateA.position, previousStateA.position); quat.copy(nextStateA.orientation, previousStateA.orientation); // Also revert the collidables' position and orientation. collidableA.position = previousStateA.position; collidableA.orientation = previousStateA.orientation; nextStateA.updateDependentFields(); nextStateB.updateDependentFields(); }
[ "function", "_resolveCollision", "(", "collision", ",", "physicsParams", ")", "{", "const", "collidableA", "=", "collision", ".", "collidableA", ";", "const", "collidableB", "=", "collision", ".", "collidableB", ";", "const", "previousStateA", "=", "collidableA", ".", "physicsJob", ".", "previousState", ";", "const", "previousStateB", "=", "collidableB", ".", "physicsJob", ".", "previousState", ";", "const", "nextStateA", "=", "collidableA", ".", "physicsJob", ".", "currentState", ";", "const", "nextStateB", "=", "collidableB", ".", "physicsJob", ".", "currentState", ";", "const", "centerA", "=", "collidableA", ".", "centerOfMass", ";", "const", "centerB", "=", "collidableB", ".", "centerOfMass", ";", "const", "contactPoint", "=", "collision", ".", "contactPoint", ";", "const", "contactPointOffsetA", "=", "tmpVec3", ";", "vec3", ".", "subtract", "(", "contactPointOffsetA", ",", "contactPoint", ",", "centerA", ")", ";", "const", "contactPointOffsetB", "=", "tmpVec4", ";", "vec3", ".", "subtract", "(", "contactPointOffsetB", ",", "contactPoint", ",", "centerB", ")", ";", "//", "// Calculate the relative velocity of the bodies at the point of contact.", "//", "// We use the velocity from the previous state, since it is the velocity that led to the", "// collision.", "//", "const", "velocityA", "=", "tmpVec1", ";", "vec3", ".", "cross", "(", "tmpVec1", ",", "previousStateA", ".", "angularVelocity", ",", "contactPointOffsetA", ")", ";", "vec3", ".", "add", "(", "velocityA", ",", "previousStateA", ".", "velocity", ",", "tmpVec1", ")", ";", "const", "velocityB", "=", "tmpVec2", ";", "vec3", ".", "cross", "(", "tmpVec2", ",", "previousStateB", ".", "angularVelocity", ",", "contactPointOffsetB", ")", ";", "vec3", ".", "add", "(", "velocityB", ",", "previousStateB", ".", "velocity", ",", "tmpVec2", ")", ";", "const", "relativeVelocity", "=", "vec3", ".", "create", "(", ")", ";", "vec3", ".", "subtract", "(", "relativeVelocity", ",", "velocityB", ",", "velocityA", ")", ";", "if", "(", "vec3", ".", "dot", "(", "relativeVelocity", ",", "collision", ".", "contactNormal", ")", ">=", "0", ")", "{", "// If the relative velocity is not pointing against the normal, then the normal was calculated", "// incorrectly (this is likely due to the time step being too large and the fact that our", "// contact calculations don't consider velocity). So update the contact normal to be in the", "// direction of the relative velocity.", "// TODO: Check that this works as expected.", "// console.warn('Non-collision because objects are moving away from each other.');", "vec3", ".", "copy", "(", "collision", ".", "contactNormal", ",", "relativeVelocity", ")", ";", "vec3", ".", "normalize", "(", "collision", ".", "contactNormal", ",", "collision", ".", "contactNormal", ")", ";", "vec3", ".", "negate", "(", "collision", ".", "contactNormal", ",", "collision", ".", "contactNormal", ")", ";", "}", "_applyImpulseFromCollision", "(", "collision", ",", "relativeVelocity", ",", "contactPointOffsetA", ",", "contactPointOffsetB", ",", "physicsParams", ")", ";", "// NOTE: This state reversion is only applied to collidableA. This assumes that only A is moving", "// during this iteration of the collision pipeline.", "// Revert to the position and orientation from immediately before the collision.", "vec3", ".", "copy", "(", "nextStateA", ".", "position", ",", "previousStateA", ".", "position", ")", ";", "quat", ".", "copy", "(", "nextStateA", ".", "orientation", ",", "previousStateA", ".", "orientation", ")", ";", "// Also revert the collidables' position and orientation.", "collidableA", ".", "position", "=", "previousStateA", ".", "position", ";", "collidableA", ".", "orientation", "=", "previousStateA", ".", "orientation", ";", "nextStateA", ".", "updateDependentFields", "(", ")", ";", "nextStateB", ".", "updateDependentFields", "(", ")", ";", "}" ]
Resolve a collision between two moving, physics-based objects. This is based on collision-response algorithms from Wikipedia (https://en.wikipedia.org/wiki/Collision_response#Impulse-based_reaction_model). @param {Collision} collision @param {PhysicsConfig} physicsParams @private
[ "Resolve", "a", "collision", "between", "two", "moving", "physics", "-", "based", "objects", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L284-L349
47,644
levilindsey/physx
src/collisions/src/collision-handler.js
_resolveCollisionWithStationaryObject
function _resolveCollisionWithStationaryObject(collision, physicsParams) { const contactNormal = collision.contactNormal; let physicsCollidable; if (collision.collidableA.physicsJob) { physicsCollidable = collision.collidableA; } else { physicsCollidable = collision.collidableB; vec3.negate(contactNormal, contactNormal); } const previousState = physicsCollidable.physicsJob.previousState; const nextState = physicsCollidable.physicsJob.currentState; const center = physicsCollidable.centerOfMass; const contactPoint = collision.contactPoint; const contactPointOffset = tmpVec3; vec3.subtract(contactPointOffset, contactPoint, center); // Calculate the relative velocity of the bodies at the point of contact. We use the velocity from // the previous state, since it is the velocity that led to the collision. const velocity = vec3.create(); vec3.cross(tmpVec1, previousState.angularVelocity, contactPointOffset); vec3.add(velocity, previousState.velocity, tmpVec1); if (vec3.dot(velocity, contactNormal) <= 0) { // If the relative velocity is not pointing against the normal, then the normal was calculated // incorrectly (this is likely due to the time step being too large and the fact that our // contact calculations don't consider velocity). So update the contact normal to be in the // direction of the relative velocity. // TODO: Check that this works as expected. console.warn('Non-collision because object is moving away from stationary object.'); vec3.copy(collision.contactNormal, velocity); vec3.normalize(collision.contactNormal, collision.contactNormal); vec3.negate(collision.contactNormal, collision.contactNormal); } _applyImpulseFromCollisionWithStationaryObject(physicsCollidable, collision, velocity, contactPointOffset, physicsParams); // Revert to the position and orientation from immediately before the collision. vec3.copy(nextState.position, previousState.position); quat.copy(nextState.orientation, previousState.orientation); // Also revert the collidable's position and orientation. physicsCollidable.position = previousState.position; physicsCollidable.orientation = previousState.orientation; nextState.updateDependentFields(); }
javascript
function _resolveCollisionWithStationaryObject(collision, physicsParams) { const contactNormal = collision.contactNormal; let physicsCollidable; if (collision.collidableA.physicsJob) { physicsCollidable = collision.collidableA; } else { physicsCollidable = collision.collidableB; vec3.negate(contactNormal, contactNormal); } const previousState = physicsCollidable.physicsJob.previousState; const nextState = physicsCollidable.physicsJob.currentState; const center = physicsCollidable.centerOfMass; const contactPoint = collision.contactPoint; const contactPointOffset = tmpVec3; vec3.subtract(contactPointOffset, contactPoint, center); // Calculate the relative velocity of the bodies at the point of contact. We use the velocity from // the previous state, since it is the velocity that led to the collision. const velocity = vec3.create(); vec3.cross(tmpVec1, previousState.angularVelocity, contactPointOffset); vec3.add(velocity, previousState.velocity, tmpVec1); if (vec3.dot(velocity, contactNormal) <= 0) { // If the relative velocity is not pointing against the normal, then the normal was calculated // incorrectly (this is likely due to the time step being too large and the fact that our // contact calculations don't consider velocity). So update the contact normal to be in the // direction of the relative velocity. // TODO: Check that this works as expected. console.warn('Non-collision because object is moving away from stationary object.'); vec3.copy(collision.contactNormal, velocity); vec3.normalize(collision.contactNormal, collision.contactNormal); vec3.negate(collision.contactNormal, collision.contactNormal); } _applyImpulseFromCollisionWithStationaryObject(physicsCollidable, collision, velocity, contactPointOffset, physicsParams); // Revert to the position and orientation from immediately before the collision. vec3.copy(nextState.position, previousState.position); quat.copy(nextState.orientation, previousState.orientation); // Also revert the collidable's position and orientation. physicsCollidable.position = previousState.position; physicsCollidable.orientation = previousState.orientation; nextState.updateDependentFields(); }
[ "function", "_resolveCollisionWithStationaryObject", "(", "collision", ",", "physicsParams", ")", "{", "const", "contactNormal", "=", "collision", ".", "contactNormal", ";", "let", "physicsCollidable", ";", "if", "(", "collision", ".", "collidableA", ".", "physicsJob", ")", "{", "physicsCollidable", "=", "collision", ".", "collidableA", ";", "}", "else", "{", "physicsCollidable", "=", "collision", ".", "collidableB", ";", "vec3", ".", "negate", "(", "contactNormal", ",", "contactNormal", ")", ";", "}", "const", "previousState", "=", "physicsCollidable", ".", "physicsJob", ".", "previousState", ";", "const", "nextState", "=", "physicsCollidable", ".", "physicsJob", ".", "currentState", ";", "const", "center", "=", "physicsCollidable", ".", "centerOfMass", ";", "const", "contactPoint", "=", "collision", ".", "contactPoint", ";", "const", "contactPointOffset", "=", "tmpVec3", ";", "vec3", ".", "subtract", "(", "contactPointOffset", ",", "contactPoint", ",", "center", ")", ";", "// Calculate the relative velocity of the bodies at the point of contact. We use the velocity from", "// the previous state, since it is the velocity that led to the collision.", "const", "velocity", "=", "vec3", ".", "create", "(", ")", ";", "vec3", ".", "cross", "(", "tmpVec1", ",", "previousState", ".", "angularVelocity", ",", "contactPointOffset", ")", ";", "vec3", ".", "add", "(", "velocity", ",", "previousState", ".", "velocity", ",", "tmpVec1", ")", ";", "if", "(", "vec3", ".", "dot", "(", "velocity", ",", "contactNormal", ")", "<=", "0", ")", "{", "// If the relative velocity is not pointing against the normal, then the normal was calculated", "// incorrectly (this is likely due to the time step being too large and the fact that our", "// contact calculations don't consider velocity). So update the contact normal to be in the", "// direction of the relative velocity.", "// TODO: Check that this works as expected.", "console", ".", "warn", "(", "'Non-collision because object is moving away from stationary object.'", ")", ";", "vec3", ".", "copy", "(", "collision", ".", "contactNormal", ",", "velocity", ")", ";", "vec3", ".", "normalize", "(", "collision", ".", "contactNormal", ",", "collision", ".", "contactNormal", ")", ";", "vec3", ".", "negate", "(", "collision", ".", "contactNormal", ",", "collision", ".", "contactNormal", ")", ";", "}", "_applyImpulseFromCollisionWithStationaryObject", "(", "physicsCollidable", ",", "collision", ",", "velocity", ",", "contactPointOffset", ",", "physicsParams", ")", ";", "// Revert to the position and orientation from immediately before the collision.", "vec3", ".", "copy", "(", "nextState", ".", "position", ",", "previousState", ".", "position", ")", ";", "quat", ".", "copy", "(", "nextState", ".", "orientation", ",", "previousState", ".", "orientation", ")", ";", "// Also revert the collidable's position and orientation.", "physicsCollidable", ".", "position", "=", "previousState", ".", "position", ";", "physicsCollidable", ".", "orientation", "=", "previousState", ".", "orientation", ";", "nextState", ".", "updateDependentFields", "(", ")", ";", "}" ]
Resolve a collision between one moving, physics-based object and one stationary object. @param {Collision} collision @param {PhysicsConfig} physicsParams @private
[ "Resolve", "a", "collision", "between", "one", "moving", "physics", "-", "based", "object", "and", "one", "stationary", "object", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-handler.js#L358-L410
47,645
mdreizin/webpack-config-stream
lib/proxyStream.js
proxyStream
function proxyStream(err, stats) { return through.obj(function(chunk, enc, cb) { processStats.call(this, chunk, stats); if (_.isError(err)) { this.emit('error', wrapError(err)); } cb(null, chunk); }); }
javascript
function proxyStream(err, stats) { return through.obj(function(chunk, enc, cb) { processStats.call(this, chunk, stats); if (_.isError(err)) { this.emit('error', wrapError(err)); } cb(null, chunk); }); }
[ "function", "proxyStream", "(", "err", ",", "stats", ")", "{", "return", "through", ".", "obj", "(", "function", "(", "chunk", ",", "enc", ",", "cb", ")", "{", "processStats", ".", "call", "(", "this", ",", "chunk", ",", "stats", ")", ";", "if", "(", "_", ".", "isError", "(", "err", ")", ")", "{", "this", ".", "emit", "(", "'error'", ",", "wrapError", "(", "err", ")", ")", ";", "}", "cb", "(", "null", ",", "chunk", ")", ";", "}", ")", ";", "}" ]
Re-uses existing `err` and `stats` objects. Can be piped. @function @alias proxyStream @param {Error=} err @param {Stats=} stats @returns {Stream}
[ "Re", "-", "uses", "existing", "err", "and", "stats", "objects", ".", "Can", "be", "piped", "." ]
f8424f97837a224bc07cc18a03ecf649d708e924
https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/proxyStream.js#L16-L26
47,646
verbose/verb-cli
bin/verb.js
run
function run(env) { console.log(); // empty line var verbfile = env.configPath; if (versionFlag && tasks.length === 0) { verbLog('CLI version', pkg.version); if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') { verbLog('Local version', env.modulePackage.version); } } // `node_modules/verb` if (!env.modulePath || !fs.existsSync(env.modulePath)) { /* deps: verb */ env.modulePath = resolve.sync('verb'); } // chdir before requiring `verbfile.js` to allow users to chdir as needed if (process.cwd() !== env.cwd) { process.chdir(env.cwd); verbLog('working directory changed to', tildify(env.cwd)); } // require verb var verbInst = require(env.modulePath); verbInst.extend('argv', argv); verbInst.emit('loaded'); if (!argv._.length && argv.no) { exit(0); } // `verbfile.js` if ((hasVerbmd && !hasVerbfile) || !verbfile) { verbfile = resolve.sync('verb-default'); env.configBase = path.dirname(env.configBase); require(verbfile)(verbInst); } else { // this is what actually loads up the verbfile require(verbfile); } verbLog('using verbfile', tildify(verbfile)); logEvents(verbInst); process.nextTick(function () { if (simpleTasksFlag) { return logTasksSimple(env, verbInst); } if (tasksFlag) { return logTasks(env, verbInst); } verbInst.run(toRun, function (err) { if (err) console.error(err); }); }); }
javascript
function run(env) { console.log(); // empty line var verbfile = env.configPath; if (versionFlag && tasks.length === 0) { verbLog('CLI version', pkg.version); if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') { verbLog('Local version', env.modulePackage.version); } } // `node_modules/verb` if (!env.modulePath || !fs.existsSync(env.modulePath)) { /* deps: verb */ env.modulePath = resolve.sync('verb'); } // chdir before requiring `verbfile.js` to allow users to chdir as needed if (process.cwd() !== env.cwd) { process.chdir(env.cwd); verbLog('working directory changed to', tildify(env.cwd)); } // require verb var verbInst = require(env.modulePath); verbInst.extend('argv', argv); verbInst.emit('loaded'); if (!argv._.length && argv.no) { exit(0); } // `verbfile.js` if ((hasVerbmd && !hasVerbfile) || !verbfile) { verbfile = resolve.sync('verb-default'); env.configBase = path.dirname(env.configBase); require(verbfile)(verbInst); } else { // this is what actually loads up the verbfile require(verbfile); } verbLog('using verbfile', tildify(verbfile)); logEvents(verbInst); process.nextTick(function () { if (simpleTasksFlag) { return logTasksSimple(env, verbInst); } if (tasksFlag) { return logTasks(env, verbInst); } verbInst.run(toRun, function (err) { if (err) console.error(err); }); }); }
[ "function", "run", "(", "env", ")", "{", "console", ".", "log", "(", ")", ";", "// empty line", "var", "verbfile", "=", "env", ".", "configPath", ";", "if", "(", "versionFlag", "&&", "tasks", ".", "length", "===", "0", ")", "{", "verbLog", "(", "'CLI version'", ",", "pkg", ".", "version", ")", ";", "if", "(", "env", ".", "modulePackage", "&&", "typeof", "env", ".", "modulePackage", ".", "version", "!==", "'undefined'", ")", "{", "verbLog", "(", "'Local version'", ",", "env", ".", "modulePackage", ".", "version", ")", ";", "}", "}", "// `node_modules/verb`", "if", "(", "!", "env", ".", "modulePath", "||", "!", "fs", ".", "existsSync", "(", "env", ".", "modulePath", ")", ")", "{", "/* deps: verb */", "env", ".", "modulePath", "=", "resolve", ".", "sync", "(", "'verb'", ")", ";", "}", "// chdir before requiring `verbfile.js` to allow users to chdir as needed", "if", "(", "process", ".", "cwd", "(", ")", "!==", "env", ".", "cwd", ")", "{", "process", ".", "chdir", "(", "env", ".", "cwd", ")", ";", "verbLog", "(", "'working directory changed to'", ",", "tildify", "(", "env", ".", "cwd", ")", ")", ";", "}", "// require verb", "var", "verbInst", "=", "require", "(", "env", ".", "modulePath", ")", ";", "verbInst", ".", "extend", "(", "'argv'", ",", "argv", ")", ";", "verbInst", ".", "emit", "(", "'loaded'", ")", ";", "if", "(", "!", "argv", ".", "_", ".", "length", "&&", "argv", ".", "no", ")", "{", "exit", "(", "0", ")", ";", "}", "// `verbfile.js`", "if", "(", "(", "hasVerbmd", "&&", "!", "hasVerbfile", ")", "||", "!", "verbfile", ")", "{", "verbfile", "=", "resolve", ".", "sync", "(", "'verb-default'", ")", ";", "env", ".", "configBase", "=", "path", ".", "dirname", "(", "env", ".", "configBase", ")", ";", "require", "(", "verbfile", ")", "(", "verbInst", ")", ";", "}", "else", "{", "// this is what actually loads up the verbfile", "require", "(", "verbfile", ")", ";", "}", "verbLog", "(", "'using verbfile'", ",", "tildify", "(", "verbfile", ")", ")", ";", "logEvents", "(", "verbInst", ")", ";", "process", ".", "nextTick", "(", "function", "(", ")", "{", "if", "(", "simpleTasksFlag", ")", "{", "return", "logTasksSimple", "(", "env", ",", "verbInst", ")", ";", "}", "if", "(", "tasksFlag", ")", "{", "return", "logTasks", "(", "env", ",", "verbInst", ")", ";", "}", "verbInst", ".", "run", "(", "toRun", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "console", ".", "error", "(", "err", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
the actual logic
[ "the", "actual", "logic" ]
f42621b3e43a631b1df40917ab5ecb9c0ff437b9
https://github.com/verbose/verb-cli/blob/f42621b3e43a631b1df40917ab5ecb9c0ff437b9/bin/verb.js#L98-L155
47,647
hash-bang/conkie-stats
modules/feedRSSAtom.js
callbackParser
function callbackParser(err, out) { if (err) { error += err + '\n\n'; } else { results[counter] = out; } counter++; if (counter === urlLength) { let result = {sources: [], feeds: []}; let i = 0; _.each(results, feed => { feed.metadata.lastBuildDate = moment(feed.metadata.lastBuildDate).format('x'); feed.metadata.update = moment(feed.metadata.update).format('x'); result.sources.push({type: feed.type, metadata: feed.metadata}); _.each(feed.items, function (item) { item.source = i; result.feeds.push(item); }); i++; }); // Sort value switch (allowSortValue[sortByDate]) { case allowSortValue.asc: result.feeds.sort((a, b) => (a.date > b.date) ? 1 : ((b.date > a.date) ? -1 : 0)); break; case allowSortValue.desc: result.feeds.sort((a, b) => (a.date < b.date) ? 1 : ((b.date < a.date) ? -1 : 0)); break; default: break; } if (error !== '') { finishCallback(error); } else { finishCallback(null, {feedRSSAtom: result}); } } }
javascript
function callbackParser(err, out) { if (err) { error += err + '\n\n'; } else { results[counter] = out; } counter++; if (counter === urlLength) { let result = {sources: [], feeds: []}; let i = 0; _.each(results, feed => { feed.metadata.lastBuildDate = moment(feed.metadata.lastBuildDate).format('x'); feed.metadata.update = moment(feed.metadata.update).format('x'); result.sources.push({type: feed.type, metadata: feed.metadata}); _.each(feed.items, function (item) { item.source = i; result.feeds.push(item); }); i++; }); // Sort value switch (allowSortValue[sortByDate]) { case allowSortValue.asc: result.feeds.sort((a, b) => (a.date > b.date) ? 1 : ((b.date > a.date) ? -1 : 0)); break; case allowSortValue.desc: result.feeds.sort((a, b) => (a.date < b.date) ? 1 : ((b.date < a.date) ? -1 : 0)); break; default: break; } if (error !== '') { finishCallback(error); } else { finishCallback(null, {feedRSSAtom: result}); } } }
[ "function", "callbackParser", "(", "err", ",", "out", ")", "{", "if", "(", "err", ")", "{", "error", "+=", "err", "+", "'\\n\\n'", ";", "}", "else", "{", "results", "[", "counter", "]", "=", "out", ";", "}", "counter", "++", ";", "if", "(", "counter", "===", "urlLength", ")", "{", "let", "result", "=", "{", "sources", ":", "[", "]", ",", "feeds", ":", "[", "]", "}", ";", "let", "i", "=", "0", ";", "_", ".", "each", "(", "results", ",", "feed", "=>", "{", "feed", ".", "metadata", ".", "lastBuildDate", "=", "moment", "(", "feed", ".", "metadata", ".", "lastBuildDate", ")", ".", "format", "(", "'x'", ")", ";", "feed", ".", "metadata", ".", "update", "=", "moment", "(", "feed", ".", "metadata", ".", "update", ")", ".", "format", "(", "'x'", ")", ";", "result", ".", "sources", ".", "push", "(", "{", "type", ":", "feed", ".", "type", ",", "metadata", ":", "feed", ".", "metadata", "}", ")", ";", "_", ".", "each", "(", "feed", ".", "items", ",", "function", "(", "item", ")", "{", "item", ".", "source", "=", "i", ";", "result", ".", "feeds", ".", "push", "(", "item", ")", ";", "}", ")", ";", "i", "++", ";", "}", ")", ";", "// Sort value", "switch", "(", "allowSortValue", "[", "sortByDate", "]", ")", "{", "case", "allowSortValue", ".", "asc", ":", "result", ".", "feeds", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "(", "a", ".", "date", ">", "b", ".", "date", ")", "?", "1", ":", "(", "(", "b", ".", "date", ">", "a", ".", "date", ")", "?", "-", "1", ":", "0", ")", ")", ";", "break", ";", "case", "allowSortValue", ".", "desc", ":", "result", ".", "feeds", ".", "sort", "(", "(", "a", ",", "b", ")", "=>", "(", "a", ".", "date", "<", "b", ".", "date", ")", "?", "1", ":", "(", "(", "b", ".", "date", "<", "a", ".", "date", ")", "?", "-", "1", ":", "0", ")", ")", ";", "break", ";", "default", ":", "break", ";", "}", "if", "(", "error", "!==", "''", ")", "{", "finishCallback", "(", "error", ")", ";", "}", "else", "{", "finishCallback", "(", "null", ",", "{", "feedRSSAtom", ":", "result", "}", ")", ";", "}", "}", "}" ]
Callback call when parser is finished @param err {string} Error reported @param out {json} Data returned
[ "Callback", "call", "when", "parser", "is", "finished" ]
c81775b305efb33a5788325ab851d4f356b240f5
https://github.com/hash-bang/conkie-stats/blob/c81775b305efb33a5788325ab851d4f356b240f5/modules/feedRSSAtom.js#L66-L106
47,648
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/maximize/plugin.js
resizeHandler
function resizeHandler() { var viewPaneSize = mainWindow.getViewPaneSize(); shim && shim.setStyles( { width : viewPaneSize.width + 'px', height : viewPaneSize.height + 'px' } ); editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); }
javascript
function resizeHandler() { var viewPaneSize = mainWindow.getViewPaneSize(); shim && shim.setStyles( { width : viewPaneSize.width + 'px', height : viewPaneSize.height + 'px' } ); editor.resize( viewPaneSize.width, viewPaneSize.height, null, true ); }
[ "function", "resizeHandler", "(", ")", "{", "var", "viewPaneSize", "=", "mainWindow", ".", "getViewPaneSize", "(", ")", ";", "shim", "&&", "shim", ".", "setStyles", "(", "{", "width", ":", "viewPaneSize", ".", "width", "+", "'px'", ",", "height", ":", "viewPaneSize", ".", "height", "+", "'px'", "}", ")", ";", "editor", ".", "resize", "(", "viewPaneSize", ".", "width", ",", "viewPaneSize", ".", "height", ",", "null", ",", "true", ")", ";", "}" ]
Saved resize handler function.
[ "Saved", "resize", "handler", "function", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/maximize/plugin.js#L145-L150
47,649
taylor1791/promissory-arbiter
src/spec/promissory-arbiter.spec.js
p1so
function p1so (topic1, topic2) { pub(topic1, null, {persist: true}); var spy = sub(topic2); return spy; }
javascript
function p1so (topic1, topic2) { pub(topic1, null, {persist: true}); var spy = sub(topic2); return spy; }
[ "function", "p1so", "(", "topic1", ",", "topic2", ")", "{", "pub", "(", "topic1", ",", "null", ",", "{", "persist", ":", "true", "}", ")", ";", "var", "spy", "=", "sub", "(", "topic2", ")", ";", "return", "spy", ";", "}" ]
Publish 1 Subscribe Other
[ "Publish", "1", "Subscribe", "Other" ]
6327b87efd9ee997cbfaa009164dac266d9e16c2
https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/spec/promissory-arbiter.spec.js#L754-L758
47,650
taylor1791/promissory-arbiter
src/spec/promissory-arbiter.spec.js
subPubArg
function subPubArg (topic, data, i) { var spy = sub(topic); pub(topic, data); var args = spy.calls.first().args; return typeof i === 'undefined' ? args : args[i]; }
javascript
function subPubArg (topic, data, i) { var spy = sub(topic); pub(topic, data); var args = spy.calls.first().args; return typeof i === 'undefined' ? args : args[i]; }
[ "function", "subPubArg", "(", "topic", ",", "data", ",", "i", ")", "{", "var", "spy", "=", "sub", "(", "topic", ")", ";", "pub", "(", "topic", ",", "data", ")", ";", "var", "args", "=", "spy", ".", "calls", ".", "first", "(", ")", ".", "args", ";", "return", "typeof", "i", "===", "'undefined'", "?", "args", ":", "args", "[", "i", "]", ";", "}" ]
Subscribes to a topic, publishes data and returns the specified arguemnts
[ "Subscribes", "to", "a", "topic", "publishes", "data", "and", "returns", "the", "specified", "arguemnts" ]
6327b87efd9ee997cbfaa009164dac266d9e16c2
https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/spec/promissory-arbiter.spec.js#L768-L774
47,651
saggiyogesh/nodeportal
public/js/jquery.fileupload-ui.js
function (options) { var processQueue = []; $.each(options.processQueue, function () { var settings = {}, action = this.action, prefix = this.prefix === true ? action : this.prefix; $.each(this, function (key, value) { if ($.type(value) === 'string' && value.charAt(0) === '@') { settings[key] = options[ value.slice(1) || (prefix ? prefix + key.charAt(0).toUpperCase() + key.slice(1) : key) ]; } else { settings[key] = value; } }); processQueue.push(settings); }); options.processQueue = processQueue; }
javascript
function (options) { var processQueue = []; $.each(options.processQueue, function () { var settings = {}, action = this.action, prefix = this.prefix === true ? action : this.prefix; $.each(this, function (key, value) { if ($.type(value) === 'string' && value.charAt(0) === '@') { settings[key] = options[ value.slice(1) || (prefix ? prefix + key.charAt(0).toUpperCase() + key.slice(1) : key) ]; } else { settings[key] = value; } }); processQueue.push(settings); }); options.processQueue = processQueue; }
[ "function", "(", "options", ")", "{", "var", "processQueue", "=", "[", "]", ";", "$", ".", "each", "(", "options", ".", "processQueue", ",", "function", "(", ")", "{", "var", "settings", "=", "{", "}", ",", "action", "=", "this", ".", "action", ",", "prefix", "=", "this", ".", "prefix", "===", "true", "?", "action", ":", "this", ".", "prefix", ";", "$", ".", "each", "(", "this", ",", "function", "(", "key", ",", "value", ")", "{", "if", "(", "$", ".", "type", "(", "value", ")", "===", "'string'", "&&", "value", ".", "charAt", "(", "0", ")", "===", "'@'", ")", "{", "settings", "[", "key", "]", "=", "options", "[", "value", ".", "slice", "(", "1", ")", "||", "(", "prefix", "?", "prefix", "+", "key", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "key", ".", "slice", "(", "1", ")", ":", "key", ")", "]", ";", "}", "else", "{", "settings", "[", "key", "]", "=", "value", ";", "}", "}", ")", ";", "processQueue", ".", "push", "(", "settings", ")", ";", "}", ")", ";", "options", ".", "processQueue", "=", "processQueue", ";", "}" ]
Replaces the settings of each processQueue item that are strings starting with an "@", using the remaining substring as key for the option map, e.g. "@autoUpload" is replaced with options.autoUpload:
[ "Replaces", "the", "settings", "of", "each", "processQueue", "item", "that", "are", "strings", "starting", "with", "an" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/jquery.fileupload-ui.js#L738-L759
47,652
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/link/plugin.js
function( editor ) { try { var selection = editor.getSelection(); if ( selection.getType() == CKEDITOR.SELECTION_ELEMENT ) { var selectedElement = selection.getSelectedElement(); if ( selectedElement.is( 'a' ) ) return selectedElement; } var range = selection.getRanges( true )[ 0 ]; range.shrink( CKEDITOR.SHRINK_TEXT ); var root = range.getCommonAncestor(); return root.getAscendant( 'a', true ); } catch( e ) { return null; } }
javascript
function( editor ) { try { var selection = editor.getSelection(); if ( selection.getType() == CKEDITOR.SELECTION_ELEMENT ) { var selectedElement = selection.getSelectedElement(); if ( selectedElement.is( 'a' ) ) return selectedElement; } var range = selection.getRanges( true )[ 0 ]; range.shrink( CKEDITOR.SHRINK_TEXT ); var root = range.getCommonAncestor(); return root.getAscendant( 'a', true ); } catch( e ) { return null; } }
[ "function", "(", "editor", ")", "{", "try", "{", "var", "selection", "=", "editor", ".", "getSelection", "(", ")", ";", "if", "(", "selection", ".", "getType", "(", ")", "==", "CKEDITOR", ".", "SELECTION_ELEMENT", ")", "{", "var", "selectedElement", "=", "selection", ".", "getSelectedElement", "(", ")", ";", "if", "(", "selectedElement", ".", "is", "(", "'a'", ")", ")", "return", "selectedElement", ";", "}", "var", "range", "=", "selection", ".", "getRanges", "(", "true", ")", "[", "0", "]", ";", "range", ".", "shrink", "(", "CKEDITOR", ".", "SHRINK_TEXT", ")", ";", "var", "root", "=", "range", ".", "getCommonAncestor", "(", ")", ";", "return", "root", ".", "getAscendant", "(", "'a'", ",", "true", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "null", ";", "}", "}" ]
Get the surrounding link element of current selection. @param editor @example CKEDITOR.plugins.link.getSelectedLink( editor ); @since 3.2.1 The following selection will all return the link element. <pre> <a href="#">li^nk</a> <a href="#">[link]</a> text[<a href="#">link]</a> <a href="#">li[nk</a>] [<b><a href="#">li]nk</a></b>] [<a href="#"><b>li]nk</b></a> </pre>
[ "Get", "the", "surrounding", "link", "element", "of", "current", "selection", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/plugin.js#L265-L283
47,653
levilindsey/physx
src/collisions/contact-calculation/src/obb-contact-calculation.js
obbVsSphere
function obbVsSphere(contactPoint, contactNormal, obb, sphere) { findClosestPointFromObbToPoint(contactPoint, obb, sphere.centerOfVolume); vec3.subtract(contactNormal, sphere.centerOfVolume, contactPoint); vec3.normalize(contactNormal, contactNormal); }
javascript
function obbVsSphere(contactPoint, contactNormal, obb, sphere) { findClosestPointFromObbToPoint(contactPoint, obb, sphere.centerOfVolume); vec3.subtract(contactNormal, sphere.centerOfVolume, contactPoint); vec3.normalize(contactNormal, contactNormal); }
[ "function", "obbVsSphere", "(", "contactPoint", ",", "contactNormal", ",", "obb", ",", "sphere", ")", "{", "findClosestPointFromObbToPoint", "(", "contactPoint", ",", "obb", ",", "sphere", ".", "centerOfVolume", ")", ";", "vec3", ".", "subtract", "(", "contactNormal", ",", "sphere", ".", "centerOfVolume", ",", "contactPoint", ")", ";", "vec3", ".", "normalize", "(", "contactNormal", ",", "contactNormal", ")", ";", "}" ]
Finds the closest point anywhere inside the OBB to the center of the sphere. @param {vec3} contactPoint Output param. @param {vec3} contactNormal Output param. @param {Obb} obb @param {Sphere} sphere
[ "Finds", "the", "closest", "point", "anywhere", "inside", "the", "OBB", "to", "the", "center", "of", "the", "sphere", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/contact-calculation/src/obb-contact-calculation.js#L42-L46
47,654
gpolitis/node-tarantula
lib/ResourcePool.js
ResourcePool
function ResourcePool (options) { this.max = options.max || 1; this.maxUses = options.maxUses || 1; this.create = options.create || function () {}; this.destroy = options.destroy || function () {}; this.active = 0; this.resources = new Array(this.max); this.resourceActive = new Array(this.max); this.resourceUses = new Array(this.max); }
javascript
function ResourcePool (options) { this.max = options.max || 1; this.maxUses = options.maxUses || 1; this.create = options.create || function () {}; this.destroy = options.destroy || function () {}; this.active = 0; this.resources = new Array(this.max); this.resourceActive = new Array(this.max); this.resourceUses = new Array(this.max); }
[ "function", "ResourcePool", "(", "options", ")", "{", "this", ".", "max", "=", "options", ".", "max", "||", "1", ";", "this", ".", "maxUses", "=", "options", ".", "maxUses", "||", "1", ";", "this", ".", "create", "=", "options", ".", "create", "||", "function", "(", ")", "{", "}", ";", "this", ".", "destroy", "=", "options", ".", "destroy", "||", "function", "(", ")", "{", "}", ";", "this", ".", "active", "=", "0", ";", "this", ".", "resources", "=", "new", "Array", "(", "this", ".", "max", ")", ";", "this", ".", "resourceActive", "=", "new", "Array", "(", "this", ".", "max", ")", ";", "this", ".", "resourceUses", "=", "new", "Array", "(", "this", ".", "max", ")", ";", "}" ]
Class for managing a pool of resources @param {object} options @param {int} options.max Maximum number of resources to keep @param {int} options.maxUses Maximum number of times a resource may be used @param {function} options.create Called to create a new Resource @param {function} options.destroy Called to destroy an resource, after it is used up -- @param {Resource}
[ "Class", "for", "managing", "a", "pool", "of", "resources" ]
fd5bfdff5c287244bd5b4a871074a7a67c37387d
https://github.com/gpolitis/node-tarantula/blob/fd5bfdff5c287244bd5b4a871074a7a67c37387d/lib/ResourcePool.js#L15-L24
47,655
bigpipe/fittings
index.js
Fittings
function Fittings(bigpipe) { if (!this.name) throw new Error('The fittings.name property is required.'); this.ultron = new Ultron(bigpipe); this.bigpipe = bigpipe; this.setup(); }
javascript
function Fittings(bigpipe) { if (!this.name) throw new Error('The fittings.name property is required.'); this.ultron = new Ultron(bigpipe); this.bigpipe = bigpipe; this.setup(); }
[ "function", "Fittings", "(", "bigpipe", ")", "{", "if", "(", "!", "this", ".", "name", ")", "throw", "new", "Error", "(", "'The fittings.name property is required.'", ")", ";", "this", ".", "ultron", "=", "new", "Ultron", "(", "bigpipe", ")", ";", "this", ".", "bigpipe", "=", "bigpipe", ";", "this", ".", "setup", "(", ")", ";", "}" ]
Fittings is the default framework provider for BigPipe. @constructor @param {BigPipe} bigpipe @api public
[ "Fittings", "is", "the", "default", "framework", "provider", "for", "BigPipe", "." ]
3fc601c7835eec9c4c222fe78003af02a13671b0
https://github.com/bigpipe/fittings/blob/3fc601c7835eec9c4c222fe78003af02a13671b0/index.js#L31-L38
47,656
bigpipe/fittings
index.js
makeitso
function makeitso(where) { if ('string' === typeof where) { where = { expose: path.basename(where).replace(new RegExp(path.extname(where).replace('.', '\\.') +'$'), ''), path: where }; } return where; }
javascript
function makeitso(where) { if ('string' === typeof where) { where = { expose: path.basename(where).replace(new RegExp(path.extname(where).replace('.', '\\.') +'$'), ''), path: where }; } return where; }
[ "function", "makeitso", "(", "where", ")", "{", "if", "(", "'string'", "===", "typeof", "where", ")", "{", "where", "=", "{", "expose", ":", "path", ".", "basename", "(", "where", ")", ".", "replace", "(", "new", "RegExp", "(", "path", ".", "extname", "(", "where", ")", ".", "replace", "(", "'.'", ",", "'\\\\.'", ")", "+", "'$'", ")", ",", "''", ")", ",", "path", ":", "where", "}", ";", "}", "return", "where", ";", "}" ]
As the libraries as run through browserify it makes sense to give them a custom export name. When it's an object we assume that they already follow our required structure. If this is not the case we use the filename as the name it should be exposed under. @param {String|Object} where Either the location of a file or object. @returns {Object} @api private
[ "As", "the", "libraries", "as", "run", "through", "browserify", "it", "makes", "sense", "to", "give", "them", "a", "custom", "export", "name", ".", "When", "it", "s", "an", "object", "we", "assume", "that", "they", "already", "follow", "our", "required", "structure", ".", "If", "this", "is", "not", "the", "case", "we", "use", "the", "filename", "as", "the", "name", "it", "should", "be", "exposed", "under", "." ]
3fc601c7835eec9c4c222fe78003af02a13671b0
https://github.com/bigpipe/fittings/blob/3fc601c7835eec9c4c222fe78003af02a13671b0/index.js#L117-L126
47,657
saggiyogesh/nodeportal
lib/Mailer/MailMessage.js
Attachment
function Attachment(options) { this.fileName = options.fileName; this.contents = options.contents; this.filePath = options.filePath; this.streamSource = options.streamSource; this.contentType = options.contentType; this.cid = options.cid; }
javascript
function Attachment(options) { this.fileName = options.fileName; this.contents = options.contents; this.filePath = options.filePath; this.streamSource = options.streamSource; this.contentType = options.contentType; this.cid = options.cid; }
[ "function", "Attachment", "(", "options", ")", "{", "this", ".", "fileName", "=", "options", ".", "fileName", ";", "this", ".", "contents", "=", "options", ".", "contents", ";", "this", ".", "filePath", "=", "options", ".", "filePath", ";", "this", ".", "streamSource", "=", "options", ".", "streamSource", ";", "this", ".", "contentType", "=", "options", ".", "contentType", ";", "this", ".", "cid", "=", "options", ".", "cid", ";", "}" ]
Attachment constructor. Options of nodemailer attachment are available @constructor
[ "Attachment", "constructor", ".", "Options", "of", "nodemailer", "attachment", "are", "available" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Mailer/MailMessage.js#L14-L21
47,658
gpolitis/node-tarantula
lib/tarantula.js
trimHash
function trimHash (uri) { var indexOfHash = uri.indexOf('#'); return (indexOfHash != -1) ? uri.substring(0, indexOfHash) : uri; }
javascript
function trimHash (uri) { var indexOfHash = uri.indexOf('#'); return (indexOfHash != -1) ? uri.substring(0, indexOfHash) : uri; }
[ "function", "trimHash", "(", "uri", ")", "{", "var", "indexOfHash", "=", "uri", ".", "indexOf", "(", "'#'", ")", ";", "return", "(", "indexOfHash", "!=", "-", "1", ")", "?", "uri", ".", "substring", "(", "0", ",", "indexOfHash", ")", ":", "uri", ";", "}" ]
Remove Hash part of a URL @param {string} uri The URL to remove hash from @return {string} The URL without hash
[ "Remove", "Hash", "part", "of", "a", "URL" ]
fd5bfdff5c287244bd5b4a871074a7a67c37387d
https://github.com/gpolitis/node-tarantula/blob/fd5bfdff5c287244bd5b4a871074a7a67c37387d/lib/tarantula.js#L346-L349
47,659
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/scayt/plugin.js
in_array
function in_array( needle, haystack ) { var found = 0, key; for ( key in haystack ) { if ( haystack[ key ] == needle ) { found = 1; break; } } return found; }
javascript
function in_array( needle, haystack ) { var found = 0, key; for ( key in haystack ) { if ( haystack[ key ] == needle ) { found = 1; break; } } return found; }
[ "function", "in_array", "(", "needle", ",", "haystack", ")", "{", "var", "found", "=", "0", ",", "key", ";", "for", "(", "key", "in", "haystack", ")", "{", "if", "(", "haystack", "[", "key", "]", "==", "needle", ")", "{", "found", "=", "1", ";", "break", ";", "}", "}", "return", "found", ";", "}" ]
Checks if a value exists in an array
[ "Checks", "if", "a", "value", "exists", "in", "an", "array" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/scayt/plugin.js#L17-L30
47,660
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/scayt/plugin.js
function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder ) { editor.addCommand( commandName, command ); // If the "menu" plugin is loaded, register the menu item. editor.addMenuItem( commandName, { label : buttonLabel, command : commandName, group : menugroup, order : menuOrder }); }
javascript
function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder ) { editor.addCommand( commandName, command ); // If the "menu" plugin is loaded, register the menu item. editor.addMenuItem( commandName, { label : buttonLabel, command : commandName, group : menugroup, order : menuOrder }); }
[ "function", "(", "editor", ",", "buttonName", ",", "buttonLabel", ",", "commandName", ",", "command", ",", "menugroup", ",", "menuOrder", ")", "{", "editor", ".", "addCommand", "(", "commandName", ",", "command", ")", ";", "// If the \"menu\" plugin is loaded, register the menu item.\r", "editor", ".", "addMenuItem", "(", "commandName", ",", "{", "label", ":", "buttonLabel", ",", "command", ":", "commandName", ",", "group", ":", "menugroup", ",", "order", ":", "menuOrder", "}", ")", ";", "}" ]
Context menu constructing.
[ "Context", "menu", "constructing", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/scayt/plugin.js#L447-L459
47,661
saggiyogesh/nodeportal
plugins/managePlugin/client/js/managePlugin.js
handlePermissionUpdate
function handlePermissionUpdate() { permissionArea.find("form").submit(function (e) { e.preventDefault(); //console.log(e); var form = e.currentTarget; appendFormFields(form); Rocket.Util.submitFormAsync(form, function (responseData) { //console.log(responseData); if (responseData && responseData.status && responseData.status == "success") { location.reload(); } }); }); }
javascript
function handlePermissionUpdate() { permissionArea.find("form").submit(function (e) { e.preventDefault(); //console.log(e); var form = e.currentTarget; appendFormFields(form); Rocket.Util.submitFormAsync(form, function (responseData) { //console.log(responseData); if (responseData && responseData.status && responseData.status == "success") { location.reload(); } }); }); }
[ "function", "handlePermissionUpdate", "(", ")", "{", "permissionArea", ".", "find", "(", "\"form\"", ")", ".", "submit", "(", "function", "(", "e", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "//console.log(e);", "var", "form", "=", "e", ".", "currentTarget", ";", "appendFormFields", "(", "form", ")", ";", "Rocket", ".", "Util", ".", "submitFormAsync", "(", "form", ",", "function", "(", "responseData", ")", "{", "//console.log(responseData);", "if", "(", "responseData", "&&", "responseData", ".", "status", "&&", "responseData", ".", "status", "==", "\"success\"", ")", "{", "location", ".", "reload", "(", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
open permissions on tab click
[ "open", "permissions", "on", "tab", "click" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/managePlugin/client/js/managePlugin.js#L51-L64
47,662
ForbesLindesay/stop
lib/manifest.js
addManifest
function addManifest(file, options) { file = file || '/app.manifest'; var stream = new Transform({objectMode: true}); var domains = {}; var hostProtocols = {}; stream._transform = function (page, _, callback) { if (!(options && options.justManifests)) { if (page.statusCode !== 404 || url.resolve(page.url, file) !== page.url) { if (page.statusCode === 200 && page.headers['content-type'] && page.headers['content-type'].indexOf('text/html') !== -1 && options && options.addLinks) { var body = page.body.toString(); var link = '<link href="' + file + '" rel="manifest"/>'; page.body = new Buffer(body.replace(/<\/head>/, link + '</head>')); } this.push(page); } } if (page.statusCode === 200) { var host = url.parse(page.url).host; var protocol = hostProtocols[host] || (hostProtocols[host] = url.parse(page.url).protocol); var domain = protocol + '//' + host; domain = domains[domain] || (domains[domain] = {hash: crypto.createHash('sha512'), urls: []}); domain.hash.update(page.statusCode + ' - ' + page.url); domain.hash.update(page.body || ''); domain.urls.push(page.url); } callback(null); }; stream._flush = function (callback) { Object.keys(domains).forEach(function (domain) { stream.push({ statusCode: 200, url: url.resolve(domain, file), headers: {}, body: new Buffer('CACHE MANIFEST\n\n# hash: ' + domains[domain].hash.digest('base64') + '\n\n' + domains[domain].urls.map(function (u) { return url.parse(u).pathname; }).join('\n') + '\n'), dependencies: domains[domain].urls }); }); callback(); }; return stream; }
javascript
function addManifest(file, options) { file = file || '/app.manifest'; var stream = new Transform({objectMode: true}); var domains = {}; var hostProtocols = {}; stream._transform = function (page, _, callback) { if (!(options && options.justManifests)) { if (page.statusCode !== 404 || url.resolve(page.url, file) !== page.url) { if (page.statusCode === 200 && page.headers['content-type'] && page.headers['content-type'].indexOf('text/html') !== -1 && options && options.addLinks) { var body = page.body.toString(); var link = '<link href="' + file + '" rel="manifest"/>'; page.body = new Buffer(body.replace(/<\/head>/, link + '</head>')); } this.push(page); } } if (page.statusCode === 200) { var host = url.parse(page.url).host; var protocol = hostProtocols[host] || (hostProtocols[host] = url.parse(page.url).protocol); var domain = protocol + '//' + host; domain = domains[domain] || (domains[domain] = {hash: crypto.createHash('sha512'), urls: []}); domain.hash.update(page.statusCode + ' - ' + page.url); domain.hash.update(page.body || ''); domain.urls.push(page.url); } callback(null); }; stream._flush = function (callback) { Object.keys(domains).forEach(function (domain) { stream.push({ statusCode: 200, url: url.resolve(domain, file), headers: {}, body: new Buffer('CACHE MANIFEST\n\n# hash: ' + domains[domain].hash.digest('base64') + '\n\n' + domains[domain].urls.map(function (u) { return url.parse(u).pathname; }).join('\n') + '\n'), dependencies: domains[domain].urls }); }); callback(); }; return stream; }
[ "function", "addManifest", "(", "file", ",", "options", ")", "{", "file", "=", "file", "||", "'/app.manifest'", ";", "var", "stream", "=", "new", "Transform", "(", "{", "objectMode", ":", "true", "}", ")", ";", "var", "domains", "=", "{", "}", ";", "var", "hostProtocols", "=", "{", "}", ";", "stream", ".", "_transform", "=", "function", "(", "page", ",", "_", ",", "callback", ")", "{", "if", "(", "!", "(", "options", "&&", "options", ".", "justManifests", ")", ")", "{", "if", "(", "page", ".", "statusCode", "!==", "404", "||", "url", ".", "resolve", "(", "page", ".", "url", ",", "file", ")", "!==", "page", ".", "url", ")", "{", "if", "(", "page", ".", "statusCode", "===", "200", "&&", "page", ".", "headers", "[", "'content-type'", "]", "&&", "page", ".", "headers", "[", "'content-type'", "]", ".", "indexOf", "(", "'text/html'", ")", "!==", "-", "1", "&&", "options", "&&", "options", ".", "addLinks", ")", "{", "var", "body", "=", "page", ".", "body", ".", "toString", "(", ")", ";", "var", "link", "=", "'<link href=\"'", "+", "file", "+", "'\" rel=\"manifest\"/>'", ";", "page", ".", "body", "=", "new", "Buffer", "(", "body", ".", "replace", "(", "/", "<\\/head>", "/", ",", "link", "+", "'</head>'", ")", ")", ";", "}", "this", ".", "push", "(", "page", ")", ";", "}", "}", "if", "(", "page", ".", "statusCode", "===", "200", ")", "{", "var", "host", "=", "url", ".", "parse", "(", "page", ".", "url", ")", ".", "host", ";", "var", "protocol", "=", "hostProtocols", "[", "host", "]", "||", "(", "hostProtocols", "[", "host", "]", "=", "url", ".", "parse", "(", "page", ".", "url", ")", ".", "protocol", ")", ";", "var", "domain", "=", "protocol", "+", "'//'", "+", "host", ";", "domain", "=", "domains", "[", "domain", "]", "||", "(", "domains", "[", "domain", "]", "=", "{", "hash", ":", "crypto", ".", "createHash", "(", "'sha512'", ")", ",", "urls", ":", "[", "]", "}", ")", ";", "domain", ".", "hash", ".", "update", "(", "page", ".", "statusCode", "+", "' - '", "+", "page", ".", "url", ")", ";", "domain", ".", "hash", ".", "update", "(", "page", ".", "body", "||", "''", ")", ";", "domain", ".", "urls", ".", "push", "(", "page", ".", "url", ")", ";", "}", "callback", "(", "null", ")", ";", "}", ";", "stream", ".", "_flush", "=", "function", "(", "callback", ")", "{", "Object", ".", "keys", "(", "domains", ")", ".", "forEach", "(", "function", "(", "domain", ")", "{", "stream", ".", "push", "(", "{", "statusCode", ":", "200", ",", "url", ":", "url", ".", "resolve", "(", "domain", ",", "file", ")", ",", "headers", ":", "{", "}", ",", "body", ":", "new", "Buffer", "(", "'CACHE MANIFEST\\n\\n# hash: '", "+", "domains", "[", "domain", "]", ".", "hash", ".", "digest", "(", "'base64'", ")", "+", "'\\n\\n'", "+", "domains", "[", "domain", "]", ".", "urls", ".", "map", "(", "function", "(", "u", ")", "{", "return", "url", ".", "parse", "(", "u", ")", ".", "pathname", ";", "}", ")", ".", "join", "(", "'\\n'", ")", "+", "'\\n'", ")", ",", "dependencies", ":", "domains", "[", "domain", "]", ".", "urls", "}", ")", ";", "}", ")", ";", "callback", "(", ")", ";", "}", ";", "return", "stream", ";", "}" ]
Add cache manifest files to the stream. Options: - justManifests - set to `true` to only emit the manifest files. - addLinks - set to `true` to add <link href="/app.manifest" rel="manifest"/> to each html page. @param {String} file @param {Ojbect} options @returns {TransformStream}
[ "Add", "cache", "manifest", "files", "to", "the", "stream", "." ]
61db8899bdde604dc45cfc8f11fffa1beaa27abb
https://github.com/ForbesLindesay/stop/blob/61db8899bdde604dc45cfc8f11fffa1beaa27abb/lib/manifest.js#L24-L73
47,663
h0x91b/ESB-node-driver
examples/bench-requester.js
report
function report(){ if(responses < 1) return; var dt = new Date - starttime; console.log( '%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s', (responses/dt*1000).toFixed(2), (totaltime/responses).toFixed(2), maxtime, mintime, Object.keys(esb.responseCallbacks).length ); responses = 0; totaltime = 0; maxtime = 0; mintime = 100000; }
javascript
function report(){ if(responses < 1) return; var dt = new Date - starttime; console.log( '%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s', (responses/dt*1000).toFixed(2), (totaltime/responses).toFixed(2), maxtime, mintime, Object.keys(esb.responseCallbacks).length ); responses = 0; totaltime = 0; maxtime = 0; mintime = 100000; }
[ "function", "report", "(", ")", "{", "if", "(", "responses", "<", "1", ")", "return", ";", "var", "dt", "=", "new", "Date", "-", "starttime", ";", "console", ".", "log", "(", "'%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s'", ",", "(", "responses", "/", "dt", "*", "1000", ")", ".", "toFixed", "(", "2", ")", ",", "(", "totaltime", "/", "responses", ")", ".", "toFixed", "(", "2", ")", ",", "maxtime", ",", "mintime", ",", "Object", ".", "keys", "(", "esb", ".", "responseCallbacks", ")", ".", "length", ")", ";", "responses", "=", "0", ";", "totaltime", "=", "0", ";", "maxtime", "=", "0", ";", "mintime", "=", "100000", ";", "}" ]
,5);
[ "5", ")", ";" ]
df9bda67a65c9f9c92218091a238ef3a5d5e694a
https://github.com/h0x91b/ESB-node-driver/blob/df9bda67a65c9f9c92218091a238ef3a5d5e694a/examples/bench-requester.js#L56-L71
47,664
Pencroff/kea-config
src/config-manager.js
function (path) { 'use strict'; path = fs.realpathSync(path); var config = require(path); this.setData(config, false); return this; }
javascript
function (path) { 'use strict'; path = fs.realpathSync(path); var config = require(path); this.setData(config, false); return this; }
[ "function", "(", "path", ")", "{", "'use strict'", ";", "path", "=", "fs", ".", "realpathSync", "(", "path", ")", ";", "var", "config", "=", "require", "(", "path", ")", ";", "this", ".", "setData", "(", "config", ",", "false", ")", ";", "return", "this", ";", "}" ]
ConfigManager initialization by data in file. Not save previous configuration. @param {string} path - path to CommonJs module with configuration, from project root
[ "ConfigManager", "initialization", "by", "data", "in", "file", ".", "Not", "save", "previous", "configuration", "." ]
0889d7b8a89ee8720ebc3493e2b102de079869b1
https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L202-L208
47,665
Pencroff/kea-config
src/config-manager.js
function (path) { 'use strict'; path = fs.realpathSync(path); var updateConf = require(path); this.setData(updateConf, true); return this; }
javascript
function (path) { 'use strict'; path = fs.realpathSync(path); var updateConf = require(path); this.setData(updateConf, true); return this; }
[ "function", "(", "path", ")", "{", "'use strict'", ";", "path", "=", "fs", ".", "realpathSync", "(", "path", ")", ";", "var", "updateConf", "=", "require", "(", "path", ")", ";", "this", ".", "setData", "(", "updateConf", ",", "true", ")", ";", "return", "this", ";", "}" ]
Update exist configuration. Merge new config to exist. @param {string} path - path to CommonJs module with configuration, from project root
[ "Update", "exist", "configuration", ".", "Merge", "new", "config", "to", "exist", "." ]
0889d7b8a89ee8720ebc3493e2b102de079869b1
https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L213-L219
47,666
Pencroff/kea-config
src/config-manager.js
function (key) { 'use strict'; var value = conf[key]; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') !== -1) { value = getNestedValue(conf, key); } if (isObj(value)) { if (isExtensionObj(value)) { value = applyExtension.call(this, value); } else { value = openReferences.call(this, value); value = JSON.parse(JSON.stringify(value)); } } return value; }
javascript
function (key) { 'use strict'; var value = conf[key]; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') !== -1) { value = getNestedValue(conf, key); } if (isObj(value)) { if (isExtensionObj(value)) { value = applyExtension.call(this, value); } else { value = openReferences.call(this, value); value = JSON.parse(JSON.stringify(value)); } } return value; }
[ "function", "(", "key", ")", "{", "'use strict'", ";", "var", "value", "=", "conf", "[", "key", "]", ";", "if", "(", "!", "isStr", "(", "key", ")", ")", "{", "throw", "new", "Error", "(", "confKeyStrMsg", ",", "'config-manager'", ")", ";", "}", "if", "(", "key", ".", "indexOf", "(", "'.'", ")", "!==", "-", "1", ")", "{", "value", "=", "getNestedValue", "(", "conf", ",", "key", ")", ";", "}", "if", "(", "isObj", "(", "value", ")", ")", "{", "if", "(", "isExtensionObj", "(", "value", ")", ")", "{", "value", "=", "applyExtension", ".", "call", "(", "this", ",", "value", ")", ";", "}", "else", "{", "value", "=", "openReferences", ".", "call", "(", "this", ",", "value", ")", ";", "value", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "value", ")", ")", ";", "}", "}", "return", "value", ";", "}" ]
Get 'value' of 'key'. @param {string} key - key in configuration. Like 'simpleKey' or 'section.subsection.complex.key'. See config-managet-test.js @returns {*} value - `value` of `key`. Can be `primitive` or `javascript object`. Objects not connected to original configuration. If value contain reference (`{$ref: 'some.reference.to.other.key'}`), then return reference value, if value contain reference with template(`{ $ref: 'some.reference', $tmpl: '{some}:{template}.{string}' }`) and reference point to object then return string with populated placeholder in template (look example on top of page). @example <caption>Using deep references</caption> ```js // Configuration example { nameValue: 'loginName', dbParams: { username: { $ref: 'web.nameValue' }, password: '12345' }, dbConnection: { user: { $ref: 'web.dbParams' }, key: { $ref: 'web.sessionKey' } }, dbConectionStr: { $ref: 'web.dbConnection', $tmpl: 'db:{user.username}::{user.password}@{key}' } }; configManager.get('dbConnection'); //should return object // { // user: { // username: 'loginName', // password: '12345' // }, // key: '6ketaq3cgo315rk9' // } configManager.get('dbConectionStr'); //should return string 'db:loginName::12345@6ketaq3cgo315rk9' ```
[ "Get", "value", "of", "key", "." ]
0889d7b8a89ee8720ebc3493e2b102de079869b1
https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L274-L292
47,667
Pencroff/kea-config
src/config-manager.js
function (key, value) { 'use strict'; var obj; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') === -1) { conf[key] = value; } else { obj = getLastNodeKey(key, conf); obj.node[obj.key] = value; } return this; }
javascript
function (key, value) { 'use strict'; var obj; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') === -1) { conf[key] = value; } else { obj = getLastNodeKey(key, conf); obj.node[obj.key] = value; } return this; }
[ "function", "(", "key", ",", "value", ")", "{", "'use strict'", ";", "var", "obj", ";", "if", "(", "!", "isStr", "(", "key", ")", ")", "{", "throw", "new", "Error", "(", "confKeyStrMsg", ",", "'config-manager'", ")", ";", "}", "if", "(", "key", ".", "indexOf", "(", "'.'", ")", "===", "-", "1", ")", "{", "conf", "[", "key", "]", "=", "value", ";", "}", "else", "{", "obj", "=", "getLastNodeKey", "(", "key", ",", "conf", ")", ";", "obj", ".", "node", "[", "obj", ".", "key", "]", "=", "value", ";", "}", "return", "this", ";", "}" ]
Set 'value' for 'key' @param {string} key - key in configuration. Like 'simpleKey' or 'section.subsection.complex.key'. See config-managet-test.js @param {*} value
[ "Set", "value", "for", "key" ]
0889d7b8a89ee8720ebc3493e2b102de079869b1
https://github.com/Pencroff/kea-config/blob/0889d7b8a89ee8720ebc3493e2b102de079869b1/src/config-manager.js#L298-L311
47,668
mdreizin/webpack-config-stream
lib/formatStream.js
formatStream
function formatStream(options) { if (!_.isObject(options)) { options = {}; } var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS); if (!gutil.colors.supportsColor) { statsOptions.colors = false; } return through.obj(function(chunk, enc, cb) { var stats = chunk[processStats.STATS_DATA_FIELD_NAME], isStats = chunk[processStats.STATS_FLAG_FIELD_NAME]; if (isStats) { var filename = path.resolve(chunk.path); gutil.log(MESSAGE, gutil.colors.magenta(tildify(filename))); gutil.log('\n' + stats.toString(statsOptions)); } cb(null, chunk); }); }
javascript
function formatStream(options) { if (!_.isObject(options)) { options = {}; } var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS); if (!gutil.colors.supportsColor) { statsOptions.colors = false; } return through.obj(function(chunk, enc, cb) { var stats = chunk[processStats.STATS_DATA_FIELD_NAME], isStats = chunk[processStats.STATS_FLAG_FIELD_NAME]; if (isStats) { var filename = path.resolve(chunk.path); gutil.log(MESSAGE, gutil.colors.magenta(tildify(filename))); gutil.log('\n' + stats.toString(statsOptions)); } cb(null, chunk); }); }
[ "function", "formatStream", "(", "options", ")", "{", "if", "(", "!", "_", ".", "isObject", "(", "options", ")", ")", "{", "options", "=", "{", "}", ";", "}", "var", "statsOptions", "=", "options", ".", "verbose", "===", "true", "?", "_", ".", "defaults", "(", "options", ",", "DEFAULT_VERBOSE_STATS_OPTIONS", ")", ":", "_", ".", "defaults", "(", "options", ",", "DEFAULT_STATS_OPTIONS", ")", ";", "if", "(", "!", "gutil", ".", "colors", ".", "supportsColor", ")", "{", "statsOptions", ".", "colors", "=", "false", ";", "}", "return", "through", ".", "obj", "(", "function", "(", "chunk", ",", "enc", ",", "cb", ")", "{", "var", "stats", "=", "chunk", "[", "processStats", ".", "STATS_DATA_FIELD_NAME", "]", ",", "isStats", "=", "chunk", "[", "processStats", ".", "STATS_FLAG_FIELD_NAME", "]", ";", "if", "(", "isStats", ")", "{", "var", "filename", "=", "path", ".", "resolve", "(", "chunk", ".", "path", ")", ";", "gutil", ".", "log", "(", "MESSAGE", ",", "gutil", ".", "colors", ".", "magenta", "(", "tildify", "(", "filename", ")", ")", ")", ";", "gutil", ".", "log", "(", "'\\n'", "+", "stats", ".", "toString", "(", "statsOptions", ")", ")", ";", "}", "cb", "(", "null", ",", "chunk", ")", ";", "}", ")", ";", "}" ]
Writes formatted string of `stats` object and displays related `webpack.config.js` file path. Can be piped. @function @alias formatStream @param {Object=} options - Options to pass to {@link http://webpack.github.io/docs/node.js-api.html#stats-tostring `stats.toString()`}. @param {Boolean} [options.verbose=false] - Writes fully formatted version of `stats` object. @returns {Stream}
[ "Writes", "formatted", "string", "of", "stats", "object", "and", "displays", "related", "webpack", ".", "config", ".", "js", "file", "path", ".", "Can", "be", "piped", "." ]
f8424f97837a224bc07cc18a03ecf649d708e924
https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/formatStream.js#L27-L51
47,669
mattbasta/btype
src/parser.js
parseString
function parseString(input) { var stripped = input.substring(1, input.length - 1); return stripped.replace(/\\(\w|\\)/gi, function(_, b) { switch (b) { case '\\r': return '\r'; case '\\n': return '\n'; case '\\t': return '\t'; case '\\0': return '\0'; case '\\\\': return '\\'; default: throw new SyntaxError('Invalid escape code "' + b + '"'); } }); }
javascript
function parseString(input) { var stripped = input.substring(1, input.length - 1); return stripped.replace(/\\(\w|\\)/gi, function(_, b) { switch (b) { case '\\r': return '\r'; case '\\n': return '\n'; case '\\t': return '\t'; case '\\0': return '\0'; case '\\\\': return '\\'; default: throw new SyntaxError('Invalid escape code "' + b + '"'); } }); }
[ "function", "parseString", "(", "input", ")", "{", "var", "stripped", "=", "input", ".", "substring", "(", "1", ",", "input", ".", "length", "-", "1", ")", ";", "return", "stripped", ".", "replace", "(", "/", "\\\\(\\w|\\\\)", "/", "gi", ",", "function", "(", "_", ",", "b", ")", "{", "switch", "(", "b", ")", "{", "case", "'\\\\r'", ":", "return", "'\\r'", ";", "case", "'\\\\n'", ":", "return", "'\\n'", ";", "case", "'\\\\t'", ":", "return", "'\\t'", ";", "case", "'\\\\0'", ":", "return", "'\\0'", ";", "case", "'\\\\\\\\'", ":", "return", "'\\\\'", ";", "default", ":", "throw", "new", "SyntaxError", "(", "'Invalid escape code \"'", "+", "b", "+", "'\"'", ")", ";", "}", "}", ")", ";", "}" ]
Turns an encoded string into its text content @param {string} input @return {string}
[ "Turns", "an", "encoded", "string", "into", "its", "text", "content" ]
7d28db96f3e14fd83d4a72f6008cb9a26208ab71
https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L11-L25
47,670
mattbasta/btype
src/parser.js
parseSwitchType
function parseSwitchType(lex) { var start = lex.accept('switchtype'); if (!start) { return null; } var expr = parseExpression(lex); lex.assert('{'); var cases = []; var end; do { let c = parseSwitchTypeCase(lex); cases.push(c); } while (!(end = lex.accept('}'))); return new nodes.SwitchTypeNode(expr, cases, start.start, end.end); }
javascript
function parseSwitchType(lex) { var start = lex.accept('switchtype'); if (!start) { return null; } var expr = parseExpression(lex); lex.assert('{'); var cases = []; var end; do { let c = parseSwitchTypeCase(lex); cases.push(c); } while (!(end = lex.accept('}'))); return new nodes.SwitchTypeNode(expr, cases, start.start, end.end); }
[ "function", "parseSwitchType", "(", "lex", ")", "{", "var", "start", "=", "lex", ".", "accept", "(", "'switchtype'", ")", ";", "if", "(", "!", "start", ")", "{", "return", "null", ";", "}", "var", "expr", "=", "parseExpression", "(", "lex", ")", ";", "lex", ".", "assert", "(", "'{'", ")", ";", "var", "cases", "=", "[", "]", ";", "var", "end", ";", "do", "{", "let", "c", "=", "parseSwitchTypeCase", "(", "lex", ")", ";", "cases", ".", "push", "(", "c", ")", ";", "}", "while", "(", "!", "(", "end", "=", "lex", ".", "accept", "(", "'}'", ")", ")", ")", ";", "return", "new", "nodes", ".", "SwitchTypeNode", "(", "expr", ",", "cases", ",", "start", ".", "start", ",", "end", ".", "end", ")", ";", "}" ]
Parses a `switchtype` statement @param {Lexer} lex @return {SwitchType}
[ "Parses", "a", "switchtype", "statement" ]
7d28db96f3e14fd83d4a72f6008cb9a26208ab71
https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1035-L1052
47,671
mattbasta/btype
src/parser.js
parseSwitchTypeCase
function parseSwitchTypeCase(lex) { var start = lex.assert('case'); var type = parseType(lex); lex.assert('{'); var body = parseStatements(lex, '}', false); var end = lex.assert('}'); return new nodes.SwitchTypeCaseNode(type, body, start.start, end.end); }
javascript
function parseSwitchTypeCase(lex) { var start = lex.assert('case'); var type = parseType(lex); lex.assert('{'); var body = parseStatements(lex, '}', false); var end = lex.assert('}'); return new nodes.SwitchTypeCaseNode(type, body, start.start, end.end); }
[ "function", "parseSwitchTypeCase", "(", "lex", ")", "{", "var", "start", "=", "lex", ".", "assert", "(", "'case'", ")", ";", "var", "type", "=", "parseType", "(", "lex", ")", ";", "lex", ".", "assert", "(", "'{'", ")", ";", "var", "body", "=", "parseStatements", "(", "lex", ",", "'}'", ",", "false", ")", ";", "var", "end", "=", "lex", ".", "assert", "(", "'}'", ")", ";", "return", "new", "nodes", ".", "SwitchTypeCaseNode", "(", "type", ",", "body", ",", "start", ".", "start", ",", "end", ".", "end", ")", ";", "}" ]
Parses a SwitchType's case statement @param {Lexer} @return {SwitchTypeCase}
[ "Parses", "a", "SwitchType", "s", "case", "statement" ]
7d28db96f3e14fd83d4a72f6008cb9a26208ab71
https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1059-L1068
47,672
mattbasta/btype
src/parser.js
parseStatement
function parseStatement(lex, isRoot = false) { return parseFunctionDeclaration(lex) || isRoot && parseOperatorStatement(lex) || isRoot && parseObjectDeclaration(lex) || parseIf(lex) || parseReturn(lex) || isRoot && parseExport(lex) || isRoot && parseImport(lex) || parseSwitchType(lex) || parseWhile(lex) || parseDoWhile(lex) || parseFor(lex) || parseBreak(lex) || parseContinue(lex) || parseExpressionBase(lex); }
javascript
function parseStatement(lex, isRoot = false) { return parseFunctionDeclaration(lex) || isRoot && parseOperatorStatement(lex) || isRoot && parseObjectDeclaration(lex) || parseIf(lex) || parseReturn(lex) || isRoot && parseExport(lex) || isRoot && parseImport(lex) || parseSwitchType(lex) || parseWhile(lex) || parseDoWhile(lex) || parseFor(lex) || parseBreak(lex) || parseContinue(lex) || parseExpressionBase(lex); }
[ "function", "parseStatement", "(", "lex", ",", "isRoot", "=", "false", ")", "{", "return", "parseFunctionDeclaration", "(", "lex", ")", "||", "isRoot", "&&", "parseOperatorStatement", "(", "lex", ")", "||", "isRoot", "&&", "parseObjectDeclaration", "(", "lex", ")", "||", "parseIf", "(", "lex", ")", "||", "parseReturn", "(", "lex", ")", "||", "isRoot", "&&", "parseExport", "(", "lex", ")", "||", "isRoot", "&&", "parseImport", "(", "lex", ")", "||", "parseSwitchType", "(", "lex", ")", "||", "parseWhile", "(", "lex", ")", "||", "parseDoWhile", "(", "lex", ")", "||", "parseFor", "(", "lex", ")", "||", "parseBreak", "(", "lex", ")", "||", "parseContinue", "(", "lex", ")", "||", "parseExpressionBase", "(", "lex", ")", ";", "}" ]
Parses a single statement @param {Lexer} lex @param {bool} @return {*}
[ "Parses", "a", "single", "statement" ]
7d28db96f3e14fd83d4a72f6008cb9a26208ab71
https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1076-L1091
47,673
mattbasta/btype
src/parser.js
parseStatements
function parseStatements(lex, endTokens, isRoot) { endTokens = Array.isArray(endTokens) ? endTokens : [endTokens]; var statements = []; var temp = lex.peek(); while (endTokens.indexOf(temp) === -1 && (temp.type && endTokens.indexOf(temp.type) === -1)) { var statement = parseStatement(lex, isRoot); if (!statement) { throw new Error('Invalid statement'); } temp = lex.peek(); statements.push(statement); } return statements; }
javascript
function parseStatements(lex, endTokens, isRoot) { endTokens = Array.isArray(endTokens) ? endTokens : [endTokens]; var statements = []; var temp = lex.peek(); while (endTokens.indexOf(temp) === -1 && (temp.type && endTokens.indexOf(temp.type) === -1)) { var statement = parseStatement(lex, isRoot); if (!statement) { throw new Error('Invalid statement'); } temp = lex.peek(); statements.push(statement); } return statements; }
[ "function", "parseStatements", "(", "lex", ",", "endTokens", ",", "isRoot", ")", "{", "endTokens", "=", "Array", ".", "isArray", "(", "endTokens", ")", "?", "endTokens", ":", "[", "endTokens", "]", ";", "var", "statements", "=", "[", "]", ";", "var", "temp", "=", "lex", ".", "peek", "(", ")", ";", "while", "(", "endTokens", ".", "indexOf", "(", "temp", ")", "===", "-", "1", "&&", "(", "temp", ".", "type", "&&", "endTokens", ".", "indexOf", "(", "temp", ".", "type", ")", "===", "-", "1", ")", ")", "{", "var", "statement", "=", "parseStatement", "(", "lex", ",", "isRoot", ")", ";", "if", "(", "!", "statement", ")", "{", "throw", "new", "Error", "(", "'Invalid statement'", ")", ";", "}", "temp", "=", "lex", ".", "peek", "(", ")", ";", "statements", ".", "push", "(", "statement", ")", ";", "}", "return", "statements", ";", "}" ]
Parses an array of statements @param {Lexer} lex @param {string|string[]} endTokens @param {bool} isRoot @return {array}
[ "Parses", "an", "array", "of", "statements" ]
7d28db96f3e14fd83d4a72f6008cb9a26208ab71
https://github.com/mattbasta/btype/blob/7d28db96f3e14fd83d4a72f6008cb9a26208ab71/src/parser.js#L1100-L1114
47,674
bezoerb/asset-resolver
lib/resolver.js
requestAsync
function requestAsync(resource, opts = {}) { const settings = { followRedirect: true, encoding: null, rejectUnauthorized: false }; if (opts.user && opts.pass) { settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)}; } return new Bluebird((resolve, reject) => { // Handle protocol-relative urls resource = url.resolve('http://te.st', resource); request(resource, settings, (err, resp, body) => { let msg; if (err) { debug('Url failed:', err.message || err); return reject(err); } if (resp.statusCode !== 200) { msg = 'Wrong status code ' + resp.statusCode + ' for ' + resource; debug(msg); return reject(new Error(msg)); } const mimeType = result(resp, 'headers.content-type') || mime.getType(resource); resolve({ contents: body, path: resource, mime: mimeType }); }); }); }
javascript
function requestAsync(resource, opts = {}) { const settings = { followRedirect: true, encoding: null, rejectUnauthorized: false }; if (opts.user && opts.pass) { settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)}; } return new Bluebird((resolve, reject) => { // Handle protocol-relative urls resource = url.resolve('http://te.st', resource); request(resource, settings, (err, resp, body) => { let msg; if (err) { debug('Url failed:', err.message || err); return reject(err); } if (resp.statusCode !== 200) { msg = 'Wrong status code ' + resp.statusCode + ' for ' + resource; debug(msg); return reject(new Error(msg)); } const mimeType = result(resp, 'headers.content-type') || mime.getType(resource); resolve({ contents: body, path: resource, mime: mimeType }); }); }); }
[ "function", "requestAsync", "(", "resource", ",", "opts", "=", "{", "}", ")", "{", "const", "settings", "=", "{", "followRedirect", ":", "true", ",", "encoding", ":", "null", ",", "rejectUnauthorized", ":", "false", "}", ";", "if", "(", "opts", ".", "user", "&&", "opts", ".", "pass", ")", "{", "settings", ".", "headers", "=", "{", "Authorization", ":", "'Basic '", "+", "token", "(", "opts", ".", "user", ",", "opts", ".", "pass", ")", "}", ";", "}", "return", "new", "Bluebird", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "// Handle protocol-relative urls", "resource", "=", "url", ".", "resolve", "(", "'http://te.st'", ",", "resource", ")", ";", "request", "(", "resource", ",", "settings", ",", "(", "err", ",", "resp", ",", "body", ")", "=>", "{", "let", "msg", ";", "if", "(", "err", ")", "{", "debug", "(", "'Url failed:'", ",", "err", ".", "message", "||", "err", ")", ";", "return", "reject", "(", "err", ")", ";", "}", "if", "(", "resp", ".", "statusCode", "!==", "200", ")", "{", "msg", "=", "'Wrong status code '", "+", "resp", ".", "statusCode", "+", "' for '", "+", "resource", ";", "debug", "(", "msg", ")", ";", "return", "reject", "(", "new", "Error", "(", "msg", ")", ")", ";", "}", "const", "mimeType", "=", "result", "(", "resp", ",", "'headers.content-type'", ")", "||", "mime", ".", "getType", "(", "resource", ")", ";", "resolve", "(", "{", "contents", ":", "body", ",", "path", ":", "resource", ",", "mime", ":", "mimeType", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Get external resource @param {string} resource Ressource to be fetched @param {object} opts Option hash @returns {Promise} Promise
[ "Get", "external", "resource" ]
031e634920d62d76e5766dfdfcd7b35b7ca84213
https://github.com/bezoerb/asset-resolver/blob/031e634920d62d76e5766dfdfcd7b35b7ca84213/lib/resolver.js#L52-L88
47,675
bezoerb/asset-resolver
lib/resolver.js
readAsync
function readAsync(resource) { return fs.readFile(resource).then(body => { const mimeType = mime.getType(resource); debug('Fetched:', resource); return Bluebird.resolve({ contents: body, path: resource, mime: mimeType }); }); }
javascript
function readAsync(resource) { return fs.readFile(resource).then(body => { const mimeType = mime.getType(resource); debug('Fetched:', resource); return Bluebird.resolve({ contents: body, path: resource, mime: mimeType }); }); }
[ "function", "readAsync", "(", "resource", ")", "{", "return", "fs", ".", "readFile", "(", "resource", ")", ".", "then", "(", "body", "=>", "{", "const", "mimeType", "=", "mime", ".", "getType", "(", "resource", ")", ";", "debug", "(", "'Fetched:'", ",", "resource", ")", ";", "return", "Bluebird", ".", "resolve", "(", "{", "contents", ":", "body", ",", "path", ":", "resource", ",", "mime", ":", "mimeType", "}", ")", ";", "}", ")", ";", "}" ]
Get local resource @param {string} resource Resource to be fetched @returns {Promise} Promise
[ "Get", "local", "resource" ]
031e634920d62d76e5766dfdfcd7b35b7ca84213
https://github.com/bezoerb/asset-resolver/blob/031e634920d62d76e5766dfdfcd7b35b7ca84213/lib/resolver.js#L95-L107
47,676
dman777/gulp-newy
lib/newy.js
checkMissingDir
function checkMissingDir(destinationFile) { var filePath = path.dirname(destinationFile); var pathAbsolute = path.isAbsolute(filePath); var directories = filePath.split(path.sep); return transversePath(directories); }
javascript
function checkMissingDir(destinationFile) { var filePath = path.dirname(destinationFile); var pathAbsolute = path.isAbsolute(filePath); var directories = filePath.split(path.sep); return transversePath(directories); }
[ "function", "checkMissingDir", "(", "destinationFile", ")", "{", "var", "filePath", "=", "path", ".", "dirname", "(", "destinationFile", ")", ";", "var", "pathAbsolute", "=", "path", ".", "isAbsolute", "(", "filePath", ")", ";", "var", "directories", "=", "filePath", ".", "split", "(", "path", ".", "sep", ")", ";", "return", "transversePath", "(", "directories", ")", ";", "}" ]
check for missing directory
[ "check", "for", "missing", "directory" ]
12e5bb01b908e83c5e3d99d54630168770ec817d
https://github.com/dman777/gulp-newy/blob/12e5bb01b908e83c5e3d99d54630168770ec817d/lib/newy.js#L10-L15
47,677
saggiyogesh/nodeportal
lib/ServeClientFiles/ClientDirWatcher.js
generateCache
function generateCache(filePath) { var id = generateIdFromFilePath(filePath); Debug._l(id); fs.readFile(filePath, 'utf8', function (err, data) { if (err) { Debug._l("err: " + err); return; } fs.stat(filePath, function (err, stat) { setCache(id, {modified:stat.mtime, content:data }); }); }); }
javascript
function generateCache(filePath) { var id = generateIdFromFilePath(filePath); Debug._l(id); fs.readFile(filePath, 'utf8', function (err, data) { if (err) { Debug._l("err: " + err); return; } fs.stat(filePath, function (err, stat) { setCache(id, {modified:stat.mtime, content:data }); }); }); }
[ "function", "generateCache", "(", "filePath", ")", "{", "var", "id", "=", "generateIdFromFilePath", "(", "filePath", ")", ";", "Debug", ".", "_l", "(", "id", ")", ";", "fs", ".", "readFile", "(", "filePath", ",", "'utf8'", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "Debug", ".", "_l", "(", "\"err: \"", "+", "err", ")", ";", "return", ";", "}", "fs", ".", "stat", "(", "filePath", ",", "function", "(", "err", ",", "stat", ")", "{", "setCache", "(", "id", ",", "{", "modified", ":", "stat", ".", "mtime", ",", "content", ":", "data", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Reads file and cache its data @param id @param filePath
[ "Reads", "file", "and", "cache", "its", "data" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/ServeClientFiles/ClientDirWatcher.js#L26-L38
47,678
saggiyogesh/nodeportal
public/js/util.js
function (options) { if (!options) { throw Error("Ajax options missing"); } var that = this, util = Rocket.Util; options.success = util.ajaxResponse(options.callback); util.ajax(options); }
javascript
function (options) { if (!options) { throw Error("Ajax options missing"); } var that = this, util = Rocket.Util; options.success = util.ajaxResponse(options.callback); util.ajax(options); }
[ "function", "(", "options", ")", "{", "if", "(", "!", "options", ")", "{", "throw", "Error", "(", "\"Ajax options missing\"", ")", ";", "}", "var", "that", "=", "this", ",", "util", "=", "Rocket", ".", "Util", ";", "options", ".", "success", "=", "util", ".", "ajaxResponse", "(", "options", ".", "callback", ")", ";", "util", ".", "ajax", "(", "options", ")", ";", "}" ]
Ajax io transport utility method @param options
[ "Ajax", "io", "transport", "utility", "method" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L57-L64
47,679
saggiyogesh/nodeportal
public/js/util.js
function (msg, nodeId, ns, isShow) { ns = ns || Rocket.Plugin.currentPlugin.namespace; var node = $("#" + ns + "_" + nodeId), msgSpan = node.find("span.message"); isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide"); if (node.data("autohide") == true && !node.hasClass("hide")) { node.delay(4000).fadeOut(1000, function () { $(this).addClass("hide"); $(msgSpan).html(""); }); } //attach close listener to hide the flash message $(node.find(".close")).click(function () { node.addClass('hide').css("display", "none"); $(msgSpan).html(""); }); if (msg) msgSpan.html(msg); }
javascript
function (msg, nodeId, ns, isShow) { ns = ns || Rocket.Plugin.currentPlugin.namespace; var node = $("#" + ns + "_" + nodeId), msgSpan = node.find("span.message"); isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide"); if (node.data("autohide") == true && !node.hasClass("hide")) { node.delay(4000).fadeOut(1000, function () { $(this).addClass("hide"); $(msgSpan).html(""); }); } //attach close listener to hide the flash message $(node.find(".close")).click(function () { node.addClass('hide').css("display", "none"); $(msgSpan).html(""); }); if (msg) msgSpan.html(msg); }
[ "function", "(", "msg", ",", "nodeId", ",", "ns", ",", "isShow", ")", "{", "ns", "=", "ns", "||", "Rocket", ".", "Plugin", ".", "currentPlugin", ".", "namespace", ";", "var", "node", "=", "$", "(", "\"#\"", "+", "ns", "+", "\"_\"", "+", "nodeId", ")", ",", "msgSpan", "=", "node", ".", "find", "(", "\"span.message\"", ")", ";", "isShow", "?", "node", ".", "removeClass", "(", "\"hide\"", ")", "&&", "node", ".", "css", "(", "\"display\"", ",", "\"block\"", ")", ":", "node", ".", "addClass", "(", "\"hide\"", ")", ";", "if", "(", "node", ".", "data", "(", "\"autohide\"", ")", "==", "true", "&&", "!", "node", ".", "hasClass", "(", "\"hide\"", ")", ")", "{", "node", ".", "delay", "(", "4000", ")", ".", "fadeOut", "(", "1000", ",", "function", "(", ")", "{", "$", "(", "this", ")", ".", "addClass", "(", "\"hide\"", ")", ";", "$", "(", "msgSpan", ")", ".", "html", "(", "\"\"", ")", ";", "}", ")", ";", "}", "//attach close listener to hide the flash message", "$", "(", "node", ".", "find", "(", "\".close\"", ")", ")", ".", "click", "(", "function", "(", ")", "{", "node", ".", "addClass", "(", "'hide'", ")", ".", "css", "(", "\"display\"", ",", "\"none\"", ")", ";", "$", "(", "msgSpan", ")", ".", "html", "(", "\"\"", ")", ";", "}", ")", ";", "if", "(", "msg", ")", "msgSpan", ".", "html", "(", "msg", ")", ";", "}" ]
Method to toggle show of a flash messages Jade template should be as for error flash #<nodeId>.hide.alert.alert-error button(class="close", data-dismiss="alert") x span.message for success flash #<nodeId>.hide.alert.alert-success button(class="close", data-dismiss="alert") x span.message @param msg - Message to be displayed @param nodeId - Id for flash message container @param ns - Namespace of current plugin @param isShow - flag to show or hide
[ "Method", "to", "toggle", "show", "of", "a", "flash", "messages" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L208-L227
47,680
saggiyogesh/nodeportal
public/js/util.js
function (msg, nodeId, ns) { nodeId = nodeId || "errorFlash"; this.flashMessage(msg, nodeId, ns, true); }
javascript
function (msg, nodeId, ns) { nodeId = nodeId || "errorFlash"; this.flashMessage(msg, nodeId, ns, true); }
[ "function", "(", "msg", ",", "nodeId", ",", "ns", ")", "{", "nodeId", "=", "nodeId", "||", "\"errorFlash\"", ";", "this", ".", "flashMessage", "(", "msg", ",", "nodeId", ",", "ns", ",", "true", ")", ";", "}" ]
Id for error flash is default "errorFlash", without namespace @param msg @param nodeId @param ns
[ "Id", "for", "error", "flash", "is", "default", "errorFlash", "without", "namespace" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/util.js#L234-L237
47,681
saggiyogesh/nodeportal
lib/Renderer/ErrorRenderer.js
ErrorRenderer
function ErrorRenderer(err, req, res) { PageRenderer.call(this, req, res); Object.defineProperties(this, { err: { value: err || new Error() } }); req.attrs.isErrorPage = true; }
javascript
function ErrorRenderer(err, req, res) { PageRenderer.call(this, req, res); Object.defineProperties(this, { err: { value: err || new Error() } }); req.attrs.isErrorPage = true; }
[ "function", "ErrorRenderer", "(", "err", ",", "req", ",", "res", ")", "{", "PageRenderer", ".", "call", "(", "this", ",", "req", ",", "res", ")", ";", "Object", ".", "defineProperties", "(", "this", ",", "{", "err", ":", "{", "value", ":", "err", "||", "new", "Error", "(", ")", "}", "}", ")", ";", "req", ".", "attrs", ".", "isErrorPage", "=", "true", ";", "}" ]
Constructor to create ErrorRenderer @param err @param req @param res @constructor
[ "Constructor", "to", "create", "ErrorRenderer" ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Renderer/ErrorRenderer.js#L21-L29
47,682
KTH/kth-node-api-key-strategy
index.js
Strategy
function Strategy (options, verify) { if (typeof options === 'function') { verify = options options = {} } else { if (options && options.log) { log = options.log } } if (!verify) { throw new Error('apikey authentication strategy requires a verify function') } passport.Strategy.call(this) this._apiKeyHeader = options.apiKeyHeader || 'api_key' this.name = 'apikey' this._verify = verify this._passReqToCallback = true }
javascript
function Strategy (options, verify) { if (typeof options === 'function') { verify = options options = {} } else { if (options && options.log) { log = options.log } } if (!verify) { throw new Error('apikey authentication strategy requires a verify function') } passport.Strategy.call(this) this._apiKeyHeader = options.apiKeyHeader || 'api_key' this.name = 'apikey' this._verify = verify this._passReqToCallback = true }
[ "function", "Strategy", "(", "options", ",", "verify", ")", "{", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "verify", "=", "options", "options", "=", "{", "}", "}", "else", "{", "if", "(", "options", "&&", "options", ".", "log", ")", "{", "log", "=", "options", ".", "log", "}", "}", "if", "(", "!", "verify", ")", "{", "throw", "new", "Error", "(", "'apikey authentication strategy requires a verify function'", ")", "}", "passport", ".", "Strategy", ".", "call", "(", "this", ")", "this", ".", "_apiKeyHeader", "=", "options", ".", "apiKeyHeader", "||", "'api_key'", "this", ".", "name", "=", "'apikey'", "this", ".", "_verify", "=", "verify", "this", ".", "_passReqToCallback", "=", "true", "}" ]
Creates an instance of `Strategy` checking api keys.
[ "Creates", "an", "instance", "of", "Strategy", "checking", "api", "keys", "." ]
617d28cee15661edd007e2567779df9a5a3e0264
https://github.com/KTH/kth-node-api-key-strategy/blob/617d28cee15661edd007e2567779df9a5a3e0264/index.js#L19-L38
47,683
ticup/CloudTypes-paper
shared/CString.js
CString
function CString(value, written, cond) { this.value = value || ''; this.written = written || false; this.cond = cond || false; }
javascript
function CString(value, written, cond) { this.value = value || ''; this.written = written || false; this.cond = cond || false; }
[ "function", "CString", "(", "value", ",", "written", ",", "cond", ")", "{", "this", ".", "value", "=", "value", "||", "''", ";", "this", ".", "written", "=", "written", "||", "false", ";", "this", ".", "cond", "=", "cond", "||", "false", ";", "}" ]
Actual CString object of which an instance represents a variable of which the property is defined with CStringDeclaration
[ "Actual", "CString", "object", "of", "which", "an", "instance", "represents", "a", "variable", "of", "which", "the", "property", "is", "defined", "with", "CStringDeclaration" ]
f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda
https://github.com/ticup/CloudTypes-paper/blob/f3b6adcd60bd66a28eb0e22edfcdcd9500ef7dda/shared/CString.js#L26-L30
47,684
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/undo/plugin.js
function( event ) { var keystroke = event && event.data.getKey(), isModifierKey = keystroke in modifierKeyCodes, isEditingKey = keystroke in editingKeyCodes, wasEditingKey = this.lastKeystroke in editingKeyCodes, sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke, // Keystrokes which navigation through contents. isReset = keystroke in navigationKeyCodes, wasReset = this.lastKeystroke in navigationKeyCodes, // Keystrokes which just introduce new contents. isContent = ( !isEditingKey && !isReset ), // Create undo snap for every different modifier key. modifierSnapshot = ( isEditingKey && !sameAsLastEditingKey ), // Create undo snap on the following cases: // 1. Just start to type . // 2. Typing some content after a modifier. // 3. Typing some content after make a visible selection. startedTyping = !( isModifierKey || this.typing ) || ( isContent && ( wasEditingKey || wasReset ) ); if ( startedTyping || modifierSnapshot ) { var beforeTypeImage = new Image( this.editor ); // Use setTimeout, so we give the necessary time to the // browser to insert the character into the DOM. CKEDITOR.tools.setTimeout( function() { var currentSnapshot = this.editor.getSnapshot(); // In IE, we need to remove the expando attributes. if ( CKEDITOR.env.ie ) currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' ); if ( beforeTypeImage.contents != currentSnapshot ) { // It's safe to now indicate typing state. this.typing = true; // This's a special save, with specified snapshot // and without auto 'fireChange'. if ( !this.save( false, beforeTypeImage, false ) ) // Drop future snapshots. this.snapshots.splice( this.index + 1, this.snapshots.length - this.index - 1 ); this.hasUndo = true; this.hasRedo = false; this.typesCount = 1; this.modifiersCount = 1; this.onChange(); } }, 0, this ); } this.lastKeystroke = keystroke; // Create undo snap after typed too much (over 25 times). if ( isEditingKey ) { this.typesCount = 0; this.modifiersCount++; if ( this.modifiersCount > 25 ) { this.save( false, null, false ); this.modifiersCount = 1; } } else if ( !isReset ) { this.modifiersCount = 0; this.typesCount++; if ( this.typesCount > 25 ) { this.save( false, null, false ); this.typesCount = 1; } } }
javascript
function( event ) { var keystroke = event && event.data.getKey(), isModifierKey = keystroke in modifierKeyCodes, isEditingKey = keystroke in editingKeyCodes, wasEditingKey = this.lastKeystroke in editingKeyCodes, sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke, // Keystrokes which navigation through contents. isReset = keystroke in navigationKeyCodes, wasReset = this.lastKeystroke in navigationKeyCodes, // Keystrokes which just introduce new contents. isContent = ( !isEditingKey && !isReset ), // Create undo snap for every different modifier key. modifierSnapshot = ( isEditingKey && !sameAsLastEditingKey ), // Create undo snap on the following cases: // 1. Just start to type . // 2. Typing some content after a modifier. // 3. Typing some content after make a visible selection. startedTyping = !( isModifierKey || this.typing ) || ( isContent && ( wasEditingKey || wasReset ) ); if ( startedTyping || modifierSnapshot ) { var beforeTypeImage = new Image( this.editor ); // Use setTimeout, so we give the necessary time to the // browser to insert the character into the DOM. CKEDITOR.tools.setTimeout( function() { var currentSnapshot = this.editor.getSnapshot(); // In IE, we need to remove the expando attributes. if ( CKEDITOR.env.ie ) currentSnapshot = currentSnapshot.replace( /\s+data-cke-expando=".*?"/g, '' ); if ( beforeTypeImage.contents != currentSnapshot ) { // It's safe to now indicate typing state. this.typing = true; // This's a special save, with specified snapshot // and without auto 'fireChange'. if ( !this.save( false, beforeTypeImage, false ) ) // Drop future snapshots. this.snapshots.splice( this.index + 1, this.snapshots.length - this.index - 1 ); this.hasUndo = true; this.hasRedo = false; this.typesCount = 1; this.modifiersCount = 1; this.onChange(); } }, 0, this ); } this.lastKeystroke = keystroke; // Create undo snap after typed too much (over 25 times). if ( isEditingKey ) { this.typesCount = 0; this.modifiersCount++; if ( this.modifiersCount > 25 ) { this.save( false, null, false ); this.modifiersCount = 1; } } else if ( !isReset ) { this.modifiersCount = 0; this.typesCount++; if ( this.typesCount > 25 ) { this.save( false, null, false ); this.typesCount = 1; } } }
[ "function", "(", "event", ")", "{", "var", "keystroke", "=", "event", "&&", "event", ".", "data", ".", "getKey", "(", ")", ",", "isModifierKey", "=", "keystroke", "in", "modifierKeyCodes", ",", "isEditingKey", "=", "keystroke", "in", "editingKeyCodes", ",", "wasEditingKey", "=", "this", ".", "lastKeystroke", "in", "editingKeyCodes", ",", "sameAsLastEditingKey", "=", "isEditingKey", "&&", "keystroke", "==", "this", ".", "lastKeystroke", ",", "// Keystrokes which navigation through contents.\r", "isReset", "=", "keystroke", "in", "navigationKeyCodes", ",", "wasReset", "=", "this", ".", "lastKeystroke", "in", "navigationKeyCodes", ",", "// Keystrokes which just introduce new contents.\r", "isContent", "=", "(", "!", "isEditingKey", "&&", "!", "isReset", ")", ",", "// Create undo snap for every different modifier key.\r", "modifierSnapshot", "=", "(", "isEditingKey", "&&", "!", "sameAsLastEditingKey", ")", ",", "// Create undo snap on the following cases:\r", "// 1. Just start to type .\r", "// 2. Typing some content after a modifier.\r", "// 3. Typing some content after make a visible selection.\r", "startedTyping", "=", "!", "(", "isModifierKey", "||", "this", ".", "typing", ")", "||", "(", "isContent", "&&", "(", "wasEditingKey", "||", "wasReset", ")", ")", ";", "if", "(", "startedTyping", "||", "modifierSnapshot", ")", "{", "var", "beforeTypeImage", "=", "new", "Image", "(", "this", ".", "editor", ")", ";", "// Use setTimeout, so we give the necessary time to the\r", "// browser to insert the character into the DOM.\r", "CKEDITOR", ".", "tools", ".", "setTimeout", "(", "function", "(", ")", "{", "var", "currentSnapshot", "=", "this", ".", "editor", ".", "getSnapshot", "(", ")", ";", "// In IE, we need to remove the expando attributes.\r", "if", "(", "CKEDITOR", ".", "env", ".", "ie", ")", "currentSnapshot", "=", "currentSnapshot", ".", "replace", "(", "/", "\\s+data-cke-expando=\".*?\"", "/", "g", ",", "''", ")", ";", "if", "(", "beforeTypeImage", ".", "contents", "!=", "currentSnapshot", ")", "{", "// It's safe to now indicate typing state.\r", "this", ".", "typing", "=", "true", ";", "// This's a special save, with specified snapshot\r", "// and without auto 'fireChange'.\r", "if", "(", "!", "this", ".", "save", "(", "false", ",", "beforeTypeImage", ",", "false", ")", ")", "// Drop future snapshots.\r", "this", ".", "snapshots", ".", "splice", "(", "this", ".", "index", "+", "1", ",", "this", ".", "snapshots", ".", "length", "-", "this", ".", "index", "-", "1", ")", ";", "this", ".", "hasUndo", "=", "true", ";", "this", ".", "hasRedo", "=", "false", ";", "this", ".", "typesCount", "=", "1", ";", "this", ".", "modifiersCount", "=", "1", ";", "this", ".", "onChange", "(", ")", ";", "}", "}", ",", "0", ",", "this", ")", ";", "}", "this", ".", "lastKeystroke", "=", "keystroke", ";", "// Create undo snap after typed too much (over 25 times).\r", "if", "(", "isEditingKey", ")", "{", "this", ".", "typesCount", "=", "0", ";", "this", ".", "modifiersCount", "++", ";", "if", "(", "this", ".", "modifiersCount", ">", "25", ")", "{", "this", ".", "save", "(", "false", ",", "null", ",", "false", ")", ";", "this", ".", "modifiersCount", "=", "1", ";", "}", "}", "else", "if", "(", "!", "isReset", ")", "{", "this", ".", "modifiersCount", "=", "0", ";", "this", ".", "typesCount", "++", ";", "if", "(", "this", ".", "typesCount", ">", "25", ")", "{", "this", ".", "save", "(", "false", ",", "null", ",", "false", ")", ";", "this", ".", "typesCount", "=", "1", ";", "}", "}", "}" ]
Process undo system regard keystrikes. @param {CKEDITOR.dom.event} event
[ "Process", "undo", "system", "regard", "keystrikes", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L238-L325
47,685
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/undo/plugin.js
function( onContentOnly, image, autoFireChange ) { var snapshots = this.snapshots; // Get a content image. if ( !image ) image = new Image( this.editor ); // Do nothing if it was not possible to retrieve an image. if ( image.contents === false ) return false; // Check if this is a duplicate. In such case, do nothing. if ( this.currentImage && image.equals( this.currentImage, onContentOnly ) ) return false; // Drop future snapshots. snapshots.splice( this.index + 1, snapshots.length - this.index - 1 ); // If we have reached the limit, remove the oldest one. if ( snapshots.length == this.limit ) snapshots.shift(); // Add the new image, updating the current index. this.index = snapshots.push( image ) - 1; this.currentImage = image; if ( autoFireChange !== false ) this.fireChange(); return true; }
javascript
function( onContentOnly, image, autoFireChange ) { var snapshots = this.snapshots; // Get a content image. if ( !image ) image = new Image( this.editor ); // Do nothing if it was not possible to retrieve an image. if ( image.contents === false ) return false; // Check if this is a duplicate. In such case, do nothing. if ( this.currentImage && image.equals( this.currentImage, onContentOnly ) ) return false; // Drop future snapshots. snapshots.splice( this.index + 1, snapshots.length - this.index - 1 ); // If we have reached the limit, remove the oldest one. if ( snapshots.length == this.limit ) snapshots.shift(); // Add the new image, updating the current index. this.index = snapshots.push( image ) - 1; this.currentImage = image; if ( autoFireChange !== false ) this.fireChange(); return true; }
[ "function", "(", "onContentOnly", ",", "image", ",", "autoFireChange", ")", "{", "var", "snapshots", "=", "this", ".", "snapshots", ";", "// Get a content image.\r", "if", "(", "!", "image", ")", "image", "=", "new", "Image", "(", "this", ".", "editor", ")", ";", "// Do nothing if it was not possible to retrieve an image.\r", "if", "(", "image", ".", "contents", "===", "false", ")", "return", "false", ";", "// Check if this is a duplicate. In such case, do nothing.\r", "if", "(", "this", ".", "currentImage", "&&", "image", ".", "equals", "(", "this", ".", "currentImage", ",", "onContentOnly", ")", ")", "return", "false", ";", "// Drop future snapshots.\r", "snapshots", ".", "splice", "(", "this", ".", "index", "+", "1", ",", "snapshots", ".", "length", "-", "this", ".", "index", "-", "1", ")", ";", "// If we have reached the limit, remove the oldest one.\r", "if", "(", "snapshots", ".", "length", "==", "this", ".", "limit", ")", "snapshots", ".", "shift", "(", ")", ";", "// Add the new image, updating the current index.\r", "this", ".", "index", "=", "snapshots", ".", "push", "(", "image", ")", "-", "1", ";", "this", ".", "currentImage", "=", "image", ";", "if", "(", "autoFireChange", "!==", "false", ")", "this", ".", "fireChange", "(", ")", ";", "return", "true", ";", "}" ]
Save a snapshot of document image for later retrieve.
[ "Save", "a", "snapshot", "of", "document", "image", "for", "later", "retrieve", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L378-L409
47,686
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/undo/plugin.js
function( isUndo ) { var snapshots = this.snapshots, currentImage = this.currentImage, image, i; if ( currentImage ) { if ( isUndo ) { for ( i = this.index - 1 ; i >= 0 ; i-- ) { image = snapshots[ i ]; if ( !currentImage.equals( image, true ) ) { image.index = i; return image; } } } else { for ( i = this.index + 1 ; i < snapshots.length ; i++ ) { image = snapshots[ i ]; if ( !currentImage.equals( image, true ) ) { image.index = i; return image; } } } } return null; }
javascript
function( isUndo ) { var snapshots = this.snapshots, currentImage = this.currentImage, image, i; if ( currentImage ) { if ( isUndo ) { for ( i = this.index - 1 ; i >= 0 ; i-- ) { image = snapshots[ i ]; if ( !currentImage.equals( image, true ) ) { image.index = i; return image; } } } else { for ( i = this.index + 1 ; i < snapshots.length ; i++ ) { image = snapshots[ i ]; if ( !currentImage.equals( image, true ) ) { image.index = i; return image; } } } } return null; }
[ "function", "(", "isUndo", ")", "{", "var", "snapshots", "=", "this", ".", "snapshots", ",", "currentImage", "=", "this", ".", "currentImage", ",", "image", ",", "i", ";", "if", "(", "currentImage", ")", "{", "if", "(", "isUndo", ")", "{", "for", "(", "i", "=", "this", ".", "index", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "image", "=", "snapshots", "[", "i", "]", ";", "if", "(", "!", "currentImage", ".", "equals", "(", "image", ",", "true", ")", ")", "{", "image", ".", "index", "=", "i", ";", "return", "image", ";", "}", "}", "}", "else", "{", "for", "(", "i", "=", "this", ".", "index", "+", "1", ";", "i", "<", "snapshots", ".", "length", ";", "i", "++", ")", "{", "image", "=", "snapshots", "[", "i", "]", ";", "if", "(", "!", "currentImage", ".", "equals", "(", "image", ",", "true", ")", ")", "{", "image", ".", "index", "=", "i", ";", "return", "image", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Get the closest available image.
[ "Get", "the", "closest", "available", "image", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L437-L472
47,687
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/undo/plugin.js
function() { if ( this.undoable() ) { this.save( true ); var image = this.getNextImage( true ); if ( image ) return this.restoreImage( image ), true; } return false; }
javascript
function() { if ( this.undoable() ) { this.save( true ); var image = this.getNextImage( true ); if ( image ) return this.restoreImage( image ), true; } return false; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "undoable", "(", ")", ")", "{", "this", ".", "save", "(", "true", ")", ";", "var", "image", "=", "this", ".", "getNextImage", "(", "true", ")", ";", "if", "(", "image", ")", "return", "this", ".", "restoreImage", "(", "image", ")", ",", "true", ";", "}", "return", "false", ";", "}" ]
Perform undo on current index.
[ "Perform", "undo", "on", "current", "index", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L496-L508
47,688
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/undo/plugin.js
function() { if ( this.redoable() ) { // Try to save. If no changes have been made, the redo stack // will not change, so it will still be redoable. this.save( true ); // If instead we had changes, we can't redo anymore. if ( this.redoable() ) { var image = this.getNextImage( false ); if ( image ) return this.restoreImage( image ), true; } } return false; }
javascript
function() { if ( this.redoable() ) { // Try to save. If no changes have been made, the redo stack // will not change, so it will still be redoable. this.save( true ); // If instead we had changes, we can't redo anymore. if ( this.redoable() ) { var image = this.getNextImage( false ); if ( image ) return this.restoreImage( image ), true; } } return false; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "redoable", "(", ")", ")", "{", "// Try to save. If no changes have been made, the redo stack\r", "// will not change, so it will still be redoable.\r", "this", ".", "save", "(", "true", ")", ";", "// If instead we had changes, we can't redo anymore.\r", "if", "(", "this", ".", "redoable", "(", ")", ")", "{", "var", "image", "=", "this", ".", "getNextImage", "(", "false", ")", ";", "if", "(", "image", ")", "return", "this", ".", "restoreImage", "(", "image", ")", ",", "true", ";", "}", "}", "return", "false", ";", "}" ]
Perform redo on current index.
[ "Perform", "redo", "on", "current", "index", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/undo/plugin.js#L513-L531
47,689
vega/vega-projection
src/projections.js
create
function create(type, constructor) { return function projection() { var p = constructor(); p.type = type; p.path = geoPath().projection(p); p.copy = p.copy || function() { var c = projection(); projectionProperties.forEach(function(prop) { if (p.hasOwnProperty(prop)) c[prop](p[prop]()); }); c.path.pointRadius(p.path.pointRadius()); return c; }; return p; }; }
javascript
function create(type, constructor) { return function projection() { var p = constructor(); p.type = type; p.path = geoPath().projection(p); p.copy = p.copy || function() { var c = projection(); projectionProperties.forEach(function(prop) { if (p.hasOwnProperty(prop)) c[prop](p[prop]()); }); c.path.pointRadius(p.path.pointRadius()); return c; }; return p; }; }
[ "function", "create", "(", "type", ",", "constructor", ")", "{", "return", "function", "projection", "(", ")", "{", "var", "p", "=", "constructor", "(", ")", ";", "p", ".", "type", "=", "type", ";", "p", ".", "path", "=", "geoPath", "(", ")", ".", "projection", "(", "p", ")", ";", "p", ".", "copy", "=", "p", ".", "copy", "||", "function", "(", ")", "{", "var", "c", "=", "projection", "(", ")", ";", "projectionProperties", ".", "forEach", "(", "function", "(", "prop", ")", "{", "if", "(", "p", ".", "hasOwnProperty", "(", "prop", ")", ")", "c", "[", "prop", "]", "(", "p", "[", "prop", "]", "(", ")", ")", ";", "}", ")", ";", "c", ".", "path", ".", "pointRadius", "(", "p", ".", "path", ".", "pointRadius", "(", ")", ")", ";", "return", "c", ";", "}", ";", "return", "p", ";", "}", ";", "}" ]
Augment projections with their type and a copy method.
[ "Augment", "projections", "with", "their", "type", "and", "a", "copy", "method", "." ]
0d71d4ed52196373f92f369ed8cffb9233eaabd1
https://github.com/vega/vega-projection/blob/0d71d4ed52196373f92f369ed8cffb9233eaabd1/src/projections.js#L50-L69
47,690
levilindsey/physx
src/collisions/src/collidable-factories.js
createObbFromRenderableShape
function createObbFromRenderableShape(params, physicsJob) { const halfRangeX = params.scale[0] / 2; const halfRangeY = params.scale[1] / 2; const halfRangeZ = params.scale[2] / 2; return new Obb(halfRangeX, halfRangeY, halfRangeZ, params.isStationary, physicsJob); }
javascript
function createObbFromRenderableShape(params, physicsJob) { const halfRangeX = params.scale[0] / 2; const halfRangeY = params.scale[1] / 2; const halfRangeZ = params.scale[2] / 2; return new Obb(halfRangeX, halfRangeY, halfRangeZ, params.isStationary, physicsJob); }
[ "function", "createObbFromRenderableShape", "(", "params", ",", "physicsJob", ")", "{", "const", "halfRangeX", "=", "params", ".", "scale", "[", "0", "]", "/", "2", ";", "const", "halfRangeY", "=", "params", ".", "scale", "[", "1", "]", "/", "2", ";", "const", "halfRangeZ", "=", "params", ".", "scale", "[", "2", "]", "/", "2", ";", "return", "new", "Obb", "(", "halfRangeX", ",", "halfRangeY", ",", "halfRangeZ", ",", "params", ".", "isStationary", ",", "physicsJob", ")", ";", "}" ]
This assumes the base RenderableShape has a side length of one unit. @param {CollidableShapeConfig} params @param {CollidablePhysicsJob} [physicsJob] @returns {Collidable}
[ "This", "assumes", "the", "base", "RenderableShape", "has", "a", "side", "length", "of", "one", "unit", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L28-L33
47,691
levilindsey/physx
src/collisions/src/collidable-factories.js
createSphereFromRenderableShape
function createSphereFromRenderableShape(params, physicsJob) { const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3); return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob); }
javascript
function createSphereFromRenderableShape(params, physicsJob) { const radius = params.radius || vec3.length(params.scale) / Math.sqrt(3); return new Sphere(0, 0, 0, radius, params.isStationary, physicsJob); }
[ "function", "createSphereFromRenderableShape", "(", "params", ",", "physicsJob", ")", "{", "const", "radius", "=", "params", ".", "radius", "||", "vec3", ".", "length", "(", "params", ".", "scale", ")", "/", "Math", ".", "sqrt", "(", "3", ")", ";", "return", "new", "Sphere", "(", "0", ",", "0", ",", "0", ",", "radius", ",", "params", ".", "isStationary", ",", "physicsJob", ")", ";", "}" ]
This assumes the base RenderableShape has a "radius" of one unit. @param {CollidableShapeConfig} params @param {CollidablePhysicsJob} [physicsJob] @returns {Collidable}
[ "This", "assumes", "the", "base", "RenderableShape", "has", "a", "radius", "of", "one", "unit", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L42-L45
47,692
levilindsey/physx
src/collisions/src/collidable-factories.js
createCapsuleFromRenderableShape
function createCapsuleFromRenderableShape(params, physicsJob) { const scale = params.scale; const capsuleEndPointsDistance = params.capsuleEndPointsDistance; const isStationary = params.isStationary; let radius = params.radius; let halfDistance; // There are two modes: either we use scale, or we use radius and capsuleEndPointsDistance. if (typeof radius === 'number' && typeof capsuleEndPointsDistance === 'number') { halfDistance = capsuleEndPointsDistance / 2; } else { const copy = vec3.clone(scale); copy.sort(); const length = copy[2]; radius = (copy[0] + copy[1]) / 2; halfDistance = length / 2 - radius; } const orientation = quat.create(); if (scale[0] > scale[1]) { if (scale[0] > scale[2]) { vec3.rotateY(orientation, orientation, _geometry.HALF_PI); } else { // Do nothing; the capsule defaults to being aligned with the z-axis. } } else { if (scale[1] > scale[2]) { vec3.rotateX(orientation, orientation, -_geometry.HALF_PI); } else { // Do nothing; the capsule defaults to being aligned with the z-axis. } } const capsule = new Capsule(halfDistance, radius, isStationary, physicsJob); capsule.orientation = orientation; return capsule; }
javascript
function createCapsuleFromRenderableShape(params, physicsJob) { const scale = params.scale; const capsuleEndPointsDistance = params.capsuleEndPointsDistance; const isStationary = params.isStationary; let radius = params.radius; let halfDistance; // There are two modes: either we use scale, or we use radius and capsuleEndPointsDistance. if (typeof radius === 'number' && typeof capsuleEndPointsDistance === 'number') { halfDistance = capsuleEndPointsDistance / 2; } else { const copy = vec3.clone(scale); copy.sort(); const length = copy[2]; radius = (copy[0] + copy[1]) / 2; halfDistance = length / 2 - radius; } const orientation = quat.create(); if (scale[0] > scale[1]) { if (scale[0] > scale[2]) { vec3.rotateY(orientation, orientation, _geometry.HALF_PI); } else { // Do nothing; the capsule defaults to being aligned with the z-axis. } } else { if (scale[1] > scale[2]) { vec3.rotateX(orientation, orientation, -_geometry.HALF_PI); } else { // Do nothing; the capsule defaults to being aligned with the z-axis. } } const capsule = new Capsule(halfDistance, radius, isStationary, physicsJob); capsule.orientation = orientation; return capsule; }
[ "function", "createCapsuleFromRenderableShape", "(", "params", ",", "physicsJob", ")", "{", "const", "scale", "=", "params", ".", "scale", ";", "const", "capsuleEndPointsDistance", "=", "params", ".", "capsuleEndPointsDistance", ";", "const", "isStationary", "=", "params", ".", "isStationary", ";", "let", "radius", "=", "params", ".", "radius", ";", "let", "halfDistance", ";", "// There are two modes: either we use scale, or we use radius and capsuleEndPointsDistance.", "if", "(", "typeof", "radius", "===", "'number'", "&&", "typeof", "capsuleEndPointsDistance", "===", "'number'", ")", "{", "halfDistance", "=", "capsuleEndPointsDistance", "/", "2", ";", "}", "else", "{", "const", "copy", "=", "vec3", ".", "clone", "(", "scale", ")", ";", "copy", ".", "sort", "(", ")", ";", "const", "length", "=", "copy", "[", "2", "]", ";", "radius", "=", "(", "copy", "[", "0", "]", "+", "copy", "[", "1", "]", ")", "/", "2", ";", "halfDistance", "=", "length", "/", "2", "-", "radius", ";", "}", "const", "orientation", "=", "quat", ".", "create", "(", ")", ";", "if", "(", "scale", "[", "0", "]", ">", "scale", "[", "1", "]", ")", "{", "if", "(", "scale", "[", "0", "]", ">", "scale", "[", "2", "]", ")", "{", "vec3", ".", "rotateY", "(", "orientation", ",", "orientation", ",", "_geometry", ".", "HALF_PI", ")", ";", "}", "else", "{", "// Do nothing; the capsule defaults to being aligned with the z-axis.", "}", "}", "else", "{", "if", "(", "scale", "[", "1", "]", ">", "scale", "[", "2", "]", ")", "{", "vec3", ".", "rotateX", "(", "orientation", ",", "orientation", ",", "-", "_geometry", ".", "HALF_PI", ")", ";", "}", "else", "{", "// Do nothing; the capsule defaults to being aligned with the z-axis.", "}", "}", "const", "capsule", "=", "new", "Capsule", "(", "halfDistance", ",", "radius", ",", "isStationary", ",", "physicsJob", ")", ";", "capsule", ".", "orientation", "=", "orientation", ";", "return", "capsule", ";", "}" ]
The radius of the created capsule will be an average from the two shortest sides. There are two modes: either we use scale, or we use radius and capsuleEndPointsDistance. @param {CollidableShapeConfig} params @param {CollidablePhysicsJob} [physicsJob] @returns {Collidable}
[ "The", "radius", "of", "the", "created", "capsule", "will", "be", "an", "average", "from", "the", "two", "shortest", "sides", "." ]
62df9f6968082ed34aa784a23f3db6c8feca6f3a
https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collidable-factories.js#L56-L95
47,693
saggiyogesh/nodeportal
public/ckeditor/_source/core/htmlparser/fragment.js
function( node, index ) { isNaN( index ) && ( index = this.children.length ); var previous = index > 0 ? this.children[ index - 1 ] : null; if ( previous ) { // If the block to be appended is following text, trim spaces at // the right of it. if ( node._.isBlockLike && previous.type == CKEDITOR.NODE_TEXT ) { previous.value = CKEDITOR.tools.rtrim( previous.value ); // If we have completely cleared the previous node. if ( previous.value.length === 0 ) { // Remove it from the list and add the node again. this.children.pop(); this.add( node ); return; } } previous.next = node; } node.previous = previous; node.parent = this; this.children.splice( index, 0, node ); this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike ); }
javascript
function( node, index ) { isNaN( index ) && ( index = this.children.length ); var previous = index > 0 ? this.children[ index - 1 ] : null; if ( previous ) { // If the block to be appended is following text, trim spaces at // the right of it. if ( node._.isBlockLike && previous.type == CKEDITOR.NODE_TEXT ) { previous.value = CKEDITOR.tools.rtrim( previous.value ); // If we have completely cleared the previous node. if ( previous.value.length === 0 ) { // Remove it from the list and add the node again. this.children.pop(); this.add( node ); return; } } previous.next = node; } node.previous = previous; node.parent = this; this.children.splice( index, 0, node ); this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike ); }
[ "function", "(", "node", ",", "index", ")", "{", "isNaN", "(", "index", ")", "&&", "(", "index", "=", "this", ".", "children", ".", "length", ")", ";", "var", "previous", "=", "index", ">", "0", "?", "this", ".", "children", "[", "index", "-", "1", "]", ":", "null", ";", "if", "(", "previous", ")", "{", "// If the block to be appended is following text, trim spaces at\r", "// the right of it.\r", "if", "(", "node", ".", "_", ".", "isBlockLike", "&&", "previous", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", ")", "{", "previous", ".", "value", "=", "CKEDITOR", ".", "tools", ".", "rtrim", "(", "previous", ".", "value", ")", ";", "// If we have completely cleared the previous node.\r", "if", "(", "previous", ".", "value", ".", "length", "===", "0", ")", "{", "// Remove it from the list and add the node again.\r", "this", ".", "children", ".", "pop", "(", ")", ";", "this", ".", "add", "(", "node", ")", ";", "return", ";", "}", "}", "previous", ".", "next", "=", "node", ";", "}", "node", ".", "previous", "=", "previous", ";", "node", ".", "parent", "=", "this", ";", "this", ".", "children", ".", "splice", "(", "index", ",", "0", ",", "node", ")", ";", "this", ".", "_", ".", "hasInlineStarted", "=", "node", ".", "type", "==", "CKEDITOR", ".", "NODE_TEXT", "||", "(", "node", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", "&&", "!", "node", ".", "_", ".", "isBlockLike", ")", ";", "}" ]
Adds a node to this fragment. @param {Object} node The node to be added. It can be any of of the following types: {@link CKEDITOR.htmlParser.element}, {@link CKEDITOR.htmlParser.text} and {@link CKEDITOR.htmlParser.comment}. @param {Number} [index] From where the insertion happens. @example
[ "Adds", "a", "node", "to", "this", "fragment", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/fragment.js#L451-L483
47,694
saggiyogesh/nodeportal
public/ckeditor/_source/core/htmlparser/fragment.js
function( writer, filter ) { var isChildrenFiltered; this.filterChildren = function() { var writer = new CKEDITOR.htmlParser.basicWriter(); this.writeChildrenHtml.call( this, writer, filter, true ); var html = writer.getHtml(); this.children = new CKEDITOR.htmlParser.fragment.fromHtml( html ).children; isChildrenFiltered = 1; }; // Filtering the root fragment before anything else. !this.name && filter && filter.onFragment( this ); this.writeChildrenHtml( writer, isChildrenFiltered ? null : filter ); }
javascript
function( writer, filter ) { var isChildrenFiltered; this.filterChildren = function() { var writer = new CKEDITOR.htmlParser.basicWriter(); this.writeChildrenHtml.call( this, writer, filter, true ); var html = writer.getHtml(); this.children = new CKEDITOR.htmlParser.fragment.fromHtml( html ).children; isChildrenFiltered = 1; }; // Filtering the root fragment before anything else. !this.name && filter && filter.onFragment( this ); this.writeChildrenHtml( writer, isChildrenFiltered ? null : filter ); }
[ "function", "(", "writer", ",", "filter", ")", "{", "var", "isChildrenFiltered", ";", "this", ".", "filterChildren", "=", "function", "(", ")", "{", "var", "writer", "=", "new", "CKEDITOR", ".", "htmlParser", ".", "basicWriter", "(", ")", ";", "this", ".", "writeChildrenHtml", ".", "call", "(", "this", ",", "writer", ",", "filter", ",", "true", ")", ";", "var", "html", "=", "writer", ".", "getHtml", "(", ")", ";", "this", ".", "children", "=", "new", "CKEDITOR", ".", "htmlParser", ".", "fragment", ".", "fromHtml", "(", "html", ")", ".", "children", ";", "isChildrenFiltered", "=", "1", ";", "}", ";", "// Filtering the root fragment before anything else.\r", "!", "this", ".", "name", "&&", "filter", "&&", "filter", ".", "onFragment", "(", "this", ")", ";", "this", ".", "writeChildrenHtml", "(", "writer", ",", "isChildrenFiltered", "?", "null", ":", "filter", ")", ";", "}" ]
Writes the fragment HTML to a CKEDITOR.htmlWriter. @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. @example var writer = new CKEDITOR.htmlWriter(); var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '&lt;P&gt;&lt;B&gt;Example' ); fragment.writeHtml( writer ) alert( writer.getHtml() ); "&lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;"
[ "Writes", "the", "fragment", "HTML", "to", "a", "CKEDITOR", ".", "htmlWriter", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/fragment.js#L494-L510
47,695
philmander/inverted
src/inverted/ProtoFactory.js
function(constructorFn, args) { var newConstructorFn = function () { constructorFn.apply(this, args); }; newConstructorFn.prototype = constructorFn.prototype; return new newConstructorFn(); }
javascript
function(constructorFn, args) { var newConstructorFn = function () { constructorFn.apply(this, args); }; newConstructorFn.prototype = constructorFn.prototype; return new newConstructorFn(); }
[ "function", "(", "constructorFn", ",", "args", ")", "{", "var", "newConstructorFn", "=", "function", "(", ")", "{", "constructorFn", ".", "apply", "(", "this", ",", "args", ")", ";", "}", ";", "newConstructorFn", ".", "prototype", "=", "constructorFn", ".", "prototype", ";", "return", "new", "newConstructorFn", "(", ")", ";", "}" ]
magic constructor fn
[ "magic", "constructor", "fn" ]
af49a1ab2f501a19c457a8b41a40306e12103bf4
https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/src/inverted/ProtoFactory.js#L126-L133
47,696
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/tableresize/plugin.js
getMasterPillarRow
function getMasterPillarRow( table ) { var $rows = table.$.rows, maxCells = 0, cellsCount, $elected, $tr; for ( var i = 0, len = $rows.length ; i < len; i++ ) { $tr = $rows[ i ]; cellsCount = $tr.cells.length; if ( cellsCount > maxCells ) { maxCells = cellsCount; $elected = $tr; } } return $elected; }
javascript
function getMasterPillarRow( table ) { var $rows = table.$.rows, maxCells = 0, cellsCount, $elected, $tr; for ( var i = 0, len = $rows.length ; i < len; i++ ) { $tr = $rows[ i ]; cellsCount = $tr.cells.length; if ( cellsCount > maxCells ) { maxCells = cellsCount; $elected = $tr; } } return $elected; }
[ "function", "getMasterPillarRow", "(", "table", ")", "{", "var", "$rows", "=", "table", ".", "$", ".", "rows", ",", "maxCells", "=", "0", ",", "cellsCount", ",", "$elected", ",", "$tr", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "$rows", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "$tr", "=", "$rows", "[", "i", "]", ";", "cellsCount", "=", "$tr", ".", "cells", ".", "length", ";", "if", "(", "cellsCount", ">", "maxCells", ")", "{", "maxCells", "=", "cellsCount", ";", "$elected", "=", "$tr", ";", "}", "}", "return", "$elected", ";", "}" ]
Gets the table row that contains the most columns.
[ "Gets", "the", "table", "row", "that", "contains", "the", "most", "columns", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/tableresize/plugin.js#L39-L58
47,697
fvsch/gulp-task-maker
tools.js
catchErrors
function catchErrors() { // don't use an arrow function, we need the `this` instance! return plumber(function(err) { if (!err.plugin) { err.plugin = 'gulp-task-maker' } showError(err) // keep watch tasks running if (this && typeof this.emit === 'function') { this.emit('end') } }) }
javascript
function catchErrors() { // don't use an arrow function, we need the `this` instance! return plumber(function(err) { if (!err.plugin) { err.plugin = 'gulp-task-maker' } showError(err) // keep watch tasks running if (this && typeof this.emit === 'function') { this.emit('end') } }) }
[ "function", "catchErrors", "(", ")", "{", "// don't use an arrow function, we need the `this` instance!", "return", "plumber", "(", "function", "(", "err", ")", "{", "if", "(", "!", "err", ".", "plugin", ")", "{", "err", ".", "plugin", "=", "'gulp-task-maker'", "}", "showError", "(", "err", ")", "// keep watch tasks running", "if", "(", "this", "&&", "typeof", "this", ".", "emit", "===", "'function'", ")", "{", "this", ".", "emit", "(", "'end'", ")", "}", "}", ")", "}" ]
gulp-plumber with our custom error handler @return {*}
[ "gulp", "-", "plumber", "with", "our", "custom", "error", "handler" ]
20ab4245f2d75174786ad140793e9438c025d546
https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/tools.js#L19-L31
47,698
saggiyogesh/nodeportal
public/ckeditor/_source/plugins/list/plugin.js
dirToListItems
function dirToListItems( list ) { var dir = list.getDirection(); if ( dir ) { for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ ) { if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() ) child.setAttribute( 'dir', dir ); } list.removeAttribute( 'dir' ); } }
javascript
function dirToListItems( list ) { var dir = list.getDirection(); if ( dir ) { for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ ) { if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() ) child.setAttribute( 'dir', dir ); } list.removeAttribute( 'dir' ); } }
[ "function", "dirToListItems", "(", "list", ")", "{", "var", "dir", "=", "list", ".", "getDirection", "(", ")", ";", "if", "(", "dir", ")", "{", "for", "(", "var", "i", "=", "0", ",", "children", "=", "list", ".", "getChildren", "(", ")", ",", "child", ";", "child", "=", "children", ".", "getItem", "(", "i", ")", ",", "i", "<", "children", ".", "count", "(", ")", ";", "i", "++", ")", "{", "if", "(", "child", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", "&&", "child", ".", "is", "(", "'li'", ")", "&&", "!", "child", ".", "getDirection", "(", ")", ")", "child", ".", "setAttribute", "(", "'dir'", ",", "dir", ")", ";", "}", "list", ".", "removeAttribute", "(", "'dir'", ")", ";", "}", "}" ]
Move direction attribute from root to list items.
[ "Move", "direction", "attribute", "from", "root", "to", "list", "items", "." ]
cfd5b340f259d3a57c20892a1e2c95b133fe99ee
https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/list/plugin.js#L487-L500
47,699
slideme/rorschach
index.js
Rorschach
function Rorschach(connectionString, options) { EventEmitter.call(this); options = options || {}; var retryPolicy = options.retryPolicy; if (retryPolicy instanceof RetryPolicy) { this.retryPolicy = retryPolicy; } else { this.retryPolicy = new RetryPolicy(retryPolicy); } // Initial state this.state = ConnectionState.LOST; initZooKeeper(this, connectionString, options.zookeeper); }
javascript
function Rorschach(connectionString, options) { EventEmitter.call(this); options = options || {}; var retryPolicy = options.retryPolicy; if (retryPolicy instanceof RetryPolicy) { this.retryPolicy = retryPolicy; } else { this.retryPolicy = new RetryPolicy(retryPolicy); } // Initial state this.state = ConnectionState.LOST; initZooKeeper(this, connectionString, options.zookeeper); }
[ "function", "Rorschach", "(", "connectionString", ",", "options", ")", "{", "EventEmitter", ".", "call", "(", "this", ")", ";", "options", "=", "options", "||", "{", "}", ";", "var", "retryPolicy", "=", "options", ".", "retryPolicy", ";", "if", "(", "retryPolicy", "instanceof", "RetryPolicy", ")", "{", "this", ".", "retryPolicy", "=", "retryPolicy", ";", "}", "else", "{", "this", ".", "retryPolicy", "=", "new", "RetryPolicy", "(", "retryPolicy", ")", ";", "}", "// Initial state", "this", ".", "state", "=", "ConnectionState", ".", "LOST", ";", "initZooKeeper", "(", "this", ",", "connectionString", ",", "options", ".", "zookeeper", ")", ";", "}" ]
Create instance and connect to ZooKeeper. @constructor @extends {events.EventEmitter} @param {String} connectionString ZooKeeper connection string @param {Object} [options] Options: @param {Object|RetryPolicy} [options.retryPolicy] RetryPolicy instance or options @param {Object} [options.zookeeper] ZooKeeper client options
[ "Create", "instance", "and", "connect", "to", "ZooKeeper", "." ]
899339baf31682f8a62b2960cdd26fbb58a9e3a1
https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/index.js#L48-L65