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
29,800
hsnaydd/validetta
dist/validetta.js
function( tmp ) { if ( tmp.val === '' ) return true; // allow empty because empty check does by required metheod var reg, cardNumber, pos, digit, i, sub_total, sum = 0, strlen; reg = new RegExp( /[^0-9]+/g ); cardNumber = tmp.val.replace( reg, '' ); strlen = cardNumber.length; if( strlen < 13 ) return messages.creditCard; for( i=0 ; i < strlen ; i++ ) { pos = strlen - i; digit = parseInt( cardNumber.substring( pos - 1, pos ), 10 ); if( i % 2 === 1 ) { sub_total = digit * 2 ; if( sub_total > 9 ) { sub_total = 1 + ( sub_total - 10 ); } } else { sub_total = digit ; } sum += sub_total ; } if( sum > 0 && sum % 10 === 0 ) return true; return messages.creditCard; }
javascript
function( tmp ) { if ( tmp.val === '' ) return true; // allow empty because empty check does by required metheod var reg, cardNumber, pos, digit, i, sub_total, sum = 0, strlen; reg = new RegExp( /[^0-9]+/g ); cardNumber = tmp.val.replace( reg, '' ); strlen = cardNumber.length; if( strlen < 13 ) return messages.creditCard; for( i=0 ; i < strlen ; i++ ) { pos = strlen - i; digit = parseInt( cardNumber.substring( pos - 1, pos ), 10 ); if( i % 2 === 1 ) { sub_total = digit * 2 ; if( sub_total > 9 ) { sub_total = 1 + ( sub_total - 10 ); } } else { sub_total = digit ; } sum += sub_total ; } if( sum > 0 && sum % 10 === 0 ) return true; return messages.creditCard; }
[ "function", "(", "tmp", ")", "{", "if", "(", "tmp", ".", "val", "===", "''", ")", "return", "true", ";", "// allow empty because empty check does by required metheod\r", "var", "reg", ",", "cardNumber", ",", "pos", ",", "digit", ",", "i", ",", "sub_total", "...
Credit Card Control @from : http://af-design.com/blog/2010/08/18/validating-credit-card-numbers
[ "Credit", "Card", "Control" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L119-L141
29,801
hsnaydd/validetta
dist/validetta.js
function( tmp, self ) { var _arg = self.options.validators.regExp[ tmp.arg ], _reg = new RegExp( _arg.pattern ); return _reg.test( tmp.val ) || _arg.errorMessage; }
javascript
function( tmp, self ) { var _arg = self.options.validators.regExp[ tmp.arg ], _reg = new RegExp( _arg.pattern ); return _reg.test( tmp.val ) || _arg.errorMessage; }
[ "function", "(", "tmp", ",", "self", ")", "{", "var", "_arg", "=", "self", ".", "options", ".", "validators", ".", "regExp", "[", "tmp", ".", "arg", "]", ",", "_reg", "=", "new", "RegExp", "(", "_arg", ".", "pattern", ")", ";", "return", "_reg", ...
Custom reg check
[ "Custom", "reg", "check" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L171-L175
29,802
hsnaydd/validetta
dist/validetta.js
function(){ var self = this; // stored this // Handle submit event $( this.form ).submit( function( e ) { // fields to be controlled transferred to global variable FIELDS = this.querySelectorAll('[data-validetta]'); return self.init( e ); }); // real-time option control if( this.options.realTime === true ) { // handle change event for form elements (without checkbox) $( this.form ).find('[data-validetta]').not('[type=checkbox]').on( 'change', function( e ) { // field to be controlled transferred to global variable FIELDS = $( this ); return self.init( e ); }); // handle click event for checkboxes $( this.form ).find('[data-validetta][type=checkbox]').on( 'click', function( e ) { // fields to be controlled transferred to global variable FIELDS = self.form.querySelectorAll('[data-validetta][type=checkbox][name="'+ this.name +'"]'); return self.init( e ); }); } // handle <form> reset button to clear error messages $( this.form ).on( 'reset', function() { $( self.form.querySelectorAll( '.'+ self.options.errorClass +', .'+ self.options.validClass ) ) .removeClass( self.options.errorClass +' '+ self.options.validClass ); return self.reset(); }); }
javascript
function(){ var self = this; // stored this // Handle submit event $( this.form ).submit( function( e ) { // fields to be controlled transferred to global variable FIELDS = this.querySelectorAll('[data-validetta]'); return self.init( e ); }); // real-time option control if( this.options.realTime === true ) { // handle change event for form elements (without checkbox) $( this.form ).find('[data-validetta]').not('[type=checkbox]').on( 'change', function( e ) { // field to be controlled transferred to global variable FIELDS = $( this ); return self.init( e ); }); // handle click event for checkboxes $( this.form ).find('[data-validetta][type=checkbox]').on( 'click', function( e ) { // fields to be controlled transferred to global variable FIELDS = self.form.querySelectorAll('[data-validetta][type=checkbox][name="'+ this.name +'"]'); return self.init( e ); }); } // handle <form> reset button to clear error messages $( this.form ).on( 'reset', function() { $( self.form.querySelectorAll( '.'+ self.options.errorClass +', .'+ self.options.validClass ) ) .removeClass( self.options.errorClass +' '+ self.options.validClass ); return self.reset(); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "// stored this\r", "// Handle submit event\r", "$", "(", "this", ".", "form", ")", ".", "submit", "(", "function", "(", "e", ")", "{", "// fields to be controlled transferred to global variable\r", "FIEL...
This is the method of handling events @return {mixed}
[ "This", "is", "the", "method", "of", "handling", "events" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L220-L249
29,803
hsnaydd/validetta
dist/validetta.js
function( e ) { // Reset error windows from all elements this.reset( FIELDS ); // Start control each elements this.checkFields( e ); if( e.type !== 'submit' ) return; // if event type is not submit, break // This is for when running remote request, return false and wait request response else if ( this.handler === 'pending' ) return false; // if event type is submit and handler is true, break submit and call onError() function else if( this.handler === true ) { this.options.onError.call( this, e ); return false; } else return this.options.onValid.call( this, e ); // if form is valid call onValid() function }
javascript
function( e ) { // Reset error windows from all elements this.reset( FIELDS ); // Start control each elements this.checkFields( e ); if( e.type !== 'submit' ) return; // if event type is not submit, break // This is for when running remote request, return false and wait request response else if ( this.handler === 'pending' ) return false; // if event type is submit and handler is true, break submit and call onError() function else if( this.handler === true ) { this.options.onError.call( this, e ); return false; } else return this.options.onValid.call( this, e ); // if form is valid call onValid() function }
[ "function", "(", "e", ")", "{", "// Reset error windows from all elements\r", "this", ".", "reset", "(", "FIELDS", ")", ";", "// Start control each elements\r", "this", ".", "checkFields", "(", "e", ")", ";", "if", "(", "e", ".", "type", "!==", "'submit'", ")"...
In this method, fields are validated @params {object} e : event object @return {mixed}
[ "In", "this", "method", "fields", "are", "validated" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L257-L268
29,804
hsnaydd/validetta
dist/validetta.js
function( el, e ) { var ajaxOptions = {}, data = {}, fieldName = el.name || el.id; if ( typeof this.remoteCache === 'undefined' ) this.remoteCache = {}; data[ fieldName ] = this.tmp.val; // Set data // exends ajax options ajaxOptions = $.extend( true, {}, { data: data }, this.options.validators.remote[ this.tmp.remote ] || {} ); // use $.param() function for generate specific cache key var cacheKey = $.param( ajaxOptions ); // Check cache var cache = this.remoteCache[ cacheKey ]; if ( typeof cache !== 'undefined' ) { switch( cache.state ) { case 'pending' : // pending means remote request not finished yet this.handler = 'pending'; // update handler and cache event type cache.event = e.type; break; case 'rejected' : // rejected means remote request could not be performed e.preventDefault(); // we have to break submit because of throw error throw new Error( cache.result.message ); case 'resolved' : // resolved means remote request has done // Check to cache, if result is invalid, open an error window if ( cache.result.valid === false ) { this.addErrorClass( this.tmp.parent ); this.window.open.call( this, el, cache.result.message ); } else { this.addValidClass( this.tmp.parent ); } } } else { // Abort if previous ajax request still running var _xhr = this.xhr[ fieldName ]; if ( typeof _xhr !== 'undefined' && _xhr.state() === 'pending' ) _xhr.abort(); // Start caching cache = this.remoteCache[ cacheKey ] = { state : 'pending', event : e.type }; // make a remote request this.remoteRequest( ajaxOptions, cache, el, fieldName ); } }
javascript
function( el, e ) { var ajaxOptions = {}, data = {}, fieldName = el.name || el.id; if ( typeof this.remoteCache === 'undefined' ) this.remoteCache = {}; data[ fieldName ] = this.tmp.val; // Set data // exends ajax options ajaxOptions = $.extend( true, {}, { data: data }, this.options.validators.remote[ this.tmp.remote ] || {} ); // use $.param() function for generate specific cache key var cacheKey = $.param( ajaxOptions ); // Check cache var cache = this.remoteCache[ cacheKey ]; if ( typeof cache !== 'undefined' ) { switch( cache.state ) { case 'pending' : // pending means remote request not finished yet this.handler = 'pending'; // update handler and cache event type cache.event = e.type; break; case 'rejected' : // rejected means remote request could not be performed e.preventDefault(); // we have to break submit because of throw error throw new Error( cache.result.message ); case 'resolved' : // resolved means remote request has done // Check to cache, if result is invalid, open an error window if ( cache.result.valid === false ) { this.addErrorClass( this.tmp.parent ); this.window.open.call( this, el, cache.result.message ); } else { this.addValidClass( this.tmp.parent ); } } } else { // Abort if previous ajax request still running var _xhr = this.xhr[ fieldName ]; if ( typeof _xhr !== 'undefined' && _xhr.state() === 'pending' ) _xhr.abort(); // Start caching cache = this.remoteCache[ cacheKey ] = { state : 'pending', event : e.type }; // make a remote request this.remoteRequest( ajaxOptions, cache, el, fieldName ); } }
[ "function", "(", "el", ",", "e", ")", "{", "var", "ajaxOptions", "=", "{", "}", ",", "data", "=", "{", "}", ",", "fieldName", "=", "el", ".", "name", "||", "el", ".", "id", ";", "if", "(", "typeof", "this", ".", "remoteCache", "===", "'undefined'...
Checks remote validations @param {object} el current field @param {object} e event object @throws {error} If previous remote request for same value has rejected @return {void}
[ "Checks", "remote", "validations" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L350-L396
29,805
hsnaydd/validetta
dist/validetta.js
function( ajaxOptions, cache, el, fieldName, e ) { var self = this; $( this.tmp.parent ).addClass('validetta-pending'); // cache xhr this.xhr[ fieldName ] = $.ajax( ajaxOptions ) .done( function( result ) { if( typeof result !== 'object' ) result = JSON.parse( result ); cache.state = 'resolved'; cache.result = result; if ( cache.event === 'submit' ) { self.handler = false; $( self.form ).trigger('submit'); } else if( result.valid === false ) { self.addErrorClass( self.tmp.parent ); self.window.open.call( self, el, result.message ); } else { self.addValidClass( self.tmp.parent ); } } ) .fail( function( jqXHR, textStatus ) { if ( textStatus !== 'abort' ) { // Dont throw error if request is aborted var _msg = 'Ajax request failed for field ('+ fieldName +') : '+ jqXHR.status +' '+ jqXHR.statusText; cache.state = 'rejected'; cache.result = { valid : false, message : _msg }; throw new Error( _msg ); } } ) .always( function( result ) { $( self.tmp.parent ).removeClass('validetta-pending'); } ); this.handler = 'pending'; }
javascript
function( ajaxOptions, cache, el, fieldName, e ) { var self = this; $( this.tmp.parent ).addClass('validetta-pending'); // cache xhr this.xhr[ fieldName ] = $.ajax( ajaxOptions ) .done( function( result ) { if( typeof result !== 'object' ) result = JSON.parse( result ); cache.state = 'resolved'; cache.result = result; if ( cache.event === 'submit' ) { self.handler = false; $( self.form ).trigger('submit'); } else if( result.valid === false ) { self.addErrorClass( self.tmp.parent ); self.window.open.call( self, el, result.message ); } else { self.addValidClass( self.tmp.parent ); } } ) .fail( function( jqXHR, textStatus ) { if ( textStatus !== 'abort' ) { // Dont throw error if request is aborted var _msg = 'Ajax request failed for field ('+ fieldName +') : '+ jqXHR.status +' '+ jqXHR.statusText; cache.state = 'rejected'; cache.result = { valid : false, message : _msg }; throw new Error( _msg ); } } ) .always( function( result ) { $( self.tmp.parent ).removeClass('validetta-pending'); } ); this.handler = 'pending'; }
[ "function", "(", "ajaxOptions", ",", "cache", ",", "el", ",", "fieldName", ",", "e", ")", "{", "var", "self", "=", "this", ";", "$", "(", "this", ".", "tmp", ".", "parent", ")", ".", "addClass", "(", "'validetta-pending'", ")", ";", "// cache xhr\r", ...
Calls ajax request for remote validations @param {object} ajaxOptions Ajax options @param {object} cache Cache object @param {object} el processing element @param {string} fieldName Field name for make specific caching @param {object} e Event object
[ "Calls", "ajax", "request", "for", "remote", "validations" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L407-L441
29,806
hsnaydd/validetta
dist/validetta.js
function( el, error ) { // We want display errors ? if ( !this.options.showErrorMessages ) { // because of form not valid, set handler true for break submit this.handler = true; return; } var elParent = this.parents( el ); // If the parent element undefined, that means el is an object. So we need to transform to the element if( typeof elParent === 'undefined' ) elParent = el[0].parentNode; // if there is an error window which previously opened for el, return if ( elParent.querySelectorAll( '.'+ this.options.errorTemplateClass ).length ) return; // Create the error window object which will be appear var errorObject = document.createElement('span'); errorObject.className = this.options.errorTemplateClass + ' '+this.options.errorTemplateClass + '--' + this.options.bubblePosition; // if error display is bubble, calculate to positions if( this.options.display === 'bubble' ) { var pos, W = 0, H = 0; // !! Here, JQuery functions are using to support the IE8 pos = $( el ).position(); if ( this.options.bubblePosition === 'bottom' ){ H = el.offsetHeight; } else { W = el.offsetWidth; } errorObject.innerHTML = ''; errorObject.style.top = pos.top + H + this.options.bubbleGapTop +'px'; errorObject.style.left = pos.left + W + this.options.bubbleGapLeft +'px' } elParent.appendChild( errorObject ); errorObject.innerHTML = error ; // we have an error so we need to break submit // set to handler true this.handler = true; }
javascript
function( el, error ) { // We want display errors ? if ( !this.options.showErrorMessages ) { // because of form not valid, set handler true for break submit this.handler = true; return; } var elParent = this.parents( el ); // If the parent element undefined, that means el is an object. So we need to transform to the element if( typeof elParent === 'undefined' ) elParent = el[0].parentNode; // if there is an error window which previously opened for el, return if ( elParent.querySelectorAll( '.'+ this.options.errorTemplateClass ).length ) return; // Create the error window object which will be appear var errorObject = document.createElement('span'); errorObject.className = this.options.errorTemplateClass + ' '+this.options.errorTemplateClass + '--' + this.options.bubblePosition; // if error display is bubble, calculate to positions if( this.options.display === 'bubble' ) { var pos, W = 0, H = 0; // !! Here, JQuery functions are using to support the IE8 pos = $( el ).position(); if ( this.options.bubblePosition === 'bottom' ){ H = el.offsetHeight; } else { W = el.offsetWidth; } errorObject.innerHTML = ''; errorObject.style.top = pos.top + H + this.options.bubbleGapTop +'px'; errorObject.style.left = pos.left + W + this.options.bubbleGapLeft +'px' } elParent.appendChild( errorObject ); errorObject.innerHTML = error ; // we have an error so we need to break submit // set to handler true this.handler = true; }
[ "function", "(", "el", ",", "error", ")", "{", "// We want display errors ?\r", "if", "(", "!", "this", ".", "options", ".", "showErrorMessages", ")", "{", "// because of form not valid, set handler true for break submit\r", "this", ".", "handler", "=", "true", ";", ...
Error window opens @params {object} el : element which has an error ( it can be native element or jQuery object ) @params {string} error : error messages
[ "Error", "window", "opens" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L455-L492
29,807
hsnaydd/validetta
dist/validetta.js
function( el ) { var _errorMessages = {}; // if el is undefined ( This is the process of resetting all <form> ) // or el is an object that has element more than one // and these elements are not checkbox if( typeof el === 'undefined' || ( el.length > 1 && el[0].type !== 'checkbox' ) ) { _errorMessages = this.form.querySelectorAll( '.'+ this.options.errorTemplateClass ); } else { _errorMessages = this.parents( el[0] ).querySelectorAll( '.'+ this.options.errorTemplateClass ); } for ( var i = 0, _lengthErrorMessages = _errorMessages.length; i < _lengthErrorMessages; i++ ) { this.window.close.call( this, _errorMessages[ i ] ); } // set to handler false // otherwise at the next validation attempt, submit will not continue even the validation is successful this.handler = false; }
javascript
function( el ) { var _errorMessages = {}; // if el is undefined ( This is the process of resetting all <form> ) // or el is an object that has element more than one // and these elements are not checkbox if( typeof el === 'undefined' || ( el.length > 1 && el[0].type !== 'checkbox' ) ) { _errorMessages = this.form.querySelectorAll( '.'+ this.options.errorTemplateClass ); } else { _errorMessages = this.parents( el[0] ).querySelectorAll( '.'+ this.options.errorTemplateClass ); } for ( var i = 0, _lengthErrorMessages = _errorMessages.length; i < _lengthErrorMessages; i++ ) { this.window.close.call( this, _errorMessages[ i ] ); } // set to handler false // otherwise at the next validation attempt, submit will not continue even the validation is successful this.handler = false; }
[ "function", "(", "el", ")", "{", "var", "_errorMessages", "=", "{", "}", ";", "// if el is undefined ( This is the process of resetting all <form> )\r", "// or el is an object that has element more than one\r", "// and these elements are not checkbox\r", "if", "(", "typeof", "el", ...
Removes all error messages windows @param {object} or {void} el : form elements which have an error message window
[ "Removes", "all", "error", "messages", "windows" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L509-L526
29,808
hsnaydd/validetta
dist/validetta.js
function( el ) { var upLength = parseInt( el.getAttribute( 'data-vd-parent-up' ), 10 ) || 0; for ( var i = 0; i <= upLength ; i++ ) { el = el.parentNode; } return el; }
javascript
function( el ) { var upLength = parseInt( el.getAttribute( 'data-vd-parent-up' ), 10 ) || 0; for ( var i = 0; i <= upLength ; i++ ) { el = el.parentNode; } return el; }
[ "function", "(", "el", ")", "{", "var", "upLength", "=", "parseInt", "(", "el", ".", "getAttribute", "(", "'data-vd-parent-up'", ")", ",", "10", ")", "||", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<=", "upLength", ";", "i", "++", ")...
Finds parent element @param {object} el element @return {object} el parent element
[ "Finds", "parent", "element" ]
f712b7375e1465bfc687a8c6fc93ea700cb590e3
https://github.com/hsnaydd/validetta/blob/f712b7375e1465bfc687a8c6fc93ea700cb590e3/dist/validetta.js#L553-L559
29,809
aweary/alder
fixtures/baz/baz.js
shouldBeIncluded
function shouldBeIncluded(file) { let isIncluded = false let isIgnored = false if (hasIgnorePattern) { return !ignorePattern.test(file) } if (hasIncludePattern) { return includePattern.test(file) } return true }
javascript
function shouldBeIncluded(file) { let isIncluded = false let isIgnored = false if (hasIgnorePattern) { return !ignorePattern.test(file) } if (hasIncludePattern) { return includePattern.test(file) } return true }
[ "function", "shouldBeIncluded", "(", "file", ")", "{", "let", "isIncluded", "=", "false", "let", "isIgnored", "=", "false", "if", "(", "hasIgnorePattern", ")", "{", "return", "!", "ignorePattern", ".", "test", "(", "file", ")", "}", "if", "(", "hasIncludeP...
Uses either the ignore or include pattern to determine if a file should be shown. @param {String} file filename
[ "Uses", "either", "the", "ignore", "or", "include", "pattern", "to", "determine", "if", "a", "file", "should", "be", "shown", "." ]
edf7c40a7a95b61e82a0685bdb720eac47777d01
https://github.com/aweary/alder/blob/edf7c40a7a95b61e82a0685bdb720eac47777d01/fixtures/baz/baz.js#L66-L76
29,810
aweary/alder
alder.js
buildPrefix
function buildPrefix(depth, bottom) { if (!shouldIndent) { return '' } let prefix = bottom ? BOX_BOTTOM_LEFT : BOX_INTERSECTION let spacing = [] let spaceIndex = 0 while(spaceIndex < depth) { spacing[spaceIndex] = depths[spaceIndex] && !printJSX ? BOX_VERTICAL : EMPTY spaceIndex++ } return printJSX ? spacing.join('') : spacing.join('') + prefix }
javascript
function buildPrefix(depth, bottom) { if (!shouldIndent) { return '' } let prefix = bottom ? BOX_BOTTOM_LEFT : BOX_INTERSECTION let spacing = [] let spaceIndex = 0 while(spaceIndex < depth) { spacing[spaceIndex] = depths[spaceIndex] && !printJSX ? BOX_VERTICAL : EMPTY spaceIndex++ } return printJSX ? spacing.join('') : spacing.join('') + prefix }
[ "function", "buildPrefix", "(", "depth", ",", "bottom", ")", "{", "if", "(", "!", "shouldIndent", ")", "{", "return", "''", "}", "let", "prefix", "=", "bottom", "?", "BOX_BOTTOM_LEFT", ":", "BOX_INTERSECTION", "let", "spacing", "=", "[", "]", "let", "spa...
Pads filenames with either whitespace or box characters. The depths map is used to track whether a character should be whitespace or a vertical character. Typically it will be whitespace if there are no other files at that depth that need to be rendered. @param {Number} depth the level at which this file/filder is nested @param {Boolean} bottom whether this is the last file in the folder
[ "Pads", "filenames", "with", "either", "whitespace", "or", "box", "characters", ".", "The", "depths", "map", "is", "used", "to", "track", "whether", "a", "character", "should", "be", "whitespace", "or", "a", "vertical", "character", ".", "Typically", "it", "...
edf7c40a7a95b61e82a0685bdb720eac47777d01
https://github.com/aweary/alder/blob/edf7c40a7a95b61e82a0685bdb720eac47777d01/alder.js#L104-L116
29,811
aweary/alder
alder.js
shouldBeIncluded
function shouldBeIncluded(file) { if (!showAllFiles && file[0] === '.') { return false } if (hasExcludePattern) { return !excludePattern.test(file) } if (hasIncludePattern) { return includePattern.test(file) } return true }
javascript
function shouldBeIncluded(file) { if (!showAllFiles && file[0] === '.') { return false } if (hasExcludePattern) { return !excludePattern.test(file) } if (hasIncludePattern) { return includePattern.test(file) } return true }
[ "function", "shouldBeIncluded", "(", "file", ")", "{", "if", "(", "!", "showAllFiles", "&&", "file", "[", "0", "]", "===", "'.'", ")", "{", "return", "false", "}", "if", "(", "hasExcludePattern", ")", "{", "return", "!", "excludePattern", ".", "test", ...
Uses either the exclude or include pattern to determine if a file should be shown. @param {String} file filename
[ "Uses", "either", "the", "exclude", "or", "include", "pattern", "to", "determine", "if", "a", "file", "should", "be", "shown", "." ]
edf7c40a7a95b61e82a0685bdb720eac47777d01
https://github.com/aweary/alder/blob/edf7c40a7a95b61e82a0685bdb720eac47777d01/alder.js#L123-L135
29,812
JakubMrozek/eet
lib/eet.js
generatePKP
function generatePKP (privateKey, dicPopl, idProvoz, idPokl, poradCis, datTrzby, celkTrzba) { const options = [dicPopl, idProvoz, idPokl, poradCis, datTrzby, celkTrzba] const strToHash = options.join('|') const sign = crypto.createSign('RSA-SHA256') sign.write(strToHash) sign.end() return sign.sign(privateKey, 'base64') }
javascript
function generatePKP (privateKey, dicPopl, idProvoz, idPokl, poradCis, datTrzby, celkTrzba) { const options = [dicPopl, idProvoz, idPokl, poradCis, datTrzby, celkTrzba] const strToHash = options.join('|') const sign = crypto.createSign('RSA-SHA256') sign.write(strToHash) sign.end() return sign.sign(privateKey, 'base64') }
[ "function", "generatePKP", "(", "privateKey", ",", "dicPopl", ",", "idProvoz", ",", "idPokl", ",", "poradCis", ",", "datTrzby", ",", "celkTrzba", ")", "{", "const", "options", "=", "[", "dicPopl", ",", "idProvoz", ",", "idPokl", ",", "poradCis", ",", "datT...
Vygeneruje podpisovy kod poplatnika. @see http://www.etrzby.cz/assets/cs/prilohy/EET_popis_rozhrani_v3.1.1.pdf (sekce 4.1)
[ "Vygeneruje", "podpisovy", "kod", "poplatnika", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L25-L32
29,813
JakubMrozek/eet
lib/eet.js
generateBKP
function generateBKP (pkp) { const buffer = new Buffer(pkp, 'base64') const hash = crypto.createHash('sha1') hash.update(buffer) const sha1str = hash.digest('hex').toUpperCase() return sha1str.match(/(.{1,8})/g).join('-') }
javascript
function generateBKP (pkp) { const buffer = new Buffer(pkp, 'base64') const hash = crypto.createHash('sha1') hash.update(buffer) const sha1str = hash.digest('hex').toUpperCase() return sha1str.match(/(.{1,8})/g).join('-') }
[ "function", "generateBKP", "(", "pkp", ")", "{", "const", "buffer", "=", "new", "Buffer", "(", "pkp", ",", "'base64'", ")", "const", "hash", "=", "crypto", ".", "createHash", "(", "'sha1'", ")", "hash", ".", "update", "(", "buffer", ")", "const", "sha1...
Vygeneruje bezpecnostni kod poplatnika. @see http://www.etrzby.cz/assets/cs/prilohy/EET_popis_rozhrani_v3.1.1.pdf (sekce 4.2)
[ "Vygeneruje", "bezpecnostni", "kod", "poplatnika", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L40-L46
29,814
JakubMrozek/eet
lib/eet.js
doRequest
function doRequest (options, items) { const uid = options.uid || uuid.v4() const date = options.currentDate || new Date() const soapOptions = {} if (options.playground) { soapOptions.endpoint = PG_WSDL_URL } if (options.httpClient) { soapOptions.httpClient = options.httpClient } const timeout = options.timeout || 2000 const offline = options.offline || false return new Promise((resolve, reject) => { const body = getBodyItems(options.privateKey, date, uid, items) soap.createClient(WSDL, soapOptions, (err, client) => { if (err) return reject(err) client.setSecurity(new WSSecurity(options.privateKey, options.certificate, uid)) client.OdeslaniTrzby(body, (err, response) => { if (err) return reject(err) try { validate.httpResponse(response) resolve(getResponseItems(response)) } catch (e) { reject(e) } }, {timeout: timeout}) }) }).catch(err => { if (!offline) return Promise.reject(err) let code = getFooterItems(options.privateKey, items) let bkp = code.bkp let pkp = code.pkp return Promise.resolve({pkp: pkp.$value, bkp: bkp.$value, err}) }) }
javascript
function doRequest (options, items) { const uid = options.uid || uuid.v4() const date = options.currentDate || new Date() const soapOptions = {} if (options.playground) { soapOptions.endpoint = PG_WSDL_URL } if (options.httpClient) { soapOptions.httpClient = options.httpClient } const timeout = options.timeout || 2000 const offline = options.offline || false return new Promise((resolve, reject) => { const body = getBodyItems(options.privateKey, date, uid, items) soap.createClient(WSDL, soapOptions, (err, client) => { if (err) return reject(err) client.setSecurity(new WSSecurity(options.privateKey, options.certificate, uid)) client.OdeslaniTrzby(body, (err, response) => { if (err) return reject(err) try { validate.httpResponse(response) resolve(getResponseItems(response)) } catch (e) { reject(e) } }, {timeout: timeout}) }) }).catch(err => { if (!offline) return Promise.reject(err) let code = getFooterItems(options.privateKey, items) let bkp = code.bkp let pkp = code.pkp return Promise.resolve({pkp: pkp.$value, bkp: bkp.$value, err}) }) }
[ "function", "doRequest", "(", "options", ",", "items", ")", "{", "const", "uid", "=", "options", ".", "uid", "||", "uuid", ".", "v4", "(", ")", "const", "date", "=", "options", ".", "currentDate", "||", "new", "Date", "(", ")", "const", "soapOptions", ...
Odeslani platby do EET. Volby: - options.playground (boolean): povolit testovaci prostredi, def. false - options.offline (boolean): při chybě vygeneruje PKP a BKP, def. false Polozky (items) jsou popsany u funkce getItemsForBody(). Vraci Promise. Pokud je vse v poradku, vrati FIK, v opacnem pripade vraci info o chybe.
[ "Odeslani", "platby", "do", "EET", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L59-L94
29,815
JakubMrozek/eet
lib/eet.js
getBodyItems
function getBodyItems (privateKey, currentDate, uid, items) { return { Hlavicka: getHeaderItems(uid, currentDate, items.prvniZaslani, items.overeni), Data: getDataItems(items), KontrolniKody: getFooterItems(privateKey, items) } }
javascript
function getBodyItems (privateKey, currentDate, uid, items) { return { Hlavicka: getHeaderItems(uid, currentDate, items.prvniZaslani, items.overeni), Data: getDataItems(items), KontrolniKody: getFooterItems(privateKey, items) } }
[ "function", "getBodyItems", "(", "privateKey", ",", "currentDate", ",", "uid", ",", "items", ")", "{", "return", "{", "Hlavicka", ":", "getHeaderItems", "(", "uid", ",", "currentDate", ",", "items", ".", "prvniZaslani", ",", "items", ".", "overeni", ")", "...
Vrati vsechny polozky pro obsah SOAP body. Polozky:
[ "Vrati", "vsechny", "polozky", "pro", "obsah", "SOAP", "body", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L102-L108
29,816
JakubMrozek/eet
lib/eet.js
getHeaderItems
function getHeaderItems (uid, currentDate, prvniZaslani, overeni) { return { attributes: { uuid_zpravy: uid, dat_odesl: formatDate(currentDate), prvni_zaslani: formatBool(prvniZaslani, true), overeni: formatBool(overeni, false) } } }
javascript
function getHeaderItems (uid, currentDate, prvniZaslani, overeni) { return { attributes: { uuid_zpravy: uid, dat_odesl: formatDate(currentDate), prvni_zaslani: formatBool(prvniZaslani, true), overeni: formatBool(overeni, false) } } }
[ "function", "getHeaderItems", "(", "uid", ",", "currentDate", ",", "prvniZaslani", ",", "overeni", ")", "{", "return", "{", "attributes", ":", "{", "uuid_zpravy", ":", "uid", ",", "dat_odesl", ":", "formatDate", "(", "currentDate", ")", ",", "prvni_zaslani", ...
Vygeneruje polozky pro element Hlavicka.
[ "Vygeneruje", "polozky", "pro", "element", "Hlavicka", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L114-L123
29,817
JakubMrozek/eet
lib/eet.js
getFooterItems
function getFooterItems (privateKey, items) { const pkp = generatePKP( privateKey, items.dicPopl, items.idProvoz, items.idPokl, items.poradCis, formatDate(items.datTrzby), formatNumber(items.celkTrzba) ) const bkp = generateBKP(pkp) return { pkp: { attributes: { digest: 'SHA256', cipher: 'RSA2048', encoding: 'base64' }, $value: pkp }, bkp: { attributes: { digest: 'SHA1', encoding: 'base16' }, $value: bkp } } }
javascript
function getFooterItems (privateKey, items) { const pkp = generatePKP( privateKey, items.dicPopl, items.idProvoz, items.idPokl, items.poradCis, formatDate(items.datTrzby), formatNumber(items.celkTrzba) ) const bkp = generateBKP(pkp) return { pkp: { attributes: { digest: 'SHA256', cipher: 'RSA2048', encoding: 'base64' }, $value: pkp }, bkp: { attributes: { digest: 'SHA1', encoding: 'base16' }, $value: bkp } } }
[ "function", "getFooterItems", "(", "privateKey", ",", "items", ")", "{", "const", "pkp", "=", "generatePKP", "(", "privateKey", ",", "items", ".", "dicPopl", ",", "items", ".", "idProvoz", ",", "items", ".", "idPokl", ",", "items", ".", "poradCis", ",", ...
Vygeneruje polozky pro element KontrolniKody.
[ "Vygeneruje", "polozky", "pro", "element", "KontrolniKody", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L194-L223
29,818
JakubMrozek/eet
lib/eet.js
getResponseItems
function getResponseItems (response) { const header = response.Hlavicka.attributes const body = response.Potvrzeni.attributes return { uuid: header.uuid_zpravy, bkp: header.bkp, date: new Date(header.dat_prij), test: body.test === 'true', fik: body.fik, warnings: getWarnings(response.Varovani) } }
javascript
function getResponseItems (response) { const header = response.Hlavicka.attributes const body = response.Potvrzeni.attributes return { uuid: header.uuid_zpravy, bkp: header.bkp, date: new Date(header.dat_prij), test: body.test === 'true', fik: body.fik, warnings: getWarnings(response.Varovani) } }
[ "function", "getResponseItems", "(", "response", ")", "{", "const", "header", "=", "response", ".", "Hlavicka", ".", "attributes", "const", "body", "=", "response", ".", "Potvrzeni", ".", "attributes", "return", "{", "uuid", ":", "header", ".", "uuid_zpravy", ...
Zpracuje OK odpoved ze serveru EET.
[ "Zpracuje", "OK", "odpoved", "ze", "serveru", "EET", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/eet.js#L229-L240
29,819
grasshopper-cms/grasshopper-api-js
lib/routes/social/twitter.js
_loadUserFromToken
function _loadUserFromToken(){ return BB .bind(this) .then(function() { return grasshopper.request(this.token).users.current(); }) .then(function(user){ this.user = user; }); }
javascript
function _loadUserFromToken(){ return BB .bind(this) .then(function() { return grasshopper.request(this.token).users.current(); }) .then(function(user){ this.user = user; }); }
[ "function", "_loadUserFromToken", "(", ")", "{", "return", "BB", ".", "bind", "(", "this", ")", ".", "then", "(", "function", "(", ")", "{", "return", "grasshopper", ".", "request", "(", "this", ".", "token", ")", ".", "users", ".", "current", "(", "...
Utility function to return the current logged in user.
[ "Utility", "function", "to", "return", "the", "current", "logged", "in", "user", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/twitter.js#L62-L71
29,820
grasshopper-cms/grasshopper-api-js
lib/routes/social/twitter.js
_linkIdentity
function _linkIdentity() { var identityOptions = { id: this.params.raw.user_id, accessToken: this.params.access_token, accessSecret: this.params.access_secret, screen_name: this.params.raw.screen_name }; return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'twitter', identityOptions)); }
javascript
function _linkIdentity() { var identityOptions = { id: this.params.raw.user_id, accessToken: this.params.access_token, accessSecret: this.params.access_secret, screen_name: this.params.raw.screen_name }; return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'twitter', identityOptions)); }
[ "function", "_linkIdentity", "(", ")", "{", "var", "identityOptions", "=", "{", "id", ":", "this", ".", "params", ".", "raw", ".", "user_id", ",", "accessToken", ":", "this", ".", "params", ".", "access_token", ",", "accessSecret", ":", "this", ".", "par...
Utility function to link a user's twitter info to the current user.
[ "Utility", "function", "to", "link", "a", "user", "s", "twitter", "info", "to", "the", "current", "user", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/twitter.js#L74-L83
29,821
aaronj1335/webpack-postcss-tools
index.js
makeVarMap
function makeVarMap(filename) { var map = {vars: {}, media: {}, selector: {}}; function resolveImport(path, basedir) { if (path[0] === '/') return path; if (path[0] === '.') return pathResolve(join(basedir, path)); // webpack treats anything starting w/ ~ as a module name, which we're // about to do below, so just remove leading tildes path = path.replace(/^~/, ''); return resolve.sync(path, { basedir: basedir, packageFilter: function (package) { var newPackage = extend({}, package); if (newPackage.style != null) newPackage.main = newPackage.style; return newPackage; } }); } function processRules(rule) { // only variables declared for `:root` are supported for now if (rule.type !== 'rule' || rule.selectors.length !== 1 || rule.selectors[0] !== ':root' || rule.parent.type !== 'root') return; rule.each(function (decl) { var prop = decl.prop; var value = decl.value; if (prop && prop.indexOf('--') === 0) map.vars[prop] = value; }); } function processAtRuleCustom(atRule) { if (atRule.name && ['custom-media', 'custom-selector'].indexOf(atRule.name) !== -1) { var type = atRule.name.split('-')[1]; var name = atRule.params.split(/\s+/, 1)[0]; var nameRe = new RegExp('^' + name + '\\s+'); map[type][name] = atRule.params.replace(nameRe, ''); } } function isUrl(string) { return /(https?:)?\/\//.test(string); } function process(fn) { var style = postcss().process(fs.readFileSync(fn, 'utf8')); // recurse into each import. because we make the recursive call before // extracting values (depth-first, post-order traversal), files that import // libraries can re-define variable declarations, which more-closely // matches the browser's behavior style.root.eachAtRule(function (atRule) { if (atRule.name !== 'import') return; var stripped = stripQuotes(unwrapUrl(atRule.params)); if(isUrl(stripped)) { return; } process(resolveImport(stripped, dirname(fn))); }); // extract variable definitions style.root.eachRule(processRules); // extract custom definitions style.root.eachAtRule(processAtRuleCustom); } process(pathResolve(filename)); return map; }
javascript
function makeVarMap(filename) { var map = {vars: {}, media: {}, selector: {}}; function resolveImport(path, basedir) { if (path[0] === '/') return path; if (path[0] === '.') return pathResolve(join(basedir, path)); // webpack treats anything starting w/ ~ as a module name, which we're // about to do below, so just remove leading tildes path = path.replace(/^~/, ''); return resolve.sync(path, { basedir: basedir, packageFilter: function (package) { var newPackage = extend({}, package); if (newPackage.style != null) newPackage.main = newPackage.style; return newPackage; } }); } function processRules(rule) { // only variables declared for `:root` are supported for now if (rule.type !== 'rule' || rule.selectors.length !== 1 || rule.selectors[0] !== ':root' || rule.parent.type !== 'root') return; rule.each(function (decl) { var prop = decl.prop; var value = decl.value; if (prop && prop.indexOf('--') === 0) map.vars[prop] = value; }); } function processAtRuleCustom(atRule) { if (atRule.name && ['custom-media', 'custom-selector'].indexOf(atRule.name) !== -1) { var type = atRule.name.split('-')[1]; var name = atRule.params.split(/\s+/, 1)[0]; var nameRe = new RegExp('^' + name + '\\s+'); map[type][name] = atRule.params.replace(nameRe, ''); } } function isUrl(string) { return /(https?:)?\/\//.test(string); } function process(fn) { var style = postcss().process(fs.readFileSync(fn, 'utf8')); // recurse into each import. because we make the recursive call before // extracting values (depth-first, post-order traversal), files that import // libraries can re-define variable declarations, which more-closely // matches the browser's behavior style.root.eachAtRule(function (atRule) { if (atRule.name !== 'import') return; var stripped = stripQuotes(unwrapUrl(atRule.params)); if(isUrl(stripped)) { return; } process(resolveImport(stripped, dirname(fn))); }); // extract variable definitions style.root.eachRule(processRules); // extract custom definitions style.root.eachAtRule(processAtRuleCustom); } process(pathResolve(filename)); return map; }
[ "function", "makeVarMap", "(", "filename", ")", "{", "var", "map", "=", "{", "vars", ":", "{", "}", ",", "media", ":", "{", "}", ",", "selector", ":", "{", "}", "}", ";", "function", "resolveImport", "(", "path", ",", "basedir", ")", "{", "if", "...
create maps of variables and custom media queries because we want to: - treat every css file as a separate webpack module - statically resolve css variables during the build we run into an issue where we're compiling a css library with variables that might be overridden by a later stylesheet. we solve this by resolving all variables up front (making a "variable map"), and then using this while actually compiling the css during the webpack build. the downside of this approach is that changing a variable value usually requires you to restart the webpack dev build. this takes a single css filename as an entry point and makes a map of all variables, including those defined in `import`'ed css files. it does the same for custom media queries.
[ "create", "maps", "of", "variables", "and", "custom", "media", "queries" ]
9baa0e43cc9929ca94e9cab336089bfb96ffed98
https://github.com/aaronj1335/webpack-postcss-tools/blob/9baa0e43cc9929ca94e9cab336089bfb96ffed98/index.js#L33-L121
29,822
aaronj1335/webpack-postcss-tools
index.js
prependTildesToImports
function prependTildesToImports(styles) { styles.eachAtRule(function (atRule) { if (atRule.name !== 'import') return; var stripped = stripQuotes(unwrapUrl(atRule.params)); if (stripped[0] !== '.' && stripped[0] !== '~' && stripped[0] !== '/') { atRule.params = '"~' + stripped + '"'; } }); }
javascript
function prependTildesToImports(styles) { styles.eachAtRule(function (atRule) { if (atRule.name !== 'import') return; var stripped = stripQuotes(unwrapUrl(atRule.params)); if (stripped[0] !== '.' && stripped[0] !== '~' && stripped[0] !== '/') { atRule.params = '"~' + stripped + '"'; } }); }
[ "function", "prependTildesToImports", "(", "styles", ")", "{", "styles", ".", "eachAtRule", "(", "function", "(", "atRule", ")", "{", "if", "(", "atRule", ".", "name", "!==", "'import'", ")", "return", ";", "var", "stripped", "=", "stripQuotes", "(", "unwr...
prepend a tilde to css module imports webpack's css-loader [treats css imports as relative paths][url-to-req], not modules. the easiest way i've found to correct this prepending a `~` to each import to force webpack to use it's full module lookup machinery. [url-to-req]: https://github.com/webpack/css-loader/blob/7b50d4f569adcaf5bf185180c15435bde03f4de7/index.js#L37
[ "prepend", "a", "tilde", "to", "css", "module", "imports" ]
9baa0e43cc9929ca94e9cab336089bfb96ffed98
https://github.com/aaronj1335/webpack-postcss-tools/blob/9baa0e43cc9929ca94e9cab336089bfb96ffed98/index.js#L136-L147
29,823
grasshopper-cms/grasshopper-api-js
lib/routes/social/facebook.js
facebookReq
function facebookReq(req, res){ var redirectUrl = _.has(grasshopper.config.identities, 'facebook') ? grasshopper.config.identities.facebook.redirectUrl : 'defaultRoute'; BB.bind({token: req.session.token, params: req.query, res: res, req: req, user: null }) .then(function(){ if(!_.isUndefined(this.token)){ this.token = new Buffer(this.token, 'base64'); //A token exists, let's decode it return _linkSocialAccount.call(this); } else { return _createSocialAccount.call(this); } }) .then(function(){ res.redirect(redirectUrl); }) .catch(function(err){ console.log(err.stack); res.redirect(redirectUrl + '?error='+ err.message); }); }
javascript
function facebookReq(req, res){ var redirectUrl = _.has(grasshopper.config.identities, 'facebook') ? grasshopper.config.identities.facebook.redirectUrl : 'defaultRoute'; BB.bind({token: req.session.token, params: req.query, res: res, req: req, user: null }) .then(function(){ if(!_.isUndefined(this.token)){ this.token = new Buffer(this.token, 'base64'); //A token exists, let's decode it return _linkSocialAccount.call(this); } else { return _createSocialAccount.call(this); } }) .then(function(){ res.redirect(redirectUrl); }) .catch(function(err){ console.log(err.stack); res.redirect(redirectUrl + '?error='+ err.message); }); }
[ "function", "facebookReq", "(", "req", ",", "res", ")", "{", "var", "redirectUrl", "=", "_", ".", "has", "(", "grasshopper", ".", "config", ".", "identities", ",", "'facebook'", ")", "?", "grasshopper", ".", "config", ".", "identities", ".", "facebook", ...
Middleware that handles all of the logic for creating and linking social accounts.
[ "Middleware", "that", "handles", "all", "of", "the", "logic", "for", "creating", "and", "linking", "social", "accounts", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/facebook.js#L15-L36
29,824
Aldaviva/mongoose-moment
lib/schema.js
SchemaMoment
function SchemaMoment(key, options) { SchemaType.call(this, key, options); this.get(function(val, self){ if(!val){ return val; } else { return new Moment(val); } }); }
javascript
function SchemaMoment(key, options) { SchemaType.call(this, key, options); this.get(function(val, self){ if(!val){ return val; } else { return new Moment(val); } }); }
[ "function", "SchemaMoment", "(", "key", ",", "options", ")", "{", "SchemaType", ".", "call", "(", "this", ",", "key", ",", "options", ")", ";", "this", ".", "get", "(", "function", "(", "val", ",", "self", ")", "{", "if", "(", "!", "val", ")", "{...
Moment SchemaType constructor. @param {String} key @param {Object} options @inherits SchemaType @api private
[ "Moment", "SchemaType", "constructor", "." ]
ba36ec59e9a630b21d61d9ad63d9865ff3cb0872
https://github.com/Aldaviva/mongoose-moment/blob/ba36ec59e9a630b21d61d9ad63d9865ff3cb0872/lib/schema.js#L46-L56
29,825
Battochon/passwordless-postgrestore
lib/postgrestore.js
PostgreStore
function PostgreStore(conString, options) { if(!conString){ throw new Error('Connection String is missing.'); } this._options = options || {}; this._options.pgstore = this._options.pgstore || {}; this._difficulty = this._options.pgstore.difficulty || 10; this._table = this._options.pgstore.table || 'passwordless'; this._client = new pg.Pool({ connectionString: conString, max: this._options.pgstore.pgPoolSize || 10 }); if(!isNumber(this._difficulty) || this._cost < 1) { throw new Error('bcrypt difficulty must be an integer >= 1'); } delete this._options.pgstore; var self = this; this._client.connect(function(err, client) { if(err) { throw new Error('Could not connect to Postgres database, with error : ' + err); } }); }
javascript
function PostgreStore(conString, options) { if(!conString){ throw new Error('Connection String is missing.'); } this._options = options || {}; this._options.pgstore = this._options.pgstore || {}; this._difficulty = this._options.pgstore.difficulty || 10; this._table = this._options.pgstore.table || 'passwordless'; this._client = new pg.Pool({ connectionString: conString, max: this._options.pgstore.pgPoolSize || 10 }); if(!isNumber(this._difficulty) || this._cost < 1) { throw new Error('bcrypt difficulty must be an integer >= 1'); } delete this._options.pgstore; var self = this; this._client.connect(function(err, client) { if(err) { throw new Error('Could not connect to Postgres database, with error : ' + err); } }); }
[ "function", "PostgreStore", "(", "conString", ",", "options", ")", "{", "if", "(", "!", "conString", ")", "{", "throw", "new", "Error", "(", "'Connection String is missing.'", ")", ";", "}", "this", ".", "_options", "=", "options", "||", "{", "}", ";", "...
Constructor of PostgreStore @param {String} conString URI as defined by the PostgreSQL specification. Please check the documentation for details: https://github.com/brianc/node-postgres @param {Object} [options] Combines both the options for the PostgreClient as well as the options for PostgreStore. For the PostgreClient options please refer back to the documentation. PostgreStore understands the following options: (1) { pgstore: { difficulty: integer }} to change the bcrypt difficulty. Defaults to: 10 (1) { pgstore: { table: string }} to change the name of the table used. Defaults to: 'passwordless' (2) { pgstore: { pgPoolSize: integer }} to change the pool size of PostgreSQL client. Defaults to: 10 @constructor
[ "Constructor", "of", "PostgreStore" ]
feb17613cf4dad8ebfabba54e146d0bc14b390d0
https://github.com/Battochon/passwordless-postgrestore/blob/feb17613cf4dad8ebfabba54e146d0bc14b390d0/lib/postgrestore.js#L21-L48
29,826
grasshopper-cms/grasshopper-api-js
lib/routes/google.js
oauth
function oauth(httpRequest, httpResponse){ var code = httpRequest.query.code, redirectUrl = _.has(grasshopper.config.identities, 'google') ? grasshopper.config.identities.google.redirectUrl : 'defaultRoute'; grasshopper.auth('Google', { code: code }) .then(function(token) { httpRequest.session.token = new Buffer(token).toString('base64'); httpRequest.session.save(function() { httpResponse.redirect(redirectUrl+'/'+ httpRequest.session.token); }); }) .fail(function(err){ httpResponse.redirect(redirectUrl+'/error='+ err.message); }); }
javascript
function oauth(httpRequest, httpResponse){ var code = httpRequest.query.code, redirectUrl = _.has(grasshopper.config.identities, 'google') ? grasshopper.config.identities.google.redirectUrl : 'defaultRoute'; grasshopper.auth('Google', { code: code }) .then(function(token) { httpRequest.session.token = new Buffer(token).toString('base64'); httpRequest.session.save(function() { httpResponse.redirect(redirectUrl+'/'+ httpRequest.session.token); }); }) .fail(function(err){ httpResponse.redirect(redirectUrl+'/error='+ err.message); }); }
[ "function", "oauth", "(", "httpRequest", ",", "httpResponse", ")", "{", "var", "code", "=", "httpRequest", ".", "query", ".", "code", ",", "redirectUrl", "=", "_", ".", "has", "(", "grasshopper", ".", "config", ".", "identities", ",", "'google'", ")", "?...
Method will accept the oauth callback from google, run authentication, then redirect the user to the page that accepts the token.
[ "Method", "will", "accept", "the", "oauth", "callback", "from", "google", "run", "authentication", "then", "redirect", "the", "user", "to", "the", "page", "that", "accepts", "the", "token", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/google.js#L24-L42
29,827
grasshopper-cms/grasshopper-api-js
lib/routes/google.js
url
function url(httpRequest, httpResponse) { var response = new Response(httpResponse); grasshopper.googleAuthUrl() .then(function(url) { response.writeSuccess(url); }) .fail(function(message) { var err = { code : 400, message : message }; response.writeError(err); }) .done(); }
javascript
function url(httpRequest, httpResponse) { var response = new Response(httpResponse); grasshopper.googleAuthUrl() .then(function(url) { response.writeSuccess(url); }) .fail(function(message) { var err = { code : 400, message : message }; response.writeError(err); }) .done(); }
[ "function", "url", "(", "httpRequest", ",", "httpResponse", ")", "{", "var", "response", "=", "new", "Response", "(", "httpResponse", ")", ";", "grasshopper", ".", "googleAuthUrl", "(", ")", ".", "then", "(", "function", "(", "url", ")", "{", "response", ...
Method will return a google auth url.
[ "Method", "will", "return", "a", "google", "auth", "url", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/google.js#L47-L63
29,828
grasshopper-cms/grasshopper-api-js
lib/routes/token.js
parseHeader
function parseHeader(authHeader, callback){ try { var parts=authHeader.split(/:/), username=parts[0], password=parts[1]; callback(null, {username: username, password: password}); } catch(ex){ callback(ex); } }
javascript
function parseHeader(authHeader, callback){ try { var parts=authHeader.split(/:/), username=parts[0], password=parts[1]; callback(null, {username: username, password: password}); } catch(ex){ callback(ex); } }
[ "function", "parseHeader", "(", "authHeader", ",", "callback", ")", "{", "try", "{", "var", "parts", "=", "authHeader", ".", "split", "(", "/", ":", "/", ")", ",", "username", "=", "parts", "[", "0", "]", ",", "password", "=", "parts", "[", "1", "]...
Method will pull out the username and password out of the auth header. @param authHeader String found in the HTTP authentication header. @param callback
[ "Method", "will", "pull", "out", "the", "username", "and", "password", "out", "of", "the", "auth", "header", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/token.js#L19-L30
29,829
newrelic/yakaa
https.js
createConnection
function createConnection(port, host, options) { if (isObject(port)) { options = port; } else if (isObject(host)) { options = host; } else if (isObject(options)) { options = options; } else { options = {}; } if (isNumber(port)) { options.port = port; } if (isString(host)) { options.host = host; } debug('createConnection', options); return tls.connect(options); }
javascript
function createConnection(port, host, options) { if (isObject(port)) { options = port; } else if (isObject(host)) { options = host; } else if (isObject(options)) { options = options; } else { options = {}; } if (isNumber(port)) { options.port = port; } if (isString(host)) { options.host = host; } debug('createConnection', options); return tls.connect(options); }
[ "function", "createConnection", "(", "port", ",", "host", ",", "options", ")", "{", "if", "(", "isObject", "(", "port", ")", ")", "{", "options", "=", "port", ";", "}", "else", "if", "(", "isObject", "(", "host", ")", ")", "{", "options", "=", "hos...
HTTPS agents.
[ "HTTPS", "agents", "." ]
8574311a6e35da5122eecef145df386eaa4a6d5e
https://github.com/newrelic/yakaa/blob/8574311a6e35da5122eecef145df386eaa4a6d5e/https.js#L43-L67
29,830
BKWLD/vue-balance-text
index.js
bind
function bind(el, _ref) { var modifiers = _ref.modifiers; var target; // Support children's modifier target = modifiers.children ? Array.from(el.children) : el; // Add balance text to the element Vue.nextTick(function () { return balanceText(target, { watch: true }); }); // Manually fire again later, like after styles are injected by Webpack return setTimeout(function () { return balanceText(target); }, 300); }
javascript
function bind(el, _ref) { var modifiers = _ref.modifiers; var target; // Support children's modifier target = modifiers.children ? Array.from(el.children) : el; // Add balance text to the element Vue.nextTick(function () { return balanceText(target, { watch: true }); }); // Manually fire again later, like after styles are injected by Webpack return setTimeout(function () { return balanceText(target); }, 300); }
[ "function", "bind", "(", "el", ",", "_ref", ")", "{", "var", "modifiers", "=", "_ref", ".", "modifiers", ";", "var", "target", ";", "// Support children's modifier", "target", "=", "modifiers", ".", "children", "?", "Array", ".", "from", "(", "el", ".", ...
Add balance text to the element
[ "Add", "balance", "text", "to", "the", "element" ]
86e00b5fbef3d38b7d180cd89b98b66757975010
https://github.com/BKWLD/vue-balance-text/blob/86e00b5fbef3d38b7d180cd89b98b66757975010/index.js#L17-L35
29,831
BKWLD/vue-balance-text
index.js
componentUpdated
function componentUpdated(el, _ref2) { var modifiers = _ref2.modifiers; var target; target = modifiers.children ? Array.from(el.children) : el; return balanceText(target); }
javascript
function componentUpdated(el, _ref2) { var modifiers = _ref2.modifiers; var target; target = modifiers.children ? Array.from(el.children) : el; return balanceText(target); }
[ "function", "componentUpdated", "(", "el", ",", "_ref2", ")", "{", "var", "modifiers", "=", "_ref2", ".", "modifiers", ";", "var", "target", ";", "target", "=", "modifiers", ".", "children", "?", "Array", ".", "from", "(", "el", ".", "children", ")", "...
Update when contents change
[ "Update", "when", "contents", "change" ]
86e00b5fbef3d38b7d180cd89b98b66757975010
https://github.com/BKWLD/vue-balance-text/blob/86e00b5fbef3d38b7d180cd89b98b66757975010/index.js#L37-L43
29,832
JakubMrozek/eet
lib/validate.js
date
function date (value) { if (Object.prototype.toString.call(value) !== '[object Date]' || isNaN(value)) { throw new Error(`Value '${value}' is not a date object.`) } }
javascript
function date (value) { if (Object.prototype.toString.call(value) !== '[object Date]' || isNaN(value)) { throw new Error(`Value '${value}' is not a date object.`) } }
[ "function", "date", "(", "value", ")", "{", "if", "(", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "value", ")", "!==", "'[object Date]'", "||", "isNaN", "(", "value", ")", ")", "{", "throw", "new", "Error", "(", "`", "${", "value"...
Validace data.
[ "Validace", "data", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/validate.js#L67-L71
29,833
JakubMrozek/eet
lib/validate.js
httpResponse
function httpResponse (response) { if (!response) { throw new Error('Unable to parse response.') } const errorAttrs = response.Chyba && response.Chyba.attributes if (errorAttrs) { throw new Error(`${response.Chyba.$value} (${errorAttrs.kod})`) } const body = response.Potvrzeni && response.Potvrzeni.attributes const header = response.Hlavicka && response.Hlavicka.attributes if (!body || !header) { throw new Error('Unable to read response.') } }
javascript
function httpResponse (response) { if (!response) { throw new Error('Unable to parse response.') } const errorAttrs = response.Chyba && response.Chyba.attributes if (errorAttrs) { throw new Error(`${response.Chyba.$value} (${errorAttrs.kod})`) } const body = response.Potvrzeni && response.Potvrzeni.attributes const header = response.Hlavicka && response.Hlavicka.attributes if (!body || !header) { throw new Error('Unable to read response.') } }
[ "function", "httpResponse", "(", "response", ")", "{", "if", "(", "!", "response", ")", "{", "throw", "new", "Error", "(", "'Unable to parse response.'", ")", "}", "const", "errorAttrs", "=", "response", ".", "Chyba", "&&", "response", ".", "Chyba", ".", "...
Zpracuje chybnou odpoved.
[ "Zpracuje", "chybnou", "odpoved", "." ]
28a8f0b6743308c705eb0c17e985e0ed065b692e
https://github.com/JakubMrozek/eet/blob/28a8f0b6743308c705eb0c17e985e0ed065b692e/lib/validate.js#L98-L111
29,834
grasshopper-cms/grasshopper-api-js
lib/routes/social/pinterest.js
_createSocialAccount
function _createSocialAccount(){ return BB .bind(this) .then(function() { return grasshopper.auth('Pinterest', this.params); }) .then(function(token) { this.req.session.token = new Buffer(token).toString('base64'); this.req.session.save(); }); }
javascript
function _createSocialAccount(){ return BB .bind(this) .then(function() { return grasshopper.auth('Pinterest', this.params); }) .then(function(token) { this.req.session.token = new Buffer(token).toString('base64'); this.req.session.save(); }); }
[ "function", "_createSocialAccount", "(", ")", "{", "return", "BB", ".", "bind", "(", "this", ")", ".", "then", "(", "function", "(", ")", "{", "return", "grasshopper", ".", "auth", "(", "'Pinterest'", ",", "this", ".", "params", ")", ";", "}", ")", "...
Function that will create a user in our system. the `auth` function will auto-create a user if there is not already one in the system.
[ "Function", "that", "will", "create", "a", "user", "in", "our", "system", ".", "the", "auth", "function", "will", "auto", "-", "create", "a", "user", "if", "there", "is", "not", "already", "one", "in", "the", "system", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L66-L76
29,835
grasshopper-cms/grasshopper-api-js
lib/routes/social/pinterest.js
_linkSocialAccount
function _linkSocialAccount(){ return BB.bind(this) .then(_loadUserFromToken) .then(_getUserSocialDetails) .then(_linkIdentity) .catch(function(){ return _createSocialAccount.call(this); // Could not link account. Create one instead. }); }
javascript
function _linkSocialAccount(){ return BB.bind(this) .then(_loadUserFromToken) .then(_getUserSocialDetails) .then(_linkIdentity) .catch(function(){ return _createSocialAccount.call(this); // Could not link account. Create one instead. }); }
[ "function", "_linkSocialAccount", "(", ")", "{", "return", "BB", ".", "bind", "(", "this", ")", ".", "then", "(", "_loadUserFromToken", ")", ".", "then", "(", "_getUserSocialDetails", ")", ".", "then", "(", "_linkIdentity", ")", ".", "catch", "(", "functio...
Function will link an existing account loading the current user from their token. We first load the user from token, then link identities. If there is an issue, we try to create the user.
[ "Function", "will", "link", "an", "existing", "account", "loading", "the", "current", "user", "from", "their", "token", ".", "We", "first", "load", "the", "user", "from", "token", "then", "link", "identities", ".", "If", "there", "is", "an", "issue", "we",...
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L81-L90
29,836
grasshopper-cms/grasshopper-api-js
lib/routes/social/pinterest.js
_getUserSocialDetails
function _getUserSocialDetails(){ return BB .bind(this) .then(function() { return pinterest .query() .get('me/?fields=id,first_name,last_name,url,username,image&access_token=' + this.params.access_token) .request(); }) .then(function(res){ this.socialUserInfo = res[1].data; }); }
javascript
function _getUserSocialDetails(){ return BB .bind(this) .then(function() { return pinterest .query() .get('me/?fields=id,first_name,last_name,url,username,image&access_token=' + this.params.access_token) .request(); }) .then(function(res){ this.socialUserInfo = res[1].data; }); }
[ "function", "_getUserSocialDetails", "(", ")", "{", "return", "BB", ".", "bind", "(", "this", ")", ".", "then", "(", "function", "(", ")", "{", "return", "pinterest", ".", "query", "(", ")", ".", "get", "(", "'me/?fields=id,first_name,last_name,url,username,im...
Pinterest doesn't return any user info back with login. So go get some basic info so we can link the account.
[ "Pinterest", "doesn", "t", "return", "any", "user", "info", "back", "with", "login", ".", "So", "go", "get", "some", "basic", "info", "so", "we", "can", "link", "the", "account", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L105-L117
29,837
grasshopper-cms/grasshopper-api-js
lib/routes/social/pinterest.js
_linkIdentity
function _linkIdentity() { var identityOptions = { id: this.socialUserInfo.id, accessToken: this.params.access_token, screen_name: this.socialUserInfo.username }; return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'pinterest', identityOptions)); }
javascript
function _linkIdentity() { var identityOptions = { id: this.socialUserInfo.id, accessToken: this.params.access_token, screen_name: this.socialUserInfo.username }; return BB.resolve(grasshopper.request(this.token).users.linkIdentity(this.user._id.toString(), 'pinterest', identityOptions)); }
[ "function", "_linkIdentity", "(", ")", "{", "var", "identityOptions", "=", "{", "id", ":", "this", ".", "socialUserInfo", ".", "id", ",", "accessToken", ":", "this", ".", "params", ".", "access_token", ",", "screen_name", ":", "this", ".", "socialUserInfo", ...
Utility function to link a user's pinterest info to the current user.
[ "Utility", "function", "to", "link", "a", "user", "s", "pinterest", "info", "to", "the", "current", "user", "." ]
05a952b8b65e3a66c8a27f5d84699ee5cf02844d
https://github.com/grasshopper-cms/grasshopper-api-js/blob/05a952b8b65e3a66c8a27f5d84699ee5cf02844d/lib/routes/social/pinterest.js#L120-L128
29,838
wmfs/tymly-core
lib/boot/refs/first-pass/index.js
firstPass
function firstPass (loadedComponents, messages) { messages.heading('Reference resolution - first pass') const components = loadedComponents.blueprintComponents const tymlyRefs = loadedComponents.blueprintRefs const resolutions = findFirstPassResolutions(tymlyRefs, components) if (!resolutions) { messages.subHeading('Nothing to resolve') return } resolveResolutions(resolutions, components, messages) }
javascript
function firstPass (loadedComponents, messages) { messages.heading('Reference resolution - first pass') const components = loadedComponents.blueprintComponents const tymlyRefs = loadedComponents.blueprintRefs const resolutions = findFirstPassResolutions(tymlyRefs, components) if (!resolutions) { messages.subHeading('Nothing to resolve') return } resolveResolutions(resolutions, components, messages) }
[ "function", "firstPass", "(", "loadedComponents", ",", "messages", ")", "{", "messages", ".", "heading", "(", "'Reference resolution - first pass'", ")", "const", "components", "=", "loadedComponents", ".", "blueprintComponents", "const", "tymlyRefs", "=", "loadedCompon...
First pass through the references. None of the services have yet been booted, but we can resolve static references
[ "First", "pass", "through", "the", "references", ".", "None", "of", "the", "services", "have", "yet", "been", "booted", "but", "we", "can", "resolve", "static", "references" ]
7f05f7b8c2a1c09b03bb4a6ac34013ff4c9edfee
https://github.com/wmfs/tymly-core/blob/7f05f7b8c2a1c09b03bb4a6ac34013ff4c9edfee/lib/boot/refs/first-pass/index.js#L6-L20
29,839
benjamn/arson
index.js
getArrayOfHoles
function getArrayOfHoles(length) { var holyLen = HOLY_ARRAY.length; if (length > holyLen) { HOLY_ARRAY.length = length; for (var i = holyLen; i < length; ++i) { HOLY_ARRAY[i] = ARRAY_HOLE_INDEX; } } return HOLY_ARRAY.slice(0, length); }
javascript
function getArrayOfHoles(length) { var holyLen = HOLY_ARRAY.length; if (length > holyLen) { HOLY_ARRAY.length = length; for (var i = holyLen; i < length; ++i) { HOLY_ARRAY[i] = ARRAY_HOLE_INDEX; } } return HOLY_ARRAY.slice(0, length); }
[ "function", "getArrayOfHoles", "(", "length", ")", "{", "var", "holyLen", "=", "HOLY_ARRAY", ".", "length", ";", "if", "(", "length", ">", "holyLen", ")", "{", "HOLY_ARRAY", ".", "length", "=", "length", ";", "for", "(", "var", "i", "=", "holyLen", ";"...
Returns an array of the given length filled with ARRAY_HOLE_INDEX.
[ "Returns", "an", "array", "of", "the", "given", "length", "filled", "with", "ARRAY_HOLE_INDEX", "." ]
aeee18764c9901759762d2f011589caea9e768e1
https://github.com/benjamn/arson/blob/aeee18764c9901759762d2f011589caea9e768e1/index.js#L39-L49
29,840
canjs/can-construct
can-construct.js
function (what, oldProps, propName, val) { Object.defineProperty(what, propName, {value: val, configurable: true, enumerable: true, writable: true}); }
javascript
function (what, oldProps, propName, val) { Object.defineProperty(what, propName, {value: val, configurable: true, enumerable: true, writable: true}); }
[ "function", "(", "what", ",", "oldProps", ",", "propName", ",", "val", ")", "{", "Object", ".", "defineProperty", "(", "what", ",", "propName", ",", "{", "value", ":", "val", ",", "configurable", ":", "true", ",", "enumerable", ":", "true", ",", "writa...
used for overwriting a single property. this should be used for patching other objects the super plugin overwrites this
[ "used", "for", "overwriting", "a", "single", "property", ".", "this", "should", "be", "used", "for", "patching", "other", "objects", "the", "super", "plugin", "overwrites", "this" ]
0c64cc2ccf917d705070d51416ac8cd1bda35259
https://github.com/canjs/can-construct/blob/0c64cc2ccf917d705070d51416ac8cd1bda35259/can-construct.js#L334-L336
29,841
canjs/can-construct
can-construct.js
init
function init() { /* jshint validthis: true */ // All construction is actually done in the init method. if (!initializing) { //!steal-remove-start if(process.env.NODE_ENV !== 'production') { if(!this || (this.constructor !== Constructor) && // We are being called without `new` or we are extending. arguments.length && Constructor.constructorExtends) { dev.warn('can/construct/construct.js: extending a Construct without calling extend'); } } //!steal-remove-end return (!this || this.constructor !== Constructor) && // We are being called without `new` or we are extending. arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : // We are being called with `new`. Constructor.newInstance.apply(Constructor, arguments); } }
javascript
function init() { /* jshint validthis: true */ // All construction is actually done in the init method. if (!initializing) { //!steal-remove-start if(process.env.NODE_ENV !== 'production') { if(!this || (this.constructor !== Constructor) && // We are being called without `new` or we are extending. arguments.length && Constructor.constructorExtends) { dev.warn('can/construct/construct.js: extending a Construct without calling extend'); } } //!steal-remove-end return (!this || this.constructor !== Constructor) && // We are being called without `new` or we are extending. arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : // We are being called with `new`. Constructor.newInstance.apply(Constructor, arguments); } }
[ "function", "init", "(", ")", "{", "/* jshint validthis: true */", "// All construction is actually done in the init method.", "if", "(", "!", "initializing", ")", "{", "//!steal-remove-start", "if", "(", "process", ".", "env", ".", "NODE_ENV", "!==", "'production'", ")...
!steal-remove-end The dummy class constructor.
[ "!steal", "-", "remove", "-", "end", "The", "dummy", "class", "constructor", "." ]
0c64cc2ccf917d705070d51416ac8cd1bda35259
https://github.com/canjs/can-construct/blob/0c64cc2ccf917d705070d51416ac8cd1bda35259/can-construct.js#L642-L662
29,842
grasshopper-cms/grasshopper-core-nodejs
lib/event/filter.js
findMatch
function findMatch(filters, listener){ var handlers = [], isMatch = true; if( !_.isUndefined(listener.filters.nodes) && listener.filters.nodes.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.nodes , function(node) { return (node === filters.node || node === '*'); } ) ); } if ( isMatch && !_.isUndefined(listener.filters.types) && listener.filters.types.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.types , function(type) { return (type === filters.type || type === '*'); } ) ); } if( isMatch && !_.isUndefined(listener.filters.contentids) && listener.filters.contentids.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.contentids , function(contentid) { return (contentid === filters.contentid || contentid === '*'); } ) ); } if( isMatch && !_.isUndefined(listener.filters.system) && listener.filters.system.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.system , function(val) { return (val === filters.system || val === '*'); } ) ); } // If we still have a match return handlers attached to the listener if( isMatch ) { handlers = listener.handlers; } return handlers; }
javascript
function findMatch(filters, listener){ var handlers = [], isMatch = true; if( !_.isUndefined(listener.filters.nodes) && listener.filters.nodes.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.nodes , function(node) { return (node === filters.node || node === '*'); } ) ); } if ( isMatch && !_.isUndefined(listener.filters.types) && listener.filters.types.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.types , function(type) { return (type === filters.type || type === '*'); } ) ); } if( isMatch && !_.isUndefined(listener.filters.contentids) && listener.filters.contentids.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.contentids , function(contentid) { return (contentid === filters.contentid || contentid === '*'); } ) ); } if( isMatch && !_.isUndefined(listener.filters.system) && listener.filters.system.length > 0 ) { isMatch = !_.isUndefined( _.find( listener.filters.system , function(val) { return (val === filters.system || val === '*'); } ) ); } // If we still have a match return handlers attached to the listener if( isMatch ) { handlers = listener.handlers; } return handlers; }
[ "function", "findMatch", "(", "filters", ",", "listener", ")", "{", "var", "handlers", "=", "[", "]", ",", "isMatch", "=", "true", ";", "if", "(", "!", "_", ".", "isUndefined", "(", "listener", ".", "filters", ".", "nodes", ")", "&&", "listener", "."...
Function will look at the filters that have been passed in to the module through an emit call and compair them to the filters that are attached to all of the listeners. If there are matches the function will return an array of event handlers that match the criteria. @param filters - Event filters that are passed in through emit @param listener - Listener that has been registered in the application @returns {Array} - Array of event handlers that match the filter criteria
[ "Function", "will", "look", "at", "the", "filters", "that", "have", "been", "passed", "in", "to", "the", "module", "through", "an", "emit", "call", "and", "compair", "them", "to", "the", "filters", "that", "are", "attached", "to", "all", "of", "the", "li...
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/event/filter.js#L17-L51
29,843
grasshopper-cms/grasshopper-core-nodejs
lib/event/filter.js
filterListeners
function filterListeners (listenerCollection) { return function(filters) { var handlers = []; _.each(listenerCollection, function(listener){ handlers = handlers.concat( findMatch(filters, listener) ); }); return handlers; }; }
javascript
function filterListeners (listenerCollection) { return function(filters) { var handlers = []; _.each(listenerCollection, function(listener){ handlers = handlers.concat( findMatch(filters, listener) ); }); return handlers; }; }
[ "function", "filterListeners", "(", "listenerCollection", ")", "{", "return", "function", "(", "filters", ")", "{", "var", "handlers", "=", "[", "]", ";", "_", ".", "each", "(", "listenerCollection", ",", "function", "(", "listener", ")", "{", "handlers", ...
Function that accepts a collection of listeners and inspects each one to determine if their handler should be called. @param listenerCollection @returns {Function}
[ "Function", "that", "accepts", "a", "collection", "of", "listeners", "and", "inspects", "each", "one", "to", "determine", "if", "their", "handler", "should", "be", "called", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/event/filter.js#L60-L70
29,844
casetext/fireproof
lib/demux.js
Demux
function Demux(refs, limit) { if (!(this instanceof Fireproof.Demux)) { return new Fireproof.Demux(refs); } else if (arguments.length > 1 && !Array.isArray(refs)) { refs = Array.prototype.slice.call(arguments, 0); } this._limit = (limit !== undefined ? limit : true); this._refs = refs; this._positions = refs.reduce(function(positions, ref) { positions[ref.ref().toString()] = { name: undefined, priority: undefined }; return positions; }, {}); // we always want there to be a "previous" promise to hang operations from this._previousPromise = Fireproof.Promise.resolve([]); this._buffer = []; }
javascript
function Demux(refs, limit) { if (!(this instanceof Fireproof.Demux)) { return new Fireproof.Demux(refs); } else if (arguments.length > 1 && !Array.isArray(refs)) { refs = Array.prototype.slice.call(arguments, 0); } this._limit = (limit !== undefined ? limit : true); this._refs = refs; this._positions = refs.reduce(function(positions, ref) { positions[ref.ref().toString()] = { name: undefined, priority: undefined }; return positions; }, {}); // we always want there to be a "previous" promise to hang operations from this._previousPromise = Fireproof.Promise.resolve([]); this._buffer = []; }
[ "function", "Demux", "(", "refs", ",", "limit", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Fireproof", ".", "Demux", ")", ")", "{", "return", "new", "Fireproof", ".", "Demux", "(", "refs", ")", ";", "}", "else", "if", "(", "arguments", "...
A helper object for retrieving sorted Firebase objects from multiple locations. @constructor Fireproof.Demux @static @param {Array} refs a list of Fireproof object references to draw from. @param {boolean} [limitToFirst] Whether to use "limitToFirst" to restrict the length of queries to Firebase. True by default. Set this to false if you want to control the query more directly by setting it on the objects you pass to refs.
[ "A", "helper", "object", "for", "retrieving", "sorted", "Firebase", "objects", "from", "multiple", "locations", "." ]
a568157310d965d2c115e5a3c9e8287fc8fe021b
https://github.com/casetext/fireproof/blob/a568157310d965d2c115e5a3c9e8287fc8fe021b/lib/demux.js#L12-L38
29,845
reddit/node-build
lib/uploadToSentry.js
createRelease
function createRelease(endpoint, version) { return new Promise(function(resolve, reject) { superagent .post(endpoint) .set(HEADERS) .send({ version: version }) .end(function(err, res) { if (!err) { console.log('Sentry - Pushed release. Version: ' + version); resolve(res); } else { reject(err); } }); }); }
javascript
function createRelease(endpoint, version) { return new Promise(function(resolve, reject) { superagent .post(endpoint) .set(HEADERS) .send({ version: version }) .end(function(err, res) { if (!err) { console.log('Sentry - Pushed release. Version: ' + version); resolve(res); } else { reject(err); } }); }); }
[ "function", "createRelease", "(", "endpoint", ",", "version", ")", "{", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "superagent", ".", "post", "(", "endpoint", ")", ".", "set", "(", "HEADERS", ")", ".", "send", ...
Creates a Sentry release, a versioned collection of compiled js and their sourcemaps. @param {String} endpoint The endpoint this release is being pushed to @param {String} version The version for this release
[ "Creates", "a", "Sentry", "release", "a", "versioned", "collection", "of", "compiled", "js", "and", "their", "sourcemaps", "." ]
af30dc8c637631b177ae33a1984a44ffa839914b
https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L20-L35
29,846
reddit/node-build
lib/uploadToSentry.js
uploadFile
function uploadFile(endpoint, releaseVersion, filePath) { // sentry lets you use the tilde to indicate it just looks at relative locations // instead of relying on the host/domain. var IGNORE_DOMAIN = '~'; var staticBase = process.env.STATIC_BASE; var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/' : ''; var CONFLICT_CODE = 409; var fileData = path.parse(filePath); var fileName = fileData.name + fileData.ext; var sentryFilePath = IGNORE_DOMAIN + IGNORE_PATH + fileName; return new Promise(function(resolve, reject) { superagent .post(endpoint) .set(HEADERS) .attach('file', filePath) .field('name', sentryFilePath) .end(function(err, res) { if (!err) { console.log('Sentry (release: ' + releaseVersion + ') - Successfully uploaded ' + fileName); resolve(); } if (err && err.response && err.response.statusCode === CONFLICT_CODE) { console.log('Sentry (' + releaseVersion + ') - ' + fileName + ' already exists.'); resolve(); } else { reject(err); } }); }); }
javascript
function uploadFile(endpoint, releaseVersion, filePath) { // sentry lets you use the tilde to indicate it just looks at relative locations // instead of relying on the host/domain. var IGNORE_DOMAIN = '~'; var staticBase = process.env.STATIC_BASE; var IGNORE_PATH = staticBase ? url.parse(staticBase).path + '/' : ''; var CONFLICT_CODE = 409; var fileData = path.parse(filePath); var fileName = fileData.name + fileData.ext; var sentryFilePath = IGNORE_DOMAIN + IGNORE_PATH + fileName; return new Promise(function(resolve, reject) { superagent .post(endpoint) .set(HEADERS) .attach('file', filePath) .field('name', sentryFilePath) .end(function(err, res) { if (!err) { console.log('Sentry (release: ' + releaseVersion + ') - Successfully uploaded ' + fileName); resolve(); } if (err && err.response && err.response.statusCode === CONFLICT_CODE) { console.log('Sentry (' + releaseVersion + ') - ' + fileName + ' already exists.'); resolve(); } else { reject(err); } }); }); }
[ "function", "uploadFile", "(", "endpoint", ",", "releaseVersion", ",", "filePath", ")", "{", "// sentry lets you use the tilde to indicate it just looks at relative locations", "// instead of relying on the host/domain.", "var", "IGNORE_DOMAIN", "=", "'~'", ";", "var", "staticBas...
Uploads a single file to a selected release. @param {String} endpoint The endpoint to push these files to @param {String} releaseVersion The release version for this file @param {String} filePath The absolute file path for the file we want to upload to the release
[ "Uploads", "a", "single", "file", "to", "a", "selected", "release", "." ]
af30dc8c637631b177ae33a1984a44ffa839914b
https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L46-L78
29,847
reddit/node-build
lib/uploadToSentry.js
uploadToSentry
function uploadToSentry(projectSlug, orgSlug, releaseVersion, assets) { var releaseEndpoint = makeUrl(projectSlug, orgSlug); var uploadEndpoint = releaseEndpoint + releaseVersion + '/files/'; createRelease(releaseEndpoint, releaseVersion) .then(function() { return Promise.all(assets.map(uploadFile.bind(null, uploadEndpoint, releaseVersion ))); }) .catch(function(e) { console.log('Release failed with error: ', e); }); }
javascript
function uploadToSentry(projectSlug, orgSlug, releaseVersion, assets) { var releaseEndpoint = makeUrl(projectSlug, orgSlug); var uploadEndpoint = releaseEndpoint + releaseVersion + '/files/'; createRelease(releaseEndpoint, releaseVersion) .then(function() { return Promise.all(assets.map(uploadFile.bind(null, uploadEndpoint, releaseVersion ))); }) .catch(function(e) { console.log('Release failed with error: ', e); }); }
[ "function", "uploadToSentry", "(", "projectSlug", ",", "orgSlug", ",", "releaseVersion", ",", "assets", ")", "{", "var", "releaseEndpoint", "=", "makeUrl", "(", "projectSlug", ",", "orgSlug", ")", ";", "var", "uploadEndpoint", "=", "releaseEndpoint", "+", "relea...
Creates a Sentry release and pushes the relevant assets to that release. @param {String} projectName The Sentry project this release belongs to @param {String} releaseVersion The release version for the js assets @param {Array} assets An array of filepaths to the assets that will be uploaded
[ "Creates", "a", "Sentry", "release", "and", "pushes", "the", "relevant", "assets", "to", "that", "release", "." ]
af30dc8c637631b177ae33a1984a44ffa839914b
https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/uploadToSentry.js#L89-L103
29,848
gilt/swig
packages/swig-cli/index.js
tell
function tell(name, taskInfo) { if (swig.tasks[name]) { console.log(`Task '${name}' has been overridden by a local installation`.yellow); } swig.tasks[name] = _.extend({ description: '<unknown>', flags: {}, }, taskInfo); }
javascript
function tell(name, taskInfo) { if (swig.tasks[name]) { console.log(`Task '${name}' has been overridden by a local installation`.yellow); } swig.tasks[name] = _.extend({ description: '<unknown>', flags: {}, }, taskInfo); }
[ "function", "tell", "(", "name", ",", "taskInfo", ")", "{", "if", "(", "swig", ".", "tasks", "[", "name", "]", ")", "{", "console", ".", "log", "(", "`", "${", "name", "}", "`", ".", "yellow", ")", ";", "}", "swig", ".", "tasks", "[", "name", ...
allows a task to tell swig about itself
[ "allows", "a", "task", "to", "tell", "swig", "about", "itself" ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-cli/index.js#L170-L179
29,849
acss-io/gulp-atomizer
index.js
function (file, unused, cb) { if (file.isNull()) { // nothing to do return cb(null, file) } else if (file.isStream()) { // file.contents is a Stream. We don't support streams this.emit('error', new PluginError(PLUGIN_NAME, 'Streams not supported!')) } else if (file.isBuffer()) { // lazy init the acss class if (!acss) { acss = new Atomizer() if (addRules) { acss.addRules(addRules) } } // generate the class names and push them into the global collector array var html = String(file.contents) var classes = acss.findClassNames(html) foundClasses = Array.prototype.concat(foundClasses, classes) // make a note of this file if it's the newer than we've seen before if (!latestMod || file.stat && file.stat.mtime > latestMod) { latestFile = file latestMod = file.stat && file.stat.mtime } // tell the engine we're done cb() } }
javascript
function (file, unused, cb) { if (file.isNull()) { // nothing to do return cb(null, file) } else if (file.isStream()) { // file.contents is a Stream. We don't support streams this.emit('error', new PluginError(PLUGIN_NAME, 'Streams not supported!')) } else if (file.isBuffer()) { // lazy init the acss class if (!acss) { acss = new Atomizer() if (addRules) { acss.addRules(addRules) } } // generate the class names and push them into the global collector array var html = String(file.contents) var classes = acss.findClassNames(html) foundClasses = Array.prototype.concat(foundClasses, classes) // make a note of this file if it's the newer than we've seen before if (!latestMod || file.stat && file.stat.mtime > latestMod) { latestFile = file latestMod = file.stat && file.stat.mtime } // tell the engine we're done cb() } }
[ "function", "(", "file", ",", "unused", ",", "cb", ")", "{", "if", "(", "file", ".", "isNull", "(", ")", ")", "{", "// nothing to do", "return", "cb", "(", "null", ",", "file", ")", "}", "else", "if", "(", "file", ".", "isStream", "(", ")", ")", ...
create the file handler
[ "create", "the", "file", "handler" ]
8a0e4aca88ea4d8cb701b7323fa6164887f97503
https://github.com/acss-io/gulp-atomizer/blob/8a0e4aca88ea4d8cb701b7323fa6164887f97503/index.js#L36-L67
29,850
senecajs/seneca-mem-store
mem-store.js
do_save
function do_save(id, isnew) { var mement = ent.data$(true, 'string') if (undefined !== id) { mement.id = id } mement.entity$ = ent.entity$ entmap[base] = entmap[base] || {} entmap[base][name] = entmap[base][name] || {} var prev = entmap[base][name][mement.id] if (isnew && prev) { return reply(error('entity-id-exists', { type: ent.entity$, id: id })) } var shouldMerge = true if (options.merge !== false && ent.merge$ === false) { shouldMerge = false } if (options.merge === false && ent.merge$ !== true) { shouldMerge = false } mement = _.cloneDeep(mement) if (shouldMerge) { mement = _.assign(prev || {}, mement) } prev = entmap[base][name][mement.id] = mement seneca.log.debug(function() { return [ 'save/' + (create ? 'insert' : 'update'), ent.canon$({ string: 1 }), mement, desc ] }) reply(null, ent.make$(prev)) }
javascript
function do_save(id, isnew) { var mement = ent.data$(true, 'string') if (undefined !== id) { mement.id = id } mement.entity$ = ent.entity$ entmap[base] = entmap[base] || {} entmap[base][name] = entmap[base][name] || {} var prev = entmap[base][name][mement.id] if (isnew && prev) { return reply(error('entity-id-exists', { type: ent.entity$, id: id })) } var shouldMerge = true if (options.merge !== false && ent.merge$ === false) { shouldMerge = false } if (options.merge === false && ent.merge$ !== true) { shouldMerge = false } mement = _.cloneDeep(mement) if (shouldMerge) { mement = _.assign(prev || {}, mement) } prev = entmap[base][name][mement.id] = mement seneca.log.debug(function() { return [ 'save/' + (create ? 'insert' : 'update'), ent.canon$({ string: 1 }), mement, desc ] }) reply(null, ent.make$(prev)) }
[ "function", "do_save", "(", "id", ",", "isnew", ")", "{", "var", "mement", "=", "ent", ".", "data$", "(", "true", ",", "'string'", ")", "if", "(", "undefined", "!==", "id", ")", "{", "mement", ".", "id", "=", "id", "}", "mement", ".", "entity$", ...
The actual save logic for saving or creating and then saving the entity.
[ "The", "actual", "save", "logic", "for", "saving", "or", "creating", "and", "then", "saving", "the", "entity", "." ]
46a25e9fe75f85a31dc6c052f4807eaf4745fdbb
https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L82-L123
29,851
senecajs/seneca-mem-store
mem-store.js
create_new
function create_new() { var id // Check if we already have an id or if // we need to generate a new one. if (undefined !== ent.id$) { // Take a copy of the existing id and // delete it from the ent object. Do // save will handle the id for us. id = ent.id$ delete ent.id$ // Save with the existing id return do_save(id, true) } // Generate a new id id = options.generate_id ? options.generate_id(ent) : void 0 if (undefined !== id) { return do_save(id, true) } else { var gen_id = { role: 'basic', cmd: 'generate_id', name: name, base: base, zone: zone } // When we get a respones we will use the id param // as our entity id, if this fails we just fail and // call reply() as we have no way to save without an id seneca.act(gen_id, function(err, id) { if (err) return reply(err) do_save(id, true) }) } }
javascript
function create_new() { var id // Check if we already have an id or if // we need to generate a new one. if (undefined !== ent.id$) { // Take a copy of the existing id and // delete it from the ent object. Do // save will handle the id for us. id = ent.id$ delete ent.id$ // Save with the existing id return do_save(id, true) } // Generate a new id id = options.generate_id ? options.generate_id(ent) : void 0 if (undefined !== id) { return do_save(id, true) } else { var gen_id = { role: 'basic', cmd: 'generate_id', name: name, base: base, zone: zone } // When we get a respones we will use the id param // as our entity id, if this fails we just fail and // call reply() as we have no way to save without an id seneca.act(gen_id, function(err, id) { if (err) return reply(err) do_save(id, true) }) } }
[ "function", "create_new", "(", ")", "{", "var", "id", "// Check if we already have an id or if", "// we need to generate a new one.", "if", "(", "undefined", "!==", "ent", ".", "id$", ")", "{", "// Take a copy of the existing id and", "// delete it from the ent object. Do", "...
We will still use do_save to save the entity but we need a place to handle new entites and id concerns.
[ "We", "will", "still", "use", "do_save", "to", "save", "the", "entity", "but", "we", "need", "a", "place", "to", "handle", "new", "entites", "and", "id", "concerns", "." ]
46a25e9fe75f85a31dc6c052f4807eaf4745fdbb
https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L127-L165
29,852
senecajs/seneca-mem-store
mem-store.js
listents
function listents(seneca, entmap, qent, q, done) { var list = [] var canon = qent.canon$({ object: true }) var base = canon.base var name = canon.name var entset = entmap[base] ? entmap[base][name] : null if (entset) { if (_.isString(q)) { var ent = entset[q] if (ent) { list.push(ent) } } if (_.isArray(q)) { _.each(q, function(id) { var ent = entset[id] if (ent) { ent = qent.make$(ent) list.push(ent) } }) } if (_.isObject(q)) { _.keys(entset).forEach(function(id) { var ent = entset[id] for (var p in q) { if (!~p.indexOf('$') && q[p] !== ent[p]) { return } } ent = qent.make$(ent) list.push(ent) }) } } // Always sort first, this is the 'expected' behaviour. if (q.sort$) { for (var sf in q.sort$) { break } var sd = q.sort$[sf] < 0 ? -1 : 1 list = list.sort(function(a, b) { return sd * (a[sf] < b[sf] ? -1 : a[sf] === b[sf] ? 0 : 1) }) } // Skip before limiting. if (q.skip$ && q.skip$ > 0) { list = list.slice(q.skip$) } // Limited the possibly sorted and skipped list. if (q.limit$ && q.limit$ >= 0) { list = list.slice(0, q.limit$) } // Prune fields if (q.fields$) { for (var i = 0; i < list.length; i++) { var entfields = list[i].fields$() for (var j = 0; j < entfields.length; j++) { if ('id' !== entfields[j] && -1 == q.fields$.indexOf(entfields[j])) { delete list[i][entfields[j]] } } } } // Return the resulting list to the caller. done.call(seneca, null, list) }
javascript
function listents(seneca, entmap, qent, q, done) { var list = [] var canon = qent.canon$({ object: true }) var base = canon.base var name = canon.name var entset = entmap[base] ? entmap[base][name] : null if (entset) { if (_.isString(q)) { var ent = entset[q] if (ent) { list.push(ent) } } if (_.isArray(q)) { _.each(q, function(id) { var ent = entset[id] if (ent) { ent = qent.make$(ent) list.push(ent) } }) } if (_.isObject(q)) { _.keys(entset).forEach(function(id) { var ent = entset[id] for (var p in q) { if (!~p.indexOf('$') && q[p] !== ent[p]) { return } } ent = qent.make$(ent) list.push(ent) }) } } // Always sort first, this is the 'expected' behaviour. if (q.sort$) { for (var sf in q.sort$) { break } var sd = q.sort$[sf] < 0 ? -1 : 1 list = list.sort(function(a, b) { return sd * (a[sf] < b[sf] ? -1 : a[sf] === b[sf] ? 0 : 1) }) } // Skip before limiting. if (q.skip$ && q.skip$ > 0) { list = list.slice(q.skip$) } // Limited the possibly sorted and skipped list. if (q.limit$ && q.limit$ >= 0) { list = list.slice(0, q.limit$) } // Prune fields if (q.fields$) { for (var i = 0; i < list.length; i++) { var entfields = list[i].fields$() for (var j = 0; j < entfields.length; j++) { if ('id' !== entfields[j] && -1 == q.fields$.indexOf(entfields[j])) { delete list[i][entfields[j]] } } } } // Return the resulting list to the caller. done.call(seneca, null, list) }
[ "function", "listents", "(", "seneca", ",", "entmap", ",", "qent", ",", "q", ",", "done", ")", "{", "var", "list", "=", "[", "]", "var", "canon", "=", "qent", ".", "canon$", "(", "{", "object", ":", "true", "}", ")", "var", "base", "=", "canon", ...
Seneca supports a reasonable set of features in terms of listing. This function can handle sorting, skiping, limiting and general retrieval.
[ "Seneca", "supports", "a", "reasonable", "set", "of", "features", "in", "terms", "of", "listing", ".", "This", "function", "can", "handle", "sorting", "skiping", "limiting", "and", "general", "retrieval", "." ]
46a25e9fe75f85a31dc6c052f4807eaf4745fdbb
https://github.com/senecajs/seneca-mem-store/blob/46a25e9fe75f85a31dc6c052f4807eaf4745fdbb/mem-store.js#L329-L404
29,853
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/content/validate.js
validateContentType
function validateContentType(cb) { if (!_.isUndefined(kontx.args.meta) && !_.isUndefined(kontx.args.meta.type)) { db.contentTypes.getById(kontx.args.meta.type.toString()).then( function(contentType) { cb(null, contentType); }, function() { cb(createError(400, messages.invalid_content_type)); }); } else { cb(createError(400, messages.invalid_content_type)); } }
javascript
function validateContentType(cb) { if (!_.isUndefined(kontx.args.meta) && !_.isUndefined(kontx.args.meta.type)) { db.contentTypes.getById(kontx.args.meta.type.toString()).then( function(contentType) { cb(null, contentType); }, function() { cb(createError(400, messages.invalid_content_type)); }); } else { cb(createError(400, messages.invalid_content_type)); } }
[ "function", "validateContentType", "(", "cb", ")", "{", "if", "(", "!", "_", ".", "isUndefined", "(", "kontx", ".", "args", ".", "meta", ")", "&&", "!", "_", ".", "isUndefined", "(", "kontx", ".", "args", ".", "meta", ".", "type", ")", ")", "{", ...
Function will test to see if the content type is in the system.
[ "Function", "will", "test", "to", "see", "if", "the", "content", "type", "is", "in", "the", "system", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L27-L40
29,854
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/content/validate.js
validateFields
function validateFields(contentType, cb) { if (_.isArray(contentType.fields)) { async.each(contentType.fields, validateField, function(err) { cb(err); }); } else { cb(); } }
javascript
function validateFields(contentType, cb) { if (_.isArray(contentType.fields)) { async.each(contentType.fields, validateField, function(err) { cb(err); }); } else { cb(); } }
[ "function", "validateFields", "(", "contentType", ",", "cb", ")", "{", "if", "(", "_", ".", "isArray", "(", "contentType", ".", "fields", ")", ")", "{", "async", ".", "each", "(", "contentType", ".", "fields", ",", "validateField", ",", "function", "(", ...
Function will iterate all the fields in the content type and check the validation rules for each one.
[ "Function", "will", "iterate", "all", "the", "fields", "in", "the", "content", "type", "and", "check", "the", "validation", "rules", "for", "each", "one", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L43-L51
29,855
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/content/validate.js
validateField
function validateField(field, cb) { if (_.isArray(field.validation)) { async.each(field.validation, performValidation(field), function(err) { cb(err); }); } else { cb(); } }
javascript
function validateField(field, cb) { if (_.isArray(field.validation)) { async.each(field.validation, performValidation(field), function(err) { cb(err); }); } else { cb(); } }
[ "function", "validateField", "(", "field", ",", "cb", ")", "{", "if", "(", "_", ".", "isArray", "(", "field", ".", "validation", ")", ")", "{", "async", ".", "each", "(", "field", ".", "validation", ",", "performValidation", "(", "field", ")", ",", "...
Function will iterate all of the validation rules for a specific field and perform the validation rule.
[ "Function", "will", "iterate", "all", "of", "the", "validation", "rules", "for", "a", "specific", "field", "and", "perform", "the", "validation", "rule", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L54-L62
29,856
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/content/validate.js
performValidation
function performValidation(field) { return function(rule, cb) { var valueToBeValidated = kontx.args.fields[field._id], validate = validator.get(rule); //Undefined values do not need to be validated unless the field is required if (rule.type === 'required' || !_.isUndefined(valueToBeValidated)) { if (_.isArray(valueToBeValidated)) { q.all( _.map(valueToBeValidated, function(value) { return validate(value, rule.options); }) ) .then( function() { cb(); }, function() { cb(createError(400, validationTemplate({ label: field.label }))); } ); } else { validate(valueToBeValidated, rule.options) .then( function() { cb(); }, function() { cb(createError(400, validationTemplate({ label: field.label }))); } ); } } else { cb(); } }; }
javascript
function performValidation(field) { return function(rule, cb) { var valueToBeValidated = kontx.args.fields[field._id], validate = validator.get(rule); //Undefined values do not need to be validated unless the field is required if (rule.type === 'required' || !_.isUndefined(valueToBeValidated)) { if (_.isArray(valueToBeValidated)) { q.all( _.map(valueToBeValidated, function(value) { return validate(value, rule.options); }) ) .then( function() { cb(); }, function() { cb(createError(400, validationTemplate({ label: field.label }))); } ); } else { validate(valueToBeValidated, rule.options) .then( function() { cb(); }, function() { cb(createError(400, validationTemplate({ label: field.label }))); } ); } } else { cb(); } }; }
[ "function", "performValidation", "(", "field", ")", "{", "return", "function", "(", "rule", ",", "cb", ")", "{", "var", "valueToBeValidated", "=", "kontx", ".", "args", ".", "fields", "[", "field", ".", "_id", "]", ",", "validate", "=", "validator", ".",...
Function actually tests the field for a specific validation rule.
[ "Function", "actually", "tests", "the", "field", "for", "a", "specific", "validation", "rule", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/content/validate.js#L65-L105
29,857
grasshopper-cms/grasshopper-core-nodejs
lib/security/providers/facebook.js
_getPersistantFacebookToken
function _getPersistantFacebookToken(){ return facebook.query() .get('/oauth/access_token?' + 'grant_type=fb_exchange_token&' + 'client_id=' + appId + '&' + 'client_secret=' + secret + '&' + 'fb_exchange_token=' + this.options.code) .request() .then(function (res) { // Bad tokens result in a 200 with an error object if (res[1].error) { throw new Error(res[1].error.message); } this.creds = querystring.parse(res[1]); }.bind(this)); }
javascript
function _getPersistantFacebookToken(){ return facebook.query() .get('/oauth/access_token?' + 'grant_type=fb_exchange_token&' + 'client_id=' + appId + '&' + 'client_secret=' + secret + '&' + 'fb_exchange_token=' + this.options.code) .request() .then(function (res) { // Bad tokens result in a 200 with an error object if (res[1].error) { throw new Error(res[1].error.message); } this.creds = querystring.parse(res[1]); }.bind(this)); }
[ "function", "_getPersistantFacebookToken", "(", ")", "{", "return", "facebook", ".", "query", "(", ")", ".", "get", "(", "'/oauth/access_token?'", "+", "'grant_type=fb_exchange_token&'", "+", "'client_id='", "+", "appId", "+", "'&'", "+", "'client_secret='", "+", ...
Function will accept the passed in authentication token from FB and exchange it for a permenant token. This token will be saved to the user's identities profile.
[ "Function", "will", "accept", "the", "passed", "in", "authentication", "token", "from", "FB", "and", "exchange", "it", "for", "a", "permenant", "token", ".", "This", "token", "will", "be", "saved", "to", "the", "user", "s", "identities", "profile", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L39-L55
29,858
grasshopper-cms/grasshopper-core-nodejs
lib/security/providers/facebook.js
_createNewFacebookUser
function _createNewFacebookUser() { var avatar = '', excludedFields = ['link', 'email', 'first_name', 'last_name','picture'], newUser; //Set Image if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){ avatar = this.socialUserInfo.picture.data.url; } newUser = { role: 'external', identities: { facebook: { id: this.socialUserInfo.id, accessToken: this.creds.access_token, expiresIn: this.creds.expires } }, linkedidentities: ['facebook'], profile: { picture: avatar }, enabled: true, email: this.socialUserInfo.email, firstname: this.socialUserInfo.first_name, lastname: this.socialUserInfo.last_name }; _.each(profileFieldsArr, function(field){ if(excludedFields.indexOf(field) === -1){ newUser.profile[field] = this.socialUserInfo[field]; } }.bind(this)); return db.users.insert(newUser); }
javascript
function _createNewFacebookUser() { var avatar = '', excludedFields = ['link', 'email', 'first_name', 'last_name','picture'], newUser; //Set Image if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){ avatar = this.socialUserInfo.picture.data.url; } newUser = { role: 'external', identities: { facebook: { id: this.socialUserInfo.id, accessToken: this.creds.access_token, expiresIn: this.creds.expires } }, linkedidentities: ['facebook'], profile: { picture: avatar }, enabled: true, email: this.socialUserInfo.email, firstname: this.socialUserInfo.first_name, lastname: this.socialUserInfo.last_name }; _.each(profileFieldsArr, function(field){ if(excludedFields.indexOf(field) === -1){ newUser.profile[field] = this.socialUserInfo[field]; } }.bind(this)); return db.users.insert(newUser); }
[ "function", "_createNewFacebookUser", "(", ")", "{", "var", "avatar", "=", "''", ",", "excludedFields", "=", "[", "'link'", ",", "'email'", ",", "'first_name'", ",", "'last_name'", ",", "'picture'", "]", ",", "newUser", ";", "//Set Image", "if", "(", "this",...
Function that takes the facebook social data and attaches it to a user in grasshopper
[ "Function", "that", "takes", "the", "facebook", "social", "data", "and", "attaches", "it", "to", "a", "user", "in", "grasshopper" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L97-L133
29,859
grasshopper-cms/grasshopper-core-nodejs
lib/security/providers/facebook.js
_createNewToken
function _createNewToken() { var token = uuid.v4(), newTokenObj = { _id: crypto.createHash(token, config.crypto.secret_passphrase), uid: this.userInfo._id.toString(), created: new Date().toISOString(), type: 'facebook' }; return db.tokens.insert(newTokenObj).then(function() { return token; }); }
javascript
function _createNewToken() { var token = uuid.v4(), newTokenObj = { _id: crypto.createHash(token, config.crypto.secret_passphrase), uid: this.userInfo._id.toString(), created: new Date().toISOString(), type: 'facebook' }; return db.tokens.insert(newTokenObj).then(function() { return token; }); }
[ "function", "_createNewToken", "(", ")", "{", "var", "token", "=", "uuid", ".", "v4", "(", ")", ",", "newTokenObj", "=", "{", "_id", ":", "crypto", ".", "createHash", "(", "token", ",", "config", ".", "crypto", ".", "secret_passphrase", ")", ",", "uid"...
Function will create a new access token in grasshopper and return it to the app
[ "Function", "will", "create", "a", "new", "access", "token", "in", "grasshopper", "and", "return", "it", "to", "the", "app" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/security/providers/facebook.js#L149-L159
29,860
aureooms/js-itertools
lib/reduce/some.js
some
function some(iterable, n) { if (n <= 0) return true; for (let item of iterable) { if (item && --n === 0) return true; } return false; }
javascript
function some(iterable, n) { if (n <= 0) return true; for (let item of iterable) { if (item && --n === 0) return true; } return false; }
[ "function", "some", "(", "iterable", ",", "n", ")", "{", "if", "(", "n", "<=", "0", ")", "return", "true", ";", "for", "(", "let", "item", "of", "iterable", ")", "{", "if", "(", "item", "&&", "--", "n", "===", "0", ")", "return", "true", ";", ...
Returns true if at least some of the elements of the input iterable are truthy. @example some( repeat( true ) , 100 ) ; // returns true @example some( repeat( false ) , 0 ) ; // returns true @example some( repeat( false ) , 10 ) ; // loops forever @example some( nrepeat( true , 10 ) , 11 ) ; // returns false @param {Iterable} iterable - The input iterable. @param {Number} n - The number of elements that should be truthy. @returns {Boolean} Returns <code>true</code> if at least <code>n</code> elements of <code>iterable</code> are truthy, <code>false</code> otherwise.
[ "Returns", "true", "if", "at", "least", "some", "of", "the", "elements", "of", "the", "input", "iterable", "are", "truthy", "." ]
72bafa5f3f957ceb37bdfa87a222364fe4974be3
https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/some.js#L30-L40
29,861
grasshopper-cms/grasshopper-core-nodejs
lib/runners/users.js
roleOrSelf
function roleOrSelf (role) { if (!_.isNumber(role)) { role = roles[role.toUpperCase()]; } return function validateRoleOrSelf (kontx, next) { var userPrivLevel = roles[kontx.user.role.toUpperCase()], passedInUserId = kontx.args[0], err = createError(strings.group('codes').forbidden, strings.group('errors').user_privileges_exceeded); //If user object passed in instead of a string then parse. if (!_.isUndefined(kontx.args[0]._id)) { passedInUserId = kontx.args[0]._id; } //If user has enough priviliges then keep going if (userPrivLevel <= parseInt(role, 10) || kontx.user._id.toString() === passedInUserId.toString()) { next(); return; } next(err); }; }
javascript
function roleOrSelf (role) { if (!_.isNumber(role)) { role = roles[role.toUpperCase()]; } return function validateRoleOrSelf (kontx, next) { var userPrivLevel = roles[kontx.user.role.toUpperCase()], passedInUserId = kontx.args[0], err = createError(strings.group('codes').forbidden, strings.group('errors').user_privileges_exceeded); //If user object passed in instead of a string then parse. if (!_.isUndefined(kontx.args[0]._id)) { passedInUserId = kontx.args[0]._id; } //If user has enough priviliges then keep going if (userPrivLevel <= parseInt(role, 10) || kontx.user._id.toString() === passedInUserId.toString()) { next(); return; } next(err); }; }
[ "function", "roleOrSelf", "(", "role", ")", "{", "if", "(", "!", "_", ".", "isNumber", "(", "role", ")", ")", "{", "role", "=", "roles", "[", "role", ".", "toUpperCase", "(", ")", "]", ";", "}", "return", "function", "validateRoleOrSelf", "(", "kontx...
Middleware the ensures that the user either has a good enough role or is trying to get information about themselves. @param role @returns {Function}
[ "Middleware", "the", "ensures", "that", "the", "user", "either", "has", "a", "good", "enough", "role", "or", "is", "trying", "to", "get", "information", "about", "themselves", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/runners/users.js#L18-L41
29,862
grasshopper-cms/grasshopper-core-nodejs
lib/runners/users.js
setDefaultUser
function setDefaultUser (kontx, next) { var a = _.clone(kontx.args); if (a.length === 0) { //No args are sent in, set first to be user id a[0] = kontx.user._id; } else if (_.has(a[0], 'include') || _.has(a[0], 'exclude')) { // If first arg is options then reassign a[0] = kontx.user._id; a[1] = kontx.args[0]; } kontx.args = a; next(); }
javascript
function setDefaultUser (kontx, next) { var a = _.clone(kontx.args); if (a.length === 0) { //No args are sent in, set first to be user id a[0] = kontx.user._id; } else if (_.has(a[0], 'include') || _.has(a[0], 'exclude')) { // If first arg is options then reassign a[0] = kontx.user._id; a[1] = kontx.args[0]; } kontx.args = a; next(); }
[ "function", "setDefaultUser", "(", "kontx", ",", "next", ")", "{", "var", "a", "=", "_", ".", "clone", "(", "kontx", ".", "args", ")", ";", "if", "(", "a", ".", "length", "===", "0", ")", "{", "//No args are sent in, set first to be user id", "a", "[", ...
Middleware that will set the function argument equal to the currently logged in user id if it is left empty. This can be used for returning back the currently logged in user's information. @param kontx @param next
[ "Middleware", "that", "will", "set", "the", "function", "argument", "equal", "to", "the", "currently", "logged", "in", "user", "id", "if", "it", "is", "left", "empty", ".", "This", "can", "be", "used", "for", "returning", "back", "the", "currently", "logge...
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/runners/users.js#L49-L62
29,863
grasshopper-cms/grasshopper-core-nodejs
lib/db/mongodb/mixins/fields.js
function(options){ var cleanOptions = this.parseOptions(options), excludes = _.clone(this.privateFields), includeExludes = []; // If any includes are passed in through the options clean up the // default excluded fields. A type can have some excluded fields by // default and if the user overrides this then we need to clean up the query. if(options && options.include){ _.each(options.include, function(include){ //If the include matches an existing exclude then remove it from the //excludes and also from the includes (you can't mix them) excludes = _.remove(excludes, function(o){ if(o === include){ cleanOptions.include = _.remove(cleanOptions.include, function(i){ return i !== include; }); } return o !== include; }); }); } includeExludes = _.union(cleanOptions.include, this.parseExclusion(cleanOptions.exclude), this.parseExclusion(excludes) ); return includeExludes.join(' '); }
javascript
function(options){ var cleanOptions = this.parseOptions(options), excludes = _.clone(this.privateFields), includeExludes = []; // If any includes are passed in through the options clean up the // default excluded fields. A type can have some excluded fields by // default and if the user overrides this then we need to clean up the query. if(options && options.include){ _.each(options.include, function(include){ //If the include matches an existing exclude then remove it from the //excludes and also from the includes (you can't mix them) excludes = _.remove(excludes, function(o){ if(o === include){ cleanOptions.include = _.remove(cleanOptions.include, function(i){ return i !== include; }); } return o !== include; }); }); } includeExludes = _.union(cleanOptions.include, this.parseExclusion(cleanOptions.exclude), this.parseExclusion(excludes) ); return includeExludes.join(' '); }
[ "function", "(", "options", ")", "{", "var", "cleanOptions", "=", "this", ".", "parseOptions", "(", "options", ")", ",", "excludes", "=", "_", ".", "clone", "(", "this", ".", "privateFields", ")", ",", "includeExludes", "=", "[", "]", ";", "// If any inc...
Build string variable that can be sent to mongo query to include or exclude fields in the response. Your implementation module should set 'privateFields' so that we can use the parameter here. @param options Query options object @returns {string}
[ "Build", "string", "variable", "that", "can", "be", "sent", "to", "mongo", "query", "to", "include", "or", "exclude", "fields", "in", "the", "response", ".", "Your", "implementation", "module", "should", "set", "privateFields", "so", "that", "we", "can", "us...
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/db/mongodb/mixins/fields.js#L38-L69
29,864
gilt/swig
packages/swig-minify/lib/regex-replacer.js
Position
function Position(file, line, column) { this.file = file; this.line = line || 1; this.column = column || 0; }
javascript
function Position(file, line, column) { this.file = file; this.line = line || 1; this.column = column || 0; }
[ "function", "Position", "(", "file", ",", "line", ",", "column", ")", "{", "this", ".", "file", "=", "file", ";", "this", ".", "line", "=", "line", "||", "1", ";", "this", ".", "column", "=", "column", "||", "0", ";", "}" ]
Handle a position in a file
[ "Handle", "a", "position", "in", "a", "file" ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-minify/lib/regex-replacer.js#L13-L17
29,865
gilt/swig
packages/swig-spec/lib/jasmine-nyan-reporter.js
function () { function draw(color, n) { n = Math.max(parseInt(n), 0); write(' '); write('\u001b[' + color + 'm' + n + '\u001b[0m'); write('\n'); } draw(colors.green, this.passed); draw(colors.fail, this.failed); draw(colors.pending, this.pending + ' '); write('\n'); cursor.up(this.numberOfLines); }
javascript
function () { function draw(color, n) { n = Math.max(parseInt(n), 0); write(' '); write('\u001b[' + color + 'm' + n + '\u001b[0m'); write('\n'); } draw(colors.green, this.passed); draw(colors.fail, this.failed); draw(colors.pending, this.pending + ' '); write('\n'); cursor.up(this.numberOfLines); }
[ "function", "(", ")", "{", "function", "draw", "(", "color", ",", "n", ")", "{", "n", "=", "Math", ".", "max", "(", "parseInt", "(", "n", ")", ",", "0", ")", ";", "write", "(", "' '", ")", ";", "write", "(", "'\\u001b['", "+", "color", "+", "...
Draw the "scoreboard" showing the number of passes, failures and pending tests. @api private
[ "Draw", "the", "scoreboard", "showing", "the", "number", "of", "passes", "failures", "and", "pending", "tests", "." ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L261-L277
29,866
gilt/swig
packages/swig-spec/lib/jasmine-nyan-reporter.js
function () { var self = this; this.trajectories.forEach(function(line, index) { write('\u001b[' + self.scoreboardWidth + 'C'); write(line.join('')); write('\n'); }); cursor.up(this.numberOfLines); }
javascript
function () { var self = this; this.trajectories.forEach(function(line, index) { write('\u001b[' + self.scoreboardWidth + 'C'); write(line.join('')); write('\n'); }); cursor.up(this.numberOfLines); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "this", ".", "trajectories", ".", "forEach", "(", "function", "(", "line", ",", "index", ")", "{", "write", "(", "'\\u001b['", "+", "self", ".", "scoreboardWidth", "+", "'C'", ")", ";", "wri...
Draw the rainbow. @api private
[ "Draw", "the", "rainbow", "." ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L300-L310
29,867
gilt/swig
packages/swig-spec/lib/jasmine-nyan-reporter.js
function () { var self = this; var startWidth = this.scoreboardWidth + this.trajectories[0].length; var color = '\u001b[' + startWidth + 'C'; var padding = ''; write(color); write('_,------,'); write('\n'); write(color); padding = self.tick ? ' ' : ' '; write('_|' + padding + '/\\_/\\ '); write('\n'); write(color); padding = self.tick ? '_' : '__'; var tail = self.tick ? '~' : '^'; var face; write(tail + '|' + padding + this.drawFace() + ' '); write('\n'); write(color); padding = self.tick ? ' ' : ' '; write(padding + '"" "" '); write('\n'); cursor.up(this.numberOfLines); }
javascript
function () { var self = this; var startWidth = this.scoreboardWidth + this.trajectories[0].length; var color = '\u001b[' + startWidth + 'C'; var padding = ''; write(color); write('_,------,'); write('\n'); write(color); padding = self.tick ? ' ' : ' '; write('_|' + padding + '/\\_/\\ '); write('\n'); write(color); padding = self.tick ? '_' : '__'; var tail = self.tick ? '~' : '^'; var face; write(tail + '|' + padding + this.drawFace() + ' '); write('\n'); write(color); padding = self.tick ? ' ' : ' '; write(padding + '"" "" '); write('\n'); cursor.up(this.numberOfLines); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "startWidth", "=", "this", ".", "scoreboardWidth", "+", "this", ".", "trajectories", "[", "0", "]", ".", "length", ";", "var", "color", "=", "'\\u001b['", "+", "startWidth", "+", "'C'",...
Draw the nyan cat @api private
[ "Draw", "the", "nyan", "cat" ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-spec/lib/jasmine-nyan-reporter.js#L317-L345
29,868
aureooms/js-itertools
lib/reduce/_reduce.js
_reduce
function _reduce(accumulator, iterable, initializer) { for (let item of iterable) { initializer = accumulator(initializer, item); } return initializer; }
javascript
function _reduce(accumulator, iterable, initializer) { for (let item of iterable) { initializer = accumulator(initializer, item); } return initializer; }
[ "function", "_reduce", "(", "accumulator", ",", "iterable", ",", "initializer", ")", "{", "for", "(", "let", "item", "of", "iterable", ")", "{", "initializer", "=", "accumulator", "(", "initializer", ",", "item", ")", ";", "}", "return", "initializer", ";"...
Applies the accumulator function iteratively on the last return value of the accumulator and the next value in the input iterable. The initial value is the initializer parameter. @example _reduce( ( x , y ) => x + y , range( 10 ) , 0 ) ; // returns 45 @example _reduce( ( x , y ) => x + y , range( 10 ) , 100 ) ; // returns 145 @param {Function} accumulator - The accumulator, a 2-ary function. @param {Iterable} iterable - The input iterable. @param {Object} initializer - The initial value of the reduction. @returns {Object} - The reduction of the elements of <code>iterable</code>.
[ "Applies", "the", "accumulator", "function", "iteratively", "on", "the", "last", "return", "value", "of", "the", "accumulator", "and", "the", "next", "value", "in", "the", "input", "iterable", ".", "The", "initial", "value", "is", "the", "initializer", "parame...
72bafa5f3f957ceb37bdfa87a222364fe4974be3
https://github.com/aureooms/js-itertools/blob/72bafa5f3f957ceb37bdfa87a222364fe4974be3/lib/reduce/_reduce.js#L23-L30
29,869
gilt/swig
packages/swig-install/lib/public-directory.js
compile
function compile() { swig.log.info('', 'Compiling module list...'); const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech'); const modPaths = glob.sync(modulesPath); let dirs; swig.log.verbose(`[compile] searching: ${modulesPath}`); swig.log.verbose(`[compile] found module directories: ${modPaths.length}`); modPaths.forEach((modPath) => { swig.log.verbose(`[compile] compiling: ${modPath}`); dirs = fs.readdirSync(modPath); _.each(dirs, (dir) => { const dirPath = path.join(modPath, dir); if (fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()) { azModules.push({ name: dir, path: dirPath }); } }); }); // group by basename, and take the 'topmost' module in the hierarchy azModules = _.groupBy(azModules, module => path.basename(module.path)); // pull out the 'winning' module path, for each module azModules = _.map(azModules, (modulesList) => { // the modules arg will be [{ name:, path: }, ...] if (modulesList.length === 1) { return modulesList[0]; } // glob will almost always return the right order, // but let's assert this to be safe. we can spare the cycles. return _.sortBy(modulesList, module => module.path.length)[0]; }); // and now we pretty sort a-z for various output // we dont reset azModules to the sorted array because we need it dirty for deps.less _.sortBy(azModules, mod => mod.name).forEach((mod) => { modules[mod.name] = mod.path; }); swig.log.verbose('[compile] sorted modules: '); swig.log.verbose(modules); }
javascript
function compile() { swig.log.info('', 'Compiling module list...'); const modulesPath = path.join(swig.temp, '/**/node_modules/@gilt-tech'); const modPaths = glob.sync(modulesPath); let dirs; swig.log.verbose(`[compile] searching: ${modulesPath}`); swig.log.verbose(`[compile] found module directories: ${modPaths.length}`); modPaths.forEach((modPath) => { swig.log.verbose(`[compile] compiling: ${modPath}`); dirs = fs.readdirSync(modPath); _.each(dirs, (dir) => { const dirPath = path.join(modPath, dir); if (fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory()) { azModules.push({ name: dir, path: dirPath }); } }); }); // group by basename, and take the 'topmost' module in the hierarchy azModules = _.groupBy(azModules, module => path.basename(module.path)); // pull out the 'winning' module path, for each module azModules = _.map(azModules, (modulesList) => { // the modules arg will be [{ name:, path: }, ...] if (modulesList.length === 1) { return modulesList[0]; } // glob will almost always return the right order, // but let's assert this to be safe. we can spare the cycles. return _.sortBy(modulesList, module => module.path.length)[0]; }); // and now we pretty sort a-z for various output // we dont reset azModules to the sorted array because we need it dirty for deps.less _.sortBy(azModules, mod => mod.name).forEach((mod) => { modules[mod.name] = mod.path; }); swig.log.verbose('[compile] sorted modules: '); swig.log.verbose(modules); }
[ "function", "compile", "(", ")", "{", "swig", ".", "log", ".", "info", "(", "''", ",", "'Compiling module list...'", ")", ";", "const", "modulesPath", "=", "path", ".", "join", "(", "swig", ".", "temp", ",", "'/**/node_modules/@gilt-tech'", ")", ";", "cons...
find and compile a list of all unique modules, and their paths
[ "find", "and", "compile", "a", "list", "of", "all", "unique", "modules", "and", "their", "paths" ]
499e83d60dea7208640549056d99988b29177980
https://github.com/gilt/swig/blob/499e83d60dea7208640549056d99988b29177980/packages/swig-install/lib/public-directory.js#L54-L101
29,870
casetext/fireproof
lib/pager.js
Pager
function Pager(ref, initialCount) { if (arguments.length < 1) { throw new Error('Not enough arguments to Pager'); } this._mainRef = ref.ref(); this._resetCurrentOperation(); this.hasNext = true; this.hasPrevious = false; var promise; if (initialCount) { promise = this.next(initialCount); } else { promise = Fireproof.Promise.resolve([]); } this.then = promise.then.bind(promise); }
javascript
function Pager(ref, initialCount) { if (arguments.length < 1) { throw new Error('Not enough arguments to Pager'); } this._mainRef = ref.ref(); this._resetCurrentOperation(); this.hasNext = true; this.hasPrevious = false; var promise; if (initialCount) { promise = this.next(initialCount); } else { promise = Fireproof.Promise.resolve([]); } this.then = promise.then.bind(promise); }
[ "function", "Pager", "(", "ref", ",", "initialCount", ")", "{", "if", "(", "arguments", ".", "length", "<", "1", ")", "{", "throw", "new", "Error", "(", "'Not enough arguments to Pager'", ")", ";", "}", "this", ".", "_mainRef", "=", "ref", ".", "ref", ...
A helper object for paging over Firebase objects. @constructor Fireproof.Pager @static @param {Fireproof} ref a Firebase ref whose children you wish to page over. @param {Number} [initialCount] The number of objects in the first page. @property {Boolean} hasPrevious True if there are more objects before the current page. @property {Boolean} hasNext True if there are more objects after the current page.
[ "A", "helper", "object", "for", "paging", "over", "Firebase", "objects", "." ]
a568157310d965d2c115e5a3c9e8287fc8fe021b
https://github.com/casetext/fireproof/blob/a568157310d965d2c115e5a3c9e8287fc8fe021b/lib/pager.js#L11-L32
29,871
pex-gl/pex-gl
patch-gl.js
flipImageData
function flipImageData (data, width, height) { const numComponents = data.length / (width * height) for (let y = 0; y < height / 2; y++) { for (let x = 0; x < width; x++) { for (let c = 0; c < numComponents; c++) { const i = (y * width + x) * numComponents + c const flippedI = ((height - y - 1) * width + x) * numComponents + c const tmp = data[i] data[i] = data[flippedI] data[flippedI] = tmp } } } }
javascript
function flipImageData (data, width, height) { const numComponents = data.length / (width * height) for (let y = 0; y < height / 2; y++) { for (let x = 0; x < width; x++) { for (let c = 0; c < numComponents; c++) { const i = (y * width + x) * numComponents + c const flippedI = ((height - y - 1) * width + x) * numComponents + c const tmp = data[i] data[i] = data[flippedI] data[flippedI] = tmp } } } }
[ "function", "flipImageData", "(", "data", ",", "width", ",", "height", ")", "{", "const", "numComponents", "=", "data", ".", "length", "/", "(", "width", "*", "height", ")", "for", "(", "let", "y", "=", "0", ";", "y", "<", "height", "/", "2", ";", ...
Flipping array buffer in place
[ "Flipping", "array", "buffer", "in", "place" ]
d611c6defd45676da98edb9242da9c30faeef18e
https://github.com/pex-gl/pex-gl/blob/d611c6defd45676da98edb9242da9c30faeef18e/patch-gl.js#L2-L15
29,872
stealjs/steal-npm
npm-load.js
deeplyExtendPkg
function deeplyExtendPkg(a, b) { if(!a.resolutions) { a.resolutions = {}; } utils.extend(a.resolutions, b.resolutions || {}); if(!a.steal) { a.steal = {}; } if(!b.steal) { b.steal = {}; } utils.extend(a.steal, b.steal, true); }
javascript
function deeplyExtendPkg(a, b) { if(!a.resolutions) { a.resolutions = {}; } utils.extend(a.resolutions, b.resolutions || {}); if(!a.steal) { a.steal = {}; } if(!b.steal) { b.steal = {}; } utils.extend(a.steal, b.steal, true); }
[ "function", "deeplyExtendPkg", "(", "a", ",", "b", ")", "{", "if", "(", "!", "a", ".", "resolutions", ")", "{", "a", ".", "resolutions", "=", "{", "}", ";", "}", "utils", ".", "extend", "(", "a", ".", "resolutions", ",", "b", ".", "resolutions", ...
Deeply extend the configuration that needs to be kept from a previous bundle that runs through the build process. This makes sure that if we load different configuration for different bundles, all of it is retained for use in production.
[ "Deeply", "extend", "the", "configuration", "that", "needs", "to", "be", "kept", "from", "a", "previous", "bundle", "that", "runs", "through", "the", "build", "process", ".", "This", "makes", "sure", "that", "if", "we", "load", "different", "configuration", ...
216463c552cabe7d9dad86d754da784b5dea3d78
https://github.com/stealjs/steal-npm/blob/216463c552cabe7d9dad86d754da784b5dea3d78/npm-load.js#L255-L269
29,873
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/nodes/getChildren.js
loadChild
function loadChild(node, cb){ db.nodes.getByParent(node._id.toString()).then( function(data){ payload = payload.concat(data); async.each(data, loadChild, cb); }).done(); }
javascript
function loadChild(node, cb){ db.nodes.getByParent(node._id.toString()).then( function(data){ payload = payload.concat(data); async.each(data, loadChild, cb); }).done(); }
[ "function", "loadChild", "(", "node", ",", "cb", ")", "{", "db", ".", "nodes", ".", "getByParent", "(", "node", ".", "_id", ".", "toString", "(", ")", ")", ".", "then", "(", "function", "(", "data", ")", "{", "payload", "=", "payload", ".", "concat...
Recursive function to load children and save them into the payload
[ "Recursive", "function", "to", "load", "children", "and", "save", "them", "into", "the", "payload" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/nodes/getChildren.js#L21-L27
29,874
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/nodes/getChildren.js
setNodes
function setNodes(data){ payload = data; if(kontx.args.deep === true){ async.eachSeries(data, loadChild, sendNext); } else { sendNext(); } }
javascript
function setNodes(data){ payload = data; if(kontx.args.deep === true){ async.eachSeries(data, loadChild, sendNext); } else { sendNext(); } }
[ "function", "setNodes", "(", "data", ")", "{", "payload", "=", "data", ";", "if", "(", "kontx", ".", "args", ".", "deep", "===", "true", ")", "{", "async", ".", "eachSeries", "(", "data", ",", "loadChild", ",", "sendNext", ")", ";", "}", "else", "{...
Initial callback that sets the payload and kicks off the recursive method if "deep" is set to true
[ "Initial", "callback", "that", "sets", "the", "payload", "and", "kicks", "off", "the", "recursive", "method", "if", "deep", "is", "set", "to", "true" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/nodes/getChildren.js#L30-L39
29,875
reddit/node-build
lib/build.js
function() { if (!builds.length) { return; } // this shouldn't happen var build = builds.shift(); var buildCallback = function(stats) { cb(build.buildName, stats); if (builds.length) { runNextBuild(); } }; console.log(colors.cyan('[Starting build]'), build.buildName); executeBuild(build, buildCallback); }
javascript
function() { if (!builds.length) { return; } // this shouldn't happen var build = builds.shift(); var buildCallback = function(stats) { cb(build.buildName, stats); if (builds.length) { runNextBuild(); } }; console.log(colors.cyan('[Starting build]'), build.buildName); executeBuild(build, buildCallback); }
[ "function", "(", ")", "{", "if", "(", "!", "builds", ".", "length", ")", "{", "return", ";", "}", "// this shouldn't happen", "var", "build", "=", "builds", ".", "shift", "(", ")", ";", "var", "buildCallback", "=", "function", "(", "stats", ")", "{", ...
Run each build serially so the server can do things like read an app manifest file that's genrated during the client build step.
[ "Run", "each", "build", "serially", "so", "the", "server", "can", "do", "things", "like", "read", "an", "app", "manifest", "file", "that", "s", "genrated", "during", "the", "client", "build", "step", "." ]
af30dc8c637631b177ae33a1984a44ffa839914b
https://github.com/reddit/node-build/blob/af30dc8c637631b177ae33a1984a44ffa839914b/lib/build.js#L20-L32
29,876
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js
function(){ var portHeight=parseFloat($("#workarea").css("height")); var portWidth=parseFloat($("#workarea").css("width")); var portX=$("#workarea").scrollLeft(); var portY=$("#workarea").scrollTop(); var windowWidth=parseFloat($("#svgcanvas").css("width")); var windowHeight=parseFloat($("#svgcanvas").css("height")); var overviewWidth=$("#overviewMiniView").attr("width"); var overviewHeight=$("#overviewMiniView").attr("height"); var viewBoxX=portX/windowWidth*overviewWidth; var viewBoxY=portY/windowHeight*overviewHeight; var viewBoxWidth=portWidth/windowWidth*overviewWidth; var viewBoxHeight=portHeight/windowHeight*overviewHeight; $("#overview_window_view_box").css("min-width",viewBoxWidth+"px"); $("#overview_window_view_box").css("min-height",viewBoxHeight+"px"); $("#overview_window_view_box").css("top",viewBoxY+"px"); $("#overview_window_view_box").css("left",viewBoxX+"px"); }
javascript
function(){ var portHeight=parseFloat($("#workarea").css("height")); var portWidth=parseFloat($("#workarea").css("width")); var portX=$("#workarea").scrollLeft(); var portY=$("#workarea").scrollTop(); var windowWidth=parseFloat($("#svgcanvas").css("width")); var windowHeight=parseFloat($("#svgcanvas").css("height")); var overviewWidth=$("#overviewMiniView").attr("width"); var overviewHeight=$("#overviewMiniView").attr("height"); var viewBoxX=portX/windowWidth*overviewWidth; var viewBoxY=portY/windowHeight*overviewHeight; var viewBoxWidth=portWidth/windowWidth*overviewWidth; var viewBoxHeight=portHeight/windowHeight*overviewHeight; $("#overview_window_view_box").css("min-width",viewBoxWidth+"px"); $("#overview_window_view_box").css("min-height",viewBoxHeight+"px"); $("#overview_window_view_box").css("top",viewBoxY+"px"); $("#overview_window_view_box").css("left",viewBoxX+"px"); }
[ "function", "(", ")", "{", "var", "portHeight", "=", "parseFloat", "(", "$", "(", "\"#workarea\"", ")", ".", "css", "(", "\"height\"", ")", ")", ";", "var", "portWidth", "=", "parseFloat", "(", "$", "(", "\"#workarea\"", ")", ".", "css", "(", "\"width\...
define dynamic animation of the view box.
[ "define", "dynamic", "animation", "of", "the", "view", "box", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js#L30-L49
29,877
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js
function(){ var viewWidth=$("#svgroot").attr("width"); var viewHeight=$("#svgroot").attr("height"); var viewX=640; var viewY=480; if(svgedit.browser.isIE()) { //This has only been tested with Firefox 10 and IE 9 (without chrome frame). //I am not sure if if is Firefox or IE that is being non compliant here. //Either way the one that is noncompliant may become more compliant later. //TAG:HACK //TAG:VERSION_DEPENDENT //TAG:BROWSER_SNIFFING viewX=0; viewY=0; } var svgWidth_old=$("#overviewMiniView").attr("width"); var svgHeight_new=viewHeight/viewWidth*svgWidth_old; $("#overviewMiniView").attr("viewBox",viewX+" "+viewY+" "+viewWidth+" "+viewHeight); $("#overviewMiniView").attr("height",svgHeight_new); updateViewBox(); }
javascript
function(){ var viewWidth=$("#svgroot").attr("width"); var viewHeight=$("#svgroot").attr("height"); var viewX=640; var viewY=480; if(svgedit.browser.isIE()) { //This has only been tested with Firefox 10 and IE 9 (without chrome frame). //I am not sure if if is Firefox or IE that is being non compliant here. //Either way the one that is noncompliant may become more compliant later. //TAG:HACK //TAG:VERSION_DEPENDENT //TAG:BROWSER_SNIFFING viewX=0; viewY=0; } var svgWidth_old=$("#overviewMiniView").attr("width"); var svgHeight_new=viewHeight/viewWidth*svgWidth_old; $("#overviewMiniView").attr("viewBox",viewX+" "+viewY+" "+viewWidth+" "+viewHeight); $("#overviewMiniView").attr("height",svgHeight_new); updateViewBox(); }
[ "function", "(", ")", "{", "var", "viewWidth", "=", "$", "(", "\"#svgroot\"", ")", ".", "attr", "(", "\"width\"", ")", ";", "var", "viewHeight", "=", "$", "(", "\"#svgroot\"", ")", ".", "attr", "(", "\"height\"", ")", ";", "var", "viewX", "=", "640",...
comphensate for changes in zoom and canvas size
[ "comphensate", "for", "changes", "in", "zoom", "and", "canvas", "size" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-overview_window.js#L59-L82
29,878
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js
getLinked
function getLinked(elem, attr) { var str = elem.getAttribute(attr); if(!str) {return null;} var m = str.match(/\(\#(.*)\)/); if(!m || m.length !== 2) { return null; } return S.getElem(m[1]); }
javascript
function getLinked(elem, attr) { var str = elem.getAttribute(attr); if(!str) {return null;} var m = str.match(/\(\#(.*)\)/); if(!m || m.length !== 2) { return null; } return S.getElem(m[1]); }
[ "function", "getLinked", "(", "elem", ",", "attr", ")", "{", "var", "str", "=", "elem", ".", "getAttribute", "(", "attr", ")", ";", "if", "(", "!", "str", ")", "{", "return", "null", ";", "}", "var", "m", "=", "str", ".", "match", "(", "/", "\\...
elem = a graphic element will have an attribute like marker-start attr - marker-start, marker-mid, or marker-end returns the marker element that is linked to the graphic element
[ "elem", "=", "a", "graphic", "element", "will", "have", "an", "attribute", "like", "marker", "-", "start", "attr", "-", "marker", "-", "start", "marker", "-", "mid", "or", "marker", "-", "end", "returns", "the", "marker", "element", "that", "is", "linked...
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L113-L121
29,879
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js
colorChanged
function colorChanged(elem) { var color = elem.getAttribute('stroke'); $.each(mtypes, function(i, pos) { var marker = getLinked(elem, 'marker-'+pos); if (!marker) {return;} if (!marker.attributes.se_type) {return;} // not created by this extension var ch = marker.lastElementChild; if (!ch) {return;} var curfill = ch.getAttribute('fill'); var curstroke = ch.getAttribute('stroke'); if (curfill && curfill != 'none') {ch.setAttribute('fill', color);} if (curstroke && curstroke != 'none') {ch.setAttribute('stroke', color);} }); }
javascript
function colorChanged(elem) { var color = elem.getAttribute('stroke'); $.each(mtypes, function(i, pos) { var marker = getLinked(elem, 'marker-'+pos); if (!marker) {return;} if (!marker.attributes.se_type) {return;} // not created by this extension var ch = marker.lastElementChild; if (!ch) {return;} var curfill = ch.getAttribute('fill'); var curstroke = ch.getAttribute('stroke'); if (curfill && curfill != 'none') {ch.setAttribute('fill', color);} if (curstroke && curstroke != 'none') {ch.setAttribute('stroke', color);} }); }
[ "function", "colorChanged", "(", "elem", ")", "{", "var", "color", "=", "elem", ".", "getAttribute", "(", "'stroke'", ")", ";", "$", ".", "each", "(", "mtypes", ",", "function", "(", "i", ",", "pos", ")", "{", "var", "marker", "=", "getLinked", "(", ...
called when the main system modifies an object this routine changes the associated markers to be the same color
[ "called", "when", "the", "main", "system", "modifies", "an", "object", "this", "routine", "changes", "the", "associated", "markers", "to", "be", "the", "same", "color" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L329-L343
29,880
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js
updateReferences
function updateReferences(el) { $.each(mtypes, function (i, pos) { var id = marker_prefix + pos + '_' + el.id; var marker_name = 'marker-'+pos; var marker = getLinked(el, marker_name); if (!marker || !marker.attributes.se_type) {return;} // not created by this extension var url = el.getAttribute(marker_name); if (url) { var len = el.id.length; var linkid = url.substr(-len-1, len); if (el.id != linkid) { var val = $('#'+pos + '_marker').attr('value'); addMarker(id, val); svgCanvas.changeSelectedAttribute(marker_name, "url(#" + id + ")"); if (el.tagName === 'line' && pos == 'mid') {el = convertline(el);} S.call("changed", selElems); } } }); }
javascript
function updateReferences(el) { $.each(mtypes, function (i, pos) { var id = marker_prefix + pos + '_' + el.id; var marker_name = 'marker-'+pos; var marker = getLinked(el, marker_name); if (!marker || !marker.attributes.se_type) {return;} // not created by this extension var url = el.getAttribute(marker_name); if (url) { var len = el.id.length; var linkid = url.substr(-len-1, len); if (el.id != linkid) { var val = $('#'+pos + '_marker').attr('value'); addMarker(id, val); svgCanvas.changeSelectedAttribute(marker_name, "url(#" + id + ")"); if (el.tagName === 'line' && pos == 'mid') {el = convertline(el);} S.call("changed", selElems); } } }); }
[ "function", "updateReferences", "(", "el", ")", "{", "$", ".", "each", "(", "mtypes", ",", "function", "(", "i", ",", "pos", ")", "{", "var", "id", "=", "marker_prefix", "+", "pos", "+", "'_'", "+", "el", ".", "id", ";", "var", "marker_name", "=", ...
called when the main system creates or modifies an object primary purpose is create new markers for cloned objects
[ "called", "when", "the", "main", "system", "creates", "or", "modifies", "an", "object", "primary", "purpose", "is", "create", "new", "markers", "for", "cloned", "objects" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-markers.js#L347-L366
29,881
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js
function(elem) { try { // TODO: Fix issue with rotated groups. Currently they work // fine in FF, but not in other browsers (same problem mentioned // in Issue 339 comment #2). var bb = svgedit.utilities.getBBox(elem); var angle = svgedit.utilities.getRotationAngle(elem); if ((angle && angle % 90) || svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) { // Accurate way to get BBox of rotated element in Firefox: // Put element in group and get its BBox var good_bb = false; // Get the BBox from the raw path for these elements var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; if (elemNames.indexOf(elem.tagName) >= 0) { bb = good_bb = canvas.convertToPath(elem, true); } else if (elem.tagName == 'rect') { // Look for radius var rx = elem.getAttribute('rx'); var ry = elem.getAttribute('ry'); if (rx || ry) { bb = good_bb = canvas.convertToPath(elem, true); } } if (!good_bb) { // Must use clone else FF freaks out var clone = elem.cloneNode(true); var g = document.createElementNS(NS.SVG, "g"); var parent = elem.parentNode; parent.appendChild(g); g.appendChild(clone); bb = svgedit.utilities.bboxToObj(g.getBBox()); parent.removeChild(g); } // Old method: Works by giving the rotated BBox, // this is (unfortunately) what Opera and Safari do // natively when getting the BBox of the parent group // var angle = angle * Math.PI / 180.0; // var rminx = Number.MAX_VALUE, rminy = Number.MAX_VALUE, // rmaxx = Number.MIN_VALUE, rmaxy = Number.MIN_VALUE; // var cx = round(bb.x + bb.width/2), // cy = round(bb.y + bb.height/2); // var pts = [ [bb.x - cx, bb.y - cy], // [bb.x + bb.width - cx, bb.y - cy], // [bb.x + bb.width - cx, bb.y + bb.height - cy], // [bb.x - cx, bb.y + bb.height - cy] ]; // var j = 4; // while (j--) { // var x = pts[j][0], // y = pts[j][1], // r = Math.sqrt( x*x + y*y ); // var theta = Math.atan2(y,x) + angle; // x = round(r * Math.cos(theta) + cx); // y = round(r * Math.sin(theta) + cy); // // // now set the bbox for the shape after it's been rotated // if (x < rminx) rminx = x; // if (y < rminy) rminy = y; // if (x > rmaxx) rmaxx = x; // if (y > rmaxy) rmaxy = y; // } // // bb.x = rminx; // bb.y = rminy; // bb.width = rmaxx - rminx; // bb.height = rmaxy - rminy; } return bb; } catch(e) { console.log(elem, e); return null; } }
javascript
function(elem) { try { // TODO: Fix issue with rotated groups. Currently they work // fine in FF, but not in other browsers (same problem mentioned // in Issue 339 comment #2). var bb = svgedit.utilities.getBBox(elem); var angle = svgedit.utilities.getRotationAngle(elem); if ((angle && angle % 90) || svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) { // Accurate way to get BBox of rotated element in Firefox: // Put element in group and get its BBox var good_bb = false; // Get the BBox from the raw path for these elements var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; if (elemNames.indexOf(elem.tagName) >= 0) { bb = good_bb = canvas.convertToPath(elem, true); } else if (elem.tagName == 'rect') { // Look for radius var rx = elem.getAttribute('rx'); var ry = elem.getAttribute('ry'); if (rx || ry) { bb = good_bb = canvas.convertToPath(elem, true); } } if (!good_bb) { // Must use clone else FF freaks out var clone = elem.cloneNode(true); var g = document.createElementNS(NS.SVG, "g"); var parent = elem.parentNode; parent.appendChild(g); g.appendChild(clone); bb = svgedit.utilities.bboxToObj(g.getBBox()); parent.removeChild(g); } // Old method: Works by giving the rotated BBox, // this is (unfortunately) what Opera and Safari do // natively when getting the BBox of the parent group // var angle = angle * Math.PI / 180.0; // var rminx = Number.MAX_VALUE, rminy = Number.MAX_VALUE, // rmaxx = Number.MIN_VALUE, rmaxy = Number.MIN_VALUE; // var cx = round(bb.x + bb.width/2), // cy = round(bb.y + bb.height/2); // var pts = [ [bb.x - cx, bb.y - cy], // [bb.x + bb.width - cx, bb.y - cy], // [bb.x + bb.width - cx, bb.y + bb.height - cy], // [bb.x - cx, bb.y + bb.height - cy] ]; // var j = 4; // while (j--) { // var x = pts[j][0], // y = pts[j][1], // r = Math.sqrt( x*x + y*y ); // var theta = Math.atan2(y,x) + angle; // x = round(r * Math.cos(theta) + cx); // y = round(r * Math.sin(theta) + cy); // // // now set the bbox for the shape after it's been rotated // if (x < rminx) rminx = x; // if (y < rminy) rminy = y; // if (x > rmaxx) rmaxx = x; // if (y > rmaxy) rmaxy = y; // } // // bb.x = rminx; // bb.y = rminy; // bb.width = rmaxx - rminx; // bb.height = rmaxy - rminy; } return bb; } catch(e) { console.log(elem, e); return null; } }
[ "function", "(", "elem", ")", "{", "try", "{", "// TODO: Fix issue with rotated groups. Currently they work", "// fine in FF, but not in other browsers (same problem mentioned", "// in Issue 339 comment #2).", "var", "bb", "=", "svgedit", ".", "utilities", ".", "getBBox", "(", ...
Make sure the expected BBox is returned if the element is a group
[ "Make", "sure", "the", "expected", "BBox", "is", "returned", "if", "the", "element", "is", "a", "group" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js#L602-L679
29,882
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js
function(m) { console.log([m.a, m.b, m.c, m.d, m.e, m.f]); }
javascript
function(m) { console.log([m.a, m.b, m.c, m.d, m.e, m.f]); }
[ "function", "(", "m", ")", "{", "console", ".", "log", "(", "[", "m", ".", "a", ",", "m", ".", "b", ",", "m", ".", "c", ",", "m", ".", "d", ",", "m", ".", "e", ",", "m", ".", "f", "]", ")", ";", "}" ]
Debug tool to easily see the current matrix in the browser's console
[ "Debug", "tool", "to", "easily", "see", "the", "current", "matrix", "in", "the", "browser", "s", "console" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/svgcanvas.js#L1022-L1024
29,883
apostrophecms-legacy/apostrophe-pages
index.js
sanitizeSpontaneousAreas
function sanitizeSpontaneousAreas(req, data, page, callback) { var toSanitize = []; _.each(data, function(val, key) { if (typeof(val) === 'object') { if (val.type === 'area') { if (_.has(page, key) && ((typeof(page[key]) !== 'object') || (page[key].type !== 'area'))) { // Spontaneous areas may not replace properties that are not areas return; } toSanitize.push({ key: key, items: val.items }); } } }); return async.eachSeries(toSanitize, function(entry, callback) { return apos.sanitizeItems(req, entry.items || [], function(err, _items) { if (err) { return callback(err); } entry.items = _items; return callback(null); }); }, function(err) { if (err) { return callback(err); } _.each(toSanitize, function(entry) { page[entry.key] = { type: 'area', items: entry.items }; }); return callback(null); }); }
javascript
function sanitizeSpontaneousAreas(req, data, page, callback) { var toSanitize = []; _.each(data, function(val, key) { if (typeof(val) === 'object') { if (val.type === 'area') { if (_.has(page, key) && ((typeof(page[key]) !== 'object') || (page[key].type !== 'area'))) { // Spontaneous areas may not replace properties that are not areas return; } toSanitize.push({ key: key, items: val.items }); } } }); return async.eachSeries(toSanitize, function(entry, callback) { return apos.sanitizeItems(req, entry.items || [], function(err, _items) { if (err) { return callback(err); } entry.items = _items; return callback(null); }); }, function(err) { if (err) { return callback(err); } _.each(toSanitize, function(entry) { page[entry.key] = { type: 'area', items: entry.items }; }); return callback(null); }); }
[ "function", "sanitizeSpontaneousAreas", "(", "req", ",", "data", ",", "page", ",", "callback", ")", "{", "var", "toSanitize", "=", "[", "]", ";", "_", ".", "each", "(", "data", ",", "function", "(", "val", ",", "key", ")", "{", "if", "(", "typeof", ...
Both the new and edit page operations utilize this to deal with areas that arise spontaneously via page templates rather than being hardcoded in the schema. The rule is that if an otherwise unknown property is an object with a "type" sub-property set to "area", that is accepted and sanitized as an area.
[ "Both", "the", "new", "and", "edit", "page", "operations", "utilize", "this", "to", "deal", "with", "areas", "that", "arise", "spontaneously", "via", "page", "templates", "rather", "than", "being", "hardcoded", "in", "the", "schema", ".", "The", "rule", "is"...
72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3
https://github.com/apostrophecms-legacy/apostrophe-pages/blob/72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3/index.js#L1760-L1790
29,884
apostrophecms-legacy/apostrophe-pages
index.js
diffVersions
function diffVersions(callback) { var prior = null; _.each(versions, function(version) { if (!prior) { version.diff = [ { value: '[NEW]', added: true } ]; } else { version.diff = apos.diffPages(prior, version); } prior = version; }); versions.reverse(); return callback(null); }
javascript
function diffVersions(callback) { var prior = null; _.each(versions, function(version) { if (!prior) { version.diff = [ { value: '[NEW]', added: true } ]; } else { version.diff = apos.diffPages(prior, version); } prior = version; }); versions.reverse(); return callback(null); }
[ "function", "diffVersions", "(", "callback", ")", "{", "var", "prior", "=", "null", ";", "_", ".", "each", "(", "versions", ",", "function", "(", "version", ")", "{", "if", "(", "!", "prior", ")", "{", "version", ".", "diff", "=", "[", "{", "value"...
We must diff on the fly because versions get pruned over time
[ "We", "must", "diff", "on", "the", "fly", "because", "versions", "get", "pruned", "over", "time" ]
72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3
https://github.com/apostrophecms-legacy/apostrophe-pages/blob/72eb4b1df351b1c253e9b1c2bd2fe3fff6eb71b3/index.js#L2226-L2238
29,885
grasshopper-cms/grasshopper-core-nodejs
lib/db/mongodb/nodes.js
getId
function getId(id){ if(_.isObject(id) && !_.isUndefined(id.id)){ if (objectIdRegex.test(id.id)) { id = id.id; } else { id = null; } } return id; }
javascript
function getId(id){ if(_.isObject(id) && !_.isUndefined(id.id)){ if (objectIdRegex.test(id.id)) { id = id.id; } else { id = null; } } return id; }
[ "function", "getId", "(", "id", ")", "{", "if", "(", "_", ".", "isObject", "(", "id", ")", "&&", "!", "_", ".", "isUndefined", "(", "id", ".", "id", ")", ")", "{", "if", "(", "objectIdRegex", ".", "test", "(", "id", ".", "id", ")", ")", "{", ...
Function will look at the id that has been passed to the module and if it is a string send it back, if it is an object with an `id` property then it will check to see if it is a valid mongo objectid format and then send it back. @param id @returns {*}
[ "Function", "will", "look", "at", "the", "id", "that", "has", "been", "passed", "to", "the", "module", "and", "if", "it", "is", "a", "string", "send", "it", "back", "if", "it", "is", "an", "object", "with", "an", "id", "property", "then", "it", "will...
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/db/mongodb/nodes.js#L30-L40
29,886
grasshopper-cms/grasshopper-core-nodejs
dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-connector.js
init
function init() { // Make sure all connectors have data set $(svgcontent).find('*').each(function() { var conn = this.getAttributeNS(se_ns, "connector"); if(conn) { this.setAttribute('class', conn_sel.substr(1)); var conn_data = conn.split(' '); var sbb = svgCanvas.getStrokedBBox([getElem(conn_data[0])]); var ebb = svgCanvas.getStrokedBBox([getElem(conn_data[1])]); $(this).data('c_start',conn_data[0]) .data('c_end',conn_data[1]) .data('start_bb', sbb) .data('end_bb', ebb); svgCanvas.getEditorNS(true); } }); // updateConnectors(); }
javascript
function init() { // Make sure all connectors have data set $(svgcontent).find('*').each(function() { var conn = this.getAttributeNS(se_ns, "connector"); if(conn) { this.setAttribute('class', conn_sel.substr(1)); var conn_data = conn.split(' '); var sbb = svgCanvas.getStrokedBBox([getElem(conn_data[0])]); var ebb = svgCanvas.getStrokedBBox([getElem(conn_data[1])]); $(this).data('c_start',conn_data[0]) .data('c_end',conn_data[1]) .data('start_bb', sbb) .data('end_bb', ebb); svgCanvas.getEditorNS(true); } }); // updateConnectors(); }
[ "function", "init", "(", ")", "{", "// Make sure all connectors have data set", "$", "(", "svgcontent", ")", ".", "find", "(", "'*'", ")", ".", "each", "(", "function", "(", ")", "{", "var", "conn", "=", "this", ".", "getAttributeNS", "(", "se_ns", ",", ...
Do on reset
[ "Do", "on", "reset" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/dev/server/public/admin/vendor/svg-edit-2.7/extensions/ext-connector.js#L274-L291
29,887
matmanjs/matman
packages/matman-crawler/asserts/nightmare-preload.js
error
function error(err) { if (!(err instanceof Error)) return err return { code: err.code, message: err.message, details: err.detail, stack: err.stack || '' } }
javascript
function error(err) { if (!(err instanceof Error)) return err return { code: err.code, message: err.message, details: err.detail, stack: err.stack || '' } }
[ "function", "error", "(", "err", ")", "{", "if", "(", "!", "(", "err", "instanceof", "Error", ")", ")", "return", "err", "return", "{", "code", ":", "err", ".", "code", ",", "message", ":", "err", ".", "message", ",", "details", ":", "err", ".", ...
Make errors serializeable
[ "Make", "errors", "serializeable" ]
2ffe0760aba4d8ccb45f056bb1aa1b8429e2c89a
https://github.com/matmanjs/matman/blob/2ffe0760aba4d8ccb45f056bb1aa1b8429e2c89a/packages/matman-crawler/asserts/nightmare-preload.js#L106-L114
29,888
stratumn/js-chainscript
src/proto/chainscript_pb.js
Segment
function Segment(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Segment(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Segment", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if", ...
Properties of a Segment. @memberof stratumn.chainscript @interface ISegment @property {stratumn.chainscript.ILink|null} [link] Segment link @property {stratumn.chainscript.ISegmentMeta|null} [meta] Segment meta Constructs a new Segment. @memberof stratumn.chainscript @classdesc Represents a Segment. @implements ISegment @constructor @param {stratumn.chainscript.ISegment=} [properties] Properties to set
[ "Properties", "of", "a", "Segment", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L48-L53
29,889
stratumn/js-chainscript
src/proto/chainscript_pb.js
SegmentMeta
function SegmentMeta(properties) { this.evidences = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function SegmentMeta(properties) { this.evidences = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "SegmentMeta", "(", "properties", ")", "{", "this", ".", "evidences", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", ...
Properties of a SegmentMeta. @memberof stratumn.chainscript @interface ISegmentMeta @property {Uint8Array|null} [linkHash] SegmentMeta linkHash @property {Array.<stratumn.chainscript.IEvidence>|null} [evidences] SegmentMeta evidences Constructs a new SegmentMeta. @memberof stratumn.chainscript @classdesc Represents a SegmentMeta. @implements ISegmentMeta @constructor @param {stratumn.chainscript.ISegmentMeta=} [properties] Properties to set
[ "Properties", "of", "a", "SegmentMeta", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L268-L274
29,890
stratumn/js-chainscript
src/proto/chainscript_pb.js
Evidence
function Evidence(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Evidence(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Evidence", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if",...
Properties of an Evidence. @memberof stratumn.chainscript @interface IEvidence @property {string|null} [version] Evidence version @property {string|null} [backend] Evidence backend @property {string|null} [provider] Evidence provider @property {Uint8Array|null} [proof] Evidence proof Constructs a new Evidence. @memberof stratumn.chainscript @classdesc Represents an Evidence. @implements IEvidence @constructor @param {stratumn.chainscript.IEvidence=} [properties] Properties to set
[ "Properties", "of", "an", "Evidence", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L510-L515
29,891
stratumn/js-chainscript
src/proto/chainscript_pb.js
Link
function Link(properties) { this.signatures = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Link(properties) { this.signatures = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Link", "(", "properties", ")", "{", "this", ".", "signatures", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys"...
Properties of a Link. @memberof stratumn.chainscript @interface ILink @property {string|null} [version] Link version @property {Uint8Array|null} [data] Link data @property {stratumn.chainscript.ILinkMeta|null} [meta] Link meta @property {Array.<stratumn.chainscript.ISignature>|null} [signatures] Link signatures Constructs a new Link. @memberof stratumn.chainscript @classdesc Represents a Link. @implements ILink @constructor @param {stratumn.chainscript.ILink=} [properties] Properties to set
[ "Properties", "of", "a", "Link", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L773-L779
29,892
stratumn/js-chainscript
src/proto/chainscript_pb.js
Process
function Process(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Process(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Process", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if", ...
Properties of a Process. @memberof stratumn.chainscript @interface IProcess @property {string|null} [name] Process name @property {string|null} [state] Process state Constructs a new Process. @memberof stratumn.chainscript @classdesc Represents a Process. @implements IProcess @constructor @param {stratumn.chainscript.IProcess=} [properties] Properties to set
[ "Properties", "of", "a", "Process", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1061-L1066
29,893
stratumn/js-chainscript
src/proto/chainscript_pb.js
LinkMeta
function LinkMeta(properties) { this.refs = []; this.tags = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function LinkMeta(properties) { this.refs = []; this.tags = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "LinkMeta", "(", "properties", ")", "{", "this", ".", "refs", "=", "[", "]", ";", "this", ".", "tags", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",...
Properties of a LinkMeta. @memberof stratumn.chainscript @interface ILinkMeta @property {string|null} [clientId] LinkMeta clientId @property {Uint8Array|null} [prevLinkHash] LinkMeta prevLinkHash @property {number|null} [priority] LinkMeta priority @property {Array.<stratumn.chainscript.ILinkReference>|null} [refs] LinkMeta refs @property {number|null} [outDegree] LinkMeta outDegree @property {stratumn.chainscript.IProcess|null} [process] LinkMeta process @property {string|null} [mapId] LinkMeta mapId @property {string|null} [action] LinkMeta action @property {string|null} [step] LinkMeta step @property {Array.<string>|null} [tags] LinkMeta tags @property {Uint8Array|null} [data] LinkMeta data Constructs a new LinkMeta. @memberof stratumn.chainscript @classdesc Represents a LinkMeta. @implements ILinkMeta @constructor @param {stratumn.chainscript.ILinkMeta=} [properties] Properties to set
[ "Properties", "of", "a", "LinkMeta", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1280-L1287
29,894
stratumn/js-chainscript
src/proto/chainscript_pb.js
LinkReference
function LinkReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function LinkReference(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "LinkReference", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", ...
Properties of a LinkReference. @memberof stratumn.chainscript @interface ILinkReference @property {Uint8Array|null} [linkHash] LinkReference linkHash @property {string|null} [process] LinkReference process Constructs a new LinkReference. @memberof stratumn.chainscript @classdesc Represents a LinkReference. @implements ILinkReference @constructor @param {stratumn.chainscript.ILinkReference=} [properties] Properties to set
[ "Properties", "of", "a", "LinkReference", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1741-L1746
29,895
stratumn/js-chainscript
src/proto/chainscript_pb.js
Signature
function Signature(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
javascript
function Signature(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) this[keys[i]] = properties[keys[i]]; }
[ "function", "Signature", "(", "properties", ")", "{", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "++", "i", ")", "if"...
Properties of a Signature. @memberof stratumn.chainscript @interface ISignature @property {string|null} [version] Signature version @property {string|null} [type] Signature type @property {string|null} [payloadPath] Signature payloadPath @property {Uint8Array|null} [publicKey] Signature publicKey @property {Uint8Array|null} [signature] Signature signature Constructs a new Signature. @memberof stratumn.chainscript @classdesc Represents a Signature. @implements ISignature @constructor @param {stratumn.chainscript.ISignature=} [properties] Properties to set
[ "Properties", "of", "a", "Signature", "." ]
1aba9933f18107d6d66c0b559cb07255e6398cdb
https://github.com/stratumn/js-chainscript/blob/1aba9933f18107d6d66c0b559cb07255e6398cdb/src/proto/chainscript_pb.js#L1963-L1968
29,896
grasshopper-cms/grasshopper-core-nodejs
lib/middleware/assets/index.js
proxy
function proxy(func){ 'use strict'; // Returns a middleware return function (kontx, next){ func(kontx.args).then( function(payload){ kontx.payload = payload; next(); }, function(err){ next(err); } ); }; }
javascript
function proxy(func){ 'use strict'; // Returns a middleware return function (kontx, next){ func(kontx.args).then( function(payload){ kontx.payload = payload; next(); }, function(err){ next(err); } ); }; }
[ "function", "proxy", "(", "func", ")", "{", "'use strict'", ";", "// Returns a middleware", "return", "function", "(", "kontx", ",", "next", ")", "{", "func", "(", "kontx", ".", "args", ")", ".", "then", "(", "function", "(", "payload", ")", "{", "kontx"...
Proxy function will take a assets function and wrap it with a middleware. @param func @returns {Function}
[ "Proxy", "function", "will", "take", "a", "assets", "function", "and", "wrap", "it", "with", "a", "middleware", "." ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/lib/middleware/assets/index.js#L9-L24
29,897
grasshopper-cms/grasshopper-core-nodejs
docs/js/vendor/flipclock/flipclock.js
function(index, obj) { var lang = this.lang; var lindex = index.toLowerCase(); if(typeof obj == "object") { lang = obj; } if(lang && lang[lindex]) { return lang[lindex]; } return index; }
javascript
function(index, obj) { var lang = this.lang; var lindex = index.toLowerCase(); if(typeof obj == "object") { lang = obj; } if(lang && lang[lindex]) { return lang[lindex]; } return index; }
[ "function", "(", "index", ",", "obj", ")", "{", "var", "lang", "=", "this", ".", "lang", ";", "var", "lindex", "=", "index", ".", "toLowerCase", "(", ")", ";", "if", "(", "typeof", "obj", "==", "\"object\"", ")", "{", "lang", "=", "obj", ";", "}"...
Localize strings into various languages @param string The index of the localized string @param object Optionally pass a lang object
[ "Localize", "strings", "into", "various", "languages" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L354-L367
29,898
grasshopper-cms/grasshopper-core-nodejs
docs/js/vendor/flipclock/flipclock.js
function(callback) { this.face.stop(); this.timer.stop(callback); for(var x in this.lists) { this.lists[x].stop(); } }
javascript
function(callback) { this.face.stop(); this.timer.stop(callback); for(var x in this.lists) { this.lists[x].stop(); } }
[ "function", "(", "callback", ")", "{", "this", ".", "face", ".", "stop", "(", ")", ";", "this", ".", "timer", ".", "stop", "(", "callback", ")", ";", "for", "(", "var", "x", "in", "this", ".", "lists", ")", "{", "this", ".", "lists", "[", "x", ...
Stops the clock
[ "Stops", "the", "clock" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L396-L403
29,899
grasshopper-cms/grasshopper-core-nodejs
docs/js/vendor/flipclock/flipclock.js
function(label, css, excludeDots) { if(typeof css == "boolean" || !css) { excludeDots = css; css = label; } var dots = [ '<span class="'+this.factory.classes.dot+' top"></span>', '<span class="'+this.factory.classes.dot+' bottom"></span>' ].join(''); if(excludeDots) { dots = ''; } label = this.factory.localize(label); var html = [ '<span class="'+this.factory.classes.divider+' '+(css ? css : '').toLowerCase()+'">', '<span class="'+this.factory.classes.label+'">'+(label ? label : '')+'</span>', dots, '</span>' ]; return $(html.join('')); }
javascript
function(label, css, excludeDots) { if(typeof css == "boolean" || !css) { excludeDots = css; css = label; } var dots = [ '<span class="'+this.factory.classes.dot+' top"></span>', '<span class="'+this.factory.classes.dot+' bottom"></span>' ].join(''); if(excludeDots) { dots = ''; } label = this.factory.localize(label); var html = [ '<span class="'+this.factory.classes.divider+' '+(css ? css : '').toLowerCase()+'">', '<span class="'+this.factory.classes.label+'">'+(label ? label : '')+'</span>', dots, '</span>' ]; return $(html.join('')); }
[ "function", "(", "label", ",", "css", ",", "excludeDots", ")", "{", "if", "(", "typeof", "css", "==", "\"boolean\"", "||", "!", "css", ")", "{", "excludeDots", "=", "css", ";", "css", "=", "label", ";", "}", "var", "dots", "=", "[", "'<span class=\"'...
Creates a jQuery object used for the digit divider @param mixed The divider label text @param mixed Set true to exclude the dots in the divider. If not set, is false.
[ "Creates", "a", "jQuery", "object", "used", "for", "the", "digit", "divider" ]
8fabc3bfc5b18855ead443db0644608a277d0ea0
https://github.com/grasshopper-cms/grasshopper-core-nodejs/blob/8fabc3bfc5b18855ead443db0644608a277d0ea0/docs/js/vendor/flipclock/flipclock.js#L514-L540