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
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
duniter/duniter-ui
public/libraries.js
function( entireComponent ) { // Insert a new component holder in the root or box. if ( entireComponent ) P.$root.html( createWrappedComponent() ) else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) ) // Trigger the queued “render” events. return P.trigger( 'render' ) }
javascript
function( entireComponent ) { // Insert a new component holder in the root or box. if ( entireComponent ) P.$root.html( createWrappedComponent() ) else P.$root.find( '.' + CLASSES.box ).html( P.component.nodes( STATE.open ) ) // Trigger the queued “render” events. return P.trigger( 'render' ) }
[ "function", "(", "entireComponent", ")", "{", "if", "(", "entireComponent", ")", "P", ".", "$root", ".", "html", "(", "createWrappedComponent", "(", ")", ")", "else", "P", ".", "$root", ".", "find", "(", "'.'", "+", "CLASSES", ".", "box", ")", ".", "html", "(", "P", ".", "component", ".", "nodes", "(", "STATE", ".", "open", ")", ")", "return", "P", ".", "trigger", "(", "'render'", ")", "}" ]
start Render a new picker
[ "start", "Render", "a", "new", "picker" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73601-L73609
train
duniter/duniter-ui
public/libraries.js
function() { // If it’s already stopped, do nothing. if ( !STATE.start ) return P // Then close the picker. P.close() // Remove the hidden field. if ( P._hidden ) { P._hidden.parentNode.removeChild( P._hidden ) } // Remove the root. P.$root.remove() // Remove the input class, remove the stored data, and unbind // the events (after a tick for IE - see `P.close`). $ELEMENT.removeClass( CLASSES.input ).removeData( NAME ) setTimeout( function() { $ELEMENT.off( '.' + STATE.id ) }, 0) // Restore the element state ELEMENT.type = STATE.type ELEMENT.readOnly = false // Trigger the queued “stop” events. P.trigger( 'stop' ) // Reset the picker states. STATE.methods = {} STATE.start = false return P }
javascript
function() { // If it’s already stopped, do nothing. if ( !STATE.start ) return P // Then close the picker. P.close() // Remove the hidden field. if ( P._hidden ) { P._hidden.parentNode.removeChild( P._hidden ) } // Remove the root. P.$root.remove() // Remove the input class, remove the stored data, and unbind // the events (after a tick for IE - see `P.close`). $ELEMENT.removeClass( CLASSES.input ).removeData( NAME ) setTimeout( function() { $ELEMENT.off( '.' + STATE.id ) }, 0) // Restore the element state ELEMENT.type = STATE.type ELEMENT.readOnly = false // Trigger the queued “stop” events. P.trigger( 'stop' ) // Reset the picker states. STATE.methods = {} STATE.start = false return P }
[ "function", "(", ")", "{", "if", "(", "!", "STATE", ".", "start", ")", "return", "P", "P", ".", "close", "(", ")", "if", "(", "P", ".", "_hidden", ")", "{", "P", ".", "_hidden", ".", "parentNode", ".", "removeChild", "(", "P", ".", "_hidden", ")", "}", "P", ".", "$root", ".", "remove", "(", ")", "$ELEMENT", ".", "removeClass", "(", "CLASSES", ".", "input", ")", ".", "removeData", "(", "NAME", ")", "setTimeout", "(", "function", "(", ")", "{", "$ELEMENT", ".", "off", "(", "'.'", "+", "STATE", ".", "id", ")", "}", ",", "0", ")", "ELEMENT", ".", "type", "=", "STATE", ".", "type", "ELEMENT", ".", "readOnly", "=", "false", "P", ".", "trigger", "(", "'stop'", ")", "STATE", ".", "methods", "=", "{", "}", "STATE", ".", "start", "=", "false", "return", "P", "}" ]
render Destroy everything
[ "render", "Destroy", "everything" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73615-L73650
train
duniter/duniter-ui
public/libraries.js
function( dontGiveFocus ) { // If it’s already open, do nothing. if ( STATE.open ) return P // Add the “active” class. $ELEMENT.addClass( CLASSES.active ) aria( ELEMENT, 'expanded', true ) // * A Firefox bug, when `html` has `overflow:hidden`, results in // killing transitions :(. So add the “opened” state on the next tick. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 setTimeout( function() { // Add the “opened” class to the picker root. P.$root.addClass( CLASSES.opened ) aria( P.$root[0], 'hidden', false ) }, 0 ) // If we have to give focus, bind the element and doc events. if ( dontGiveFocus !== false ) { // Set it as open. STATE.open = true // Prevent the page from scrolling. if ( IS_DEFAULT_THEME ) { $html. css( 'overflow', 'hidden' ). css( 'padding-right', '+=' + getScrollbarWidth() ) } // Pass focus to the root element’s jQuery object. // * Workaround for iOS8 to bring the picker’s root into view. P.$root[0].focus() // Bind the document events. $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) { var target = event.target // If the target of the event is not the element, close the picker picker. // * Don’t worry about clicks or focusins on the root because those don’t bubble up. // Also, for Firefox, a click on an `option` element bubbles up directly // to the doc. So make sure the target wasn't the doc. // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling, // which causes the picker to unexpectedly close when right-clicking it. So make // sure the event wasn’t a right-click. if ( target != ELEMENT && target != document && event.which != 3 ) { // If the target was the holder that covers the screen, // keep the element focused to maintain tabindex. P.close( target === P.$root.children()[0] ) } }).on( 'keydown.' + STATE.id, function( event ) { var // Get the keycode. keycode = event.keyCode, // Translate that to a selection change. keycodeToMove = P.component.key[ keycode ], // Grab the target. target = event.target // On escape, close the picker and give focus. if ( keycode == 27 ) { P.close( true ) } // Check if there is a key movement or “enter” keypress on the element. else if ( target == P.$root[0] && ( keycodeToMove || keycode == 13 ) ) { // Prevent the default action to stop page movement. event.preventDefault() // Trigger the key movement action. if ( keycodeToMove ) { PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] ) } // On “enter”, if the highlighted item isn’t disabled, set the value and close. else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) { P.set( 'select', P.component.item.highlight ).close() } } // If the target is within the root and “enter” is pressed, // prevent the default action and trigger a click on the target instead. else if ( $.contains( P.$root[0], target ) && keycode == 13 ) { event.preventDefault() target.click() } }) } // Trigger the queued “open” events. return P.trigger( 'open' ) }
javascript
function( dontGiveFocus ) { // If it’s already open, do nothing. if ( STATE.open ) return P // Add the “active” class. $ELEMENT.addClass( CLASSES.active ) aria( ELEMENT, 'expanded', true ) // * A Firefox bug, when `html` has `overflow:hidden`, results in // killing transitions :(. So add the “opened” state on the next tick. // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=625289 setTimeout( function() { // Add the “opened” class to the picker root. P.$root.addClass( CLASSES.opened ) aria( P.$root[0], 'hidden', false ) }, 0 ) // If we have to give focus, bind the element and doc events. if ( dontGiveFocus !== false ) { // Set it as open. STATE.open = true // Prevent the page from scrolling. if ( IS_DEFAULT_THEME ) { $html. css( 'overflow', 'hidden' ). css( 'padding-right', '+=' + getScrollbarWidth() ) } // Pass focus to the root element’s jQuery object. // * Workaround for iOS8 to bring the picker’s root into view. P.$root[0].focus() // Bind the document events. $document.on( 'click.' + STATE.id + ' focusin.' + STATE.id, function( event ) { var target = event.target // If the target of the event is not the element, close the picker picker. // * Don’t worry about clicks or focusins on the root because those don’t bubble up. // Also, for Firefox, a click on an `option` element bubbles up directly // to the doc. So make sure the target wasn't the doc. // * In Firefox stopPropagation() doesn’t prevent right-click events from bubbling, // which causes the picker to unexpectedly close when right-clicking it. So make // sure the event wasn’t a right-click. if ( target != ELEMENT && target != document && event.which != 3 ) { // If the target was the holder that covers the screen, // keep the element focused to maintain tabindex. P.close( target === P.$root.children()[0] ) } }).on( 'keydown.' + STATE.id, function( event ) { var // Get the keycode. keycode = event.keyCode, // Translate that to a selection change. keycodeToMove = P.component.key[ keycode ], // Grab the target. target = event.target // On escape, close the picker and give focus. if ( keycode == 27 ) { P.close( true ) } // Check if there is a key movement or “enter” keypress on the element. else if ( target == P.$root[0] && ( keycodeToMove || keycode == 13 ) ) { // Prevent the default action to stop page movement. event.preventDefault() // Trigger the key movement action. if ( keycodeToMove ) { PickerConstructor._.trigger( P.component.key.go, P, [ PickerConstructor._.trigger( keycodeToMove ) ] ) } // On “enter”, if the highlighted item isn’t disabled, set the value and close. else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) { P.set( 'select', P.component.item.highlight ).close() } } // If the target is within the root and “enter” is pressed, // prevent the default action and trigger a click on the target instead. else if ( $.contains( P.$root[0], target ) && keycode == 13 ) { event.preventDefault() target.click() } }) } // Trigger the queued “open” events. return P.trigger( 'open' ) }
[ "function", "(", "dontGiveFocus", ")", "{", "if", "(", "STATE", ".", "open", ")", "return", "P", "$ELEMENT", ".", "addClass", "(", "CLASSES", ".", "active", ")", "aria", "(", "ELEMENT", ",", "'expanded'", ",", "true", ")", "setTimeout", "(", "function", "(", ")", "{", "P", ".", "$root", ".", "addClass", "(", "CLASSES", ".", "opened", ")", "aria", "(", "P", ".", "$root", "[", "0", "]", ",", "'hidden'", ",", "false", ")", "}", ",", "0", ")", "if", "(", "dontGiveFocus", "!==", "false", ")", "{", "STATE", ".", "open", "=", "true", "if", "(", "IS_DEFAULT_THEME", ")", "{", "$html", ".", "css", "(", "'overflow'", ",", "'hidden'", ")", ".", "css", "(", "'padding-right'", ",", "'+='", "+", "getScrollbarWidth", "(", ")", ")", "}", "P", ".", "$root", "[", "0", "]", ".", "focus", "(", ")", "$document", ".", "on", "(", "'click.'", "+", "STATE", ".", "id", "+", "' focusin.'", "+", "STATE", ".", "id", ",", "function", "(", "event", ")", "{", "var", "target", "=", "event", ".", "target", "if", "(", "target", "!=", "ELEMENT", "&&", "target", "!=", "document", "&&", "event", ".", "which", "!=", "3", ")", "{", "P", ".", "close", "(", "target", "===", "P", ".", "$root", ".", "children", "(", ")", "[", "0", "]", ")", "}", "}", ")", ".", "on", "(", "'keydown.'", "+", "STATE", ".", "id", ",", "function", "(", "event", ")", "{", "var", "keycode", "=", "event", ".", "keyCode", ",", "keycodeToMove", "=", "P", ".", "component", ".", "key", "[", "keycode", "]", ",", "target", "=", "event", ".", "target", "if", "(", "keycode", "==", "27", ")", "{", "P", ".", "close", "(", "true", ")", "}", "else", "if", "(", "target", "==", "P", ".", "$root", "[", "0", "]", "&&", "(", "keycodeToMove", "||", "keycode", "==", "13", ")", ")", "{", "event", ".", "preventDefault", "(", ")", "if", "(", "keycodeToMove", ")", "{", "PickerConstructor", ".", "_", ".", "trigger", "(", "P", ".", "component", ".", "key", ".", "go", ",", "P", ",", "[", "PickerConstructor", ".", "_", ".", "trigger", "(", "keycodeToMove", ")", "]", ")", "}", "else", "if", "(", "!", "P", ".", "$root", ".", "find", "(", "'.'", "+", "CLASSES", ".", "highlighted", ")", ".", "hasClass", "(", "CLASSES", ".", "disabled", ")", ")", "{", "P", ".", "set", "(", "'select'", ",", "P", ".", "component", ".", "item", ".", "highlight", ")", ".", "close", "(", ")", "}", "}", "else", "if", "(", "$", ".", "contains", "(", "P", ".", "$root", "[", "0", "]", ",", "target", ")", "&&", "keycode", "==", "13", ")", "{", "event", ".", "preventDefault", "(", ")", "target", ".", "click", "(", ")", "}", "}", ")", "}", "return", "P", ".", "trigger", "(", "'open'", ")", "}" ]
stop Open up the picker
[ "stop", "Open", "up", "the", "picker" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73656-L73760
train
duniter/duniter-ui
public/libraries.js
function( thing, value, options ) { var thingItem, thingValue, thingIsObject = $.isPlainObject( thing ), thingObject = thingIsObject ? thing : {} // Make sure we have usable options. options = thingIsObject && $.isPlainObject( value ) ? value : options || {} if ( thing ) { // If the thing isn’t an object, make it one. if ( !thingIsObject ) { thingObject[ thing ] = value } // Go through the things of items to set. for ( thingItem in thingObject ) { // Grab the value of the thing. thingValue = thingObject[ thingItem ] // First, if the item exists and there’s a value, set it. if ( thingItem in P.component.item ) { if ( thingValue === undefined ) thingValue = null P.component.set( thingItem, thingValue, options ) } // Then, check to update the element value and broadcast a change. if ( thingItem == 'select' || thingItem == 'clear' ) { $ELEMENT. val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ). trigger( 'change' ) } } // Render a new picker. P.render() } // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`. return options.muted ? P : P.trigger( 'set', thingObject ) }
javascript
function( thing, value, options ) { var thingItem, thingValue, thingIsObject = $.isPlainObject( thing ), thingObject = thingIsObject ? thing : {} // Make sure we have usable options. options = thingIsObject && $.isPlainObject( value ) ? value : options || {} if ( thing ) { // If the thing isn’t an object, make it one. if ( !thingIsObject ) { thingObject[ thing ] = value } // Go through the things of items to set. for ( thingItem in thingObject ) { // Grab the value of the thing. thingValue = thingObject[ thingItem ] // First, if the item exists and there’s a value, set it. if ( thingItem in P.component.item ) { if ( thingValue === undefined ) thingValue = null P.component.set( thingItem, thingValue, options ) } // Then, check to update the element value and broadcast a change. if ( thingItem == 'select' || thingItem == 'clear' ) { $ELEMENT. val( thingItem == 'clear' ? '' : P.get( thingItem, SETTINGS.format ) ). trigger( 'change' ) } } // Render a new picker. P.render() } // When the method isn’t muted, trigger queued “set” events and pass the `thingObject`. return options.muted ? P : P.trigger( 'set', thingObject ) }
[ "function", "(", "thing", ",", "value", ",", "options", ")", "{", "var", "thingItem", ",", "thingValue", ",", "thingIsObject", "=", "$", ".", "isPlainObject", "(", "thing", ")", ",", "thingObject", "=", "thingIsObject", "?", "thing", ":", "{", "}", "options", "=", "thingIsObject", "&&", "$", ".", "isPlainObject", "(", "value", ")", "?", "value", ":", "options", "||", "{", "}", "if", "(", "thing", ")", "{", "if", "(", "!", "thingIsObject", ")", "{", "thingObject", "[", "thing", "]", "=", "value", "}", "for", "(", "thingItem", "in", "thingObject", ")", "{", "thingValue", "=", "thingObject", "[", "thingItem", "]", "if", "(", "thingItem", "in", "P", ".", "component", ".", "item", ")", "{", "if", "(", "thingValue", "===", "undefined", ")", "thingValue", "=", "null", "P", ".", "component", ".", "set", "(", "thingItem", ",", "thingValue", ",", "options", ")", "}", "if", "(", "thingItem", "==", "'select'", "||", "thingItem", "==", "'clear'", ")", "{", "$ELEMENT", ".", "val", "(", "thingItem", "==", "'clear'", "?", "''", ":", "P", ".", "get", "(", "thingItem", ",", "SETTINGS", ".", "format", ")", ")", ".", "trigger", "(", "'change'", ")", "}", "}", "P", ".", "render", "(", ")", "}", "return", "options", ".", "muted", "?", "P", ":", "P", ".", "trigger", "(", "'set'", ",", "thingObject", ")", "}" ]
clear Set something
[ "clear", "Set", "something" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73826-L73868
train
duniter/duniter-ui
public/libraries.js
function( thing, format ) { // Make sure there’s something to get. thing = thing || 'value' // If a picker state exists, return that. if ( STATE[ thing ] != null ) { return STATE[ thing ] } // Return the submission value, if that. if ( thing == 'valueSubmit' ) { if ( P._hidden ) { return P._hidden.value } thing = 'value' } // Return the value, if that. if ( thing == 'value' ) { return ELEMENT.value } // Check if a component item exists, return that. if ( thing in P.component.item ) { if ( typeof format == 'string' ) { var thingValue = P.component.get( thing ) return thingValue ? PickerConstructor._.trigger( P.component.formats.toString, P.component, [ format, thingValue ] ) : '' } return P.component.get( thing ) } }
javascript
function( thing, format ) { // Make sure there’s something to get. thing = thing || 'value' // If a picker state exists, return that. if ( STATE[ thing ] != null ) { return STATE[ thing ] } // Return the submission value, if that. if ( thing == 'valueSubmit' ) { if ( P._hidden ) { return P._hidden.value } thing = 'value' } // Return the value, if that. if ( thing == 'value' ) { return ELEMENT.value } // Check if a component item exists, return that. if ( thing in P.component.item ) { if ( typeof format == 'string' ) { var thingValue = P.component.get( thing ) return thingValue ? PickerConstructor._.trigger( P.component.formats.toString, P.component, [ format, thingValue ] ) : '' } return P.component.get( thing ) } }
[ "function", "(", "thing", ",", "format", ")", "{", "thing", "=", "thing", "||", "'value'", "if", "(", "STATE", "[", "thing", "]", "!=", "null", ")", "{", "return", "STATE", "[", "thing", "]", "}", "if", "(", "thing", "==", "'valueSubmit'", ")", "{", "if", "(", "P", ".", "_hidden", ")", "{", "return", "P", ".", "_hidden", ".", "value", "}", "thing", "=", "'value'", "}", "if", "(", "thing", "==", "'value'", ")", "{", "return", "ELEMENT", ".", "value", "}", "if", "(", "thing", "in", "P", ".", "component", ".", "item", ")", "{", "if", "(", "typeof", "format", "==", "'string'", ")", "{", "var", "thingValue", "=", "P", ".", "component", ".", "get", "(", "thing", ")", "return", "thingValue", "?", "PickerConstructor", ".", "_", ".", "trigger", "(", "P", ".", "component", ".", "formats", ".", "toString", ",", "P", ".", "component", ",", "[", "format", ",", "thingValue", "]", ")", ":", "''", "}", "return", "P", ".", "component", ".", "get", "(", "thing", ")", "}", "}" ]
set Get something
[ "set", "Get", "something" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73874-L73910
train
duniter/duniter-ui
public/libraries.js
function( thing, method, internal ) { var thingName, thingMethod, thingIsObject = $.isPlainObject( thing ), thingObject = thingIsObject ? thing : {} if ( thing ) { // If the thing isn’t an object, make it one. if ( !thingIsObject ) { thingObject[ thing ] = method } // Go through the things to bind to. for ( thingName in thingObject ) { // Grab the method of the thing. thingMethod = thingObject[ thingName ] // If it was an internal binding, prefix it. if ( internal ) { thingName = '_' + thingName } // Make sure the thing methods collection exists. STATE.methods[ thingName ] = STATE.methods[ thingName ] || [] // Add the method to the relative method collection. STATE.methods[ thingName ].push( thingMethod ) } } return P }
javascript
function( thing, method, internal ) { var thingName, thingMethod, thingIsObject = $.isPlainObject( thing ), thingObject = thingIsObject ? thing : {} if ( thing ) { // If the thing isn’t an object, make it one. if ( !thingIsObject ) { thingObject[ thing ] = method } // Go through the things to bind to. for ( thingName in thingObject ) { // Grab the method of the thing. thingMethod = thingObject[ thingName ] // If it was an internal binding, prefix it. if ( internal ) { thingName = '_' + thingName } // Make sure the thing methods collection exists. STATE.methods[ thingName ] = STATE.methods[ thingName ] || [] // Add the method to the relative method collection. STATE.methods[ thingName ].push( thingMethod ) } } return P }
[ "function", "(", "thing", ",", "method", ",", "internal", ")", "{", "var", "thingName", ",", "thingMethod", ",", "thingIsObject", "=", "$", ".", "isPlainObject", "(", "thing", ")", ",", "thingObject", "=", "thingIsObject", "?", "thing", ":", "{", "}", "if", "(", "thing", ")", "{", "if", "(", "!", "thingIsObject", ")", "{", "thingObject", "[", "thing", "]", "=", "method", "}", "for", "(", "thingName", "in", "thingObject", ")", "{", "thingMethod", "=", "thingObject", "[", "thingName", "]", "if", "(", "internal", ")", "{", "thingName", "=", "'_'", "+", "thingName", "}", "STATE", ".", "methods", "[", "thingName", "]", "=", "STATE", ".", "methods", "[", "thingName", "]", "||", "[", "]", "STATE", ".", "methods", "[", "thingName", "]", ".", "push", "(", "thingMethod", ")", "}", "}", "return", "P", "}" ]
get Bind events on the things.
[ "get", "Bind", "events", "on", "the", "things", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73917-L73950
train
duniter/duniter-ui
public/libraries.js
function() { var i, thingName, names = arguments; for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) { thingName = names[i] if ( thingName in STATE.methods ) { delete STATE.methods[thingName] } } return P }
javascript
function() { var i, thingName, names = arguments; for ( i = 0, namesCount = names.length; i < namesCount; i += 1 ) { thingName = names[i] if ( thingName in STATE.methods ) { delete STATE.methods[thingName] } } return P }
[ "function", "(", ")", "{", "var", "i", ",", "thingName", ",", "names", "=", "arguments", ";", "for", "(", "i", "=", "0", ",", "namesCount", "=", "names", ".", "length", ";", "i", "<", "namesCount", ";", "i", "+=", "1", ")", "{", "thingName", "=", "names", "[", "i", "]", "if", "(", "thingName", "in", "STATE", ".", "methods", ")", "{", "delete", "STATE", ".", "methods", "[", "thingName", "]", "}", "}", "return", "P", "}" ]
on Unbind events on the things.
[ "on", "Unbind", "events", "on", "the", "things", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73957-L73967
train
duniter/duniter-ui
public/libraries.js
function( name, data ) { var _trigger = function( name ) { var methodList = STATE.methods[ name ] if ( methodList ) { methodList.map( function( method ) { PickerConstructor._.trigger( method, P, [ data ] ) }) } } _trigger( '_' + name ) _trigger( name ) return P }
javascript
function( name, data ) { var _trigger = function( name ) { var methodList = STATE.methods[ name ] if ( methodList ) { methodList.map( function( method ) { PickerConstructor._.trigger( method, P, [ data ] ) }) } } _trigger( '_' + name ) _trigger( name ) return P }
[ "function", "(", "name", ",", "data", ")", "{", "var", "_trigger", "=", "function", "(", "name", ")", "{", "var", "methodList", "=", "STATE", ".", "methods", "[", "name", "]", "if", "(", "methodList", ")", "{", "methodList", ".", "map", "(", "function", "(", "method", ")", "{", "PickerConstructor", ".", "_", ".", "trigger", "(", "method", ",", "P", ",", "[", "data", "]", ")", "}", ")", "}", "}", "_trigger", "(", "'_'", "+", "name", ")", "_trigger", "(", "name", ")", "return", "P", "}" ]
Fire off method events.
[ "Fire", "off", "method", "events", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73973-L73985
train
duniter/duniter-ui
public/libraries.js
createWrappedComponent
function createWrappedComponent() { // Create a picker wrapper holder return PickerConstructor._.node( 'div', // Create a picker wrapper node PickerConstructor._.node( 'div', // Create a picker frame PickerConstructor._.node( 'div', // Create a picker box node PickerConstructor._.node( 'div', // Create the components nodes. P.component.nodes( STATE.open ), // The picker box class CLASSES.box ), // Picker wrap class CLASSES.wrap ), // Picker frame class CLASSES.frame ), // Picker holder class CLASSES.holder ) //endreturn }
javascript
function createWrappedComponent() { // Create a picker wrapper holder return PickerConstructor._.node( 'div', // Create a picker wrapper node PickerConstructor._.node( 'div', // Create a picker frame PickerConstructor._.node( 'div', // Create a picker box node PickerConstructor._.node( 'div', // Create the components nodes. P.component.nodes( STATE.open ), // The picker box class CLASSES.box ), // Picker wrap class CLASSES.wrap ), // Picker frame class CLASSES.frame ), // Picker holder class CLASSES.holder ) //endreturn }
[ "function", "createWrappedComponent", "(", ")", "{", "return", "PickerConstructor", ".", "_", ".", "node", "(", "'div'", ",", "PickerConstructor", ".", "_", ".", "node", "(", "'div'", ",", "PickerConstructor", ".", "_", ".", "node", "(", "'div'", ",", "PickerConstructor", ".", "_", ".", "node", "(", "'div'", ",", "P", ".", "component", ".", "nodes", "(", "STATE", ".", "open", ")", ",", "CLASSES", ".", "box", ")", ",", "CLASSES", ".", "wrap", ")", ",", "CLASSES", ".", "frame", ")", ",", "CLASSES", ".", "holder", ")", "}" ]
Wrap the picker holder components together.
[ "Wrap", "the", "picker", "holder", "components", "together", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L73992-L74024
train
duniter/duniter-ui
public/libraries.js
prepareElement
function prepareElement() { $ELEMENT. // Store the picker data by component name. data(NAME, P). // Add the “input” class name. addClass(CLASSES.input). // Remove the tabindex. attr('tabindex', -1). // If there’s a `data-value`, update the value of the element. val( $ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value ) // Only bind keydown events if the element isn’t editable. if ( !SETTINGS.editable ) { $ELEMENT. // On focus/click, focus onto the root to open it up. on( 'focus.' + STATE.id + ' click.' + STATE.id, function( event ) { event.preventDefault() P.$root[0].focus() }). // Handle keyboard event based on the picker being opened or not. on( 'keydown.' + STATE.id, handleKeydownEvent ) } // Update the aria attributes. aria(ELEMENT, { haspopup: true, expanded: false, readonly: false, owns: ELEMENT.id + '_root' }) }
javascript
function prepareElement() { $ELEMENT. // Store the picker data by component name. data(NAME, P). // Add the “input” class name. addClass(CLASSES.input). // Remove the tabindex. attr('tabindex', -1). // If there’s a `data-value`, update the value of the element. val( $ELEMENT.data('value') ? P.get('select', SETTINGS.format) : ELEMENT.value ) // Only bind keydown events if the element isn’t editable. if ( !SETTINGS.editable ) { $ELEMENT. // On focus/click, focus onto the root to open it up. on( 'focus.' + STATE.id + ' click.' + STATE.id, function( event ) { event.preventDefault() P.$root[0].focus() }). // Handle keyboard event based on the picker being opened or not. on( 'keydown.' + STATE.id, handleKeydownEvent ) } // Update the aria attributes. aria(ELEMENT, { haspopup: true, expanded: false, readonly: false, owns: ELEMENT.id + '_root' }) }
[ "function", "prepareElement", "(", ")", "{", "$ELEMENT", ".", "data", "(", "NAME", ",", "P", ")", ".", "addClass", "(", "CLASSES", ".", "input", ")", ".", "attr", "(", "'tabindex'", ",", "-", "1", ")", ".", "val", "(", "$ELEMENT", ".", "data", "(", "'value'", ")", "?", "P", ".", "get", "(", "'select'", ",", "SETTINGS", ".", "format", ")", ":", "ELEMENT", ".", "value", ")", "if", "(", "!", "SETTINGS", ".", "editable", ")", "{", "$ELEMENT", ".", "on", "(", "'focus.'", "+", "STATE", ".", "id", "+", "' click.'", "+", "STATE", ".", "id", ",", "function", "(", "event", ")", "{", "event", ".", "preventDefault", "(", ")", "P", ".", "$root", "[", "0", "]", ".", "focus", "(", ")", "}", ")", ".", "on", "(", "'keydown.'", "+", "STATE", ".", "id", ",", "handleKeydownEvent", ")", "}", "aria", "(", "ELEMENT", ",", "{", "haspopup", ":", "true", ",", "expanded", ":", "false", ",", "readonly", ":", "false", ",", "owns", ":", "ELEMENT", ".", "id", "+", "'_root'", "}", ")", "}" ]
createWrappedComponent Prepare the input element with all bindings.
[ "createWrappedComponent", "Prepare", "the", "input", "element", "with", "all", "bindings", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74031-L74074
train
duniter/duniter-ui
public/libraries.js
prepareElementRoot
function prepareElementRoot() { P.$root. on({ // For iOS8. keydown: handleKeydownEvent, // When something within the root is focused, stop from bubbling // to the doc and remove the “focused” state from the root. focusin: function( event ) { P.$root.removeClass( CLASSES.focused ) event.stopPropagation() }, // When something within the root holder is clicked, stop it // from bubbling to the doc. 'mousedown click': function( event ) { var target = event.target // Make sure the target isn’t the root holder so it can bubble up. if ( target != P.$root.children()[ 0 ] ) { event.stopPropagation() // * For mousedown events, cancel the default action in order to // prevent cases where focus is shifted onto external elements // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). // Also, for Firefox, don’t prevent action on the `option` element. if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) { event.preventDefault() // Re-focus onto the root so that users can click away // from elements focused within the picker. P.$root[0].focus() } } } }). // Add/remove the “target” class on focus and blur. on({ focus: function() { $ELEMENT.addClass( CLASSES.target ) }, blur: function() { $ELEMENT.removeClass( CLASSES.target ) } }). // Open the picker and adjust the root “focused” state on( 'focus.toOpen', handleFocusToOpenEvent ). // If there’s a click on an actionable element, carry out the actions. on( 'click', '[data-pick], [data-nav], [data-clear], [data-close]', function() { var $target = $( this ), targetData = $target.data(), targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ), // * For IE, non-focusable elements can be active elements as well // (http://stackoverflow.com/a/2684561). activeElement = getActiveElement() activeElement = activeElement && ( activeElement.type || activeElement.href ) // If it’s disabled or nothing inside is actively focused, re-focus the element. if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) { P.$root[0].focus() } // If something is superficially changed, update the `highlight` based on the `nav`. if ( !targetDisabled && targetData.nav ) { P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } ) } // If something is picked, set `select` then close with focus. else if ( !targetDisabled && 'pick' in targetData ) { P.set( 'select', targetData.pick ) } // If a “clear” button is pressed, empty the values and close with focus. else if ( targetData.clear ) { P.clear().close( true ) } else if ( targetData.close ) { P.close( true ) } }) //P.$root aria( P.$root[0], 'hidden', true ) }
javascript
function prepareElementRoot() { P.$root. on({ // For iOS8. keydown: handleKeydownEvent, // When something within the root is focused, stop from bubbling // to the doc and remove the “focused” state from the root. focusin: function( event ) { P.$root.removeClass( CLASSES.focused ) event.stopPropagation() }, // When something within the root holder is clicked, stop it // from bubbling to the doc. 'mousedown click': function( event ) { var target = event.target // Make sure the target isn’t the root holder so it can bubble up. if ( target != P.$root.children()[ 0 ] ) { event.stopPropagation() // * For mousedown events, cancel the default action in order to // prevent cases where focus is shifted onto external elements // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). // Also, for Firefox, don’t prevent action on the `option` element. if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) { event.preventDefault() // Re-focus onto the root so that users can click away // from elements focused within the picker. P.$root[0].focus() } } } }). // Add/remove the “target” class on focus and blur. on({ focus: function() { $ELEMENT.addClass( CLASSES.target ) }, blur: function() { $ELEMENT.removeClass( CLASSES.target ) } }). // Open the picker and adjust the root “focused” state on( 'focus.toOpen', handleFocusToOpenEvent ). // If there’s a click on an actionable element, carry out the actions. on( 'click', '[data-pick], [data-nav], [data-clear], [data-close]', function() { var $target = $( this ), targetData = $target.data(), targetDisabled = $target.hasClass( CLASSES.navDisabled ) || $target.hasClass( CLASSES.disabled ), // * For IE, non-focusable elements can be active elements as well // (http://stackoverflow.com/a/2684561). activeElement = getActiveElement() activeElement = activeElement && ( activeElement.type || activeElement.href ) // If it’s disabled or nothing inside is actively focused, re-focus the element. if ( targetDisabled || activeElement && !$.contains( P.$root[0], activeElement ) ) { P.$root[0].focus() } // If something is superficially changed, update the `highlight` based on the `nav`. if ( !targetDisabled && targetData.nav ) { P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } ) } // If something is picked, set `select` then close with focus. else if ( !targetDisabled && 'pick' in targetData ) { P.set( 'select', targetData.pick ) } // If a “clear” button is pressed, empty the values and close with focus. else if ( targetData.clear ) { P.clear().close( true ) } else if ( targetData.close ) { P.close( true ) } }) //P.$root aria( P.$root[0], 'hidden', true ) }
[ "function", "prepareElementRoot", "(", ")", "{", "P", ".", "$root", ".", "on", "(", "{", "keydown", ":", "handleKeydownEvent", ",", "focusin", ":", "function", "(", "event", ")", "{", "P", ".", "$root", ".", "removeClass", "(", "CLASSES", ".", "focused", ")", "event", ".", "stopPropagation", "(", ")", "}", ",", "'mousedown click'", ":", "function", "(", "event", ")", "{", "var", "target", "=", "event", ".", "target", "if", "(", "target", "!=", "P", ".", "$root", ".", "children", "(", ")", "[", "0", "]", ")", "{", "event", ".", "stopPropagation", "(", ")", "if", "(", "event", ".", "type", "==", "'mousedown'", "&&", "!", "$", "(", "target", ")", ".", "is", "(", "'input, select, textarea, button, option'", ")", ")", "{", "event", ".", "preventDefault", "(", ")", "P", ".", "$root", "[", "0", "]", ".", "focus", "(", ")", "}", "}", "}", "}", ")", ".", "on", "(", "{", "focus", ":", "function", "(", ")", "{", "$ELEMENT", ".", "addClass", "(", "CLASSES", ".", "target", ")", "}", ",", "blur", ":", "function", "(", ")", "{", "$ELEMENT", ".", "removeClass", "(", "CLASSES", ".", "target", ")", "}", "}", ")", ".", "on", "(", "'focus.toOpen'", ",", "handleFocusToOpenEvent", ")", ".", "on", "(", "'click'", ",", "'[data-pick], [data-nav], [data-clear], [data-close]'", ",", "function", "(", ")", "{", "var", "$target", "=", "$", "(", "this", ")", ",", "targetData", "=", "$target", ".", "data", "(", ")", ",", "targetDisabled", "=", "$target", ".", "hasClass", "(", "CLASSES", ".", "navDisabled", ")", "||", "$target", ".", "hasClass", "(", "CLASSES", ".", "disabled", ")", ",", "activeElement", "=", "getActiveElement", "(", ")", "activeElement", "=", "activeElement", "&&", "(", "activeElement", ".", "type", "||", "activeElement", ".", "href", ")", "if", "(", "targetDisabled", "||", "activeElement", "&&", "!", "$", ".", "contains", "(", "P", ".", "$root", "[", "0", "]", ",", "activeElement", ")", ")", "{", "P", ".", "$root", "[", "0", "]", ".", "focus", "(", ")", "}", "if", "(", "!", "targetDisabled", "&&", "targetData", ".", "nav", ")", "{", "P", ".", "set", "(", "'highlight'", ",", "P", ".", "component", ".", "item", ".", "highlight", ",", "{", "nav", ":", "targetData", ".", "nav", "}", ")", "}", "else", "if", "(", "!", "targetDisabled", "&&", "'pick'", "in", "targetData", ")", "{", "P", ".", "set", "(", "'select'", ",", "targetData", ".", "pick", ")", "}", "else", "if", "(", "targetData", ".", "clear", ")", "{", "P", ".", "clear", "(", ")", ".", "close", "(", "true", ")", "}", "else", "if", "(", "targetData", ".", "close", ")", "{", "P", ".", "close", "(", "true", ")", "}", "}", ")", "aria", "(", "P", ".", "$root", "[", "0", "]", ",", "'hidden'", ",", "true", ")", "}" ]
Prepare the root picker element with all bindings.
[ "Prepare", "the", "root", "picker", "element", "with", "all", "bindings", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74080-L74175
train
duniter/duniter-ui
public/libraries.js
function( event ) { var target = event.target // Make sure the target isn’t the root holder so it can bubble up. if ( target != P.$root.children()[ 0 ] ) { event.stopPropagation() // * For mousedown events, cancel the default action in order to // prevent cases where focus is shifted onto external elements // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). // Also, for Firefox, don’t prevent action on the `option` element. if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) { event.preventDefault() // Re-focus onto the root so that users can click away // from elements focused within the picker. P.$root[0].focus() } } }
javascript
function( event ) { var target = event.target // Make sure the target isn’t the root holder so it can bubble up. if ( target != P.$root.children()[ 0 ] ) { event.stopPropagation() // * For mousedown events, cancel the default action in order to // prevent cases where focus is shifted onto external elements // when using things like jQuery mobile or MagnificPopup (ref: #249 & #120). // Also, for Firefox, don’t prevent action on the `option` element. if ( event.type == 'mousedown' && !$( target ).is( 'input, select, textarea, button, option' )) { event.preventDefault() // Re-focus onto the root so that users can click away // from elements focused within the picker. P.$root[0].focus() } } }
[ "function", "(", "event", ")", "{", "var", "target", "=", "event", ".", "target", "if", "(", "target", "!=", "P", ".", "$root", ".", "children", "(", ")", "[", "0", "]", ")", "{", "event", ".", "stopPropagation", "(", ")", "if", "(", "event", ".", "type", "==", "'mousedown'", "&&", "!", "$", "(", "target", ")", ".", "is", "(", "'input, select, textarea, button, option'", ")", ")", "{", "event", ".", "preventDefault", "(", ")", "P", ".", "$root", "[", "0", "]", ".", "focus", "(", ")", "}", "}", "}" ]
When something within the root holder is clicked, stop it from bubbling to the doc.
[ "When", "something", "within", "the", "root", "holder", "is", "clicked", "stop", "it", "from", "bubbling", "to", "the", "doc", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74098-L74120
train
duniter/duniter-ui
public/libraries.js
prepareElementHidden
function prepareElementHidden() { var name if ( SETTINGS.hiddenName === true ) { name = ELEMENT.name ELEMENT.name = '' } else { name = [ typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit' ] name = name[0] + ELEMENT.name + name[1] } P._hidden = $( '<input ' + 'type=hidden ' + // Create the name using the original input’s with a prefix and suffix. 'name="' + name + '"' + // If the element has a value, set the hidden value as well. ( $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '' ) + '>' )[0] $ELEMENT. // If the value changes, update the hidden input with the correct format. on('change.' + STATE.id, function() { P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : '' }) // Insert the hidden input as specified in the settings. if ( SETTINGS.container ) $( SETTINGS.container ).append( P._hidden ) else $ELEMENT.after( P._hidden ) }
javascript
function prepareElementHidden() { var name if ( SETTINGS.hiddenName === true ) { name = ELEMENT.name ELEMENT.name = '' } else { name = [ typeof SETTINGS.hiddenPrefix == 'string' ? SETTINGS.hiddenPrefix : '', typeof SETTINGS.hiddenSuffix == 'string' ? SETTINGS.hiddenSuffix : '_submit' ] name = name[0] + ELEMENT.name + name[1] } P._hidden = $( '<input ' + 'type=hidden ' + // Create the name using the original input’s with a prefix and suffix. 'name="' + name + '"' + // If the element has a value, set the hidden value as well. ( $ELEMENT.data('value') || ELEMENT.value ? ' value="' + P.get('select', SETTINGS.formatSubmit) + '"' : '' ) + '>' )[0] $ELEMENT. // If the value changes, update the hidden input with the correct format. on('change.' + STATE.id, function() { P._hidden.value = ELEMENT.value ? P.get('select', SETTINGS.formatSubmit) : '' }) // Insert the hidden input as specified in the settings. if ( SETTINGS.container ) $( SETTINGS.container ).append( P._hidden ) else $ELEMENT.after( P._hidden ) }
[ "function", "prepareElementHidden", "(", ")", "{", "var", "name", "if", "(", "SETTINGS", ".", "hiddenName", "===", "true", ")", "{", "name", "=", "ELEMENT", ".", "name", "ELEMENT", ".", "name", "=", "''", "}", "else", "{", "name", "=", "[", "typeof", "SETTINGS", ".", "hiddenPrefix", "==", "'string'", "?", "SETTINGS", ".", "hiddenPrefix", ":", "''", ",", "typeof", "SETTINGS", ".", "hiddenSuffix", "==", "'string'", "?", "SETTINGS", ".", "hiddenSuffix", ":", "'_submit'", "]", "name", "=", "name", "[", "0", "]", "+", "ELEMENT", ".", "name", "+", "name", "[", "1", "]", "}", "P", ".", "_hidden", "=", "$", "(", "'<input '", "+", "'type=hidden '", "+", "'name=\"'", "+", "name", "+", "'\"'", "+", "(", "$ELEMENT", ".", "data", "(", "'value'", ")", "||", "ELEMENT", ".", "value", "?", "' value=\"'", "+", "P", ".", "get", "(", "'select'", ",", "SETTINGS", ".", "formatSubmit", ")", "+", "'\"'", ":", "''", ")", "+", "'>'", ")", "[", "0", "]", "$ELEMENT", ".", "on", "(", "'change.'", "+", "STATE", ".", "id", ",", "function", "(", ")", "{", "P", ".", "_hidden", ".", "value", "=", "ELEMENT", ".", "value", "?", "P", ".", "get", "(", "'select'", ",", "SETTINGS", ".", "formatSubmit", ")", ":", "''", "}", ")", "if", "(", "SETTINGS", ".", "container", ")", "$", "(", "SETTINGS", ".", "container", ")", ".", "append", "(", "P", ".", "_hidden", ")", "else", "$ELEMENT", ".", "after", "(", "P", ".", "_hidden", ")", "}" ]
Prepare the hidden input element along with all bindings.
[ "Prepare", "the", "hidden", "input", "element", "along", "with", "all", "bindings", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74181-L74226
train
duniter/duniter-ui
public/libraries.js
handleKeydownEvent
function handleKeydownEvent( event ) { var keycode = event.keyCode, // Check if one of the delete keys was pressed. isKeycodeDelete = /^(8|46)$/.test(keycode) // For some reason IE clears the input value on “escape”. if ( keycode == 27 ) { P.close() return false } // Check if `space` or `delete` was pressed or the picker is closed with a key movement. if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) { // Prevent it from moving the page and bubbling to doc. event.preventDefault() event.stopPropagation() // If `delete` was pressed, clear the values and close the picker. // Otherwise open the picker. if ( isKeycodeDelete ) { P.clear().close() } else { P.open() } } }
javascript
function handleKeydownEvent( event ) { var keycode = event.keyCode, // Check if one of the delete keys was pressed. isKeycodeDelete = /^(8|46)$/.test(keycode) // For some reason IE clears the input value on “escape”. if ( keycode == 27 ) { P.close() return false } // Check if `space` or `delete` was pressed or the picker is closed with a key movement. if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[keycode] ) { // Prevent it from moving the page and bubbling to doc. event.preventDefault() event.stopPropagation() // If `delete` was pressed, clear the values and close the picker. // Otherwise open the picker. if ( isKeycodeDelete ) { P.clear().close() } else { P.open() } } }
[ "function", "handleKeydownEvent", "(", "event", ")", "{", "var", "keycode", "=", "event", ".", "keyCode", ",", "isKeycodeDelete", "=", "/", "^(8|46)$", "/", ".", "test", "(", "keycode", ")", "if", "(", "keycode", "==", "27", ")", "{", "P", ".", "close", "(", ")", "return", "false", "}", "if", "(", "keycode", "==", "32", "||", "isKeycodeDelete", "||", "!", "STATE", ".", "open", "&&", "P", ".", "component", ".", "key", "[", "keycode", "]", ")", "{", "event", ".", "preventDefault", "(", ")", "event", ".", "stopPropagation", "(", ")", "if", "(", "isKeycodeDelete", ")", "{", "P", ".", "clear", "(", ")", ".", "close", "(", ")", "}", "else", "{", "P", ".", "open", "(", ")", "}", "}", "}" ]
For iOS8.
[ "For", "iOS8", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74230-L74255
train
duniter/duniter-ui
public/libraries.js
handleFocusToOpenEvent
function handleFocusToOpenEvent( event ) { // Stop the event from propagating to the doc. event.stopPropagation() // If it’s a focus event, add the “focused” class to the root. if ( event.type == 'focus' ) { P.$root.addClass( CLASSES.focused ) } // And then finally open the picker. P.open() }
javascript
function handleFocusToOpenEvent( event ) { // Stop the event from propagating to the doc. event.stopPropagation() // If it’s a focus event, add the “focused” class to the root. if ( event.type == 'focus' ) { P.$root.addClass( CLASSES.focused ) } // And then finally open the picker. P.open() }
[ "function", "handleFocusToOpenEvent", "(", "event", ")", "{", "event", ".", "stopPropagation", "(", ")", "if", "(", "event", ".", "type", "==", "'focus'", ")", "{", "P", ".", "$root", ".", "addClass", "(", "CLASSES", ".", "focused", ")", "}", "P", ".", "open", "(", ")", "}" ]
Separated for IE
[ "Separated", "for", "IE" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74259-L74271
train
duniter/duniter-ui
public/libraries.js
isUsingDefaultTheme
function isUsingDefaultTheme( element ) { var theme, prop = 'position' // For IE. if ( element.currentStyle ) { theme = element.currentStyle[prop] } // For normal browsers. else if ( window.getComputedStyle ) { theme = getComputedStyle( element )[prop] } return theme == 'fixed' }
javascript
function isUsingDefaultTheme( element ) { var theme, prop = 'position' // For IE. if ( element.currentStyle ) { theme = element.currentStyle[prop] } // For normal browsers. else if ( window.getComputedStyle ) { theme = getComputedStyle( element )[prop] } return theme == 'fixed' }
[ "function", "isUsingDefaultTheme", "(", "element", ")", "{", "var", "theme", ",", "prop", "=", "'position'", "if", "(", "element", ".", "currentStyle", ")", "{", "theme", "=", "element", ".", "currentStyle", "[", "prop", "]", "}", "else", "if", "(", "window", ".", "getComputedStyle", ")", "{", "theme", "=", "getComputedStyle", "(", "element", ")", "[", "prop", "]", "}", "return", "theme", "==", "'fixed'", "}" ]
Check if the default theme is being used.
[ "Check", "if", "the", "default", "theme", "is", "being", "used", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74309-L74325
train
duniter/duniter-ui
public/libraries.js
function( wrapper, item, klass, attribute ) { // If the item is false-y, just return an empty string if ( !item ) return '' // If the item is an array, do a join item = $.isArray( item ) ? item.join( '' ) : item // Check for the class klass = klass ? ' class="' + klass + '"' : '' // Check for any attributes attribute = attribute ? ' ' + attribute : '' // Return the wrapped item return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>' }
javascript
function( wrapper, item, klass, attribute ) { // If the item is false-y, just return an empty string if ( !item ) return '' // If the item is an array, do a join item = $.isArray( item ) ? item.join( '' ) : item // Check for the class klass = klass ? ' class="' + klass + '"' : '' // Check for any attributes attribute = attribute ? ' ' + attribute : '' // Return the wrapped item return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>' }
[ "function", "(", "wrapper", ",", "item", ",", "klass", ",", "attribute", ")", "{", "if", "(", "!", "item", ")", "return", "''", "item", "=", "$", ".", "isArray", "(", "item", ")", "?", "item", ".", "join", "(", "''", ")", ":", "item", "klass", "=", "klass", "?", "' class=\"'", "+", "klass", "+", "'\"'", ":", "''", "attribute", "=", "attribute", "?", "' '", "+", "attribute", ":", "''", "return", "'<'", "+", "wrapper", "+", "klass", "+", "attribute", "+", "'>'", "+", "item", "+", "'</'", "+", "wrapper", "+", "'>'", "}" ]
group Create a dom node string
[ "group", "Create", "a", "dom", "node", "string" ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L74416-L74432
train
duniter/duniter-ui
public/libraries.js
getWordLengthFromCollection
function getWordLengthFromCollection( string, collection, dateObject ) { // Grab the first word from the string. var word = string.match( /\w+/ )[ 0 ] // If there's no month index, add it to the date object if ( !dateObject.mm && !dateObject.m ) { dateObject.m = collection.indexOf( word ) + 1 } // Return the length of the word. return word.length }
javascript
function getWordLengthFromCollection( string, collection, dateObject ) { // Grab the first word from the string. var word = string.match( /\w+/ )[ 0 ] // If there's no month index, add it to the date object if ( !dateObject.mm && !dateObject.m ) { dateObject.m = collection.indexOf( word ) + 1 } // Return the length of the word. return word.length }
[ "function", "getWordLengthFromCollection", "(", "string", ",", "collection", ",", "dateObject", ")", "{", "var", "word", "=", "string", ".", "match", "(", "/", "\\w+", "/", ")", "[", "0", "]", "if", "(", "!", "dateObject", ".", "mm", "&&", "!", "dateObject", ".", "m", ")", "{", "dateObject", ".", "m", "=", "collection", ".", "indexOf", "(", "word", ")", "+", "1", "}", "return", "word", ".", "length", "}" ]
Return the length of the first word in a collection.
[ "Return", "the", "length", "of", "the", "first", "word", "in", "a", "collection", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L75209-L75221
train
duniter/duniter-ui
public/libraries.js
function ( formatString, itemObject ) { var calendar = this return calendar.formats.toArray( formatString ).map( function( label ) { return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' ) }).join( '' ) }
javascript
function ( formatString, itemObject ) { var calendar = this return calendar.formats.toArray( formatString ).map( function( label ) { return _.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' ) }).join( '' ) }
[ "function", "(", "formatString", ",", "itemObject", ")", "{", "var", "calendar", "=", "this", "return", "calendar", ".", "formats", ".", "toArray", "(", "formatString", ")", ".", "map", "(", "function", "(", "label", ")", "{", "return", "_", ".", "trigger", "(", "calendar", ".", "formats", "[", "label", "]", ",", "calendar", ",", "[", "0", ",", "itemObject", "]", ")", "||", "label", ".", "replace", "(", "/", "^!", "/", ",", "''", ")", "}", ")", ".", "join", "(", "''", ")", "}" ]
Format an object into a string using the formatting options.
[ "Format", "an", "object", "into", "a", "string", "using", "the", "formatting", "options", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/public/libraries.js#L75299-L75304
train
weepower/wee-core
scripts/routes/route-map.js
_addRouteRecord
function _addRouteRecord(route, parent, exclude = false, ancestors = []) { const { path, name, handler } = route; const finalPath = _normalizePath(path, parent, ancestors); // Push path into ancestors array ancestors.push(path); const record = { name, parent, handler, path: finalPath, regex: PathToRegexp(finalPath), // redirect, TODO: Look into redirect functionality further before: route.before, init: route.init, update: route.update, after: route.after, unload: route.unload, pop: route.pop, meta: route.meta || {}, }; // Children should be mapped before parent in case of wildcard in parent if (route.children && route.children.length) { let i = 0; const length = route.children.length; for (; i < length; i++) { _addRouteRecord(route.children[i], route, exclude, ancestors); // After record is added, pop last ancestor off for the next set of paths ancestors.pop(); } } // Exclude from main mapping/return created route record object if (exclude) { return record; } if (! pathMap[record.path]) { pathList.push(record.path); pathMap[record.path] = record; } if (name && ! nameMap[name]) { nameMap[name] = record; } }
javascript
function _addRouteRecord(route, parent, exclude = false, ancestors = []) { const { path, name, handler } = route; const finalPath = _normalizePath(path, parent, ancestors); // Push path into ancestors array ancestors.push(path); const record = { name, parent, handler, path: finalPath, regex: PathToRegexp(finalPath), // redirect, TODO: Look into redirect functionality further before: route.before, init: route.init, update: route.update, after: route.after, unload: route.unload, pop: route.pop, meta: route.meta || {}, }; // Children should be mapped before parent in case of wildcard in parent if (route.children && route.children.length) { let i = 0; const length = route.children.length; for (; i < length; i++) { _addRouteRecord(route.children[i], route, exclude, ancestors); // After record is added, pop last ancestor off for the next set of paths ancestors.pop(); } } // Exclude from main mapping/return created route record object if (exclude) { return record; } if (! pathMap[record.path]) { pathList.push(record.path); pathMap[record.path] = record; } if (name && ! nameMap[name]) { nameMap[name] = record; } }
[ "function", "_addRouteRecord", "(", "route", ",", "parent", ",", "exclude", "=", "false", ",", "ancestors", "=", "[", "]", ")", "{", "const", "{", "path", ",", "name", ",", "handler", "}", "=", "route", ";", "const", "finalPath", "=", "_normalizePath", "(", "path", ",", "parent", ",", "ancestors", ")", ";", "ancestors", ".", "push", "(", "path", ")", ";", "const", "record", "=", "{", "name", ",", "parent", ",", "handler", ",", "path", ":", "finalPath", ",", "regex", ":", "PathToRegexp", "(", "finalPath", ")", ",", "before", ":", "route", ".", "before", ",", "init", ":", "route", ".", "init", ",", "update", ":", "route", ".", "update", ",", "after", ":", "route", ".", "after", ",", "unload", ":", "route", ".", "unload", ",", "pop", ":", "route", ".", "pop", ",", "meta", ":", "route", ".", "meta", "||", "{", "}", ",", "}", ";", "if", "(", "route", ".", "children", "&&", "route", ".", "children", ".", "length", ")", "{", "let", "i", "=", "0", ";", "const", "length", "=", "route", ".", "children", ".", "length", ";", "for", "(", ";", "i", "<", "length", ";", "i", "++", ")", "{", "_addRouteRecord", "(", "route", ".", "children", "[", "i", "]", ",", "route", ",", "exclude", ",", "ancestors", ")", ";", "ancestors", ".", "pop", "(", ")", ";", "}", "}", "if", "(", "exclude", ")", "{", "return", "record", ";", "}", "if", "(", "!", "pathMap", "[", "record", ".", "path", "]", ")", "{", "pathList", ".", "push", "(", "record", ".", "path", ")", ";", "pathMap", "[", "record", ".", "path", "]", "=", "record", ";", "}", "if", "(", "name", "&&", "!", "nameMap", "[", "name", "]", ")", "{", "nameMap", "[", "name", "]", "=", "record", ";", "}", "}" ]
Register new route @param {Object} route @param {Object} [parent] @param {boolean} exclude @private
[ "Register", "new", "route" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/routes/route-map.js#L25-L74
train
weepower/wee-core
scripts/routes/route-map.js
_normalizePath
function _normalizePath(path, parent, ancestors) { if (path === '/') { return path; } path = path.replace(/\/$/, ''); // If path begins with / then assume it is independent route if (path[0] === '/') { return path; } // If no parent, and route doesn't start with /, then prepend / if (! parent) { return `/${path}`; } if (ancestors) { return _cleanPath(`${ancestors.join('/')}/${path}`); } return _cleanPath(`${parent.path}/${path}`); }
javascript
function _normalizePath(path, parent, ancestors) { if (path === '/') { return path; } path = path.replace(/\/$/, ''); // If path begins with / then assume it is independent route if (path[0] === '/') { return path; } // If no parent, and route doesn't start with /, then prepend / if (! parent) { return `/${path}`; } if (ancestors) { return _cleanPath(`${ancestors.join('/')}/${path}`); } return _cleanPath(`${parent.path}/${path}`); }
[ "function", "_normalizePath", "(", "path", ",", "parent", ",", "ancestors", ")", "{", "if", "(", "path", "===", "'/'", ")", "{", "return", "path", ";", "}", "path", "=", "path", ".", "replace", "(", "/", "\\/$", "/", ",", "''", ")", ";", "if", "(", "path", "[", "0", "]", "===", "'/'", ")", "{", "return", "path", ";", "}", "if", "(", "!", "parent", ")", "{", "return", "`", "${", "path", "}", "`", ";", "}", "if", "(", "ancestors", ")", "{", "return", "_cleanPath", "(", "`", "${", "ancestors", ".", "join", "(", "'/'", ")", "}", "${", "path", "}", "`", ")", ";", "}", "return", "_cleanPath", "(", "`", "${", "parent", ".", "path", "}", "${", "path", "}", "`", ")", ";", "}" ]
Find full path of route @param {string} path @param {Object} [parent] @returns {*} @private
[ "Find", "full", "path", "of", "route" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/routes/route-map.js#L84-L106
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_type.js
build_doc_map
function build_doc_map(docs) { var map = {}; _.each(docs, function(tag) { if (map[tag["tagname"]]) map[tag["tagname"]].push(tag); else map[tag["tagname"]] = new Array(tag); }); return map; }
javascript
function build_doc_map(docs) { var map = {}; _.each(docs, function(tag) { if (map[tag["tagname"]]) map[tag["tagname"]].push(tag); else map[tag["tagname"]] = new Array(tag); }); return map; }
[ "function", "build_doc_map", "(", "docs", ")", "{", "var", "map", "=", "{", "}", ";", "_", ".", "each", "(", "docs", ",", "function", "(", "tag", ")", "{", "if", "(", "map", "[", "tag", "[", "\"tagname\"", "]", "]", ")", "map", "[", "tag", "[", "\"tagname\"", "]", "]", ".", "push", "(", "tag", ")", ";", "else", "map", "[", "tag", "[", "\"tagname\"", "]", "]", "=", "new", "Array", "(", "tag", ")", ";", "}", ")", ";", "return", "map", ";", "}" ]
Build map of at-tags for quick lookup
[ "Build", "map", "of", "at", "-", "tags", "for", "quick", "lookup" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_type.js#L56-L65
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
isIso8601DateTimeString
function isIso8601DateTimeString(value) { var regex = /^(([+-]\d{6}|\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?)(T((([01]\d|2[0-3])(:[0-5]\d)(:[0-5]\d(\.\d{1,3})?)?)|(24:00(:00(\.0{1,3})?)?))(Z|([+-])([01]\d|2[0-3]):([0-5]\d))?)?$/; // Verify that it's in ISO 8601 format (via the regex) and that it represents a valid point in time (via Date.parse) return regex.test(value) && !isNaN(Date.parse(value)); }
javascript
function isIso8601DateTimeString(value) { var regex = /^(([+-]\d{6}|\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?)(T((([01]\d|2[0-3])(:[0-5]\d)(:[0-5]\d(\.\d{1,3})?)?)|(24:00(:00(\.0{1,3})?)?))(Z|([+-])([01]\d|2[0-3]):([0-5]\d))?)?$/; // Verify that it's in ISO 8601 format (via the regex) and that it represents a valid point in time (via Date.parse) return regex.test(value) && !isNaN(Date.parse(value)); }
[ "function", "isIso8601DateTimeString", "(", "value", ")", "{", "var", "regex", "=", "/", "^(([+-]\\d{6}|\\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\\d|3[01]))?)?)(T((([01]\\d|2[0-3])(:[0-5]\\d)(:[0-5]\\d(\\.\\d{1,3})?)?)|(24:00(:00(\\.0{1,3})?)?))(Z|([+-])([01]\\d|2[0-3]):([0-5]\\d))?)?$", "/", ";", "return", "regex", ".", "test", "(", "value", ")", "&&", "!", "isNaN", "(", "Date", ".", "parse", "(", "value", ")", ")", ";", "}" ]
Check that a given value is a valid ISO 8601 format date string with optional time and time zone components
[ "Check", "that", "a", "given", "value", "is", "a", "valid", "ISO", "8601", "format", "date", "string", "with", "optional", "time", "and", "time", "zone", "components" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L13-L18
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
isIso8601DateString
function isIso8601DateString(value) { var regex = /^([+-]\d{6}|\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?$/; // Verify that it's in ISO 8601 format (via the regex) and that it represents a valid day (via Date.parse) return regex.test(value) && !isNaN(Date.parse(value)); }
javascript
function isIso8601DateString(value) { var regex = /^([+-]\d{6}|\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?$/; // Verify that it's in ISO 8601 format (via the regex) and that it represents a valid day (via Date.parse) return regex.test(value) && !isNaN(Date.parse(value)); }
[ "function", "isIso8601DateString", "(", "value", ")", "{", "var", "regex", "=", "/", "^([+-]\\d{6}|\\d{4})(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\\d|3[01]))?)?$", "/", ";", "return", "regex", ".", "test", "(", "value", ")", "&&", "!", "isNaN", "(", "Date", ".", "parse", "(", "value", ")", ")", ";", "}" ]
Check that a given value is a valid ISO 8601 date string without time and time zone components
[ "Check", "that", "a", "given", "value", "is", "a", "valid", "ISO", "8601", "date", "string", "without", "time", "and", "time", "zone", "components" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L21-L26
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
extractIso8601TimePieces
function extractIso8601TimePieces(value) { var timePieces = /^(\d{2}):(\d{2})(?:\:(\d{2}))?(?:\.(\d{1,3}))?$/.exec(value); if (timePieces === null) { return null; } var hour = timePieces[1] ? parseInt(timePieces[1], 10) : 0; var minute = timePieces[2] ? parseInt(timePieces[2], 10) : 0; var second = timePieces[3] ? parseInt(timePieces[3], 10) : 0; // The millisecond component has a variable length; normalize the length by padding it with zeros var millisecond = timePieces[4] ? parseInt(utils.padRight(timePieces[4], 3, '0'), 10) : 0; return [ hour, minute, second, millisecond ]; }
javascript
function extractIso8601TimePieces(value) { var timePieces = /^(\d{2}):(\d{2})(?:\:(\d{2}))?(?:\.(\d{1,3}))?$/.exec(value); if (timePieces === null) { return null; } var hour = timePieces[1] ? parseInt(timePieces[1], 10) : 0; var minute = timePieces[2] ? parseInt(timePieces[2], 10) : 0; var second = timePieces[3] ? parseInt(timePieces[3], 10) : 0; // The millisecond component has a variable length; normalize the length by padding it with zeros var millisecond = timePieces[4] ? parseInt(utils.padRight(timePieces[4], 3, '0'), 10) : 0; return [ hour, minute, second, millisecond ]; }
[ "function", "extractIso8601TimePieces", "(", "value", ")", "{", "var", "timePieces", "=", "/", "^(\\d{2}):(\\d{2})(?:\\:(\\d{2}))?(?:\\.(\\d{1,3}))?$", "/", ".", "exec", "(", "value", ")", ";", "if", "(", "timePieces", "===", "null", ")", "{", "return", "null", ";", "}", "var", "hour", "=", "timePieces", "[", "1", "]", "?", "parseInt", "(", "timePieces", "[", "1", "]", ",", "10", ")", ":", "0", ";", "var", "minute", "=", "timePieces", "[", "2", "]", "?", "parseInt", "(", "timePieces", "[", "2", "]", ",", "10", ")", ":", "0", ";", "var", "second", "=", "timePieces", "[", "3", "]", "?", "parseInt", "(", "timePieces", "[", "3", "]", ",", "10", ")", ":", "0", ";", "var", "millisecond", "=", "timePieces", "[", "4", "]", "?", "parseInt", "(", "utils", ".", "padRight", "(", "timePieces", "[", "4", "]", ",", "3", ",", "'0'", ")", ",", "10", ")", ":", "0", ";", "return", "[", "hour", ",", "minute", ",", "second", ",", "millisecond", "]", ";", "}" ]
Converts an ISO 8601 time into an array of its component pieces
[ "Converts", "an", "ISO", "8601", "time", "into", "an", "array", "of", "its", "component", "pieces" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L43-L57
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
compareTimes
function compareTimes(a, b) { if (typeof a !== 'string' || typeof b !== 'string') { return NaN; } var aTimePieces = extractIso8601TimePieces(a); var bTimePieces = extractIso8601TimePieces(b); if (aTimePieces === null || bTimePieces === null) { return NaN; } for (var timePieceIndex = 0; timePieceIndex < aTimePieces.length; timePieceIndex++) { if (aTimePieces[timePieceIndex] < bTimePieces[timePieceIndex]) { return -1; } else if (aTimePieces[timePieceIndex] > bTimePieces[timePieceIndex]) { return 1; } } // If we got here, the two parameters represent the same time of day return 0; }
javascript
function compareTimes(a, b) { if (typeof a !== 'string' || typeof b !== 'string') { return NaN; } var aTimePieces = extractIso8601TimePieces(a); var bTimePieces = extractIso8601TimePieces(b); if (aTimePieces === null || bTimePieces === null) { return NaN; } for (var timePieceIndex = 0; timePieceIndex < aTimePieces.length; timePieceIndex++) { if (aTimePieces[timePieceIndex] < bTimePieces[timePieceIndex]) { return -1; } else if (aTimePieces[timePieceIndex] > bTimePieces[timePieceIndex]) { return 1; } } // If we got here, the two parameters represent the same time of day return 0; }
[ "function", "compareTimes", "(", "a", ",", "b", ")", "{", "if", "(", "typeof", "a", "!==", "'string'", "||", "typeof", "b", "!==", "'string'", ")", "{", "return", "NaN", ";", "}", "var", "aTimePieces", "=", "extractIso8601TimePieces", "(", "a", ")", ";", "var", "bTimePieces", "=", "extractIso8601TimePieces", "(", "b", ")", ";", "if", "(", "aTimePieces", "===", "null", "||", "bTimePieces", "===", "null", ")", "{", "return", "NaN", ";", "}", "for", "(", "var", "timePieceIndex", "=", "0", ";", "timePieceIndex", "<", "aTimePieces", ".", "length", ";", "timePieceIndex", "++", ")", "{", "if", "(", "aTimePieces", "[", "timePieceIndex", "]", "<", "bTimePieces", "[", "timePieceIndex", "]", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "aTimePieces", "[", "timePieceIndex", "]", ">", "bTimePieces", "[", "timePieceIndex", "]", ")", "{", "return", "1", ";", "}", "}", "return", "0", ";", "}" ]
Compares the given time strings. Returns a negative number if a is less than b, a positive number if a is greater than b, or zero if a and b are equal.
[ "Compares", "the", "given", "time", "strings", ".", "Returns", "a", "negative", "number", "if", "a", "is", "less", "than", "b", "a", "positive", "number", "if", "a", "is", "greater", "than", "b", "or", "zero", "if", "a", "and", "b", "are", "equal", "." ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L61-L83
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
convertToTimestamp
function convertToTimestamp(value) { if (value instanceof Date) { return value.getTime(); } else if (typeof value === 'number') { return Math.floor(value); } else if (typeof value === 'string') { return Date.parse(value); } else { return NaN; } }
javascript
function convertToTimestamp(value) { if (value instanceof Date) { return value.getTime(); } else if (typeof value === 'number') { return Math.floor(value); } else if (typeof value === 'string') { return Date.parse(value); } else { return NaN; } }
[ "function", "convertToTimestamp", "(", "value", ")", "{", "if", "(", "value", "instanceof", "Date", ")", "{", "return", "value", ".", "getTime", "(", ")", ";", "}", "else", "if", "(", "typeof", "value", "===", "'number'", ")", "{", "return", "Math", ".", "floor", "(", "value", ")", ";", "}", "else", "if", "(", "typeof", "value", "===", "'string'", ")", "{", "return", "Date", ".", "parse", "(", "value", ")", ";", "}", "else", "{", "return", "NaN", ";", "}", "}" ]
Converts the given date representation to a timestamp that represents the number of ms since the Unix epoch
[ "Converts", "the", "given", "date", "representation", "to", "a", "timestamp", "that", "represents", "the", "number", "of", "ms", "since", "the", "Unix", "epoch" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L86-L96
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
compareDates
function compareDates(a, b) { var aTimestamp = convertToTimestamp(a); var bTimestamp = convertToTimestamp(b); if (isNaN(aTimestamp) || isNaN(bTimestamp)) { return NaN; } else { return aTimestamp - bTimestamp; } }
javascript
function compareDates(a, b) { var aTimestamp = convertToTimestamp(a); var bTimestamp = convertToTimestamp(b); if (isNaN(aTimestamp) || isNaN(bTimestamp)) { return NaN; } else { return aTimestamp - bTimestamp; } }
[ "function", "compareDates", "(", "a", ",", "b", ")", "{", "var", "aTimestamp", "=", "convertToTimestamp", "(", "a", ")", ";", "var", "bTimestamp", "=", "convertToTimestamp", "(", "b", ")", ";", "if", "(", "isNaN", "(", "aTimestamp", ")", "||", "isNaN", "(", "bTimestamp", ")", ")", "{", "return", "NaN", ";", "}", "else", "{", "return", "aTimestamp", "-", "bTimestamp", ";", "}", "}" ]
Compares the given date representations. Returns a negative number if a is less than b, a positive number if a is greater than b, or zero if a and b are equal.
[ "Compares", "the", "given", "date", "representations", ".", "Returns", "a", "negative", "number", "if", "a", "is", "less", "than", "b", "a", "positive", "number", "if", "a", "is", "greater", "than", "b", "or", "zero", "if", "a", "and", "b", "are", "equal", "." ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L100-L109
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
normalizeIso8601TimeZone
function normalizeIso8601TimeZone(value) { if (value === 'Z') { return 0; } var regex = /^([+-])(\d\d):?(\d\d)$/; var matches = regex.exec(value); if (matches === null) { return NaN; } else { var multiplicationFactor = (matches[1] === '+') ? 1 : -1; var hour = parseInt(matches[2], 10); var minute = parseInt(matches[3], 10); return multiplicationFactor * ((hour * 60) + minute); } }
javascript
function normalizeIso8601TimeZone(value) { if (value === 'Z') { return 0; } var regex = /^([+-])(\d\d):?(\d\d)$/; var matches = regex.exec(value); if (matches === null) { return NaN; } else { var multiplicationFactor = (matches[1] === '+') ? 1 : -1; var hour = parseInt(matches[2], 10); var minute = parseInt(matches[3], 10); return multiplicationFactor * ((hour * 60) + minute); } }
[ "function", "normalizeIso8601TimeZone", "(", "value", ")", "{", "if", "(", "value", "===", "'Z'", ")", "{", "return", "0", ";", "}", "var", "regex", "=", "/", "^([+-])(\\d\\d):?(\\d\\d)$", "/", ";", "var", "matches", "=", "regex", ".", "exec", "(", "value", ")", ";", "if", "(", "matches", "===", "null", ")", "{", "return", "NaN", ";", "}", "else", "{", "var", "multiplicationFactor", "=", "(", "matches", "[", "1", "]", "===", "'+'", ")", "?", "1", ":", "-", "1", ";", "var", "hour", "=", "parseInt", "(", "matches", "[", "2", "]", ",", "10", ")", ";", "var", "minute", "=", "parseInt", "(", "matches", "[", "3", "]", ",", "10", ")", ";", "return", "multiplicationFactor", "*", "(", "(", "hour", "*", "60", ")", "+", "minute", ")", ";", "}", "}" ]
Converts an ISO 8601 time zone into the number of minutes offset from UTC
[ "Converts", "an", "ISO", "8601", "time", "zone", "into", "the", "number", "of", "minutes", "offset", "from", "UTC" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L112-L128
train
OldSneerJaw/couchster
templates/validation-function/time-module.js
compareTimeZones
function compareTimeZones(a, b) { if (typeof a !== 'string' || typeof b !== 'string') { return NaN; } return normalizeIso8601TimeZone(a) - normalizeIso8601TimeZone(b); }
javascript
function compareTimeZones(a, b) { if (typeof a !== 'string' || typeof b !== 'string') { return NaN; } return normalizeIso8601TimeZone(a) - normalizeIso8601TimeZone(b); }
[ "function", "compareTimeZones", "(", "a", ",", "b", ")", "{", "if", "(", "typeof", "a", "!==", "'string'", "||", "typeof", "b", "!==", "'string'", ")", "{", "return", "NaN", ";", "}", "return", "normalizeIso8601TimeZone", "(", "a", ")", "-", "normalizeIso8601TimeZone", "(", "b", ")", ";", "}" ]
Compares the given time zone representations. Returns a negative number if a is less than b, a positive number if a is greater than b, or zero if a and b are equal.
[ "Compares", "the", "given", "time", "zone", "representations", ".", "Returns", "a", "negative", "number", "if", "a", "is", "less", "than", "b", "a", "positive", "number", "if", "a", "is", "greater", "than", "b", "or", "zero", "if", "a", "and", "b", "are", "equal", "." ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/time-module.js#L132-L138
train
EduardoRFS/koa-Router
lib/layer.js
decode_param
function decode_param(val) { if (typeof val !== 'string' || val.length === 0) { return val; } try { return decodeURIComponent(val); } catch (err) { if (err instanceof URIError) { err.message = `Failed to decode param '${val}'`; err.status = err.statusCode = 400; } throw err; } }
javascript
function decode_param(val) { if (typeof val !== 'string' || val.length === 0) { return val; } try { return decodeURIComponent(val); } catch (err) { if (err instanceof URIError) { err.message = `Failed to decode param '${val}'`; err.status = err.statusCode = 400; } throw err; } }
[ "function", "decode_param", "(", "val", ")", "{", "if", "(", "typeof", "val", "!==", "'string'", "||", "val", ".", "length", "===", "0", ")", "{", "return", "val", ";", "}", "try", "{", "return", "decodeURIComponent", "(", "val", ")", ";", "}", "catch", "(", "err", ")", "{", "if", "(", "err", "instanceof", "URIError", ")", "{", "err", ".", "message", "=", "`", "${", "val", "}", "`", ";", "err", ".", "status", "=", "err", ".", "statusCode", "=", "400", ";", "}", "throw", "err", ";", "}", "}" ]
Decode param value. @param {string} val @return {string} @private
[ "Decode", "param", "value", "." ]
5e721821211b8139e83a10d868e2e6b083af5433
https://github.com/EduardoRFS/koa-Router/blob/5e721821211b8139e83a10d868e2e6b083af5433/lib/layer.js#L144-L159
train
postmanlabs/mime-format
index.js
function (mime) { var info = { type: UNKNOWN, format: RAW, guessed: true }, match, base; // extract the mime base base = (base = mime.split(SEP)) && base[0] || E; // bail out on the mime types that are sure-shot ones with no ambiguity match = base.match(AUDIO_VIDEO_IMAGE_TEXT); if (match && match[1]) { info.type = info.format = match[1]; // we do special kane matching to extract the format in case the match was text // this ensures that we get same formats like we will do in kane match later down the line if (info.type === TEXT) { match = mime.match(JSON_XML_SCRIPT_SIBLINGS); info.format = match && match[1] || PLAIN; } return info; } // we do a kane match on entire mime (not just base) to find texts match = mime.match(JSON_XML_SCRIPT_SIBLINGS); if (match && match[1]) { info.type = TEXT; info.format = match[1]; return info; } // now we match the subtype having names from the sure shot bases match = mime.match(AUDIO_VIDEO_IMAGE_TEXT_SUBTYPE); if (match && match[1]) { info.type = info.format = match[1]; return info; } // now that most text and sure-shot types and sub-types are out of our way, we detect standard bases // and rest are unknown match = base.match(APPLICATION_MESSAGE_MULTIPART); if (match && match[1]) { info.type = match[1]; info.format = RAW; return info; } // at this point nothing has matched nothing. it is worth keeping a note of it info.orphan = true; return info; }
javascript
function (mime) { var info = { type: UNKNOWN, format: RAW, guessed: true }, match, base; // extract the mime base base = (base = mime.split(SEP)) && base[0] || E; // bail out on the mime types that are sure-shot ones with no ambiguity match = base.match(AUDIO_VIDEO_IMAGE_TEXT); if (match && match[1]) { info.type = info.format = match[1]; // we do special kane matching to extract the format in case the match was text // this ensures that we get same formats like we will do in kane match later down the line if (info.type === TEXT) { match = mime.match(JSON_XML_SCRIPT_SIBLINGS); info.format = match && match[1] || PLAIN; } return info; } // we do a kane match on entire mime (not just base) to find texts match = mime.match(JSON_XML_SCRIPT_SIBLINGS); if (match && match[1]) { info.type = TEXT; info.format = match[1]; return info; } // now we match the subtype having names from the sure shot bases match = mime.match(AUDIO_VIDEO_IMAGE_TEXT_SUBTYPE); if (match && match[1]) { info.type = info.format = match[1]; return info; } // now that most text and sure-shot types and sub-types are out of our way, we detect standard bases // and rest are unknown match = base.match(APPLICATION_MESSAGE_MULTIPART); if (match && match[1]) { info.type = match[1]; info.format = RAW; return info; } // at this point nothing has matched nothing. it is worth keeping a note of it info.orphan = true; return info; }
[ "function", "(", "mime", ")", "{", "var", "info", "=", "{", "type", ":", "UNKNOWN", ",", "format", ":", "RAW", ",", "guessed", ":", "true", "}", ",", "match", ",", "base", ";", "base", "=", "(", "base", "=", "mime", ".", "split", "(", "SEP", ")", ")", "&&", "base", "[", "0", "]", "||", "E", ";", "match", "=", "base", ".", "match", "(", "AUDIO_VIDEO_IMAGE_TEXT", ")", ";", "if", "(", "match", "&&", "match", "[", "1", "]", ")", "{", "info", ".", "type", "=", "info", ".", "format", "=", "match", "[", "1", "]", ";", "if", "(", "info", ".", "type", "===", "TEXT", ")", "{", "match", "=", "mime", ".", "match", "(", "JSON_XML_SCRIPT_SIBLINGS", ")", ";", "info", ".", "format", "=", "match", "&&", "match", "[", "1", "]", "||", "PLAIN", ";", "}", "return", "info", ";", "}", "match", "=", "mime", ".", "match", "(", "JSON_XML_SCRIPT_SIBLINGS", ")", ";", "if", "(", "match", "&&", "match", "[", "1", "]", ")", "{", "info", ".", "type", "=", "TEXT", ";", "info", ".", "format", "=", "match", "[", "1", "]", ";", "return", "info", ";", "}", "match", "=", "mime", ".", "match", "(", "AUDIO_VIDEO_IMAGE_TEXT_SUBTYPE", ")", ";", "if", "(", "match", "&&", "match", "[", "1", "]", ")", "{", "info", ".", "type", "=", "info", ".", "format", "=", "match", "[", "1", "]", ";", "return", "info", ";", "}", "match", "=", "base", ".", "match", "(", "APPLICATION_MESSAGE_MULTIPART", ")", ";", "if", "(", "match", "&&", "match", "[", "1", "]", ")", "{", "info", ".", "type", "=", "match", "[", "1", "]", ";", "info", ".", "format", "=", "RAW", ";", "return", "info", ";", "}", "info", ".", "orphan", "=", "true", ";", "return", "info", ";", "}" ]
Attempts to guess the format by analysing mime type and not a db lookup @private @param {String} mime - contentType header value @returns {Object}
[ "Attempts", "to", "guess", "the", "format", "by", "analysing", "mime", "type", "and", "not", "a", "db", "lookup" ]
35635e3797bde3a09c2fff55daf22a81c9bd2587
https://github.com/postmanlabs/mime-format/blob/35635e3797bde3a09c2fff55daf22a81c9bd2587/index.js#L99-L153
train
travis-hilterbrand/grunt-file-creator
tasks/file-creator.js
function(o) { var a = []; _.each(o, function(value, key) { a.push({file:key,method:value}); }); return a; }
javascript
function(o) { var a = []; _.each(o, function(value, key) { a.push({file:key,method:value}); }); return a; }
[ "function", "(", "o", ")", "{", "var", "a", "=", "[", "]", ";", "_", ".", "each", "(", "o", ",", "function", "(", "value", ",", "key", ")", "{", "a", ".", "push", "(", "{", "file", ":", "key", ",", "method", ":", "value", "}", ")", ";", "}", ")", ";", "return", "a", ";", "}" ]
flattens to array
[ "flattens", "to", "array" ]
fbbea6589e0118972fb9b1f2ff2439469de982e1
https://github.com/travis-hilterbrand/grunt-file-creator/blob/fbbea6589e0118972fb9b1f2ff2439469de982e1/tasks/file-creator.js#L105-L111
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/jsd_parser.js
expand
function expand(docset, customTags) { docset["comment"] = DocParser.parse(docset["comment"], customTags); docset["tagname"] = DocType.detect(docset["comment"], docset["code"]); if (docset["tagname"] == "class") return DocExpander.expand(docset); else return docset; }
javascript
function expand(docset, customTags) { docset["comment"] = DocParser.parse(docset["comment"], customTags); docset["tagname"] = DocType.detect(docset["comment"], docset["code"]); if (docset["tagname"] == "class") return DocExpander.expand(docset); else return docset; }
[ "function", "expand", "(", "docset", ",", "customTags", ")", "{", "docset", "[", "\"comment\"", "]", "=", "DocParser", ".", "parse", "(", "docset", "[", "\"comment\"", "]", ",", "customTags", ")", ";", "docset", "[", "\"tagname\"", "]", "=", "DocType", ".", "detect", "(", "docset", "[", "\"comment\"", "]", ",", "docset", "[", "\"code\"", "]", ")", ";", "if", "(", "docset", "[", "\"tagname\"", "]", "==", "\"class\"", ")", "return", "DocExpander", ".", "expand", "(", "docset", ")", ";", "else", "return", "docset", ";", "}" ]
Parses the docs, detects tagname and expands class docset
[ "Parses", "the", "docs", "detects", "tagname", "and", "expands", "class", "docset" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/jsd_parser.js#L438-L446
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/jsd_parser.js
merge
function merge(docset, customTags) { doc_ast.linenr = docset["linenr"]; // useful for applying global NS items to the proper NS docset["original_name"] = docset["code"].name; docset["comment"] = doc_ast.detect(docset["tagname"], docset["comment"], customTags); return Merger.merge(docset); }
javascript
function merge(docset, customTags) { doc_ast.linenr = docset["linenr"]; // useful for applying global NS items to the proper NS docset["original_name"] = docset["code"].name; docset["comment"] = doc_ast.detect(docset["tagname"], docset["comment"], customTags); return Merger.merge(docset); }
[ "function", "merge", "(", "docset", ",", "customTags", ")", "{", "doc_ast", ".", "linenr", "=", "docset", "[", "\"linenr\"", "]", ";", "docset", "[", "\"original_name\"", "]", "=", "docset", "[", "\"code\"", "]", ".", "name", ";", "docset", "[", "\"comment\"", "]", "=", "doc_ast", ".", "detect", "(", "docset", "[", "\"tagname\"", "]", ",", "docset", "[", "\"comment\"", "]", ",", "customTags", ")", ";", "return", "Merger", ".", "merge", "(", "docset", ")", ";", "}" ]
Merges comment and code parts of docset
[ "Merges", "comment", "and", "code", "parts", "of", "docset" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/jsd_parser.js#L449-L457
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/jsd_parser.js
createBasicTranslation
function createBasicTranslation(memberName, type, i, options) { var node = {}; node["id"] = memberName; node["type"] = type; if (i["inheritdoc"] !== undefined) { node["inheritdoc"] = i["inheritdoc"].src; } else if (i["doc"] !== undefined) { node["description"] = i["doc"]; // short description lasts until the first empty line node["short_description"] = node["description"].replace(/\n\n[\s\S]*$/, '\n'); } else { node["undocumented"] = true; } node["line"] = i["linenr"]; if (i["private"] !== undefined) node["private"] = i["private"]; if (i["experimental"] !== undefined) node["experimental"] = i["experimental"]; if (i["ignore"] !== undefined) node["ignore"] = i["ignore"]; if (i["chainable"] !== undefined) node["chainable"] = i["chainable"]; if (i["see"] !== undefined) node["related_to"] = i["see"].name; if (i["author"] !== undefined && i["author"].length > 0) node["author"] = i["author"].doc; if (i["version"] !== undefined) node["version"] = i["version"].doc; if (i["since"] !== undefined) node["since"] = i["since"].doc; if (i["author"] !== undefined) node["author"] = i["author"]; if (i["related"] !== undefined) node["related"] = i["related"].name; if (options.customTags) { _.each(options.customTags, function(tag) { if (i[tag] !== undefined) node[tag] = i[tag]; }); } return node; }
javascript
function createBasicTranslation(memberName, type, i, options) { var node = {}; node["id"] = memberName; node["type"] = type; if (i["inheritdoc"] !== undefined) { node["inheritdoc"] = i["inheritdoc"].src; } else if (i["doc"] !== undefined) { node["description"] = i["doc"]; // short description lasts until the first empty line node["short_description"] = node["description"].replace(/\n\n[\s\S]*$/, '\n'); } else { node["undocumented"] = true; } node["line"] = i["linenr"]; if (i["private"] !== undefined) node["private"] = i["private"]; if (i["experimental"] !== undefined) node["experimental"] = i["experimental"]; if (i["ignore"] !== undefined) node["ignore"] = i["ignore"]; if (i["chainable"] !== undefined) node["chainable"] = i["chainable"]; if (i["see"] !== undefined) node["related_to"] = i["see"].name; if (i["author"] !== undefined && i["author"].length > 0) node["author"] = i["author"].doc; if (i["version"] !== undefined) node["version"] = i["version"].doc; if (i["since"] !== undefined) node["since"] = i["since"].doc; if (i["author"] !== undefined) node["author"] = i["author"]; if (i["related"] !== undefined) node["related"] = i["related"].name; if (options.customTags) { _.each(options.customTags, function(tag) { if (i[tag] !== undefined) node[tag] = i[tag]; }); } return node; }
[ "function", "createBasicTranslation", "(", "memberName", ",", "type", ",", "i", ",", "options", ")", "{", "var", "node", "=", "{", "}", ";", "node", "[", "\"id\"", "]", "=", "memberName", ";", "node", "[", "\"type\"", "]", "=", "type", ";", "if", "(", "i", "[", "\"inheritdoc\"", "]", "!==", "undefined", ")", "{", "node", "[", "\"inheritdoc\"", "]", "=", "i", "[", "\"inheritdoc\"", "]", ".", "src", ";", "}", "else", "if", "(", "i", "[", "\"doc\"", "]", "!==", "undefined", ")", "{", "node", "[", "\"description\"", "]", "=", "i", "[", "\"doc\"", "]", ";", "node", "[", "\"short_description\"", "]", "=", "node", "[", "\"description\"", "]", ".", "replace", "(", "/", "\\n\\n[\\s\\S]*$", "/", ",", "'\\n'", ")", ";", "}", "else", "\\n", "{", "node", "[", "\"undocumented\"", "]", "=", "true", ";", "}", "node", "[", "\"line\"", "]", "=", "i", "[", "\"linenr\"", "]", ";", "if", "(", "i", "[", "\"private\"", "]", "!==", "undefined", ")", "node", "[", "\"private\"", "]", "=", "i", "[", "\"private\"", "]", ";", "if", "(", "i", "[", "\"experimental\"", "]", "!==", "undefined", ")", "node", "[", "\"experimental\"", "]", "=", "i", "[", "\"experimental\"", "]", ";", "if", "(", "i", "[", "\"ignore\"", "]", "!==", "undefined", ")", "node", "[", "\"ignore\"", "]", "=", "i", "[", "\"ignore\"", "]", ";", "if", "(", "i", "[", "\"chainable\"", "]", "!==", "undefined", ")", "node", "[", "\"chainable\"", "]", "=", "i", "[", "\"chainable\"", "]", ";", "if", "(", "i", "[", "\"see\"", "]", "!==", "undefined", ")", "node", "[", "\"related_to\"", "]", "=", "i", "[", "\"see\"", "]", ".", "name", ";", "if", "(", "i", "[", "\"author\"", "]", "!==", "undefined", "&&", "i", "[", "\"author\"", "]", ".", "length", ">", "0", ")", "node", "[", "\"author\"", "]", "=", "i", "[", "\"author\"", "]", ".", "doc", ";", "if", "(", "i", "[", "\"version\"", "]", "!==", "undefined", ")", "node", "[", "\"version\"", "]", "=", "i", "[", "\"version\"", "]", ".", "doc", ";", "if", "(", "i", "[", "\"since\"", "]", "!==", "undefined", ")", "node", "[", "\"since\"", "]", "=", "i", "[", "\"since\"", "]", ".", "doc", ";", "if", "(", "i", "[", "\"author\"", "]", "!==", "undefined", ")", "node", "[", "\"author\"", "]", "=", "i", "[", "\"author\"", "]", ";", "if", "(", "i", "[", "\"related\"", "]", "!==", "undefined", ")", "node", "[", "\"related\"", "]", "=", "i", "[", "\"related\"", "]", ".", "name", ";", "if", "(", "options", ".", "customTags", ")", "{", "_", ".", "each", "(", "options", ".", "customTags", ",", "function", "(", "tag", ")", "{", "if", "(", "i", "[", "tag", "]", "!==", "undefined", ")", "node", "[", "tag", "]", "=", "i", "[", "tag", "]", ";", "}", ")", ";", "}", "}" ]
creates types for nodes that can be anything
[ "creates", "types", "for", "nodes", "that", "can", "be", "anything" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/jsd_parser.js#L460-L518
train
EduardoRFS/koa-Router
lib/route.js
Route
function Route(path) { this.path = path; this.stack = []; this.handle = compose(this.stack); debug('new %s', path); // route handlers for various http methods this.methods = {}; }
javascript
function Route(path) { this.path = path; this.stack = []; this.handle = compose(this.stack); debug('new %s', path); // route handlers for various http methods this.methods = {}; }
[ "function", "Route", "(", "path", ")", "{", "this", ".", "path", "=", "path", ";", "this", ".", "stack", "=", "[", "]", ";", "this", ".", "handle", "=", "compose", "(", "this", ".", "stack", ")", ";", "debug", "(", "'new %s'", ",", "path", ")", ";", "this", ".", "methods", "=", "{", "}", ";", "}" ]
Initialize `Route` with the given `path`, @param {String} path @public
[ "Initialize", "Route", "with", "the", "given", "path" ]
5e721821211b8139e83a10d868e2e6b083af5433
https://github.com/EduardoRFS/koa-Router/blob/5e721821211b8139e83a10d868e2e6b083af5433/lib/route.js#L42-L51
train
apostrophecms-legacy/apostrophe-schemas
public/js/editor.js
function(data, name, $field, $el, field, callback) { data[name] = self.getArea($el, name); if (field.required && (apos.areaIsEmpty(data[name]))) { return apos.afterYield(_.partial(callback, 'required')); } return apos.afterYield(callback); }
javascript
function(data, name, $field, $el, field, callback) { data[name] = self.getArea($el, name); if (field.required && (apos.areaIsEmpty(data[name]))) { return apos.afterYield(_.partial(callback, 'required')); } return apos.afterYield(callback); }
[ "function", "(", "data", ",", "name", ",", "$field", ",", "$el", ",", "field", ",", "callback", ")", "{", "data", "[", "name", "]", "=", "self", ".", "getArea", "(", "$el", ",", "name", ")", ";", "if", "(", "field", ".", "required", "&&", "(", "apos", ".", "areaIsEmpty", "(", "data", "[", "name", "]", ")", ")", ")", "{", "return", "apos", ".", "afterYield", "(", "_", ".", "partial", "(", "callback", ",", "'required'", ")", ")", ";", "}", "return", "apos", ".", "afterYield", "(", "callback", ")", ";", "}" ]
Convert the tough cases
[ "Convert", "the", "tough", "cases" ]
702e30657a38b31fa1005532f2aa487fd153aac7
https://github.com/apostrophecms-legacy/apostrophe-schemas/blob/702e30657a38b31fa1005532f2aa487fd153aac7/public/js/editor.js#L198-L205
train
apostrophecms-legacy/apostrophe-schemas
public/js/editor.js
function(data, name, $field, $el, field, callback) { data[name] = $field.val(); if (field.required && !data[name].length) { return apos.afterYield(_.partial(callback, 'required')); } if (field.max && (data[name].length > field.max)) { var $fieldset = self.findFieldset($el, name); $fieldset.addClass('apos-error-max'); return apos.afterYield(_.partial(callback, 'max')); } return apos.afterYield(callback); }
javascript
function(data, name, $field, $el, field, callback) { data[name] = $field.val(); if (field.required && !data[name].length) { return apos.afterYield(_.partial(callback, 'required')); } if (field.max && (data[name].length > field.max)) { var $fieldset = self.findFieldset($el, name); $fieldset.addClass('apos-error-max'); return apos.afterYield(_.partial(callback, 'max')); } return apos.afterYield(callback); }
[ "function", "(", "data", ",", "name", ",", "$field", ",", "$el", ",", "field", ",", "callback", ")", "{", "data", "[", "name", "]", "=", "$field", ".", "val", "(", ")", ";", "if", "(", "field", ".", "required", "&&", "!", "data", "[", "name", "]", ".", "length", ")", "{", "return", "apos", ".", "afterYield", "(", "_", ".", "partial", "(", "callback", ",", "'required'", ")", ")", ";", "}", "if", "(", "field", ".", "max", "&&", "(", "data", "[", "name", "]", ".", "length", ">", "field", ".", "max", ")", ")", "{", "var", "$fieldset", "=", "self", ".", "findFieldset", "(", "$el", ",", "name", ")", ";", "$fieldset", ".", "addClass", "(", "'apos-error-max'", ")", ";", "return", "apos", ".", "afterYield", "(", "_", ".", "partial", "(", "callback", ",", "'max'", ")", ")", ";", "}", "return", "apos", ".", "afterYield", "(", "callback", ")", ";", "}" ]
The rest are very simple because the server does the serious sanitization work and the representation in the DOM is a simple form element
[ "The", "rest", "are", "very", "simple", "because", "the", "server", "does", "the", "serious", "sanitization", "work", "and", "the", "representation", "in", "the", "DOM", "is", "a", "simple", "form", "element" ]
702e30657a38b31fa1005532f2aa487fd153aac7
https://github.com/apostrophecms-legacy/apostrophe-schemas/blob/702e30657a38b31fa1005532f2aa487fd153aac7/public/js/editor.js#L299-L310
train
weepower/wee-core
scripts/routes/pjax.js
_isValid
function _isValid(el, currentPath) { // Link has no destination URL if (! el.href) { return false; } // Link opens a new browser window if (el.target === '_blank') { return false; } // Link is not absolute URL if (! /https?:/.test(el.href)) { return false; } // Link is a download if (el.hasAttribute('download')) { return false; } // Link is supposed to be ignored if (el.hasAttribute('data-static')) { return false; } // Link is external URL if (el.host && el.host !== location.host) { return false; } // Link is current page, but with a hash added if (el.hash && el.pathname === currentPath) { return false; } return true; }
javascript
function _isValid(el, currentPath) { // Link has no destination URL if (! el.href) { return false; } // Link opens a new browser window if (el.target === '_blank') { return false; } // Link is not absolute URL if (! /https?:/.test(el.href)) { return false; } // Link is a download if (el.hasAttribute('download')) { return false; } // Link is supposed to be ignored if (el.hasAttribute('data-static')) { return false; } // Link is external URL if (el.host && el.host !== location.host) { return false; } // Link is current page, but with a hash added if (el.hash && el.pathname === currentPath) { return false; } return true; }
[ "function", "_isValid", "(", "el", ",", "currentPath", ")", "{", "if", "(", "!", "el", ".", "href", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "target", "===", "'_blank'", ")", "{", "return", "false", ";", "}", "if", "(", "!", "/", "https?:", "/", ".", "test", "(", "el", ".", "href", ")", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "hasAttribute", "(", "'download'", ")", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "hasAttribute", "(", "'data-static'", ")", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "host", "&&", "el", ".", "host", "!==", "location", ".", "host", ")", "{", "return", "false", ";", "}", "if", "(", "el", ".", "hash", "&&", "el", ".", "pathname", "===", "currentPath", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Determine if path is valid for history navigation @param {HTMLElement} el @param {string} [currentPath] @returns {boolean} @private
[ "Determine", "if", "path", "is", "valid", "for", "history", "navigation" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/routes/pjax.js#L48-L71
train
weepower/wee-core
scripts/routes/pjax.js
_path
function _path(loc) { loc = loc || location; return loc.pathname + loc.search + loc.hash; }
javascript
function _path(loc) { loc = loc || location; return loc.pathname + loc.search + loc.hash; }
[ "function", "_path", "(", "loc", ")", "{", "loc", "=", "loc", "||", "location", ";", "return", "loc", ".", "pathname", "+", "loc", ".", "search", "+", "loc", ".", "hash", ";", "}" ]
Return current path @private @param {object} [loc] @returns {string}
[ "Return", "current", "path" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/routes/pjax.js#L80-L83
train
ChrisWren/grunt-link-checker
tasks/link-checker.js
function (message) { if (options.force) { grunt.log.error(message); } else { grunt.warn(message); } }
javascript
function (message) { if (options.force) { grunt.log.error(message); } else { grunt.warn(message); } }
[ "function", "(", "message", ")", "{", "if", "(", "options", ".", "force", ")", "{", "grunt", ".", "log", ".", "error", "(", "message", ")", ";", "}", "else", "{", "grunt", ".", "warn", "(", "message", ")", ";", "}", "}" ]
Borrowed from grunt-contrib-qunit If options.force then log an error, otherwise exit with a warning
[ "Borrowed", "from", "grunt", "-", "contrib", "-", "qunit", "If", "options", ".", "force", "then", "log", "an", "error", "otherwise", "exit", "with", "a", "warning" ]
96a7826c73c946a1c54c7999f90d11628ffdb47f
https://github.com/ChrisWren/grunt-link-checker/blob/96a7826c73c946a1c54c7999f90d11628ffdb47f/tasks/link-checker.js#L26-L32
train
OldSneerJaw/couchster
templates/validation-function/template.js
simpleTypeFilter
function simpleTypeFilter(newDoc, oldDoc, candidateDocType) { if (oldDoc) { if (newDoc._deleted) { return oldDoc.type === candidateDocType; } else { return newDoc.type === oldDoc.type && oldDoc.type === candidateDocType; } } else { return newDoc.type === candidateDocType; } }
javascript
function simpleTypeFilter(newDoc, oldDoc, candidateDocType) { if (oldDoc) { if (newDoc._deleted) { return oldDoc.type === candidateDocType; } else { return newDoc.type === oldDoc.type && oldDoc.type === candidateDocType; } } else { return newDoc.type === candidateDocType; } }
[ "function", "simpleTypeFilter", "(", "newDoc", ",", "oldDoc", ",", "candidateDocType", ")", "{", "if", "(", "oldDoc", ")", "{", "if", "(", "newDoc", ".", "_deleted", ")", "{", "return", "oldDoc", ".", "type", "===", "candidateDocType", ";", "}", "else", "{", "return", "newDoc", ".", "type", "===", "oldDoc", ".", "type", "&&", "oldDoc", ".", "type", "===", "candidateDocType", ";", "}", "}", "else", "{", "return", "newDoc", ".", "type", "===", "candidateDocType", ";", "}", "}" ]
A type filter that matches on the document's type property
[ "A", "type", "filter", "that", "matches", "on", "the", "document", "s", "type", "property" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/templates/validation-function/template.js#L23-L33
train
2do2go/mongodbext
lib/collection/index.js
function(methodName, alternatives) { return function() { var callback = Array.prototype.slice.call(arguments).pop(); if (!Array.isArray(alternatives)) { alternatives = [alternatives]; } var alternativeString; if (alternatives.length === 1) { alternativeString = alternatives[0]; } else { var lastItem = alternatives.pop(); alternativeString = alternatives.join('", "') + '" or "' + lastItem; } callback(MongoError.create({ message: 'Method "' + methodName + '" is deprecated, use "' + alternativeString + '" instead', driver: true })); }; }
javascript
function(methodName, alternatives) { return function() { var callback = Array.prototype.slice.call(arguments).pop(); if (!Array.isArray(alternatives)) { alternatives = [alternatives]; } var alternativeString; if (alternatives.length === 1) { alternativeString = alternatives[0]; } else { var lastItem = alternatives.pop(); alternativeString = alternatives.join('", "') + '" or "' + lastItem; } callback(MongoError.create({ message: 'Method "' + methodName + '" is deprecated, use "' + alternativeString + '" instead', driver: true })); }; }
[ "function", "(", "methodName", ",", "alternatives", ")", "{", "return", "function", "(", ")", "{", "var", "callback", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ".", "pop", "(", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "alternatives", ")", ")", "{", "alternatives", "=", "[", "alternatives", "]", ";", "}", "var", "alternativeString", ";", "if", "(", "alternatives", ".", "length", "===", "1", ")", "{", "alternativeString", "=", "alternatives", "[", "0", "]", ";", "}", "else", "{", "var", "lastItem", "=", "alternatives", ".", "pop", "(", ")", ";", "alternativeString", "=", "alternatives", ".", "join", "(", "'\", \"'", ")", "+", "'\" or \"'", "+", "lastItem", ";", "}", "callback", "(", "MongoError", ".", "create", "(", "{", "message", ":", "'Method \"'", "+", "methodName", "+", "'\" is deprecated, use \"'", "+", "alternativeString", "+", "'\" instead'", ",", "driver", ":", "true", "}", ")", ")", ";", "}", ";", "}" ]
override deprecated methods, throw error
[ "override", "deprecated", "methods", "throw", "error" ]
df045c430c4acdb9e6a55e1aaa8e449b72e7d0b2
https://github.com/2do2go/mongodbext/blob/df045c430c4acdb9e6a55e1aaa8e449b72e7d0b2/lib/collection/index.js#L112-L133
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_ast.js
add_shared
function add_shared(hash, customTags, doc_map) { hash = utils.merge(hash, { "inheritable" : !!doc_map["inheritable"], "inheritdoc" : extract(doc_map, "inheritdoc"), "related" : extract(doc_map, "related"), "see" : extract(doc_map, "see"), "private" : extract(doc_map, "private") !== null ? true : false, "experimental" : extract(doc_map, "experimental") !== null ? true : false, "ignore" : extract(doc_map, "ignore") !== null ? true : false, "author" : extract_plural(doc_map["author"] || []), "version" : extract(doc_map, "version"), "since" : extract(doc_map, "since"), "todo" : extract(doc_map, "todo") }); if (customTags !== undefined) { var custom = {}; _.each(customTags, function(tag) { var text = extract(doc_map, tag); if (text !== null) { custom[tag] = text.doc.length > 0 ? text.doc : true; } }); hash = utils.merge(hash, custom); } return hash; }
javascript
function add_shared(hash, customTags, doc_map) { hash = utils.merge(hash, { "inheritable" : !!doc_map["inheritable"], "inheritdoc" : extract(doc_map, "inheritdoc"), "related" : extract(doc_map, "related"), "see" : extract(doc_map, "see"), "private" : extract(doc_map, "private") !== null ? true : false, "experimental" : extract(doc_map, "experimental") !== null ? true : false, "ignore" : extract(doc_map, "ignore") !== null ? true : false, "author" : extract_plural(doc_map["author"] || []), "version" : extract(doc_map, "version"), "since" : extract(doc_map, "since"), "todo" : extract(doc_map, "todo") }); if (customTags !== undefined) { var custom = {}; _.each(customTags, function(tag) { var text = extract(doc_map, tag); if (text !== null) { custom[tag] = text.doc.length > 0 ? text.doc : true; } }); hash = utils.merge(hash, custom); } return hash; }
[ "function", "add_shared", "(", "hash", ",", "customTags", ",", "doc_map", ")", "{", "hash", "=", "utils", ".", "merge", "(", "hash", ",", "{", "\"inheritable\"", ":", "!", "!", "doc_map", "[", "\"inheritable\"", "]", ",", "\"inheritdoc\"", ":", "extract", "(", "doc_map", ",", "\"inheritdoc\"", ")", ",", "\"related\"", ":", "extract", "(", "doc_map", ",", "\"related\"", ")", ",", "\"see\"", ":", "extract", "(", "doc_map", ",", "\"see\"", ")", ",", "\"private\"", ":", "extract", "(", "doc_map", ",", "\"private\"", ")", "!==", "null", "?", "true", ":", "false", ",", "\"experimental\"", ":", "extract", "(", "doc_map", ",", "\"experimental\"", ")", "!==", "null", "?", "true", ":", "false", ",", "\"ignore\"", ":", "extract", "(", "doc_map", ",", "\"ignore\"", ")", "!==", "null", "?", "true", ":", "false", ",", "\"author\"", ":", "extract_plural", "(", "doc_map", "[", "\"author\"", "]", "||", "[", "]", ")", ",", "\"version\"", ":", "extract", "(", "doc_map", ",", "\"version\"", ")", ",", "\"since\"", ":", "extract", "(", "doc_map", ",", "\"since\"", ")", ",", "\"todo\"", ":", "extract", "(", "doc_map", ",", "\"todo\"", ")", "}", ")", ";", "if", "(", "customTags", "!==", "undefined", ")", "{", "var", "custom", "=", "{", "}", ";", "_", ".", "each", "(", "customTags", ",", "function", "(", "tag", ")", "{", "var", "text", "=", "extract", "(", "doc_map", ",", "tag", ")", ";", "if", "(", "text", "!==", "null", ")", "{", "custom", "[", "tag", "]", "=", "text", ".", "doc", ".", "length", ">", "0", "?", "text", ".", "doc", ":", "true", ";", "}", "}", ")", ";", "hash", "=", "utils", ".", "merge", "(", "hash", ",", "custom", ")", ";", "}", "return", "hash", ";", "}" ]
Detects properties common for each doc-object and adds them
[ "Detects", "properties", "common", "for", "each", "doc", "-", "object", "and", "adds", "them" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_ast.js#L170-L198
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_ast.js
detect_list
function detect_list(type, doc_map) { if (doc_map[type]) return _.flatten(_.map(doc_map[type], function(d) { d[type] })); else return null; }
javascript
function detect_list(type, doc_map) { if (doc_map[type]) return _.flatten(_.map(doc_map[type], function(d) { d[type] })); else return null; }
[ "function", "detect_list", "(", "type", ",", "doc_map", ")", "{", "if", "(", "doc_map", "[", "type", "]", ")", "return", "_", ".", "flatten", "(", "_", ".", "map", "(", "doc_map", "[", "type", "]", ",", "function", "(", "d", ")", "{", "d", "[", "type", "]", "}", ")", ")", ";", "else", "return", "null", ";", "}" ]
for detecting mixins and alternateClassNames
[ "for", "detecting", "mixins", "and", "alternateClassNames" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_ast.js#L236-L241
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_ast.js
detect_doc
function detect_doc(docs, customTags) { var ignore_tags = _.union(["param", "return", "author", "version", "cancelable", "bubbles", "since", "inherits", "todo", "deprecated"], customTags); var doc_tags = _.filter(docs, function(tag) { return !_.include(ignore_tags, tag["tagname"]) && !subproperty(tag) }); return _.compact(_.map(doc_tags, function(tag) { return tag["doc"] })).join(" "); }
javascript
function detect_doc(docs, customTags) { var ignore_tags = _.union(["param", "return", "author", "version", "cancelable", "bubbles", "since", "inherits", "todo", "deprecated"], customTags); var doc_tags = _.filter(docs, function(tag) { return !_.include(ignore_tags, tag["tagname"]) && !subproperty(tag) }); return _.compact(_.map(doc_tags, function(tag) { return tag["doc"] })).join(" "); }
[ "function", "detect_doc", "(", "docs", ",", "customTags", ")", "{", "var", "ignore_tags", "=", "_", ".", "union", "(", "[", "\"param\"", ",", "\"return\"", ",", "\"author\"", ",", "\"version\"", ",", "\"cancelable\"", ",", "\"bubbles\"", ",", "\"since\"", ",", "\"inherits\"", ",", "\"todo\"", ",", "\"deprecated\"", "]", ",", "customTags", ")", ";", "var", "doc_tags", "=", "_", ".", "filter", "(", "docs", ",", "function", "(", "tag", ")", "{", "return", "!", "_", ".", "include", "(", "ignore_tags", ",", "tag", "[", "\"tagname\"", "]", ")", "&&", "!", "subproperty", "(", "tag", ")", "}", ")", ";", "return", "_", ".", "compact", "(", "_", ".", "map", "(", "doc_tags", ",", "function", "(", "tag", ")", "{", "return", "tag", "[", "\"doc\"", "]", "}", ")", ")", ".", "join", "(", "\" \"", ")", ";", "}" ]
Combines "doc"-s of most tags Ignore tags that have doc comment themselves and subproperty tags
[ "Combines", "doc", "-", "s", "of", "most", "tags", "Ignore", "tags", "that", "have", "doc", "comment", "themselves", "and", "subproperty", "tags" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_ast.js#L345-L350
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_parser.js
maybe_name
function maybe_name() { skip_horiz_white(); if (look(ident_pattern_with_dot)) { current_tag["name"] = match(ident_pattern_with_dot); } else if (look(ident_pattern)) { current_tag["name"] = match(ident_pattern); } }
javascript
function maybe_name() { skip_horiz_white(); if (look(ident_pattern_with_dot)) { current_tag["name"] = match(ident_pattern_with_dot); } else if (look(ident_pattern)) { current_tag["name"] = match(ident_pattern); } }
[ "function", "maybe_name", "(", ")", "{", "skip_horiz_white", "(", ")", ";", "if", "(", "look", "(", "ident_pattern_with_dot", ")", ")", "{", "current_tag", "[", "\"name\"", "]", "=", "match", "(", "ident_pattern_with_dot", ")", ";", "}", "else", "if", "(", "look", "(", "ident_pattern", ")", ")", "{", "current_tag", "[", "\"name\"", "]", "=", "match", "(", "ident_pattern", ")", ";", "}", "}" ]
matches identifier name if possible and sets it on @current_tag
[ "matches", "identifier", "name", "if", "possible", "and", "sets", "it", "on" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_parser.js#L640-L648
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_parser.js
default_value
function default_value() { start_pos = input.pointer(); value = parse_balanced(/\[/, /\]/, /[^\[\]]*/); if (look(/\]/)) { return value; } else { input.setPointer(start_pos); return match(/[^\]]*/); } }
javascript
function default_value() { start_pos = input.pointer(); value = parse_balanced(/\[/, /\]/, /[^\[\]]*/); if (look(/\]/)) { return value; } else { input.setPointer(start_pos); return match(/[^\]]*/); } }
[ "function", "default_value", "(", ")", "{", "start_pos", "=", "input", ".", "pointer", "(", ")", ";", "value", "=", "parse_balanced", "(", "/", "\\[", "/", ",", "/", "\\]", "/", ",", "/", "[^\\[\\]]*", "/", ")", ";", "if", "(", "look", "(", "/", "\\]", "/", ")", ")", "{", "return", "value", ";", "}", "else", "{", "input", ".", "setPointer", "(", "start_pos", ")", ";", "return", "match", "(", "/", "[^\\]]*", "/", ")", ";", "}", "}" ]
Attempts to allow balanced braces in default value. When the nested parsing doesn't finish at closing "]", roll back to beginning and simply grab anything up to closing "]".
[ "Attempts", "to", "allow", "balanced", "braces", "in", "default", "value", ".", "When", "the", "nested", "parsing", "doesn", "t", "finish", "at", "closing", "]", "roll", "back", "to", "beginning", "and", "simply", "grab", "anything", "up", "to", "closing", "]", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_parser.js#L661-L671
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_parser.js
parse_balanced
function parse_balanced(re_open, re_close, re_rest) { result = match(re_rest); while (look(re_open)) { result += match(re_open); result += parse_balanced(re_open, re_close, re_rest); result += match(re_close); result += match(re_rest); } return result; }
javascript
function parse_balanced(re_open, re_close, re_rest) { result = match(re_rest); while (look(re_open)) { result += match(re_open); result += parse_balanced(re_open, re_close, re_rest); result += match(re_close); result += match(re_rest); } return result; }
[ "function", "parse_balanced", "(", "re_open", ",", "re_close", ",", "re_rest", ")", "{", "result", "=", "match", "(", "re_rest", ")", ";", "while", "(", "look", "(", "re_open", ")", ")", "{", "result", "+=", "match", "(", "re_open", ")", ";", "result", "+=", "parse_balanced", "(", "re_open", ",", "re_close", ",", "re_rest", ")", ";", "result", "+=", "match", "(", "re_close", ")", ";", "result", "+=", "match", "(", "re_rest", ")", ";", "}", "return", "result", ";", "}" ]
Helper method to parse a string up to a closing brace, balancing opening-closing braces in between. @param re_open The beginning brace regex @param re_close The closing brace regex @param re_rest Regex to match text without any braces
[ "Helper", "method", "to", "parse", "a", "string", "up", "to", "a", "closing", "brace", "balancing", "opening", "-", "closing", "braces", "in", "between", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_parser.js#L698-L707
train
CartoDB/node-redis-mpool
index.js
RedisPool
function RedisPool(opts) { if (!(this instanceof RedisPool)) { return new RedisPool(opts); } EventEmitter.call(this); opts = opts || {}; var defaults = { host: '127.0.0.1', port: '6379', max: 50, idleTimeoutMillis: 10000, reapIntervalMillis: 1000, noReadyCheck: false, returnToHead: false, unwatchOnRelease: true, name: 'default', log: false, slowPool: { log: false, elapsedThreshold: 25 }, emitter: { statusInterval: 60000 }, commands: [] }; this.options = _.defaults(opts, defaults); this.pools = {}; this.elapsedThreshold = this.options.slowPool.elapsedThreshold; // add custom Redis commands if (this.options.commands && this.options.commands.length) { this.options.commands.forEach(function(newCommand) { redis.add_command(newCommand); }); } var self = this; setInterval(function() { Object.keys(self.pools).forEach(function(poolKey) { var pool = self.pools[poolKey]; self.emit('status', { name: self.options.name, db: poolKey, count: pool.getPoolSize(), unused: pool.availableObjectsCount(), waiting: pool.waitingClientsCount() }); }); }, this.options.emitter.statusInterval); }
javascript
function RedisPool(opts) { if (!(this instanceof RedisPool)) { return new RedisPool(opts); } EventEmitter.call(this); opts = opts || {}; var defaults = { host: '127.0.0.1', port: '6379', max: 50, idleTimeoutMillis: 10000, reapIntervalMillis: 1000, noReadyCheck: false, returnToHead: false, unwatchOnRelease: true, name: 'default', log: false, slowPool: { log: false, elapsedThreshold: 25 }, emitter: { statusInterval: 60000 }, commands: [] }; this.options = _.defaults(opts, defaults); this.pools = {}; this.elapsedThreshold = this.options.slowPool.elapsedThreshold; // add custom Redis commands if (this.options.commands && this.options.commands.length) { this.options.commands.forEach(function(newCommand) { redis.add_command(newCommand); }); } var self = this; setInterval(function() { Object.keys(self.pools).forEach(function(poolKey) { var pool = self.pools[poolKey]; self.emit('status', { name: self.options.name, db: poolKey, count: pool.getPoolSize(), unused: pool.availableObjectsCount(), waiting: pool.waitingClientsCount() }); }); }, this.options.emitter.statusInterval); }
[ "function", "RedisPool", "(", "opts", ")", "{", "if", "(", "!", "(", "this", "instanceof", "RedisPool", ")", ")", "{", "return", "new", "RedisPool", "(", "opts", ")", ";", "}", "EventEmitter", ".", "call", "(", "this", ")", ";", "opts", "=", "opts", "||", "{", "}", ";", "var", "defaults", "=", "{", "host", ":", "'127.0.0.1'", ",", "port", ":", "'6379'", ",", "max", ":", "50", ",", "idleTimeoutMillis", ":", "10000", ",", "reapIntervalMillis", ":", "1000", ",", "noReadyCheck", ":", "false", ",", "returnToHead", ":", "false", ",", "unwatchOnRelease", ":", "true", ",", "name", ":", "'default'", ",", "log", ":", "false", ",", "slowPool", ":", "{", "log", ":", "false", ",", "elapsedThreshold", ":", "25", "}", ",", "emitter", ":", "{", "statusInterval", ":", "60000", "}", ",", "commands", ":", "[", "]", "}", ";", "this", ".", "options", "=", "_", ".", "defaults", "(", "opts", ",", "defaults", ")", ";", "this", ".", "pools", "=", "{", "}", ";", "this", ".", "elapsedThreshold", "=", "this", ".", "options", ".", "slowPool", ".", "elapsedThreshold", ";", "if", "(", "this", ".", "options", ".", "commands", "&&", "this", ".", "options", ".", "commands", ".", "length", ")", "{", "this", ".", "options", ".", "commands", ".", "forEach", "(", "function", "(", "newCommand", ")", "{", "redis", ".", "add_command", "(", "newCommand", ")", ";", "}", ")", ";", "}", "var", "self", "=", "this", ";", "setInterval", "(", "function", "(", ")", "{", "Object", ".", "keys", "(", "self", ".", "pools", ")", ".", "forEach", "(", "function", "(", "poolKey", ")", "{", "var", "pool", "=", "self", ".", "pools", "[", "poolKey", "]", ";", "self", ".", "emit", "(", "'status'", ",", "{", "name", ":", "self", ".", "options", ".", "name", ",", "db", ":", "poolKey", ",", "count", ":", "pool", ".", "getPoolSize", "(", ")", ",", "unused", ":", "pool", ".", "availableObjectsCount", "(", ")", ",", "waiting", ":", "pool", ".", "waitingClientsCount", "(", ")", "}", ")", ";", "}", ")", ";", "}", ",", "this", ".", "options", ".", "emitter", ".", "statusInterval", ")", ";", "}" ]
Create a new multi database Redis pool. It will emit `status` event with information about each created pool. @param {Object} opts @returns {RedisPool} @constructor
[ "Create", "a", "new", "multi", "database", "Redis", "pool", ".", "It", "will", "emit", "status", "event", "with", "information", "about", "each", "created", "pool", "." ]
181e8fee869ac0696328a6af06e7be966cb09602
https://github.com/CartoDB/node-redis-mpool/blob/181e8fee869ac0696328a6af06e7be966cb09602/index.js#L20-L74
train
CartoDB/node-redis-mpool
index.js
makePool
function makePool(options, database) { return Pool({ name: options.name + ':' + database, create: function(callback) { var callbackCalled = false; var client = redis.createClient(options.port, options.host, { no_ready_check: options.noReadyCheck }); client.on('error', function (err) { log(options, {db: database, action: 'error', err: err.message}); if (!callbackCalled) { callbackCalled = true; callback(err, client); } client.end(FLUSH_CONNECTION); }); client.on('ready', function () { client.select(database, function(err/*, res*/) { if (!callbackCalled) { callbackCalled = true; callback(err, client); } }); }); }, destroy: function(client) { client.quit(); client.end(FLUSH_CONNECTION); }, validate: function(client) { return client && client.connected; }, max: options.max, idleTimeoutMillis: options.idleTimeoutMillis, reapIntervalMillis: options.reapIntervalMillis, returnToHead: options.returnToHead, log: options.log }); }
javascript
function makePool(options, database) { return Pool({ name: options.name + ':' + database, create: function(callback) { var callbackCalled = false; var client = redis.createClient(options.port, options.host, { no_ready_check: options.noReadyCheck }); client.on('error', function (err) { log(options, {db: database, action: 'error', err: err.message}); if (!callbackCalled) { callbackCalled = true; callback(err, client); } client.end(FLUSH_CONNECTION); }); client.on('ready', function () { client.select(database, function(err/*, res*/) { if (!callbackCalled) { callbackCalled = true; callback(err, client); } }); }); }, destroy: function(client) { client.quit(); client.end(FLUSH_CONNECTION); }, validate: function(client) { return client && client.connected; }, max: options.max, idleTimeoutMillis: options.idleTimeoutMillis, reapIntervalMillis: options.reapIntervalMillis, returnToHead: options.returnToHead, log: options.log }); }
[ "function", "makePool", "(", "options", ",", "database", ")", "{", "return", "Pool", "(", "{", "name", ":", "options", ".", "name", "+", "':'", "+", "database", ",", "create", ":", "function", "(", "callback", ")", "{", "var", "callbackCalled", "=", "false", ";", "var", "client", "=", "redis", ".", "createClient", "(", "options", ".", "port", ",", "options", ".", "host", ",", "{", "no_ready_check", ":", "options", ".", "noReadyCheck", "}", ")", ";", "client", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "log", "(", "options", ",", "{", "db", ":", "database", ",", "action", ":", "'error'", ",", "err", ":", "err", ".", "message", "}", ")", ";", "if", "(", "!", "callbackCalled", ")", "{", "callbackCalled", "=", "true", ";", "callback", "(", "err", ",", "client", ")", ";", "}", "client", ".", "end", "(", "FLUSH_CONNECTION", ")", ";", "}", ")", ";", "client", ".", "on", "(", "'ready'", ",", "function", "(", ")", "{", "client", ".", "select", "(", "database", ",", "function", "(", "err", ")", "{", "if", "(", "!", "callbackCalled", ")", "{", "callbackCalled", "=", "true", ";", "callback", "(", "err", ",", "client", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", ",", "destroy", ":", "function", "(", "client", ")", "{", "client", ".", "quit", "(", ")", ";", "client", ".", "end", "(", "FLUSH_CONNECTION", ")", ";", "}", ",", "validate", ":", "function", "(", "client", ")", "{", "return", "client", "&&", "client", ".", "connected", ";", "}", ",", "max", ":", "options", ".", "max", ",", "idleTimeoutMillis", ":", "options", ".", "idleTimeoutMillis", ",", "reapIntervalMillis", ":", "options", ".", "reapIntervalMillis", ",", "returnToHead", ":", "options", ".", "returnToHead", ",", "log", ":", "options", ".", "log", "}", ")", ";", "}" ]
Factory to create new Redis pools for a given Redis database @param options @param database @returns {Object}
[ "Factory", "to", "create", "new", "Redis", "pools", "for", "a", "given", "Redis", "database" ]
181e8fee869ac0696328a6af06e7be966cb09602
https://github.com/CartoDB/node-redis-mpool/blob/181e8fee869ac0696328a6af06e7be966cb09602/index.js#L130-L176
train
weepower/wee-core
scripts/wee-store.js
_storageFactory
function _storageFactory(type) { let storage; if (type === 'local') { storage = window.localStorage; } else if (type === 'session') { storage = window.sessionStorage; } return { getItem(key) { return JSON.parse(storage.getItem(key)); }, setItem(key, value) { value = JSON.stringify(value); return storage.setItem(key, value); }, removeItem(key) { return storage.removeItem(key); } }; }
javascript
function _storageFactory(type) { let storage; if (type === 'local') { storage = window.localStorage; } else if (type === 'session') { storage = window.sessionStorage; } return { getItem(key) { return JSON.parse(storage.getItem(key)); }, setItem(key, value) { value = JSON.stringify(value); return storage.setItem(key, value); }, removeItem(key) { return storage.removeItem(key); } }; }
[ "function", "_storageFactory", "(", "type", ")", "{", "let", "storage", ";", "if", "(", "type", "===", "'local'", ")", "{", "storage", "=", "window", ".", "localStorage", ";", "}", "else", "if", "(", "type", "===", "'session'", ")", "{", "storage", "=", "window", ".", "sessionStorage", ";", "}", "return", "{", "getItem", "(", "key", ")", "{", "return", "JSON", ".", "parse", "(", "storage", ".", "getItem", "(", "key", ")", ")", ";", "}", ",", "setItem", "(", "key", ",", "value", ")", "{", "value", "=", "JSON", ".", "stringify", "(", "value", ")", ";", "return", "storage", ".", "setItem", "(", "key", ",", "value", ")", ";", "}", ",", "removeItem", "(", "key", ")", "{", "return", "storage", ".", "removeItem", "(", "key", ")", ";", "}", "}", ";", "}" ]
Create wrapper for browser storage api @param {string} type @returns {*} @private
[ "Create", "wrapper", "for", "browser", "storage", "api" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-store.js#L17-L39
train
alan-wu/ZincJS
src/scene.js
function(numberOfDownloaded, finishCallback, allCompletedCallback) { let downloadedItem = 0; return zincGeometry => { downloadedItem = downloadedItem + 1; if (finishCallback != undefined && (typeof finishCallback == 'function')) finishCallback(zincGeometry); if (downloadedItem == numberOfDownloaded) if (allCompletedCallback != undefined && (typeof allCompletedCallback == 'function')) allCompletedCallback(); }; }
javascript
function(numberOfDownloaded, finishCallback, allCompletedCallback) { let downloadedItem = 0; return zincGeometry => { downloadedItem = downloadedItem + 1; if (finishCallback != undefined && (typeof finishCallback == 'function')) finishCallback(zincGeometry); if (downloadedItem == numberOfDownloaded) if (allCompletedCallback != undefined && (typeof allCompletedCallback == 'function')) allCompletedCallback(); }; }
[ "function", "(", "numberOfDownloaded", ",", "finishCallback", ",", "allCompletedCallback", ")", "{", "let", "downloadedItem", "=", "0", ";", "return", "zincGeometry", "=>", "{", "downloadedItem", "=", "downloadedItem", "+", "1", ";", "if", "(", "finishCallback", "!=", "undefined", "&&", "(", "typeof", "finishCallback", "==", "'function'", ")", ")", "finishCallback", "(", "zincGeometry", ")", ";", "if", "(", "downloadedItem", "==", "numberOfDownloaded", ")", "if", "(", "allCompletedCallback", "!=", "undefined", "&&", "(", "typeof", "allCompletedCallback", "==", "'function'", ")", ")", "allCompletedCallback", "(", ")", ";", "}", ";", "}" ]
Object to keep track of number of items downloaded and when add items are downloaded allCompletedCallback is called
[ "Object", "to", "keep", "track", "of", "number", "of", "items", "downloaded", "and", "when", "add", "items", "are", "downloaded", "allCompletedCallback", "is", "called" ]
f2c25b63a109b8f09e7329211703a60d49b62676
https://github.com/alan-wu/ZincJS/blob/f2c25b63a109b8f09e7329211703a60d49b62676/src/scene.js#L340-L350
train
kaelzhang/neuron.js
lib/ecma5.js
extend
function extend (host, methods) { for (var name in methods) { if (!host[name]) { host[name] = methods[name]; } } }
javascript
function extend (host, methods) { for (var name in methods) { if (!host[name]) { host[name] = methods[name]; } } }
[ "function", "extend", "(", "host", ",", "methods", ")", "{", "for", "(", "var", "name", "in", "methods", ")", "{", "if", "(", "!", "host", "[", "name", "]", ")", "{", "host", "[", "name", "]", "=", "methods", "[", "name", "]", ";", "}", "}", "}" ]
- always has no dependencies on Neuron - always follow ECMA standard strictly, including logic, exception type - throw the same error hint as webkit on a certain exception
[ "-", "always", "has", "no", "dependencies", "on", "Neuron", "-", "always", "follow", "ECMA", "standard", "strictly", "including", "logic", "exception", "type", "-", "throw", "the", "same", "error", "hint", "as", "webkit", "on", "a", "certain", "exception" ]
3e1eed28f08ab14f289f476f886ac7f095036e66
https://github.com/kaelzhang/neuron.js/blob/3e1eed28f08ab14f289f476f886ac7f095036e66/lib/ecma5.js#L40-L46
train
OldSneerJaw/couchster
src/validation/property-validator-schema.js
makeTypeConstraintsSchema
function makeTypeConstraintsSchema(typeName) { const allTypeConstraints = typeSpecificConstraintSchemas(); const constraints = Object.assign({ }, universalConstraintSchemas(typeEqualitySchemas[typeName]), allTypeConstraints[typeName]); return joi.object().keys(constraints) // Prevent the use of more than one constraint from the "required value" category .without('required', [ 'mustNotBeMissing', 'mustNotBeNull' ]) .without('mustNotBeMissing', [ 'required', 'mustNotBeNull' ]) .without('mustNotBeNull', [ 'required', 'mustNotBeMissing' ]) // Prevent the use of more than one constraint from the "equality" category .without('mustEqual', [ 'mustEqualStrict', 'mustEqualIgnoreCase' ]) .without('mustEqualStrict', [ 'mustEqual', 'mustEqualIgnoreCase' ]) .without('mustEqualIgnoreCase', [ 'mustEqual', 'mustEqualStrict' ]) // Prevent the use of more than one constraint from the "minimum value" category .without('minimumValue', [ 'minimumValueExclusive', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ]) .without('minimumValueExclusive', [ 'minimumValue', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ]) // Prevent the use of more than one constraint from the "maximum value" category .without('maximumValue', [ 'maximumValueExclusive', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ]) .without('maximumValueExclusive', [ 'maximumValue', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ]) // Prevent the use of more than one constraint from the "immutability" category .without('immutable', [ 'immutableStrict', 'immutableWhenSet', 'immutableWhenSetStrict' ]) .without('immutableStrict', [ 'immutable', 'immutableWhenSet', 'immutableWhenSetStrict' ]) .without('immutableWhenSet', [ 'immutable', 'immutableStrict', 'immutableWhenSetStrict' ]) .without('immutableWhenSetStrict', [ 'immutable', 'immutableStrict', 'immutableWhenSet' ]) // Prevent the use of more than one constraint from the "skip validation" category .without('skipValidationWhenValueUnchanged', [ 'skipValidationWhenValueUnchangedStrict' ]); }
javascript
function makeTypeConstraintsSchema(typeName) { const allTypeConstraints = typeSpecificConstraintSchemas(); const constraints = Object.assign({ }, universalConstraintSchemas(typeEqualitySchemas[typeName]), allTypeConstraints[typeName]); return joi.object().keys(constraints) // Prevent the use of more than one constraint from the "required value" category .without('required', [ 'mustNotBeMissing', 'mustNotBeNull' ]) .without('mustNotBeMissing', [ 'required', 'mustNotBeNull' ]) .without('mustNotBeNull', [ 'required', 'mustNotBeMissing' ]) // Prevent the use of more than one constraint from the "equality" category .without('mustEqual', [ 'mustEqualStrict', 'mustEqualIgnoreCase' ]) .without('mustEqualStrict', [ 'mustEqual', 'mustEqualIgnoreCase' ]) .without('mustEqualIgnoreCase', [ 'mustEqual', 'mustEqualStrict' ]) // Prevent the use of more than one constraint from the "minimum value" category .without('minimumValue', [ 'minimumValueExclusive', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ]) .without('minimumValueExclusive', [ 'minimumValue', 'mustEqual', 'mustEqualStrict', 'mustEqualIgnoreCase' ]) // Prevent the use of more than one constraint from the "maximum value" category .without('maximumValue', [ 'maximumValueExclusive', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ]) .without('maximumValueExclusive', [ 'maximumValue', 'mustEqualStrict', 'mustEqual', 'mustEqualIgnoreCase' ]) // Prevent the use of more than one constraint from the "immutability" category .without('immutable', [ 'immutableStrict', 'immutableWhenSet', 'immutableWhenSetStrict' ]) .without('immutableStrict', [ 'immutable', 'immutableWhenSet', 'immutableWhenSetStrict' ]) .without('immutableWhenSet', [ 'immutable', 'immutableStrict', 'immutableWhenSetStrict' ]) .without('immutableWhenSetStrict', [ 'immutable', 'immutableStrict', 'immutableWhenSet' ]) // Prevent the use of more than one constraint from the "skip validation" category .without('skipValidationWhenValueUnchanged', [ 'skipValidationWhenValueUnchangedStrict' ]); }
[ "function", "makeTypeConstraintsSchema", "(", "typeName", ")", "{", "const", "allTypeConstraints", "=", "typeSpecificConstraintSchemas", "(", ")", ";", "const", "constraints", "=", "Object", ".", "assign", "(", "{", "}", ",", "universalConstraintSchemas", "(", "typeEqualitySchemas", "[", "typeName", "]", ")", ",", "allTypeConstraints", "[", "typeName", "]", ")", ";", "return", "joi", ".", "object", "(", ")", ".", "keys", "(", "constraints", ")", ".", "without", "(", "'required'", ",", "[", "'mustNotBeMissing'", ",", "'mustNotBeNull'", "]", ")", ".", "without", "(", "'mustNotBeMissing'", ",", "[", "'required'", ",", "'mustNotBeNull'", "]", ")", ".", "without", "(", "'mustNotBeNull'", ",", "[", "'required'", ",", "'mustNotBeMissing'", "]", ")", ".", "without", "(", "'mustEqual'", ",", "[", "'mustEqualStrict'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'mustEqualStrict'", ",", "[", "'mustEqual'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'mustEqualIgnoreCase'", ",", "[", "'mustEqual'", ",", "'mustEqualStrict'", "]", ")", ".", "without", "(", "'minimumValue'", ",", "[", "'minimumValueExclusive'", ",", "'mustEqual'", ",", "'mustEqualStrict'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'minimumValueExclusive'", ",", "[", "'minimumValue'", ",", "'mustEqual'", ",", "'mustEqualStrict'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'maximumValue'", ",", "[", "'maximumValueExclusive'", ",", "'mustEqualStrict'", ",", "'mustEqual'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'maximumValueExclusive'", ",", "[", "'maximumValue'", ",", "'mustEqualStrict'", ",", "'mustEqual'", ",", "'mustEqualIgnoreCase'", "]", ")", ".", "without", "(", "'immutable'", ",", "[", "'immutableStrict'", ",", "'immutableWhenSet'", ",", "'immutableWhenSetStrict'", "]", ")", ".", "without", "(", "'immutableStrict'", ",", "[", "'immutable'", ",", "'immutableWhenSet'", ",", "'immutableWhenSetStrict'", "]", ")", ".", "without", "(", "'immutableWhenSet'", ",", "[", "'immutable'", ",", "'immutableStrict'", ",", "'immutableWhenSetStrict'", "]", ")", ".", "without", "(", "'immutableWhenSetStrict'", ",", "[", "'immutable'", ",", "'immutableStrict'", ",", "'immutableWhenSet'", "]", ")", ".", "without", "(", "'skipValidationWhenValueUnchanged'", ",", "[", "'skipValidationWhenValueUnchangedStrict'", "]", ")", ";", "}" ]
Creates a validation schema for the constraints of the specified type
[ "Creates", "a", "validation", "schema", "for", "the", "constraints", "of", "the", "specified", "type" ]
59528affeee2c3946829f79f46718d6cbac69412
https://github.com/OldSneerJaw/couchster/blob/59528affeee2c3946829f79f46718d6cbac69412/src/validation/property-validator-schema.js#L209-L240
train
gjtorikian/panino-docs
lib/panino/plugins/renderers/c9ac_support/util.js
processOne
function processOne() { var item = array.pop(); fn(item, function(result, err) { if (array.length > 0) processOne(); else callback(result, err); }); }
javascript
function processOne() { var item = array.pop(); fn(item, function(result, err) { if (array.length > 0) processOne(); else callback(result, err); }); }
[ "function", "processOne", "(", ")", "{", "var", "item", "=", "array", ".", "pop", "(", ")", ";", "fn", "(", "item", ",", "function", "(", "result", ",", "err", ")", "{", "if", "(", "array", ".", "length", ">", "0", ")", "processOne", "(", ")", ";", "else", "callback", "(", "result", ",", "err", ")", ";", "}", ")", ";", "}" ]
Just to be sure
[ "Just", "to", "be", "sure" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/renderers/c9ac_support/util.js#L22-L30
train
weepower/wee-core
scripts/dom/index.js
_setClass
function _setClass(el, className) { el instanceof SVGElement ? el.setAttribute('class', className) : el.className = className; }
javascript
function _setClass(el, className) { el instanceof SVGElement ? el.setAttribute('class', className) : el.className = className; }
[ "function", "_setClass", "(", "el", ",", "className", ")", "{", "el", "instanceof", "SVGElement", "?", "el", ".", "setAttribute", "(", "'class'", ",", "className", ")", ":", "el", ".", "className", "=", "className", ";", "}" ]
Set class value of element @private @param {HTMLElement} el @param {string} className
[ "Set", "class", "value", "of", "element" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/dom/index.js#L26-L30
train
weepower/wee-core
scripts/dom/index.js
_toCamel
function _toCamel(name) { return name.toLowerCase() .replace(/-(.)/g, (match, val) => val.toUpperCase()); }
javascript
function _toCamel(name) { return name.toLowerCase() .replace(/-(.)/g, (match, val) => val.toUpperCase()); }
[ "function", "_toCamel", "(", "name", ")", "{", "return", "name", ".", "toLowerCase", "(", ")", ".", "replace", "(", "/", "-(.)", "/", "g", ",", "(", "match", ",", "val", ")", "=>", "val", ".", "toUpperCase", "(", ")", ")", ";", "}" ]
Convert dash-separated string to camel-case @private @param {string} name @returns {string}
[ "Convert", "dash", "-", "separated", "string", "to", "camel", "-", "case" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/dom/index.js#L39-L42
train
weepower/wee-core
scripts/dom/index.js
_getSelected
function _getSelected(select) { const arr = []; _slice.call(select.options).map((el) => { if (el.selected) { arr.push(el.value); } }); return arr; }
javascript
function _getSelected(select) { const arr = []; _slice.call(select.options).map((el) => { if (el.selected) { arr.push(el.value); } }); return arr; }
[ "function", "_getSelected", "(", "select", ")", "{", "const", "arr", "=", "[", "]", ";", "_slice", ".", "call", "(", "select", ".", "options", ")", ".", "map", "(", "(", "el", ")", "=>", "{", "if", "(", "el", ".", "selected", ")", "{", "arr", ".", "push", "(", "el", ".", "value", ")", ";", "}", "}", ")", ";", "return", "arr", ";", "}" ]
Get the selected options from a select @private @param {HTMLElement} select @returns {Array} selected
[ "Get", "the", "selected", "options", "from", "a", "select" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/dom/index.js#L62-L72
train
weepower/wee-core
scripts/dom/index.js
_getSibling
function _getSibling(target, dir, filter, options) { let match; $each(target, (el) => { const index = $index(el) + dir; $children($parent(el)).forEach((el, i) => { if (i === index && (! filter || filter && $is(el, filter, options))) { match = el; } }); }); return match; }
javascript
function _getSibling(target, dir, filter, options) { let match; $each(target, (el) => { const index = $index(el) + dir; $children($parent(el)).forEach((el, i) => { if (i === index && (! filter || filter && $is(el, filter, options))) { match = el; } }); }); return match; }
[ "function", "_getSibling", "(", "target", ",", "dir", ",", "filter", ",", "options", ")", "{", "let", "match", ";", "$each", "(", "target", ",", "(", "el", ")", "=>", "{", "const", "index", "=", "$index", "(", "el", ")", "+", "dir", ";", "$children", "(", "$parent", "(", "el", ")", ")", ".", "forEach", "(", "(", "el", ",", "i", ")", "=>", "{", "if", "(", "i", "===", "index", "&&", "(", "!", "filter", "||", "filter", "&&", "$is", "(", "el", ",", "filter", ",", "options", ")", ")", ")", "{", "match", "=", "el", ";", "}", "}", ")", ";", "}", ")", ";", "return", "match", ";", "}" ]
Return either direct previous or next sibling @private @param {($|HTMLElement|string)} target @param {number} dir @param filter @param {Object} [options] @returns {HTMLElement}
[ "Return", "either", "direct", "previous", "or", "next", "sibling" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/dom/index.js#L84-L99
train
alan-wu/ZincJS
src/utilities.js
partialCallback
function partialCallback(text, urlIndex) { result[urlIndex] = text; numComplete++; // When all files have downloaded if (numComplete == numUrls) { callback(result); } }
javascript
function partialCallback(text, urlIndex) { result[urlIndex] = text; numComplete++; // When all files have downloaded if (numComplete == numUrls) { callback(result); } }
[ "function", "partialCallback", "(", "text", ",", "urlIndex", ")", "{", "result", "[", "urlIndex", "]", "=", "text", ";", "numComplete", "++", ";", "if", "(", "numComplete", "==", "numUrls", ")", "{", "callback", "(", "result", ")", ";", "}", "}" ]
Callback for a single file
[ "Callback", "for", "a", "single", "file" ]
f2c25b63a109b8f09e7329211703a60d49b62676
https://github.com/alan-wu/ZincJS/blob/f2c25b63a109b8f09e7329211703a60d49b62676/src/utilities.js#L29-L37
train
c9/vfs-socket
worker.js
write
function write(id, chunk) { // They want to write to our real stream var stream = streams[id]; if (!stream) return; stream.write(chunk); }
javascript
function write(id, chunk) { // They want to write to our real stream var stream = streams[id]; if (!stream) return; stream.write(chunk); }
[ "function", "write", "(", "id", ",", "chunk", ")", "{", "var", "stream", "=", "streams", "[", "id", "]", ";", "if", "(", "!", "stream", ")", "return", ";", "stream", ".", "write", "(", "chunk", ")", ";", "}" ]
Remote side writing to our local writable streams
[ "Remote", "side", "writing", "to", "our", "local", "writable", "streams" ]
1a88b31d8d59f4a9d8226acb5c44e9de7ec15bd5
https://github.com/c9/vfs-socket/blob/1a88b31d8d59f4a9d8226acb5c44e9de7ec15bd5/worker.js#L267-L272
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_expander.js
expand_comment
function expand_comment(docset) { groups = { "class": [], "cfg": [], "Constructor": [] } // By default everything goes to :class group var group_name = "class"; _.each(docset["comment"], function (tag) { tagname = tag["tagname"]; if (tagname == "cfg" || tagname == "Constructor") { group_name = tagname; if (tagname == "cfg") groups["cfg"].push([]); } if (tagname == "alias") groups["class"].push(tag); // For backwards compatibility allow @xtype after @constructor else if (group_name == "cfg") _.last(groups["cfg"]).push(tag); else groups[group_name].push(tag); }); return groups_to_docsets(groups, docset); }
javascript
function expand_comment(docset) { groups = { "class": [], "cfg": [], "Constructor": [] } // By default everything goes to :class group var group_name = "class"; _.each(docset["comment"], function (tag) { tagname = tag["tagname"]; if (tagname == "cfg" || tagname == "Constructor") { group_name = tagname; if (tagname == "cfg") groups["cfg"].push([]); } if (tagname == "alias") groups["class"].push(tag); // For backwards compatibility allow @xtype after @constructor else if (group_name == "cfg") _.last(groups["cfg"]).push(tag); else groups[group_name].push(tag); }); return groups_to_docsets(groups, docset); }
[ "function", "expand_comment", "(", "docset", ")", "{", "groups", "=", "{", "\"class\"", ":", "[", "]", ",", "\"cfg\"", ":", "[", "]", ",", "\"Constructor\"", ":", "[", "]", "}", "var", "group_name", "=", "\"class\"", ";", "_", ".", "each", "(", "docset", "[", "\"comment\"", "]", ",", "function", "(", "tag", ")", "{", "tagname", "=", "tag", "[", "\"tagname\"", "]", ";", "if", "(", "tagname", "==", "\"cfg\"", "||", "tagname", "==", "\"Constructor\"", ")", "{", "group_name", "=", "tagname", ";", "if", "(", "tagname", "==", "\"cfg\"", ")", "groups", "[", "\"cfg\"", "]", ".", "push", "(", "[", "]", ")", ";", "}", "if", "(", "tagname", "==", "\"alias\"", ")", "groups", "[", "\"class\"", "]", ".", "push", "(", "tag", ")", ";", "else", "if", "(", "group_name", "==", "\"cfg\"", ")", "_", ".", "last", "(", "groups", "[", "\"cfg\"", "]", ")", ".", "push", "(", "tag", ")", ";", "else", "groups", "[", "group_name", "]", ".", "push", "(", "tag", ")", ";", "}", ")", ";", "return", "groups_to_docsets", "(", "groups", ",", "docset", ")", ";", "}" ]
Handles old syntax where configs and constructor are part of class doc-comment. Gathers all tags until first @cfg or @constructor into the first bare :class group. We have a special case for @xtype which in ExtJS comments often appears after @constructor - so we explicitly place it into :class group. Then gathers each @cfg and tags following it into :cfg group, so that it becomes array of arrays of tags. This is to allow some configs to be marked with @private or whatever else. Finally gathers tags after @constructor into its group.
[ "Handles", "old", "syntax", "where", "configs", "and", "constructor", "are", "part", "of", "class", "doc", "-", "comment", ".", "Gathers", "all", "tags", "until", "first" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_expander.js#L35-L63
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_expander.js
groups_to_docsets
function groups_to_docsets(groups, docset) { var results = [{ "tagname": "class", "type": docset["type"], "comment": groups["class"], "code": docset["code"], "linenr": docset["linenr"] }]; _.each(groups["cfg"], function(cfg) { results.push({ "tagname": "cfg", "type": docset["type"], "comment": cfg, "code": {}, "linenr": docset["linenr"] }); }); if (groups["Constructor"].length > 0) { // Remember that a constructor is already found and ignore if a // constructor is detected from code. var constructor_found = true results.push({ "tagname": "method", "type": docset["type"], "comment": groups["Constructor"], "code": {}, "linenr": docset["linenr"] }); } return results; }
javascript
function groups_to_docsets(groups, docset) { var results = [{ "tagname": "class", "type": docset["type"], "comment": groups["class"], "code": docset["code"], "linenr": docset["linenr"] }]; _.each(groups["cfg"], function(cfg) { results.push({ "tagname": "cfg", "type": docset["type"], "comment": cfg, "code": {}, "linenr": docset["linenr"] }); }); if (groups["Constructor"].length > 0) { // Remember that a constructor is already found and ignore if a // constructor is detected from code. var constructor_found = true results.push({ "tagname": "method", "type": docset["type"], "comment": groups["Constructor"], "code": {}, "linenr": docset["linenr"] }); } return results; }
[ "function", "groups_to_docsets", "(", "groups", ",", "docset", ")", "{", "var", "results", "=", "[", "{", "\"tagname\"", ":", "\"class\"", ",", "\"type\"", ":", "docset", "[", "\"type\"", "]", ",", "\"comment\"", ":", "groups", "[", "\"class\"", "]", ",", "\"code\"", ":", "docset", "[", "\"code\"", "]", ",", "\"linenr\"", ":", "docset", "[", "\"linenr\"", "]", "}", "]", ";", "_", ".", "each", "(", "groups", "[", "\"cfg\"", "]", ",", "function", "(", "cfg", ")", "{", "results", ".", "push", "(", "{", "\"tagname\"", ":", "\"cfg\"", ",", "\"type\"", ":", "docset", "[", "\"type\"", "]", ",", "\"comment\"", ":", "cfg", ",", "\"code\"", ":", "{", "}", ",", "\"linenr\"", ":", "docset", "[", "\"linenr\"", "]", "}", ")", ";", "}", ")", ";", "if", "(", "groups", "[", "\"Constructor\"", "]", ".", "length", ">", "0", ")", "{", "var", "constructor_found", "=", "true", "results", ".", "push", "(", "{", "\"tagname\"", ":", "\"method\"", ",", "\"type\"", ":", "docset", "[", "\"type\"", "]", ",", "\"comment\"", ":", "groups", "[", "\"Constructor\"", "]", ",", "\"code\"", ":", "{", "}", ",", "\"linenr\"", ":", "docset", "[", "\"linenr\"", "]", "}", ")", ";", "}", "return", "results", ";", "}" ]
Turns groups hash into list of docsets
[ "Turns", "groups", "hash", "into", "list", "of", "docsets" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_expander.js#L66-L100
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/doc_expander.js
expand_code
function expand_code(docset) { var results = []; if (docset["code"] && docset["code"]["members"]) { _.each(docset["code"]["members"], function(m) { if (! (constructor_found && m["name"] == "Constructor") ) results.push(code_to_docset(m)); }); } return results; }
javascript
function expand_code(docset) { var results = []; if (docset["code"] && docset["code"]["members"]) { _.each(docset["code"]["members"], function(m) { if (! (constructor_found && m["name"] == "Constructor") ) results.push(code_to_docset(m)); }); } return results; }
[ "function", "expand_code", "(", "docset", ")", "{", "var", "results", "=", "[", "]", ";", "if", "(", "docset", "[", "\"code\"", "]", "&&", "docset", "[", "\"code\"", "]", "[", "\"members\"", "]", ")", "{", "_", ".", "each", "(", "docset", "[", "\"code\"", "]", "[", "\"members\"", "]", ",", "function", "(", "m", ")", "{", "if", "(", "!", "(", "constructor_found", "&&", "m", "[", "\"name\"", "]", "==", "\"Constructor\"", ")", ")", "results", ".", "push", "(", "code_to_docset", "(", "m", ")", ")", ";", "}", ")", ";", "}", "return", "results", ";", "}" ]
Turns auto-detected class members into docsets in their own right.
[ "Turns", "auto", "-", "detected", "class", "members", "into", "docsets", "in", "their", "own", "right", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/doc_expander.js#L103-L114
train
artifishional/air-m2
src/loader/loader.js
vertextes
function vertextes(parent, exist = [], item, _path) { return [...parent.children].reduce( (acc, node, index) => { if(node.tagName === "IMG") { //const [ name, props = {} ] = JSON.parse(node.getAttribute("m2") || "[]"); node.setAttribute("m2", JSON.stringify([ `*${imgcounter++}`, { resources: [ {type: "img", url: node.getAttribute("src") } ]} ])); item = []; } /* if(node.tagName === "link" && node.getAttribute("rel") === "stylesheet") { exist[1].resources.push( {type: "style", url: node.getAttribute("href") } ); node.remove(); return acc; }*/ if(node.getAttribute("m2")) { const m2data = transform(node, item, _path); if(!m2data[1].template && exist[1].type !== "switcher") { const placer = document.createElement("div"); placer.setAttribute("data-pid", m2data[1].pid ); node.parentNode.replaceChild(placer, node); } node.remove(); acc.push( m2data ); } else { vertextes(node, exist, item, _path); } return acc; }, exist); }
javascript
function vertextes(parent, exist = [], item, _path) { return [...parent.children].reduce( (acc, node, index) => { if(node.tagName === "IMG") { //const [ name, props = {} ] = JSON.parse(node.getAttribute("m2") || "[]"); node.setAttribute("m2", JSON.stringify([ `*${imgcounter++}`, { resources: [ {type: "img", url: node.getAttribute("src") } ]} ])); item = []; } /* if(node.tagName === "link" && node.getAttribute("rel") === "stylesheet") { exist[1].resources.push( {type: "style", url: node.getAttribute("href") } ); node.remove(); return acc; }*/ if(node.getAttribute("m2")) { const m2data = transform(node, item, _path); if(!m2data[1].template && exist[1].type !== "switcher") { const placer = document.createElement("div"); placer.setAttribute("data-pid", m2data[1].pid ); node.parentNode.replaceChild(placer, node); } node.remove(); acc.push( m2data ); } else { vertextes(node, exist, item, _path); } return acc; }, exist); }
[ "function", "vertextes", "(", "parent", ",", "exist", "=", "[", "]", ",", "item", ",", "_path", ")", "{", "return", "[", "...", "parent", ".", "children", "]", ".", "reduce", "(", "(", "acc", ",", "node", ",", "index", ")", "=>", "{", "if", "(", "node", ".", "tagName", "===", "\"IMG\"", ")", "{", "node", ".", "setAttribute", "(", "\"m2\"", ",", "JSON", ".", "stringify", "(", "[", "`", "${", "imgcounter", "++", "}", "`", ",", "{", "resources", ":", "[", "{", "type", ":", "\"img\"", ",", "url", ":", "node", ".", "getAttribute", "(", "\"src\"", ")", "}", "]", "}", "]", ")", ")", ";", "item", "=", "[", "]", ";", "}", "if", "(", "node", ".", "getAttribute", "(", "\"m2\"", ")", ")", "{", "const", "m2data", "=", "transform", "(", "node", ",", "item", ",", "_path", ")", ";", "if", "(", "!", "m2data", "[", "1", "]", ".", "template", "&&", "exist", "[", "1", "]", ".", "type", "!==", "\"switcher\"", ")", "{", "const", "placer", "=", "document", ".", "createElement", "(", "\"div\"", ")", ";", "placer", ".", "setAttribute", "(", "\"data-pid\"", ",", "m2data", "[", "1", "]", ".", "pid", ")", ";", "node", ".", "parentNode", ".", "replaceChild", "(", "placer", ",", "node", ")", ";", "}", "node", ".", "remove", "(", ")", ";", "acc", ".", "push", "(", "m2data", ")", ";", "}", "else", "{", "vertextes", "(", "node", ",", "exist", ",", "item", ",", "_path", ")", ";", "}", "return", "acc", ";", "}", ",", "exist", ")", ";", "}" ]
todo need refactor
[ "todo", "need", "refactor" ]
554203dcc835e4877481f53efc92e04aff79ce4c
https://github.com/artifishional/air-m2/blob/554203dcc835e4877481f53efc92e04aff79ce4c/src/loader/loader.js#L42-L73
train
shapesecurity/shift-scope-js
examples/const.js
declarationImpliesInitialisation
function declarationImpliesInitialisation(variable, scope) { return variable.name === "arguments" && scope.type === ScopeType.FUNCTION || variable.declarations.some(decl => decl.type === DeclarationType.PARAMETER || decl.type === DeclarationType.FUNCTION_NAME || decl.type === DeclarationType.CATCH ); }
javascript
function declarationImpliesInitialisation(variable, scope) { return variable.name === "arguments" && scope.type === ScopeType.FUNCTION || variable.declarations.some(decl => decl.type === DeclarationType.PARAMETER || decl.type === DeclarationType.FUNCTION_NAME || decl.type === DeclarationType.CATCH ); }
[ "function", "declarationImpliesInitialisation", "(", "variable", ",", "scope", ")", "{", "return", "variable", ".", "name", "===", "\"arguments\"", "&&", "scope", ".", "type", "===", "ScopeType", ".", "FUNCTION", "||", "variable", ".", "declarations", ".", "some", "(", "decl", "=>", "decl", ".", "type", "===", "DeclarationType", ".", "PARAMETER", "||", "decl", ".", "type", "===", "DeclarationType", ".", "FUNCTION_NAME", "||", "decl", ".", "type", "===", "DeclarationType", ".", "CATCH", ")", ";", "}" ]
determine if a variable has an implicit initial value
[ "determine", "if", "a", "variable", "has", "an", "implicit", "initial", "value" ]
2a467754fec0e8f0149a08d0a366c2663f0670fd
https://github.com/shapesecurity/shift-scope-js/blob/2a467754fec0e8f0149a08d0a366c2663f0670fd/examples/const.js#L55-L62
train
weepower/wee-core
scripts/core/types.js
_arrEquals
function _arrEquals(a, b) { return a.length == b.length && a.every((el, i) => _equals(el, b[i])); }
javascript
function _arrEquals(a, b) { return a.length == b.length && a.every((el, i) => _equals(el, b[i])); }
[ "function", "_arrEquals", "(", "a", ",", "b", ")", "{", "return", "a", ".", "length", "==", "b", ".", "length", "&&", "a", ".", "every", "(", "(", "el", ",", "i", ")", "=>", "_equals", "(", "el", ",", "b", "[", "i", "]", ")", ")", ";", "}" ]
Compare two arrays for equality @private @param {Array} a @param {Array} b @returns {boolean}
[ "Compare", "two", "arrays", "for", "equality" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/core/types.js#L11-L14
train
weepower/wee-core
scripts/core/types.js
_copy
function _copy(val) { const type = $type(val); if (type == 'object') { val = _extend({}, val, true); } else if (type == 'array') { val = val.slice(0); } return val; }
javascript
function _copy(val) { const type = $type(val); if (type == 'object') { val = _extend({}, val, true); } else if (type == 'array') { val = val.slice(0); } return val; }
[ "function", "_copy", "(", "val", ")", "{", "const", "type", "=", "$type", "(", "val", ")", ";", "if", "(", "type", "==", "'object'", ")", "{", "val", "=", "_extend", "(", "{", "}", ",", "val", ",", "true", ")", ";", "}", "else", "if", "(", "type", "==", "'array'", ")", "{", "val", "=", "val", ".", "slice", "(", "0", ")", ";", "}", "return", "val", ";", "}" ]
Clone value to a new instance @private @param {*} val @returns {*}
[ "Clone", "value", "to", "a", "new", "instance" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/core/types.js#L44-L54
train
weepower/wee-core
scripts/core/types.js
_equals
function _equals(a, b) { if (a === b) { return true; } const aType = $type(a); if (aType != $type(b)) { return false; } if (aType == 'array') { return _arrEquals(a, b); } if (aType == 'object') { return _objEquals(a, b); } if (aType == 'date') { return +a == +b; } return false; }
javascript
function _equals(a, b) { if (a === b) { return true; } const aType = $type(a); if (aType != $type(b)) { return false; } if (aType == 'array') { return _arrEquals(a, b); } if (aType == 'object') { return _objEquals(a, b); } if (aType == 'date') { return +a == +b; } return false; }
[ "function", "_equals", "(", "a", ",", "b", ")", "{", "if", "(", "a", "===", "b", ")", "{", "return", "true", ";", "}", "const", "aType", "=", "$type", "(", "a", ")", ";", "if", "(", "aType", "!=", "$type", "(", "b", ")", ")", "{", "return", "false", ";", "}", "if", "(", "aType", "==", "'array'", ")", "{", "return", "_arrEquals", "(", "a", ",", "b", ")", ";", "}", "if", "(", "aType", "==", "'object'", ")", "{", "return", "_objEquals", "(", "a", ",", "b", ")", ";", "}", "if", "(", "aType", "==", "'date'", ")", "{", "return", "+", "a", "==", "+", "b", ";", "}", "return", "false", ";", "}" ]
Compare two values for equality @private @param {*} a @param {*} b @returns {boolean}
[ "Compare", "two", "values", "for", "equality" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/core/types.js#L64-L88
train
weepower/wee-core
scripts/core/types.js
_objEquals
function _objEquals(a, b) { const aKeys = Object.keys(a); return _arrEquals(aKeys.sort(), Object.keys(b).sort()) && aKeys.every(i => _equals(a[i], b[i])); }
javascript
function _objEquals(a, b) { const aKeys = Object.keys(a); return _arrEquals(aKeys.sort(), Object.keys(b).sort()) && aKeys.every(i => _equals(a[i], b[i])); }
[ "function", "_objEquals", "(", "a", ",", "b", ")", "{", "const", "aKeys", "=", "Object", ".", "keys", "(", "a", ")", ";", "return", "_arrEquals", "(", "aKeys", ".", "sort", "(", ")", ",", "Object", ".", "keys", "(", "b", ")", ".", "sort", "(", ")", ")", "&&", "aKeys", ".", "every", "(", "i", "=>", "_equals", "(", "a", "[", "i", "]", ",", "b", "[", "i", "]", ")", ")", ";", "}" ]
Compare two objects for equality @private @param {Object} a @param {Object} b @returns {boolean}
[ "Compare", "two", "objects", "for", "equality" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/core/types.js#L143-L148
train
kaelzhang/neuron.js
lib/util.js
format_parsed
function format_parsed (parsed) { var pkg = (parsed.s && '@' + parsed.s + '/') + parsed.n + '@' + parsed.v; parsed.id = pkg + parsed.p; parsed.k = pkg; return parsed; }
javascript
function format_parsed (parsed) { var pkg = (parsed.s && '@' + parsed.s + '/') + parsed.n + '@' + parsed.v; parsed.id = pkg + parsed.p; parsed.k = pkg; return parsed; }
[ "function", "format_parsed", "(", "parsed", ")", "{", "var", "pkg", "=", "(", "parsed", ".", "s", "&&", "'@'", "+", "parsed", ".", "s", "+", "'/'", ")", "+", "parsed", ".", "n", "+", "'@'", "+", "parsed", ".", "v", ";", "parsed", ".", "id", "=", "pkg", "+", "parsed", ".", "p", ";", "parsed", ".", "k", "=", "pkg", ";", "return", "parsed", ";", "}" ]
Format package id and pkg `parsed` -> '[email protected]'
[ "Format", "package", "id", "and", "pkg", "parsed", "-", ">", "a" ]
3e1eed28f08ab14f289f476f886ac7f095036e66
https://github.com/kaelzhang/neuron.js/blob/3e1eed28f08ab14f289f476f886ac7f095036e66/lib/util.js#L43-L50
train
kaelzhang/neuron.js
lib/util.js
mix
function mix (receiver, supplier) { for (var key in supplier) { receiver[key] = supplier[key]; } return receiver; }
javascript
function mix (receiver, supplier) { for (var key in supplier) { receiver[key] = supplier[key]; } return receiver; }
[ "function", "mix", "(", "receiver", ",", "supplier", ")", "{", "for", "(", "var", "key", "in", "supplier", ")", "{", "receiver", "[", "key", "]", "=", "supplier", "[", "key", "]", ";", "}", "return", "receiver", ";", "}" ]
A very simple `mix` method copy all properties in the supplier to the receiver @param {Object} receiver @param {Object} supplier @returns {mixed} receiver
[ "A", "very", "simple", "mix", "method", "copy", "all", "properties", "in", "the", "supplier", "to", "the", "receiver" ]
3e1eed28f08ab14f289f476f886ac7f095036e66
https://github.com/kaelzhang/neuron.js/blob/3e1eed28f08ab14f289f476f886ac7f095036e66/lib/util.js#L58-L63
train
weepower/wee-core
scripts/routes/transitions.js
_whichTransitionEvent
function _whichTransitionEvent() { const el = document.createElement('meta'); const animations = { transition: 'transitionend', OTransition: 'oTransitionEnd', MozTransition: 'transitionend', WebkitTransition: 'webkitTransitionEnd', }; for (const t in animations) { if (el.style[t] !== undefined) { return animations[t]; } } }
javascript
function _whichTransitionEvent() { const el = document.createElement('meta'); const animations = { transition: 'transitionend', OTransition: 'oTransitionEnd', MozTransition: 'transitionend', WebkitTransition: 'webkitTransitionEnd', }; for (const t in animations) { if (el.style[t] !== undefined) { return animations[t]; } } }
[ "function", "_whichTransitionEvent", "(", ")", "{", "const", "el", "=", "document", ".", "createElement", "(", "'meta'", ")", ";", "const", "animations", "=", "{", "transition", ":", "'transitionend'", ",", "OTransition", ":", "'oTransitionEnd'", ",", "MozTransition", ":", "'transitionend'", ",", "WebkitTransition", ":", "'webkitTransitionEnd'", ",", "}", ";", "for", "(", "const", "t", "in", "animations", ")", "{", "if", "(", "el", ".", "style", "[", "t", "]", "!==", "undefined", ")", "{", "return", "animations", "[", "t", "]", ";", "}", "}", "}" ]
Detect what transition property to listen for @returns {*} @private
[ "Detect", "what", "transition", "property", "to", "listen", "for" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/routes/transitions.js#L13-L27
train
weepower/wee-core
scripts/wee-screen.js
_addRule
function _addRule(conf) { // Attach unique identifier conf.i = id++; // Only setup watching when enabled if (conf.watch !== false) { events.push(conf); // Only attach event once if (! bound) { const run = _run.bind(this, false, 0, null); bound = 1; events = [conf]; // Attach resize event _win.addEventListener('resize', run); } } // Evaluate rule immediately if not disabled if (conf.init !== false) { _run(true, [conf]); } }
javascript
function _addRule(conf) { // Attach unique identifier conf.i = id++; // Only setup watching when enabled if (conf.watch !== false) { events.push(conf); // Only attach event once if (! bound) { const run = _run.bind(this, false, 0, null); bound = 1; events = [conf]; // Attach resize event _win.addEventListener('resize', run); } } // Evaluate rule immediately if not disabled if (conf.init !== false) { _run(true, [conf]); } }
[ "function", "_addRule", "(", "conf", ")", "{", "conf", ".", "i", "=", "id", "++", ";", "if", "(", "conf", ".", "watch", "!==", "false", ")", "{", "events", ".", "push", "(", "conf", ")", ";", "if", "(", "!", "bound", ")", "{", "const", "run", "=", "_run", ".", "bind", "(", "this", ",", "false", ",", "0", ",", "null", ")", ";", "bound", "=", "1", ";", "events", "=", "[", "conf", "]", ";", "_win", ".", "addEventListener", "(", "'resize'", ",", "run", ")", ";", "}", "}", "if", "(", "conf", ".", "init", "!==", "false", ")", "{", "_run", "(", "true", ",", "[", "conf", "]", ")", ";", "}", "}" ]
Bind individual rule @private @param {Object} conf - breakpoint rules @param {Array} [conf.args] - callback arguments @param {Function} conf.callback @param {boolean} [conf.each=false] - execute for each matching breakpoint @param {boolean} [conf.init=true] - check event on load @param {number} [conf.max] - maximum breakpoint value @param {number} [conf.min] - minimum breakpoint value @param {boolean} [conf.once=false] - only execute the callback once @param {Object} [conf.scope] - callback scope @param {number} [conf.size] - specific breakpoint value @param {boolean} [conf.watch=true] - check event on screen resize @param {string} [conf.namespace] - namespace the event
[ "Bind", "individual", "rule" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-screen.js#L27-L50
train
weepower/wee-core
scripts/wee-screen.js
_eq
function _eq(evt, size, init) { const sz = evt.size; const mn = evt.min; const mx = evt.max; const ex = evt.each || init; // Check match against rules return (! sz && ! mn && ! mx) || (sz && sz === size) || (mn && size >= mn && (ex || current < mn) && (! mx || size <= mx)) || (mx && size <= mx && (ex || current > mx) && (! mn || size >= mn)); }
javascript
function _eq(evt, size, init) { const sz = evt.size; const mn = evt.min; const mx = evt.max; const ex = evt.each || init; // Check match against rules return (! sz && ! mn && ! mx) || (sz && sz === size) || (mn && size >= mn && (ex || current < mn) && (! mx || size <= mx)) || (mx && size <= mx && (ex || current > mx) && (! mn || size >= mn)); }
[ "function", "_eq", "(", "evt", ",", "size", ",", "init", ")", "{", "const", "sz", "=", "evt", ".", "size", ";", "const", "mn", "=", "evt", ".", "min", ";", "const", "mx", "=", "evt", ".", "max", ";", "const", "ex", "=", "evt", ".", "each", "||", "init", ";", "return", "(", "!", "sz", "&&", "!", "mn", "&&", "!", "mx", ")", "||", "(", "sz", "&&", "sz", "===", "size", ")", "||", "(", "mn", "&&", "size", ">=", "mn", "&&", "(", "ex", "||", "current", "<", "mn", ")", "&&", "(", "!", "mx", "||", "size", "<=", "mx", ")", ")", "||", "(", "mx", "&&", "size", "<=", "mx", "&&", "(", "ex", "||", "current", ">", "mx", ")", "&&", "(", "!", "mn", "||", "size", ">=", "mn", ")", ")", ";", "}" ]
Compare event rules against current size @private @param {Object} evt @param {number} size @param {boolean} init @returns {boolean}
[ "Compare", "event", "rules", "against", "current", "size" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-screen.js#L61-L72
train
weepower/wee-core
scripts/wee-screen.js
_run
function _run(init, rules, namespace) { const size = _size(); let evts = rules || events; let i; // If breakpoint has been hit or resize logic initialized if (size && (init || size !== current)) { if (namespace) { evts = evts.filter(obj => obj.namespace === namespace); } i = evts.length; while (i--) { const evt = evts[i]; if (_eq(evt, size, init)) { const f = init && ! current; const data = { dir: f ? 0 : (size > current ? 1 : -1), init: f, prev: current, size, }; $exec(evt.callback, { args: evt.args ? [data].concat(evt.args) : [data], scope: evt.scope, }); // Disable future execution if once if (evt.once) { events = events.filter(obj => obj.i !== evt.i); } } } // Cache current value current = size; } }
javascript
function _run(init, rules, namespace) { const size = _size(); let evts = rules || events; let i; // If breakpoint has been hit or resize logic initialized if (size && (init || size !== current)) { if (namespace) { evts = evts.filter(obj => obj.namespace === namespace); } i = evts.length; while (i--) { const evt = evts[i]; if (_eq(evt, size, init)) { const f = init && ! current; const data = { dir: f ? 0 : (size > current ? 1 : -1), init: f, prev: current, size, }; $exec(evt.callback, { args: evt.args ? [data].concat(evt.args) : [data], scope: evt.scope, }); // Disable future execution if once if (evt.once) { events = events.filter(obj => obj.i !== evt.i); } } } // Cache current value current = size; } }
[ "function", "_run", "(", "init", ",", "rules", ",", "namespace", ")", "{", "const", "size", "=", "_size", "(", ")", ";", "let", "evts", "=", "rules", "||", "events", ";", "let", "i", ";", "if", "(", "size", "&&", "(", "init", "||", "size", "!==", "current", ")", ")", "{", "if", "(", "namespace", ")", "{", "evts", "=", "evts", ".", "filter", "(", "obj", "=>", "obj", ".", "namespace", "===", "namespace", ")", ";", "}", "i", "=", "evts", ".", "length", ";", "while", "(", "i", "--", ")", "{", "const", "evt", "=", "evts", "[", "i", "]", ";", "if", "(", "_eq", "(", "evt", ",", "size", ",", "init", ")", ")", "{", "const", "f", "=", "init", "&&", "!", "current", ";", "const", "data", "=", "{", "dir", ":", "f", "?", "0", ":", "(", "size", ">", "current", "?", "1", ":", "-", "1", ")", ",", "init", ":", "f", ",", "prev", ":", "current", ",", "size", ",", "}", ";", "$exec", "(", "evt", ".", "callback", ",", "{", "args", ":", "evt", ".", "args", "?", "[", "data", "]", ".", "concat", "(", "evt", ".", "args", ")", ":", "[", "data", "]", ",", "scope", ":", "evt", ".", "scope", ",", "}", ")", ";", "if", "(", "evt", ".", "once", ")", "{", "events", "=", "events", ".", "filter", "(", "obj", "=>", "obj", ".", "i", "!==", "evt", ".", "i", ")", ";", "}", "}", "}", "current", "=", "size", ";", "}", "}" ]
Check mapped rules for matching conditions @private @param {boolean} [init=false] - initial page load @param {Array} [rules] - breakpoint rules @param {string} [namespace] - namespace for map object
[ "Check", "mapped", "rules", "for", "matching", "conditions" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-screen.js#L82-L122
train
weepower/wee-core
scripts/wee-routes.js
router
function router(config = {}) { $extend(settings, config); // Update scrollBehavior property in case that was changed history.scrollBehavior = settings.scrollBehavior; history.transition = settings.transition; return router; }
javascript
function router(config = {}) { $extend(settings, config); // Update scrollBehavior property in case that was changed history.scrollBehavior = settings.scrollBehavior; history.transition = settings.transition; return router; }
[ "function", "router", "(", "config", "=", "{", "}", ")", "{", "$extend", "(", "settings", ",", "config", ")", ";", "history", ".", "scrollBehavior", "=", "settings", ".", "scrollBehavior", ";", "history", ".", "transition", "=", "settings", ".", "transition", ";", "return", "router", ";", "}" ]
Set base configurations for router @param {Object} config @returns {router}
[ "Set", "base", "configurations", "for", "router" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-routes.js#L32-L40
train
kaelzhang/neuron.js
lib/define.js
run_callbacks
function run_callbacks (object, key) { var callbacks = object[key]; var callback; // Mark the module is ready // `delete module.c` is not safe // #135 // Android 2.2 might treat `null` as [object Global] and equal it to true, // So, never confuse `null` and `false` object[key] = FALSE; while(callback = callbacks.pop()){ callback(); } }
javascript
function run_callbacks (object, key) { var callbacks = object[key]; var callback; // Mark the module is ready // `delete module.c` is not safe // #135 // Android 2.2 might treat `null` as [object Global] and equal it to true, // So, never confuse `null` and `false` object[key] = FALSE; while(callback = callbacks.pop()){ callback(); } }
[ "function", "run_callbacks", "(", "object", ",", "key", ")", "{", "var", "callbacks", "=", "object", "[", "key", "]", ";", "var", "callback", ";", "object", "[", "key", "]", "=", "FALSE", ";", "while", "(", "callback", "=", "callbacks", ".", "pop", "(", ")", ")", "{", "callback", "(", ")", ";", "}", "}" ]
Run the callbacks
[ "Run", "the", "callbacks" ]
3e1eed28f08ab14f289f476f886ac7f095036e66
https://github.com/kaelzhang/neuron.js/blob/3e1eed28f08ab14f289f476f886ac7f095036e66/lib/define.js#L85-L97
train
shadowgov/envc
lib/parser.js
Parser
function Parser(options) { options = options || {}; // env storage this._env = Object.create(null); // current env this._currEnv = options.currEnv || process.env; // enable/disable booleans this._allowBool = has.call(options, 'booleans') ? options.booleans : false; // enable/disable numbers this._allowNum = has.call(options, 'numbers') ? options.numbers : false; }
javascript
function Parser(options) { options = options || {}; // env storage this._env = Object.create(null); // current env this._currEnv = options.currEnv || process.env; // enable/disable booleans this._allowBool = has.call(options, 'booleans') ? options.booleans : false; // enable/disable numbers this._allowNum = has.call(options, 'numbers') ? options.numbers : false; }
[ "function", "Parser", "(", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "_env", "=", "Object", ".", "create", "(", "null", ")", ";", "this", ".", "_currEnv", "=", "options", ".", "currEnv", "||", "process", ".", "env", ";", "this", ".", "_allowBool", "=", "has", ".", "call", "(", "options", ",", "'booleans'", ")", "?", "options", ".", "booleans", ":", "false", ";", "this", ".", "_allowNum", "=", "has", ".", "call", "(", "options", ",", "'numbers'", ")", "?", "options", ".", "numbers", ":", "false", ";", "}" ]
.env file parser. @constructor
[ ".", "env", "file", "parser", "." ]
a5e998c465197dbd748a5bf58fb4a0896b6fabff
https://github.com/shadowgov/envc/blob/a5e998c465197dbd748a5bf58fb4a0896b6fabff/lib/parser.js#L19-L37
train
shadowgov/envc
lib/parser.js
scan
function scan(str, re) { var match = null; var ret = []; while (match = re.exec(str)) { ret.push(match); } return ret; }
javascript
function scan(str, re) { var match = null; var ret = []; while (match = re.exec(str)) { ret.push(match); } return ret; }
[ "function", "scan", "(", "str", ",", "re", ")", "{", "var", "match", "=", "null", ";", "var", "ret", "=", "[", "]", ";", "while", "(", "match", "=", "re", ".", "exec", "(", "str", ")", ")", "{", "ret", ".", "push", "(", "match", ")", ";", "}", "return", "ret", ";", "}" ]
Scan `str` with `re`. @param {String} str @param {RegExp} re @returns {Array} @private
[ "Scan", "str", "with", "re", "." ]
a5e998c465197dbd748a5bf58fb4a0896b6fabff
https://github.com/shadowgov/envc/blob/a5e998c465197dbd748a5bf58fb4a0896b6fabff/lib/parser.js#L254-L263
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
function() { // First deal only with doc-comments doc_comments = _.filter(docs, function(d) { return d["type"] == "doc_comment"; }); // Detect code in each docset. Sometimes a docset has already // been detected as part of detecting some previous docset (like // Class detecting all of its configs) - in such case, skip. _.each(doc_comments, function(docset) { code = docset["code"]; if ( !(code && code["tagname"]) ) docset["code"] = detect(code); else docset["code"] = ""; }); // Return all doc-comments + other comments for which related // code was detected. return _.filter(docs, function(d) { return d["type"] == "doc_comment" || d["code"] && d["code"]["tagname"]; }); }
javascript
function() { // First deal only with doc-comments doc_comments = _.filter(docs, function(d) { return d["type"] == "doc_comment"; }); // Detect code in each docset. Sometimes a docset has already // been detected as part of detecting some previous docset (like // Class detecting all of its configs) - in such case, skip. _.each(doc_comments, function(docset) { code = docset["code"]; if ( !(code && code["tagname"]) ) docset["code"] = detect(code); else docset["code"] = ""; }); // Return all doc-comments + other comments for which related // code was detected. return _.filter(docs, function(d) { return d["type"] == "doc_comment" || d["code"] && d["code"]["tagname"]; }); }
[ "function", "(", ")", "{", "doc_comments", "=", "_", ".", "filter", "(", "docs", ",", "function", "(", "d", ")", "{", "return", "d", "[", "\"type\"", "]", "==", "\"doc_comment\"", ";", "}", ")", ";", "_", ".", "each", "(", "doc_comments", ",", "function", "(", "docset", ")", "{", "code", "=", "docset", "[", "\"code\"", "]", ";", "if", "(", "!", "(", "code", "&&", "code", "[", "\"tagname\"", "]", ")", ")", "docset", "[", "\"code\"", "]", "=", "detect", "(", "code", ")", ";", "else", "docset", "[", "\"code\"", "]", "=", "\"\"", ";", "}", ")", ";", "return", "_", ".", "filter", "(", "docs", ",", "function", "(", "d", ")", "{", "return", "d", "[", "\"type\"", "]", "==", "\"doc_comment\"", "||", "d", "[", "\"code\"", "]", "&&", "d", "[", "\"code\"", "]", "[", "\"tagname\"", "]", ";", "}", ")", ";", "}" ]
Performs the detection of code in all docsets. @returns the processed array of docsets. (But it does it destructively by modifying the passed-in docsets.)
[ "Performs", "the", "detection", "of", "code", "in", "all", "docsets", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L40-L63
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
detect_class_members_from_object
function detect_class_members_from_object(cls, ast) { cls["members"] = [] return each_pair_in_object_expression(ast, function(key, value, pair) { detect_method_or_property(cls, key, value, pair); }); }
javascript
function detect_class_members_from_object(cls, ast) { cls["members"] = [] return each_pair_in_object_expression(ast, function(key, value, pair) { detect_method_or_property(cls, key, value, pair); }); }
[ "function", "detect_class_members_from_object", "(", "cls", ",", "ast", ")", "{", "cls", "[", "\"members\"", "]", "=", "[", "]", "return", "each_pair_in_object_expression", "(", "ast", ",", "function", "(", "key", ",", "value", ",", "pair", ")", "{", "detect_method_or_property", "(", "cls", ",", "key", ",", "value", ",", "pair", ")", ";", "}", ")", ";", "}" ]
Detects class members from object literal
[ "Detects", "class", "members", "from", "object", "literal" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L303-L308
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
detect_class_members_from_array
function detect_class_members_from_array(cls, ast) { cls["members"] = []; return _.each(ast["elements"], function(el) { detect_method_or_property(cls, key_value(el), el, el); }); }
javascript
function detect_class_members_from_array(cls, ast) { cls["members"] = []; return _.each(ast["elements"], function(el) { detect_method_or_property(cls, key_value(el), el, el); }); }
[ "function", "detect_class_members_from_array", "(", "cls", ",", "ast", ")", "{", "cls", "[", "\"members\"", "]", "=", "[", "]", ";", "return", "_", ".", "each", "(", "ast", "[", "\"elements\"", "]", ",", "function", "(", "el", ")", "{", "detect_method_or_property", "(", "cls", ",", "key_value", "(", "el", ")", ",", "el", ",", "el", ")", ";", "}", ")", ";", "}" ]
Detects class members from array literal
[ "Detects", "class", "members", "from", "array", "literal" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L311-L316
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
detect_method_or_property
function detect_method_or_property(cls, key, value, pair) { if (isFn(value)) { var m = make_method(key, value); if (apply_autodetected(m, pair)) return cls["members"].push(m); } else { var p = make_property(key, value); if (apply_autodetected(p, pair)) return cls["members"].push(p); } }
javascript
function detect_method_or_property(cls, key, value, pair) { if (isFn(value)) { var m = make_method(key, value); if (apply_autodetected(m, pair)) return cls["members"].push(m); } else { var p = make_property(key, value); if (apply_autodetected(p, pair)) return cls["members"].push(p); } }
[ "function", "detect_method_or_property", "(", "cls", ",", "key", ",", "value", ",", "pair", ")", "{", "if", "(", "isFn", "(", "value", ")", ")", "{", "var", "m", "=", "make_method", "(", "key", ",", "value", ")", ";", "if", "(", "apply_autodetected", "(", "m", ",", "pair", ")", ")", "return", "cls", "[", "\"members\"", "]", ".", "push", "(", "m", ")", ";", "}", "else", "{", "var", "p", "=", "make_property", "(", "key", ",", "value", ")", ";", "if", "(", "apply_autodetected", "(", "p", ",", "pair", ")", ")", "return", "cls", "[", "\"members\"", "]", ".", "push", "(", "p", ")", ";", "}", "}" ]
Detects item in object literal either as method or property
[ "Detects", "item", "in", "object", "literal", "either", "as", "method", "or", "property" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L319-L330
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
apply_autodetected
function apply_autodetected(m, ast, inheritable) { docset = find_docset(ast); var inheritable = inheritable || true; if (!docset || docset["type"] != "doc_comment") { if (inheritable) m["inheritdoc"] = {}; else m["private"] = true; m["autodetected"] = true; } if (docset) { docset["code"] = m; return false; } else { // Get line number from third place at range array. // This third item exists in forked EsprimaJS at // https://github.com/nene/esprima/tree/linenr-in-range m["linenr"] = ast["range"][2]; return true; } }
javascript
function apply_autodetected(m, ast, inheritable) { docset = find_docset(ast); var inheritable = inheritable || true; if (!docset || docset["type"] != "doc_comment") { if (inheritable) m["inheritdoc"] = {}; else m["private"] = true; m["autodetected"] = true; } if (docset) { docset["code"] = m; return false; } else { // Get line number from third place at range array. // This third item exists in forked EsprimaJS at // https://github.com/nene/esprima/tree/linenr-in-range m["linenr"] = ast["range"][2]; return true; } }
[ "function", "apply_autodetected", "(", "m", ",", "ast", ",", "inheritable", ")", "{", "docset", "=", "find_docset", "(", "ast", ")", ";", "var", "inheritable", "=", "inheritable", "||", "true", ";", "if", "(", "!", "docset", "||", "docset", "[", "\"type\"", "]", "!=", "\"doc_comment\"", ")", "{", "if", "(", "inheritable", ")", "m", "[", "\"inheritdoc\"", "]", "=", "{", "}", ";", "else", "m", "[", "\"private\"", "]", "=", "true", ";", "m", "[", "\"autodetected\"", "]", "=", "true", ";", "}", "if", "(", "docset", ")", "{", "docset", "[", "\"code\"", "]", "=", "m", ";", "return", "false", ";", "}", "else", "{", "m", "[", "\"linenr\"", "]", "=", "ast", "[", "\"range\"", "]", "[", "2", "]", ";", "return", "true", ";", "}", "}" ]
When member has a comment, adds code to the related docset and returns false. Otherwise detects the line number of member and returns true.
[ "When", "member", "has", "a", "comment", "adds", "code", "to", "the", "related", "docset", "and", "returns", "false", ".", "Otherwise", "detects", "the", "line", "number", "of", "member", "and", "returns", "true", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L413-L437
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js
each_pair_in_object_expression
function each_pair_in_object_expression(ast, func) { if (! (ast && ast["type"] == "ObjectExpression")) { return; } return _.each(ast["properties"], function(p) { isFn(key_value(p["key"]), p["value"], p); }); }
javascript
function each_pair_in_object_expression(ast, func) { if (! (ast && ast["type"] == "ObjectExpression")) { return; } return _.each(ast["properties"], function(p) { isFn(key_value(p["key"]), p["value"], p); }); }
[ "function", "each_pair_in_object_expression", "(", "ast", ",", "func", ")", "{", "if", "(", "!", "(", "ast", "&&", "ast", "[", "\"type\"", "]", "==", "\"ObjectExpression\"", ")", ")", "{", "return", ";", "}", "return", "_", ".", "each", "(", "ast", "[", "\"properties\"", "]", ",", "function", "(", "p", ")", "{", "isFn", "(", "key_value", "(", "p", "[", "\"key\"", "]", ")", ",", "p", "[", "\"value\"", "]", ",", "p", ")", ";", "}", ")", ";", "}" ]
Iterates over keys and values in ObjectExpression. The keys are turned into strings, but values are left as is for further processing.
[ "Iterates", "over", "keys", "and", "values", "in", "ObjectExpression", ".", "The", "keys", "are", "turned", "into", "strings", "but", "values", "are", "left", "as", "is", "for", "further", "processing", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/ast_esprima.js#L512-L520
train
weepower/wee-core
scripts/wee-fetch.js
createFetchInstance
function createFetchInstance(defaultConfig) { const context = fetchFactory(defaultConfig); const instance = bind(context.request, context); // Copy properties from context extend(instance, context, context); return instance; }
javascript
function createFetchInstance(defaultConfig) { const context = fetchFactory(defaultConfig); const instance = bind(context.request, context); // Copy properties from context extend(instance, context, context); return instance; }
[ "function", "createFetchInstance", "(", "defaultConfig", ")", "{", "const", "context", "=", "fetchFactory", "(", "defaultConfig", ")", ";", "const", "instance", "=", "bind", "(", "context", ".", "request", ",", "context", ")", ";", "extend", "(", "instance", ",", "context", ",", "context", ")", ";", "return", "instance", ";", "}" ]
Create a new instance of fetch @param defaultConfig @returns {wrap}
[ "Create", "a", "new", "instance", "of", "fetch" ]
3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4
https://github.com/weepower/wee-core/blob/3ffbb38ce0c9d21b0c5f4aad6b31295d7a2750f4/scripts/wee-fetch.js#L13-L21
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/js_parser.js
line_number
function line_number(index, source) { // To speed things up, remember the index until which we counted, // then next time just begin counting from there. This way we // only count each line once. var i = start_index; var count = 0; while (i < index) { if (source[i] === "\n") { count++; } i++; } start_linenr = count + start_linenr; start_index = index; return start_linenr; }
javascript
function line_number(index, source) { // To speed things up, remember the index until which we counted, // then next time just begin counting from there. This way we // only count each line once. var i = start_index; var count = 0; while (i < index) { if (source[i] === "\n") { count++; } i++; } start_linenr = count + start_linenr; start_index = index; return start_linenr; }
[ "function", "line_number", "(", "index", ",", "source", ")", "{", "var", "i", "=", "start_index", ";", "var", "count", "=", "0", ";", "while", "(", "i", "<", "index", ")", "{", "if", "(", "source", "[", "i", "]", "===", "\"\\n\"", ")", "\\n", "{", "count", "++", ";", "}", "}", "i", "++", ";", "start_linenr", "=", "count", "+", "start_linenr", ";", "start_index", "=", "index", ";", "}" ]
Given index inside input string, returns the corresponding line number
[ "Given", "index", "inside", "input", "string", "returns", "the", "corresponding", "line", "number" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/js_parser.js#L124-L141
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/js_parser.js
stuff_after
function stuff_after(comment, ast) { var code = code_after(comment["range"], ast); if (code && comment["next"]) return code["range"][0] < comment["next"]["range"][0] ? code : ""; else return code; }
javascript
function stuff_after(comment, ast) { var code = code_after(comment["range"], ast); if (code && comment["next"]) return code["range"][0] < comment["next"]["range"][0] ? code : ""; else return code; }
[ "function", "stuff_after", "(", "comment", ",", "ast", ")", "{", "var", "code", "=", "code_after", "(", "comment", "[", "\"range\"", "]", ",", "ast", ")", ";", "if", "(", "code", "&&", "comment", "[", "\"next\"", "]", ")", "return", "code", "[", "\"range\"", "]", "[", "0", "]", "<", "comment", "[", "\"next\"", "]", "[", "\"range\"", "]", "[", "0", "]", "?", "code", ":", "\"\"", ";", "else", "return", "code", ";", "}" ]
Sees if there is some code following the comment. Returns the code found. But if the comment is instead followed by another comment, returns an empty string.
[ "Sees", "if", "there", "is", "some", "code", "following", "the", "comment", ".", "Returns", "the", "code", "found", ".", "But", "if", "the", "comment", "is", "instead", "followed", "by", "another", "comment", "returns", "an", "empty", "string", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/js_parser.js#L146-L153
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/js_parser.js
code_after
function code_after(range, parent) { // Look through all child nodes of parent... var children = child_nodes(parent); for (var i = 0; i < children.length; i++) { if (less(range, children[i]["range"])) { // If node is after our range, then that's it. There could // be comments in our way, but that's taken care of in // #stuff_after method. return children[i]; } else if (within(range, children[i]["range"])) { // Our range is within the node --> recurse return code_after(range, children[i]) } } return; }
javascript
function code_after(range, parent) { // Look through all child nodes of parent... var children = child_nodes(parent); for (var i = 0; i < children.length; i++) { if (less(range, children[i]["range"])) { // If node is after our range, then that's it. There could // be comments in our way, but that's taken care of in // #stuff_after method. return children[i]; } else if (within(range, children[i]["range"])) { // Our range is within the node --> recurse return code_after(range, children[i]) } } return; }
[ "function", "code_after", "(", "range", ",", "parent", ")", "{", "var", "children", "=", "child_nodes", "(", "parent", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "children", ".", "length", ";", "i", "++", ")", "{", "if", "(", "less", "(", "range", ",", "children", "[", "i", "]", "[", "\"range\"", "]", ")", ")", "{", "return", "children", "[", "i", "]", ";", "}", "else", "if", "(", "within", "(", "range", ",", "children", "[", "i", "]", "[", "\"range\"", "]", ")", ")", "{", "return", "code_after", "(", "range", ",", "children", "[", "i", "]", ")", "}", "}", "return", ";", "}" ]
Looks for code following the given range. The second argument is the parent node within which we perform our search.
[ "Looks", "for", "code", "following", "the", "given", "range", ".", "The", "second", "argument", "is", "the", "parent", "node", "within", "which", "we", "perform", "our", "search", "." ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/js_parser.js#L160-L176
train
gjtorikian/panino-docs
lib/panino/plugins/parsers/javascript/jsd/js_parser.js
child_nodes
function child_nodes(node) { var properties = NODE_TYPES[node["type"]]; if (properties === undefined) { console.error("FATAL".red + ": Unknown node type: " + node["type"]); console.trace(); process.exit(1); } var x = properties.map(function(p) { return node[p]; }); return _.flatten(_.compact(x)); }
javascript
function child_nodes(node) { var properties = NODE_TYPES[node["type"]]; if (properties === undefined) { console.error("FATAL".red + ": Unknown node type: " + node["type"]); console.trace(); process.exit(1); } var x = properties.map(function(p) { return node[p]; }); return _.flatten(_.compact(x)); }
[ "function", "child_nodes", "(", "node", ")", "{", "var", "properties", "=", "NODE_TYPES", "[", "node", "[", "\"type\"", "]", "]", ";", "if", "(", "properties", "===", "undefined", ")", "{", "console", ".", "error", "(", "\"FATAL\"", ".", "red", "+", "\": Unknown node type: \"", "+", "node", "[", "\"type\"", "]", ")", ";", "console", ".", "trace", "(", ")", ";", "process", ".", "exit", "(", "1", ")", ";", "}", "var", "x", "=", "properties", ".", "map", "(", "function", "(", "p", ")", "{", "return", "node", "[", "p", "]", ";", "}", ")", ";", "return", "_", ".", "flatten", "(", "_", ".", "compact", "(", "x", ")", ")", ";", "}" ]
Returns array of child nodes of given node
[ "Returns", "array", "of", "child", "nodes", "of", "given", "node" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino/plugins/parsers/javascript/jsd/js_parser.js#L194-L208
train
apostrophecms-legacy/apostrophe-schemas
index.js
function(req, data, name, snippet, field, callback) { var manager = self._pages.getManager(field.withType); if (!manager) { return callback(new Error('join with type ' + field.withType + ' unrecognized')); } var titleOrId = self._apos.sanitizeString(data[name]); var criteria = { $or: [ { sortTitle: self._apos.sortify(titleOrId) }, { _id: titleOrId } ] }; return manager.get(req, criteria, { fields: { _id: 1 } }, function(err, results) { if (err) { return callback(err); } results = results.pages || results.snippets; if (!results.length) { return callback(null); } snippet[field.idField] = results[0]._id; return callback(null); }); }
javascript
function(req, data, name, snippet, field, callback) { var manager = self._pages.getManager(field.withType); if (!manager) { return callback(new Error('join with type ' + field.withType + ' unrecognized')); } var titleOrId = self._apos.sanitizeString(data[name]); var criteria = { $or: [ { sortTitle: self._apos.sortify(titleOrId) }, { _id: titleOrId } ] }; return manager.get(req, criteria, { fields: { _id: 1 } }, function(err, results) { if (err) { return callback(err); } results = results.pages || results.snippets; if (!results.length) { return callback(null); } snippet[field.idField] = results[0]._id; return callback(null); }); }
[ "function", "(", "req", ",", "data", ",", "name", ",", "snippet", ",", "field", ",", "callback", ")", "{", "var", "manager", "=", "self", ".", "_pages", ".", "getManager", "(", "field", ".", "withType", ")", ";", "if", "(", "!", "manager", ")", "{", "return", "callback", "(", "new", "Error", "(", "'join with type '", "+", "field", ".", "withType", "+", "' unrecognized'", ")", ")", ";", "}", "var", "titleOrId", "=", "self", ".", "_apos", ".", "sanitizeString", "(", "data", "[", "name", "]", ")", ";", "var", "criteria", "=", "{", "$or", ":", "[", "{", "sortTitle", ":", "self", ".", "_apos", ".", "sortify", "(", "titleOrId", ")", "}", ",", "{", "_id", ":", "titleOrId", "}", "]", "}", ";", "return", "manager", ".", "get", "(", "req", ",", "criteria", ",", "{", "fields", ":", "{", "_id", ":", "1", "}", "}", ",", "function", "(", "err", ",", "results", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "results", "=", "results", ".", "pages", "||", "results", ".", "snippets", ";", "if", "(", "!", "results", ".", "length", ")", "{", "return", "callback", "(", "null", ")", ";", "}", "snippet", "[", "field", ".", "idField", "]", "=", "results", "[", "0", "]", ".", "_id", ";", "return", "callback", "(", "null", ")", ";", "}", ")", ";", "}" ]
Support for one-to-one joins in CSV imports, by title or id of item joined with. Title match is tolerant
[ "Support", "for", "one", "-", "to", "-", "one", "joins", "in", "CSV", "imports", "by", "title", "or", "id", "of", "item", "joined", "with", ".", "Title", "match", "is", "tolerant" ]
702e30657a38b31fa1005532f2aa487fd153aac7
https://github.com/apostrophecms-legacy/apostrophe-schemas/blob/702e30657a38b31fa1005532f2aa487fd153aac7/index.js#L426-L444
train
apostrophecms-legacy/apostrophe-schemas
index.js
function(req, data, name, snippet, field, callback) { var manager = self._pages.getManager(field.withType); if (!manager) { return callback(new Error('join with type ' + field.withType + ' unrecognized')); } var titlesOrIds = self._apos.sanitizeString(data[name]).split(/\s*,\s*/); if ((!titlesOrIds) || (titlesOrIds[0] === undefined)) { return setImmediate(callback); } var clauses = []; _.each(titlesOrIds, function(titleOrId) { clauses.push({ sortTitle: self._apos.sortify(titleOrId) }); clauses.push({ _id: titleOrId }); }); return manager.get(req, { $or: clauses }, { fields: { _id: 1 }, withJoins: false }, function(err, results) { if (err) { return callback(err); } results = results.pages || results.snippets; if (field.limit !== undefined) { results = results.slice(0, field.limit); } snippet[field.idsField] = _.pluck(results, '_id'); return callback(null); }); }
javascript
function(req, data, name, snippet, field, callback) { var manager = self._pages.getManager(field.withType); if (!manager) { return callback(new Error('join with type ' + field.withType + ' unrecognized')); } var titlesOrIds = self._apos.sanitizeString(data[name]).split(/\s*,\s*/); if ((!titlesOrIds) || (titlesOrIds[0] === undefined)) { return setImmediate(callback); } var clauses = []; _.each(titlesOrIds, function(titleOrId) { clauses.push({ sortTitle: self._apos.sortify(titleOrId) }); clauses.push({ _id: titleOrId }); }); return manager.get(req, { $or: clauses }, { fields: { _id: 1 }, withJoins: false }, function(err, results) { if (err) { return callback(err); } results = results.pages || results.snippets; if (field.limit !== undefined) { results = results.slice(0, field.limit); } snippet[field.idsField] = _.pluck(results, '_id'); return callback(null); }); }
[ "function", "(", "req", ",", "data", ",", "name", ",", "snippet", ",", "field", ",", "callback", ")", "{", "var", "manager", "=", "self", ".", "_pages", ".", "getManager", "(", "field", ".", "withType", ")", ";", "if", "(", "!", "manager", ")", "{", "return", "callback", "(", "new", "Error", "(", "'join with type '", "+", "field", ".", "withType", "+", "' unrecognized'", ")", ")", ";", "}", "var", "titlesOrIds", "=", "self", ".", "_apos", ".", "sanitizeString", "(", "data", "[", "name", "]", ")", ".", "split", "(", "/", "\\s*,\\s*", "/", ")", ";", "if", "(", "(", "!", "titlesOrIds", ")", "||", "(", "titlesOrIds", "[", "0", "]", "===", "undefined", ")", ")", "{", "return", "setImmediate", "(", "callback", ")", ";", "}", "var", "clauses", "=", "[", "]", ";", "_", ".", "each", "(", "titlesOrIds", ",", "function", "(", "titleOrId", ")", "{", "clauses", ".", "push", "(", "{", "sortTitle", ":", "self", ".", "_apos", ".", "sortify", "(", "titleOrId", ")", "}", ")", ";", "clauses", ".", "push", "(", "{", "_id", ":", "titleOrId", "}", ")", ";", "}", ")", ";", "return", "manager", ".", "get", "(", "req", ",", "{", "$or", ":", "clauses", "}", ",", "{", "fields", ":", "{", "_id", ":", "1", "}", ",", "withJoins", ":", "false", "}", ",", "function", "(", "err", ",", "results", ")", "{", "if", "(", "err", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "results", "=", "results", ".", "pages", "||", "results", ".", "snippets", ";", "if", "(", "field", ".", "limit", "!==", "undefined", ")", "{", "results", "=", "results", ".", "slice", "(", "0", ",", "field", ".", "limit", ")", ";", "}", "snippet", "[", "field", ".", "idsField", "]", "=", "_", ".", "pluck", "(", "results", ",", "'_id'", ")", ";", "return", "callback", "(", "null", ")", ";", "}", ")", ";", "}" ]
Support for array joins in CSV imports, by title or id of items joined with, in a comma-separated list. Title match is tolerant, but you must NOT supply any commas that may appear in the titles of the individual items, since commas are reserved for separating items in the list
[ "Support", "for", "array", "joins", "in", "CSV", "imports", "by", "title", "or", "id", "of", "items", "joined", "with", "in", "a", "comma", "-", "separated", "list", ".", "Title", "match", "is", "tolerant", "but", "you", "must", "NOT", "supply", "any", "commas", "that", "may", "appear", "in", "the", "titles", "of", "the", "individual", "items", "since", "commas", "are", "reserved", "for", "separating", "items", "in", "the", "list" ]
702e30657a38b31fa1005532f2aa487fd153aac7
https://github.com/apostrophecms-legacy/apostrophe-schemas/blob/702e30657a38b31fa1005532f2aa487fd153aac7/index.js#L450-L475
train
artifishional/air-m2
src/view/fullscreen_api.js
error
function error() { reject(new TypeError()); doc.removeEventListener(api.events.error, error, false); }
javascript
function error() { reject(new TypeError()); doc.removeEventListener(api.events.error, error, false); }
[ "function", "error", "(", ")", "{", "reject", "(", "new", "TypeError", "(", ")", ")", ";", "doc", ".", "removeEventListener", "(", "api", ".", "events", ".", "error", ",", "error", ",", "false", ")", ";", "}" ]
When receiving an internal fullscreenerror event, reject the promise
[ "When", "receiving", "an", "internal", "fullscreenerror", "event", "reject", "the", "promise" ]
554203dcc835e4877481f53efc92e04aff79ce4c
https://github.com/artifishional/air-m2/blob/554203dcc835e4877481f53efc92e04aff79ce4c/src/view/fullscreen_api.js#L112-L115
train
shapesecurity/shift-scope-js
src/annotate-source.js
insertInto
function insertInto(annotations, index, text, afterExisting) { for (let i = 0; i < annotations.length; ++i) { if (annotations[i].index >= index) { if (afterExisting) { while (i < annotations.length && annotations[i].index === index) { ++i; } } annotations.splice(i, 0, { index, text }); return; } } annotations.push({ index, text }); }
javascript
function insertInto(annotations, index, text, afterExisting) { for (let i = 0; i < annotations.length; ++i) { if (annotations[i].index >= index) { if (afterExisting) { while (i < annotations.length && annotations[i].index === index) { ++i; } } annotations.splice(i, 0, { index, text }); return; } } annotations.push({ index, text }); }
[ "function", "insertInto", "(", "annotations", ",", "index", ",", "text", ",", "afterExisting", ")", "{", "for", "(", "let", "i", "=", "0", ";", "i", "<", "annotations", ".", "length", ";", "++", "i", ")", "{", "if", "(", "annotations", "[", "i", "]", ".", "index", ">=", "index", ")", "{", "if", "(", "afterExisting", ")", "{", "while", "(", "i", "<", "annotations", ".", "length", "&&", "annotations", "[", "i", "]", ".", "index", "===", "index", ")", "{", "++", "i", ";", "}", "}", "annotations", ".", "splice", "(", "i", ",", "0", ",", "{", "index", ",", "text", "}", ")", ";", "return", ";", "}", "}", "annotations", ".", "push", "(", "{", "index", ",", "text", "}", ")", ";", "}" ]
Copyright 2017 Shape Security, Inc. Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
[ "Copyright", "2017", "Shape", "Security", "Inc", "." ]
2a467754fec0e8f0149a08d0a366c2663f0670fd
https://github.com/shapesecurity/shift-scope-js/blob/2a467754fec0e8f0149a08d0a366c2663f0670fd/src/annotate-source.js#L17-L31
train
maxrumsey/hookcord
src/external/discord.js
DiscordJS
function DiscordJS(embed) { if (embed.file) { console.log('Files in embeds will not be sent.'); embed.file = undefined; } return { 'embeds': [ embed, ], }; }
javascript
function DiscordJS(embed) { if (embed.file) { console.log('Files in embeds will not be sent.'); embed.file = undefined; } return { 'embeds': [ embed, ], }; }
[ "function", "DiscordJS", "(", "embed", ")", "{", "if", "(", "embed", ".", "file", ")", "{", "console", ".", "log", "(", "'Files in embeds will not be sent.'", ")", ";", "embed", ".", "file", "=", "undefined", ";", "}", "return", "{", "'embeds'", ":", "[", "embed", ",", "]", ",", "}", ";", "}" ]
Parses Discord.JS embeds and turns them into webhooks. @returns {WebhookJSON} @param {Object} DiscordJSEmbed The {@link https://discord.js.org/#/docs/main/stable/class/RichEmbed|Discord.JS Embed} to pass into the parser. @example var embed = new require('discord.js').RichEmbed(); embed.setTitle('Hello!') let hook = new hookcord.Hook(); hook.login('ID', 'SECRET') .setPayload(hookcord.DiscordJS(embed)); .fire()
[ "Parses", "Discord", ".", "JS", "embeds", "and", "turns", "them", "into", "webhooks", "." ]
ca3cee6b482178a7624a906431a717089748bd49
https://github.com/maxrumsey/hookcord/blob/ca3cee6b482178a7624a906431a717089748bd49/src/external/discord.js#L13-L23
train
gjtorikian/panino-docs
lib/panino.js
parse_files
function parse_files(files, options, callback) { var nodes = { // root section node '': { id: '', type: 'section', children: [], description: '', short_description: '', href: '#', root: true, file: '', line: 0 } }; var reportObject = { }; async.forEachSeries(files, function (file, next_file) { var fn = parsers[path.extname(file)]; if (!fn) { next_file(); return; } console.info('Parsing file: ' + file); fn(file, options, function (err, file_nodes, file_report) { // TODO: fail on name clash here as well -- as we might get name clash // from different parsers, or even different files _.extend(nodes, file_nodes); _.extend(reportObject, file_report); next_file(err); }); }, function (err) { callback(err, nodes, reportObject); }); }
javascript
function parse_files(files, options, callback) { var nodes = { // root section node '': { id: '', type: 'section', children: [], description: '', short_description: '', href: '#', root: true, file: '', line: 0 } }; var reportObject = { }; async.forEachSeries(files, function (file, next_file) { var fn = parsers[path.extname(file)]; if (!fn) { next_file(); return; } console.info('Parsing file: ' + file); fn(file, options, function (err, file_nodes, file_report) { // TODO: fail on name clash here as well -- as we might get name clash // from different parsers, or even different files _.extend(nodes, file_nodes); _.extend(reportObject, file_report); next_file(err); }); }, function (err) { callback(err, nodes, reportObject); }); }
[ "function", "parse_files", "(", "files", ",", "options", ",", "callback", ")", "{", "var", "nodes", "=", "{", "''", ":", "{", "id", ":", "''", ",", "type", ":", "'section'", ",", "children", ":", "[", "]", ",", "description", ":", "''", ",", "short_description", ":", "''", ",", "href", ":", "'#'", ",", "root", ":", "true", ",", "file", ":", "''", ",", "line", ":", "0", "}", "}", ";", "var", "reportObject", "=", "{", "}", ";", "async", ".", "forEachSeries", "(", "files", ",", "function", "(", "file", ",", "next_file", ")", "{", "var", "fn", "=", "parsers", "[", "path", ".", "extname", "(", "file", ")", "]", ";", "if", "(", "!", "fn", ")", "{", "next_file", "(", ")", ";", "return", ";", "}", "console", ".", "info", "(", "'Parsing file: '", "+", "file", ")", ";", "fn", "(", "file", ",", "options", ",", "function", "(", "err", ",", "file_nodes", ",", "file_report", ")", "{", "_", ".", "extend", "(", "nodes", ",", "file_nodes", ")", ";", "_", ".", "extend", "(", "reportObject", ",", "file_report", ")", ";", "next_file", "(", "err", ")", ";", "}", ")", ";", "}", ",", "function", "(", "err", ")", "{", "callback", "(", "err", ",", "nodes", ",", "reportObject", ")", ";", "}", ")", ";", "}" ]
parse all files and prepare a "raw list of nodes
[ "parse", "all", "files", "and", "prepare", "a", "raw", "list", "of", "nodes" ]
23ea0355d42875a59f14a065ac3c06d096112ced
https://github.com/gjtorikian/panino-docs/blob/23ea0355d42875a59f14a065ac3c06d096112ced/lib/panino.js#L38-L75
train
duniter/duniter-ui
index.js
isPortTaken
function isPortTaken(port, fn) { const net = require('net') const tester = net.createServer() .once('error', function (err) { if (err.code != 'EADDRINUSE') return fn(err) fn(null, true) }) .once('listening', function() { tester.once('close', function() { fn(null, false) }) .close() }) .listen(port) }
javascript
function isPortTaken(port, fn) { const net = require('net') const tester = net.createServer() .once('error', function (err) { if (err.code != 'EADDRINUSE') return fn(err) fn(null, true) }) .once('listening', function() { tester.once('close', function() { fn(null, false) }) .close() }) .listen(port) }
[ "function", "isPortTaken", "(", "port", ",", "fn", ")", "{", "const", "net", "=", "require", "(", "'net'", ")", "const", "tester", "=", "net", ".", "createServer", "(", ")", ".", "once", "(", "'error'", ",", "function", "(", "err", ")", "{", "if", "(", "err", ".", "code", "!=", "'EADDRINUSE'", ")", "return", "fn", "(", "err", ")", "fn", "(", "null", ",", "true", ")", "}", ")", ".", "once", "(", "'listening'", ",", "function", "(", ")", "{", "tester", ".", "once", "(", "'close'", ",", "function", "(", ")", "{", "fn", "(", "null", ",", "false", ")", "}", ")", ".", "close", "(", ")", "}", ")", ".", "listen", "(", "port", ")", "}" ]
Checks if a port is already taken by another app. Source: https://gist.github.com/timoxley/1689041 @param port @param fn
[ "Checks", "if", "a", "port", "is", "already", "taken", "by", "another", "app", "." ]
de5c73aa4fe9add95711f3efba2f883645f315d1
https://github.com/duniter/duniter-ui/blob/de5c73aa4fe9add95711f3efba2f883645f315d1/index.js#L145-L157
train