id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
46,600
looeee/npm-three-app
demo/module-import/js/vendor/three.module.js
function ( animation, bones ) { if ( ! animation ) { console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' ); return null; } var addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) { // only return track if there are actually keys. if ( animationKeys.length !== 0 ) { var times = []; var values = []; AnimationUtils.flattenJSON( animationKeys, times, values, propertyName ); // empty keys are filtered out, so check again if ( times.length !== 0 ) { destTracks.push( new trackType( trackName, times, values ) ); } } }; var tracks = []; var clipName = animation.name || 'default'; // automatic length determination in AnimationClip. var duration = animation.length || - 1; var fps = animation.fps || 30; var hierarchyTracks = animation.hierarchy || []; for ( var h = 0; h < hierarchyTracks.length; h ++ ) { var animationKeys = hierarchyTracks[ h ].keys; // skip empty tracks if ( ! animationKeys || animationKeys.length === 0 ) continue; // process morph targets if ( animationKeys[ 0 ].morphTargets ) { // figure out all morph targets used in this track var morphTargetNames = {}; for ( var k = 0; k < animationKeys.length; k ++ ) { if ( animationKeys[ k ].morphTargets ) { for ( var m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) { morphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1; } } } // create a track for each morph target with all zero // morphTargetInfluences except for the keys in which // the morphTarget is named. for ( var morphTargetName in morphTargetNames ) { var times = []; var values = []; for ( var m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) { var animationKey = animationKeys[ k ]; times.push( animationKey.time ); values.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 ); } tracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) ); } duration = morphTargetNames.length * ( fps || 1.0 ); } else { // ...assume skeletal animation var boneName = '.bones[' + bones[ h ].name + ']'; addNonemptyTrack( VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks ); addNonemptyTrack( QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks ); addNonemptyTrack( VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks ); } } if ( tracks.length === 0 ) { return null; } var clip = new AnimationClip( clipName, duration, tracks ); return clip; }
javascript
function ( animation, bones ) { if ( ! animation ) { console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' ); return null; } var addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) { // only return track if there are actually keys. if ( animationKeys.length !== 0 ) { var times = []; var values = []; AnimationUtils.flattenJSON( animationKeys, times, values, propertyName ); // empty keys are filtered out, so check again if ( times.length !== 0 ) { destTracks.push( new trackType( trackName, times, values ) ); } } }; var tracks = []; var clipName = animation.name || 'default'; // automatic length determination in AnimationClip. var duration = animation.length || - 1; var fps = animation.fps || 30; var hierarchyTracks = animation.hierarchy || []; for ( var h = 0; h < hierarchyTracks.length; h ++ ) { var animationKeys = hierarchyTracks[ h ].keys; // skip empty tracks if ( ! animationKeys || animationKeys.length === 0 ) continue; // process morph targets if ( animationKeys[ 0 ].morphTargets ) { // figure out all morph targets used in this track var morphTargetNames = {}; for ( var k = 0; k < animationKeys.length; k ++ ) { if ( animationKeys[ k ].morphTargets ) { for ( var m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) { morphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1; } } } // create a track for each morph target with all zero // morphTargetInfluences except for the keys in which // the morphTarget is named. for ( var morphTargetName in morphTargetNames ) { var times = []; var values = []; for ( var m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) { var animationKey = animationKeys[ k ]; times.push( animationKey.time ); values.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 ); } tracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) ); } duration = morphTargetNames.length * ( fps || 1.0 ); } else { // ...assume skeletal animation var boneName = '.bones[' + bones[ h ].name + ']'; addNonemptyTrack( VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks ); addNonemptyTrack( QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks ); addNonemptyTrack( VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks ); } } if ( tracks.length === 0 ) { return null; } var clip = new AnimationClip( clipName, duration, tracks ); return clip; }
[ "function", "(", "animation", ",", "bones", ")", "{", "if", "(", "!", "animation", ")", "{", "console", ".", "error", "(", "'THREE.AnimationClip: No animation in JSONLoader data.'", ")", ";", "return", "null", ";", "}", "var", "addNonemptyTrack", "=", "function", "(", "trackType", ",", "trackName", ",", "animationKeys", ",", "propertyName", ",", "destTracks", ")", "{", "// only return track if there are actually keys.", "if", "(", "animationKeys", ".", "length", "!==", "0", ")", "{", "var", "times", "=", "[", "]", ";", "var", "values", "=", "[", "]", ";", "AnimationUtils", ".", "flattenJSON", "(", "animationKeys", ",", "times", ",", "values", ",", "propertyName", ")", ";", "// empty keys are filtered out, so check again", "if", "(", "times", ".", "length", "!==", "0", ")", "{", "destTracks", ".", "push", "(", "new", "trackType", "(", "trackName", ",", "times", ",", "values", ")", ")", ";", "}", "}", "}", ";", "var", "tracks", "=", "[", "]", ";", "var", "clipName", "=", "animation", ".", "name", "||", "'default'", ";", "// automatic length determination in AnimationClip.", "var", "duration", "=", "animation", ".", "length", "||", "-", "1", ";", "var", "fps", "=", "animation", ".", "fps", "||", "30", ";", "var", "hierarchyTracks", "=", "animation", ".", "hierarchy", "||", "[", "]", ";", "for", "(", "var", "h", "=", "0", ";", "h", "<", "hierarchyTracks", ".", "length", ";", "h", "++", ")", "{", "var", "animationKeys", "=", "hierarchyTracks", "[", "h", "]", ".", "keys", ";", "// skip empty tracks", "if", "(", "!", "animationKeys", "||", "animationKeys", ".", "length", "===", "0", ")", "continue", ";", "// process morph targets", "if", "(", "animationKeys", "[", "0", "]", ".", "morphTargets", ")", "{", "// figure out all morph targets used in this track", "var", "morphTargetNames", "=", "{", "}", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "animationKeys", ".", "length", ";", "k", "++", ")", "{", "if", "(", "animationKeys", "[", "k", "]", ".", "morphTargets", ")", "{", "for", "(", "var", "m", "=", "0", ";", "m", "<", "animationKeys", "[", "k", "]", ".", "morphTargets", ".", "length", ";", "m", "++", ")", "{", "morphTargetNames", "[", "animationKeys", "[", "k", "]", ".", "morphTargets", "[", "m", "]", "]", "=", "-", "1", ";", "}", "}", "}", "// create a track for each morph target with all zero", "// morphTargetInfluences except for the keys in which", "// the morphTarget is named.", "for", "(", "var", "morphTargetName", "in", "morphTargetNames", ")", "{", "var", "times", "=", "[", "]", ";", "var", "values", "=", "[", "]", ";", "for", "(", "var", "m", "=", "0", ";", "m", "!==", "animationKeys", "[", "k", "]", ".", "morphTargets", ".", "length", ";", "++", "m", ")", "{", "var", "animationKey", "=", "animationKeys", "[", "k", "]", ";", "times", ".", "push", "(", "animationKey", ".", "time", ")", ";", "values", ".", "push", "(", "(", "animationKey", ".", "morphTarget", "===", "morphTargetName", ")", "?", "1", ":", "0", ")", ";", "}", "tracks", ".", "push", "(", "new", "NumberKeyframeTrack", "(", "'.morphTargetInfluence['", "+", "morphTargetName", "+", "']'", ",", "times", ",", "values", ")", ")", ";", "}", "duration", "=", "morphTargetNames", ".", "length", "*", "(", "fps", "||", "1.0", ")", ";", "}", "else", "{", "// ...assume skeletal animation", "var", "boneName", "=", "'.bones['", "+", "bones", "[", "h", "]", ".", "name", "+", "']'", ";", "addNonemptyTrack", "(", "VectorKeyframeTrack", ",", "boneName", "+", "'.position'", ",", "animationKeys", ",", "'pos'", ",", "tracks", ")", ";", "addNonemptyTrack", "(", "QuaternionKeyframeTrack", ",", "boneName", "+", "'.quaternion'", ",", "animationKeys", ",", "'rot'", ",", "tracks", ")", ";", "addNonemptyTrack", "(", "VectorKeyframeTrack", ",", "boneName", "+", "'.scale'", ",", "animationKeys", ",", "'scl'", ",", "tracks", ")", ";", "}", "}", "if", "(", "tracks", ".", "length", "===", "0", ")", "{", "return", "null", ";", "}", "var", "clip", "=", "new", "AnimationClip", "(", "clipName", ",", "duration", ",", "tracks", ")", ";", "return", "clip", ";", "}" ]
parse the animation.hierarchy format
[ "parse", "the", "animation", ".", "hierarchy", "format" ]
439be8d3119bf0f00a7790f77a57ec76fc126580
https://github.com/looeee/npm-three-app/blob/439be8d3119bf0f00a7790f77a57ec76fc126580/demo/module-import/js/vendor/three.module.js#L33468-L33589
46,601
looeee/npm-three-app
demo/module-import/js/vendor/three.module.js
function ( clip, optionalRoot ) { var root = optionalRoot || this._root, rootUuid = root.uuid, clipObject = typeof clip === 'string' ? AnimationClip.findByName( root, clip ) : clip, clipUuid = clipObject ? clipObject.uuid : clip, actionsForClip = this._actionsByClip[ clipUuid ]; if ( actionsForClip !== undefined ) { return actionsForClip.actionByRoot[ rootUuid ] || null; } return null; }
javascript
function ( clip, optionalRoot ) { var root = optionalRoot || this._root, rootUuid = root.uuid, clipObject = typeof clip === 'string' ? AnimationClip.findByName( root, clip ) : clip, clipUuid = clipObject ? clipObject.uuid : clip, actionsForClip = this._actionsByClip[ clipUuid ]; if ( actionsForClip !== undefined ) { return actionsForClip.actionByRoot[ rootUuid ] || null; } return null; }
[ "function", "(", "clip", ",", "optionalRoot", ")", "{", "var", "root", "=", "optionalRoot", "||", "this", ".", "_root", ",", "rootUuid", "=", "root", ".", "uuid", ",", "clipObject", "=", "typeof", "clip", "===", "'string'", "?", "AnimationClip", ".", "findByName", "(", "root", ",", "clip", ")", ":", "clip", ",", "clipUuid", "=", "clipObject", "?", "clipObject", ".", "uuid", ":", "clip", ",", "actionsForClip", "=", "this", ".", "_actionsByClip", "[", "clipUuid", "]", ";", "if", "(", "actionsForClip", "!==", "undefined", ")", "{", "return", "actionsForClip", ".", "actionByRoot", "[", "rootUuid", "]", "||", "null", ";", "}", "return", "null", ";", "}" ]
get an existing action
[ "get", "an", "existing", "action" ]
439be8d3119bf0f00a7790f77a57ec76fc126580
https://github.com/looeee/npm-three-app/blob/439be8d3119bf0f00a7790f77a57ec76fc126580/demo/module-import/js/vendor/three.module.js#L42945-L42965
46,602
looeee/npm-three-app
demo/module-import/js/vendor/three.module.js
function ( deltaTime ) { deltaTime *= this.timeScale; var actions = this._actions, nActions = this._nActiveActions, time = this.time += deltaTime, timeDirection = Math.sign( deltaTime ), accuIndex = this._accuIndex ^= 1; // run active actions for ( var i = 0; i !== nActions; ++ i ) { var action = actions[ i ]; action._update( time, deltaTime, timeDirection, accuIndex ); } // update scene graph var bindings = this._bindings, nBindings = this._nActiveBindings; for ( var i = 0; i !== nBindings; ++ i ) { bindings[ i ].apply( accuIndex ); } return this; }
javascript
function ( deltaTime ) { deltaTime *= this.timeScale; var actions = this._actions, nActions = this._nActiveActions, time = this.time += deltaTime, timeDirection = Math.sign( deltaTime ), accuIndex = this._accuIndex ^= 1; // run active actions for ( var i = 0; i !== nActions; ++ i ) { var action = actions[ i ]; action._update( time, deltaTime, timeDirection, accuIndex ); } // update scene graph var bindings = this._bindings, nBindings = this._nActiveBindings; for ( var i = 0; i !== nBindings; ++ i ) { bindings[ i ].apply( accuIndex ); } return this; }
[ "function", "(", "deltaTime", ")", "{", "deltaTime", "*=", "this", ".", "timeScale", ";", "var", "actions", "=", "this", ".", "_actions", ",", "nActions", "=", "this", ".", "_nActiveActions", ",", "time", "=", "this", ".", "time", "+=", "deltaTime", ",", "timeDirection", "=", "Math", ".", "sign", "(", "deltaTime", ")", ",", "accuIndex", "=", "this", ".", "_accuIndex", "^=", "1", ";", "// run active actions", "for", "(", "var", "i", "=", "0", ";", "i", "!==", "nActions", ";", "++", "i", ")", "{", "var", "action", "=", "actions", "[", "i", "]", ";", "action", ".", "_update", "(", "time", ",", "deltaTime", ",", "timeDirection", ",", "accuIndex", ")", ";", "}", "// update scene graph", "var", "bindings", "=", "this", ".", "_bindings", ",", "nBindings", "=", "this", ".", "_nActiveBindings", ";", "for", "(", "var", "i", "=", "0", ";", "i", "!==", "nBindings", ";", "++", "i", ")", "{", "bindings", "[", "i", "]", ".", "apply", "(", "accuIndex", ")", ";", "}", "return", "this", ";", "}" ]
advance the time and update apply the animation
[ "advance", "the", "time", "and", "update", "apply", "the", "animation" ]
439be8d3119bf0f00a7790f77a57ec76fc126580
https://github.com/looeee/npm-three-app/blob/439be8d3119bf0f00a7790f77a57ec76fc126580/demo/module-import/js/vendor/three.module.js#L42995-L43030
46,603
ifraixedes/node-hmac-validator
src/hmac-validator.js
checkConfig
function checkConfig(config) { let requiredProps = ['algorithm', 'format']; const errMsg = `Configuration isn't an object with the required properties: ${requiredProps.join(', ')}`; if ((!config) || (typeof config !== 'object')) { throw new Error(errMsg); } requiredProps.forEach(p => { if (!config[p]) { throw new Error(errMsg); } }); }
javascript
function checkConfig(config) { let requiredProps = ['algorithm', 'format']; const errMsg = `Configuration isn't an object with the required properties: ${requiredProps.join(', ')}`; if ((!config) || (typeof config !== 'object')) { throw new Error(errMsg); } requiredProps.forEach(p => { if (!config[p]) { throw new Error(errMsg); } }); }
[ "function", "checkConfig", "(", "config", ")", "{", "let", "requiredProps", "=", "[", "'algorithm'", ",", "'format'", "]", ";", "const", "errMsg", "=", "`", "${", "requiredProps", ".", "join", "(", "', '", ")", "}", "`", ";", "if", "(", "(", "!", "config", ")", "||", "(", "typeof", "config", "!==", "'object'", ")", ")", "{", "throw", "new", "Error", "(", "errMsg", ")", ";", "}", "requiredProps", ".", "forEach", "(", "p", "=>", "{", "if", "(", "!", "config", "[", "p", "]", ")", "{", "throw", "new", "Error", "(", "errMsg", ")", ";", "}", "}", ")", ";", "}" ]
Makes basic checks on Hmac validator configuration like required parameters. @param {Object} config - The configuration used to create a new Hmac validator @throws {Error} When one of the checks fails
[ "Makes", "basic", "checks", "on", "Hmac", "validator", "configuration", "like", "required", "parameters", "." ]
995c0d17ca0acd2bfcad895b2dde9a6c833fb570
https://github.com/ifraixedes/node-hmac-validator/blob/995c0d17ca0acd2bfcad895b2dde9a6c833fb570/src/hmac-validator.js#L79-L92
46,604
iamso/u.js
dist/u.packed.js
function(arg) { return /^f/.test(typeof arg) ? /c/.test(document.readyState) ? arg() : u._defInit.push(arg) : new Init(arg); }
javascript
function(arg) { return /^f/.test(typeof arg) ? /c/.test(document.readyState) ? arg() : u._defInit.push(arg) : new Init(arg); }
[ "function", "(", "arg", ")", "{", "return", "/", "^f", "/", ".", "test", "(", "typeof", "arg", ")", "?", "/", "c", "/", ".", "test", "(", "document", ".", "readyState", ")", "?", "arg", "(", ")", ":", "u", ".", "_defInit", ".", "push", "(", "arg", ")", ":", "new", "Init", "(", "arg", ")", ";", "}" ]
u main function @param {(string|object|function)} arg - selector, dom element or function @return {(object|undefined)} instance or execute function on dom ready
[ "u", "main", "function" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L41-L43
46,605
iamso/u.js
dist/u.packed.js
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; fn = handler; } else if (/^s/.test(typeof selector)) { fn = handler; handler = function(e) { var element; if (u(e.target).is(selector)) { element = e.target; } else if (u(e.target).parents(selector).length) { element = u(e.target).parents(selector)[0]; } if (element) { fn.apply(element, [e]); } }; } return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event){ u._events.add(el, event, fn, handler); el.addEventListener(event, function temp(e) { el.removeEventListener(event, temp); u._events.remove(el, event, fn); handler.call(this,e); }); }); }); }
javascript
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; fn = handler; } else if (/^s/.test(typeof selector)) { fn = handler; handler = function(e) { var element; if (u(e.target).is(selector)) { element = e.target; } else if (u(e.target).parents(selector).length) { element = u(e.target).parents(selector)[0]; } if (element) { fn.apply(element, [e]); } }; } return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event){ u._events.add(el, event, fn, handler); el.addEventListener(event, function temp(e) { el.removeEventListener(event, temp); u._events.remove(el, event, fn); handler.call(this,e); }); }); }); }
[ "function", "(", "event", ",", "selector", ",", "handler", ",", "fn", ")", "{", "if", "(", "/", "^f", "/", ".", "test", "(", "typeof", "selector", ")", ")", "{", "handler", "=", "selector", ";", "fn", "=", "handler", ";", "}", "else", "if", "(", "/", "^s", "/", ".", "test", "(", "typeof", "selector", ")", ")", "{", "fn", "=", "handler", ";", "handler", "=", "function", "(", "e", ")", "{", "var", "element", ";", "if", "(", "u", "(", "e", ".", "target", ")", ".", "is", "(", "selector", ")", ")", "{", "element", "=", "e", ".", "target", ";", "}", "else", "if", "(", "u", "(", "e", ".", "target", ")", ".", "parents", "(", "selector", ")", ".", "length", ")", "{", "element", "=", "u", "(", "e", ".", "target", ")", ".", "parents", "(", "selector", ")", "[", "0", "]", ";", "}", "if", "(", "element", ")", "{", "fn", ".", "apply", "(", "element", ",", "[", "e", "]", ")", ";", "}", "}", ";", "}", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "var", "events", "=", "event", ".", "split", "(", "' '", ")", ";", "u", ".", "each", "(", "events", ",", "function", "(", "i", ",", "event", ")", "{", "u", ".", "_events", ".", "add", "(", "el", ",", "event", ",", "fn", ",", "handler", ")", ";", "el", ".", "addEventListener", "(", "event", ",", "function", "temp", "(", "e", ")", "{", "el", ".", "removeEventListener", "(", "event", ",", "temp", ")", ";", "u", ".", "_events", ".", "remove", "(", "el", ",", "event", ",", "fn", ")", ";", "handler", ".", "call", "(", "this", ",", "e", ")", ";", "}", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
one method add one time event listeners to elements @param {string} event - event type i.e 'click' @param {function} handler - event handler function @return {object} this
[ "one", "method", "add", "one", "time", "event", "listeners", "to", "elements" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L724-L755
46,606
iamso/u.js
dist/u.packed.js
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; } fn = handler; return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event, origEvent){ origEvent = u._events.remove(el, event, fn); handler = origEvent.length ? origEvent[0].handler : handler; el.removeEventListener(event, handler); }); }); }
javascript
function(event, selector, handler, fn) { if (/^f/.test(typeof selector)) { handler = selector; } fn = handler; return this.each(function(index, el) { var events = event.split(' '); u.each(events, function(i, event, origEvent){ origEvent = u._events.remove(el, event, fn); handler = origEvent.length ? origEvent[0].handler : handler; el.removeEventListener(event, handler); }); }); }
[ "function", "(", "event", ",", "selector", ",", "handler", ",", "fn", ")", "{", "if", "(", "/", "^f", "/", ".", "test", "(", "typeof", "selector", ")", ")", "{", "handler", "=", "selector", ";", "}", "fn", "=", "handler", ";", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "var", "events", "=", "event", ".", "split", "(", "' '", ")", ";", "u", ".", "each", "(", "events", ",", "function", "(", "i", ",", "event", ",", "origEvent", ")", "{", "origEvent", "=", "u", ".", "_events", ".", "remove", "(", "el", ",", "event", ",", "fn", ")", ";", "handler", "=", "origEvent", ".", "length", "?", "origEvent", "[", "0", "]", ".", "handler", ":", "handler", ";", "el", ".", "removeEventListener", "(", "event", ",", "handler", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
off method remove event listeners from elements @param {string} event - event type i.e 'click' @param {function} handler - event handler function @return {object} this
[ "off", "method", "remove", "event", "listeners", "from", "elements" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L765-L778
46,607
iamso/u.js
dist/u.packed.js
function(e, data, evt) { if (/^f/.test(typeof CustomEvent)) { evt = new CustomEvent(e, { detail: data, bubbles: true, cancelable: false }); } else { evt = document.createEvent('CustomEvent'); evt.initCustomEvent(e, true, false, data); } return this.each(function(index, el) { el.dispatchEvent ? el.dispatchEvent(evt) : el.fireEvent('on' + e, evt); }); }
javascript
function(e, data, evt) { if (/^f/.test(typeof CustomEvent)) { evt = new CustomEvent(e, { detail: data, bubbles: true, cancelable: false }); } else { evt = document.createEvent('CustomEvent'); evt.initCustomEvent(e, true, false, data); } return this.each(function(index, el) { el.dispatchEvent ? el.dispatchEvent(evt) : el.fireEvent('on' + e, evt); }); }
[ "function", "(", "e", ",", "data", ",", "evt", ")", "{", "if", "(", "/", "^f", "/", ".", "test", "(", "typeof", "CustomEvent", ")", ")", "{", "evt", "=", "new", "CustomEvent", "(", "e", ",", "{", "detail", ":", "data", ",", "bubbles", ":", "true", ",", "cancelable", ":", "false", "}", ")", ";", "}", "else", "{", "evt", "=", "document", ".", "createEvent", "(", "'CustomEvent'", ")", ";", "evt", ".", "initCustomEvent", "(", "e", ",", "true", ",", "false", ",", "data", ")", ";", "}", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "dispatchEvent", "?", "el", ".", "dispatchEvent", "(", "evt", ")", ":", "el", ".", "fireEvent", "(", "'on'", "+", "e", ",", "evt", ")", ";", "}", ")", ";", "}" ]
trigger method trigger an event for an element @param {string} e - event name @param {string} [data] - custom data @param {string} evt - placeholder for the event object @return {object} this
[ "trigger", "method", "trigger", "an", "event", "for", "an", "element" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L789-L806
46,608
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? (this[0].scrollTop !== undefined ? this[0].scrollTop : (this[0].scrollY || this[0].pageYOffset)) : 0) : this.each(function(index, el) { el.scrollTop === undefined || el.scrollTo !== undefined ? el.scrollTo(0, val) : el.scrollTop = val; }); }
javascript
function(val) { return val === undefined ? (this.length ? (this[0].scrollTop !== undefined ? this[0].scrollTop : (this[0].scrollY || this[0].pageYOffset)) : 0) : this.each(function(index, el) { el.scrollTop === undefined || el.scrollTo !== undefined ? el.scrollTo(0, val) : el.scrollTop = val; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "(", "this", "[", "0", "]", ".", "scrollTop", "!==", "undefined", "?", "this", "[", "0", "]", ".", "scrollTop", ":", "(", "this", "[", "0", "]", ".", "scrollY", "||", "this", "[", "0", "]", ".", "pageYOffset", ")", ")", ":", "0", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "scrollTop", "===", "undefined", "||", "el", ".", "scrollTo", "!==", "undefined", "?", "el", ".", "scrollTo", "(", "0", ",", "val", ")", ":", "el", ".", "scrollTop", "=", "val", ";", "}", ")", ";", "}" ]
scrollTop method get or set element scrollTop @param {number} [val] - new scrollTop @return {number} scrollTop
[ "scrollTop", "method", "get", "or", "set", "element", "scrollTop" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L856-L860
46,609
iamso/u.js
dist/u.packed.js
function(to, duration, callback) { return this.each(function(index, el) { var _el = u(el), start = _el.scrollTop(), change = to - start, currentTime = 0, increment = 20; duration = duration || 1500; function easing(t, b, c, d) { t /= d/2; if (t < 1) { return c/2 * Math.pow( 2, 10 * (t - 1) ) + b; } t--; return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b; } function animateScroll() { currentTime += increment; var val = easing(currentTime, start, change, duration); _el.scrollTop(val); if (currentTime < duration) { requestAnimationFrame(animateScroll); } else { callback && callback.apply(window); } } animateScroll(); }); }
javascript
function(to, duration, callback) { return this.each(function(index, el) { var _el = u(el), start = _el.scrollTop(), change = to - start, currentTime = 0, increment = 20; duration = duration || 1500; function easing(t, b, c, d) { t /= d/2; if (t < 1) { return c/2 * Math.pow( 2, 10 * (t - 1) ) + b; } t--; return c/2 * ( -Math.pow( 2, -10 * t) + 2 ) + b; } function animateScroll() { currentTime += increment; var val = easing(currentTime, start, change, duration); _el.scrollTop(val); if (currentTime < duration) { requestAnimationFrame(animateScroll); } else { callback && callback.apply(window); } } animateScroll(); }); }
[ "function", "(", "to", ",", "duration", ",", "callback", ")", "{", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "var", "_el", "=", "u", "(", "el", ")", ",", "start", "=", "_el", ".", "scrollTop", "(", ")", ",", "change", "=", "to", "-", "start", ",", "currentTime", "=", "0", ",", "increment", "=", "20", ";", "duration", "=", "duration", "||", "1500", ";", "function", "easing", "(", "t", ",", "b", ",", "c", ",", "d", ")", "{", "t", "/=", "d", "/", "2", ";", "if", "(", "t", "<", "1", ")", "{", "return", "c", "/", "2", "*", "Math", ".", "pow", "(", "2", ",", "10", "*", "(", "t", "-", "1", ")", ")", "+", "b", ";", "}", "t", "--", ";", "return", "c", "/", "2", "*", "(", "-", "Math", ".", "pow", "(", "2", ",", "-", "10", "*", "t", ")", "+", "2", ")", "+", "b", ";", "}", "function", "animateScroll", "(", ")", "{", "currentTime", "+=", "increment", ";", "var", "val", "=", "easing", "(", "currentTime", ",", "start", ",", "change", ",", "duration", ")", ";", "_el", ".", "scrollTop", "(", "val", ")", ";", "if", "(", "currentTime", "<", "duration", ")", "{", "requestAnimationFrame", "(", "animateScroll", ")", ";", "}", "else", "{", "callback", "&&", "callback", ".", "apply", "(", "window", ")", ";", "}", "}", "animateScroll", "(", ")", ";", "}", ")", ";", "}" ]
scrollTo method scroll to a certain position inside the element @param {number} to - position to scroll to @param {number} duration - duration for the animation @param {function} callback - function to call when finished @return {object} this
[ "scrollTo", "method", "scroll", "to", "a", "certain", "position", "inside", "the", "element" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L871-L901
46,610
iamso/u.js
dist/u.packed.js
function(duration, callback) { return this.each(function(index, el) { u(el).scrollTo(0, duration, callback); }); }
javascript
function(duration, callback) { return this.each(function(index, el) { u(el).scrollTo(0, duration, callback); }); }
[ "function", "(", "duration", ",", "callback", ")", "{", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "u", "(", "el", ")", ".", "scrollTo", "(", "0", ",", "duration", ",", "callback", ")", ";", "}", ")", ";", "}" ]
scrollToTop method shortcut for scroll to 0 @param {number} duration - duration for the animation @param {function} callback - function to call when finished @return {object} this
[ "scrollToTop", "method", "shortcut", "for", "scroll", "to", "0" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L911-L915
46,611
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].clientWidth || this[0].innerWidth : 0) : this.each(function(index, el) { el.style.width = val + 'px'; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].clientWidth || this[0].innerWidth : 0) : this.each(function(index, el) { el.style.width = val + 'px'; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "clientWidth", "||", "this", "[", "0", "]", ".", "innerWidth", ":", "0", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "style", ".", "width", "=", "val", "+", "'px'", ";", "}", ")", ";", "}" ]
width method get or set element width @param {number} [val] - new width @return {number} width
[ "width", "method", "get", "or", "set", "element", "width" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L924-L928
46,612
iamso/u.js
dist/u.packed.js
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetWidth + parseInt(getComputedStyle(this[0]).marginLeft) + parseInt(getComputedStyle(this[0]).marginRight) : this[0].offsetWidth; }
javascript
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetWidth + parseInt(getComputedStyle(this[0]).marginLeft) + parseInt(getComputedStyle(this[0]).marginRight) : this[0].offsetWidth; }
[ "function", "(", "margin", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "0", ";", "}", "return", "margin", "?", "this", "[", "0", "]", ".", "offsetWidth", "+", "parseInt", "(", "getComputedStyle", "(", "this", "[", "0", "]", ")", ".", "marginLeft", ")", "+", "parseInt", "(", "getComputedStyle", "(", "this", "[", "0", "]", ")", ".", "marginRight", ")", ":", "this", "[", "0", "]", ".", "offsetWidth", ";", "}" ]
outerWidth method get element outer width @param {boolean} [margin] - if true, includes margin @return {number} outerWidth
[ "outerWidth", "method", "get", "element", "outer", "width" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L937-L942
46,613
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].clientHeight || this[0].innerHeight : 0) : this.each(function(index, el) { el.style.height = val + 'px'; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].clientHeight || this[0].innerHeight : 0) : this.each(function(index, el) { el.style.height = val + 'px'; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "clientHeight", "||", "this", "[", "0", "]", ".", "innerHeight", ":", "0", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "style", ".", "height", "=", "val", "+", "'px'", ";", "}", ")", ";", "}" ]
height method get or set element height @param {number} [val] - new height @return {number} height
[ "height", "method", "get", "or", "set", "element", "height" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L951-L955
46,614
iamso/u.js
dist/u.packed.js
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetHeight + parseInt(getComputedStyle(this[0]).marginTop) + parseInt(getComputedStyle(this[0]).marginBottom) : this[0].offsetHeight; }
javascript
function(margin) { if (!this.length) { return 0; } return margin ? this[0].offsetHeight + parseInt(getComputedStyle(this[0]).marginTop) + parseInt(getComputedStyle(this[0]).marginBottom) : this[0].offsetHeight; }
[ "function", "(", "margin", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "0", ";", "}", "return", "margin", "?", "this", "[", "0", "]", ".", "offsetHeight", "+", "parseInt", "(", "getComputedStyle", "(", "this", "[", "0", "]", ")", ".", "marginTop", ")", "+", "parseInt", "(", "getComputedStyle", "(", "this", "[", "0", "]", ")", ".", "marginBottom", ")", ":", "this", "[", "0", "]", ".", "offsetHeight", ";", "}" ]
outerHeight method get element outer height @param {boolean} [margin] - if true, includes margin @return {number} outerHeight
[ "outerHeight", "method", "get", "element", "outer", "height" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L964-L969
46,615
iamso/u.js
dist/u.packed.js
function(attr, val) { return val === undefined ? (this.length ? this[0].getAttribute(attr) : null) : this.each(function(index, el) { el.setAttribute(attr, val); }); }
javascript
function(attr, val) { return val === undefined ? (this.length ? this[0].getAttribute(attr) : null) : this.each(function(index, el) { el.setAttribute(attr, val); }); }
[ "function", "(", "attr", ",", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "getAttribute", "(", "attr", ")", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "setAttribute", "(", "attr", ",", "val", ")", ";", "}", ")", ";", "}" ]
attr method get or set an attribute @param {string} attr - attribute name @param {string} [val] - attribute value @return {(string|object)} attribute value or this
[ "attr", "method", "get", "or", "set", "an", "attribute" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1003-L1007
46,616
iamso/u.js
dist/u.packed.js
function(prop, val) { return val === undefined ? (this.length ? this[0][prop] : null) : this.each(function(index, el) { el[prop] = val; }); }
javascript
function(prop, val) { return val === undefined ? (this.length ? this[0][prop] : null) : this.each(function(index, el) { el[prop] = val; }); }
[ "function", "(", "prop", ",", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", "[", "prop", "]", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", "[", "prop", "]", "=", "val", ";", "}", ")", ";", "}" ]
prop method get or set a property of the underlying DOM object @param {string} prop - property name @param {string} [val] - property value @return {(string|object)} property value or this
[ "prop", "method", "get", "or", "set", "a", "property", "of", "the", "underlying", "DOM", "object" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1041-L1045
46,617
iamso/u.js
dist/u.packed.js
function(attr, val, el, index, obj, attrCamel) { if (attr === undefined) { if (!this.length) { return {}; } el = this[0]; obj = u.extend({}, el.dataset || {}); if ((index = el[u._id]) === undefined) { el[u._id] = index = u._data.push(obj) - 1; return obj; } else { return u._data[index] = u.extend({}, obj, u._data[index]); } } else { attrCamel = u.toCamel(u.toDash(attr)); if (val === undefined) { if (!this.length) { return null; } el = this[0]; if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr); el[u._id] = index = u._data.push(obj) - 1; return obj[attrCamel]; } else { return !!u._data[index][attrCamel] ? u._data[index][attrCamel] : (u._data[index][attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr)); } } else { return this.each(function(index, el) { if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = val; el[u._id] = index = u._data.push(obj) - 1; } else { u._data[index][attrCamel] = val; } }); } } }
javascript
function(attr, val, el, index, obj, attrCamel) { if (attr === undefined) { if (!this.length) { return {}; } el = this[0]; obj = u.extend({}, el.dataset || {}); if ((index = el[u._id]) === undefined) { el[u._id] = index = u._data.push(obj) - 1; return obj; } else { return u._data[index] = u.extend({}, obj, u._data[index]); } } else { attrCamel = u.toCamel(u.toDash(attr)); if (val === undefined) { if (!this.length) { return null; } el = this[0]; if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr); el[u._id] = index = u._data.push(obj) - 1; return obj[attrCamel]; } else { return !!u._data[index][attrCamel] ? u._data[index][attrCamel] : (u._data[index][attrCamel] = el.dataset ? el.dataset[attrCamel] : el.getAttribute('data-' + attr)); } } else { return this.each(function(index, el) { if ((index = el[u._id]) === undefined) { obj = {}; obj[attrCamel] = val; el[u._id] = index = u._data.push(obj) - 1; } else { u._data[index][attrCamel] = val; } }); } } }
[ "function", "(", "attr", ",", "val", ",", "el", ",", "index", ",", "obj", ",", "attrCamel", ")", "{", "if", "(", "attr", "===", "undefined", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "{", "}", ";", "}", "el", "=", "this", "[", "0", "]", ";", "obj", "=", "u", ".", "extend", "(", "{", "}", ",", "el", ".", "dataset", "||", "{", "}", ")", ";", "if", "(", "(", "index", "=", "el", "[", "u", ".", "_id", "]", ")", "===", "undefined", ")", "{", "el", "[", "u", ".", "_id", "]", "=", "index", "=", "u", ".", "_data", ".", "push", "(", "obj", ")", "-", "1", ";", "return", "obj", ";", "}", "else", "{", "return", "u", ".", "_data", "[", "index", "]", "=", "u", ".", "extend", "(", "{", "}", ",", "obj", ",", "u", ".", "_data", "[", "index", "]", ")", ";", "}", "}", "else", "{", "attrCamel", "=", "u", ".", "toCamel", "(", "u", ".", "toDash", "(", "attr", ")", ")", ";", "if", "(", "val", "===", "undefined", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "null", ";", "}", "el", "=", "this", "[", "0", "]", ";", "if", "(", "(", "index", "=", "el", "[", "u", ".", "_id", "]", ")", "===", "undefined", ")", "{", "obj", "=", "{", "}", ";", "obj", "[", "attrCamel", "]", "=", "el", ".", "dataset", "?", "el", ".", "dataset", "[", "attrCamel", "]", ":", "el", ".", "getAttribute", "(", "'data-'", "+", "attr", ")", ";", "el", "[", "u", ".", "_id", "]", "=", "index", "=", "u", ".", "_data", ".", "push", "(", "obj", ")", "-", "1", ";", "return", "obj", "[", "attrCamel", "]", ";", "}", "else", "{", "return", "!", "!", "u", ".", "_data", "[", "index", "]", "[", "attrCamel", "]", "?", "u", ".", "_data", "[", "index", "]", "[", "attrCamel", "]", ":", "(", "u", ".", "_data", "[", "index", "]", "[", "attrCamel", "]", "=", "el", ".", "dataset", "?", "el", ".", "dataset", "[", "attrCamel", "]", ":", "el", ".", "getAttribute", "(", "'data-'", "+", "attr", ")", ")", ";", "}", "}", "else", "{", "return", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "if", "(", "(", "index", "=", "el", "[", "u", ".", "_id", "]", ")", "===", "undefined", ")", "{", "obj", "=", "{", "}", ";", "obj", "[", "attrCamel", "]", "=", "val", ";", "el", "[", "u", ".", "_id", "]", "=", "index", "=", "u", ".", "_data", ".", "push", "(", "obj", ")", "-", "1", ";", "}", "else", "{", "u", ".", "_data", "[", "index", "]", "[", "attrCamel", "]", "=", "val", ";", "}", "}", ")", ";", "}", "}", "}" ]
data method get or set a data attribute @param {string} attr - attribute name @param {string} [val] - attribute value @param {undefined} [el] - element placeholder @param {undefined} [index] - index placeholder @param {undefined} [obj] - object placeholder @param {undefined} [attrCamel] - placeholder for attribute name in camelCase @return {(string|object)} attribute value or this
[ "data", "method", "get", "or", "set", "a", "data", "attribute" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1059-L1107
46,618
iamso/u.js
dist/u.packed.js
function(attr, index, attrCamel) { return this.each(function(i, el) { if (attr !== undefined) { attrCamel = u.toCamel(u.toDash(attr)); if ((index = el[u._id]) !== undefined) { el.dataset ? delete el.dataset[attrCamel] : el.removeAttribute('data-' + attr); delete u._data[index][attrCamel]; } } }); }
javascript
function(attr, index, attrCamel) { return this.each(function(i, el) { if (attr !== undefined) { attrCamel = u.toCamel(u.toDash(attr)); if ((index = el[u._id]) !== undefined) { el.dataset ? delete el.dataset[attrCamel] : el.removeAttribute('data-' + attr); delete u._data[index][attrCamel]; } } }); }
[ "function", "(", "attr", ",", "index", ",", "attrCamel", ")", "{", "return", "this", ".", "each", "(", "function", "(", "i", ",", "el", ")", "{", "if", "(", "attr", "!==", "undefined", ")", "{", "attrCamel", "=", "u", ".", "toCamel", "(", "u", ".", "toDash", "(", "attr", ")", ")", ";", "if", "(", "(", "index", "=", "el", "[", "u", ".", "_id", "]", ")", "!==", "undefined", ")", "{", "el", ".", "dataset", "?", "delete", "el", ".", "dataset", "[", "attrCamel", "]", ":", "el", ".", "removeAttribute", "(", "'data-'", "+", "attr", ")", ";", "delete", "u", ".", "_data", "[", "index", "]", "[", "attrCamel", "]", ";", "}", "}", "}", ")", ";", "}" ]
removeData method remove data attribute @param {string} attr - attribute name @param {undefined} [index] - index placeholder @param {undefined} [attrCamel] - placeholder for attribute name in camelCase @return {object} this
[ "removeData", "method", "remove", "data", "attribute" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1118-L1128
46,619
iamso/u.js
dist/u.packed.js
function(props, val) { if (/^o/.test(typeof props)) { for(var prop in props) { var prefixed = u.prfx(prop); if (props.hasOwnProperty(prop)) { this.each(function(index, el) { el.style[prefixed] = props[prop]; }); } } return this; } else { return val === undefined ? (this.length ? getComputedStyle(this[0])[props] : null) : this.each(function(index, el) { var prefixed = u.prfx(props); el.style[prefixed] = val; }); } }
javascript
function(props, val) { if (/^o/.test(typeof props)) { for(var prop in props) { var prefixed = u.prfx(prop); if (props.hasOwnProperty(prop)) { this.each(function(index, el) { el.style[prefixed] = props[prop]; }); } } return this; } else { return val === undefined ? (this.length ? getComputedStyle(this[0])[props] : null) : this.each(function(index, el) { var prefixed = u.prfx(props); el.style[prefixed] = val; }); } }
[ "function", "(", "props", ",", "val", ")", "{", "if", "(", "/", "^o", "/", ".", "test", "(", "typeof", "props", ")", ")", "{", "for", "(", "var", "prop", "in", "props", ")", "{", "var", "prefixed", "=", "u", ".", "prfx", "(", "prop", ")", ";", "if", "(", "props", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "style", "[", "prefixed", "]", "=", "props", "[", "prop", "]", ";", "}", ")", ";", "}", "}", "return", "this", ";", "}", "else", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "getComputedStyle", "(", "this", "[", "0", "]", ")", "[", "props", "]", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "var", "prefixed", "=", "u", ".", "prfx", "(", "props", ")", ";", "el", ".", "style", "[", "prefixed", "]", "=", "val", ";", "}", ")", ";", "}", "}" ]
css method get or set css properties @param {(string|object)} props - property name or object with names and values @param {string} [val] - property value @return {(string|object)} property value or this
[ "css", "method", "get", "or", "set", "css", "properties" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1138-L1156
46,620
iamso/u.js
dist/u.packed.js
function(child) { return this.length ? (/^o/.test(typeof child) ? this[0] !== child[0] && this[0].contains(child[0]) : this[0].querySelector(child) !== null) : false; }
javascript
function(child) { return this.length ? (/^o/.test(typeof child) ? this[0] !== child[0] && this[0].contains(child[0]) : this[0].querySelector(child) !== null) : false; }
[ "function", "(", "child", ")", "{", "return", "this", ".", "length", "?", "(", "/", "^o", "/", ".", "test", "(", "typeof", "child", ")", "?", "this", "[", "0", "]", "!==", "child", "[", "0", "]", "&&", "this", "[", "0", "]", ".", "contains", "(", "child", "[", "0", "]", ")", ":", "this", "[", "0", "]", ".", "querySelector", "(", "child", ")", "!==", "null", ")", ":", "false", ";", "}" ]
contains method check if child is contained in this element @param {(string|object)} child - element or css selector @return {boolean}
[ "contains", "method", "check", "if", "child", "is", "contained", "in", "this", "element" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1278-L1280
46,621
iamso/u.js
dist/u.packed.js
function(filter) { return u(array.filter.call(this, function(el, index) { return /^f/.test(typeof filter) ? filter(index, el) : u(el).is(filter); })); }
javascript
function(filter) { return u(array.filter.call(this, function(el, index) { return /^f/.test(typeof filter) ? filter(index, el) : u(el).is(filter); })); }
[ "function", "(", "filter", ")", "{", "return", "u", "(", "array", ".", "filter", ".", "call", "(", "this", ",", "function", "(", "el", ",", "index", ")", "{", "return", "/", "^f", "/", ".", "test", "(", "typeof", "filter", ")", "?", "filter", "(", "index", ",", "el", ")", ":", "u", "(", "el", ")", ".", "is", "(", "filter", ")", ";", "}", ")", ")", ";", "}" ]
filter method filter elements by selector or filter function @param {string|function} filter - selector or filter function @return {object} matching elements
[ "filter", "method", "filter", "elements", "by", "selector", "or", "filter", "function" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1300-L1304
46,622
iamso/u.js
dist/u.packed.js
function(sel) { if (!this.length) { return false; } var m = (this[0].matches || this[0].matchesSelector || this[0].msMatchesSelector || this[0].mozMatchesSelector || this[0].webkitMatchesSelector || this[0].oMatchesSelector || function(s) { return [].indexOf.call(document.querySelectorAll(s), this) !== -1; }); return m.call(this[0], sel); }
javascript
function(sel) { if (!this.length) { return false; } var m = (this[0].matches || this[0].matchesSelector || this[0].msMatchesSelector || this[0].mozMatchesSelector || this[0].webkitMatchesSelector || this[0].oMatchesSelector || function(s) { return [].indexOf.call(document.querySelectorAll(s), this) !== -1; }); return m.call(this[0], sel); }
[ "function", "(", "sel", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "false", ";", "}", "var", "m", "=", "(", "this", "[", "0", "]", ".", "matches", "||", "this", "[", "0", "]", ".", "matchesSelector", "||", "this", "[", "0", "]", ".", "msMatchesSelector", "||", "this", "[", "0", "]", ".", "mozMatchesSelector", "||", "this", "[", "0", "]", ".", "webkitMatchesSelector", "||", "this", "[", "0", "]", ".", "oMatchesSelector", "||", "function", "(", "s", ")", "{", "return", "[", "]", ".", "indexOf", ".", "call", "(", "document", ".", "querySelectorAll", "(", "s", ")", ",", "this", ")", "!==", "-", "1", ";", "}", ")", ";", "return", "m", ".", "call", "(", "this", "[", "0", "]", ",", "sel", ")", ";", "}" ]
is method matches the element against a selector @param {string} sel - selector to match @return {boolean}
[ "is", "method", "matches", "the", "element", "against", "a", "selector" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1313-L1321
46,623
iamso/u.js
dist/u.packed.js
function(el) { if (!el) { return this[0] ? this.first().prevAll().length : -1; } if (''+el === el) { return u.toArray(u(el)).indexOf(this[0]); } el = el.ujs ? el[0] : el; return u.toArray(this).indexOf(el); }
javascript
function(el) { if (!el) { return this[0] ? this.first().prevAll().length : -1; } if (''+el === el) { return u.toArray(u(el)).indexOf(this[0]); } el = el.ujs ? el[0] : el; return u.toArray(this).indexOf(el); }
[ "function", "(", "el", ")", "{", "if", "(", "!", "el", ")", "{", "return", "this", "[", "0", "]", "?", "this", ".", "first", "(", ")", ".", "prevAll", "(", ")", ".", "length", ":", "-", "1", ";", "}", "if", "(", "''", "+", "el", "===", "el", ")", "{", "return", "u", ".", "toArray", "(", "u", "(", "el", ")", ")", ".", "indexOf", "(", "this", "[", "0", "]", ")", ";", "}", "el", "=", "el", ".", "ujs", "?", "el", "[", "0", "]", ":", "el", ";", "return", "u", ".", "toArray", "(", "this", ")", ".", "indexOf", "(", "el", ")", ";", "}" ]
index method get the index of an element @param {object|string} [el] - elements or css selector @return {number} index
[ "index", "method", "get", "the", "index", "of", "an", "element" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1340-L1349
46,624
iamso/u.js
dist/u.packed.js
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.previousElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
javascript
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.previousElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
[ "function", "(", "sel", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "this", ";", "}", "var", "matched", "=", "[", "]", ",", "el", "=", "this", "[", "0", "]", ";", "while", "(", "el", "=", "el", ".", "previousElementSibling", ")", "{", "sel", "?", "(", "u", "(", "el", ")", ".", "is", "(", "sel", ")", "&&", "matched", ".", "push", "(", "el", ")", ")", ":", "matched", ".", "push", "(", "el", ")", ";", "}", "return", "u", "(", "matched", ")", ";", "}" ]
prevAll method get all previous element siblings @param {string} [sel] - selector to filter siblings @return {object} sibling elements
[ "prevAll", "method", "get", "all", "previous", "element", "siblings" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1369-L1382
46,625
iamso/u.js
dist/u.packed.js
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.nextElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
javascript
function(sel) { if (!this.length) { return this; } var matched = [], el = this[0]; while (el = el.nextElementSibling) { sel ? (u(el).is(sel) && matched.push(el)) : matched.push(el); } return u(matched); }
[ "function", "(", "sel", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "this", ";", "}", "var", "matched", "=", "[", "]", ",", "el", "=", "this", "[", "0", "]", ";", "while", "(", "el", "=", "el", ".", "nextElementSibling", ")", "{", "sel", "?", "(", "u", "(", "el", ")", ".", "is", "(", "sel", ")", "&&", "matched", ".", "push", "(", "el", ")", ")", ":", "matched", ".", "push", "(", "el", ")", ";", "}", "return", "u", "(", "matched", ")", ";", "}" ]
nextAll method get all next element siblings @param {string} [sel] - selector to filter siblings @return {object} sibling elements
[ "nextAll", "method", "get", "all", "next", "element", "siblings" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1402-L1415
46,626
iamso/u.js
dist/u.packed.js
function(sel) { if (!this.length) { return this; } var el = this[0]; return u(array.filter.call(el.parentNode.children, function(child) { return sel ? child !== el && u(child).is(sel) : child !== el; })); }
javascript
function(sel) { if (!this.length) { return this; } var el = this[0]; return u(array.filter.call(el.parentNode.children, function(child) { return sel ? child !== el && u(child).is(sel) : child !== el; })); }
[ "function", "(", "sel", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "this", ";", "}", "var", "el", "=", "this", "[", "0", "]", ";", "return", "u", "(", "array", ".", "filter", ".", "call", "(", "el", ".", "parentNode", ".", "children", ",", "function", "(", "child", ")", "{", "return", "sel", "?", "child", "!==", "el", "&&", "u", "(", "child", ")", ".", "is", "(", "sel", ")", ":", "child", "!==", "el", ";", "}", ")", ")", ";", "}" ]
siblings method get element siblings @param {string} [sel] - selector to filter siblings @return {object} sibling elements
[ "siblings", "method", "get", "element", "siblings" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1424-L1432
46,627
iamso/u.js
dist/u.packed.js
function(sel) { if (!this.length) { return this; } var parents = [], finished = false, currentElement = this[0]; while (!finished) { currentElement = currentElement.parentNode; if (currentElement) { if (sel === undefined) { parents.push(currentElement); } else if (u(currentElement).is(sel)) { parents.push(currentElement); } } else { finished = true; } } return u(parents); }
javascript
function(sel) { if (!this.length) { return this; } var parents = [], finished = false, currentElement = this[0]; while (!finished) { currentElement = currentElement.parentNode; if (currentElement) { if (sel === undefined) { parents.push(currentElement); } else if (u(currentElement).is(sel)) { parents.push(currentElement); } } else { finished = true; } } return u(parents); }
[ "function", "(", "sel", ")", "{", "if", "(", "!", "this", ".", "length", ")", "{", "return", "this", ";", "}", "var", "parents", "=", "[", "]", ",", "finished", "=", "false", ",", "currentElement", "=", "this", "[", "0", "]", ";", "while", "(", "!", "finished", ")", "{", "currentElement", "=", "currentElement", ".", "parentNode", ";", "if", "(", "currentElement", ")", "{", "if", "(", "sel", "===", "undefined", ")", "{", "parents", ".", "push", "(", "currentElement", ")", ";", "}", "else", "if", "(", "u", "(", "currentElement", ")", ".", "is", "(", "sel", ")", ")", "{", "parents", ".", "push", "(", "currentElement", ")", ";", "}", "}", "else", "{", "finished", "=", "true", ";", "}", "}", "return", "u", "(", "parents", ")", ";", "}" ]
parents method get the parent elements @return {object} element
[ "parents", "method", "get", "the", "parent", "elements" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1450-L1473
46,628
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].textContent : null) : this.each(function(index, el) { el.textContent = val; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].textContent : null) : this.each(function(index, el) { el.textContent = val; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "textContent", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "textContent", "=", "val", ";", "}", ")", ";", "}" ]
text method get or set the textContent value @param {string} [val] - text value @return {(string|object)} text value or this
[ "text", "method", "get", "or", "set", "the", "textContent", "value" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1482-L1486
46,629
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].innerHTML : null) : this.each(function(index, el) { el.innerHTML = val; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].innerHTML : null) : this.each(function(index, el) { el.innerHTML = val; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "innerHTML", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "innerHTML", "=", "val", ";", "}", ")", ";", "}" ]
html method get or set innerHTML value @param {string} [val] - html value @return {(string|object)} html value or this
[ "html", "method", "get", "or", "set", "innerHTML", "value" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1495-L1499
46,630
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].outerHTML : null) : this.each(function(index, el) { el.outerHTML = val; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].outerHTML : null) : this.each(function(index, el) { el.outerHTML = val; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "outerHTML", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "outerHTML", "=", "val", ";", "}", ")", ";", "}" ]
outerHTML method get or set outerHTML value @param {string} [val] - html value @return {(string|object)} html value or this
[ "outerHTML", "method", "get", "or", "set", "outerHTML", "value" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1508-L1512
46,631
iamso/u.js
dist/u.packed.js
function(val) { return val === undefined ? (this.length ? this[0].value : null) : this.each(function(index, el) { el.value = val; }); }
javascript
function(val) { return val === undefined ? (this.length ? this[0].value : null) : this.each(function(index, el) { el.value = val; }); }
[ "function", "(", "val", ")", "{", "return", "val", "===", "undefined", "?", "(", "this", ".", "length", "?", "this", "[", "0", "]", ".", "value", ":", "null", ")", ":", "this", ".", "each", "(", "function", "(", "index", ",", "el", ")", "{", "el", ".", "value", "=", "val", ";", "}", ")", ";", "}" ]
val method get or set the value property of inputs and textareas @param {string} [val] - text value @return {(string|object)} text value or this
[ "val", "method", "get", "or", "set", "the", "value", "property", "of", "inputs", "and", "textareas" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1521-L1525
46,632
iamso/u.js
dist/u.packed.js
function() { var args = u.toArray(arguments); args.unshift(u.fn); return u.extend.apply(this, args); }
javascript
function() { var args = u.toArray(arguments); args.unshift(u.fn); return u.extend.apply(this, args); }
[ "function", "(", ")", "{", "var", "args", "=", "u", ".", "toArray", "(", "arguments", ")", ";", "args", ".", "unshift", "(", "u", ".", "fn", ")", ";", "return", "u", ".", "extend", ".", "apply", "(", "this", ",", "args", ")", ";", "}" ]
extend method extend the u.js prototype object @return {object} u.js prototype
[ "extend", "method", "extend", "the", "u", ".", "js", "prototype", "object" ]
e82362d337b439e28d223931a6d489969c7b379c
https://github.com/iamso/u.js/blob/e82362d337b439e28d223931a6d489969c7b379c/dist/u.packed.js#L1600-L1604
46,633
freakimkaefig/musicjson2abc
lib/abc_parser/data/Tune.js
function(params) { This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = []; if (This.isFirstLine(This.lineNum)) { if (params.name) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.name;} } else { if (params.subname) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.subname;} } if (params.style) This.appendElement('style', null, null, {head: params.style}); if (params.stem) This.appendElement('stem', null, null, {direction: params.stem}); else if (This.voiceNum > 0) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0]!== undefined) { var found = false; for (var i = 0; i < This.lines[This.lineNum].staff[This.staffNum].voices[0].length; i++) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0].el_type === 'stem') found = true; } if (!found) { var stem = { el_type: 'stem', direction: 'up' }; This.lines[This.lineNum].staff[This.staffNum].voices[0].splice(0,0,stem); } } This.appendElement('stem', null, null, {direction: 'down'}); } if (params.scale) This.appendElement('scale', null, null, { size: params.scale} ); }
javascript
function(params) { This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = []; if (This.isFirstLine(This.lineNum)) { if (params.name) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.name;} } else { if (params.subname) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.subname;} } if (params.style) This.appendElement('style', null, null, {head: params.style}); if (params.stem) This.appendElement('stem', null, null, {direction: params.stem}); else if (This.voiceNum > 0) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0]!== undefined) { var found = false; for (var i = 0; i < This.lines[This.lineNum].staff[This.staffNum].voices[0].length; i++) { if (This.lines[This.lineNum].staff[This.staffNum].voices[0].el_type === 'stem') found = true; } if (!found) { var stem = { el_type: 'stem', direction: 'up' }; This.lines[This.lineNum].staff[This.staffNum].voices[0].splice(0,0,stem); } } This.appendElement('stem', null, null, {direction: 'down'}); } if (params.scale) This.appendElement('scale', null, null, { size: params.scale} ); }
[ "function", "(", "params", ")", "{", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "voices", "[", "This", ".", "voiceNum", "]", "=", "[", "]", ";", "if", "(", "This", ".", "isFirstLine", "(", "This", ".", "lineNum", ")", ")", "{", "if", "(", "params", ".", "name", ")", "{", "if", "(", "!", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", ")", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", "=", "[", "]", ";", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", "[", "This", ".", "voiceNum", "]", "=", "params", ".", "name", ";", "}", "}", "else", "{", "if", "(", "params", ".", "subname", ")", "{", "if", "(", "!", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", ")", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", "=", "[", "]", ";", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "title", "[", "This", ".", "voiceNum", "]", "=", "params", ".", "subname", ";", "}", "}", "if", "(", "params", ".", "style", ")", "This", ".", "appendElement", "(", "'style'", ",", "null", ",", "null", ",", "{", "head", ":", "params", ".", "style", "}", ")", ";", "if", "(", "params", ".", "stem", ")", "This", ".", "appendElement", "(", "'stem'", ",", "null", ",", "null", ",", "{", "direction", ":", "params", ".", "stem", "}", ")", ";", "else", "if", "(", "This", ".", "voiceNum", ">", "0", ")", "{", "if", "(", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "voices", "[", "0", "]", "!==", "undefined", ")", "{", "var", "found", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "voices", "[", "0", "]", ".", "length", ";", "i", "++", ")", "{", "if", "(", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "voices", "[", "0", "]", ".", "el_type", "===", "'stem'", ")", "found", "=", "true", ";", "}", "if", "(", "!", "found", ")", "{", "var", "stem", "=", "{", "el_type", ":", "'stem'", ",", "direction", ":", "'up'", "}", ";", "This", ".", "lines", "[", "This", ".", "lineNum", "]", ".", "staff", "[", "This", ".", "staffNum", "]", ".", "voices", "[", "0", "]", ".", "splice", "(", "0", ",", "0", ",", "stem", ")", ";", "}", "}", "This", ".", "appendElement", "(", "'stem'", ",", "null", ",", "null", ",", "{", "direction", ":", "'down'", "}", ")", ";", "}", "if", "(", "params", ".", "scale", ")", "This", ".", "appendElement", "(", "'scale'", ",", "null", ",", "null", ",", "{", "size", ":", "params", ".", "scale", "}", ")", ";", "}" ]
Close the previous line.
[ "Close", "the", "previous", "line", "." ]
c119c7927c3c9b6aa5f3558cc73990478472dfbb
https://github.com/freakimkaefig/musicjson2abc/blob/c119c7927c3c9b6aa5f3558cc73990478472dfbb/lib/abc_parser/data/Tune.js#L585-L612
46,634
Hugo-ter-Doest/chart-parsers
lib/TypedFeatureStructure.js
featureIsUnifiable
function featureIsUnifiable(feature) { logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + fs2.features[feature]); if (fs1.features[feature]) { // If feature of fs2 is a back pointer we want it to overrule feature // of the fs1. if (newStackb.indexOf(fs2.features[feature].id) > -1) { fs1.addAuxFeature(feature, fs2.features[feature], signature); } // One of the features should be not a back pointer because // otherwise we are checking for unification multiple times if ((newStacka.indexOf(fs1.features[feature].id) === -1) || (newStackb.indexOf(fs2.features[feature].id) === -1)) { var unifiable = fs1.features[feature].unifiable(fs2.features[feature], signature, newStacka, newStackb); logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + ' with result: ' + unifiable); return (unifiable); } else { return (true); } } else { fs1.addAuxFeature(feature, fs2.features[feature], signature); return (true); } }
javascript
function featureIsUnifiable(feature) { logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + fs2.features[feature]); if (fs1.features[feature]) { // If feature of fs2 is a back pointer we want it to overrule feature // of the fs1. if (newStackb.indexOf(fs2.features[feature].id) > -1) { fs1.addAuxFeature(feature, fs2.features[feature], signature); } // One of the features should be not a back pointer because // otherwise we are checking for unification multiple times if ((newStacka.indexOf(fs1.features[feature].id) === -1) || (newStackb.indexOf(fs2.features[feature].id) === -1)) { var unifiable = fs1.features[feature].unifiable(fs2.features[feature], signature, newStacka, newStackb); logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + ' with result: ' + unifiable); return (unifiable); } else { return (true); } } else { fs1.addAuxFeature(feature, fs2.features[feature], signature); return (true); } }
[ "function", "featureIsUnifiable", "(", "feature", ")", "{", "logger", ".", "debug", "(", "'TypedFeatureStructure.unifiable: checking feature: '", "+", "feature", "+", "fs2", ".", "features", "[", "feature", "]", ")", ";", "if", "(", "fs1", ".", "features", "[", "feature", "]", ")", "{", "// If feature of fs2 is a back pointer we want it to overrule feature", "// of the fs1.", "if", "(", "newStackb", ".", "indexOf", "(", "fs2", ".", "features", "[", "feature", "]", ".", "id", ")", ">", "-", "1", ")", "{", "fs1", ".", "addAuxFeature", "(", "feature", ",", "fs2", ".", "features", "[", "feature", "]", ",", "signature", ")", ";", "}", "// One of the features should be not a back pointer because", "// otherwise we are checking for unification multiple times", "if", "(", "(", "newStacka", ".", "indexOf", "(", "fs1", ".", "features", "[", "feature", "]", ".", "id", ")", "===", "-", "1", ")", "||", "(", "newStackb", ".", "indexOf", "(", "fs2", ".", "features", "[", "feature", "]", ".", "id", ")", "===", "-", "1", ")", ")", "{", "var", "unifiable", "=", "fs1", ".", "features", "[", "feature", "]", ".", "unifiable", "(", "fs2", ".", "features", "[", "feature", "]", ",", "signature", ",", "newStacka", ",", "newStackb", ")", ";", "logger", ".", "debug", "(", "'TypedFeatureStructure.unifiable: checking feature: '", "+", "feature", "+", "' with result: '", "+", "unifiable", ")", ";", "return", "(", "unifiable", ")", ";", "}", "else", "{", "return", "(", "true", ")", ";", "}", "}", "else", "{", "fs1", ".", "addAuxFeature", "(", "feature", ",", "fs2", ".", "features", "[", "feature", "]", ",", "signature", ")", ";", "return", "(", "true", ")", ";", "}", "}" ]
Checks if a feature of two features structures can be unified
[ "Checks", "if", "a", "feature", "of", "two", "features", "structures", "can", "be", "unified" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/lib/TypedFeatureStructure.js#L243-L268
46,635
Hugo-ter-Doest/chart-parsers
lib/TypedFeatureStructure.js
prettyPrint0
function prettyPrint0(fs, indent) { logger.debug('prettyPrint0: ' + fs); var result = ''; if (fs) { if (Object.keys(fs.incoming).length > 1) { if (fs.printed) { // Return the label return (fs.getLabel()); } else { // Print the label result += fs.getLabel() + space; indent += fs.getLabel().length + 1; // and continue to print the substructure } } // mark the current node as printed fs.printed = true; if (!Object.keys(fs.features).length) { logger.debug('prettyPrint0() ' + fs.type.name); result += (debug ? fs.getLabel() : ''); if (fs.type === signature.typeLattice.string) { // Print the lexical string result += '\"' + fs.lexicalString + '\"'; } else { if (fs.type === signature.typeLattice.list) { // Distinguish ordinary references from list of references if (fs.listOfCrossRefs) { // Print the list of cross references result += '<'; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ', '; } else { // Print the referred fs result += prettyPrint0(ref, indent + 1) + ',\n'; } }); // Remove the last comma plus space, if necessary if (fs.listOfCrossRefs.length) { result = result.substr(0, result.length - 2); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { if (fs.type === signature.typeLattice.concatlist) { // Print concatenation of lists of cross referenced nodes if (fs.listOfCrossRefs) { result += '<'; var nrPrinted = 0; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ' + '; } else { result += prettyPrint0(ref, indent + 1) + ' +\n'; } nrPrinted++; }); // Remove the last comma plus space, if one or more elements // were printed if (nrPrinted) { result = result.substr(0, result.length - 3); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { // Print the type result += fs.type.prettyPrint(); } } } } else { // Print the substructure result += '[' + (debug ? fs.getLabel() : ''); Object.keys(fs.features).forEach(function (feature, index) { if (index === 0) { // first print the type of the substructure logger.debug('prettyPrint0(): ' + fs.type.name); result += fs.type.prettyPrint() + '\n'; // + ' (incoming: ' +' + //' Object.keys(fs.incoming).length + ')' + '\n'; result += space.repeat(indent + 1); result += feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } else { result += space.repeat(indent + 1) + feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } }); result += space.repeat(indent) + ']'; } } else { result += 'WARNING: empty fs\n'; } return (result); }
javascript
function prettyPrint0(fs, indent) { logger.debug('prettyPrint0: ' + fs); var result = ''; if (fs) { if (Object.keys(fs.incoming).length > 1) { if (fs.printed) { // Return the label return (fs.getLabel()); } else { // Print the label result += fs.getLabel() + space; indent += fs.getLabel().length + 1; // and continue to print the substructure } } // mark the current node as printed fs.printed = true; if (!Object.keys(fs.features).length) { logger.debug('prettyPrint0() ' + fs.type.name); result += (debug ? fs.getLabel() : ''); if (fs.type === signature.typeLattice.string) { // Print the lexical string result += '\"' + fs.lexicalString + '\"'; } else { if (fs.type === signature.typeLattice.list) { // Distinguish ordinary references from list of references if (fs.listOfCrossRefs) { // Print the list of cross references result += '<'; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ', '; } else { // Print the referred fs result += prettyPrint0(ref, indent + 1) + ',\n'; } }); // Remove the last comma plus space, if necessary if (fs.listOfCrossRefs.length) { result = result.substr(0, result.length - 2); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { if (fs.type === signature.typeLattice.concatlist) { // Print concatenation of lists of cross referenced nodes if (fs.listOfCrossRefs) { result += '<'; var nrPrinted = 0; fs.listOfCrossRefs.forEach(function (ref) { if (ref.printed) { result += ref.getLabel() + ' + '; } else { result += prettyPrint0(ref, indent + 1) + ' +\n'; } nrPrinted++; }); // Remove the last comma plus space, if one or more elements // were printed if (nrPrinted) { result = result.substr(0, result.length - 3); } result += '>'; } else { // Print the type result += fs.type.prettyPrint(); } } else { // Print the type result += fs.type.prettyPrint(); } } } } else { // Print the substructure result += '[' + (debug ? fs.getLabel() : ''); Object.keys(fs.features).forEach(function (feature, index) { if (index === 0) { // first print the type of the substructure logger.debug('prettyPrint0(): ' + fs.type.name); result += fs.type.prettyPrint() + '\n'; // + ' (incoming: ' +' + //' Object.keys(fs.incoming).length + ')' + '\n'; result += space.repeat(indent + 1); result += feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } else { result += space.repeat(indent + 1) + feature + ':' + space; result += prettyPrint0(fs.features[feature], indent + feature.length + 3) + '\n'; } }); result += space.repeat(indent) + ']'; } } else { result += 'WARNING: empty fs\n'; } return (result); }
[ "function", "prettyPrint0", "(", "fs", ",", "indent", ")", "{", "logger", ".", "debug", "(", "'prettyPrint0: '", "+", "fs", ")", ";", "var", "result", "=", "''", ";", "if", "(", "fs", ")", "{", "if", "(", "Object", ".", "keys", "(", "fs", ".", "incoming", ")", ".", "length", ">", "1", ")", "{", "if", "(", "fs", ".", "printed", ")", "{", "// Return the label", "return", "(", "fs", ".", "getLabel", "(", ")", ")", ";", "}", "else", "{", "// Print the label", "result", "+=", "fs", ".", "getLabel", "(", ")", "+", "space", ";", "indent", "+=", "fs", ".", "getLabel", "(", ")", ".", "length", "+", "1", ";", "// and continue to print the substructure", "}", "}", "// mark the current node as printed", "fs", ".", "printed", "=", "true", ";", "if", "(", "!", "Object", ".", "keys", "(", "fs", ".", "features", ")", ".", "length", ")", "{", "logger", ".", "debug", "(", "'prettyPrint0() '", "+", "fs", ".", "type", ".", "name", ")", ";", "result", "+=", "(", "debug", "?", "fs", ".", "getLabel", "(", ")", ":", "''", ")", ";", "if", "(", "fs", ".", "type", "===", "signature", ".", "typeLattice", ".", "string", ")", "{", "// Print the lexical string", "result", "+=", "'\\\"'", "+", "fs", ".", "lexicalString", "+", "'\\\"'", ";", "}", "else", "{", "if", "(", "fs", ".", "type", "===", "signature", ".", "typeLattice", ".", "list", ")", "{", "// Distinguish ordinary references from list of references", "if", "(", "fs", ".", "listOfCrossRefs", ")", "{", "// Print the list of cross references", "result", "+=", "'<'", ";", "fs", ".", "listOfCrossRefs", ".", "forEach", "(", "function", "(", "ref", ")", "{", "if", "(", "ref", ".", "printed", ")", "{", "result", "+=", "ref", ".", "getLabel", "(", ")", "+", "', '", ";", "}", "else", "{", "// Print the referred fs", "result", "+=", "prettyPrint0", "(", "ref", ",", "indent", "+", "1", ")", "+", "',\\n'", ";", "}", "}", ")", ";", "// Remove the last comma plus space, if necessary", "if", "(", "fs", ".", "listOfCrossRefs", ".", "length", ")", "{", "result", "=", "result", ".", "substr", "(", "0", ",", "result", ".", "length", "-", "2", ")", ";", "}", "result", "+=", "'>'", ";", "}", "else", "{", "// Print the type", "result", "+=", "fs", ".", "type", ".", "prettyPrint", "(", ")", ";", "}", "}", "else", "{", "if", "(", "fs", ".", "type", "===", "signature", ".", "typeLattice", ".", "concatlist", ")", "{", "// Print concatenation of lists of cross referenced nodes", "if", "(", "fs", ".", "listOfCrossRefs", ")", "{", "result", "+=", "'<'", ";", "var", "nrPrinted", "=", "0", ";", "fs", ".", "listOfCrossRefs", ".", "forEach", "(", "function", "(", "ref", ")", "{", "if", "(", "ref", ".", "printed", ")", "{", "result", "+=", "ref", ".", "getLabel", "(", ")", "+", "' + '", ";", "}", "else", "{", "result", "+=", "prettyPrint0", "(", "ref", ",", "indent", "+", "1", ")", "+", "' +\\n'", ";", "}", "nrPrinted", "++", ";", "}", ")", ";", "// Remove the last comma plus space, if one or more elements", "// were printed", "if", "(", "nrPrinted", ")", "{", "result", "=", "result", ".", "substr", "(", "0", ",", "result", ".", "length", "-", "3", ")", ";", "}", "result", "+=", "'>'", ";", "}", "else", "{", "// Print the type", "result", "+=", "fs", ".", "type", ".", "prettyPrint", "(", ")", ";", "}", "}", "else", "{", "// Print the type", "result", "+=", "fs", ".", "type", ".", "prettyPrint", "(", ")", ";", "}", "}", "}", "}", "else", "{", "// Print the substructure", "result", "+=", "'['", "+", "(", "debug", "?", "fs", ".", "getLabel", "(", ")", ":", "''", ")", ";", "Object", ".", "keys", "(", "fs", ".", "features", ")", ".", "forEach", "(", "function", "(", "feature", ",", "index", ")", "{", "if", "(", "index", "===", "0", ")", "{", "// first print the type of the substructure", "logger", ".", "debug", "(", "'prettyPrint0(): '", "+", "fs", ".", "type", ".", "name", ")", ";", "result", "+=", "fs", ".", "type", ".", "prettyPrint", "(", ")", "+", "'\\n'", ";", "// + ' (incoming: ' +' +", "//' Object.keys(fs.incoming).length + ')' + '\\n';", "result", "+=", "space", ".", "repeat", "(", "indent", "+", "1", ")", ";", "result", "+=", "feature", "+", "':'", "+", "space", ";", "result", "+=", "prettyPrint0", "(", "fs", ".", "features", "[", "feature", "]", ",", "indent", "+", "feature", ".", "length", "+", "3", ")", "+", "'\\n'", ";", "}", "else", "{", "result", "+=", "space", ".", "repeat", "(", "indent", "+", "1", ")", "+", "feature", "+", "':'", "+", "space", ";", "result", "+=", "prettyPrint0", "(", "fs", ".", "features", "[", "feature", "]", ",", "indent", "+", "feature", ".", "length", "+", "3", ")", "+", "'\\n'", ";", "}", "}", ")", ";", "result", "+=", "space", ".", "repeat", "(", "indent", ")", "+", "']'", ";", "}", "}", "else", "{", "result", "+=", "'WARNING: empty fs\\n'", ";", "}", "return", "(", "result", ")", ";", "}" ]
Actual pretty printer
[ "Actual", "pretty", "printer" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/lib/TypedFeatureStructure.js#L705-L816
46,636
thealjey/webcompiler
lib/livereload.js
livereload
function livereload() { if (!reloadFn) { const lr = (0, _tinyLr2.default)(); lr.listen(LIVERELOAD_PORT); reloadFn = (file = '*') => { lr.changed({ body: { files: [file] } }); }; } return reloadFn; }
javascript
function livereload() { if (!reloadFn) { const lr = (0, _tinyLr2.default)(); lr.listen(LIVERELOAD_PORT); reloadFn = (file = '*') => { lr.changed({ body: { files: [file] } }); }; } return reloadFn; }
[ "function", "livereload", "(", ")", "{", "if", "(", "!", "reloadFn", ")", "{", "const", "lr", "=", "(", "0", ",", "_tinyLr2", ".", "default", ")", "(", ")", ";", "lr", ".", "listen", "(", "LIVERELOAD_PORT", ")", ";", "reloadFn", "=", "(", "file", "=", "'*'", ")", "=>", "{", "lr", ".", "changed", "(", "{", "body", ":", "{", "files", ":", "[", "file", "]", "}", "}", ")", ";", "}", ";", "}", "return", "reloadFn", ";", "}" ]
Starts a LiveReload server and returns a function that triggers the reload. @function livereload @return {LiveReloadTrigger} the trigger function @example <link rel="stylesheet" href="css/style.css"> @example import {livereload} from 'webcompiler'; // or - import {livereload} from 'webcompiler/lib/livereload'; // or - var livereload = require('webcompiler').livereload; // or - var livereload = require('webcompiler/lib/livereload').livereload; // initialize the server const lr = livereload(); // only reload the styles lr('css/style.css'); // refresh the whole page lr('*'); // or simply lr();
[ "Starts", "a", "LiveReload", "server", "and", "returns", "a", "function", "that", "triggers", "the", "reload", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/livereload.js#L40-L52
46,637
Aigeec/mandrill-webhook-authenticator
src/mandrill-webhook-authenticator.js
function(fullUrl, body, key, signature) { var data = fullUrl + sortPostParameters(body); var expected = getHash(data, key); return expected === signature; }
javascript
function(fullUrl, body, key, signature) { var data = fullUrl + sortPostParameters(body); var expected = getHash(data, key); return expected === signature; }
[ "function", "(", "fullUrl", ",", "body", ",", "key", ",", "signature", ")", "{", "var", "data", "=", "fullUrl", "+", "sortPostParameters", "(", "body", ")", ";", "var", "expected", "=", "getHash", "(", "data", ",", "key", ")", ";", "return", "expected", "===", "signature", ";", "}" ]
Generate the signature from the full url and sorted post data to compart to the one provided. When mandrill is testing the existence of a url it can send a post request with no events and key set to 'test-webhook'. @param { string } fullUrl - domain and url of request - should match exactly the url specified in the webhook @param { string } body - request body @param { string } key - Mandrill Inbound Webhook auth key @param { string } signature - signature provided in the 'x-mandrill-signature' header @returns { boolean } True is signature is valid otherwise false
[ "Generate", "the", "signature", "from", "the", "full", "url", "and", "sorted", "post", "data", "to", "compart", "to", "the", "one", "provided", ".", "When", "mandrill", "is", "testing", "the", "existence", "of", "a", "url", "it", "can", "send", "a", "post", "request", "with", "no", "events", "and", "key", "set", "to", "test", "-", "webhook", "." ]
d140241b5f274d4e951b1a294e35195a7e4177f9
https://github.com/Aigeec/mandrill-webhook-authenticator/blob/d140241b5f274d4e951b1a294e35195a7e4177f9/src/mandrill-webhook-authenticator.js#L70-L74
46,638
Aigeec/mandrill-webhook-authenticator
src/mandrill-webhook-authenticator.js
function(body) { body = Object(body); var sortedKeys = Object.keys(body).sort(); return sortedKeys.reduce(function(signature, key) { return signature + key + body[key]; }, ''); }
javascript
function(body) { body = Object(body); var sortedKeys = Object.keys(body).sort(); return sortedKeys.reduce(function(signature, key) { return signature + key + body[key]; }, ''); }
[ "function", "(", "body", ")", "{", "body", "=", "Object", "(", "body", ")", ";", "var", "sortedKeys", "=", "Object", ".", "keys", "(", "body", ")", ".", "sort", "(", ")", ";", "return", "sortedKeys", ".", "reduce", "(", "function", "(", "signature", ",", "key", ")", "{", "return", "signature", "+", "key", "+", "body", "[", "key", "]", ";", "}", ",", "''", ")", ";", "}" ]
Sort the post parameters alphabetically and append each POST variable's key and value with no delimiter. @param { string } body - Post body @returns { string } string of sorted key values with no delimiter
[ "Sort", "the", "post", "parameters", "alphabetically", "and", "append", "each", "POST", "variable", "s", "key", "and", "value", "with", "no", "delimiter", "." ]
d140241b5f274d4e951b1a294e35195a7e4177f9
https://github.com/Aigeec/mandrill-webhook-authenticator/blob/d140241b5f274d4e951b1a294e35195a7e4177f9/src/mandrill-webhook-authenticator.js#L81-L87
46,639
Aigeec/mandrill-webhook-authenticator
src/mandrill-webhook-authenticator.js
function(req, res, next) { var signature = req.headers[MANDRILL_SIGNATURE_HEADER]; var fullUrl = options.domain + req.url; var isValid = validator(fullUrl, req.body, signature); var respondWith = responder(res); if (!signature) { respondWith(401, NOT_AUTHORIZED); }else if (req.body && req.body.mandrill_events === '[]' && isValid('test-webhook')) { respondWith(200, OK); }else if (!isValid(options.webhookAuthKey)) { respondWith(403, FORBIDDEN); } else { next(); } }
javascript
function(req, res, next) { var signature = req.headers[MANDRILL_SIGNATURE_HEADER]; var fullUrl = options.domain + req.url; var isValid = validator(fullUrl, req.body, signature); var respondWith = responder(res); if (!signature) { respondWith(401, NOT_AUTHORIZED); }else if (req.body && req.body.mandrill_events === '[]' && isValid('test-webhook')) { respondWith(200, OK); }else if (!isValid(options.webhookAuthKey)) { respondWith(403, FORBIDDEN); } else { next(); } }
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "signature", "=", "req", ".", "headers", "[", "MANDRILL_SIGNATURE_HEADER", "]", ";", "var", "fullUrl", "=", "options", ".", "domain", "+", "req", ".", "url", ";", "var", "isValid", "=", "validator", "(", "fullUrl", ",", "req", ".", "body", ",", "signature", ")", ";", "var", "respondWith", "=", "responder", "(", "res", ")", ";", "if", "(", "!", "signature", ")", "{", "respondWith", "(", "401", ",", "NOT_AUTHORIZED", ")", ";", "}", "else", "if", "(", "req", ".", "body", "&&", "req", ".", "body", ".", "mandrill_events", "===", "'[]'", "&&", "isValid", "(", "'test-webhook'", ")", ")", "{", "respondWith", "(", "200", ",", "OK", ")", ";", "}", "else", "if", "(", "!", "isValid", "(", "options", ".", "webhookAuthKey", ")", ")", "{", "respondWith", "(", "403", ",", "FORBIDDEN", ")", ";", "}", "else", "{", "next", "(", ")", ";", "}", "}" ]
Express middleware compatible function to process requests and only continure if the signature is valid. Will return 200 if the request is a test request. It does not update the request. @param { Request } req @param { Response } res @param { function } next
[ "Express", "middleware", "compatible", "function", "to", "process", "requests", "and", "only", "continure", "if", "the", "signature", "is", "valid", ".", "Will", "return", "200", "if", "the", "request", "is", "a", "test", "request", ".", "It", "does", "not", "update", "the", "request", "." ]
d140241b5f274d4e951b1a294e35195a7e4177f9
https://github.com/Aigeec/mandrill-webhook-authenticator/blob/d140241b5f274d4e951b1a294e35195a7e4177f9/src/mandrill-webhook-authenticator.js#L134-L150
46,640
souporserious/create-styled-element
example/index.js
Column
function Column({ size, ...props }) { const staticStyles = { display: 'flex', flexDirection: 'column', } const dynamicStyles = { flex: `0 0 ${size / 12 * 100}`, } return createStyledElement('div', props)(staticStyles, dynamicStyles) }
javascript
function Column({ size, ...props }) { const staticStyles = { display: 'flex', flexDirection: 'column', } const dynamicStyles = { flex: `0 0 ${size / 12 * 100}`, } return createStyledElement('div', props)(staticStyles, dynamicStyles) }
[ "function", "Column", "(", "{", "size", ",", "...", "props", "}", ")", "{", "const", "staticStyles", "=", "{", "display", ":", "'flex'", ",", "flexDirection", ":", "'column'", ",", "}", "const", "dynamicStyles", "=", "{", "flex", ":", "`", "${", "size", "/", "12", "*", "100", "}", "`", ",", "}", "return", "createStyledElement", "(", "'div'", ",", "props", ")", "(", "staticStyles", ",", "dynamicStyles", ")", "}" ]
Multiple Styled Components Example
[ "Multiple", "Styled", "Components", "Example" ]
3abe540520cc25a44e4cb9e157e0eceeacf8f08f
https://github.com/souporserious/create-styled-element/blob/3abe540520cc25a44e4cb9e157e0eceeacf8f08f/example/index.js#L19-L28
46,641
meerkats/winston-slacker
index.js
Slack
function Slack(options) { var suppliedOptions = options ? options : {}; if (!suppliedOptions.webhook || typeof suppliedOptions.webhook !== 'string') { throw new Error('Invalid webhook parameter'); } this.name = 'slack'; this.webhook = suppliedOptions.webhook; this.customFormatter = suppliedOptions.customFormatter || defaultFormatter; delete suppliedOptions.customFormatter; delete suppliedOptions.webhook; this.options = extend({ channel: '#general', username: 'winston-slacker', iconUrl: false, iconEmoji: false, level: 'info', silent: false, raw: false, name: 'slacker', handleExceptions: false, }, suppliedOptions); }
javascript
function Slack(options) { var suppliedOptions = options ? options : {}; if (!suppliedOptions.webhook || typeof suppliedOptions.webhook !== 'string') { throw new Error('Invalid webhook parameter'); } this.name = 'slack'; this.webhook = suppliedOptions.webhook; this.customFormatter = suppliedOptions.customFormatter || defaultFormatter; delete suppliedOptions.customFormatter; delete suppliedOptions.webhook; this.options = extend({ channel: '#general', username: 'winston-slacker', iconUrl: false, iconEmoji: false, level: 'info', silent: false, raw: false, name: 'slacker', handleExceptions: false, }, suppliedOptions); }
[ "function", "Slack", "(", "options", ")", "{", "var", "suppliedOptions", "=", "options", "?", "options", ":", "{", "}", ";", "if", "(", "!", "suppliedOptions", ".", "webhook", "||", "typeof", "suppliedOptions", ".", "webhook", "!==", "'string'", ")", "{", "throw", "new", "Error", "(", "'Invalid webhook parameter'", ")", ";", "}", "this", ".", "name", "=", "'slack'", ";", "this", ".", "webhook", "=", "suppliedOptions", ".", "webhook", ";", "this", ".", "customFormatter", "=", "suppliedOptions", ".", "customFormatter", "||", "defaultFormatter", ";", "delete", "suppliedOptions", ".", "customFormatter", ";", "delete", "suppliedOptions", ".", "webhook", ";", "this", ".", "options", "=", "extend", "(", "{", "channel", ":", "'#general'", ",", "username", ":", "'winston-slacker'", ",", "iconUrl", ":", "false", ",", "iconEmoji", ":", "false", ",", "level", ":", "'info'", ",", "silent", ":", "false", ",", "raw", ":", "false", ",", "name", ":", "'slacker'", ",", "handleExceptions", ":", "false", ",", "}", ",", "suppliedOptions", ")", ";", "}" ]
Slack integration for Winston @param {object} Options parameter
[ "Slack", "integration", "for", "Winston" ]
fdd4c3ff41b600749708f9d6b64f298e5c9beb30
https://github.com/meerkats/winston-slacker/blob/fdd4c3ff41b600749708f9d6b64f298e5c9beb30/index.js#L19-L40
46,642
meerkats/winston-slacker
index.js
send
function send(message, callback) { const suppliedCallback = callback || function () {}; if (!message) { return suppliedCallback(new Error('No message')); } const requestParams = { url: this.webhook, body: extend(this.options, { text: message }), json: true }; return request.post(requestParams, function (err, res, body) { if (err || body !== 'ok') { return suppliedCallback(err || new Error(body)); } return suppliedCallback(null, body); }); }
javascript
function send(message, callback) { const suppliedCallback = callback || function () {}; if (!message) { return suppliedCallback(new Error('No message')); } const requestParams = { url: this.webhook, body: extend(this.options, { text: message }), json: true }; return request.post(requestParams, function (err, res, body) { if (err || body !== 'ok') { return suppliedCallback(err || new Error(body)); } return suppliedCallback(null, body); }); }
[ "function", "send", "(", "message", ",", "callback", ")", "{", "const", "suppliedCallback", "=", "callback", "||", "function", "(", ")", "{", "}", ";", "if", "(", "!", "message", ")", "{", "return", "suppliedCallback", "(", "new", "Error", "(", "'No message'", ")", ")", ";", "}", "const", "requestParams", "=", "{", "url", ":", "this", ".", "webhook", ",", "body", ":", "extend", "(", "this", ".", "options", ",", "{", "text", ":", "message", "}", ")", ",", "json", ":", "true", "}", ";", "return", "request", ".", "post", "(", "requestParams", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "err", "||", "body", "!==", "'ok'", ")", "{", "return", "suppliedCallback", "(", "err", "||", "new", "Error", "(", "body", ")", ")", ";", "}", "return", "suppliedCallback", "(", "null", ",", "body", ")", ";", "}", ")", ";", "}" ]
Handles the sending of a message to an Incoming webhook @param {text} Message text @param {function} Callback function for post execution
[ "Handles", "the", "sending", "of", "a", "message", "to", "an", "Incoming", "webhook" ]
fdd4c3ff41b600749708f9d6b64f298e5c9beb30
https://github.com/meerkats/winston-slacker/blob/fdd4c3ff41b600749708f9d6b64f298e5c9beb30/index.js#L47-L63
46,643
Hugo-ter-Doest/chart-parsers
example/example_with_wordnet.js
tokenize_sentence
function tokenize_sentence(sentence) { var tokenized = tokenizer.tokenize(sentence); logger.info("tokenize_sentence: " + tokenized); return(tokenized); }
javascript
function tokenize_sentence(sentence) { var tokenized = tokenizer.tokenize(sentence); logger.info("tokenize_sentence: " + tokenized); return(tokenized); }
[ "function", "tokenize_sentence", "(", "sentence", ")", "{", "var", "tokenized", "=", "tokenizer", ".", "tokenize", "(", "sentence", ")", ";", "logger", ".", "info", "(", "\"tokenize_sentence: \"", "+", "tokenized", ")", ";", "return", "(", "tokenized", ")", ";", "}" ]
Split sentence in words and punctuation
[ "Split", "sentence", "in", "words", "and", "punctuation" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/example/example_with_wordnet.js#L73-L77
46,644
Hugo-ter-Doest/chart-parsers
example/example_with_wordnet.js
stem_sentence
function stem_sentence(sentence) { for (var i = 0; i < sentence.length; i++) { sentence[i] = natural.PorterStemmer.stem(sentence[i]); } logger.info("stem_sentence: " + sentence); return(sentence); }
javascript
function stem_sentence(sentence) { for (var i = 0; i < sentence.length; i++) { sentence[i] = natural.PorterStemmer.stem(sentence[i]); } logger.info("stem_sentence: " + sentence); return(sentence); }
[ "function", "stem_sentence", "(", "sentence", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "sentence", ".", "length", ";", "i", "++", ")", "{", "sentence", "[", "i", "]", "=", "natural", ".", "PorterStemmer", ".", "stem", "(", "sentence", "[", "i", "]", ")", ";", "}", "logger", ".", "info", "(", "\"stem_sentence: \"", "+", "sentence", ")", ";", "return", "(", "sentence", ")", ";", "}" ]
Stem the words of the sentence Not used in the example, because Wordnet cannot recognise all stems
[ "Stem", "the", "words", "of", "the", "sentence", "Not", "used", "in", "the", "example", "because", "Wordnet", "cannot", "recognise", "all", "stems" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/example/example_with_wordnet.js#L81-L87
46,645
Hugo-ter-Doest/chart-parsers
lib/Type.js
Type
function Type(name, super_types, fs) { this.super_types = []; this.name = name; if (super_types) { this.super_types = super_types; } this.fs = fs; }
javascript
function Type(name, super_types, fs) { this.super_types = []; this.name = name; if (super_types) { this.super_types = super_types; } this.fs = fs; }
[ "function", "Type", "(", "name", ",", "super_types", ",", "fs", ")", "{", "this", ".", "super_types", "=", "[", "]", ";", "this", ".", "name", "=", "name", ";", "if", "(", "super_types", ")", "{", "this", ".", "super_types", "=", "super_types", ";", "}", "this", ".", "fs", "=", "fs", ";", "}" ]
Constructor - name is a string - super_types is an array of types; it should be nonempty
[ "Constructor", "-", "name", "is", "a", "string", "-", "super_types", "is", "an", "array", "of", "types", ";", "it", "should", "be", "nonempty" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/lib/Type.js#L28-L35
46,646
svanderburg/nijs
lib/ast/NixFunction.js
NixFunction
function NixFunction(args) { if(args.argSpec === null) { throw "Cannot derivate function argument specification from a null reference"; } else if(typeof args.argSpec == "string" || typeof args.argSpec == "object") { this.argSpec = args.argSpec; this.body = args.body; } else { throw "Cannot derive function argument specification from an object of type: "+args.argSpec; } }
javascript
function NixFunction(args) { if(args.argSpec === null) { throw "Cannot derivate function argument specification from a null reference"; } else if(typeof args.argSpec == "string" || typeof args.argSpec == "object") { this.argSpec = args.argSpec; this.body = args.body; } else { throw "Cannot derive function argument specification from an object of type: "+args.argSpec; } }
[ "function", "NixFunction", "(", "args", ")", "{", "if", "(", "args", ".", "argSpec", "===", "null", ")", "{", "throw", "\"Cannot derivate function argument specification from a null reference\"", ";", "}", "else", "if", "(", "typeof", "args", ".", "argSpec", "==", "\"string\"", "||", "typeof", "args", ".", "argSpec", "==", "\"object\"", ")", "{", "this", ".", "argSpec", "=", "args", ".", "argSpec", ";", "this", ".", "body", "=", "args", ".", "body", ";", "}", "else", "{", "throw", "\"Cannot derive function argument specification from an object of type: \"", "+", "args", ".", "argSpec", ";", "}", "}" ]
Creates a new NixFunction instance. @class NixFunction @extends NixBlock @classdesc Captures the abstract syntax of a Nix function consisting of an argument and function body. @constructor @param {Object} args Arguments to this function @param {Mixed} args.argSpec Argument specification of the function. If a string is given then the resulting function takes a single parameter with that name. If an array or object is given, then it's converted to an attribute set taking multiple parameters. In the former case, the array values correspond to the parameter names. In the latter case, the object keys are used as parameter names and their values are considered default values. @param {Mixed} args.body The body of the function, which can be a JavaScript object or an instance of the NixObject prototype
[ "Creates", "a", "new", "NixFunction", "instance", "." ]
4e2738cbff3a43aba9297315ca5120cecf8dae3e
https://github.com/svanderburg/nijs/blob/4e2738cbff3a43aba9297315ca5120cecf8dae3e/lib/ast/NixFunction.js#L23-L32
46,647
cosmojs/loopback-satellizer
index.js
function(req, res, next) { var requestTokenUrl = 'https://api.twitter.com/oauth/request_token'; var accessTokenUrl = 'https://api.twitter.com/oauth/access_token'; var authenticateUrl = 'https://api.twitter.com/oauth/authenticate'; // Step 2. Redirect to the authorization screen. if (!req.query.oauth_token || !req.query.oauth_verifier) { var requestTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, callback: config.TWITTER_CALLBACK }; request.post({ url: requestTokenUrl, oauth: requestTokenOauth }, function(err, response, body) { var oauthToken = qs.parse(body); var params = qs.stringify({ oauth_token: oauthToken.oauth_token }); res.redirect(authenticateUrl + '?' + params); }); return; } // Step 3. Exchange oauth token and oauth verifier for access token. var accessTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, token: req.query.oauth_token, verifier: req.query.oauth_verifier }; request.post({ url: accessTokenUrl, oauth: accessTokenOauth }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = qs.parse(profile); next(); }); }
javascript
function(req, res, next) { var requestTokenUrl = 'https://api.twitter.com/oauth/request_token'; var accessTokenUrl = 'https://api.twitter.com/oauth/access_token'; var authenticateUrl = 'https://api.twitter.com/oauth/authenticate'; // Step 2. Redirect to the authorization screen. if (!req.query.oauth_token || !req.query.oauth_verifier) { var requestTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, callback: config.TWITTER_CALLBACK }; request.post({ url: requestTokenUrl, oauth: requestTokenOauth }, function(err, response, body) { var oauthToken = qs.parse(body); var params = qs.stringify({ oauth_token: oauthToken.oauth_token }); res.redirect(authenticateUrl + '?' + params); }); return; } // Step 3. Exchange oauth token and oauth verifier for access token. var accessTokenOauth = { consumer_key: config.TWITTER_KEY, consumer_secret: config.TWITTER_SECRET, token: req.query.oauth_token, verifier: req.query.oauth_verifier }; request.post({ url: accessTokenUrl, oauth: accessTokenOauth }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = qs.parse(profile); next(); }); }
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "requestTokenUrl", "=", "'https://api.twitter.com/oauth/request_token'", ";", "var", "accessTokenUrl", "=", "'https://api.twitter.com/oauth/access_token'", ";", "var", "authenticateUrl", "=", "'https://api.twitter.com/oauth/authenticate'", ";", "// Step 2. Redirect to the authorization screen.", "if", "(", "!", "req", ".", "query", ".", "oauth_token", "||", "!", "req", ".", "query", ".", "oauth_verifier", ")", "{", "var", "requestTokenOauth", "=", "{", "consumer_key", ":", "config", ".", "TWITTER_KEY", ",", "consumer_secret", ":", "config", ".", "TWITTER_SECRET", ",", "callback", ":", "config", ".", "TWITTER_CALLBACK", "}", ";", "request", ".", "post", "(", "{", "url", ":", "requestTokenUrl", ",", "oauth", ":", "requestTokenOauth", "}", ",", "function", "(", "err", ",", "response", ",", "body", ")", "{", "var", "oauthToken", "=", "qs", ".", "parse", "(", "body", ")", ";", "var", "params", "=", "qs", ".", "stringify", "(", "{", "oauth_token", ":", "oauthToken", ".", "oauth_token", "}", ")", ";", "res", ".", "redirect", "(", "authenticateUrl", "+", "'?'", "+", "params", ")", ";", "}", ")", ";", "return", ";", "}", "// Step 3. Exchange oauth token and oauth verifier for access token.", "var", "accessTokenOauth", "=", "{", "consumer_key", ":", "config", ".", "TWITTER_KEY", ",", "consumer_secret", ":", "config", ".", "TWITTER_SECRET", ",", "token", ":", "req", ".", "query", ".", "oauth_token", ",", "verifier", ":", "req", ".", "query", ".", "oauth_verifier", "}", ";", "request", ".", "post", "(", "{", "url", ":", "accessTokenUrl", ",", "oauth", ":", "accessTokenOauth", "}", ",", "function", "(", "err", ",", "response", ",", "profile", ")", "{", "if", "(", "err", ")", "{", "res", ".", "status", "(", "500", ")", ".", "send", "(", "err", ")", ";", "return", ";", "}", "req", ".", "profile", "=", "qs", ".", "parse", "(", "profile", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
Step 1. Obtain request token for the authorization popup.
[ "Step", "1", ".", "Obtain", "request", "token", "for", "the", "authorization", "popup", "." ]
1c365d49eeb358f63c03b029fee4b16c50115fe1
https://github.com/cosmojs/loopback-satellizer/blob/1c365d49eeb358f63c03b029fee4b16c50115fe1/index.js#L729-L767
46,648
cosmojs/loopback-satellizer
index.js
function (req, res, next) { var prifile = req.profile; var filter = { or: [{ twitter: profile.user_id }, { email: profile.email }] }; User.find({ where: filter }, function(err, users) { var user = users[0]; if (user) { if (!user.twitter) { user.twitter = profile.user_id; user.displayName = user.displayName || profile.name; user.save(function() { req.user = user; next(); }); return; } req.user = user; next(); return; } User.create({ displayName: profile.name, yahoo: profile.user_id, email: profile.email, password: profile.user_id }, function (err, user) { req.user = user; next(); }); }); }
javascript
function (req, res, next) { var prifile = req.profile; var filter = { or: [{ twitter: profile.user_id }, { email: profile.email }] }; User.find({ where: filter }, function(err, users) { var user = users[0]; if (user) { if (!user.twitter) { user.twitter = profile.user_id; user.displayName = user.displayName || profile.name; user.save(function() { req.user = user; next(); }); return; } req.user = user; next(); return; } User.create({ displayName: profile.name, yahoo: profile.user_id, email: profile.email, password: profile.user_id }, function (err, user) { req.user = user; next(); }); }); }
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "prifile", "=", "req", ".", "profile", ";", "var", "filter", "=", "{", "or", ":", "[", "{", "twitter", ":", "profile", ".", "user_id", "}", ",", "{", "email", ":", "profile", ".", "email", "}", "]", "}", ";", "User", ".", "find", "(", "{", "where", ":", "filter", "}", ",", "function", "(", "err", ",", "users", ")", "{", "var", "user", "=", "users", "[", "0", "]", ";", "if", "(", "user", ")", "{", "if", "(", "!", "user", ".", "twitter", ")", "{", "user", ".", "twitter", "=", "profile", ".", "user_id", ";", "user", ".", "displayName", "=", "user", ".", "displayName", "||", "profile", ".", "name", ";", "user", ".", "save", "(", "function", "(", ")", "{", "req", ".", "user", "=", "user", ";", "next", "(", ")", ";", "}", ")", ";", "return", ";", "}", "req", ".", "user", "=", "user", ";", "next", "(", ")", ";", "return", ";", "}", "User", ".", "create", "(", "{", "displayName", ":", "profile", ".", "name", ",", "yahoo", ":", "profile", ".", "user_id", ",", "email", ":", "profile", ".", "email", ",", "password", ":", "profile", ".", "user_id", "}", ",", "function", "(", "err", ",", "user", ")", "{", "req", ".", "user", "=", "user", ";", "next", "(", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Step 4b. Create a new user account or return an existing one.
[ "Step", "4b", ".", "Create", "a", "new", "user", "account", "or", "return", "an", "existing", "one", "." ]
1c365d49eeb358f63c03b029fee4b16c50115fe1
https://github.com/cosmojs/loopback-satellizer/blob/1c365d49eeb358f63c03b029fee4b16c50115fe1/index.js#L802-L836
46,649
cosmojs/loopback-satellizer
index.js
function (req, res, next) { var profileUrl = 'https://api.foursquare.com/v2/users/self'; var params = { v: '20140806', oauth_token: req.accessToken }; request.get({ url: profileUrl, qs: params, json: true }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = profile.response.user; next(); }); }
javascript
function (req, res, next) { var profileUrl = 'https://api.foursquare.com/v2/users/self'; var params = { v: '20140806', oauth_token: req.accessToken }; request.get({ url: profileUrl, qs: params, json: true }, function(err, response, profile) { if (err) { res.status(500).send(err); return; } req.profile = profile.response.user; next(); }); }
[ "function", "(", "req", ",", "res", ",", "next", ")", "{", "var", "profileUrl", "=", "'https://api.foursquare.com/v2/users/self'", ";", "var", "params", "=", "{", "v", ":", "'20140806'", ",", "oauth_token", ":", "req", ".", "accessToken", "}", ";", "request", ".", "get", "(", "{", "url", ":", "profileUrl", ",", "qs", ":", "params", ",", "json", ":", "true", "}", ",", "function", "(", "err", ",", "response", ",", "profile", ")", "{", "if", "(", "err", ")", "{", "res", ".", "status", "(", "500", ")", ".", "send", "(", "err", ")", ";", "return", ";", "}", "req", ".", "profile", "=", "profile", ".", "response", ".", "user", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
Step 2. Retrieve information about the current user.
[ "Step", "2", ".", "Retrieve", "information", "about", "the", "current", "user", "." ]
1c365d49eeb358f63c03b029fee4b16c50115fe1
https://github.com/cosmojs/loopback-satellizer/blob/1c365d49eeb358f63c03b029fee4b16c50115fe1/index.js#L862-L877
46,650
Jellyvision/lateralus
src/lateralus.mixins.js
getAugmentedOptionsObject
function getAugmentedOptionsObject (initialObject) { // jshint validthis:true const thisIsLateralus = isLateralus(this); const augmentedOptions = _.extend(initialObject || {}, { lateralus: thisIsLateralus ? this : this.lateralus }); if (!thisIsLateralus) { augmentedOptions.component = this.component || this; } return augmentedOptions; }
javascript
function getAugmentedOptionsObject (initialObject) { // jshint validthis:true const thisIsLateralus = isLateralus(this); const augmentedOptions = _.extend(initialObject || {}, { lateralus: thisIsLateralus ? this : this.lateralus }); if (!thisIsLateralus) { augmentedOptions.component = this.component || this; } return augmentedOptions; }
[ "function", "getAugmentedOptionsObject", "(", "initialObject", ")", "{", "// jshint validthis:true", "const", "thisIsLateralus", "=", "isLateralus", "(", "this", ")", ";", "const", "augmentedOptions", "=", "_", ".", "extend", "(", "initialObject", "||", "{", "}", ",", "{", "lateralus", ":", "thisIsLateralus", "?", "this", ":", "this", ".", "lateralus", "}", ")", ";", "if", "(", "!", "thisIsLateralus", ")", "{", "augmentedOptions", ".", "component", "=", "this", ".", "component", "||", "this", ";", "}", "return", "augmentedOptions", ";", "}" ]
Helper function for initModel and initCollection. @param {Object} [initialObject] @return {{ lateralus: Lateralus, component: Lateralus.Component= }} `component` is not defined if `this` is the Lateralus instance. @private
[ "Helper", "function", "for", "initModel", "and", "initCollection", "." ]
feaa3e27536de6d53cf9648529a4c61380535be8
https://github.com/Jellyvision/lateralus/blob/feaa3e27536de6d53cf9648529a4c61380535be8/src/lateralus.mixins.js#L393-L405
46,651
thealjey/webcompiler
lib/logger.js
formatLine
function formatLine(message, file, line, column) { const { yellow, cyan, magenta } = consoleStyles; return ['"', yellow(message), '" in ', cyan((0, _path.relative)('', file)), ' on ', magenta(line), ':', magenta(column)]; }
javascript
function formatLine(message, file, line, column) { const { yellow, cyan, magenta } = consoleStyles; return ['"', yellow(message), '" in ', cyan((0, _path.relative)('', file)), ' on ', magenta(line), ':', magenta(column)]; }
[ "function", "formatLine", "(", "message", ",", "file", ",", "line", ",", "column", ")", "{", "const", "{", "yellow", ",", "cyan", ",", "magenta", "}", "=", "consoleStyles", ";", "return", "[", "'\"'", ",", "yellow", "(", "message", ")", ",", "'\" in '", ",", "cyan", "(", "(", "0", ",", "_path", ".", "relative", ")", "(", "''", ",", "file", ")", ")", ",", "' on '", ",", "magenta", "(", "line", ")", ",", "':'", ",", "magenta", "(", "column", ")", "]", ";", "}" ]
Formats an error line with colors. @memberof module:logger @private @function formatLine @param {string} message - error message @param {string} file - offending file @param {number | string} line - offending line @param {number | string} column - offending column @return {Array<string | module:logger.Message>} styled messages
[ "Formats", "an", "error", "line", "with", "colors", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L284-L288
46,652
thealjey/webcompiler
lib/logger.js
formatErrorMarker
function formatErrorMarker(message = 'Error') { const { bold, bgRed, white } = consoleStyles; return bgRed(bold(white(message))); }
javascript
function formatErrorMarker(message = 'Error') { const { bold, bgRed, white } = consoleStyles; return bgRed(bold(white(message))); }
[ "function", "formatErrorMarker", "(", "message", "=", "'Error'", ")", "{", "const", "{", "bold", ",", "bgRed", ",", "white", "}", "=", "consoleStyles", ";", "return", "bgRed", "(", "bold", "(", "white", "(", "message", ")", ")", ")", ";", "}" ]
Returns a string "Error" styled as a bold white text on a red background, ready to be printed to the console. @memberof module:logger @private @function formatErrorMarker @param {string} [message="Error"] - a message to apply styles to @return {module:logger.Message} a styled message
[ "Returns", "a", "string", "Error", "styled", "as", "a", "bold", "white", "text", "on", "a", "red", "background", "ready", "to", "be", "printed", "to", "the", "console", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L299-L303
46,653
thealjey/webcompiler
lib/logger.js
log
function log(...messages) { const { message, styles } = new Message({ ansi: ['', ''], css: '' }).addMessages(messages); console.log(message, ...styles); }
javascript
function log(...messages) { const { message, styles } = new Message({ ansi: ['', ''], css: '' }).addMessages(messages); console.log(message, ...styles); }
[ "function", "log", "(", "...", "messages", ")", "{", "const", "{", "message", ",", "styles", "}", "=", "new", "Message", "(", "{", "ansi", ":", "[", "''", ",", "''", "]", ",", "css", ":", "''", "}", ")", ".", "addMessages", "(", "messages", ")", ";", "console", ".", "log", "(", "message", ",", "...", "styles", ")", ";", "}" ]
Log colorful messages out to the console on Node.js as well as in a browser in the simplest and most composable way. @memberof module:logger @function log @param {...(string | number | module:logger.Message)} messages - messages to log @example import {log, consoleStyles} from 'webcompiler'; // or - import {log, consoleStyles} from 'webcompiler/lib/logger'; // or - var webcompiler = require('webcompiler'); // var log = webcompiler.log; // var consoleStyles = webcompiler.consoleStyles; // or - var logger = require('webcompiler/lib/logger'); // var log = logger.log; // var consoleStyles = logger.consoleStyles; const {red, green, blue, bold, underline} = consoleStyles; log('Colorful ', bold(red('R'), green('G'), blue('B')), ' logs are ', underline('very'), ' easy!');
[ "Log", "colorful", "messages", "out", "to", "the", "console", "on", "Node", ".", "js", "as", "well", "as", "in", "a", "browser", "in", "the", "simplest", "and", "most", "composable", "way", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L325-L329
46,654
thealjey/webcompiler
lib/logger.js
logPostCSSWarnings
function logPostCSSWarnings(warnings) { (0, _forEach2.default)(warnings, ({ text, plugin, node: { source: { input: { file } } }, line, column }) => { log(formatErrorMarker('Warning'), ': ', ...formatLine(`${text}(${plugin})`, file, line, column)); }); log('PostCSS warnings: ', warnings.length); }
javascript
function logPostCSSWarnings(warnings) { (0, _forEach2.default)(warnings, ({ text, plugin, node: { source: { input: { file } } }, line, column }) => { log(formatErrorMarker('Warning'), ': ', ...formatLine(`${text}(${plugin})`, file, line, column)); }); log('PostCSS warnings: ', warnings.length); }
[ "function", "logPostCSSWarnings", "(", "warnings", ")", "{", "(", "0", ",", "_forEach2", ".", "default", ")", "(", "warnings", ",", "(", "{", "text", ",", "plugin", ",", "node", ":", "{", "source", ":", "{", "input", ":", "{", "file", "}", "}", "}", ",", "line", ",", "column", "}", ")", "=>", "{", "log", "(", "formatErrorMarker", "(", "'Warning'", ")", ",", "': '", ",", "...", "formatLine", "(", "`", "${", "text", "}", "${", "plugin", "}", "`", ",", "file", ",", "line", ",", "column", ")", ")", ";", "}", ")", ";", "log", "(", "'PostCSS warnings: '", ",", "warnings", ".", "length", ")", ";", "}" ]
Prints PostCSS Warning objects out to the console. @memberof module:logger @function logPostCSSWarnings @param {Array<PostCSSWarning>} warnings - warning objects @example import {logPostCSSWarnings} from 'webcompiler'; // or - import {logPostCSSWarnings} from 'webcompiler/lib/logger'; // or - var logPostCSSWarnings = require('webcompiler').logPostCSSWarnings; // or - var logPostCSSWarnings = require('webcompiler/lib/logger').logPostCSSWarnings; import postcss from 'postcss'; postcss(...).process(...).then(result => { const warnings = result.warnings(); if (warnings.length) { return logPostCSSWarnings(warnings); } ... });
[ "Prints", "PostCSS", "Warning", "objects", "out", "to", "the", "console", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L382-L387
46,655
thealjey/webcompiler
lib/logger.js
logSASSError
function logSASSError({ message, file, line, column }) { log(formatErrorMarker('SASS error'), ': ', ...formatLine(message, file, line, column)); }
javascript
function logSASSError({ message, file, line, column }) { log(formatErrorMarker('SASS error'), ': ', ...formatLine(message, file, line, column)); }
[ "function", "logSASSError", "(", "{", "message", ",", "file", ",", "line", ",", "column", "}", ")", "{", "log", "(", "formatErrorMarker", "(", "'SASS error'", ")", ",", "': '", ",", "...", "formatLine", "(", "message", ",", "file", ",", "line", ",", "column", ")", ")", ";", "}" ]
Prints a Node SASS error object out to the console. @memberof module:logger @function logSASSError @param {NodeSassError} error - error object @example import {logSASSError} from 'webcompiler'; // or - import {logSASSError} from 'webcompiler/lib/logger'; // or - var logSASSError = require('webcompiler').logSASSError; // or - var logSASSError = require('webcompiler/lib/logger').logSASSError; import {render} from 'node-sass'; render(..., (error, result) => { if (error) { return logSASSError(error); } ... });
[ "Prints", "a", "Node", "SASS", "error", "object", "out", "to", "the", "console", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L409-L411
46,656
thealjey/webcompiler
lib/logger.js
logLintingErrors
function logLintingErrors(errors, prefix = null) { (0, _forEach2.default)(errors, ({ message, rule, file, line, column }) => { log(formatErrorMarker(), ': ', ...formatLine(`${message}${rule ? ` (${rule})` : ''}`, file, line, column)); }); log(prefix ? `${prefix} l` : 'L', 'inting errors: ', errors.length); }
javascript
function logLintingErrors(errors, prefix = null) { (0, _forEach2.default)(errors, ({ message, rule, file, line, column }) => { log(formatErrorMarker(), ': ', ...formatLine(`${message}${rule ? ` (${rule})` : ''}`, file, line, column)); }); log(prefix ? `${prefix} l` : 'L', 'inting errors: ', errors.length); }
[ "function", "logLintingErrors", "(", "errors", ",", "prefix", "=", "null", ")", "{", "(", "0", ",", "_forEach2", ".", "default", ")", "(", "errors", ",", "(", "{", "message", ",", "rule", ",", "file", ",", "line", ",", "column", "}", ")", "=>", "{", "log", "(", "formatErrorMarker", "(", ")", ",", "': '", ",", "...", "formatLine", "(", "`", "${", "message", "}", "${", "rule", "?", "`", "${", "rule", "}", "`", ":", "''", "}", "`", ",", "file", ",", "line", ",", "column", ")", ")", ";", "}", ")", ";", "log", "(", "prefix", "?", "`", "${", "prefix", "}", "`", ":", "'L'", ",", "'inting errors: '", ",", "errors", ".", "length", ")", ";", "}" ]
Prints linting errors out to the console. @memberof module:logger @function logLintingErrors @param {Array<LintError>} errors - error objects @param {string} [prefix=null] - will be printed on the last line along with the total number of messages @example import {logLintingErrors} from 'webcompiler'; // or - import {logLintingErrors} from 'webcompiler/lib/logger'; // or - var logLintingErrors = require('webcompiler').logLintingErrors; // or - var logLintingErrors = require('webcompiler/lib/logger').logLintingErrors;
[ "Prints", "linting", "errors", "out", "to", "the", "console", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/logger.js#L426-L431
46,657
Hugo-ter-Doest/chart-parsers
lib/ProductionRule.js
ProductionRule
function ProductionRule(lhs, rhs, head) { this.lhs = lhs; this.rhs = rhs; this.head = head; // feature structure of the constraints specified with the rule this.fs = null; }
javascript
function ProductionRule(lhs, rhs, head) { this.lhs = lhs; this.rhs = rhs; this.head = head; // feature structure of the constraints specified with the rule this.fs = null; }
[ "function", "ProductionRule", "(", "lhs", ",", "rhs", ",", "head", ")", "{", "this", ".", "lhs", "=", "lhs", ";", "this", ".", "rhs", "=", "rhs", ";", "this", ".", "head", "=", "head", ";", "// feature structure of the constraints specified with the rule", "this", ".", "fs", "=", "null", ";", "}" ]
Constructor - lhs is a string - rhs is an array of strings - head is a number pointing to a rhs nonterminal
[ "Constructor", "-", "lhs", "is", "a", "string", "-", "rhs", "is", "an", "array", "of", "strings", "-", "head", "is", "a", "number", "pointing", "to", "a", "rhs", "nonterminal" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/lib/ProductionRule.js#L33-L39
46,658
paritytech/js-jsonrpc
scripts/helpers/parsed-rpc-traits.js
parseMethodsFromRust
function parseMethodsFromRust (source) { // Matching the custom `rpc` attribute with it's doc comment const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm; const commentPattern = /\s*\/\/\/\s*/g; const separatorPattern = /\s*,\s*/g; const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/; const ignorePattern = /@(ignore|deprecated|unimplemented|alias)\b/i; const methods = []; source.toString().replace(attributePattern, (match, comment, props) => { comment = comment.replace(commentPattern, '\n').trim(); // Skip deprecated methods if (ignorePattern.test(comment)) { return match; } props.split(separatorPattern).forEach((prop) => { const [, key, value] = prop.split(assignPattern) || []; if (key === 'name' && value != null) { methods.push(value); } }); return match; }); return methods; }
javascript
function parseMethodsFromRust (source) { // Matching the custom `rpc` attribute with it's doc comment const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm; const commentPattern = /\s*\/\/\/\s*/g; const separatorPattern = /\s*,\s*/g; const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/; const ignorePattern = /@(ignore|deprecated|unimplemented|alias)\b/i; const methods = []; source.toString().replace(attributePattern, (match, comment, props) => { comment = comment.replace(commentPattern, '\n').trim(); // Skip deprecated methods if (ignorePattern.test(comment)) { return match; } props.split(separatorPattern).forEach((prop) => { const [, key, value] = prop.split(assignPattern) || []; if (key === 'name' && value != null) { methods.push(value); } }); return match; }); return methods; }
[ "function", "parseMethodsFromRust", "(", "source", ")", "{", "// Matching the custom `rpc` attribute with it's doc comment", "const", "attributePattern", "=", "/", "((?:\\s*\\/\\/\\/.*$)*)\\s*#\\[rpc\\(([^)]+)\\)]", "/", "gm", ";", "const", "commentPattern", "=", "/", "\\s*\\/\\/\\/\\s*", "/", "g", ";", "const", "separatorPattern", "=", "/", "\\s*,\\s*", "/", "g", ";", "const", "assignPattern", "=", "/", "([\\S]+)\\s*=\\s*\"([^\"]*)\"", "/", ";", "const", "ignorePattern", "=", "/", "@(ignore|deprecated|unimplemented|alias)\\b", "/", "i", ";", "const", "methods", "=", "[", "]", ";", "source", ".", "toString", "(", ")", ".", "replace", "(", "attributePattern", ",", "(", "match", ",", "comment", ",", "props", ")", "=>", "{", "comment", "=", "comment", ".", "replace", "(", "commentPattern", ",", "'\\n'", ")", ".", "trim", "(", ")", ";", "// Skip deprecated methods", "if", "(", "ignorePattern", ".", "test", "(", "comment", ")", ")", "{", "return", "match", ";", "}", "props", ".", "split", "(", "separatorPattern", ")", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "const", "[", ",", "key", ",", "value", "]", "=", "prop", ".", "split", "(", "assignPattern", ")", "||", "[", "]", ";", "if", "(", "key", "===", "'name'", "&&", "value", "!=", "null", ")", "{", "methods", ".", "push", "(", "value", ")", ";", "}", "}", ")", ";", "return", "match", ";", "}", ")", ";", "return", "methods", ";", "}" ]
Get a list of JSON-RPC from Rust trait source code
[ "Get", "a", "list", "of", "JSON", "-", "RPC", "from", "Rust", "trait", "source", "code" ]
045b8953926cbc0f663de328954f1ca4ba8a4e7c
https://github.com/paritytech/js-jsonrpc/blob/045b8953926cbc0f663de328954f1ca4ba8a4e7c/scripts/helpers/parsed-rpc-traits.js#L26-L56
46,659
paritytech/js-jsonrpc
scripts/helpers/parsed-rpc-traits.js
getMethodsFromRustTraits
function getMethodsFromRustTraits () { const traitsDir = path.join(__dirname, '../../.parity/rpc/src/v1/traits'); return fs .readdirSync(traitsDir) .filter((name) => name !== 'mod.rs' && /\.rs$/.test(name)) .map((name) => fs.readFileSync(path.join(traitsDir, name))) .map(parseMethodsFromRust) .reduce((a, b) => a.concat(b)); }
javascript
function getMethodsFromRustTraits () { const traitsDir = path.join(__dirname, '../../.parity/rpc/src/v1/traits'); return fs .readdirSync(traitsDir) .filter((name) => name !== 'mod.rs' && /\.rs$/.test(name)) .map((name) => fs.readFileSync(path.join(traitsDir, name))) .map(parseMethodsFromRust) .reduce((a, b) => a.concat(b)); }
[ "function", "getMethodsFromRustTraits", "(", ")", "{", "const", "traitsDir", "=", "path", ".", "join", "(", "__dirname", ",", "'../../.parity/rpc/src/v1/traits'", ")", ";", "return", "fs", ".", "readdirSync", "(", "traitsDir", ")", ".", "filter", "(", "(", "name", ")", "=>", "name", "!==", "'mod.rs'", "&&", "/", "\\.rs$", "/", ".", "test", "(", "name", ")", ")", ".", "map", "(", "(", "name", ")", "=>", "fs", ".", "readFileSync", "(", "path", ".", "join", "(", "traitsDir", ",", "name", ")", ")", ")", ".", "map", "(", "parseMethodsFromRust", ")", ".", "reduce", "(", "(", "a", ",", "b", ")", "=>", "a", ".", "concat", "(", "b", ")", ")", ";", "}" ]
Get a list of all JSON-RPC methods from all defined traits
[ "Get", "a", "list", "of", "all", "JSON", "-", "RPC", "methods", "from", "all", "defined", "traits" ]
045b8953926cbc0f663de328954f1ca4ba8a4e7c
https://github.com/paritytech/js-jsonrpc/blob/045b8953926cbc0f663de328954f1ca4ba8a4e7c/scripts/helpers/parsed-rpc-traits.js#L59-L68
46,660
d-oliveros/isomorphine
src/util.js
firstFunction
function firstFunction(args) { for (var i = 0, len = args.length; i < len; i++) { if (typeof args[i] === 'function') { return args[i]; } } return null; }
javascript
function firstFunction(args) { for (var i = 0, len = args.length; i < len; i++) { if (typeof args[i] === 'function') { return args[i]; } } return null; }
[ "function", "firstFunction", "(", "args", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "args", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "typeof", "args", "[", "i", "]", "===", "'function'", ")", "{", "return", "args", "[", "i", "]", ";", "}", "}", "return", "null", ";", "}" ]
Returns the first function in an array. @param {Array} args The array to take the function from. @return {Function} The resulting function, or null.
[ "Returns", "the", "first", "function", "in", "an", "array", "." ]
cb123d16b4be3bb7ec57758bd0b2e43767e91864
https://github.com/d-oliveros/isomorphine/blob/cb123d16b4be3bb7ec57758bd0b2e43767e91864/src/util.js#L31-L39
46,661
d-oliveros/isomorphine
src/util.js
serializeCallback
function serializeCallback(args) { var callback; debug('Transforming callback in ', args); return args.map(function(arg) { if (typeof arg !== 'function') return arg; // It shouldn't be an argument after the callback function invariant(!callback, 'Only one callback function is allowed.'); callback = arg; return '__clientCallback__'; }); }
javascript
function serializeCallback(args) { var callback; debug('Transforming callback in ', args); return args.map(function(arg) { if (typeof arg !== 'function') return arg; // It shouldn't be an argument after the callback function invariant(!callback, 'Only one callback function is allowed.'); callback = arg; return '__clientCallback__'; }); }
[ "function", "serializeCallback", "(", "args", ")", "{", "var", "callback", ";", "debug", "(", "'Transforming callback in '", ",", "args", ")", ";", "return", "args", ".", "map", "(", "function", "(", "arg", ")", "{", "if", "(", "typeof", "arg", "!==", "'function'", ")", "return", "arg", ";", "// It shouldn't be an argument after the callback function", "invariant", "(", "!", "callback", ",", "'Only one callback function is allowed.'", ")", ";", "callback", "=", "arg", ";", "return", "'__clientCallback__'", ";", "}", ")", ";", "}" ]
Transforms the client's callback function to a callback notice string. @param {Array} args Array of arguments to transform. @return {Array} The transformed arguments array.
[ "Transforms", "the", "client", "s", "callback", "function", "to", "a", "callback", "notice", "string", "." ]
cb123d16b4be3bb7ec57758bd0b2e43767e91864
https://github.com/d-oliveros/isomorphine/blob/cb123d16b4be3bb7ec57758bd0b2e43767e91864/src/util.js#L47-L62
46,662
d-oliveros/isomorphine
src/util.js
promisify
function promisify(func) { return function promisified() { var args = Array.prototype.slice.call(arguments); var context = this; return new Promise(function(resolve, reject) { try { func.apply(context, args.concat(function(err, data) { if (err) { return reject(err); } resolve(data); })); } catch(err) { reject(err); } }); }; }
javascript
function promisify(func) { return function promisified() { var args = Array.prototype.slice.call(arguments); var context = this; return new Promise(function(resolve, reject) { try { func.apply(context, args.concat(function(err, data) { if (err) { return reject(err); } resolve(data); })); } catch(err) { reject(err); } }); }; }
[ "function", "promisify", "(", "func", ")", "{", "return", "function", "promisified", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "var", "context", "=", "this", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "try", "{", "func", ".", "apply", "(", "context", ",", "args", ".", "concat", "(", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "return", "reject", "(", "err", ")", ";", "}", "resolve", "(", "data", ")", ";", "}", ")", ")", ";", "}", "catch", "(", "err", ")", "{", "reject", "(", "err", ")", ";", "}", "}", ")", ";", "}", ";", "}" ]
Transforms a callback-based function flow to a promise-based flow
[ "Transforms", "a", "callback", "-", "based", "function", "flow", "to", "a", "promise", "-", "based", "flow" ]
cb123d16b4be3bb7ec57758bd0b2e43767e91864
https://github.com/d-oliveros/isomorphine/blob/cb123d16b4be3bb7ec57758bd0b2e43767e91864/src/util.js#L67-L86
46,663
d-oliveros/isomorphine
src/util.js
changeConfig
function changeConfig(oldConfig, newConfig) { invariant(isObject(oldConfig), 'Old config is not valid'); invariant(isObject(newConfig), 'Config is not valid'); if (newConfig.host) { var host = newConfig.host; var prefix = ''; if (host.indexOf('http://') < 0 && host.indexOf('https://') < 0) { prefix += 'http://'; } oldConfig.host = prefix + newConfig.host; } if (newConfig.port) { oldConfig.port = newConfig.port; } }
javascript
function changeConfig(oldConfig, newConfig) { invariant(isObject(oldConfig), 'Old config is not valid'); invariant(isObject(newConfig), 'Config is not valid'); if (newConfig.host) { var host = newConfig.host; var prefix = ''; if (host.indexOf('http://') < 0 && host.indexOf('https://') < 0) { prefix += 'http://'; } oldConfig.host = prefix + newConfig.host; } if (newConfig.port) { oldConfig.port = newConfig.port; } }
[ "function", "changeConfig", "(", "oldConfig", ",", "newConfig", ")", "{", "invariant", "(", "isObject", "(", "oldConfig", ")", ",", "'Old config is not valid'", ")", ";", "invariant", "(", "isObject", "(", "newConfig", ")", ",", "'Config is not valid'", ")", ";", "if", "(", "newConfig", ".", "host", ")", "{", "var", "host", "=", "newConfig", ".", "host", ";", "var", "prefix", "=", "''", ";", "if", "(", "host", ".", "indexOf", "(", "'http://'", ")", "<", "0", "&&", "host", ".", "indexOf", "(", "'https://'", ")", "<", "0", ")", "{", "prefix", "+=", "'http://'", ";", "}", "oldConfig", ".", "host", "=", "prefix", "+", "newConfig", ".", "host", ";", "}", "if", "(", "newConfig", ".", "port", ")", "{", "oldConfig", ".", "port", "=", "newConfig", ".", "port", ";", "}", "}" ]
Updates a config object @param {Object} oldConfig Old configuration object @param {Object} newConfig New configuration object @return {Undefined}
[ "Updates", "a", "config", "object" ]
cb123d16b4be3bb7ec57758bd0b2e43767e91864
https://github.com/d-oliveros/isomorphine/blob/cb123d16b4be3bb7ec57758bd0b2e43767e91864/src/util.js#L155-L173
46,664
phadej/ljs
lib/literate.js
appendCode
function appendCode() { if (state === "code") { state = "text"; if (!isWhitespace(codeBuffer)) { content += codeOpen + codeBuffer.replace(/^(?:\s*\n)+/, "").replace(/[\s\n]*$/, "") + codeClose; } codeBuffer = ""; } }
javascript
function appendCode() { if (state === "code") { state = "text"; if (!isWhitespace(codeBuffer)) { content += codeOpen + codeBuffer.replace(/^(?:\s*\n)+/, "").replace(/[\s\n]*$/, "") + codeClose; } codeBuffer = ""; } }
[ "function", "appendCode", "(", ")", "{", "if", "(", "state", "===", "\"code\"", ")", "{", "state", "=", "\"text\"", ";", "if", "(", "!", "isWhitespace", "(", "codeBuffer", ")", ")", "{", "content", "+=", "codeOpen", "+", "codeBuffer", ".", "replace", "(", "/", "^(?:\\s*\\n)+", "/", ",", "\"\"", ")", ".", "replace", "(", "/", "[\\s\\n]*$", "/", ",", "\"\"", ")", "+", "codeClose", ";", "}", "codeBuffer", "=", "\"\"", ";", "}", "}" ]
buffer for code output
[ "buffer", "for", "code", "output" ]
2ef94df30174a0aa12a65dbe0a66128b3c2726bb
https://github.com/phadej/ljs/blob/2ef94df30174a0aa12a65dbe0a66128b3c2726bb/lib/literate.js#L127-L135
46,665
camme/plugwisejs
plugwise.js
sendCommand
function sendCommand(command, mac, params, callback, scope) { var commandParts = []; // check for callback instead of params if (typeof params == 'function') { callback = params; params = ''; scope = callback; } var completeCommand = ''; completeCommand += command.request; commandParts.push(command.request); if (mac) { commandParts.push(mac); completeCommand += mac; } if (params) { commandParts.push(params); completeCommand += params; } var crcChecksum = crc.crc16(completeCommand).toString(16).toUpperCase(); if (crcChecksum.length < 2) { crcChecksum = "000" + crcChecksum; } else if (crcChecksum.length < 3) { crcChecksum = "00" + crcChecksum; } else if (crcChecksum.length < 4) { crcChecksum = "0" + crcChecksum; } commandParts.push(crcChecksum); completeCommand = protocolCommands.frames.start + commandParts.join("") + protocolCommands.frames.end; commandStack.push({mac: mac,command: command, ack:'', callback: callback, scope: scope}); if (options.log > 0) { console.log('---'); console.log(command.color + "SEND " , command.name + ":\t" + commandParts.join("\t") + colors.reset); } sp.write(completeCommand); // we use a counter to know how many ack we are up in compared to commands ackCounter -= 1; return completeCommand; }
javascript
function sendCommand(command, mac, params, callback, scope) { var commandParts = []; // check for callback instead of params if (typeof params == 'function') { callback = params; params = ''; scope = callback; } var completeCommand = ''; completeCommand += command.request; commandParts.push(command.request); if (mac) { commandParts.push(mac); completeCommand += mac; } if (params) { commandParts.push(params); completeCommand += params; } var crcChecksum = crc.crc16(completeCommand).toString(16).toUpperCase(); if (crcChecksum.length < 2) { crcChecksum = "000" + crcChecksum; } else if (crcChecksum.length < 3) { crcChecksum = "00" + crcChecksum; } else if (crcChecksum.length < 4) { crcChecksum = "0" + crcChecksum; } commandParts.push(crcChecksum); completeCommand = protocolCommands.frames.start + commandParts.join("") + protocolCommands.frames.end; commandStack.push({mac: mac,command: command, ack:'', callback: callback, scope: scope}); if (options.log > 0) { console.log('---'); console.log(command.color + "SEND " , command.name + ":\t" + commandParts.join("\t") + colors.reset); } sp.write(completeCommand); // we use a counter to know how many ack we are up in compared to commands ackCounter -= 1; return completeCommand; }
[ "function", "sendCommand", "(", "command", ",", "mac", ",", "params", ",", "callback", ",", "scope", ")", "{", "var", "commandParts", "=", "[", "]", ";", "// check for callback instead of params", "if", "(", "typeof", "params", "==", "'function'", ")", "{", "callback", "=", "params", ";", "params", "=", "''", ";", "scope", "=", "callback", ";", "}", "var", "completeCommand", "=", "''", ";", "completeCommand", "+=", "command", ".", "request", ";", "commandParts", ".", "push", "(", "command", ".", "request", ")", ";", "if", "(", "mac", ")", "{", "commandParts", ".", "push", "(", "mac", ")", ";", "completeCommand", "+=", "mac", ";", "}", "if", "(", "params", ")", "{", "commandParts", ".", "push", "(", "params", ")", ";", "completeCommand", "+=", "params", ";", "}", "var", "crcChecksum", "=", "crc", ".", "crc16", "(", "completeCommand", ")", ".", "toString", "(", "16", ")", ".", "toUpperCase", "(", ")", ";", "if", "(", "crcChecksum", ".", "length", "<", "2", ")", "{", "crcChecksum", "=", "\"000\"", "+", "crcChecksum", ";", "}", "else", "if", "(", "crcChecksum", ".", "length", "<", "3", ")", "{", "crcChecksum", "=", "\"00\"", "+", "crcChecksum", ";", "}", "else", "if", "(", "crcChecksum", ".", "length", "<", "4", ")", "{", "crcChecksum", "=", "\"0\"", "+", "crcChecksum", ";", "}", "commandParts", ".", "push", "(", "crcChecksum", ")", ";", "completeCommand", "=", "protocolCommands", ".", "frames", ".", "start", "+", "commandParts", ".", "join", "(", "\"\"", ")", "+", "protocolCommands", ".", "frames", ".", "end", ";", "commandStack", ".", "push", "(", "{", "mac", ":", "mac", ",", "command", ":", "command", ",", "ack", ":", "''", ",", "callback", ":", "callback", ",", "scope", ":", "scope", "}", ")", ";", "if", "(", "options", ".", "log", ">", "0", ")", "{", "console", ".", "log", "(", "'---'", ")", ";", "console", ".", "log", "(", "command", ".", "color", "+", "\"SEND \"", ",", "command", ".", "name", "+", "\":\\t\"", "+", "commandParts", ".", "join", "(", "\"\\t\"", ")", "+", "colors", ".", "reset", ")", ";", "}", "sp", ".", "write", "(", "completeCommand", ")", ";", "// we use a counter to know how many ack we are up in compared to commands", "ackCounter", "-=", "1", ";", "return", "completeCommand", ";", "}" ]
builds the command string and sends it
[ "builds", "the", "command", "string", "and", "sends", "it" ]
04bc02a8f734e6833cc2bf03d6e8d5b88863ea9e
https://github.com/camme/plugwisejs/blob/04bc02a8f734e6833cc2bf03d6e8d5b88863ea9e/plugwise.js#L243-L295
46,666
Zerg00s/spforms
src/Templates/App/services/spFormFactory.js
addFileToFolder
function addFileToFolder(arrayBuffer) { // Construct the endpoint. var fileCollectionEndpoint = String.format(spFormFactory.getFileEndpointUri(_spPageContextInfo.webAbsoluteUrl, doclibname, foldername) + "/add(overwrite=true, url='{0}')", fileuniquename); // Send the request and return the response. // This call returns the SharePoint file. return jQuery.ajax({ url: fileCollectionEndpoint, type: "POST", data: arrayBuffer, processData: false, headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() //,"content-length": arrayBuffer.byteLength } }); }
javascript
function addFileToFolder(arrayBuffer) { // Construct the endpoint. var fileCollectionEndpoint = String.format(spFormFactory.getFileEndpointUri(_spPageContextInfo.webAbsoluteUrl, doclibname, foldername) + "/add(overwrite=true, url='{0}')", fileuniquename); // Send the request and return the response. // This call returns the SharePoint file. return jQuery.ajax({ url: fileCollectionEndpoint, type: "POST", data: arrayBuffer, processData: false, headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() //,"content-length": arrayBuffer.byteLength } }); }
[ "function", "addFileToFolder", "(", "arrayBuffer", ")", "{", "// Construct the endpoint.", "var", "fileCollectionEndpoint", "=", "String", ".", "format", "(", "spFormFactory", ".", "getFileEndpointUri", "(", "_spPageContextInfo", ".", "webAbsoluteUrl", ",", "doclibname", ",", "foldername", ")", "+", "\"/add(overwrite=true, url='{0}')\"", ",", "fileuniquename", ")", ";", "// Send the request and return the response.", "// This call returns the SharePoint file.", "return", "jQuery", ".", "ajax", "(", "{", "url", ":", "fileCollectionEndpoint", ",", "type", ":", "\"POST\"", ",", "data", ":", "arrayBuffer", ",", "processData", ":", "false", ",", "headers", ":", "{", "\"accept\"", ":", "\"application/json;odata=verbose\"", ",", "\"X-RequestDigest\"", ":", "$", "(", "\"#__REQUESTDIGEST\"", ")", ".", "val", "(", ")", "//,\"content-length\": arrayBuffer.byteLength", "}", "}", ")", ";", "}" ]
}, onError); Add the file to the file collection in the Shared Documents folder.
[ "}", "onError", ")", ";", "Add", "the", "file", "to", "the", "file", "collection", "in", "the", "Shared", "Documents", "folder", "." ]
f8eaa19eeefa6ca7a3664138b76744f9c1d9ecec
https://github.com/Zerg00s/spforms/blob/f8eaa19eeefa6ca7a3664138b76744f9c1d9ecec/src/Templates/App/services/spFormFactory.js#L373-L391
46,667
Zerg00s/spforms
src/Templates/App/services/spFormFactory.js
updateListItem
function updateListItem(itemMetadata, customFileMetadata) { // Define the list item changes. Use the FileLeafRef property to change the display name. // Assemble the file update metadata var metadata = { __metadata: { type: itemMetadata.type }, FileLeafRef: fileuniquename, Title: filedisplayname }; // Add the custom metadata fields for this file to the metadata object if (typeof(customFileMetadata) === "object") $(metadata).extend(metadata, customFileMetadata); // Send the request and return the promise. // This call does not return response content from the server. var body = JSON.stringify(metadata); return $http.post(itemMetadata.uri, body, { headers: { "X-RequestDigest": $("#__REQUESTDIGEST").val(), "content-type": "application/json;odata=verbose", "content-length": body.length, "IF-MATCH": "*", "X-HTTP-Method": "MERGE" } }); }
javascript
function updateListItem(itemMetadata, customFileMetadata) { // Define the list item changes. Use the FileLeafRef property to change the display name. // Assemble the file update metadata var metadata = { __metadata: { type: itemMetadata.type }, FileLeafRef: fileuniquename, Title: filedisplayname }; // Add the custom metadata fields for this file to the metadata object if (typeof(customFileMetadata) === "object") $(metadata).extend(metadata, customFileMetadata); // Send the request and return the promise. // This call does not return response content from the server. var body = JSON.stringify(metadata); return $http.post(itemMetadata.uri, body, { headers: { "X-RequestDigest": $("#__REQUESTDIGEST").val(), "content-type": "application/json;odata=verbose", "content-length": body.length, "IF-MATCH": "*", "X-HTTP-Method": "MERGE" } }); }
[ "function", "updateListItem", "(", "itemMetadata", ",", "customFileMetadata", ")", "{", "// Define the list item changes. Use the FileLeafRef property to change the display name. ", "// Assemble the file update metadata ", "var", "metadata", "=", "{", "__metadata", ":", "{", "type", ":", "itemMetadata", ".", "type", "}", ",", "FileLeafRef", ":", "fileuniquename", ",", "Title", ":", "filedisplayname", "}", ";", "// Add the custom metadata fields for this file to the metadata object", "if", "(", "typeof", "(", "customFileMetadata", ")", "===", "\"object\"", ")", "$", "(", "metadata", ")", ".", "extend", "(", "metadata", ",", "customFileMetadata", ")", ";", "// Send the request and return the promise.", "// This call does not return response content from the server.", "var", "body", "=", "JSON", ".", "stringify", "(", "metadata", ")", ";", "return", "$http", ".", "post", "(", "itemMetadata", ".", "uri", ",", "body", ",", "{", "headers", ":", "{", "\"X-RequestDigest\"", ":", "$", "(", "\"#__REQUESTDIGEST\"", ")", ".", "val", "(", ")", ",", "\"content-type\"", ":", "\"application/json;odata=verbose\"", ",", "\"content-length\"", ":", "body", ".", "length", ",", "\"IF-MATCH\"", ":", "\"*\"", ",", "\"X-HTTP-Method\"", ":", "\"MERGE\"", "}", "}", ")", ";", "}" ]
Change the display name and title of the list item.
[ "Change", "the", "display", "name", "and", "title", "of", "the", "list", "item", "." ]
f8eaa19eeefa6ca7a3664138b76744f9c1d9ecec
https://github.com/Zerg00s/spforms/blob/f8eaa19eeefa6ca7a3664138b76744f9c1d9ecec/src/Templates/App/services/spFormFactory.js#L403-L429
46,668
anseki/process-bridge
process-bridge.js
parseIpcMessage
function parseIpcMessage(message, cb) { var requestId; if (message._requestId == null) { // eslint-disable-line eqeqeq throw new Error('Invalid message: ' + JSON.stringify(message)); } requestId = message._requestId; delete message._requestId; return cb(+requestId, message); }
javascript
function parseIpcMessage(message, cb) { var requestId; if (message._requestId == null) { // eslint-disable-line eqeqeq throw new Error('Invalid message: ' + JSON.stringify(message)); } requestId = message._requestId; delete message._requestId; return cb(+requestId, message); }
[ "function", "parseIpcMessage", "(", "message", ",", "cb", ")", "{", "var", "requestId", ";", "if", "(", "message", ".", "_requestId", "==", "null", ")", "{", "// eslint-disable-line eqeqeq", "throw", "new", "Error", "(", "'Invalid message: '", "+", "JSON", ".", "stringify", "(", "message", ")", ")", ";", "}", "requestId", "=", "message", ".", "_requestId", ";", "delete", "message", ".", "_requestId", ";", "return", "cb", "(", "+", "requestId", ",", "message", ")", ";", "}" ]
Callback that handles the parsed message object. @callback procMessage @param {string} requestId - ID of the message. @param {Object} message - The message object. Normalize an IPC message. @param {Object} message - IPC message. @param {procMessage} cb - Callback function that is called. @returns {any} Something that was returned by `cb`.
[ "Callback", "that", "handles", "the", "parsed", "message", "object", "." ]
3621bda208e1a94527636dacd0a8f4b9e42c9cd0
https://github.com/anseki/process-bridge/blob/3621bda208e1a94527636dacd0a8f4b9e42c9cd0/process-bridge.js#L39-L47
46,669
anseki/process-bridge
process-bridge.js
parseMessageLines
function parseMessageLines(lines, getLine, cb) { var matches, line, lineParts; if (arguments.length < 3) { cb = getLine; getLine = false; } RE_MESSAGE_LINE.lastIndex = 0; while ((matches = RE_MESSAGE_LINE.exec(lines))) { line = matches[1]; lines = matches[2]; if (line === '') { continue; } else if (getLine) { cb(line); // eslint-disable-line callback-return } else { lineParts = line.split('\t', 2); if (lineParts.length < 2 || !lineParts[0] || !lineParts[1]) { throw new Error('Invalid message: ' + line); } cb(+lineParts[0], JSON.parse(lineParts[1])); // eslint-disable-line callback-return } } return lines; }
javascript
function parseMessageLines(lines, getLine, cb) { var matches, line, lineParts; if (arguments.length < 3) { cb = getLine; getLine = false; } RE_MESSAGE_LINE.lastIndex = 0; while ((matches = RE_MESSAGE_LINE.exec(lines))) { line = matches[1]; lines = matches[2]; if (line === '') { continue; } else if (getLine) { cb(line); // eslint-disable-line callback-return } else { lineParts = line.split('\t', 2); if (lineParts.length < 2 || !lineParts[0] || !lineParts[1]) { throw new Error('Invalid message: ' + line); } cb(+lineParts[0], JSON.parse(lineParts[1])); // eslint-disable-line callback-return } } return lines; }
[ "function", "parseMessageLines", "(", "lines", ",", "getLine", ",", "cb", ")", "{", "var", "matches", ",", "line", ",", "lineParts", ";", "if", "(", "arguments", ".", "length", "<", "3", ")", "{", "cb", "=", "getLine", ";", "getLine", "=", "false", ";", "}", "RE_MESSAGE_LINE", ".", "lastIndex", "=", "0", ";", "while", "(", "(", "matches", "=", "RE_MESSAGE_LINE", ".", "exec", "(", "lines", ")", ")", ")", "{", "line", "=", "matches", "[", "1", "]", ";", "lines", "=", "matches", "[", "2", "]", ";", "if", "(", "line", "===", "''", ")", "{", "continue", ";", "}", "else", "if", "(", "getLine", ")", "{", "cb", "(", "line", ")", ";", "// eslint-disable-line callback-return", "}", "else", "{", "lineParts", "=", "line", ".", "split", "(", "'\\t'", ",", "2", ")", ";", "if", "(", "lineParts", ".", "length", "<", "2", "||", "!", "lineParts", "[", "0", "]", "||", "!", "lineParts", "[", "1", "]", ")", "{", "throw", "new", "Error", "(", "'Invalid message: '", "+", "line", ")", ";", "}", "cb", "(", "+", "lineParts", "[", "0", "]", ",", "JSON", ".", "parse", "(", "lineParts", "[", "1", "]", ")", ")", ";", "// eslint-disable-line callback-return", "}", "}", "return", "lines", ";", "}" ]
Extract & normalize an IPC message from current input stream lines, and return remaining data. @param {string} lines - current input stream. @param {boolean} [getLine] - Get a line as plain string. @param {procMessage|Function} cb - Callback function that is called. It is called with a line if `getLine` is `true`. @returns {string} remaining data.
[ "Extract", "&", "normalize", "an", "IPC", "message", "from", "current", "input", "stream", "lines", "and", "return", "remaining", "data", "." ]
3621bda208e1a94527636dacd0a8f4b9e42c9cd0
https://github.com/anseki/process-bridge/blob/3621bda208e1a94527636dacd0a8f4b9e42c9cd0/process-bridge.js#L56-L81
46,670
anseki/process-bridge
process-bridge.js
sendIpc
function sendIpc(message) { var requestIds; clearTimeout(retryTimer); if (message) { tranRequests[message._requestId] = message; } if ((requestIds = Object.keys(tranRequests)).length) { if (!childProc) { throw new Error('Child process already exited.'); } requestIds.forEach(function(requestId) { console.info('Try to send IPC message: %d', +requestId); childProc.send(tranRequests[requestId]); }); retryTimer = setTimeout(errorHandle(sendIpc), IPC_RETRY_INTERVAL); } }
javascript
function sendIpc(message) { var requestIds; clearTimeout(retryTimer); if (message) { tranRequests[message._requestId] = message; } if ((requestIds = Object.keys(tranRequests)).length) { if (!childProc) { throw new Error('Child process already exited.'); } requestIds.forEach(function(requestId) { console.info('Try to send IPC message: %d', +requestId); childProc.send(tranRequests[requestId]); }); retryTimer = setTimeout(errorHandle(sendIpc), IPC_RETRY_INTERVAL); } }
[ "function", "sendIpc", "(", "message", ")", "{", "var", "requestIds", ";", "clearTimeout", "(", "retryTimer", ")", ";", "if", "(", "message", ")", "{", "tranRequests", "[", "message", ".", "_requestId", "]", "=", "message", ";", "}", "if", "(", "(", "requestIds", "=", "Object", ".", "keys", "(", "tranRequests", ")", ")", ".", "length", ")", "{", "if", "(", "!", "childProc", ")", "{", "throw", "new", "Error", "(", "'Child process already exited.'", ")", ";", "}", "requestIds", ".", "forEach", "(", "function", "(", "requestId", ")", "{", "console", ".", "info", "(", "'Try to send IPC message: %d'", ",", "+", "requestId", ")", ";", "childProc", ".", "send", "(", "tranRequests", "[", "requestId", "]", ")", ";", "}", ")", ";", "retryTimer", "=", "setTimeout", "(", "errorHandle", "(", "sendIpc", ")", ",", "IPC_RETRY_INTERVAL", ")", ";", "}", "}" ]
Recover failed IPC-sending. In some environment, IPC message does not reach to child, with no error and return value.
[ "Recover", "failed", "IPC", "-", "sending", ".", "In", "some", "environment", "IPC", "message", "does", "not", "reach", "to", "child", "with", "no", "error", "and", "return", "value", "." ]
3621bda208e1a94527636dacd0a8f4b9e42c9cd0
https://github.com/anseki/process-bridge/blob/3621bda208e1a94527636dacd0a8f4b9e42c9cd0/process-bridge.js#L410-L422
46,671
anandthakker/geojson-clip-polygon
index.js
isOutside
function isOutside (feature, poly) { var a = feature.bbox = feature.bbox || extent(feature) var b = poly.bbox = poly.bbox || extent(poly) return a[2] < b[0] || a[0] > b[2] || a[3] < b[1] || a[1] > b[3] }
javascript
function isOutside (feature, poly) { var a = feature.bbox = feature.bbox || extent(feature) var b = poly.bbox = poly.bbox || extent(poly) return a[2] < b[0] || a[0] > b[2] || a[3] < b[1] || a[1] > b[3] }
[ "function", "isOutside", "(", "feature", ",", "poly", ")", "{", "var", "a", "=", "feature", ".", "bbox", "=", "feature", ".", "bbox", "||", "extent", "(", "feature", ")", "var", "b", "=", "poly", ".", "bbox", "=", "poly", ".", "bbox", "||", "extent", "(", "poly", ")", "return", "a", "[", "2", "]", "<", "b", "[", "0", "]", "||", "a", "[", "0", "]", ">", "b", "[", "2", "]", "||", "a", "[", "3", "]", "<", "b", "[", "1", "]", "||", "a", "[", "1", "]", ">", "b", "[", "3", "]", "}" ]
no false positives, some false negatives
[ "no", "false", "positives", "some", "false", "negatives" ]
dde74a362f2817f7553a6dd4ee133ad06a27463b
https://github.com/anandthakker/geojson-clip-polygon/blob/dde74a362f2817f7553a6dd4ee133ad06a27463b/index.js#L66-L70
46,672
thealjey/webcompiler
lib/highlight.js
highlight
function highlight(value) { const el = document.createElement('div'); cm(el, { value, mode: { name: 'jsx', typescript: true }, scrollbarStyle: 'null', inputStyle: 'contenteditable' }); const dom = (0, _cheerio.load)(el.innerHTML), lines = dom('.CodeMirror-line'); // eslint-disable-next-line lodash/prefer-lodash-method lines.find('> span').removeAttr('style'); return { dom, lines }; }
javascript
function highlight(value) { const el = document.createElement('div'); cm(el, { value, mode: { name: 'jsx', typescript: true }, scrollbarStyle: 'null', inputStyle: 'contenteditable' }); const dom = (0, _cheerio.load)(el.innerHTML), lines = dom('.CodeMirror-line'); // eslint-disable-next-line lodash/prefer-lodash-method lines.find('> span').removeAttr('style'); return { dom, lines }; }
[ "function", "highlight", "(", "value", ")", "{", "const", "el", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "cm", "(", "el", ",", "{", "value", ",", "mode", ":", "{", "name", ":", "'jsx'", ",", "typescript", ":", "true", "}", ",", "scrollbarStyle", ":", "'null'", ",", "inputStyle", ":", "'contenteditable'", "}", ")", ";", "const", "dom", "=", "(", "0", ",", "_cheerio", ".", "load", ")", "(", "el", ".", "innerHTML", ")", ",", "lines", "=", "dom", "(", "'.CodeMirror-line'", ")", ";", "// eslint-disable-next-line lodash/prefer-lodash-method", "lines", ".", "find", "(", "'> span'", ")", ".", "removeAttr", "(", "'style'", ")", ";", "return", "{", "dom", ",", "lines", "}", ";", "}" ]
Using the CodeMirror editor highlights a string of text representing JavaScript program code. @memberof module:highlight @private @method highlight @param {string} value - any valid ES2015, TypeScript, JSX, Flow code @return {Object} an object containing a CheerioDOM object and a CheerioCollection of the `pre.CodeMirror-line` elements
[ "Using", "the", "CodeMirror", "editor", "highlights", "a", "string", "of", "text", "representing", "JavaScript", "program", "code", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/highlight.js#L63-L75
46,673
thealjey/webcompiler
lib/highlight.js
highlightHTML
function highlightHTML(code = '') { if (!code) { return ''; } const { dom, lines } = highlight(code); return dom.html(lines); }
javascript
function highlightHTML(code = '') { if (!code) { return ''; } const { dom, lines } = highlight(code); return dom.html(lines); }
[ "function", "highlightHTML", "(", "code", "=", "''", ")", "{", "if", "(", "!", "code", ")", "{", "return", "''", ";", "}", "const", "{", "dom", ",", "lines", "}", "=", "highlight", "(", "code", ")", ";", "return", "dom", ".", "html", "(", "lines", ")", ";", "}" ]
Using the CodeMirror editor highlights a string of text representing JavaScript program code and returns an HTML string. @memberof module:highlight @method highlightHTML @param {string} [code=""] - any valid ES2015, TypeScript, JSX, Flow code @return {string} an HTML string of the `pre.CodeMirror-line` elements @example import {highlightHTML} from 'webcompiler'; // or - import {highlightHTML} from 'webcompiler/lib/highlight'; // or - var highlightHTML = require('webcompiler').highlightHTML; // or - var highlightHTML = require('webcompiler/lib/highlight').highlightHTML; highlightHTML('function myScript(){return 100;}'); // <pre class="CodeMirror-line">...</pre>
[ "Using", "the", "CodeMirror", "editor", "highlights", "a", "string", "of", "text", "representing", "JavaScript", "program", "code", "and", "returns", "an", "HTML", "string", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/highlight.js#L93-L100
46,674
svanderburg/nijs
bin/nijs-build/operations.js
evaluatePackage
function evaluatePackage(filename, attr, format) { var pkgs = require(path.resolve(filename)).pkgs; var pkg = pkgs[attr](); var expr = nijs.jsToNix(pkg, format); return expr; }
javascript
function evaluatePackage(filename, attr, format) { var pkgs = require(path.resolve(filename)).pkgs; var pkg = pkgs[attr](); var expr = nijs.jsToNix(pkg, format); return expr; }
[ "function", "evaluatePackage", "(", "filename", ",", "attr", ",", "format", ")", "{", "var", "pkgs", "=", "require", "(", "path", ".", "resolve", "(", "filename", ")", ")", ".", "pkgs", ";", "var", "pkg", "=", "pkgs", "[", "attr", "]", "(", ")", ";", "var", "expr", "=", "nijs", ".", "jsToNix", "(", "pkg", ",", "format", ")", ";", "return", "expr", ";", "}" ]
Imports the given package composition CommonJS module and evaluates the specified package. @param {String} filename Path to the package composition CommonJS module @param {String} attr Name of the package to evaluate @param {Boolean} format Indicates whether to nicely format to expression (i.e. generating whitespaces) or not @return {String} A string containing the generated Nix expression
[ "Imports", "the", "given", "package", "composition", "CommonJS", "module", "and", "evaluates", "the", "specified", "package", "." ]
4e2738cbff3a43aba9297315ca5120cecf8dae3e
https://github.com/svanderburg/nijs/blob/4e2738cbff3a43aba9297315ca5120cecf8dae3e/bin/nijs-build/operations.js#L17-L22
46,675
svanderburg/nijs
bin/nijs-build/operations.js
evaluatePackageAsync
function evaluatePackageAsync(filename, attr, format, callback) { var pkgs = require(path.resolve(filename)).pkgs; slasp.sequence([ function(callback) { pkgs[attr](callback); }, function(callback, pkg) { var expr = nijs.jsToNix(pkg, format); callback(null, expr); } ], callback); }
javascript
function evaluatePackageAsync(filename, attr, format, callback) { var pkgs = require(path.resolve(filename)).pkgs; slasp.sequence([ function(callback) { pkgs[attr](callback); }, function(callback, pkg) { var expr = nijs.jsToNix(pkg, format); callback(null, expr); } ], callback); }
[ "function", "evaluatePackageAsync", "(", "filename", ",", "attr", ",", "format", ",", "callback", ")", "{", "var", "pkgs", "=", "require", "(", "path", ".", "resolve", "(", "filename", ")", ")", ".", "pkgs", ";", "slasp", ".", "sequence", "(", "[", "function", "(", "callback", ")", "{", "pkgs", "[", "attr", "]", "(", "callback", ")", ";", "}", ",", "function", "(", "callback", ",", "pkg", ")", "{", "var", "expr", "=", "nijs", ".", "jsToNix", "(", "pkg", ",", "format", ")", ";", "callback", "(", "null", ",", "expr", ")", ";", "}", "]", ",", "callback", ")", ";", "}" ]
Imports the given package composition CommonJS module and asynchronously evaluates the specified package. @param {String} filename Path to the package composition CommonJS module @param {String} attr Name of the package to evaluate @param {Boolean} format Indicates whether to nicely format to expression (i.e. generating whitespaces) or not @param {function(Object, Object)} callback Callback that gets invoked with either an error set if the operation failed, or a string containing the generated Nix expression
[ "Imports", "the", "given", "package", "composition", "CommonJS", "module", "and", "asynchronously", "evaluates", "the", "specified", "package", "." ]
4e2738cbff3a43aba9297315ca5120cecf8dae3e
https://github.com/svanderburg/nijs/blob/4e2738cbff3a43aba9297315ca5120cecf8dae3e/bin/nijs-build/operations.js#L33-L46
46,676
manuelodelain/screen-navigator
examples/basic/index.js
onScreenBtnClick
function onScreenBtnClick (event) { const screenId = event.currentTarget.getAttribute('data-screen'); // if the current screen is the same as the clicked one if (screenId === screenNavigator.currentItemId) return; // display the new screen screenNavigator.showScreen(screenId); }
javascript
function onScreenBtnClick (event) { const screenId = event.currentTarget.getAttribute('data-screen'); // if the current screen is the same as the clicked one if (screenId === screenNavigator.currentItemId) return; // display the new screen screenNavigator.showScreen(screenId); }
[ "function", "onScreenBtnClick", "(", "event", ")", "{", "const", "screenId", "=", "event", ".", "currentTarget", ".", "getAttribute", "(", "'data-screen'", ")", ";", "// if the current screen is the same as the clicked one", "if", "(", "screenId", "===", "screenNavigator", ".", "currentItemId", ")", "return", ";", "// display the new screen", "screenNavigator", ".", "showScreen", "(", "screenId", ")", ";", "}" ]
screenNavigator.transitionType = Transitions.OutAndIn; button click handler
[ "screenNavigator", ".", "transitionType", "=", "Transitions", ".", "OutAndIn", ";", "button", "click", "handler" ]
73281a47e04bc0e8f146a5fe3d80f354a21febcf
https://github.com/manuelodelain/screen-navigator/blob/73281a47e04bc0e8f146a5fe3d80f354a21febcf/examples/basic/index.js#L39-L47
46,677
igorski/zMIDI
src/zMIDI.js
function( aPortNumber ) { var listener = zMIDI._listenerMap[ aPortNumber], inChannel; if ( listener ) { inChannel = zMIDI.getInChannels()[ aPortNumber ]; inChannel.close(); inChannel.removeEventListener( "midimessage", listener, true ); delete zMIDI._listenerMap[ aPortNumber ]; } }
javascript
function( aPortNumber ) { var listener = zMIDI._listenerMap[ aPortNumber], inChannel; if ( listener ) { inChannel = zMIDI.getInChannels()[ aPortNumber ]; inChannel.close(); inChannel.removeEventListener( "midimessage", listener, true ); delete zMIDI._listenerMap[ aPortNumber ]; } }
[ "function", "(", "aPortNumber", ")", "{", "var", "listener", "=", "zMIDI", ".", "_listenerMap", "[", "aPortNumber", "]", ",", "inChannel", ";", "if", "(", "listener", ")", "{", "inChannel", "=", "zMIDI", ".", "getInChannels", "(", ")", "[", "aPortNumber", "]", ";", "inChannel", ".", "close", "(", ")", ";", "inChannel", ".", "removeEventListener", "(", "\"midimessage\"", ",", "listener", ",", "true", ")", ";", "delete", "zMIDI", ".", "_listenerMap", "[", "aPortNumber", "]", ";", "}", "}" ]
detach a method to listen to MIDI message in events @public @param {number} aPortNumber index of the MIDI port stop listening on
[ "detach", "a", "method", "to", "listen", "to", "MIDI", "message", "in", "events" ]
671bb154fda0ce13269d624464a2dfc95e2a9b34
https://github.com/igorski/zMIDI/blob/671bb154fda0ce13269d624464a2dfc95e2a9b34/src/zMIDI.js#L279-L290
46,678
igorski/zMIDI
src/zMIDI.js
function() { if ( zMIDI.isConnected() ) { var inputs = /** @type {Array.<MIDIInput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.inputs === "function" ) { inputs = iface.inputs(); } else { var it = iface.inputs[ "values" ](); for ( var o = it[ "next" ](); !o[ "done" ]; o = it[ "next" ]() ) { inputs.push( o[ "value" ] ); } } return inputs; } zMIDI._handleConnectionFailure(); return null; }
javascript
function() { if ( zMIDI.isConnected() ) { var inputs = /** @type {Array.<MIDIInput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.inputs === "function" ) { inputs = iface.inputs(); } else { var it = iface.inputs[ "values" ](); for ( var o = it[ "next" ](); !o[ "done" ]; o = it[ "next" ]() ) { inputs.push( o[ "value" ] ); } } return inputs; } zMIDI._handleConnectionFailure(); return null; }
[ "function", "(", ")", "{", "if", "(", "zMIDI", ".", "isConnected", "(", ")", ")", "{", "var", "inputs", "=", "/** @type {Array.<MIDIInput>} */", "(", "[", "]", ")", ";", "var", "iface", "=", "zMIDI", ".", "_interface", ";", "if", "(", "typeof", "iface", ".", "inputs", "===", "\"function\"", ")", "{", "inputs", "=", "iface", ".", "inputs", "(", ")", ";", "}", "else", "{", "var", "it", "=", "iface", ".", "inputs", "[", "\"values\"", "]", "(", ")", ";", "for", "(", "var", "o", "=", "it", "[", "\"next\"", "]", "(", ")", ";", "!", "o", "[", "\"done\"", "]", ";", "o", "=", "it", "[", "\"next\"", "]", "(", ")", ")", "{", "inputs", ".", "push", "(", "o", "[", "\"value\"", "]", ")", ";", "}", "}", "return", "inputs", ";", "}", "zMIDI", ".", "_handleConnectionFailure", "(", ")", ";", "return", "null", ";", "}" ]
retrieve all available MIDI inputs @public @return {Array.<MIDIInput>}
[ "retrieve", "all", "available", "MIDI", "inputs" ]
671bb154fda0ce13269d624464a2dfc95e2a9b34
https://github.com/igorski/zMIDI/blob/671bb154fda0ce13269d624464a2dfc95e2a9b34/src/zMIDI.js#L314-L337
46,679
igorski/zMIDI
src/zMIDI.js
function() { if ( zMIDI.isConnected() ) { var outputs = /** @type {Array.<MIDIOutput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.outputs === "function" ) { outputs = iface.outputs(); } else { var it = iface.outputs[ "values" ](); for ( var o = it[ "next" ](); !o[ "done" ]; o = it[ "next" ]() ) { outputs.push( o[ "value" ] ); } } return outputs; } zMIDI._handleConnectionFailure(); return null; }
javascript
function() { if ( zMIDI.isConnected() ) { var outputs = /** @type {Array.<MIDIOutput>} */ ( [] ); var iface = zMIDI._interface; if ( typeof iface.outputs === "function" ) { outputs = iface.outputs(); } else { var it = iface.outputs[ "values" ](); for ( var o = it[ "next" ](); !o[ "done" ]; o = it[ "next" ]() ) { outputs.push( o[ "value" ] ); } } return outputs; } zMIDI._handleConnectionFailure(); return null; }
[ "function", "(", ")", "{", "if", "(", "zMIDI", ".", "isConnected", "(", ")", ")", "{", "var", "outputs", "=", "/** @type {Array.<MIDIOutput>} */", "(", "[", "]", ")", ";", "var", "iface", "=", "zMIDI", ".", "_interface", ";", "if", "(", "typeof", "iface", ".", "outputs", "===", "\"function\"", ")", "{", "outputs", "=", "iface", ".", "outputs", "(", ")", ";", "}", "else", "{", "var", "it", "=", "iface", ".", "outputs", "[", "\"values\"", "]", "(", ")", ";", "for", "(", "var", "o", "=", "it", "[", "\"next\"", "]", "(", ")", ";", "!", "o", "[", "\"done\"", "]", ";", "o", "=", "it", "[", "\"next\"", "]", "(", ")", ")", "{", "outputs", ".", "push", "(", "o", "[", "\"value\"", "]", ")", ";", "}", "}", "return", "outputs", ";", "}", "zMIDI", ".", "_handleConnectionFailure", "(", ")", ";", "return", "null", ";", "}" ]
retrieve all available MIDI output ports @public @return {Array.<MIDIOutput>}
[ "retrieve", "all", "available", "MIDI", "output", "ports" ]
671bb154fda0ce13269d624464a2dfc95e2a9b34
https://github.com/igorski/zMIDI/blob/671bb154fda0ce13269d624464a2dfc95e2a9b34/src/zMIDI.js#L345-L368
46,680
serg-io/dyndb
dyndb.js
sendRequest
function sendRequest(operationName, body, callback, context) { if (_.isFunction(body)) { context = callback; callback = body; body = undefined; } body || (body = {}); body = new Buffer(_.isString(body) ? body : JSON.stringify(body)); var httpOpts = { host: SERVICE_NAME.toLowerCase() + '.' + region + '.amazonaws.com', port: 443, path: '/', method: 'POST', headers: { 'x-amz-date': basicISODate(), 'x-amz-target': SERVICE_NAME + '_' + API_VERSION + '.' + operationName, 'Content-Type': 'application/x-amz-json-1.0' } }; signRequest(httpOpts, body); httpRequest(httpOpts, body, function(error, responseBody, httpResponse) { var json; try { json = JSON.parse(responseBody); } catch (parseError) { if (!error) error = parseError; } if (_.isFunction(callback)) callback.call(context || httpResponse, error, json || responseBody); }, true); }
javascript
function sendRequest(operationName, body, callback, context) { if (_.isFunction(body)) { context = callback; callback = body; body = undefined; } body || (body = {}); body = new Buffer(_.isString(body) ? body : JSON.stringify(body)); var httpOpts = { host: SERVICE_NAME.toLowerCase() + '.' + region + '.amazonaws.com', port: 443, path: '/', method: 'POST', headers: { 'x-amz-date': basicISODate(), 'x-amz-target': SERVICE_NAME + '_' + API_VERSION + '.' + operationName, 'Content-Type': 'application/x-amz-json-1.0' } }; signRequest(httpOpts, body); httpRequest(httpOpts, body, function(error, responseBody, httpResponse) { var json; try { json = JSON.parse(responseBody); } catch (parseError) { if (!error) error = parseError; } if (_.isFunction(callback)) callback.call(context || httpResponse, error, json || responseBody); }, true); }
[ "function", "sendRequest", "(", "operationName", ",", "body", ",", "callback", ",", "context", ")", "{", "if", "(", "_", ".", "isFunction", "(", "body", ")", ")", "{", "context", "=", "callback", ";", "callback", "=", "body", ";", "body", "=", "undefined", ";", "}", "body", "||", "(", "body", "=", "{", "}", ")", ";", "body", "=", "new", "Buffer", "(", "_", ".", "isString", "(", "body", ")", "?", "body", ":", "JSON", ".", "stringify", "(", "body", ")", ")", ";", "var", "httpOpts", "=", "{", "host", ":", "SERVICE_NAME", ".", "toLowerCase", "(", ")", "+", "'.'", "+", "region", "+", "'.amazonaws.com'", ",", "port", ":", "443", ",", "path", ":", "'/'", ",", "method", ":", "'POST'", ",", "headers", ":", "{", "'x-amz-date'", ":", "basicISODate", "(", ")", ",", "'x-amz-target'", ":", "SERVICE_NAME", "+", "'_'", "+", "API_VERSION", "+", "'.'", "+", "operationName", ",", "'Content-Type'", ":", "'application/x-amz-json-1.0'", "}", "}", ";", "signRequest", "(", "httpOpts", ",", "body", ")", ";", "httpRequest", "(", "httpOpts", ",", "body", ",", "function", "(", "error", ",", "responseBody", ",", "httpResponse", ")", "{", "var", "json", ";", "try", "{", "json", "=", "JSON", ".", "parse", "(", "responseBody", ")", ";", "}", "catch", "(", "parseError", ")", "{", "if", "(", "!", "error", ")", "error", "=", "parseError", ";", "}", "if", "(", "_", ".", "isFunction", "(", "callback", ")", ")", "callback", ".", "call", "(", "context", "||", "httpResponse", ",", "error", ",", "json", "||", "responseBody", ")", ";", "}", ",", "true", ")", ";", "}" ]
Underlying method that builds the request before sending it and relays the response to the callback. @method sendRequest @private @param {String} operationName Name of the DynamoDB operation to request. @param {Object|String} [body='{}'] Body of the request. @param {Function} [callback] Callback function to call after receiving the response. @param {Object} [context=httpResponseObject] Context in which the callback should be executed. Defaults to the underlying HTTP response object.
[ "Underlying", "method", "that", "builds", "the", "request", "before", "sending", "it", "and", "relays", "the", "response", "to", "the", "callback", "." ]
6f916347aec6678a855c0fa2205e8c84cabce65c
https://github.com/serg-io/dyndb/blob/6f916347aec6678a855c0fa2205e8c84cabce65c/dyndb.js#L272-L304
46,681
purtuga/dom-data-bind
src/Template.js
getTextBindingForToken
function getTextBindingForToken(Directive, tokenText) { tokenText = tokenText.trim(); let directiveInstances = PRIVATE.get(Directive); if (!directiveInstances) { directiveInstances = {}; PRIVATE.set(Directive, directiveInstances); } if (!directiveInstances[tokenText]) { directiveInstances[tokenText] = new Directive(tokenText); } return directiveInstances[tokenText]; }
javascript
function getTextBindingForToken(Directive, tokenText) { tokenText = tokenText.trim(); let directiveInstances = PRIVATE.get(Directive); if (!directiveInstances) { directiveInstances = {}; PRIVATE.set(Directive, directiveInstances); } if (!directiveInstances[tokenText]) { directiveInstances[tokenText] = new Directive(tokenText); } return directiveInstances[tokenText]; }
[ "function", "getTextBindingForToken", "(", "Directive", ",", "tokenText", ")", "{", "tokenText", "=", "tokenText", ".", "trim", "(", ")", ";", "let", "directiveInstances", "=", "PRIVATE", ".", "get", "(", "Directive", ")", ";", "if", "(", "!", "directiveInstances", ")", "{", "directiveInstances", "=", "{", "}", ";", "PRIVATE", ".", "set", "(", "Directive", ",", "directiveInstances", ")", ";", "}", "if", "(", "!", "directiveInstances", "[", "tokenText", "]", ")", "{", "directiveInstances", "[", "tokenText", "]", "=", "new", "Directive", "(", "tokenText", ")", ";", "}", "return", "directiveInstances", "[", "tokenText", "]", ";", "}" ]
Returns a node handlers for the given directive @param {Directive} Directive @param {String} tokenText The token text (no curly braces) @returns {Directive} Returns a Directive instance. Call `.getNodeHandler` to get a handler for a given node
[ "Returns", "a", "node", "handlers", "for", "the", "given", "directive" ]
0935941568ee5b48dd62a8a0baf982028adce15a
https://github.com/purtuga/dom-data-bind/blob/0935941568ee5b48dd62a8a0baf982028adce15a/src/Template.js#L338-L353
46,682
nicjansma/saltthepass.js
dist/saltthepass.js
DomainNameRule
function DomainNameRule(data) { if (typeof (data) === "undefined") { return; } // // matches // this.domain = data.domain; if (data.aliases instanceof Array) { this.aliases = data.aliases.slice(); } else { this.aliases = []; } // description (versions) this.description = data.description; // // rules // this.min = (typeof data.min !== "undefined") ? (parseInt(data.min, 10) || 0) : 0; this.max = (typeof data.max !== "undefined") ? (parseInt(data.max, 10) || Number.MAX_VALUE) : Number.MAX_VALUE; this.invalid = (typeof data.invalid !== "undefined") ? data.invalid : ""; this.required = (typeof data.required !== "undefined") ? data.required : ""; this.regex = data.regex; this.validregex = data.validregex; }
javascript
function DomainNameRule(data) { if (typeof (data) === "undefined") { return; } // // matches // this.domain = data.domain; if (data.aliases instanceof Array) { this.aliases = data.aliases.slice(); } else { this.aliases = []; } // description (versions) this.description = data.description; // // rules // this.min = (typeof data.min !== "undefined") ? (parseInt(data.min, 10) || 0) : 0; this.max = (typeof data.max !== "undefined") ? (parseInt(data.max, 10) || Number.MAX_VALUE) : Number.MAX_VALUE; this.invalid = (typeof data.invalid !== "undefined") ? data.invalid : ""; this.required = (typeof data.required !== "undefined") ? data.required : ""; this.regex = data.regex; this.validregex = data.validregex; }
[ "function", "DomainNameRule", "(", "data", ")", "{", "if", "(", "typeof", "(", "data", ")", "===", "\"undefined\"", ")", "{", "return", ";", "}", "//", "// matches", "//", "this", ".", "domain", "=", "data", ".", "domain", ";", "if", "(", "data", ".", "aliases", "instanceof", "Array", ")", "{", "this", ".", "aliases", "=", "data", ".", "aliases", ".", "slice", "(", ")", ";", "}", "else", "{", "this", ".", "aliases", "=", "[", "]", ";", "}", "// description (versions)", "this", ".", "description", "=", "data", ".", "description", ";", "//", "// rules", "//", "this", ".", "min", "=", "(", "typeof", "data", ".", "min", "!==", "\"undefined\"", ")", "?", "(", "parseInt", "(", "data", ".", "min", ",", "10", ")", "||", "0", ")", ":", "0", ";", "this", ".", "max", "=", "(", "typeof", "data", ".", "max", "!==", "\"undefined\"", ")", "?", "(", "parseInt", "(", "data", ".", "max", ",", "10", ")", "||", "Number", ".", "MAX_VALUE", ")", ":", "Number", ".", "MAX_VALUE", ";", "this", ".", "invalid", "=", "(", "typeof", "data", ".", "invalid", "!==", "\"undefined\"", ")", "?", "data", ".", "invalid", ":", "\"\"", ";", "this", ".", "required", "=", "(", "typeof", "data", ".", "required", "!==", "\"undefined\"", ")", "?", "data", ".", "required", ":", "\"\"", ";", "this", ".", "regex", "=", "data", ".", "regex", ";", "this", ".", "validregex", "=", "data", ".", "validregex", ";", "}" ]
Constructor Creates a new DomainNameRule @param {object} data Parameters
[ "Constructor", "Creates", "a", "new", "DomainNameRule" ]
11a3bc652a239d7d505b0debd16adc6d338d19f0
https://github.com/nicjansma/saltthepass.js/blob/11a3bc652a239d7d505b0debd16adc6d338d19f0/dist/saltthepass.js#L107-L136
46,683
rocketedaway/node-flickr-image-downloader
flickr-image-downloader.js
FlickrImageDownloader
function FlickrImageDownloader () { var that = this; that.url = ''; that.delay = 500; that.downloadFolder = ''; that.paths = {}; that.paths.base = 'https://www.flickr.com'; that.paths.photostream = 'photos/!username'; that.paths.set = that.paths.photostream + '/sets'; that.paths.favorites = that.paths.photostream + '/favorites'; that.image = {}; that.image.dataAttr = 'deferSrc'; that.image.selector = 'div#photo-display-container img.pc_img'; // Events constructor events.EventEmitter.call(that); // Setup listeners that.on('pageCountLoaded', function () { console.log('Event::pageCountLoaded'); that.getImageUrls(); }); that.on('imageUrlsLoaded', function () { console.log('Event::imageUrlsLoaded'); that.downloadImages(); }); that.on('downloadFinished', function (imageUrl) { console.log('Event::downloadFinished(' + imageUrl + ')'); }); that.on('allDownloadsFinished', function () { console.log('Event::allDownloadsFinished'); }); that.on('error', function (functionName, error) { console.log('Event::Error (' + functionName + ')', error); }); }
javascript
function FlickrImageDownloader () { var that = this; that.url = ''; that.delay = 500; that.downloadFolder = ''; that.paths = {}; that.paths.base = 'https://www.flickr.com'; that.paths.photostream = 'photos/!username'; that.paths.set = that.paths.photostream + '/sets'; that.paths.favorites = that.paths.photostream + '/favorites'; that.image = {}; that.image.dataAttr = 'deferSrc'; that.image.selector = 'div#photo-display-container img.pc_img'; // Events constructor events.EventEmitter.call(that); // Setup listeners that.on('pageCountLoaded', function () { console.log('Event::pageCountLoaded'); that.getImageUrls(); }); that.on('imageUrlsLoaded', function () { console.log('Event::imageUrlsLoaded'); that.downloadImages(); }); that.on('downloadFinished', function (imageUrl) { console.log('Event::downloadFinished(' + imageUrl + ')'); }); that.on('allDownloadsFinished', function () { console.log('Event::allDownloadsFinished'); }); that.on('error', function (functionName, error) { console.log('Event::Error (' + functionName + ')', error); }); }
[ "function", "FlickrImageDownloader", "(", ")", "{", "var", "that", "=", "this", ";", "that", ".", "url", "=", "''", ";", "that", ".", "delay", "=", "500", ";", "that", ".", "downloadFolder", "=", "''", ";", "that", ".", "paths", "=", "{", "}", ";", "that", ".", "paths", ".", "base", "=", "'https://www.flickr.com'", ";", "that", ".", "paths", ".", "photostream", "=", "'photos/!username'", ";", "that", ".", "paths", ".", "set", "=", "that", ".", "paths", ".", "photostream", "+", "'/sets'", ";", "that", ".", "paths", ".", "favorites", "=", "that", ".", "paths", ".", "photostream", "+", "'/favorites'", ";", "that", ".", "image", "=", "{", "}", ";", "that", ".", "image", ".", "dataAttr", "=", "'deferSrc'", ";", "that", ".", "image", ".", "selector", "=", "'div#photo-display-container img.pc_img'", ";", "// Events constructor", "events", ".", "EventEmitter", ".", "call", "(", "that", ")", ";", "// Setup listeners", "that", ".", "on", "(", "'pageCountLoaded'", ",", "function", "(", ")", "{", "console", ".", "log", "(", "'Event::pageCountLoaded'", ")", ";", "that", ".", "getImageUrls", "(", ")", ";", "}", ")", ";", "that", ".", "on", "(", "'imageUrlsLoaded'", ",", "function", "(", ")", "{", "console", ".", "log", "(", "'Event::imageUrlsLoaded'", ")", ";", "that", ".", "downloadImages", "(", ")", ";", "}", ")", ";", "that", ".", "on", "(", "'downloadFinished'", ",", "function", "(", "imageUrl", ")", "{", "console", ".", "log", "(", "'Event::downloadFinished('", "+", "imageUrl", "+", "')'", ")", ";", "}", ")", ";", "that", ".", "on", "(", "'allDownloadsFinished'", ",", "function", "(", ")", "{", "console", ".", "log", "(", "'Event::allDownloadsFinished'", ")", ";", "}", ")", ";", "that", ".", "on", "(", "'error'", ",", "function", "(", "functionName", ",", "error", ")", "{", "console", ".", "log", "(", "'Event::Error ('", "+", "functionName", "+", "')'", ",", "error", ")", ";", "}", ")", ";", "}" ]
Module to export
[ "Module", "to", "export" ]
220e93eebd652d0abce944f1c774604aa86baab7
https://github.com/rocketedaway/node-flickr-image-downloader/blob/220e93eebd652d0abce944f1c774604aa86baab7/flickr-image-downloader.js#L12-L54
46,684
af83/node-serializer
serializer.js
signStr
function signStr(str, key) { var hmac = crypto.createHmac('sha1', key); hmac.update(str); return hmac.digest('base64').replace(/\+/g, '-').replace(/\//g, '_'); }
javascript
function signStr(str, key) { var hmac = crypto.createHmac('sha1', key); hmac.update(str); return hmac.digest('base64').replace(/\+/g, '-').replace(/\//g, '_'); }
[ "function", "signStr", "(", "str", ",", "key", ")", "{", "var", "hmac", "=", "crypto", ".", "createHmac", "(", "'sha1'", ",", "key", ")", ";", "hmac", ".", "update", "(", "str", ")", ";", "return", "hmac", ".", "digest", "(", "'base64'", ")", ".", "replace", "(", "/", "\\+", "/", "g", ",", "'-'", ")", ".", "replace", "(", "/", "\\/", "/", "g", ",", "'_'", ")", ";", "}" ]
Return base64url signed sha1 hash of str using key
[ "Return", "base64url", "signed", "sha1", "hash", "of", "str", "using", "key" ]
c7cb3a075fa4b979b2bcb90fe1e457f013c7777b
https://github.com/af83/node-serializer/blob/c7cb3a075fa4b979b2bcb90fe1e457f013c7777b/serializer.js#L59-L63
46,685
anywhichway/chrome-proxy
index.js
function (changeset) { changeset.forEach(function(change) { if(change.name!=="__target__") { if(change.type==="delete") { delete proxy[change.name]; } else if(change.type==="update") { // update handler if target key value changes from function to non-function or from a non-function to a function if((typeof(change.oldValue)==="function" && typeof(target[change.name])!=="function") || (typeof(change.oldValue)!=="function" && typeof(target[change.name])==="function")) { addHandling(proxy,change.name,target[change.name]); } } else if(!proxy[change.name]) { addHandling(proxy,change.name,target[change.name]); } } })}
javascript
function (changeset) { changeset.forEach(function(change) { if(change.name!=="__target__") { if(change.type==="delete") { delete proxy[change.name]; } else if(change.type==="update") { // update handler if target key value changes from function to non-function or from a non-function to a function if((typeof(change.oldValue)==="function" && typeof(target[change.name])!=="function") || (typeof(change.oldValue)!=="function" && typeof(target[change.name])==="function")) { addHandling(proxy,change.name,target[change.name]); } } else if(!proxy[change.name]) { addHandling(proxy,change.name,target[change.name]); } } })}
[ "function", "(", "changeset", ")", "{", "changeset", ".", "forEach", "(", "function", "(", "change", ")", "{", "if", "(", "change", ".", "name", "!==", "\"__target__\"", ")", "{", "if", "(", "change", ".", "type", "===", "\"delete\"", ")", "{", "delete", "proxy", "[", "change", ".", "name", "]", ";", "}", "else", "if", "(", "change", ".", "type", "===", "\"update\"", ")", "{", "// update handler if target key value changes from function to non-function or from a non-function to a function", "if", "(", "(", "typeof", "(", "change", ".", "oldValue", ")", "===", "\"function\"", "&&", "typeof", "(", "target", "[", "change", ".", "name", "]", ")", "!==", "\"function\"", ")", "||", "(", "typeof", "(", "change", ".", "oldValue", ")", "!==", "\"function\"", "&&", "typeof", "(", "target", "[", "change", ".", "name", "]", ")", "===", "\"function\"", ")", ")", "{", "addHandling", "(", "proxy", ",", "change", ".", "name", ",", "target", "[", "change", ".", "name", "]", ")", ";", "}", "}", "else", "if", "(", "!", "proxy", "[", "change", ".", "name", "]", ")", "{", "addHandling", "(", "proxy", ",", "change", ".", "name", ",", "target", "[", "change", ".", "name", "]", ")", ";", "}", "}", "}", ")", "}" ]
Observe the target for changes and update the handlers accordingly
[ "Observe", "the", "target", "for", "changes", "and", "update", "the", "handlers", "accordingly" ]
41dde561732d27e98651beffe48b5cd389e7975b
https://github.com/anywhichway/chrome-proxy/blob/41dde561732d27e98651beffe48b5cd389e7975b/index.js#L101-L114
46,686
aldeed/node-mongo-object
lib/mongo-object.js
traverse
function traverse(obj) { each(obj, (val, indexOrProp) => { // Move deeper into the object const next = obj[indexOrProp]; // If we can go no further, then quit if (MongoObject.isBasicObject(next)) { traverse(next); } else if (Array.isArray(next)) { obj[indexOrProp] = without(next, REMOVED_MARKER); traverse(obj[indexOrProp]); } }); }
javascript
function traverse(obj) { each(obj, (val, indexOrProp) => { // Move deeper into the object const next = obj[indexOrProp]; // If we can go no further, then quit if (MongoObject.isBasicObject(next)) { traverse(next); } else if (Array.isArray(next)) { obj[indexOrProp] = without(next, REMOVED_MARKER); traverse(obj[indexOrProp]); } }); }
[ "function", "traverse", "(", "obj", ")", "{", "each", "(", "obj", ",", "(", "val", ",", "indexOrProp", ")", "=>", "{", "// Move deeper into the object", "const", "next", "=", "obj", "[", "indexOrProp", "]", ";", "// If we can go no further, then quit", "if", "(", "MongoObject", ".", "isBasicObject", "(", "next", ")", ")", "{", "traverse", "(", "next", ")", ";", "}", "else", "if", "(", "Array", ".", "isArray", "(", "next", ")", ")", "{", "obj", "[", "indexOrProp", "]", "=", "without", "(", "next", ",", "REMOVED_MARKER", ")", ";", "traverse", "(", "obj", "[", "indexOrProp", "]", ")", ";", "}", "}", ")", ";", "}" ]
Traverse and pull out removed array items at this point
[ "Traverse", "and", "pull", "out", "removed", "array", "items", "at", "this", "point" ]
040fbbdeeea4d1f8c6da17ecca2d203b8a20c048
https://github.com/aldeed/node-mongo-object/blob/040fbbdeeea4d1f8c6da17ecca2d203b8a20c048/lib/mongo-object.js#L558-L571
46,687
aldeed/node-mongo-object
lib/mongo-object.js
extractOp
function extractOp(position) { const firstPositionPiece = position.slice(0, position.indexOf('[')); return (firstPositionPiece.substring(0, 1) === '$') ? firstPositionPiece : null; }
javascript
function extractOp(position) { const firstPositionPiece = position.slice(0, position.indexOf('[')); return (firstPositionPiece.substring(0, 1) === '$') ? firstPositionPiece : null; }
[ "function", "extractOp", "(", "position", ")", "{", "const", "firstPositionPiece", "=", "position", ".", "slice", "(", "0", ",", "position", ".", "indexOf", "(", "'['", ")", ")", ";", "return", "(", "firstPositionPiece", ".", "substring", "(", "0", ",", "1", ")", "===", "'$'", ")", "?", "firstPositionPiece", ":", "null", ";", "}" ]
Extracts operator piece, if present, from position string
[ "Extracts", "operator", "piece", "if", "present", "from", "position", "string" ]
040fbbdeeea4d1f8c6da17ecca2d203b8a20c048
https://github.com/aldeed/node-mongo-object/blob/040fbbdeeea4d1f8c6da17ecca2d203b8a20c048/lib/mongo-object.js#L929-L932
46,688
ithinkihaveacat/node-fishback
lib/helper.js
isFreshEnough
function isFreshEnough(entry, req) { // If no cache-control header in request, then entry is fresh // if it hasn't expired. if (!("cache-control" in req.headers)) { return new Date().getTime() < entry.expires; } var headers = parseHeader(req.headers["cache-control"]); if ("must-revalidate" in headers) { return false; } else if ("max-stale" in headers) { // TODO Tell the client that the resource is stale, as RFC2616 requires return !headers["max-stale"] || ((headers["max-stale"] * 1000) > (new Date().getTime() - entry.expires)); // max-stale > "staleness" } else if ("max-age" in headers) { return (headers["max-age"] * 1000) > (new Date().getTime() - entry.created); // max-age > "age" } else if ("min-fresh" in headers) { return (headers["min-fresh"] * 1000) < (entry.expires - new Date().getTime()); // min-fresh < "time until expiry" } else { return new Date().getTime() < entry.expires; } }
javascript
function isFreshEnough(entry, req) { // If no cache-control header in request, then entry is fresh // if it hasn't expired. if (!("cache-control" in req.headers)) { return new Date().getTime() < entry.expires; } var headers = parseHeader(req.headers["cache-control"]); if ("must-revalidate" in headers) { return false; } else if ("max-stale" in headers) { // TODO Tell the client that the resource is stale, as RFC2616 requires return !headers["max-stale"] || ((headers["max-stale"] * 1000) > (new Date().getTime() - entry.expires)); // max-stale > "staleness" } else if ("max-age" in headers) { return (headers["max-age"] * 1000) > (new Date().getTime() - entry.created); // max-age > "age" } else if ("min-fresh" in headers) { return (headers["min-fresh"] * 1000) < (entry.expires - new Date().getTime()); // min-fresh < "time until expiry" } else { return new Date().getTime() < entry.expires; } }
[ "function", "isFreshEnough", "(", "entry", ",", "req", ")", "{", "// If no cache-control header in request, then entry is fresh", "// if it hasn't expired.", "if", "(", "!", "(", "\"cache-control\"", "in", "req", ".", "headers", ")", ")", "{", "return", "new", "Date", "(", ")", ".", "getTime", "(", ")", "<", "entry", ".", "expires", ";", "}", "var", "headers", "=", "parseHeader", "(", "req", ".", "headers", "[", "\"cache-control\"", "]", ")", ";", "if", "(", "\"must-revalidate\"", "in", "headers", ")", "{", "return", "false", ";", "}", "else", "if", "(", "\"max-stale\"", "in", "headers", ")", "{", "// TODO Tell the client that the resource is stale, as RFC2616 requires", "return", "!", "headers", "[", "\"max-stale\"", "]", "||", "(", "(", "headers", "[", "\"max-stale\"", "]", "*", "1000", ")", ">", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "entry", ".", "expires", ")", ")", ";", "// max-stale > \"staleness\"", "}", "else", "if", "(", "\"max-age\"", "in", "headers", ")", "{", "return", "(", "headers", "[", "\"max-age\"", "]", "*", "1000", ")", ">", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "entry", ".", "created", ")", ";", "// max-age > \"age\"", "}", "else", "if", "(", "\"min-fresh\"", "in", "headers", ")", "{", "return", "(", "headers", "[", "\"min-fresh\"", "]", "*", "1000", ")", "<", "(", "entry", ".", "expires", "-", "new", "Date", "(", ")", ".", "getTime", "(", ")", ")", ";", "// min-fresh < \"time until expiry\"", "}", "else", "{", "return", "new", "Date", "(", ")", ".", "getTime", "(", ")", "<", "entry", ".", "expires", ";", "}", "}" ]
true if the candidate reponse satisfies the request in terms of freshness, otherwise false.
[ "true", "if", "the", "candidate", "reponse", "satisfies", "the", "request", "in", "terms", "of", "freshness", "otherwise", "false", "." ]
dbf21d1dcc87cd0bfe19af673157a1869090934f
https://github.com/ithinkihaveacat/node-fishback/blob/dbf21d1dcc87cd0bfe19af673157a1869090934f/lib/helper.js#L70-L93
46,689
thealjey/webcompiler
lib/yaml.js
yaml
function yaml(filename, callback) { try { const yamlString = (0, _fs.readFileSync)(filename, 'utf8'); callback(null, (0, _jsYaml.safeLoad)(yamlString, { filename })); } catch (e) { callback(e, {}); } }
javascript
function yaml(filename, callback) { try { const yamlString = (0, _fs.readFileSync)(filename, 'utf8'); callback(null, (0, _jsYaml.safeLoad)(yamlString, { filename })); } catch (e) { callback(e, {}); } }
[ "function", "yaml", "(", "filename", ",", "callback", ")", "{", "try", "{", "const", "yamlString", "=", "(", "0", ",", "_fs", ".", "readFileSync", ")", "(", "filename", ",", "'utf8'", ")", ";", "callback", "(", "null", ",", "(", "0", ",", "_jsYaml", ".", "safeLoad", ")", "(", "yamlString", ",", "{", "filename", "}", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "callback", "(", "e", ",", "{", "}", ")", ";", "}", "}" ]
Read the contents of a YAML file @function yaml @param {string} filename - the full system path to a YAML file @param {ObjectOrErrorCallback} callback - a callback function @example import {yaml} from 'webcompiler'; // or - import {yaml} from 'webcompiler/lib/yaml'; // or - var yaml = require('webcompiler').yaml; // or - var yaml = require('webcompiler/lib/yaml').yaml; import {join} from 'path'; import {logError} from 'webcompiler'; yaml(join(__dirname, 'config', 'config.yaml'), (error, data) => { if (error) { return logError(error); } // the parsed config object });
[ "Read", "the", "contents", "of", "a", "YAML", "file" ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/yaml.js#L31-L39
46,690
reklatsmasters/ip2buf
lib/pton6.js
pton6
function pton6(addr, dest, index = 0) { if (typeof addr !== 'string') { throw new TypeError('Argument 1 should be a string.') } if (addr.length <= 0) { einval() } const isbuffer = Buffer.isBuffer(dest) const endp = index + IPV6_OCTETS if (isbuffer) { if (endp > dest.length) { throw new Error('Too small target buffer.') } } const buf = isbuffer ? dest : Buffer.allocUnsafe(IPV6_OCTETS) let i = 0 let colonp = null let seenDigits = 0 let val = 0 let curtok = 0 let ch = 0 if (addr[i] === ':') { if (addr.length >= 2 && addr[++i] !== ':') { einval() } } curtok = i while ((ch = i++) < addr.length) { const char = code(addr[ch]) if (isDigit(char) || isLetter16(char)) { val <<= 4 if (isDigit(char)) { val |= char - CHAR0 } else if (isLetter16Low(char)) { val |= char - CHARa + 10 } else if (isLetter16Up(char)) { val |= char - CHARA + 10 } if (++seenDigits > 4) { einval() } } else if (char === CHARCOLON) { curtok = i // If it's second colon in pair. if (seenDigits === 0) { // Only one colon pair allowed. if (colonp !== null) { einval() } colonp = index continue } else if (i >= addr.length) { einval() } if (index + 2 > endp) { einval() } buf[index++] = (val >> 8) & 0xFF buf[index++] = val & 0xFF seenDigits = 0 val = 0 } else if (char === CHARPOINT) { pton4(addr.slice(curtok), buf, index) index += IPV4_OCTETS seenDigits = 0 break } else { einval() } } // Handle last pair. if (seenDigits > 0) { if (index + 2 > endp) { einval() } buf[index++] = (val >> 8) & 0xFF buf[index++] = val & 0xFF } if (colonp !== null) { const n = index - colonp if (index === endp) { einval() } buf.copyWithin(endp - n, colonp, colonp + n) fill(buf, 0, colonp, endp - n) } return buf }
javascript
function pton6(addr, dest, index = 0) { if (typeof addr !== 'string') { throw new TypeError('Argument 1 should be a string.') } if (addr.length <= 0) { einval() } const isbuffer = Buffer.isBuffer(dest) const endp = index + IPV6_OCTETS if (isbuffer) { if (endp > dest.length) { throw new Error('Too small target buffer.') } } const buf = isbuffer ? dest : Buffer.allocUnsafe(IPV6_OCTETS) let i = 0 let colonp = null let seenDigits = 0 let val = 0 let curtok = 0 let ch = 0 if (addr[i] === ':') { if (addr.length >= 2 && addr[++i] !== ':') { einval() } } curtok = i while ((ch = i++) < addr.length) { const char = code(addr[ch]) if (isDigit(char) || isLetter16(char)) { val <<= 4 if (isDigit(char)) { val |= char - CHAR0 } else if (isLetter16Low(char)) { val |= char - CHARa + 10 } else if (isLetter16Up(char)) { val |= char - CHARA + 10 } if (++seenDigits > 4) { einval() } } else if (char === CHARCOLON) { curtok = i // If it's second colon in pair. if (seenDigits === 0) { // Only one colon pair allowed. if (colonp !== null) { einval() } colonp = index continue } else if (i >= addr.length) { einval() } if (index + 2 > endp) { einval() } buf[index++] = (val >> 8) & 0xFF buf[index++] = val & 0xFF seenDigits = 0 val = 0 } else if (char === CHARPOINT) { pton4(addr.slice(curtok), buf, index) index += IPV4_OCTETS seenDigits = 0 break } else { einval() } } // Handle last pair. if (seenDigits > 0) { if (index + 2 > endp) { einval() } buf[index++] = (val >> 8) & 0xFF buf[index++] = val & 0xFF } if (colonp !== null) { const n = index - colonp if (index === endp) { einval() } buf.copyWithin(endp - n, colonp, colonp + n) fill(buf, 0, colonp, endp - n) } return buf }
[ "function", "pton6", "(", "addr", ",", "dest", ",", "index", "=", "0", ")", "{", "if", "(", "typeof", "addr", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'Argument 1 should be a string.'", ")", "}", "if", "(", "addr", ".", "length", "<=", "0", ")", "{", "einval", "(", ")", "}", "const", "isbuffer", "=", "Buffer", ".", "isBuffer", "(", "dest", ")", "const", "endp", "=", "index", "+", "IPV6_OCTETS", "if", "(", "isbuffer", ")", "{", "if", "(", "endp", ">", "dest", ".", "length", ")", "{", "throw", "new", "Error", "(", "'Too small target buffer.'", ")", "}", "}", "const", "buf", "=", "isbuffer", "?", "dest", ":", "Buffer", ".", "allocUnsafe", "(", "IPV6_OCTETS", ")", "let", "i", "=", "0", "let", "colonp", "=", "null", "let", "seenDigits", "=", "0", "let", "val", "=", "0", "let", "curtok", "=", "0", "let", "ch", "=", "0", "if", "(", "addr", "[", "i", "]", "===", "':'", ")", "{", "if", "(", "addr", ".", "length", ">=", "2", "&&", "addr", "[", "++", "i", "]", "!==", "':'", ")", "{", "einval", "(", ")", "}", "}", "curtok", "=", "i", "while", "(", "(", "ch", "=", "i", "++", ")", "<", "addr", ".", "length", ")", "{", "const", "char", "=", "code", "(", "addr", "[", "ch", "]", ")", "if", "(", "isDigit", "(", "char", ")", "||", "isLetter16", "(", "char", ")", ")", "{", "val", "<<=", "4", "if", "(", "isDigit", "(", "char", ")", ")", "{", "val", "|=", "char", "-", "CHAR0", "}", "else", "if", "(", "isLetter16Low", "(", "char", ")", ")", "{", "val", "|=", "char", "-", "CHARa", "+", "10", "}", "else", "if", "(", "isLetter16Up", "(", "char", ")", ")", "{", "val", "|=", "char", "-", "CHARA", "+", "10", "}", "if", "(", "++", "seenDigits", ">", "4", ")", "{", "einval", "(", ")", "}", "}", "else", "if", "(", "char", "===", "CHARCOLON", ")", "{", "curtok", "=", "i", "// If it's second colon in pair.", "if", "(", "seenDigits", "===", "0", ")", "{", "// Only one colon pair allowed.", "if", "(", "colonp", "!==", "null", ")", "{", "einval", "(", ")", "}", "colonp", "=", "index", "continue", "}", "else", "if", "(", "i", ">=", "addr", ".", "length", ")", "{", "einval", "(", ")", "}", "if", "(", "index", "+", "2", ">", "endp", ")", "{", "einval", "(", ")", "}", "buf", "[", "index", "++", "]", "=", "(", "val", ">>", "8", ")", "&", "0xFF", "buf", "[", "index", "++", "]", "=", "val", "&", "0xFF", "seenDigits", "=", "0", "val", "=", "0", "}", "else", "if", "(", "char", "===", "CHARPOINT", ")", "{", "pton4", "(", "addr", ".", "slice", "(", "curtok", ")", ",", "buf", ",", "index", ")", "index", "+=", "IPV4_OCTETS", "seenDigits", "=", "0", "break", "}", "else", "{", "einval", "(", ")", "}", "}", "// Handle last pair.", "if", "(", "seenDigits", ">", "0", ")", "{", "if", "(", "index", "+", "2", ">", "endp", ")", "{", "einval", "(", ")", "}", "buf", "[", "index", "++", "]", "=", "(", "val", ">>", "8", ")", "&", "0xFF", "buf", "[", "index", "++", "]", "=", "val", "&", "0xFF", "}", "if", "(", "colonp", "!==", "null", ")", "{", "const", "n", "=", "index", "-", "colonp", "if", "(", "index", "===", "endp", ")", "{", "einval", "(", ")", "}", "buf", ".", "copyWithin", "(", "endp", "-", "n", ",", "colonp", ",", "colonp", "+", "n", ")", "fill", "(", "buf", ",", "0", ",", "colonp", ",", "endp", "-", "n", ")", "}", "return", "buf", "}" ]
Convert IPv6 to the Buffer. @param {string} addr @param {Buffer} [dest] @return {Buffer}
[ "Convert", "IPv6", "to", "the", "Buffer", "." ]
439c55cc7605423929808d42a29b9cd284914cd6
https://github.com/reklatsmasters/ip2buf/blob/439c55cc7605423929808d42a29b9cd284914cd6/lib/pton6.js#L47-L156
46,691
thealjey/webcompiler
lib/markdown.js
markdownToUnwrappedHTML
function markdownToUnwrappedHTML(markdown) { const html = (0, _trim2.default)(md.render(markdown)), { dom, children } = (0, _jsx.parseHTML)(html); if (1 !== children.length) { return html; } const [child] = children, { type, name } = child; return 'tag' === type && 'p' === name ? dom(child).html() : html; }
javascript
function markdownToUnwrappedHTML(markdown) { const html = (0, _trim2.default)(md.render(markdown)), { dom, children } = (0, _jsx.parseHTML)(html); if (1 !== children.length) { return html; } const [child] = children, { type, name } = child; return 'tag' === type && 'p' === name ? dom(child).html() : html; }
[ "function", "markdownToUnwrappedHTML", "(", "markdown", ")", "{", "const", "html", "=", "(", "0", ",", "_trim2", ".", "default", ")", "(", "md", ".", "render", "(", "markdown", ")", ")", ",", "{", "dom", ",", "children", "}", "=", "(", "0", ",", "_jsx", ".", "parseHTML", ")", "(", "html", ")", ";", "if", "(", "1", "!==", "children", ".", "length", ")", "{", "return", "html", ";", "}", "const", "[", "child", "]", "=", "children", ",", "{", "type", ",", "name", "}", "=", "child", ";", "return", "'tag'", "===", "type", "&&", "'p'", "===", "name", "?", "dom", "(", "child", ")", ".", "html", "(", ")", ":", "html", ";", "}" ]
Useful utilities for working with Markdown. @module markdown If a simple single line string is passed to the Markdown parser it thinks that it's a paragraph (it sort of technically is) and unnecessarily wraps it into `<p></p>`, which most often is not the desired behavior. This function converts Markdown to HTML and then removes the wrapping paragraph if it is the only top level tag unwrapping its contents. @memberof module:markdown @private @method markdownToUnwrappedHTML @param {string} markdown - an arbitrary Markdown string @return {string} an HTML string
[ "Useful", "utilities", "for", "working", "with", "Markdown", "." ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/markdown.js#L44-L55
46,692
thealjey/webcompiler
lib/markdown.js
markdownToJSX
function markdownToJSX(markdown = '') { markdown = (0, _trim2.default)(markdown); return markdown ? (0, _jsx.htmlToJSX)(markdownToUnwrappedHTML(markdown)) : []; }
javascript
function markdownToJSX(markdown = '') { markdown = (0, _trim2.default)(markdown); return markdown ? (0, _jsx.htmlToJSX)(markdownToUnwrappedHTML(markdown)) : []; }
[ "function", "markdownToJSX", "(", "markdown", "=", "''", ")", "{", "markdown", "=", "(", "0", ",", "_trim2", ".", "default", ")", "(", "markdown", ")", ";", "return", "markdown", "?", "(", "0", ",", "_jsx", ".", "htmlToJSX", ")", "(", "markdownToUnwrappedHTML", "(", "markdown", ")", ")", ":", "[", "]", ";", "}" ]
Converts an arbitrary Markdown string to an array of React Elements @memberof module:markdown @method markdownToJSX @param {string} [markdown=""] - an arbitrary Markdown string @return {Array<ReactElement>} an array of React Elements @example import {markdownToJSX} from 'webcompiler'; // or - import {markdownToJSX} from 'webcompiler/lib/markdown'; // or - var markdownToJSX = require('webcompiler').markdownToJSX; // or - var markdownToJSX = require('webcompiler/lib/markdown').markdownToJSX; <div>{markdownToJSX('# Hello world!')}</div>
[ "Converts", "an", "arbitrary", "Markdown", "string", "to", "an", "array", "of", "React", "Elements" ]
eb094f1632e5313ed0c5391a303150f1416b9629
https://github.com/thealjey/webcompiler/blob/eb094f1632e5313ed0c5391a303150f1416b9629/lib/markdown.js#L94-L98
46,693
jclulow/node-ansiterm
examples/scrol.js
_listbox
function _listbox() { at.write(VT_SAVE_CURSOR); // save at.write(CSI + (LAST + 2) + ';' + (AGAIN - 2) + 'r'); at.moveto(1, LAST + 2); //at.write(CSI + 'J'); // erase down KEYS.forEach(function(line, idx) { if (selected === idx) at.reverse(); var ll = line.substr(0, process.stdout.columns - 2); at.write(CSI + '4G' + ll + ESC + 'D'); if (selected === idx) at.reset(); }); _resetscroll(); at.write(VT_RESTORE_CURSOR); // restore at.reset(); }
javascript
function _listbox() { at.write(VT_SAVE_CURSOR); // save at.write(CSI + (LAST + 2) + ';' + (AGAIN - 2) + 'r'); at.moveto(1, LAST + 2); //at.write(CSI + 'J'); // erase down KEYS.forEach(function(line, idx) { if (selected === idx) at.reverse(); var ll = line.substr(0, process.stdout.columns - 2); at.write(CSI + '4G' + ll + ESC + 'D'); if (selected === idx) at.reset(); }); _resetscroll(); at.write(VT_RESTORE_CURSOR); // restore at.reset(); }
[ "function", "_listbox", "(", ")", "{", "at", ".", "write", "(", "VT_SAVE_CURSOR", ")", ";", "// save", "at", ".", "write", "(", "CSI", "+", "(", "LAST", "+", "2", ")", "+", "';'", "+", "(", "AGAIN", "-", "2", ")", "+", "'r'", ")", ";", "at", ".", "moveto", "(", "1", ",", "LAST", "+", "2", ")", ";", "//at.write(CSI + 'J'); // erase down", "KEYS", ".", "forEach", "(", "function", "(", "line", ",", "idx", ")", "{", "if", "(", "selected", "===", "idx", ")", "at", ".", "reverse", "(", ")", ";", "var", "ll", "=", "line", ".", "substr", "(", "0", ",", "process", ".", "stdout", ".", "columns", "-", "2", ")", ";", "at", ".", "write", "(", "CSI", "+", "'4G'", "+", "ll", "+", "ESC", "+", "'D'", ")", ";", "if", "(", "selected", "===", "idx", ")", "at", ".", "reset", "(", ")", ";", "}", ")", ";", "_resetscroll", "(", ")", ";", "at", ".", "write", "(", "VT_RESTORE_CURSOR", ")", ";", "// restore", "at", ".", "reset", "(", ")", ";", "}" ]
which index into KEYS is presently selected?
[ "which", "index", "into", "KEYS", "is", "presently", "selected?" ]
cf5223e692e1e1f20c452c9f21060df2cb5bd90e
https://github.com/jclulow/node-ansiterm/blob/cf5223e692e1e1f20c452c9f21060df2cb5bd90e/examples/scrol.js#L173-L191
46,694
Hugo-ter-Doest/chart-parsers
lib/Chart.js
Chart
function Chart(N) { logger.debug("Chart: " + N); this.N = N; this.outgoing_edges = new Array(N+1); this.incoming_edges = new Array(N+1); var i; for (i = 0; i <= N; i++) { this.outgoing_edges[i] = {}; this.incoming_edges[i] = {}; } }
javascript
function Chart(N) { logger.debug("Chart: " + N); this.N = N; this.outgoing_edges = new Array(N+1); this.incoming_edges = new Array(N+1); var i; for (i = 0; i <= N; i++) { this.outgoing_edges[i] = {}; this.incoming_edges[i] = {}; } }
[ "function", "Chart", "(", "N", ")", "{", "logger", ".", "debug", "(", "\"Chart: \"", "+", "N", ")", ";", "this", ".", "N", "=", "N", ";", "this", ".", "outgoing_edges", "=", "new", "Array", "(", "N", "+", "1", ")", ";", "this", ".", "incoming_edges", "=", "new", "Array", "(", "N", "+", "1", ")", ";", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<=", "N", ";", "i", "++", ")", "{", "this", ".", "outgoing_edges", "[", "i", "]", "=", "{", "}", ";", "this", ".", "incoming_edges", "[", "i", "]", "=", "{", "}", ";", "}", "}" ]
Creates a chart for recognition of a sentence of length N
[ "Creates", "a", "chart", "for", "recognition", "of", "a", "sentence", "of", "length", "N" ]
81be32f897f6dceeffebd2009ad865964da12c4b
https://github.com/Hugo-ter-Doest/chart-parsers/blob/81be32f897f6dceeffebd2009ad865964da12c4b/lib/Chart.js#L31-L43
46,695
quantmind/d3-visualize
src/core/visual.js
visualManager
function visualManager (records) { let nodes, node; records.forEach(record => { nodes = record.removedNodes; if (!nodes || !nodes.length) return; for (let i=0; i<nodes.length; ++i) { node = nodes[i]; if (node.querySelectorAll) { if (!node.__visual__) select(node).selectAll('.d3-visual').each(destroy); else destroy.call(node); } } }); }
javascript
function visualManager (records) { let nodes, node; records.forEach(record => { nodes = record.removedNodes; if (!nodes || !nodes.length) return; for (let i=0; i<nodes.length; ++i) { node = nodes[i]; if (node.querySelectorAll) { if (!node.__visual__) select(node).selectAll('.d3-visual').each(destroy); else destroy.call(node); } } }); }
[ "function", "visualManager", "(", "records", ")", "{", "let", "nodes", ",", "node", ";", "records", ".", "forEach", "(", "record", "=>", "{", "nodes", "=", "record", ".", "removedNodes", ";", "if", "(", "!", "nodes", "||", "!", "nodes", ".", "length", ")", "return", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "nodes", ".", "length", ";", "++", "i", ")", "{", "node", "=", "nodes", "[", "i", "]", ";", "if", "(", "node", ".", "querySelectorAll", ")", "{", "if", "(", "!", "node", ".", "__visual__", ")", "select", "(", "node", ")", ".", "selectAll", "(", "'.d3-visual'", ")", ".", "each", "(", "destroy", ")", ";", "else", "destroy", ".", "call", "(", "node", ")", ";", "}", "}", "}", ")", ";", "}" ]
Clears visualisation going out of scope
[ "Clears", "visualisation", "going", "out", "of", "scope" ]
67dac5a3ea5146eb70eb975667b49cf3827a5df7
https://github.com/quantmind/d3-visualize/blob/67dac5a3ea5146eb70eb975667b49cf3827a5df7/src/core/visual.js#L190-L207
46,696
Gi60s/cli-format
bin/format.js
maximizeLargeWord
function maximizeLargeWord(word, hardBreakStr, maxWidth) { var availableWidth; var ch; var chWidth; var i; availableWidth = maxWidth - Format.width(hardBreakStr); for (i = 0; i < word.length; i++) { ch = word.charAt(i); chWidth = Format.width(ch); if (availableWidth >= chWidth) { availableWidth -= chWidth; } else { break; } } return { start: word.substr(0, i) + hardBreakStr, remaining: word.substr(i) }; }
javascript
function maximizeLargeWord(word, hardBreakStr, maxWidth) { var availableWidth; var ch; var chWidth; var i; availableWidth = maxWidth - Format.width(hardBreakStr); for (i = 0; i < word.length; i++) { ch = word.charAt(i); chWidth = Format.width(ch); if (availableWidth >= chWidth) { availableWidth -= chWidth; } else { break; } } return { start: word.substr(0, i) + hardBreakStr, remaining: word.substr(i) }; }
[ "function", "maximizeLargeWord", "(", "word", ",", "hardBreakStr", ",", "maxWidth", ")", "{", "var", "availableWidth", ";", "var", "ch", ";", "var", "chWidth", ";", "var", "i", ";", "availableWidth", "=", "maxWidth", "-", "Format", ".", "width", "(", "hardBreakStr", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "word", ".", "length", ";", "i", "++", ")", "{", "ch", "=", "word", ".", "charAt", "(", "i", ")", ";", "chWidth", "=", "Format", ".", "width", "(", "ch", ")", ";", "if", "(", "availableWidth", ">=", "chWidth", ")", "{", "availableWidth", "-=", "chWidth", ";", "}", "else", "{", "break", ";", "}", "}", "return", "{", "start", ":", "word", ".", "substr", "(", "0", ",", "i", ")", "+", "hardBreakStr", ",", "remaining", ":", "word", ".", "substr", "(", "i", ")", "}", ";", "}" ]
If a word is too large for a line then find out how much will fit on one line and return the result. @param {string} word @param {string} hardBreakStr @param {number} maxWidth @returns {object}
[ "If", "a", "word", "is", "too", "large", "for", "a", "line", "then", "find", "out", "how", "much", "will", "fit", "on", "one", "line", "and", "return", "the", "result", "." ]
fe74d976cd3cb3bbbaec7d966ffd9bc41bda150d
https://github.com/Gi60s/cli-format/blob/fe74d976cd3cb3bbbaec7d966ffd9bc41bda150d/bin/format.js#L500-L522
46,697
sammysaglam/axe-prop-types
index.js
function (propType, values) { propType.info = Object.assign( propType.info ? propType.info : {}, values ); if (propType.isRequired) { propType.isRequired.info = Object.assign( propType.isRequired && propType.isRequired.info ? propType.isRequired.info : {}, values ); propType.isRequired.info.isRequired = true; propType.info.isRequired = false; } return propType; }
javascript
function (propType, values) { propType.info = Object.assign( propType.info ? propType.info : {}, values ); if (propType.isRequired) { propType.isRequired.info = Object.assign( propType.isRequired && propType.isRequired.info ? propType.isRequired.info : {}, values ); propType.isRequired.info.isRequired = true; propType.info.isRequired = false; } return propType; }
[ "function", "(", "propType", ",", "values", ")", "{", "propType", ".", "info", "=", "Object", ".", "assign", "(", "propType", ".", "info", "?", "propType", ".", "info", ":", "{", "}", ",", "values", ")", ";", "if", "(", "propType", ".", "isRequired", ")", "{", "propType", ".", "isRequired", ".", "info", "=", "Object", ".", "assign", "(", "propType", ".", "isRequired", "&&", "propType", ".", "isRequired", ".", "info", "?", "propType", ".", "isRequired", ".", "info", ":", "{", "}", ",", "values", ")", ";", "propType", ".", "isRequired", ".", "info", ".", "isRequired", "=", "true", ";", "propType", ".", "info", ".", "isRequired", "=", "false", ";", "}", "return", "propType", ";", "}" ]
function to add key value pair to proptype
[ "function", "to", "add", "key", "value", "pair", "to", "proptype" ]
4f836232c75556ff510bc1ccff2656a4fb88315b
https://github.com/sammysaglam/axe-prop-types/blob/4f836232c75556ff510bc1ccff2656a4fb88315b/index.js#L23-L41
46,698
tamtakoe/node-arjs-builder
index.js
copy
function copy(copiesMap, projectsPath, buildPath) { return _.map(copiesMap, function(dstPath, srcPath) { if (/\/$/.test(dstPath)) { //copy directory return gulp.src(path.join(projectsPath, srcPath)) .pipe(gulp.dest(path.join(buildPath, dstPath))); } else { //copy file return gulp.src(path.join(projectsPath, srcPath)) .pipe(gulpRename(dstPath)) .pipe(gulp.dest(buildPath)); }; }); }
javascript
function copy(copiesMap, projectsPath, buildPath) { return _.map(copiesMap, function(dstPath, srcPath) { if (/\/$/.test(dstPath)) { //copy directory return gulp.src(path.join(projectsPath, srcPath)) .pipe(gulp.dest(path.join(buildPath, dstPath))); } else { //copy file return gulp.src(path.join(projectsPath, srcPath)) .pipe(gulpRename(dstPath)) .pipe(gulp.dest(buildPath)); }; }); }
[ "function", "copy", "(", "copiesMap", ",", "projectsPath", ",", "buildPath", ")", "{", "return", "_", ".", "map", "(", "copiesMap", ",", "function", "(", "dstPath", ",", "srcPath", ")", "{", "if", "(", "/", "\\/$", "/", ".", "test", "(", "dstPath", ")", ")", "{", "//copy directory", "return", "gulp", ".", "src", "(", "path", ".", "join", "(", "projectsPath", ",", "srcPath", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "path", ".", "join", "(", "buildPath", ",", "dstPath", ")", ")", ")", ";", "}", "else", "{", "//copy file", "return", "gulp", ".", "src", "(", "path", ".", "join", "(", "projectsPath", ",", "srcPath", ")", ")", ".", "pipe", "(", "gulpRename", "(", "dstPath", ")", ")", ".", "pipe", "(", "gulp", ".", "dest", "(", "buildPath", ")", ")", ";", "}", ";", "}", ")", ";", "}" ]
copying for other projects
[ "copying", "for", "other", "projects" ]
9fb6ff399fe09b860f1a4673b643d291834ec632
https://github.com/tamtakoe/node-arjs-builder/blob/9fb6ff399fe09b860f1a4673b643d291834ec632/index.js#L211-L224
46,699
waigo/waigo
src/support/middleware/errorHandler.js
function() { let args = Array.prototype.slice.call(arguments), ErrorClass = args[0]; if (_.isObject(ErrorClass)) { args.shift(); } else { ErrorClass = errors.RuntimeError; } args.unshift(null); // the this arg for the .bind() call throw new (Function.prototype.bind.apply(ErrorClass, args)); }
javascript
function() { let args = Array.prototype.slice.call(arguments), ErrorClass = args[0]; if (_.isObject(ErrorClass)) { args.shift(); } else { ErrorClass = errors.RuntimeError; } args.unshift(null); // the this arg for the .bind() call throw new (Function.prototype.bind.apply(ErrorClass, args)); }
[ "function", "(", ")", "{", "let", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ",", "ErrorClass", "=", "args", "[", "0", "]", ";", "if", "(", "_", ".", "isObject", "(", "ErrorClass", ")", ")", "{", "args", ".", "shift", "(", ")", ";", "}", "else", "{", "ErrorClass", "=", "errors", ".", "RuntimeError", ";", "}", "args", ".", "unshift", "(", "null", ")", ";", "// the this arg for the .bind() call", "throw", "new", "(", "Function", ".", "prototype", ".", "bind", ".", "apply", "(", "ErrorClass", ",", "args", ")", ")", ";", "}" ]
Throw an error @param {Class} [errorClass] Error class. Default is `RuntimeError`. @param {Any} ... Additional arguments get passed to error class constructor. @throws Error
[ "Throw", "an", "error" ]
b2f50cd66b8b19016e2c7de75733330c791c76ff
https://github.com/waigo/waigo/blob/b2f50cd66b8b19016e2c7de75733330c791c76ff/src/support/middleware/errorHandler.js#L83-L96