repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
sequence
docstring
stringlengths
4
11.8k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function () { var self = this, bar = self.get('bar'), child = null; util.each(bar.get('children'), function (c) { if (c.get('selected')) { child = c; return false; } return undefined; }); return child; }
javascript
function () { var self = this, bar = self.get('bar'), child = null; util.each(bar.get('children'), function (c) { if (c.get('selected')) { child = c; return false; } return undefined; }); return child; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "bar", "=", "self", ".", "get", "(", "'bar'", ")", ",", "child", "=", "null", ";", "util", ".", "each", "(", "bar", ".", "get", "(", "'children'", ")", ",", "function", "(", "c", ")", "{", "if", "(", "c", ".", "get", "(", "'selected'", ")", ")", "{", "child", "=", "c", ";", "return", "false", ";", "}", "return", "undefined", ";", "}", ")", ";", "return", "child", ";", "}" ]
get selected tab instance @return {KISSY.Tabs.Tab}
[ "get", "selected", "tab", "instance" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L244-L254
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (tab) { var self = this, bar = self.get('bar'), body = self.get('body'); bar.set('selectedTab', tab); body.set('selectedPanelIndex', util.indexOf(tab, bar.get('children'))); return this; }
javascript
function (tab) { var self = this, bar = self.get('bar'), body = self.get('body'); bar.set('selectedTab', tab); body.set('selectedPanelIndex', util.indexOf(tab, bar.get('children'))); return this; }
[ "function", "(", "tab", ")", "{", "var", "self", "=", "this", ",", "bar", "=", "self", ".", "get", "(", "'bar'", ")", ",", "body", "=", "self", ".", "get", "(", "'body'", ")", ";", "bar", ".", "set", "(", "'selectedTab'", ",", "tab", ")", ";", "body", ".", "set", "(", "'selectedPanelIndex'", ",", "util", ".", "indexOf", "(", "tab", ",", "bar", ".", "get", "(", "'children'", ")", ")", ")", ";", "return", "this", ";", "}" ]
set tab as selected @param {KISSY.Tabs.Tab} tab @chainable
[ "set", "tab", "as", "selected" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L301-L306
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/tabs-debug.js
function (panel) { var self = this, bar = self.get('bar'), body = self.get('body'), selectedPanelIndex = util.indexOf(panel, body.get('children')); body.set('selectedPanelIndex', selectedPanelIndex); bar.set('selectedTab', self.getTabAt(selectedPanelIndex)); return this; }
javascript
function (panel) { var self = this, bar = self.get('bar'), body = self.get('body'), selectedPanelIndex = util.indexOf(panel, body.get('children')); body.set('selectedPanelIndex', selectedPanelIndex); bar.set('selectedTab', self.getTabAt(selectedPanelIndex)); return this; }
[ "function", "(", "panel", ")", "{", "var", "self", "=", "this", ",", "bar", "=", "self", ".", "get", "(", "'bar'", ")", ",", "body", "=", "self", ".", "get", "(", "'body'", ")", ",", "selectedPanelIndex", "=", "util", ".", "indexOf", "(", "panel", ",", "body", ".", "get", "(", "'children'", ")", ")", ";", "body", ".", "set", "(", "'selectedPanelIndex'", ",", "selectedPanelIndex", ")", ";", "bar", ".", "set", "(", "'selectedTab'", ",", "self", ".", "getTabAt", "(", "selectedPanelIndex", ")", ")", ";", "return", "this", ";", "}" ]
set panel as selected @param {KISSY.Tabs.Panel} panel @chainable
[ "set", "panel", "as", "selected" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/tabs-debug.js#L312-L317
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (type, create) { var self = this, customEvent, customEventObservables = self.getCustomEvents(); customEvent = customEventObservables && customEventObservables[type]; if (!customEvent && create) { customEvent = customEventObservables[type] = new CustomEventObservable({ currentTarget: self, type: type }); } return customEvent; }
javascript
function (type, create) { var self = this, customEvent, customEventObservables = self.getCustomEvents(); customEvent = customEventObservables && customEventObservables[type]; if (!customEvent && create) { customEvent = customEventObservables[type] = new CustomEventObservable({ currentTarget: self, type: type }); } return customEvent; }
[ "function", "(", "type", ",", "create", ")", "{", "var", "self", "=", "this", ",", "customEvent", ",", "customEventObservables", "=", "self", ".", "getCustomEvents", "(", ")", ";", "customEvent", "=", "customEventObservables", "&&", "customEventObservables", "[", "type", "]", ";", "if", "(", "!", "customEvent", "&&", "create", ")", "{", "customEvent", "=", "customEventObservables", "[", "type", "]", "=", "new", "CustomEventObservable", "(", "{", "currentTarget", ":", "self", ",", "type", ":", "type", "}", ")", ";", "}", "return", "customEvent", ";", "}" ]
Get custom event for specified event @private @param {String} type event type @param {Boolean} [create] whether create custom event on fly @return {KISSY.Event.CustomEvent.CustomEventObservable}
[ "Get", "custom", "event", "for", "specified", "event" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L106-L116
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (type, cfg) { var customEventObservable, self = this; splitAndRun(type, function (t) { customEventObservable = self.getCustomEventObservable(t, true); util.mix(customEventObservable, cfg); }); return self; }
javascript
function (type, cfg) { var customEventObservable, self = this; splitAndRun(type, function (t) { customEventObservable = self.getCustomEventObservable(t, true); util.mix(customEventObservable, cfg); }); return self; }
[ "function", "(", "type", ",", "cfg", ")", "{", "var", "customEventObservable", ",", "self", "=", "this", ";", "splitAndRun", "(", "type", ",", "function", "(", "t", ")", "{", "customEventObservable", "=", "self", ".", "getCustomEventObservable", "(", "t", ",", "true", ")", ";", "util", ".", "mix", "(", "customEventObservable", ",", "cfg", ")", ";", "}", ")", ";", "return", "self", ";", "}" ]
Creates a new custom event of the specified type @method publish @param {String} type The type of the event @param {Object} cfg Config params @param {Boolean} [cfg.bubbles=true] whether or not this event bubbles @param {Function} [cfg.defaultFn] this event's default action @chainable
[ "Creates", "a", "new", "custom", "event", "of", "the", "specified", "type" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L175-L182
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (anotherTarget) { var self = this, targets = self.getTargets(); if (!util.inArray(anotherTarget, targets)) { targets.push(anotherTarget); } return self; }
javascript
function (anotherTarget) { var self = this, targets = self.getTargets(); if (!util.inArray(anotherTarget, targets)) { targets.push(anotherTarget); } return self; }
[ "function", "(", "anotherTarget", ")", "{", "var", "self", "=", "this", ",", "targets", "=", "self", ".", "getTargets", "(", ")", ";", "if", "(", "!", "util", ".", "inArray", "(", "anotherTarget", ",", "targets", ")", ")", "{", "targets", ".", "push", "(", "anotherTarget", ")", ";", "}", "return", "self", ";", "}" ]
Registers another EventTarget as a bubble target. @method addTarget @param {KISSY.Event.CustomEvent.Target} anotherTarget Another EventTarget instance to add @chainable
[ "Registers", "another", "EventTarget", "as", "a", "bubble", "target", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L189-L195
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (anotherTarget) { var self = this, targets = self.getTargets(), index = util.indexOf(anotherTarget, targets); if (index !== -1) { targets.splice(index, 1); } return self; }
javascript
function (anotherTarget) { var self = this, targets = self.getTargets(), index = util.indexOf(anotherTarget, targets); if (index !== -1) { targets.splice(index, 1); } return self; }
[ "function", "(", "anotherTarget", ")", "{", "var", "self", "=", "this", ",", "targets", "=", "self", ".", "getTargets", "(", ")", ",", "index", "=", "util", ".", "indexOf", "(", "anotherTarget", ",", "targets", ")", ";", "if", "(", "index", "!==", "-", "1", ")", "{", "targets", ".", "splice", "(", "index", ",", "1", ")", ";", "}", "return", "self", ";", "}" ]
Removes a bubble target @method removeTarget @param {KISSY.Event.CustomEvent.Target} anotherTarget Another EventTarget instance to remove @chainable
[ "Removes", "a", "bubble", "target" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L202-L208
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvent; type = cfg.type; customEvent = self.getCustomEventObservable(type, true); if (customEvent) { customEvent.on(cfg); } }, 0, type, fn, context); return self; // chain }
javascript
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvent; type = cfg.type; customEvent = self.getCustomEventObservable(type, true); if (customEvent) { customEvent.on(cfg); } }, 0, type, fn, context); return self; // chain }
[ "function", "(", "type", ",", "fn", ",", "context", ")", "{", "var", "self", "=", "this", ";", "Utils", ".", "batchForType", "(", "function", "(", "type", ",", "fn", ",", "context", ")", "{", "var", "cfg", "=", "Utils", ".", "normalizeParam", "(", "type", ",", "fn", ",", "context", ")", ",", "customEvent", ";", "type", "=", "cfg", ".", "type", ";", "customEvent", "=", "self", ".", "getCustomEventObservable", "(", "type", ",", "true", ")", ";", "if", "(", "customEvent", ")", "{", "customEvent", ".", "on", "(", "cfg", ")", ";", "}", "}", ",", "0", ",", "type", ",", "fn", ",", "context", ")", ";", "return", "self", ";", "}" ]
Subscribe a callback function to a custom event fired by this object or from an object that bubbles its events to this object. @method on @param {String} type The name of the event @param {Function} fn The callback to execute in response to the event @param {Object} [context] this object in callback @chainable
[ "Subscribe", "a", "callback", "function", "to", "a", "custom", "event", "fired", "by", "this", "object", "or", "from", "an", "object", "that", "bubbles", "its", "events", "to", "this", "object", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L228-L239
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvents, customEvent; type = cfg.type; if (type) { customEvent = self.getCustomEventObservable(type, true); if (customEvent) { customEvent.detach(cfg); } } else { customEvents = self.getCustomEvents(); util.each(customEvents, function (customEvent) { customEvent.detach(cfg); }); } }, 0, type, fn, context); return self; // chain }
javascript
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvents, customEvent; type = cfg.type; if (type) { customEvent = self.getCustomEventObservable(type, true); if (customEvent) { customEvent.detach(cfg); } } else { customEvents = self.getCustomEvents(); util.each(customEvents, function (customEvent) { customEvent.detach(cfg); }); } }, 0, type, fn, context); return self; // chain }
[ "function", "(", "type", ",", "fn", ",", "context", ")", "{", "var", "self", "=", "this", ";", "Utils", ".", "batchForType", "(", "function", "(", "type", ",", "fn", ",", "context", ")", "{", "var", "cfg", "=", "Utils", ".", "normalizeParam", "(", "type", ",", "fn", ",", "context", ")", ",", "customEvents", ",", "customEvent", ";", "type", "=", "cfg", ".", "type", ";", "if", "(", "type", ")", "{", "customEvent", "=", "self", ".", "getCustomEventObservable", "(", "type", ",", "true", ")", ";", "if", "(", "customEvent", ")", "{", "customEvent", ".", "detach", "(", "cfg", ")", ";", "}", "}", "else", "{", "customEvents", "=", "self", ".", "getCustomEvents", "(", ")", ";", "util", ".", "each", "(", "customEvents", ",", "function", "(", "customEvent", ")", "{", "customEvent", ".", "detach", "(", "cfg", ")", ";", "}", ")", ";", "}", "}", ",", "0", ",", "type", ",", "fn", ",", "context", ")", ";", "return", "self", ";", "}" ]
chain Detach one or more listeners from the specified event @method detach @param {String} type The name of the event @param {Function} [fn] The subscribed function to un-subscribe. if not supplied, all observers will be removed. @param {Object} [context] The custom object passed to subscribe. @chainable
[ "chain", "Detach", "one", "or", "more", "listeners", "from", "the", "specified", "event" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L249-L267
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
CustomEventObservable
function CustomEventObservable() { var self = this; CustomEventObservable.superclass.constructor.apply(self, arguments); self.defaultFn = null; self.defaultTargetOnly = false; /** * whether this event can bubble. * Defaults to: true * @cfg {Boolean} bubbles */ /** * whether this event can bubble. * Defaults to: true * @cfg {Boolean} bubbles */ self.bubbles = true; /** * event target which binds current custom event * @cfg {KISSY.Event.CustomEvent.Target} currentTarget */ }
javascript
function CustomEventObservable() { var self = this; CustomEventObservable.superclass.constructor.apply(self, arguments); self.defaultFn = null; self.defaultTargetOnly = false; /** * whether this event can bubble. * Defaults to: true * @cfg {Boolean} bubbles */ /** * whether this event can bubble. * Defaults to: true * @cfg {Boolean} bubbles */ self.bubbles = true; /** * event target which binds current custom event * @cfg {KISSY.Event.CustomEvent.Target} currentTarget */ }
[ "function", "CustomEventObservable", "(", ")", "{", "var", "self", "=", "this", ";", "CustomEventObservable", ".", "superclass", ".", "constructor", ".", "apply", "(", "self", ",", "arguments", ")", ";", "self", ".", "defaultFn", "=", "null", ";", "self", ".", "defaultTargetOnly", "=", "false", ";", "self", ".", "bubbles", "=", "true", ";", "}" ]
custom event for registering and un-registering observer for specified event on normal object. @class KISSY.Event.CustomEvent.CustomEventObservable @extends KISSY.Event.Observable @private custom event for registering and un-registering observer for specified event on normal object. @class KISSY.Event.CustomEvent.CustomEventObservable @extends KISSY.Event.Observable @private
[ "custom", "event", "for", "registering", "and", "un", "-", "registering", "observer", "for", "specified", "event", "on", "normal", "object", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L305-L323
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (eventData) { eventData = eventData || {}; var self = this, bubbles = self.bubbles, currentTarget = self.currentTarget, parents, parentsLen, type = self.type, defaultFn = self.defaultFn, i, customEventObject = eventData, gRet, ret; eventData.type = type; if (!customEventObject.isEventObject) { customEventObject = new CustomEventObject(customEventObject); } customEventObject.target = customEventObject.target || currentTarget; customEventObject.currentTarget = currentTarget; ret = self.notify(customEventObject); if (gRet !== false && ret !== undefined) { gRet = ret; } // gRet === false prevent // gRet === false prevent if (bubbles && !customEventObject.isPropagationStopped()) { parents = currentTarget.getTargets(); parentsLen = parents && parents.length || 0; for (i = 0; i < parentsLen && !customEventObject.isPropagationStopped(); i++) { ret = parents[i].fire(type, customEventObject); // false 优先返回 // false 优先返回 if (gRet !== false && ret !== undefined) { gRet = ret; } } } // bubble first // parent defaultFn first // child defaultFn last // bubble first // parent defaultFn first // child defaultFn last if (defaultFn && !customEventObject.isDefaultPrevented()) { var target = customEventObject.target, lowestCustomEventObservable = target.getCustomEventObservable(customEventObject.type); if (!self.defaultTargetOnly && // defaults to false (!lowestCustomEventObservable || !lowestCustomEventObservable.defaultTargetOnly) || currentTarget === target) { // default value as final value if possible gRet = defaultFn.call(currentTarget, customEventObject); } } return gRet; }
javascript
function (eventData) { eventData = eventData || {}; var self = this, bubbles = self.bubbles, currentTarget = self.currentTarget, parents, parentsLen, type = self.type, defaultFn = self.defaultFn, i, customEventObject = eventData, gRet, ret; eventData.type = type; if (!customEventObject.isEventObject) { customEventObject = new CustomEventObject(customEventObject); } customEventObject.target = customEventObject.target || currentTarget; customEventObject.currentTarget = currentTarget; ret = self.notify(customEventObject); if (gRet !== false && ret !== undefined) { gRet = ret; } // gRet === false prevent // gRet === false prevent if (bubbles && !customEventObject.isPropagationStopped()) { parents = currentTarget.getTargets(); parentsLen = parents && parents.length || 0; for (i = 0; i < parentsLen && !customEventObject.isPropagationStopped(); i++) { ret = parents[i].fire(type, customEventObject); // false 优先返回 // false 优先返回 if (gRet !== false && ret !== undefined) { gRet = ret; } } } // bubble first // parent defaultFn first // child defaultFn last // bubble first // parent defaultFn first // child defaultFn last if (defaultFn && !customEventObject.isDefaultPrevented()) { var target = customEventObject.target, lowestCustomEventObservable = target.getCustomEventObservable(customEventObject.type); if (!self.defaultTargetOnly && // defaults to false (!lowestCustomEventObservable || !lowestCustomEventObservable.defaultTargetOnly) || currentTarget === target) { // default value as final value if possible gRet = defaultFn.call(currentTarget, customEventObject); } } return gRet; }
[ "function", "(", "eventData", ")", "{", "eventData", "=", "eventData", "||", "{", "}", ";", "var", "self", "=", "this", ",", "bubbles", "=", "self", ".", "bubbles", ",", "currentTarget", "=", "self", ".", "currentTarget", ",", "parents", ",", "parentsLen", ",", "type", "=", "self", ".", "type", ",", "defaultFn", "=", "self", ".", "defaultFn", ",", "i", ",", "customEventObject", "=", "eventData", ",", "gRet", ",", "ret", ";", "eventData", ".", "type", "=", "type", ";", "if", "(", "!", "customEventObject", ".", "isEventObject", ")", "{", "customEventObject", "=", "new", "CustomEventObject", "(", "customEventObject", ")", ";", "}", "customEventObject", ".", "target", "=", "customEventObject", ".", "target", "||", "currentTarget", ";", "customEventObject", ".", "currentTarget", "=", "currentTarget", ";", "ret", "=", "self", ".", "notify", "(", "customEventObject", ")", ";", "if", "(", "gRet", "!==", "false", "&&", "ret", "!==", "undefined", ")", "{", "gRet", "=", "ret", ";", "}", "if", "(", "bubbles", "&&", "!", "customEventObject", ".", "isPropagationStopped", "(", ")", ")", "{", "parents", "=", "currentTarget", ".", "getTargets", "(", ")", ";", "parentsLen", "=", "parents", "&&", "parents", ".", "length", "||", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "parentsLen", "&&", "!", "customEventObject", ".", "isPropagationStopped", "(", ")", ";", "i", "++", ")", "{", "ret", "=", "parents", "[", "i", "]", ".", "fire", "(", "type", ",", "customEventObject", ")", ";", "if", "(", "gRet", "!==", "false", "&&", "ret", "!==", "undefined", ")", "{", "gRet", "=", "ret", ";", "}", "}", "}", "if", "(", "defaultFn", "&&", "!", "customEventObject", ".", "isDefaultPrevented", "(", ")", ")", "{", "var", "target", "=", "customEventObject", ".", "target", ",", "lowestCustomEventObservable", "=", "target", ".", "getCustomEventObservable", "(", "customEventObject", ".", "type", ")", ";", "if", "(", "!", "self", ".", "defaultTargetOnly", "&&", "(", "!", "lowestCustomEventObservable", "||", "!", "lowestCustomEventObservable", ".", "defaultTargetOnly", ")", "||", "currentTarget", "===", "target", ")", "{", "gRet", "=", "defaultFn", ".", "call", "(", "currentTarget", ",", "customEventObject", ")", ";", "}", "}", "return", "gRet", ";", "}" ]
notify current custom event 's observers and then bubble up if this event can bubble. @param {KISSY.Event.CustomEvent.Object} eventData @return {*} return false if one of custom event 's observers (include bubbled) else return last value of custom event 's observers (include bubbled) 's return value.
[ "notify", "current", "custom", "event", "s", "observers", "and", "then", "bubble", "up", "if", "this", "event", "can", "bubble", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L347-L386
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (event) { // duplicate,in case detach itself in one observer var observers = [].concat(this.observers), ret, gRet, len = observers.length, i; for (i = 0; i < len && !event.isImmediatePropagationStopped(); i++) { ret = observers[i].notify(event, this); if (gRet !== false && ret !== undefined) { gRet = ret; } } return gRet; }
javascript
function (event) { // duplicate,in case detach itself in one observer var observers = [].concat(this.observers), ret, gRet, len = observers.length, i; for (i = 0; i < len && !event.isImmediatePropagationStopped(); i++) { ret = observers[i].notify(event, this); if (gRet !== false && ret !== undefined) { gRet = ret; } } return gRet; }
[ "function", "(", "event", ")", "{", "var", "observers", "=", "[", "]", ".", "concat", "(", "this", ".", "observers", ")", ",", "ret", ",", "gRet", ",", "len", "=", "observers", ".", "length", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", "&&", "!", "event", ".", "isImmediatePropagationStopped", "(", ")", ";", "i", "++", ")", "{", "ret", "=", "observers", "[", "i", "]", ".", "notify", "(", "event", ",", "this", ")", ";", "if", "(", "gRet", "!==", "false", "&&", "ret", "!==", "undefined", ")", "{", "gRet", "=", "ret", ";", "}", "}", "return", "gRet", ";", "}" ]
notify current event 's observers @param {KISSY.Event.CustomEvent.Object} event @return {*} return false if one of custom event 's observers else return last value of custom event 's observers 's return value.
[ "notify", "current", "event", "s", "observers" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L393-L403
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js
function (cfg) { var groupsRe, self = this, fn = cfg.fn, context = cfg.context, currentTarget = self.currentTarget, observers = self.observers, groups = cfg.groups; if (!observers.length) { return; } if (groups) { groupsRe = Utils.getGroupsRe(groups); } var i, j, t, observer, observerContext, len = observers.length; // 移除 fn // 移除 fn if (fn || groupsRe) { context = context || currentTarget; for (i = 0, j = 0, t = []; i < len; ++i) { observer = observers[i]; observerContext = observer.context || currentTarget; if (context !== observerContext || // 指定了函数,函数不相等,保留 fn && fn !== observer.fn || // 指定了删除的某些组,而该 observer 不属于这些组,保留,否则删除 groupsRe && !observer.groups.match(groupsRe)) { t[j++] = observer; } } self.observers = t; } else { // 全部删除 self.reset(); } // does not need to clear memory if customEvent has no observer // customEvent has defaultFn .....! // self.checkMemory(); }
javascript
function (cfg) { var groupsRe, self = this, fn = cfg.fn, context = cfg.context, currentTarget = self.currentTarget, observers = self.observers, groups = cfg.groups; if (!observers.length) { return; } if (groups) { groupsRe = Utils.getGroupsRe(groups); } var i, j, t, observer, observerContext, len = observers.length; // 移除 fn // 移除 fn if (fn || groupsRe) { context = context || currentTarget; for (i = 0, j = 0, t = []; i < len; ++i) { observer = observers[i]; observerContext = observer.context || currentTarget; if (context !== observerContext || // 指定了函数,函数不相等,保留 fn && fn !== observer.fn || // 指定了删除的某些组,而该 observer 不属于这些组,保留,否则删除 groupsRe && !observer.groups.match(groupsRe)) { t[j++] = observer; } } self.observers = t; } else { // 全部删除 self.reset(); } // does not need to clear memory if customEvent has no observer // customEvent has defaultFn .....! // self.checkMemory(); }
[ "function", "(", "cfg", ")", "{", "var", "groupsRe", ",", "self", "=", "this", ",", "fn", "=", "cfg", ".", "fn", ",", "context", "=", "cfg", ".", "context", ",", "currentTarget", "=", "self", ".", "currentTarget", ",", "observers", "=", "self", ".", "observers", ",", "groups", "=", "cfg", ".", "groups", ";", "if", "(", "!", "observers", ".", "length", ")", "{", "return", ";", "}", "if", "(", "groups", ")", "{", "groupsRe", "=", "Utils", ".", "getGroupsRe", "(", "groups", ")", ";", "}", "var", "i", ",", "j", ",", "t", ",", "observer", ",", "observerContext", ",", "len", "=", "observers", ".", "length", ";", "if", "(", "fn", "||", "groupsRe", ")", "{", "context", "=", "context", "||", "currentTarget", ";", "for", "(", "i", "=", "0", ",", "j", "=", "0", ",", "t", "=", "[", "]", ";", "i", "<", "len", ";", "++", "i", ")", "{", "observer", "=", "observers", "[", "i", "]", ";", "observerContext", "=", "observer", ".", "context", "||", "currentTarget", ";", "if", "(", "context", "!==", "observerContext", "||", "fn", "&&", "fn", "!==", "observer", ".", "fn", "||", "groupsRe", "&&", "!", "observer", ".", "groups", ".", "match", "(", "groupsRe", ")", ")", "{", "t", "[", "j", "++", "]", "=", "observer", ";", "}", "}", "self", ".", "observers", "=", "t", ";", "}", "else", "{", "self", ".", "reset", "(", ")", ";", "}", "}" ]
remove some observers from current event 's observers by observer config param @param {Object} cfg {@link KISSY.Event.CustomEvent.Observer} 's config
[ "remove", "some", "observers", "from", "current", "event", "s", "observers", "by", "observer", "config", "param" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/lib/build/event/custom.js#L408-L436
train
craterdog-bali/js-bali-component-framework
src/elements/Reference.js
Reference
function Reference(value, parameters) { abstractions.Element.call(this, utilities.types.REFERENCE, parameters); try { if (value.constructor.name !== 'URL') value = new URL(value.replace(/\$tag:#/, '$tag:%23')); } catch (exception) { throw new utilities.Exception({ $module: '/bali/elements/Reference', $procedure: '$Reference', $exception: '$invalidParameter', $parameter: '"' + value + '"', $text: '"An invalid reference value was passed to the constructor."' }, exception); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Reference(value, parameters) { abstractions.Element.call(this, utilities.types.REFERENCE, parameters); try { if (value.constructor.name !== 'URL') value = new URL(value.replace(/\$tag:#/, '$tag:%23')); } catch (exception) { throw new utilities.Exception({ $module: '/bali/elements/Reference', $procedure: '$Reference', $exception: '$invalidParameter', $parameter: '"' + value + '"', $text: '"An invalid reference value was passed to the constructor."' }, exception); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Reference", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "REFERENCE", ",", "parameters", ")", ";", "try", "{", "if", "(", "value", ".", "constructor", ".", "name", "!==", "'URL'", ")", "value", "=", "new", "URL", "(", "value", ".", "replace", "(", "/", "\\$tag:#", "/", ",", "'$tag:%23'", ")", ")", ";", "}", "catch", "(", "exception", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Reference'", ",", "$procedure", ":", "'$Reference'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "'\"'", "+", "value", "+", "'\"'", ",", "$text", ":", "'\"An invalid reference value was passed to the constructor.\"'", "}", ",", "exception", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new reference element using the specified value. @param {String|URL} value The value of the reference. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Reference} The new reference element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "reference", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Reference.js#L31-L49
train
craterdog-bali/js-bali-component-framework
src/elements/Complex.js
Complex
function Complex(real, imaginary, parameters) { abstractions.Element.call(this, utilities.types.NUMBER, parameters); // normalize the values if (real === undefined || real === null || real === -0) { real = 0; } real = utilities.precision.lockOnExtreme(real); if (imaginary === undefined || imaginary === null || imaginary === -0) { imaginary = 0; } if (imaginary.getTypeId && imaginary.getTypeId() === utilities.types.ANGLE) { // convert polar to rectangular var magnitude = real; var phase = imaginary; if (magnitude < 0) { // normalize the magnitude magnitude = -magnitude; phase = Angle.inverse(phase); } real = magnitude * Angle.cosine(phase); imaginary = magnitude * Angle.sine(phase); } imaginary = utilities.precision.lockOnExtreme(imaginary); if (real.toString() === 'NaN' || imaginary.toString() === 'NaN') { real = NaN; imaginary = NaN; } else if (real === Infinity || real === -Infinity || imaginary === Infinity || imaginary === -Infinity) { real = Infinity; imaginary = Infinity; } this.getReal = function() { return real; }; this.getImaginary = function() { return imaginary; }; this.getMagnitude = function() { // need to preserve full precision on this except for the sum part var magnitude = Math.sqrt(utilities.precision.sum(Math.pow(real, 2), Math.pow(imaginary, 2))); magnitude = utilities.precision.lockOnExtreme(magnitude); return magnitude; }; this.getPhase = function() { if (this.isInfinite()) return new Angle(0); if (this.isUndefined()) return undefined; const phase = Angle.arctangent(imaginary, real); return phase; }; return this; }
javascript
function Complex(real, imaginary, parameters) { abstractions.Element.call(this, utilities.types.NUMBER, parameters); // normalize the values if (real === undefined || real === null || real === -0) { real = 0; } real = utilities.precision.lockOnExtreme(real); if (imaginary === undefined || imaginary === null || imaginary === -0) { imaginary = 0; } if (imaginary.getTypeId && imaginary.getTypeId() === utilities.types.ANGLE) { // convert polar to rectangular var magnitude = real; var phase = imaginary; if (magnitude < 0) { // normalize the magnitude magnitude = -magnitude; phase = Angle.inverse(phase); } real = magnitude * Angle.cosine(phase); imaginary = magnitude * Angle.sine(phase); } imaginary = utilities.precision.lockOnExtreme(imaginary); if (real.toString() === 'NaN' || imaginary.toString() === 'NaN') { real = NaN; imaginary = NaN; } else if (real === Infinity || real === -Infinity || imaginary === Infinity || imaginary === -Infinity) { real = Infinity; imaginary = Infinity; } this.getReal = function() { return real; }; this.getImaginary = function() { return imaginary; }; this.getMagnitude = function() { // need to preserve full precision on this except for the sum part var magnitude = Math.sqrt(utilities.precision.sum(Math.pow(real, 2), Math.pow(imaginary, 2))); magnitude = utilities.precision.lockOnExtreme(magnitude); return magnitude; }; this.getPhase = function() { if (this.isInfinite()) return new Angle(0); if (this.isUndefined()) return undefined; const phase = Angle.arctangent(imaginary, real); return phase; }; return this; }
[ "function", "Complex", "(", "real", ",", "imaginary", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "NUMBER", ",", "parameters", ")", ";", "if", "(", "real", "===", "undefined", "||", "real", "===", "null", "||", "real", "===", "-", "0", ")", "{", "real", "=", "0", ";", "}", "real", "=", "utilities", ".", "precision", ".", "lockOnExtreme", "(", "real", ")", ";", "if", "(", "imaginary", "===", "undefined", "||", "imaginary", "===", "null", "||", "imaginary", "===", "-", "0", ")", "{", "imaginary", "=", "0", ";", "}", "if", "(", "imaginary", ".", "getTypeId", "&&", "imaginary", ".", "getTypeId", "(", ")", "===", "utilities", ".", "types", ".", "ANGLE", ")", "{", "var", "magnitude", "=", "real", ";", "var", "phase", "=", "imaginary", ";", "if", "(", "magnitude", "<", "0", ")", "{", "magnitude", "=", "-", "magnitude", ";", "phase", "=", "Angle", ".", "inverse", "(", "phase", ")", ";", "}", "real", "=", "magnitude", "*", "Angle", ".", "cosine", "(", "phase", ")", ";", "imaginary", "=", "magnitude", "*", "Angle", ".", "sine", "(", "phase", ")", ";", "}", "imaginary", "=", "utilities", ".", "precision", ".", "lockOnExtreme", "(", "imaginary", ")", ";", "if", "(", "real", ".", "toString", "(", ")", "===", "'NaN'", "||", "imaginary", ".", "toString", "(", ")", "===", "'NaN'", ")", "{", "real", "=", "NaN", ";", "imaginary", "=", "NaN", ";", "}", "else", "if", "(", "real", "===", "Infinity", "||", "real", "===", "-", "Infinity", "||", "imaginary", "===", "Infinity", "||", "imaginary", "===", "-", "Infinity", ")", "{", "real", "=", "Infinity", ";", "imaginary", "=", "Infinity", ";", "}", "this", ".", "getReal", "=", "function", "(", ")", "{", "return", "real", ";", "}", ";", "this", ".", "getImaginary", "=", "function", "(", ")", "{", "return", "imaginary", ";", "}", ";", "this", ".", "getMagnitude", "=", "function", "(", ")", "{", "var", "magnitude", "=", "Math", ".", "sqrt", "(", "utilities", ".", "precision", ".", "sum", "(", "Math", ".", "pow", "(", "real", ",", "2", ")", ",", "Math", ".", "pow", "(", "imaginary", ",", "2", ")", ")", ")", ";", "magnitude", "=", "utilities", ".", "precision", ".", "lockOnExtreme", "(", "magnitude", ")", ";", "return", "magnitude", ";", "}", ";", "this", ".", "getPhase", "=", "function", "(", ")", "{", "if", "(", "this", ".", "isInfinite", "(", ")", ")", "return", "new", "Angle", "(", "0", ")", ";", "if", "(", "this", ".", "isUndefined", "(", ")", ")", "return", "undefined", ";", "const", "phase", "=", "Angle", ".", "arctangent", "(", "imaginary", ",", "real", ")", ";", "return", "phase", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This constructor creates an immutable instance of a complex number using the specified real and imaginary values. If the imaginary value is an angle then the complex number is in polar form, otherwise it is in rectangular form. @constructor @param {Number} real The real value of the complex number. @param {Number|Angle} imaginary The imaginary value of the complex number. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Complex} The new complex number.
[ "PUBLIC", "CONSTRUCTORS", "This", "constructor", "creates", "an", "immutable", "instance", "of", "a", "complex", "number", "using", "the", "specified", "real", "and", "imaginary", "values", ".", "If", "the", "imaginary", "value", "is", "an", "angle", "then", "the", "complex", "number", "is", "in", "polar", "form", "otherwise", "it", "is", "in", "rectangular", "form", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Complex.js#L35-L84
train
craterdog-bali/js-bali-component-framework
src/utilities/Sorter.js
Sorter
function Sorter(comparator) { // the comparator is a private attribute so methods that use it are defined in the constructor comparator = comparator || new Comparator(); this.sortCollection = function(collection) { if (collection && collection.getSize() > 1) { var array = collection.toArray(); array = sortArray(comparator, array); collection.deleteAll(); collection.addItems(array); } }; return this; }
javascript
function Sorter(comparator) { // the comparator is a private attribute so methods that use it are defined in the constructor comparator = comparator || new Comparator(); this.sortCollection = function(collection) { if (collection && collection.getSize() > 1) { var array = collection.toArray(); array = sortArray(comparator, array); collection.deleteAll(); collection.addItems(array); } }; return this; }
[ "function", "Sorter", "(", "comparator", ")", "{", "comparator", "=", "comparator", "||", "new", "Comparator", "(", ")", ";", "this", ".", "sortCollection", "=", "function", "(", "collection", ")", "{", "if", "(", "collection", "&&", "collection", ".", "getSize", "(", ")", ">", "1", ")", "{", "var", "array", "=", "collection", ".", "toArray", "(", ")", ";", "array", "=", "sortArray", "(", "comparator", ",", "array", ")", ";", "collection", ".", "deleteAll", "(", ")", ";", "collection", ".", "addItems", "(", "array", ")", ";", "}", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This sorter class implements a standard merge sort algorithm. The collection to be sorted is recursively split into two collections each of which are then sorted and then the two collections are merged back into a sorted collection. @constructor @param {Comparator} comparator An optional comparator to be used when comparing items during sorting. If none is specified, the natural comparator will be used.
[ "PUBLIC", "CONSTRUCTORS", "This", "sorter", "class", "implements", "a", "standard", "merge", "sort", "algorithm", ".", "The", "collection", "to", "be", "sorted", "is", "recursively", "split", "into", "two", "collections", "each", "of", "which", "are", "then", "sorted", "and", "then", "the", "two", "collections", "are", "merged", "back", "into", "a", "sorted", "collection", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/utilities/Sorter.js#L30-L45
train
craterdog-bali/js-bali-component-framework
src/collections/Set.js
Set
function Set(parameters, comparator) { parameters = parameters || new composites.Parameters(new Catalog()); if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Set/v1'); abstractions.Collection.call(this, utilities.types.SET, parameters); // the comparator and tree are private attributes so methods that use // them are defined in the constructor comparator = comparator || new utilities.Comparator(); const tree = new RandomizedTree(comparator); this.acceptVisitor = function(visitor) { visitor.visitSet(this); }; this.toArray = function() { const array = []; const iterator = new TreeIterator(tree); while (iterator.hasNext()) array.push(iterator.getNext()); return array; }; this.getComparator = function() { return comparator; }; this.getSize = function() { return tree.size; }; this.getIterator = function() { return new TreeIterator(tree); }; this.getIndex = function(item) { item = this.convert(item); return tree.index(item) + 1; // convert to ordinal based indexing }; this.getItem = function(index) { index = this.normalizeIndex(index) - 1; // convert to javascript zero based indexing return tree.node(index).value; }; this.addItem = function(item) { item = this.convert(item); return tree.insert(item); }; this.removeItem = function(item) { item = this.convert(item); return tree.remove(item); }; this.removeItems = function(items) { var count = 0; const iterator = items.getIterator(); while (iterator.hasNext()) { const item = iterator.getNext(); if (this.removeItem(item)) { count++; } } return count; }; this.deleteAll = function() { tree.clear(); }; return this; }
javascript
function Set(parameters, comparator) { parameters = parameters || new composites.Parameters(new Catalog()); if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Set/v1'); abstractions.Collection.call(this, utilities.types.SET, parameters); // the comparator and tree are private attributes so methods that use // them are defined in the constructor comparator = comparator || new utilities.Comparator(); const tree = new RandomizedTree(comparator); this.acceptVisitor = function(visitor) { visitor.visitSet(this); }; this.toArray = function() { const array = []; const iterator = new TreeIterator(tree); while (iterator.hasNext()) array.push(iterator.getNext()); return array; }; this.getComparator = function() { return comparator; }; this.getSize = function() { return tree.size; }; this.getIterator = function() { return new TreeIterator(tree); }; this.getIndex = function(item) { item = this.convert(item); return tree.index(item) + 1; // convert to ordinal based indexing }; this.getItem = function(index) { index = this.normalizeIndex(index) - 1; // convert to javascript zero based indexing return tree.node(index).value; }; this.addItem = function(item) { item = this.convert(item); return tree.insert(item); }; this.removeItem = function(item) { item = this.convert(item); return tree.remove(item); }; this.removeItems = function(items) { var count = 0; const iterator = items.getIterator(); while (iterator.hasNext()) { const item = iterator.getNext(); if (this.removeItem(item)) { count++; } } return count; }; this.deleteAll = function() { tree.clear(); }; return this; }
[ "function", "Set", "(", "parameters", ",", "comparator", ")", "{", "parameters", "=", "parameters", "||", "new", "composites", ".", "Parameters", "(", "new", "Catalog", "(", ")", ")", ";", "if", "(", "!", "parameters", ".", "getParameter", "(", "'$type'", ")", ")", "parameters", ".", "setParameter", "(", "'$type'", ",", "'/bali/collections/Set/v1'", ")", ";", "abstractions", ".", "Collection", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "SET", ",", "parameters", ")", ";", "comparator", "=", "comparator", "||", "new", "utilities", ".", "Comparator", "(", ")", ";", "const", "tree", "=", "new", "RandomizedTree", "(", "comparator", ")", ";", "this", ".", "acceptVisitor", "=", "function", "(", "visitor", ")", "{", "visitor", ".", "visitSet", "(", "this", ")", ";", "}", ";", "this", ".", "toArray", "=", "function", "(", ")", "{", "const", "array", "=", "[", "]", ";", "const", "iterator", "=", "new", "TreeIterator", "(", "tree", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "array", ".", "push", "(", "iterator", ".", "getNext", "(", ")", ")", ";", "return", "array", ";", "}", ";", "this", ".", "getComparator", "=", "function", "(", ")", "{", "return", "comparator", ";", "}", ";", "this", ".", "getSize", "=", "function", "(", ")", "{", "return", "tree", ".", "size", ";", "}", ";", "this", ".", "getIterator", "=", "function", "(", ")", "{", "return", "new", "TreeIterator", "(", "tree", ")", ";", "}", ";", "this", ".", "getIndex", "=", "function", "(", "item", ")", "{", "item", "=", "this", ".", "convert", "(", "item", ")", ";", "return", "tree", ".", "index", "(", "item", ")", "+", "1", ";", "}", ";", "this", ".", "getItem", "=", "function", "(", "index", ")", "{", "index", "=", "this", ".", "normalizeIndex", "(", "index", ")", "-", "1", ";", "return", "tree", ".", "node", "(", "index", ")", ".", "value", ";", "}", ";", "this", ".", "addItem", "=", "function", "(", "item", ")", "{", "item", "=", "this", ".", "convert", "(", "item", ")", ";", "return", "tree", ".", "insert", "(", "item", ")", ";", "}", ";", "this", ".", "removeItem", "=", "function", "(", "item", ")", "{", "item", "=", "this", ".", "convert", "(", "item", ")", ";", "return", "tree", ".", "remove", "(", "item", ")", ";", "}", ";", "this", ".", "removeItems", "=", "function", "(", "items", ")", "{", "var", "count", "=", "0", ";", "const", "iterator", "=", "items", ".", "getIterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "const", "item", "=", "iterator", ".", "getNext", "(", ")", ";", "if", "(", "this", ".", "removeItem", "(", "item", ")", ")", "{", "count", "++", ";", "}", "}", "return", "count", ";", "}", ";", "this", ".", "deleteAll", "=", "function", "(", ")", "{", "tree", ".", "clear", "(", ")", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This constructor creates a new set component with optional parameters that are used to parameterize its type. @param {Parameters} parameters Optional parameters used to parameterize this set. @param {Comparator} comparator An optional comparator. @returns {Set} The new set.
[ "PUBLIC", "CONSTRUCTORS", "This", "constructor", "creates", "a", "new", "set", "component", "with", "optional", "parameters", "that", "are", "used", "to", "parameterize", "its", "type", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/collections/Set.js#L33-L104
train
llorsat/wonkajs
dist/templates/libraries/helpers.js
uri
function uri() { var uri = App.pkg.settings.api || ""; _.each(arguments, function(item) { uri += item + '/'; }); return uri.substring(0, uri.length - 1); }
javascript
function uri() { var uri = App.pkg.settings.api || ""; _.each(arguments, function(item) { uri += item + '/'; }); return uri.substring(0, uri.length - 1); }
[ "function", "uri", "(", ")", "{", "var", "uri", "=", "App", ".", "pkg", ".", "settings", ".", "api", "||", "\"\"", ";", "_", ".", "each", "(", "arguments", ",", "function", "(", "item", ")", "{", "uri", "+=", "item", "+", "'/'", ";", "}", ")", ";", "return", "uri", ".", "substring", "(", "0", ",", "uri", ".", "length", "-", "1", ")", ";", "}" ]
API uri builder
[ "API", "uri", "builder" ]
c45d7feaefa8dbf29b6fd1c824a1767173452611
https://github.com/llorsat/wonkajs/blob/c45d7feaefa8dbf29b6fd1c824a1767173452611/dist/templates/libraries/helpers.js#L53-L59
train
llorsat/wonkajs
dist/templates/libraries/helpers.js
setLanguage
function setLanguage(language) { window[App.pkg.settings.storage_engine || 'localStorage'][App.pkg._id + '-language'] = language; var xhr = null; var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; if(window.ActiveXObject) { for(var i = 0; i < activexmodes.length; i++) { try { xhr = new ActiveXObject(activexmodes[i]); } catch(e) {} } } else { xhr = new XMLHttpRequest(); } xhr.open('GET', 'languages/' + language + '.json', false); xhr.send(null); if(xhr.status == 200 || xhr.status == 201) { var response = JSON.parse(xhr.responseText); Globalize.culture(language); Globalize.addCultureInfo(language, { messages: response, }); } }
javascript
function setLanguage(language) { window[App.pkg.settings.storage_engine || 'localStorage'][App.pkg._id + '-language'] = language; var xhr = null; var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; if(window.ActiveXObject) { for(var i = 0; i < activexmodes.length; i++) { try { xhr = new ActiveXObject(activexmodes[i]); } catch(e) {} } } else { xhr = new XMLHttpRequest(); } xhr.open('GET', 'languages/' + language + '.json', false); xhr.send(null); if(xhr.status == 200 || xhr.status == 201) { var response = JSON.parse(xhr.responseText); Globalize.culture(language); Globalize.addCultureInfo(language, { messages: response, }); } }
[ "function", "setLanguage", "(", "language", ")", "{", "window", "[", "App", ".", "pkg", ".", "settings", ".", "storage_engine", "||", "'localStorage'", "]", "[", "App", ".", "pkg", ".", "_id", "+", "'-language'", "]", "=", "language", ";", "var", "xhr", "=", "null", ";", "var", "activexmodes", "=", "[", "\"Msxml2.XMLHTTP\"", ",", "\"Microsoft.XMLHTTP\"", "]", ";", "if", "(", "window", ".", "ActiveXObject", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "activexmodes", ".", "length", ";", "i", "++", ")", "{", "try", "{", "xhr", "=", "new", "ActiveXObject", "(", "activexmodes", "[", "i", "]", ")", ";", "}", "catch", "(", "e", ")", "{", "}", "}", "}", "else", "{", "xhr", "=", "new", "XMLHttpRequest", "(", ")", ";", "}", "xhr", ".", "open", "(", "'GET'", ",", "'languages/'", "+", "language", "+", "'.json'", ",", "false", ")", ";", "xhr", ".", "send", "(", "null", ")", ";", "if", "(", "xhr", ".", "status", "==", "200", "||", "xhr", ".", "status", "==", "201", ")", "{", "var", "response", "=", "JSON", ".", "parse", "(", "xhr", ".", "responseText", ")", ";", "Globalize", ".", "culture", "(", "language", ")", ";", "Globalize", ".", "addCultureInfo", "(", "language", ",", "{", "messages", ":", "response", ",", "}", ")", ";", "}", "}" ]
Init the I18n with language specified
[ "Init", "the", "I18n", "with", "language", "specified" ]
c45d7feaefa8dbf29b6fd1c824a1767173452611
https://github.com/llorsat/wonkajs/blob/c45d7feaefa8dbf29b6fd1c824a1767173452611/dist/templates/libraries/helpers.js#L62-L86
train
llorsat/wonkajs
dist/templates/libraries/helpers.js
namespace
function namespace() { var args = Array.prototype.slice.call(arguments); var setComponents = function(context, first, rest) { if(!context[first]) { context[first] = { models: {}, collections: {}, views: {}, }; } if(rest.length) { setComponents(context[first], _.first(rest), _.rest(rest)); } }; setComponents(window, _.first(args), _.rest(args)); }
javascript
function namespace() { var args = Array.prototype.slice.call(arguments); var setComponents = function(context, first, rest) { if(!context[first]) { context[first] = { models: {}, collections: {}, views: {}, }; } if(rest.length) { setComponents(context[first], _.first(rest), _.rest(rest)); } }; setComponents(window, _.first(args), _.rest(args)); }
[ "function", "namespace", "(", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ")", ";", "var", "setComponents", "=", "function", "(", "context", ",", "first", ",", "rest", ")", "{", "if", "(", "!", "context", "[", "first", "]", ")", "{", "context", "[", "first", "]", "=", "{", "models", ":", "{", "}", ",", "collections", ":", "{", "}", ",", "views", ":", "{", "}", ",", "}", ";", "}", "if", "(", "rest", ".", "length", ")", "{", "setComponents", "(", "context", "[", "first", "]", ",", "_", ".", "first", "(", "rest", ")", ",", "_", ".", "rest", "(", "rest", ")", ")", ";", "}", "}", ";", "setComponents", "(", "window", ",", "_", ".", "first", "(", "args", ")", ",", "_", ".", "rest", "(", "args", ")", ")", ";", "}" ]
Create a new namespace
[ "Create", "a", "new", "namespace" ]
c45d7feaefa8dbf29b6fd1c824a1767173452611
https://github.com/llorsat/wonkajs/blob/c45d7feaefa8dbf29b6fd1c824a1767173452611/dist/templates/libraries/helpers.js#L93-L108
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
Lexer
function Lexer(text, cfg) { var self = this; self.page = new Page(text); self.cursor = new Cursor(); self.nodeFactory = this; this.cfg = cfg || {}; }
javascript
function Lexer(text, cfg) { var self = this; self.page = new Page(text); self.cursor = new Cursor(); self.nodeFactory = this; this.cfg = cfg || {}; }
[ "function", "Lexer", "(", "text", ",", "cfg", ")", "{", "var", "self", "=", "this", ";", "self", ".", "page", "=", "new", "Page", "(", "text", ")", ";", "self", ".", "cursor", "=", "new", "Cursor", "(", ")", ";", "self", ".", "nodeFactory", "=", "this", ";", "this", ".", "cfg", "=", "cfg", "||", "{", "}", ";", "}" ]
Lexer for html parser @param {String} text html content @param {Object} cfg config object @class KISSY.HtmlParser.Lexer Lexer for html parser @param {String} text html content @param {Object} cfg config object @class KISSY.HtmlParser.Lexer
[ "Lexer", "for", "html", "parser" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1004-L1010
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (quoteSmart) { var self = this, start, ch, ret, cursor = self.cursor, page = self.page; start = cursor.position; ch = page.getChar(cursor); switch (ch) { case -1: ret = null; break; case '<': ch = page.getChar(cursor); if (ch === -1) { ret = self.makeString(start, cursor.position); } else if (ch === '/' || Utils.isLetter(ch)) { page.ungetChar(cursor); ret = self.parseTag(start); } else if ('!' === ch || '?' === ch) { ch = page.getChar(cursor); if (ch === -1) { ret = self.makeString(start, cursor.position); } else { if ('>' === ch) { ret = self.makeComment(start, cursor.position); } else { page.ungetChar(cursor); // remark/tag need this char // remark/tag need this char if ('-' === ch) { ret = self.parseComment(start, quoteSmart); } else { // <!DOCTYPE html> // <?xml:namespace> page.ungetChar(cursor); // tag needs prior one too // tag needs prior one too ret = self.parseTag(start); } } } } else { page.ungetChar(cursor); // see bug #1547354 <<tag> parsed as text // see bug #1547354 <<tag> parsed as text ret = self.parseString(start, quoteSmart); } break; default: page.ungetChar(cursor); // string needs to see leading fore slash // string needs to see leading fore slash ret = self.parseString(start, quoteSmart); break; } return ret; }
javascript
function (quoteSmart) { var self = this, start, ch, ret, cursor = self.cursor, page = self.page; start = cursor.position; ch = page.getChar(cursor); switch (ch) { case -1: ret = null; break; case '<': ch = page.getChar(cursor); if (ch === -1) { ret = self.makeString(start, cursor.position); } else if (ch === '/' || Utils.isLetter(ch)) { page.ungetChar(cursor); ret = self.parseTag(start); } else if ('!' === ch || '?' === ch) { ch = page.getChar(cursor); if (ch === -1) { ret = self.makeString(start, cursor.position); } else { if ('>' === ch) { ret = self.makeComment(start, cursor.position); } else { page.ungetChar(cursor); // remark/tag need this char // remark/tag need this char if ('-' === ch) { ret = self.parseComment(start, quoteSmart); } else { // <!DOCTYPE html> // <?xml:namespace> page.ungetChar(cursor); // tag needs prior one too // tag needs prior one too ret = self.parseTag(start); } } } } else { page.ungetChar(cursor); // see bug #1547354 <<tag> parsed as text // see bug #1547354 <<tag> parsed as text ret = self.parseString(start, quoteSmart); } break; default: page.ungetChar(cursor); // string needs to see leading fore slash // string needs to see leading fore slash ret = self.parseString(start, quoteSmart); break; } return ret; }
[ "function", "(", "quoteSmart", ")", "{", "var", "self", "=", "this", ",", "start", ",", "ch", ",", "ret", ",", "cursor", "=", "self", ".", "cursor", ",", "page", "=", "self", ".", "page", ";", "start", "=", "cursor", ".", "position", ";", "ch", "=", "page", ".", "getChar", "(", "cursor", ")", ";", "switch", "(", "ch", ")", "{", "case", "-", "1", ":", "ret", "=", "null", ";", "break", ";", "case", "'<'", ":", "ch", "=", "page", ".", "getChar", "(", "cursor", ")", ";", "if", "(", "ch", "===", "-", "1", ")", "{", "ret", "=", "self", ".", "makeString", "(", "start", ",", "cursor", ".", "position", ")", ";", "}", "else", "if", "(", "ch", "===", "'/'", "||", "Utils", ".", "isLetter", "(", "ch", ")", ")", "{", "page", ".", "ungetChar", "(", "cursor", ")", ";", "ret", "=", "self", ".", "parseTag", "(", "start", ")", ";", "}", "else", "if", "(", "'!'", "===", "ch", "||", "'?'", "===", "ch", ")", "{", "ch", "=", "page", ".", "getChar", "(", "cursor", ")", ";", "if", "(", "ch", "===", "-", "1", ")", "{", "ret", "=", "self", ".", "makeString", "(", "start", ",", "cursor", ".", "position", ")", ";", "}", "else", "{", "if", "(", "'>'", "===", "ch", ")", "{", "ret", "=", "self", ".", "makeComment", "(", "start", ",", "cursor", ".", "position", ")", ";", "}", "else", "{", "page", ".", "ungetChar", "(", "cursor", ")", ";", "if", "(", "'-'", "===", "ch", ")", "{", "ret", "=", "self", ".", "parseComment", "(", "start", ",", "quoteSmart", ")", ";", "}", "else", "{", "page", ".", "ungetChar", "(", "cursor", ")", ";", "ret", "=", "self", ".", "parseTag", "(", "start", ")", ";", "}", "}", "}", "}", "else", "{", "page", ".", "ungetChar", "(", "cursor", ")", ";", "ret", "=", "self", ".", "parseString", "(", "start", ",", "quoteSmart", ")", ";", "}", "break", ";", "default", ":", "page", ".", "ungetChar", "(", "cursor", ")", ";", "ret", "=", "self", ".", "parseString", "(", "start", ",", "quoteSmart", ")", ";", "break", ";", "}", "return", "ret", ";", "}" ]
get next node parsed from content @param quoteSmart @returns {KISSY.HtmlParse.Node}
[ "get", "next", "node", "parsed", "from", "content" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1024-L1073
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (start, quoteSmart) { var done = 0, ch, page = this.page, cursor = this.cursor, quote = 0; while (!done) { ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if (quoteSmart && 0 === quote && ('"' === ch || '\'' === ch)) { quote = ch; // enter quoted state } else // enter quoted state if (quoteSmart && 0 !== quote && '\\' === ch) { // handle escaped closing quote ch = page.getChar(cursor); // try to consume escape // try to consume escape if (NEGATIVE_1 !== ch && '\\' !== ch && // escaped backslash ch !== quote) // escaped quote character { // ( reflects ['] or ['] whichever opened the quotation) page.ungetChar(cursor); // unconsume char if char not an escape } } else // unconsume char if char not an escape if (quoteSmart && ch === quote) { quote = 0; // exit quoted state } else // exit quoted state if (quoteSmart && 0 === quote && ch === '/') { // handle multiline and double slash comments (with a quote) // in script like: // I can't handle single quotations. ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if ('/' === ch) { do { ch = page.getChar(cursor); } while (NEGATIVE_1 !== ch && '\n' !== ch); } else if ('*' === ch) { do { do { ch = page.getChar(cursor); } while (NEGATIVE_1 !== ch && '*' !== ch); ch = page.getChar(cursor); if (ch === '*') { page.ungetChar(cursor); } } while (NEGATIVE_1 !== ch && '/' !== ch); } else { page.ungetChar(cursor); } } else if (0 === quote && '<' === ch) { ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if ('/' === ch || Utils.isLetter(ch) || '!' === ch || // <?xml:namespace '?' === ch) { done = 1; page.ungetChar(cursor); page.ungetChar(cursor); } else { // it's not a tag, so keep going, but check for quotes page.ungetChar(cursor); } } } return this.makeString(start, cursor.position); }
javascript
function (start, quoteSmart) { var done = 0, ch, page = this.page, cursor = this.cursor, quote = 0; while (!done) { ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if (quoteSmart && 0 === quote && ('"' === ch || '\'' === ch)) { quote = ch; // enter quoted state } else // enter quoted state if (quoteSmart && 0 !== quote && '\\' === ch) { // handle escaped closing quote ch = page.getChar(cursor); // try to consume escape // try to consume escape if (NEGATIVE_1 !== ch && '\\' !== ch && // escaped backslash ch !== quote) // escaped quote character { // ( reflects ['] or ['] whichever opened the quotation) page.ungetChar(cursor); // unconsume char if char not an escape } } else // unconsume char if char not an escape if (quoteSmart && ch === quote) { quote = 0; // exit quoted state } else // exit quoted state if (quoteSmart && 0 === quote && ch === '/') { // handle multiline and double slash comments (with a quote) // in script like: // I can't handle single quotations. ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if ('/' === ch) { do { ch = page.getChar(cursor); } while (NEGATIVE_1 !== ch && '\n' !== ch); } else if ('*' === ch) { do { do { ch = page.getChar(cursor); } while (NEGATIVE_1 !== ch && '*' !== ch); ch = page.getChar(cursor); if (ch === '*') { page.ungetChar(cursor); } } while (NEGATIVE_1 !== ch && '/' !== ch); } else { page.ungetChar(cursor); } } else if (0 === quote && '<' === ch) { ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if ('/' === ch || Utils.isLetter(ch) || '!' === ch || // <?xml:namespace '?' === ch) { done = 1; page.ungetChar(cursor); page.ungetChar(cursor); } else { // it's not a tag, so keep going, but check for quotes page.ungetChar(cursor); } } } return this.makeString(start, cursor.position); }
[ "function", "(", "start", ",", "quoteSmart", ")", "{", "var", "done", "=", "0", ",", "ch", ",", "page", "=", "this", ".", "page", ",", "cursor", "=", "this", ".", "cursor", ",", "quote", "=", "0", ";", "while", "(", "!", "done", ")", "{", "ch", "=", "page", ".", "getChar", "(", "cursor", ")", ";", "if", "(", "NEGATIVE_1", "===", "ch", ")", "{", "done", "=", "1", ";", "}", "else", "if", "(", "quoteSmart", "&&", "0", "===", "quote", "&&", "(", "'\"'", "===", "ch", "||", "'\\''", "===", "\\'", ")", ")", "ch", "else", "{", "quote", "=", "ch", ";", "}", "}", "if", "(", "quoteSmart", "&&", "0", "!==", "quote", "&&", "'\\\\'", "===", "\\\\", ")", "ch", "else", "{", "ch", "=", "page", ".", "getChar", "(", "cursor", ")", ";", "if", "(", "NEGATIVE_1", "!==", "ch", "&&", "'\\\\'", "!==", "\\\\", "&&", "ch", ")", "ch", "!==", "quote", "}", "}" ]
parse a string node @private @param start @param quoteSmart strings ignore quoted contents
[ "parse", "a", "string", "node" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1385-L1449
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (quoteSmart, tagName) { var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page; start = mCursor.position; state = 0; done = false; quote = ''; comment = false; while (!done) { ch = mPage.getChar(mCursor); switch (state) { case 0: // prior to ETAGO switch (ch) { case -1: done = true; break; case '\'': if (quoteSmart && !comment) { if ('' === quote) { quote = '\''; // enter quoted state } else // enter quoted state if ('\'' === quote) { quote = ''; // exit quoted state } } // exit quoted state break; case '"': if (quoteSmart && !comment) { if ('' === quote) { quote = '"'; // enter quoted state } else // enter quoted state if ('"' === quote) { quote = ''; // exit quoted state } } // exit quoted state break; case '\\': if (quoteSmart) { if ('' !== quote) { ch = mPage.getChar(mCursor); // try to consume escaped character // try to consume escaped character if (NEGATIVE_1 === ch) { done = true; } else if (ch !== '\\' && ch !== quote) { // unconsume char if character was not an escapable char. mPage.ungetChar(mCursor); } } } break; case '/': if (quoteSmart) { if ('' === quote) { // handle multiline and double slash comments (with a quote) ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('/' === ch) { comment = true; } else if ('*' === ch) { do { do { ch = mPage.getChar(mCursor); } while (NEGATIVE_1 !== ch && '*' !== ch); ch = mPage.getChar(mCursor); if (ch === '*') { mPage.ungetChar(mCursor); } } while (NEGATIVE_1 !== ch && '/' !== ch); } else { mPage.ungetChar(mCursor); } } } break; case '\n': comment = false; break; case '<': if (quoteSmart) { if ('' === quote) { state = 1; } } else { state = 1; } break; default: break; } break; case 1: // < switch (ch) { case -1: done = true; break; case '/': // tagName = 'textarea' // <textarea><div></div></textarea> /* 8.1.2.6 Restrictions on the contents of raw text and RCDATA elements The text in raw text and RCDATA elements must not contain any occurrences of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of the element followed by one of U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/). */ if (!tagName || mPage.getText(mCursor.position, mCursor.position + tagName.length) === tagName && !mPage.getText(mCursor.position + tagName.length, mCursor.position + tagName.length + 1).match(/\w/)) { state = 2; } else { state = 0; } break; case '!': ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { state = 3; } else { state = 0; } } else { state = 0; } break; default: state = 0; break; } break; case 2: // </ comment = false; if (NEGATIVE_1 === ch) { done = true; } else if (Utils.isLetter(ch)) { // 严格 parser 遇到 </x lexer 立即结束 // 浏览器实现更复杂点,可能 lexer 和 parser 混合了 done = true; // back up to the start of ETAGO // back up to the start of ETAGO mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); } else { state = 0; } break; case 3: // <! comment = false; if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('>' === ch) { // <!----> <!--> state = 0; } else { // retreat twice , still begin to check --> mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); } } else { // retreat once , still begin to check mPage.ungetChar(mCursor); } } // eat comment // eat comment break; default: throw new Error('unexpected ' + state); } } end = mCursor.position; return this.makeCData(start, end); }
javascript
function (quoteSmart, tagName) { var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page; start = mCursor.position; state = 0; done = false; quote = ''; comment = false; while (!done) { ch = mPage.getChar(mCursor); switch (state) { case 0: // prior to ETAGO switch (ch) { case -1: done = true; break; case '\'': if (quoteSmart && !comment) { if ('' === quote) { quote = '\''; // enter quoted state } else // enter quoted state if ('\'' === quote) { quote = ''; // exit quoted state } } // exit quoted state break; case '"': if (quoteSmart && !comment) { if ('' === quote) { quote = '"'; // enter quoted state } else // enter quoted state if ('"' === quote) { quote = ''; // exit quoted state } } // exit quoted state break; case '\\': if (quoteSmart) { if ('' !== quote) { ch = mPage.getChar(mCursor); // try to consume escaped character // try to consume escaped character if (NEGATIVE_1 === ch) { done = true; } else if (ch !== '\\' && ch !== quote) { // unconsume char if character was not an escapable char. mPage.ungetChar(mCursor); } } } break; case '/': if (quoteSmart) { if ('' === quote) { // handle multiline and double slash comments (with a quote) ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('/' === ch) { comment = true; } else if ('*' === ch) { do { do { ch = mPage.getChar(mCursor); } while (NEGATIVE_1 !== ch && '*' !== ch); ch = mPage.getChar(mCursor); if (ch === '*') { mPage.ungetChar(mCursor); } } while (NEGATIVE_1 !== ch && '/' !== ch); } else { mPage.ungetChar(mCursor); } } } break; case '\n': comment = false; break; case '<': if (quoteSmart) { if ('' === quote) { state = 1; } } else { state = 1; } break; default: break; } break; case 1: // < switch (ch) { case -1: done = true; break; case '/': // tagName = 'textarea' // <textarea><div></div></textarea> /* 8.1.2.6 Restrictions on the contents of raw text and RCDATA elements The text in raw text and RCDATA elements must not contain any occurrences of the string '</' (U+003C LESS-THAN SIGN, U+002F SOLIDUS) followed by characters that case-insensitively match the tag name of the element followed by one of U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, U+003E GREATER-THAN SIGN (>), or U+002F SOLIDUS (/). */ if (!tagName || mPage.getText(mCursor.position, mCursor.position + tagName.length) === tagName && !mPage.getText(mCursor.position + tagName.length, mCursor.position + tagName.length + 1).match(/\w/)) { state = 2; } else { state = 0; } break; case '!': ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { state = 3; } else { state = 0; } } else { state = 0; } break; default: state = 0; break; } break; case 2: // </ comment = false; if (NEGATIVE_1 === ch) { done = true; } else if (Utils.isLetter(ch)) { // 严格 parser 遇到 </x lexer 立即结束 // 浏览器实现更复杂点,可能 lexer 和 parser 混合了 done = true; // back up to the start of ETAGO // back up to the start of ETAGO mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); } else { state = 0; } break; case 3: // <! comment = false; if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('-' === ch) { ch = mPage.getChar(mCursor); if (NEGATIVE_1 === ch) { done = true; } else if ('>' === ch) { // <!----> <!--> state = 0; } else { // retreat twice , still begin to check --> mPage.ungetChar(mCursor); mPage.ungetChar(mCursor); } } else { // retreat once , still begin to check mPage.ungetChar(mCursor); } } // eat comment // eat comment break; default: throw new Error('unexpected ' + state); } } end = mCursor.position; return this.makeCData(start, end); }
[ "function", "(", "quoteSmart", ",", "tagName", ")", "{", "var", "start", ",", "state", ",", "done", ",", "quote", ",", "ch", ",", "end", ",", "comment", ",", "mCursor", "=", "this", ".", "cursor", ",", "mPage", "=", "this", ".", "page", ";", "start", "=", "mCursor", ".", "position", ";", "state", "=", "0", ";", "done", "=", "false", ";", "quote", "=", "''", ";", "comment", "=", "false", ";", "while", "(", "!", "done", ")", "{", "ch", "=", "mPage", ".", "getChar", "(", "mCursor", ")", ";", "switch", "(", "state", ")", "{", "case", "0", ":", "switch", "(", "ch", ")", "{", "case", "-", "1", ":", "done", "=", "true", ";", "break", ";", "case", "'\\''", ":", "\\'", "if", "(", "quoteSmart", "&&", "!", "comment", ")", "{", "if", "(", "''", "===", "quote", ")", "{", "quote", "=", "'\\''", ";", "}", "else", "\\'", "}", "if", "(", "'\\''", "===", "\\'", ")", "quote", "{", "quote", "=", "''", ";", "}", "break", ";", "case", "'\"'", ":", "if", "(", "quoteSmart", "&&", "!", "comment", ")", "{", "if", "(", "''", "===", "quote", ")", "{", "quote", "=", "'\"'", ";", "}", "else", "if", "(", "'\"'", "===", "quote", ")", "{", "quote", "=", "''", ";", "}", "}", "break", ";", "case", "'\\\\'", ":", "\\\\", "if", "(", "quoteSmart", ")", "{", "if", "(", "''", "!==", "quote", ")", "{", "ch", "=", "mPage", ".", "getChar", "(", "mCursor", ")", ";", "if", "(", "NEGATIVE_1", "===", "ch", ")", "{", "done", "=", "true", ";", "}", "else", "if", "(", "ch", "!==", "'\\\\'", "&&", "\\\\", ")", "ch", "!==", "quote", "}", "}", "{", "mPage", ".", "ungetChar", "(", "mCursor", ")", ";", "}", "}", "break", ";", "case", "'/'", ":", "if", "(", "quoteSmart", ")", "{", "if", "(", "''", "===", "quote", ")", "{", "ch", "=", "mPage", ".", "getChar", "(", "mCursor", ")", ";", "if", "(", "NEGATIVE_1", "===", "ch", ")", "{", "done", "=", "true", ";", "}", "else", "if", "(", "'/'", "===", "ch", ")", "{", "comment", "=", "true", ";", "}", "else", "if", "(", "'*'", "===", "ch", ")", "{", "do", "{", "do", "{", "ch", "=", "mPage", ".", "getChar", "(", "mCursor", ")", ";", "}", "while", "(", "NEGATIVE_1", "!==", "ch", "&&", "'*'", "!==", "ch", ")", ";", "ch", "=", "mPage", ".", "getChar", "(", "mCursor", ")", ";", "if", "(", "ch", "===", "'*'", ")", "{", "mPage", ".", "ungetChar", "(", "mCursor", ")", ";", "}", "}", "while", "(", "NEGATIVE_1", "!==", "ch", "&&", "'/'", "!==", "ch", ")", ";", "}", "else", "{", "mPage", ".", "ungetChar", "(", "mCursor", ")", ";", "}", "}", "}", "break", ";", "case", "'\\n'", ":", "\\n", "comment", "=", "false", ";", "break", ";", "case", "'<'", ":", "if", "(", "quoteSmart", ")", "{", "if", "(", "''", "===", "quote", ")", "{", "state", "=", "1", ";", "}", "}", "else", "{", "state", "=", "1", ";", "}", "break", ";", "}", "}", "default", ":", "break", ";", "break", ";", "}" ]
parse cdata such as code in script @private @param quoteSmart if set true end tag in quote (but not in comment mode) does not end current tag ( <script>x='<a>taobao</a>'</script> ) @param tagName
[ "parse", "cdata", "such", "as", "code", "in", "script" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1457-L1648
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (attributes, bookmarks) { var page = this.page; attributes.push(new Attribute(page.getText(bookmarks[1], bookmarks[2]), '=', page.getText(bookmarks[3], bookmarks[4]))); }
javascript
function (attributes, bookmarks) { var page = this.page; attributes.push(new Attribute(page.getText(bookmarks[1], bookmarks[2]), '=', page.getText(bookmarks[3], bookmarks[4]))); }
[ "function", "(", "attributes", ",", "bookmarks", ")", "{", "var", "page", "=", "this", ".", "page", ";", "attributes", ".", "push", "(", "new", "Attribute", "(", "page", ".", "getText", "(", "bookmarks", "[", "1", "]", ",", "bookmarks", "[", "2", "]", ")", ",", "'='", ",", "page", ".", "getText", "(", "bookmarks", "[", "3", "]", ",", "bookmarks", "[", "4", "]", ")", ")", ")", ";", "}" ]
Generate an unquoted attribute @private @param attributes The list so far. @param bookmarks The array of positions.
[ "Generate", "an", "unquoted", "attribute" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1685-L1688
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (cursor) { var cs = this.lineCursors; for (var i = 0; i < cs.length; i++) { if (cs[i].position > cursor.position) { return i - 1; } } return i; }
javascript
function (cursor) { var cs = this.lineCursors; for (var i = 0; i < cs.length; i++) { if (cs[i].position > cursor.position) { return i - 1; } } return i; }
[ "function", "(", "cursor", ")", "{", "var", "cs", "=", "this", ".", "lineCursors", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "cs", ".", "length", ";", "i", "++", ")", "{", "if", "(", "cs", "[", "i", "]", ".", "position", ">", "cursor", ".", "position", ")", "{", "return", "i", "-", "1", ";", "}", "}", "return", "i", ";", "}" ]
line number of this cursor , index from zero @param cursor
[ "line", "number", "of", "this", "cursor", "index", "from", "zero" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1819-L1827
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
Node
function Node(page, startPosition, endPosition) { this.parentNode = null; this.page = page; this.startPosition = startPosition; this.endPosition = endPosition; this.nodeName = null; this.previousSibling = null; this.nextSibling = null; }
javascript
function Node(page, startPosition, endPosition) { this.parentNode = null; this.page = page; this.startPosition = startPosition; this.endPosition = endPosition; this.nodeName = null; this.previousSibling = null; this.nextSibling = null; }
[ "function", "Node", "(", "page", ",", "startPosition", ",", "endPosition", ")", "{", "this", ".", "parentNode", "=", "null", ";", "this", ".", "page", "=", "page", ";", "this", ".", "startPosition", "=", "startPosition", ";", "this", ".", "endPosition", "=", "endPosition", ";", "this", ".", "nodeName", "=", "null", ";", "this", ".", "previousSibling", "=", "null", ";", "this", ".", "nextSibling", "=", "null", ";", "}" ]
node structure from htmlparser @param page @param startPosition @param endPosition @class KISSY.HtmlParse.Node node structure from htmlparser @param page @param startPosition @param endPosition @class KISSY.HtmlParse.Node
[ "node", "structure", "from", "htmlparser" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L1939-L1947
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
Tag
function Tag(page, startPosition, endPosition, attributes) { var self = this; self.childNodes = []; self.firstChild = null; self.lastChild = null; self.attributes = attributes || []; self.nodeType = 1; if (typeof page === 'string') { createTag.apply(null, [self].concat(util.makeArray(arguments))); } else { Tag.superclass.constructor.apply(self, arguments); attributes = self.attributes; // first attribute is actually nodeName // first attribute is actually nodeName if (attributes[0]) { self.nodeName = attributes[0].name.toLowerCase(); // end tag (</div>) is a tag too in lexer , but not exist in parsed dom tree // end tag (</div>) is a tag too in lexer , but not exist in parsed dom tree self.tagName = self.nodeName.replace(/\//, ''); self._updateSelfClosed(); attributes.splice(0, 1); } var lastAttr = attributes[attributes.length - 1], lastSlash = !!(lastAttr && /\/$/.test(lastAttr.name)); if (lastSlash) { attributes.length = attributes.length - 1; } // self-closing flag // self-closing flag self.isSelfClosed = self.isSelfClosed || lastSlash; // whether has been closed by its end tag // !TODO how to set closed position correctly // whether has been closed by its end tag // !TODO how to set closed position correctly self.closed = self.isSelfClosed; } self.closedStartPosition = -1; self.closedEndPosition = -1; }
javascript
function Tag(page, startPosition, endPosition, attributes) { var self = this; self.childNodes = []; self.firstChild = null; self.lastChild = null; self.attributes = attributes || []; self.nodeType = 1; if (typeof page === 'string') { createTag.apply(null, [self].concat(util.makeArray(arguments))); } else { Tag.superclass.constructor.apply(self, arguments); attributes = self.attributes; // first attribute is actually nodeName // first attribute is actually nodeName if (attributes[0]) { self.nodeName = attributes[0].name.toLowerCase(); // end tag (</div>) is a tag too in lexer , but not exist in parsed dom tree // end tag (</div>) is a tag too in lexer , but not exist in parsed dom tree self.tagName = self.nodeName.replace(/\//, ''); self._updateSelfClosed(); attributes.splice(0, 1); } var lastAttr = attributes[attributes.length - 1], lastSlash = !!(lastAttr && /\/$/.test(lastAttr.name)); if (lastSlash) { attributes.length = attributes.length - 1; } // self-closing flag // self-closing flag self.isSelfClosed = self.isSelfClosed || lastSlash; // whether has been closed by its end tag // !TODO how to set closed position correctly // whether has been closed by its end tag // !TODO how to set closed position correctly self.closed = self.isSelfClosed; } self.closedStartPosition = -1; self.closedEndPosition = -1; }
[ "function", "Tag", "(", "page", ",", "startPosition", ",", "endPosition", ",", "attributes", ")", "{", "var", "self", "=", "this", ";", "self", ".", "childNodes", "=", "[", "]", ";", "self", ".", "firstChild", "=", "null", ";", "self", ".", "lastChild", "=", "null", ";", "self", ".", "attributes", "=", "attributes", "||", "[", "]", ";", "self", ".", "nodeType", "=", "1", ";", "if", "(", "typeof", "page", "===", "'string'", ")", "{", "createTag", ".", "apply", "(", "null", ",", "[", "self", "]", ".", "concat", "(", "util", ".", "makeArray", "(", "arguments", ")", ")", ")", ";", "}", "else", "{", "Tag", ".", "superclass", ".", "constructor", ".", "apply", "(", "self", ",", "arguments", ")", ";", "attributes", "=", "self", ".", "attributes", ";", "if", "(", "attributes", "[", "0", "]", ")", "{", "self", ".", "nodeName", "=", "attributes", "[", "0", "]", ".", "name", ".", "toLowerCase", "(", ")", ";", "self", ".", "tagName", "=", "self", ".", "nodeName", ".", "replace", "(", "/", "\\/", "/", ",", "''", ")", ";", "self", ".", "_updateSelfClosed", "(", ")", ";", "attributes", ".", "splice", "(", "0", ",", "1", ")", ";", "}", "var", "lastAttr", "=", "attributes", "[", "attributes", ".", "length", "-", "1", "]", ",", "lastSlash", "=", "!", "!", "(", "lastAttr", "&&", "/", "\\/$", "/", ".", "test", "(", "lastAttr", ".", "name", ")", ")", ";", "if", "(", "lastSlash", ")", "{", "attributes", ".", "length", "=", "attributes", ".", "length", "-", "1", ";", "}", "self", ".", "isSelfClosed", "=", "self", ".", "isSelfClosed", "||", "lastSlash", ";", "self", ".", "closed", "=", "self", ".", "isSelfClosed", ";", "}", "self", ".", "closedStartPosition", "=", "-", "1", ";", "self", ".", "closedEndPosition", "=", "-", "1", ";", "}" ]
Html Tag Class @param page @param startPosition @param endPosition @param attributes @class KISSY.HtmlParser.Tag Html Tag Class @param page @param startPosition @param endPosition @param attributes @class KISSY.HtmlParser.Tag
[ "Html", "Tag", "Class" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L2125-L2158
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function () { var self = this; if (!self.isChildrenFiltered) { var writer = new (module.require('html-parser/writer/basic'))(); self._writeChildrenHTML(writer); var parser = new (module.require('html-parser/parser'))(writer.getHtml()), children = parser.parse().childNodes; self.empty(); util.each(children, function (c) { self.appendChild(c); }); self.isChildrenFiltered = 1; } }
javascript
function () { var self = this; if (!self.isChildrenFiltered) { var writer = new (module.require('html-parser/writer/basic'))(); self._writeChildrenHTML(writer); var parser = new (module.require('html-parser/parser'))(writer.getHtml()), children = parser.parse().childNodes; self.empty(); util.each(children, function (c) { self.appendChild(c); }); self.isChildrenFiltered = 1; } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "isChildrenFiltered", ")", "{", "var", "writer", "=", "new", "(", "module", ".", "require", "(", "'html-parser/writer/basic'", ")", ")", "(", ")", ";", "self", ".", "_writeChildrenHTML", "(", "writer", ")", ";", "var", "parser", "=", "new", "(", "module", ".", "require", "(", "'html-parser/parser'", ")", ")", "(", "writer", ".", "getHtml", "(", ")", ")", ",", "children", "=", "parser", ".", "parse", "(", ")", ".", "childNodes", ";", "self", ".", "empty", "(", ")", ";", "util", ".", "each", "(", "children", ",", "function", "(", "c", ")", "{", "self", ".", "appendChild", "(", "c", ")", ";", "}", ")", ";", "self", ".", "isChildrenFiltered", "=", "1", ";", "}", "}" ]
give root node a chance to filter children first
[ "give", "root", "node", "a", "chance", "to", "filter", "children", "first" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L2296-L2308
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (writer, filter) { var self = this, tmp, attrName, tagName = self.tagName; // special treat for doctype // special treat for doctype if (tagName === '!doctype') { writer.append(this.toHtml() + '\n'); return; } self.__filter = filter; self.isChildrenFiltered = 0; // process its open tag // process its open tag if (filter) { // element filtered by its name directly if (!(tagName = filter.onTagName(tagName))) { return; } self.tagName = tagName; tmp = filter.onTag(self); if (tmp === false) { return; } // replaced // replaced if (tmp) { self = tmp; } // replaced by other type of node // replaced by other type of node if (self.nodeType !== 1) { self.writeHtml(writer, filter); return; } // preserve children but delete itself // preserve children but delete itself if (!self.tagName) { self._writeChildrenHTML(writer); return; } } writer.openTag(self); // process its attributes // process its attributes var attributes = self.attributes; for (var i = 0; i < attributes.length; i++) { var attr = attributes[i]; attrName = attr.name; if (filter) { // filtered directly by name if (!(attrName = filter.onAttributeName(attrName, self))) { continue; } attr.name = attrName; // filtered by value and node // filtered by value and node if (filter.onAttribute(attr, self) === false) { continue; } } writer.attribute(attr, self); } // close its open tag // close its open tag writer.openTagClose(self); if (!self.isSelfClosed) { self._writeChildrenHTML(writer); // process its close tag // process its close tag writer.closeTag(self); } }
javascript
function (writer, filter) { var self = this, tmp, attrName, tagName = self.tagName; // special treat for doctype // special treat for doctype if (tagName === '!doctype') { writer.append(this.toHtml() + '\n'); return; } self.__filter = filter; self.isChildrenFiltered = 0; // process its open tag // process its open tag if (filter) { // element filtered by its name directly if (!(tagName = filter.onTagName(tagName))) { return; } self.tagName = tagName; tmp = filter.onTag(self); if (tmp === false) { return; } // replaced // replaced if (tmp) { self = tmp; } // replaced by other type of node // replaced by other type of node if (self.nodeType !== 1) { self.writeHtml(writer, filter); return; } // preserve children but delete itself // preserve children but delete itself if (!self.tagName) { self._writeChildrenHTML(writer); return; } } writer.openTag(self); // process its attributes // process its attributes var attributes = self.attributes; for (var i = 0; i < attributes.length; i++) { var attr = attributes[i]; attrName = attr.name; if (filter) { // filtered directly by name if (!(attrName = filter.onAttributeName(attrName, self))) { continue; } attr.name = attrName; // filtered by value and node // filtered by value and node if (filter.onAttribute(attr, self) === false) { continue; } } writer.attribute(attr, self); } // close its open tag // close its open tag writer.openTagClose(self); if (!self.isSelfClosed) { self._writeChildrenHTML(writer); // process its close tag // process its close tag writer.closeTag(self); } }
[ "function", "(", "writer", ",", "filter", ")", "{", "var", "self", "=", "this", ",", "tmp", ",", "attrName", ",", "tagName", "=", "self", ".", "tagName", ";", "if", "(", "tagName", "===", "'!doctype'", ")", "{", "writer", ".", "append", "(", "this", ".", "toHtml", "(", ")", "+", "'\\n'", ")", ";", "\\n", "}", "return", ";", "self", ".", "__filter", "=", "filter", ";", "self", ".", "isChildrenFiltered", "=", "0", ";", "if", "(", "filter", ")", "{", "if", "(", "!", "(", "tagName", "=", "filter", ".", "onTagName", "(", "tagName", ")", ")", ")", "{", "return", ";", "}", "self", ".", "tagName", "=", "tagName", ";", "tmp", "=", "filter", ".", "onTag", "(", "self", ")", ";", "if", "(", "tmp", "===", "false", ")", "{", "return", ";", "}", "if", "(", "tmp", ")", "{", "self", "=", "tmp", ";", "}", "if", "(", "self", ".", "nodeType", "!==", "1", ")", "{", "self", ".", "writeHtml", "(", "writer", ",", "filter", ")", ";", "return", ";", "}", "if", "(", "!", "self", ".", "tagName", ")", "{", "self", ".", "_writeChildrenHTML", "(", "writer", ")", ";", "return", ";", "}", "}", "writer", ".", "openTag", "(", "self", ")", ";", "var", "attributes", "=", "self", ".", "attributes", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "attributes", ".", "length", ";", "i", "++", ")", "{", "var", "attr", "=", "attributes", "[", "i", "]", ";", "attrName", "=", "attr", ".", "name", ";", "if", "(", "filter", ")", "{", "if", "(", "!", "(", "attrName", "=", "filter", ".", "onAttributeName", "(", "attrName", ",", "self", ")", ")", ")", "{", "continue", ";", "}", "attr", ".", "name", "=", "attrName", ";", "if", "(", "filter", ".", "onAttribute", "(", "attr", ",", "self", ")", "===", "false", ")", "{", "continue", ";", "}", "}", "writer", ".", "attribute", "(", "attr", ",", "self", ")", ";", "}", "writer", ".", "openTagClose", "(", "self", ")", ";", "}" ]
serialize tag to html string in writer @param writer @param filter
[ "serialize", "tag", "to", "html", "string", "in", "writer" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L2314-L2375
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
Parser
function Parser(html, opts) { // fake root node html = util.trim(html); this.originalHTML = html; // only allow condition // 1. start with <!doctype // 2. start with <!html // 3. start with <!body // 4. not start with <head // 5. not start with <meta // only allow condition // 1. start with <!doctype // 2. start with <!html // 3. start with <!body // 4. not start with <head // 5. not start with <meta if (/^(<!doctype|<html|<body)/i.test(html)) { html = '<document>' + html + '</document>'; } else { html = '<body>' + html + '</body>'; } this.lexer = new Lexer(html); this.opts = opts || {}; }
javascript
function Parser(html, opts) { // fake root node html = util.trim(html); this.originalHTML = html; // only allow condition // 1. start with <!doctype // 2. start with <!html // 3. start with <!body // 4. not start with <head // 5. not start with <meta // only allow condition // 1. start with <!doctype // 2. start with <!html // 3. start with <!body // 4. not start with <head // 5. not start with <meta if (/^(<!doctype|<html|<body)/i.test(html)) { html = '<document>' + html + '</document>'; } else { html = '<body>' + html + '</body>'; } this.lexer = new Lexer(html); this.opts = opts || {}; }
[ "function", "Parser", "(", "html", ",", "opts", ")", "{", "html", "=", "util", ".", "trim", "(", "html", ")", ";", "this", ".", "originalHTML", "=", "html", ";", "if", "(", "/", "^(<!doctype|<html|<body)", "/", "i", ".", "test", "(", "html", ")", ")", "{", "html", "=", "'<document>'", "+", "html", "+", "'</document>'", ";", "}", "else", "{", "html", "=", "'<body>'", "+", "html", "+", "'</body>'", ";", "}", "this", ".", "lexer", "=", "new", "Lexer", "(", "html", ")", ";", "this", ".", "opts", "=", "opts", "||", "{", "}", ";", "}" ]
Html Parse Class @param html @param opts @class KISSY.HtmlParser.Parser Html Parse Class @param html @param opts @class KISSY.HtmlParser.Parser
[ "Html", "Parse", "Class" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L2478-L2500
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
MinifyWriter
function MinifyWriter() { var self = this; MinifyWriter.superclass.constructor.apply(self, arguments); self.inPre = 0; }
javascript
function MinifyWriter() { var self = this; MinifyWriter.superclass.constructor.apply(self, arguments); self.inPre = 0; }
[ "function", "MinifyWriter", "(", ")", "{", "var", "self", "=", "this", ";", "MinifyWriter", ".", "superclass", ".", "constructor", ".", "apply", "(", "self", ",", "arguments", ")", ";", "self", ".", "inPre", "=", "0", ";", "}" ]
MinifyWriter for html content @class KISSY.HtmlParser.MinifyWriter @extends KISSY.HtmlParser.BasicWriter MinifyWriter for html content @class KISSY.HtmlParser.MinifyWriter @extends KISSY.HtmlParser.BasicWriter
[ "MinifyWriter", "for", "html", "content" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L3452-L3456
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (text) { if (isConditionalComment(text)) { text = cleanConditionalComment(text); MinifyWriter.superclass.comment.call(this, text); } }
javascript
function (text) { if (isConditionalComment(text)) { text = cleanConditionalComment(text); MinifyWriter.superclass.comment.call(this, text); } }
[ "function", "(", "text", ")", "{", "if", "(", "isConditionalComment", "(", "text", ")", ")", "{", "text", "=", "cleanConditionalComment", "(", "text", ")", ";", "MinifyWriter", ".", "superclass", ".", "comment", ".", "call", "(", "this", ",", "text", ")", ";", "}", "}" ]
remove non-conditional comment
[ "remove", "non", "-", "conditional", "comment" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L3461-L3466
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js
function (el) { var self = this; if (el.tagName === 'pre') { self.inPre = 1; } MinifyWriter.superclass.openTag.apply(self, arguments); }
javascript
function (el) { var self = this; if (el.tagName === 'pre') { self.inPre = 1; } MinifyWriter.superclass.openTag.apply(self, arguments); }
[ "function", "(", "el", ")", "{", "var", "self", "=", "this", ";", "if", "(", "el", ".", "tagName", "===", "'pre'", ")", "{", "self", ".", "inPre", "=", "1", ";", "}", "MinifyWriter", ".", "superclass", ".", "openTag", ".", "apply", "(", "self", ",", "arguments", ")", ";", "}" ]
record pre track
[ "record", "pre", "track" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/html-parser-debug.js#L3470-L3476
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.10/xtemplate.js
XTemplate
function XTemplate(tpl, config) { var self = this; config = self.config = config || {}; config.loader = config.loader || loader; if (typeof tpl === 'string') { tpl = Compiler.compile(tpl, config && config.name); } XTemplate.superclass.constructor.call(self, tpl, config); }
javascript
function XTemplate(tpl, config) { var self = this; config = self.config = config || {}; config.loader = config.loader || loader; if (typeof tpl === 'string') { tpl = Compiler.compile(tpl, config && config.name); } XTemplate.superclass.constructor.call(self, tpl, config); }
[ "function", "XTemplate", "(", "tpl", ",", "config", ")", "{", "var", "self", "=", "this", ";", "config", "=", "self", ".", "config", "=", "config", "||", "{", "}", ";", "config", ".", "loader", "=", "config", ".", "loader", "||", "loader", ";", "if", "(", "typeof", "tpl", "===", "'string'", ")", "{", "tpl", "=", "Compiler", ".", "compile", "(", "tpl", ",", "config", "&&", "config", ".", "name", ")", ";", "}", "XTemplate", ".", "superclass", ".", "constructor", ".", "call", "(", "self", ",", "tpl", ",", "config", ")", ";", "}" ]
xtemplate engine for KISSY. @example KISSY.use('xtemplate',function(S, XTemplate){ document.writeln(new XTemplate('{{title}}').render({title:2})); }); @class KISSY.XTemplate @extends KISSY.XTemplate.Runtime xtemplate engine for KISSY. @example KISSY.use('xtemplate',function(S, XTemplate){ document.writeln(new XTemplate('{{title}}').render({title:2})); }); @class KISSY.XTemplate @extends KISSY.XTemplate.Runtime
[ "xtemplate", "engine", "for", "KISSY", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.10/xtemplate.js#L77-L85
train
Automattic/wpcom-unpublished
lib/site.wordads.settings.js
SiteWordAdsSettings
function SiteWordAdsSettings( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsSettings ) ) { return new SiteWordAdsSettings( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
function SiteWordAdsSettings( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsSettings ) ) { return new SiteWordAdsSettings( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
[ "function", "SiteWordAdsSettings", "(", "sid", ",", "wpcom", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SiteWordAdsSettings", ")", ")", "{", "return", "new", "SiteWordAdsSettings", "(", "sid", ",", "wpcom", ")", ";", "}", "this", ".", "_sid", "=", "sid", ";", "this", ".", "wpcom", "=", "wpcom", ";", "}" ]
`SiteWordAdsSettings` constructor. *Example:* // Require `wpcom-unpublished` library var wpcomUnpublished = require( 'wpcom-unpublished' ); // Create a `wpcomUnpublished` instance var wpcom = wpcomUnpublished(); // Create a `SiteWordAdsSettings` instance var wordAds = wpcom .site( 'my-blog.wordpress.com' ) .wordAds() .settings(); @constructor @param {wpcomUnpublished} wpcom @public
[ "SiteWordAdsSettings", "constructor", "." ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/lib/site.wordads.settings.js#L23-L30
train
craterdog-bali/js-bali-component-framework
src/utilities/Duplicator.js
Duplicator
function Duplicator() { this.duplicateComponent = function(component) { const visitor = new DuplicatingVisitor(); component.acceptVisitor(visitor); return visitor.result; }; return this; }
javascript
function Duplicator() { this.duplicateComponent = function(component) { const visitor = new DuplicatingVisitor(); component.acceptVisitor(visitor); return visitor.result; }; return this; }
[ "function", "Duplicator", "(", ")", "{", "this", ".", "duplicateComponent", "=", "function", "(", "component", ")", "{", "const", "visitor", "=", "new", "DuplicatingVisitor", "(", ")", ";", "component", ".", "acceptVisitor", "(", "visitor", ")", ";", "return", "visitor", ".", "result", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTORS This class implements a duplicator that uses a visitor to create a deep copy of a component. Since elements are immutable, they are not copied, only referenced. @constructor @returns {Duplicator} The new component duplicator.
[ "PUBLIC", "CONSTRUCTORS", "This", "class", "implements", "a", "duplicator", "that", "uses", "a", "visitor", "to", "create", "a", "deep", "copy", "of", "a", "component", ".", "Since", "elements", "are", "immutable", "they", "are", "not", "copied", "only", "referenced", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/utilities/Duplicator.js#L32-L41
train
craterdog-bali/js-bali-component-framework
src/composites/Source.js
Source
function Source(procedure, parameters) { abstractions.Composite.call(this, utilities.types.SOURCE, parameters); this.getProcedure = function() { return procedure; }; return this; }
javascript
function Source(procedure, parameters) { abstractions.Composite.call(this, utilities.types.SOURCE, parameters); this.getProcedure = function() { return procedure; }; return this; }
[ "function", "Source", "(", "procedure", ",", "parameters", ")", "{", "abstractions", ".", "Composite", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "SOURCE", ",", "parameters", ")", ";", "this", ".", "getProcedure", "=", "function", "(", ")", "{", "return", "procedure", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC FUNCTIONS This constructor creates a new source code component with optional parameters that are used to parameterize its behavior. @param {Tree} procedure The procedure that is contained within the source code. @param {Parameters} parameters Optional parameters used to parameterize the source code. @returns {Source} A new source code component.
[ "PUBLIC", "FUNCTIONS", "This", "constructor", "creates", "a", "new", "source", "code", "component", "with", "optional", "parameters", "that", "are", "used", "to", "parameterize", "its", "behavior", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/composites/Source.js#L30-L34
train
craterdog-bali/js-bali-component-framework
src/elements/Moment.js
Moment
function Moment(value, parameters) { abstractions.Element.call(this, utilities.types.MOMENT, parameters); var format; if (value === undefined || value === null) { format = FORMATS[7]; value = moment.utc(); // the current moment } else { switch (typeof value) { case 'number': format = FORMATS[7]; value = moment.utc(value); // in milliseconds since EPOC break; case 'string': FORMATS.find(function(candidate) { const attempt = moment.utc(value, candidate, true); // true means strict mode if (attempt.isValid()) { format = candidate; value = attempt; return true; } return false; }); } } if (value.constructor.name !== 'Moment') { throw new utilities.Exception({ $module: '/bali/elements/Moment', $procedure: '$Moment', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid moment value was passed to the constructor."' }); } // since this element is immutable the attributes must be read-only this.getFormat = function() { return format; }; this.getValue = function() { return value; }; return this; }
javascript
function Moment(value, parameters) { abstractions.Element.call(this, utilities.types.MOMENT, parameters); var format; if (value === undefined || value === null) { format = FORMATS[7]; value = moment.utc(); // the current moment } else { switch (typeof value) { case 'number': format = FORMATS[7]; value = moment.utc(value); // in milliseconds since EPOC break; case 'string': FORMATS.find(function(candidate) { const attempt = moment.utc(value, candidate, true); // true means strict mode if (attempt.isValid()) { format = candidate; value = attempt; return true; } return false; }); } } if (value.constructor.name !== 'Moment') { throw new utilities.Exception({ $module: '/bali/elements/Moment', $procedure: '$Moment', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid moment value was passed to the constructor."' }); } // since this element is immutable the attributes must be read-only this.getFormat = function() { return format; }; this.getValue = function() { return value; }; return this; }
[ "function", "Moment", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "MOMENT", ",", "parameters", ")", ";", "var", "format", ";", "if", "(", "value", "===", "undefined", "||", "value", "===", "null", ")", "{", "format", "=", "FORMATS", "[", "7", "]", ";", "value", "=", "moment", ".", "utc", "(", ")", ";", "}", "else", "{", "switch", "(", "typeof", "value", ")", "{", "case", "'number'", ":", "format", "=", "FORMATS", "[", "7", "]", ";", "value", "=", "moment", ".", "utc", "(", "value", ")", ";", "break", ";", "case", "'string'", ":", "FORMATS", ".", "find", "(", "function", "(", "candidate", ")", "{", "const", "attempt", "=", "moment", ".", "utc", "(", "value", ",", "candidate", ",", "true", ")", ";", "if", "(", "attempt", ".", "isValid", "(", ")", ")", "{", "format", "=", "candidate", ";", "value", "=", "attempt", ";", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "}", "}", "if", "(", "value", ".", "constructor", ".", "name", "!==", "'Moment'", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Moment'", ",", "$procedure", ":", "'$Moment'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid moment value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getFormat", "=", "function", "(", ")", "{", "return", "format", ";", "}", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new moment in time using the specified value and parameters. @param {String|Number} value The source string value of the moment in time. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Moment} The new moment in time.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "moment", "in", "time", "using", "the", "specified", "value", "and", "parameters", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Moment.js#L44-L83
train
craterdog-bali/js-bali-component-framework
src/composites/Tree.js
Tree
function Tree(type) { abstractions.Composite.call(this, type); if (!utilities.types.isProcedural(type)) { throw new utilities.Exception({ $module: '/bali/composites/Tree', $procedure: '$Tree', $exception: '$invalidParameter', $parameter: utilities.types.symbolForType(type), $text: '"An invalid tree type was passed to the constructor."' }); } // the array is a private attribute so methods that use it are defined in the constructor const array = []; this.toArray = function() { return array.slice(); // copy the array }; this.getSize = function() { return array.length; }; this.addChild = function(child) { array.push(child); child.getParent = function() { return this; }; }; this.getChild = function(index) { index = this.normalizeIndex(index) - 1; // JS uses zero based indexing return array[index]; }; this.getParent = function() { }; // will be reset by parent when added as a child return this; }
javascript
function Tree(type) { abstractions.Composite.call(this, type); if (!utilities.types.isProcedural(type)) { throw new utilities.Exception({ $module: '/bali/composites/Tree', $procedure: '$Tree', $exception: '$invalidParameter', $parameter: utilities.types.symbolForType(type), $text: '"An invalid tree type was passed to the constructor."' }); } // the array is a private attribute so methods that use it are defined in the constructor const array = []; this.toArray = function() { return array.slice(); // copy the array }; this.getSize = function() { return array.length; }; this.addChild = function(child) { array.push(child); child.getParent = function() { return this; }; }; this.getChild = function(index) { index = this.normalizeIndex(index) - 1; // JS uses zero based indexing return array[index]; }; this.getParent = function() { }; // will be reset by parent when added as a child return this; }
[ "function", "Tree", "(", "type", ")", "{", "abstractions", ".", "Composite", ".", "call", "(", "this", ",", "type", ")", ";", "if", "(", "!", "utilities", ".", "types", ".", "isProcedural", "(", "type", ")", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/composites/Tree'", ",", "$procedure", ":", "'$Tree'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "utilities", ".", "types", ".", "symbolForType", "(", "type", ")", ",", "$text", ":", "'\"An invalid tree type was passed to the constructor.\"'", "}", ")", ";", "}", "const", "array", "=", "[", "]", ";", "this", ".", "toArray", "=", "function", "(", ")", "{", "return", "array", ".", "slice", "(", ")", ";", "}", ";", "this", ".", "getSize", "=", "function", "(", ")", "{", "return", "array", ".", "length", ";", "}", ";", "this", ".", "addChild", "=", "function", "(", "child", ")", "{", "array", ".", "push", "(", "child", ")", ";", "child", ".", "getParent", "=", "function", "(", ")", "{", "return", "this", ";", "}", ";", "}", ";", "this", ".", "getChild", "=", "function", "(", "index", ")", "{", "index", "=", "this", ".", "normalizeIndex", "(", "index", ")", "-", "1", ";", "return", "array", "[", "index", "]", ";", "}", ";", "this", ".", "getParent", "=", "function", "(", ")", "{", "}", ";", "return", "this", ";", "}" ]
PUBLIC FUNCTIONS This constructor creates a new tree node component. @param {Number} type The type of the tree node component. @returns {Tree} The new tree node component.
[ "PUBLIC", "FUNCTIONS", "This", "constructor", "creates", "a", "new", "tree", "node", "component", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/composites/Tree.js#L32-L68
train
Automattic/wpcom-unpublished
lib/site.wordads.js
SiteWordAds
function SiteWordAds( sid, wpcom ) { if ( ! ( this instanceof SiteWordAds ) ) { return new SiteWordAds( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
function SiteWordAds( sid, wpcom ) { if ( ! ( this instanceof SiteWordAds ) ) { return new SiteWordAds( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
[ "function", "SiteWordAds", "(", "sid", ",", "wpcom", ")", "{", "if", "(", "!", "(", "this", "instanceof", "SiteWordAds", ")", ")", "{", "return", "new", "SiteWordAds", "(", "sid", ",", "wpcom", ")", ";", "}", "this", ".", "_sid", "=", "sid", ";", "this", ".", "wpcom", "=", "wpcom", ";", "}" ]
`SiteWordAds` constructor. Use a `WPCOM#Me` instance to create a new `SiteWordAds` instance. *Example:* // Require `wpcom-unpublished` library var wpcomUnpublished = require( 'wpcom-unpublished' ); // Create a `wpcomUnpublished` instance var wpcom = wpcomUnpublished(); // Create a `SiteWordAds` instance var wordAds = wpcom .site( 'my-blog.wordpress.com' ) .wordAds(); @constructor @param {wpcomUnpublished} wpcom @public
[ "SiteWordAds", "constructor", "." ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/lib/site.wordads.js#L32-L39
train
craterdog-bali/js-bali-component-framework
src/elements/Name.js
Name
function Name(value, parameters) { abstractions.Element.call(this, utilities.types.NAME, parameters); if (!Array.isArray(value) || value.length === 0) { throw new utilities.Exception({ $module: '/bali/elements/Name', $procedure: '$Name', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid name value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Name(value, parameters) { abstractions.Element.call(this, utilities.types.NAME, parameters); if (!Array.isArray(value) || value.length === 0) { throw new utilities.Exception({ $module: '/bali/elements/Name', $procedure: '$Name', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid name value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Name", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "NAME", ",", "parameters", ")", ";", "if", "(", "!", "Array", ".", "isArray", "(", "value", ")", "||", "value", ".", "length", "===", "0", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Name'", ",", "$procedure", ":", "'$Name'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid name value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new name element using the specified value. @param {Array} value An array containing the parts of the name string. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Symbol} The new name string element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "name", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Name.js#L30-L46
train
craterdog-bali/js-bali-component-framework
src/elements/Symbol.js
Symbol
function Symbol(value, parameters) { abstractions.Element.call(this, utilities.types.SYMBOL, parameters); if (!value || !/^[a-zA-Z][0-9a-zA-Z]*$/g.test(value)) { throw new utilities.Exception({ $module: '/bali/elements/Symbol', $procedure: '$Symbol', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid symbol value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Symbol(value, parameters) { abstractions.Element.call(this, utilities.types.SYMBOL, parameters); if (!value || !/^[a-zA-Z][0-9a-zA-Z]*$/g.test(value)) { throw new utilities.Exception({ $module: '/bali/elements/Symbol', $procedure: '$Symbol', $exception: '$invalidParameter', $parameter: value.toString(), $text: '"An invalid symbol value was passed to the constructor."' }); } // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Symbol", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "SYMBOL", ",", "parameters", ")", ";", "if", "(", "!", "value", "||", "!", "/", "^[a-zA-Z][0-9a-zA-Z]*$", "/", "g", ".", "test", "(", "value", ")", ")", "{", "throw", "new", "utilities", ".", "Exception", "(", "{", "$module", ":", "'/bali/elements/Symbol'", ",", "$procedure", ":", "'$Symbol'", ",", "$exception", ":", "'$invalidParameter'", ",", "$parameter", ":", "value", ".", "toString", "(", ")", ",", "$text", ":", "'\"An invalid symbol value was passed to the constructor.\"'", "}", ")", ";", "}", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates a new symbol element using the specified value. @param {String} value The value of the symbol. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Symbol} The new symbol element.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "a", "new", "symbol", "element", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Symbol.js#L30-L46
train
clncln1/node-aswbxml
lib/codepage.js
findMinIndexValue
function findMinIndexValue(pageNumber, searchFor) { var lookupAttr = typeof searchFor === 'string' ? 'name' : 'token'; var minIndexValue = null for (var i = 0; i < this.codePage[pageNumber].values.length; i++) { let index = searchFor.indexOf(this.codePage[pageNumber].values[i][lookupAttr]) if ( index >= 0 && (!minIndexValue || (index < minIndexValue.index))){ minIndexValue = {index: index, value: this.codePage[pageNumber].values[i] } } } return minIndexValue }
javascript
function findMinIndexValue(pageNumber, searchFor) { var lookupAttr = typeof searchFor === 'string' ? 'name' : 'token'; var minIndexValue = null for (var i = 0; i < this.codePage[pageNumber].values.length; i++) { let index = searchFor.indexOf(this.codePage[pageNumber].values[i][lookupAttr]) if ( index >= 0 && (!minIndexValue || (index < minIndexValue.index))){ minIndexValue = {index: index, value: this.codePage[pageNumber].values[i] } } } return minIndexValue }
[ "function", "findMinIndexValue", "(", "pageNumber", ",", "searchFor", ")", "{", "var", "lookupAttr", "=", "typeof", "searchFor", "===", "'string'", "?", "'name'", ":", "'token'", ";", "var", "minIndexValue", "=", "null", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "codePage", "[", "pageNumber", "]", ".", "values", ".", "length", ";", "i", "++", ")", "{", "let", "index", "=", "searchFor", ".", "indexOf", "(", "this", ".", "codePage", "[", "pageNumber", "]", ".", "values", "[", "i", "]", "[", "lookupAttr", "]", ")", "if", "(", "index", ">=", "0", "&&", "(", "!", "minIndexValue", "||", "(", "index", "<", "minIndexValue", ".", "index", ")", ")", ")", "{", "minIndexValue", "=", "{", "index", ":", "index", ",", "value", ":", "this", ".", "codePage", "[", "pageNumber", "]", ".", "values", "[", "i", "]", "}", "}", "}", "return", "minIndexValue", "}" ]
Scans the list of values getting the minimun index of the searchFor element
[ "Scans", "the", "list", "of", "values", "getting", "the", "minimun", "index", "of", "the", "searchFor", "element" ]
a00c8cbb69cc2bf665810211c052b62fe2d64c13
https://github.com/clncln1/node-aswbxml/blob/a00c8cbb69cc2bf665810211c052b62fe2d64c13/lib/codepage.js#L78-L90
train
kissyteam/kissy-xtemplate
middleware/index.js
function(str, callback) { try { var result = xtpl._compile(str, source, 'utf8', 'utf8'); } catch (e) { return callback(err); } callback(null, result); }
javascript
function(str, callback) { try { var result = xtpl._compile(str, source, 'utf8', 'utf8'); } catch (e) { return callback(err); } callback(null, result); }
[ "function", "(", "str", ",", "callback", ")", "{", "try", "{", "var", "result", "=", "xtpl", ".", "_compile", "(", "str", ",", "source", ",", "'utf8'", ",", "'utf8'", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "callback", "(", "err", ")", ";", "}", "callback", "(", "null", ",", "result", ")", ";", "}" ]
Parse and compile the CSS from the source string.
[ "Parse", "and", "compile", "the", "CSS", "from", "the", "source", "string", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/middleware/index.js#L40-L49
train
KleeGroup/focus-notifications
src/component/notification-group.js
groupDate
function groupDate({creationDate: date}) { const root = 'focus.notifications.groups'; if(_isYoungerThanA('day', date)) { return `${root}.0_today`; } if(_isYoungerThanA('week', date)) { return `${root}.1_lastWeek`; } if(_isYoungerThanA('month', date)) { return `${root}.2_lastMonth`; } return `${root}.3_before`; }
javascript
function groupDate({creationDate: date}) { const root = 'focus.notifications.groups'; if(_isYoungerThanA('day', date)) { return `${root}.0_today`; } if(_isYoungerThanA('week', date)) { return `${root}.1_lastWeek`; } if(_isYoungerThanA('month', date)) { return `${root}.2_lastMonth`; } return `${root}.3_before`; }
[ "function", "groupDate", "(", "{", "creationDate", ":", "date", "}", ")", "{", "const", "root", "=", "'focus.notifications.groups'", ";", "if", "(", "_isYoungerThanA", "(", "'day'", ",", "date", ")", ")", "{", "return", "`", "${", "root", "}", "`", ";", "}", "if", "(", "_isYoungerThanA", "(", "'week'", ",", "date", ")", ")", "{", "return", "`", "${", "root", "}", "`", ";", "}", "if", "(", "_isYoungerThanA", "(", "'month'", ",", "date", ")", ")", "{", "return", "`", "${", "root", "}", "`", ";", "}", "return", "`", "${", "root", "}", "`", ";", "}" ]
function to group date
[ "function", "to", "group", "date" ]
b9a529264b625a12c3d8d479f839f36f77b674f6
https://github.com/KleeGroup/focus-notifications/blob/b9a529264b625a12c3d8d479f839f36f77b674f6/src/component/notification-group.js#L16-L28
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function (url, data, callback) { if (typeof data === 'function') { callback = data; data = undefined; } return get(url, data, callback, 'jsonp'); }
javascript
function (url, data, callback) { if (typeof data === 'function') { callback = data; data = undefined; } return get(url, data, callback, 'jsonp'); }
[ "function", "(", "url", ",", "data", ",", "callback", ")", "{", "if", "(", "typeof", "data", "===", "'function'", ")", "{", "callback", "=", "data", ";", "data", "=", "undefined", ";", "}", "return", "get", "(", "url", ",", "data", ",", "callback", ",", "'jsonp'", ")", ";", "}" ]
preform a jsonp request @param {String} url request destination @param {Object} [data] name-value object associated with this request @param {Function} [callback] success callback when this request is done. @param callback.data returned from this request with type specified by dataType @param {String} callback.status status of this request with type String @param {KISSY.IO} callback.io io object of this request @return {KISSY.IO} @member KISSY.IO @static
[ "preform", "a", "jsonp", "request" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L116-L122
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function (url, form, data, callback, dataType) { if (typeof data === 'function') { dataType = /** @type String @ignore */ callback; callback = data; data = undefined; } return IO({ url: url, type: 'post', dataType: dataType, form: form, data: data, success: callback }); }
javascript
function (url, form, data, callback, dataType) { if (typeof data === 'function') { dataType = /** @type String @ignore */ callback; callback = data; data = undefined; } return IO({ url: url, type: 'post', dataType: dataType, form: form, data: data, success: callback }); }
[ "function", "(", "url", ",", "form", ",", "data", ",", "callback", ",", "dataType", ")", "{", "if", "(", "typeof", "data", "===", "'function'", ")", "{", "dataType", "=", "callback", ";", "callback", "=", "data", ";", "data", "=", "undefined", ";", "}", "return", "IO", "(", "{", "url", ":", "url", ",", "type", ":", "'post'", ",", "dataType", ":", "dataType", ",", "form", ":", "form", ",", "data", ":", "data", ",", "success", ":", "callback", "}", ")", ";", "}" ]
submit form without page refresh @param {String} url request destination @param {HTMLElement|KISSY.Node} form element tobe submited @param {Object} [data] name-value object associated with this request @param {Function} [callback] success callback when this request is done.@param callback.data returned from this request with type specified by dataType @param {String} callback.status status of this request with type String @param {KISSY.IO} callback.io io object of this request @param {String} [dataType] the type of data returns from this request ('xml' or 'json' or 'text') @return {KISSY.IO} @member KISSY.IO @static
[ "submit", "form", "without", "page", "refresh" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L163-L181
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
elementsToArray
function elementsToArray(elements) { var ret = []; for (var i = 0; i < elements.length; i++) { ret.push(elements[i]); } return ret; }
javascript
function elementsToArray(elements) { var ret = []; for (var i = 0; i < elements.length; i++) { ret.push(elements[i]); } return ret; }
[ "function", "elementsToArray", "(", "elements", ")", "{", "var", "ret", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "elements", ".", "length", ";", "i", "++", ")", "{", "ret", ".", "push", "(", "elements", "[", "i", "]", ")", ";", "}", "return", "ret", ";", "}" ]
do not pass form.elements to S.makeArray ie678 bug do not pass form.elements to S.makeArray ie678 bug
[ "do", "not", "pass", "form", ".", "elements", "to", "S", ".", "makeArray", "ie678", "bug", "do", "not", "pass", "form", ".", "elements", "to", "S", ".", "makeArray", "ie678", "bug" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L263-L269
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
IO
function IO(c) { var self = this; if (!(self instanceof IO)) { return new IO(c); } // Promise.call(self); // Promise.call(self); IO.superclass.constructor.call(self); Promise.Defer(self); self.userConfig = c; c = setUpConfig(c); util.mix(self, { // 结构化数据,如 json responseData: null, /** * config of current IO instance. * @member KISSY.IO * @property config * @type Object */ config: c || {}, timeoutTimer: null, /** * String typed data returned from server * @type String */ responseText: null, /** * xml typed data returned from server * @type String */ responseXML: null, responseHeadersString: '', responseHeaders: null, requestHeaders: {}, /** * readyState of current request * 0: initialized * 1: send * 4: completed * @type Number */ readyState: 0, state: 0, /** * HTTP statusText of current request * @type String */ statusText: null, /** * HTTP Status Code of current request * eg: * 200: ok * 404: Not Found * 500: Server Error * @type String */ status: 0, transport: null }); var TransportConstructor, transport; /** * fired before generating request object * @event start * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ /** * fired before generating request object * @event start * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ IO.fire('start', { // 兼容 ajaxConfig: c, io: self }); TransportConstructor = transports[c.dataType[0]] || transports['*']; transport = new TransportConstructor(self); self.transport = transport; if (c.contentType) { self.setRequestHeader('Content-Type', c.contentType); } var dataType = c.dataType[0], i, timeout = c.timeout, context = c.context, headers = c.headers, accepts = c.accepts; // Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType self.setRequestHeader('Accept', dataType && accepts[dataType] ? accepts[dataType] + (dataType === '*' ? '' : ', */*; q=0.01') : accepts['*']); // Check for headers option // Check for headers option for (i in headers) { self.setRequestHeader(i, headers[i]); } // allow setup native listener // such as xhr.upload.addEventListener('progress', function (ev) {}) // allow setup native listener // such as xhr.upload.addEventListener('progress', function (ev) {}) if (c.beforeSend && c.beforeSend.call(context, self, c) === false) { return self; } self.readyState = 1; /** * fired before sending request * @event send * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ /** * fired before sending request * @event send * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ IO.fire('send', { // 兼容 ajaxConfig: c, io: self }); // Timeout // Timeout if (c.async && timeout > 0) { self.timeoutTimer = setTimeout(function () { self.abort('timeout'); }, timeout * 1000); } try { // flag as sending self.state = 1; transport.send(); } catch (e) { logger.log(e.stack || e, 'error'); if ('@DEBUG@') { setTimeout(function () { throw e; }, 0); } // Propagate exception as error if not done // Propagate exception as error if not done if (self.state < 2) { self._ioReady(0 - 1, e.message || 'send error'); // Simply rethrow otherwise } } // Simply rethrow otherwise return self; }
javascript
function IO(c) { var self = this; if (!(self instanceof IO)) { return new IO(c); } // Promise.call(self); // Promise.call(self); IO.superclass.constructor.call(self); Promise.Defer(self); self.userConfig = c; c = setUpConfig(c); util.mix(self, { // 结构化数据,如 json responseData: null, /** * config of current IO instance. * @member KISSY.IO * @property config * @type Object */ config: c || {}, timeoutTimer: null, /** * String typed data returned from server * @type String */ responseText: null, /** * xml typed data returned from server * @type String */ responseXML: null, responseHeadersString: '', responseHeaders: null, requestHeaders: {}, /** * readyState of current request * 0: initialized * 1: send * 4: completed * @type Number */ readyState: 0, state: 0, /** * HTTP statusText of current request * @type String */ statusText: null, /** * HTTP Status Code of current request * eg: * 200: ok * 404: Not Found * 500: Server Error * @type String */ status: 0, transport: null }); var TransportConstructor, transport; /** * fired before generating request object * @event start * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ /** * fired before generating request object * @event start * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ IO.fire('start', { // 兼容 ajaxConfig: c, io: self }); TransportConstructor = transports[c.dataType[0]] || transports['*']; transport = new TransportConstructor(self); self.transport = transport; if (c.contentType) { self.setRequestHeader('Content-Type', c.contentType); } var dataType = c.dataType[0], i, timeout = c.timeout, context = c.context, headers = c.headers, accepts = c.accepts; // Set the Accepts header for the server, depending on the dataType // Set the Accepts header for the server, depending on the dataType self.setRequestHeader('Accept', dataType && accepts[dataType] ? accepts[dataType] + (dataType === '*' ? '' : ', */*; q=0.01') : accepts['*']); // Check for headers option // Check for headers option for (i in headers) { self.setRequestHeader(i, headers[i]); } // allow setup native listener // such as xhr.upload.addEventListener('progress', function (ev) {}) // allow setup native listener // such as xhr.upload.addEventListener('progress', function (ev) {}) if (c.beforeSend && c.beforeSend.call(context, self, c) === false) { return self; } self.readyState = 1; /** * fired before sending request * @event send * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ /** * fired before sending request * @event send * @member KISSY.IO * @static * @param {KISSY.Event.CustomEvent.Object} e * @param {KISSY.IO} e.io current io */ IO.fire('send', { // 兼容 ajaxConfig: c, io: self }); // Timeout // Timeout if (c.async && timeout > 0) { self.timeoutTimer = setTimeout(function () { self.abort('timeout'); }, timeout * 1000); } try { // flag as sending self.state = 1; transport.send(); } catch (e) { logger.log(e.stack || e, 'error'); if ('@DEBUG@') { setTimeout(function () { throw e; }, 0); } // Propagate exception as error if not done // Propagate exception as error if not done if (self.state < 2) { self._ioReady(0 - 1, e.message || 'send error'); // Simply rethrow otherwise } } // Simply rethrow otherwise return self; }
[ "function", "IO", "(", "c", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "(", "self", "instanceof", "IO", ")", ")", "{", "return", "new", "IO", "(", "c", ")", ";", "}", "IO", ".", "superclass", ".", "constructor", ".", "call", "(", "self", ")", ";", "Promise", ".", "Defer", "(", "self", ")", ";", "self", ".", "userConfig", "=", "c", ";", "c", "=", "setUpConfig", "(", "c", ")", ";", "util", ".", "mix", "(", "self", ",", "{", "responseData", ":", "null", ",", "config", ":", "c", "||", "{", "}", ",", "timeoutTimer", ":", "null", ",", "responseText", ":", "null", ",", "responseXML", ":", "null", ",", "responseHeadersString", ":", "''", ",", "responseHeaders", ":", "null", ",", "requestHeaders", ":", "{", "}", ",", "readyState", ":", "0", ",", "state", ":", "0", ",", "statusText", ":", "null", ",", "status", ":", "0", ",", "transport", ":", "null", "}", ")", ";", "var", "TransportConstructor", ",", "transport", ";", "IO", ".", "fire", "(", "'start'", ",", "{", "ajaxConfig", ":", "c", ",", "io", ":", "self", "}", ")", ";", "TransportConstructor", "=", "transports", "[", "c", ".", "dataType", "[", "0", "]", "]", "||", "transports", "[", "'*'", "]", ";", "transport", "=", "new", "TransportConstructor", "(", "self", ")", ";", "self", ".", "transport", "=", "transport", ";", "if", "(", "c", ".", "contentType", ")", "{", "self", ".", "setRequestHeader", "(", "'Content-Type'", ",", "c", ".", "contentType", ")", ";", "}", "var", "dataType", "=", "c", ".", "dataType", "[", "0", "]", ",", "i", ",", "timeout", "=", "c", ".", "timeout", ",", "context", "=", "c", ".", "context", ",", "headers", "=", "c", ".", "headers", ",", "accepts", "=", "c", ".", "accepts", ";", "self", ".", "setRequestHeader", "(", "'Accept'", ",", "dataType", "&&", "accepts", "[", "dataType", "]", "?", "accepts", "[", "dataType", "]", "+", "(", "dataType", "===", "'*'", "?", "''", ":", "', */*; q=0.01'", ")", ":", "accepts", "[", "'*'", "]", ")", ";", "for", "(", "i", "in", "headers", ")", "{", "self", ".", "setRequestHeader", "(", "i", ",", "headers", "[", "i", "]", ")", ";", "}", "if", "(", "c", ".", "beforeSend", "&&", "c", ".", "beforeSend", ".", "call", "(", "context", ",", "self", ",", "c", ")", "===", "false", ")", "{", "return", "self", ";", "}", "self", ".", "readyState", "=", "1", ";", "IO", ".", "fire", "(", "'send'", ",", "{", "ajaxConfig", ":", "c", ",", "io", ":", "self", "}", ")", ";", "if", "(", "c", ".", "async", "&&", "timeout", ">", "0", ")", "{", "self", ".", "timeoutTimer", "=", "setTimeout", "(", "function", "(", ")", "{", "self", ".", "abort", "(", "'timeout'", ")", ";", "}", ",", "timeout", "*", "1000", ")", ";", "}", "try", "{", "self", ".", "state", "=", "1", ";", "transport", ".", "send", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "logger", ".", "log", "(", "e", ".", "stack", "||", "e", ",", "'error'", ")", ";", "if", "(", "'@DEBUG@'", ")", "{", "setTimeout", "(", "function", "(", ")", "{", "throw", "e", ";", "}", ",", "0", ")", ";", "}", "if", "(", "self", ".", "state", "<", "2", ")", "{", "self", ".", "_ioReady", "(", "0", "-", "1", ",", "e", ".", "message", "||", "'send error'", ")", ";", "}", "}", "return", "self", ";", "}" ]
Return a io object and send request by config. @class KISSY.IO @extends KISSY.Promise @cfg {String} url request destination @cfg {String} type request type. eg: 'get','post' Default to: 'get' @cfg {String} contentType Default to: 'application/x-www-form-urlencoded; charset=UTF-8' Data will always be transmitted to the server using UTF-8 charset @cfg {Object} accepts Default to: depends on DataType. The content type sent in request header that tells the server what kind of response it will accept in return. It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Boolean} async Default to: true whether request is sent asynchronously @cfg {Boolean} cache Default to: true ,false for dataType 'script' and 'jsonp' if set false,will append _ksTs=Date.now() to url automatically @cfg {Object} contents a name-regexp map to determine request data's dataType It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Object} context specify the context of this request 's callback (success,error,complete) @cfg {Object} converters Default to: {text:{json:Json.parse,html:mirror,text:mirror,xml:KISSY.parseXML}} specified how to transform one dataType to another dataType It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Boolean} crossDomain Default to: false for same-domain request,true for cross-domain request if server-side jsonp redirect to another domain, you should set this to true. if you want use script for jsonp for same domain request, you should set this to true. @cfg {Object} data Data sent to server.if processData is true,data will be serialized to String type. if value if an Array, serialization will be based on serializeArray. @cfg {String} dataType return data as a specified type Default to: Based on server contentType header 'xml' : a XML document 'text'/'html': raw server data 'script': evaluate the return data as script 'json': parse the return data as json and return the result as final data 'jsonp': load json data via jsonp @cfg {Object} headers additional name-value header to send along with this request. @cfg {String} jsonp Default to: 'callback' Override the callback function name in a jsonp request. eg: set 'callback2' , then jsonp url will append 'callback2=?'. @cfg {String} jsonpCallback Specify the callback function name for a jsonp request. set this value will replace the auto generated function name. eg: set 'customCall' , then jsonp url will append 'callback=customCall' @cfg {String} mimeType override xhr 's mime type @cfg {String} ifModified whether enter if modified mode. Defaults to false. @cfg {Boolean} processData Default to: true whether data will be serialized as String @cfg {String} scriptCharset only for dataType 'jsonp' and 'script' and 'get' type. force the script to certain charset. @cfg {Function} beforeSend beforeSend(io,config) callback function called before the request is sent.this function has 2 arguments 1. current KISSY io object 2. current io config note: can be used for add progress event listener for native xhr's upload attribute see <a href='http://www.w3.org/TR/XMLHttpRequest/#event-xhr-progress'>XMLHttpRequest2</a> @cfg {Function} success success(data,textStatus,xhr) callback function called if the request succeeds.this function has 3 arguments 1. data returned from this request with type specified by dataType 2. status of this request with type String 3. io object of this request , for details {@link KISSY.IO} @cfg {Function} error success(data,textStatus,xhr) callback function called if the request occurs error.this function has 3 arguments 1. null value 2. status of this request with type String,such as 'timeout','Not Found','parsererror:...' 3. io object of this request , for details {@link KISSY.IO} @cfg {Function} complete success(data,textStatus,xhr) callback function called if the request finished(success or error).this function has 3 arguments 1. null value if error occurs or data returned from server 2. status of this request with type String,such as success:'ok', error:'timeout','Not Found','parsererror:...' 3. io object of this request , for details {@link KISSY.IO} @cfg {Number} timeout Set a timeout(in seconds) for this request.if will call error when timeout @cfg {Boolean} serializeArray whether add [] to data's name when data's value is array in serialization @cfg {Object} xhrFields name-value to set to native xhr.set as xhrFields:{withCredentials:true} note: withCredentials defaults to true. @cfg {String} username a username tobe used in response to HTTP access authentication request @cfg {String} password a password tobe used in response to HTTP access authentication request @cfg {Object} xdr cross domain request config object, contains sub config: xdr.src Default to: KISSY 's flash url flash sender url xdr.use if set to 'use', it will always use flash for cross domain request even in chrome/firefox xdr.subDomain cross sub domain request config object xdr.subDomain.proxy proxy page, eg: a.t.cn/a.htm send request to b.t.cn/b.htm: 1. a.htm set <code> document.domain='t.cn' </code> 2. b.t.cn/proxy.htm 's content is <code> &lt;script>document.domain='t.cn'&lt;/script> </code> 3. in a.htm , call <code> IO({xdr:{subDomain:{proxy:'/proxy.htm'}}}) </code> Return a io object and send request by config. @class KISSY.IO @extends KISSY.Promise @cfg {String} url request destination @cfg {String} type request type. eg: 'get','post' Default to: 'get' @cfg {String} contentType Default to: 'application/x-www-form-urlencoded; charset=UTF-8' Data will always be transmitted to the server using UTF-8 charset @cfg {Object} accepts Default to: depends on DataType. The content type sent in request header that tells the server what kind of response it will accept in return. It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Boolean} async Default to: true whether request is sent asynchronously @cfg {Boolean} cache Default to: true ,false for dataType 'script' and 'jsonp' if set false,will append _ksTs=Date.now() to url automatically @cfg {Object} contents a name-regexp map to determine request data's dataType It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Object} context specify the context of this request 's callback (success,error,complete) @cfg {Object} converters Default to: {text:{json:Json.parse,html:mirror,text:mirror,xml:KISSY.parseXML}} specified how to transform one dataType to another dataType It is recommended to do so once in the {@link KISSY.IO#method-setupConfig} @cfg {Boolean} crossDomain Default to: false for same-domain request,true for cross-domain request if server-side jsonp redirect to another domain, you should set this to true. if you want use script for jsonp for same domain request, you should set this to true. @cfg {Object} data Data sent to server.if processData is true,data will be serialized to String type. if value if an Array, serialization will be based on serializeArray. @cfg {String} dataType return data as a specified type Default to: Based on server contentType header 'xml' : a XML document 'text'/'html': raw server data 'script': evaluate the return data as script 'json': parse the return data as json and return the result as final data 'jsonp': load json data via jsonp @cfg {Object} headers additional name-value header to send along with this request. @cfg {String} jsonp Default to: 'callback' Override the callback function name in a jsonp request. eg: set 'callback2' , then jsonp url will append 'callback2=?'. @cfg {String} jsonpCallback Specify the callback function name for a jsonp request. set this value will replace the auto generated function name. eg: set 'customCall' , then jsonp url will append 'callback=customCall' @cfg {String} mimeType override xhr 's mime type @cfg {String} ifModified whether enter if modified mode. Defaults to false. @cfg {Boolean} processData Default to: true whether data will be serialized as String @cfg {String} scriptCharset only for dataType 'jsonp' and 'script' and 'get' type. force the script to certain charset. @cfg {Function} beforeSend beforeSend(io,config) callback function called before the request is sent.this function has 2 arguments 1. current KISSY io object 2. current io config note: can be used for add progress event listener for native xhr's upload attribute see <a href='http://www.w3.org/TR/XMLHttpRequest/#event-xhr-progress'>XMLHttpRequest2</a> @cfg {Function} success success(data,textStatus,xhr) callback function called if the request succeeds.this function has 3 arguments 1. data returned from this request with type specified by dataType 2. status of this request with type String 3. io object of this request , for details {@link KISSY.IO} @cfg {Function} error success(data,textStatus,xhr) callback function called if the request occurs error.this function has 3 arguments 1. null value 2. status of this request with type String,such as 'timeout','Not Found','parsererror:...' 3. io object of this request , for details {@link KISSY.IO} @cfg {Function} complete success(data,textStatus,xhr) callback function called if the request finished(success or error).this function has 3 arguments 1. null value if error occurs or data returned from server 2. status of this request with type String,such as success:'ok', error:'timeout','Not Found','parsererror:...' 3. io object of this request , for details {@link KISSY.IO} @cfg {Number} timeout Set a timeout(in seconds) for this request.if will call error when timeout @cfg {Boolean} serializeArray whether add [] to data's name when data's value is array in serialization @cfg {Object} xhrFields name-value to set to native xhr.set as xhrFields:{withCredentials:true} note: withCredentials defaults to true. @cfg {String} username a username tobe used in response to HTTP access authentication request @cfg {String} password a password tobe used in response to HTTP access authentication request @cfg {Object} xdr cross domain request config object, contains sub config: xdr.src Default to: KISSY 's flash url flash sender url xdr.use if set to 'use', it will always use flash for cross domain request even in chrome/firefox xdr.subDomain cross sub domain request config object xdr.subDomain.proxy proxy page, eg: a.t.cn/a.htm send request to b.t.cn/b.htm: 1. a.htm set <code> document.domain='t.cn' </code> 2. b.t.cn/proxy.htm 's content is <code> &lt;script>document.domain='t.cn'&lt;/script> </code> 3. in a.htm , call <code> IO({xdr:{subDomain:{proxy:'/proxy.htm'}}}) </code>
[ "Return", "a", "io", "object", "and", "send", "request", "by", "config", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L707-L851
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
_swf
function _swf(uri, _, uid) { if (init) { return; } init = true; var o = '<object id="' + ID + '" type="application/x-shockwave-flash" data="' + uri + '" width="0" height="0">' + '<param name="movie" value="' + uri + '" />' + '<param name="FlashVars" value="yid=' + _ + '&uid=' + uid + '&host=KISSY.IO" />' + '<param name="allowScriptAccess" value="always" />' + '</object>', c = doc.createElement('div'); Dom.prepend(c, doc.body || doc.documentElement); c.innerHTML = o; }
javascript
function _swf(uri, _, uid) { if (init) { return; } init = true; var o = '<object id="' + ID + '" type="application/x-shockwave-flash" data="' + uri + '" width="0" height="0">' + '<param name="movie" value="' + uri + '" />' + '<param name="FlashVars" value="yid=' + _ + '&uid=' + uid + '&host=KISSY.IO" />' + '<param name="allowScriptAccess" value="always" />' + '</object>', c = doc.createElement('div'); Dom.prepend(c, doc.body || doc.documentElement); c.innerHTML = o; }
[ "function", "_swf", "(", "uri", ",", "_", ",", "uid", ")", "{", "if", "(", "init", ")", "{", "return", ";", "}", "init", "=", "true", ";", "var", "o", "=", "'<object id=\"'", "+", "ID", "+", "'\" type=\"application/x-shockwave-flash\" data=\"'", "+", "uri", "+", "'\" width=\"0\" height=\"0\">'", "+", "'<param name=\"movie\" value=\"'", "+", "uri", "+", "'\" />'", "+", "'<param name=\"FlashVars\" value=\"yid='", "+", "_", "+", "'&uid='", "+", "uid", "+", "'&host=KISSY.IO\" />'", "+", "'<param name=\"allowScriptAccess\" value=\"always\" />'", "+", "'</object>'", ",", "c", "=", "doc", ".", "createElement", "(", "'div'", ")", ";", "Dom", ".", "prepend", "(", "c", ",", "doc", ".", "body", "||", "doc", ".", "documentElement", ")", ";", "c", ".", "innerHTML", "=", "o", ";", "}" ]
create the flash transporter create the flash transporter
[ "create", "the", "flash", "transporter", "create", "the", "flash", "transporter" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L1289-L1297
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function () { var self = this, io = self.io, c = io.config, xdr = c.xdr || {}; if (!xdr.src) { if (typeof KISSY !== 'undefined' && KISSY.DEV_MODE) { xdr.src = require.toUrl('../../assets/io.swf'); } else { xdr.src = require.toUrl('./assets/io.swf'); } } // 不提供则使用 cdn 默认的 flash // 不提供则使用 cdn 默认的 flash _swf(xdr.src, 1, 1); // 简便起见,用轮训 // 简便起见,用轮训 if (!flash) { setTimeout(function () { self.send(); }, 200); return; } self._uid = util.guid(); maps[self._uid] = self; // ie67 send 出错? // ie67 send 出错? flash.send(io._getUrlForSend(), { id: self._uid, uid: self._uid, method: c.type, data: c.hasContent && c.data || {} }); }
javascript
function () { var self = this, io = self.io, c = io.config, xdr = c.xdr || {}; if (!xdr.src) { if (typeof KISSY !== 'undefined' && KISSY.DEV_MODE) { xdr.src = require.toUrl('../../assets/io.swf'); } else { xdr.src = require.toUrl('./assets/io.swf'); } } // 不提供则使用 cdn 默认的 flash // 不提供则使用 cdn 默认的 flash _swf(xdr.src, 1, 1); // 简便起见,用轮训 // 简便起见,用轮训 if (!flash) { setTimeout(function () { self.send(); }, 200); return; } self._uid = util.guid(); maps[self._uid] = self; // ie67 send 出错? // ie67 send 出错? flash.send(io._getUrlForSend(), { id: self._uid, uid: self._uid, method: c.type, data: c.hasContent && c.data || {} }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "io", "=", "self", ".", "io", ",", "c", "=", "io", ".", "config", ",", "xdr", "=", "c", ".", "xdr", "||", "{", "}", ";", "if", "(", "!", "xdr", ".", "src", ")", "{", "if", "(", "typeof", "KISSY", "!==", "'undefined'", "&&", "KISSY", ".", "DEV_MODE", ")", "{", "xdr", ".", "src", "=", "require", ".", "toUrl", "(", "'../../assets/io.swf'", ")", ";", "}", "else", "{", "xdr", ".", "src", "=", "require", ".", "toUrl", "(", "'./assets/io.swf'", ")", ";", "}", "}", "_swf", "(", "xdr", ".", "src", ",", "1", ",", "1", ")", ";", "if", "(", "!", "flash", ")", "{", "setTimeout", "(", "function", "(", ")", "{", "self", ".", "send", "(", ")", ";", "}", ",", "200", ")", ";", "return", ";", "}", "self", ".", "_uid", "=", "util", ".", "guid", "(", ")", ";", "maps", "[", "self", ".", "_uid", "]", "=", "self", ";", "flash", ".", "send", "(", "io", ".", "_getUrlForSend", "(", ")", ",", "{", "id", ":", "self", ".", "_uid", ",", "uid", ":", "self", ".", "_uid", ",", "method", ":", "c", ".", "type", ",", "data", ":", "c", ".", "hasContent", "&&", "c", ".", "data", "||", "{", "}", "}", ")", ";", "}" ]
rewrite send to support flash xdr
[ "rewrite", "send", "to", "support", "flash", "xdr" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L1304-L1331
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function () { var self = this, c = self.io.config, uri = c.uri, hostname = uri.hostname, iframe, iframeUri, iframeDesc = iframeMap[hostname]; var proxy = PROXY_PAGE; if (c.xdr && c.xdr.subDomain && c.xdr.subDomain.proxy) { proxy = c.xdr.subDomain.proxy; } if (iframeDesc && iframeDesc.ready) { self.nativeXhr = XhrTransportBase.nativeXhr(0, iframeDesc.iframe.contentWindow); if (self.nativeXhr) { self.sendInternal(); } else { LoggerManager.error('document.domain not set correctly!'); } return; } if (!iframeDesc) { iframeDesc = iframeMap[hostname] = {}; iframe = iframeDesc.iframe = doc.createElement('iframe'); Dom.css(iframe, { position: 'absolute', left: '-9999px', top: '-9999px' }); Dom.prepend(iframe, doc.body || doc.documentElement); iframeUri = {}; iframeUri.protocol = uri.protocol; iframeUri.host = uri.host; iframeUri.pathname = proxy; iframe.src = url.stringify(iframeUri); } else { iframe = iframeDesc.iframe; } Event.on(iframe, 'load', _onLoad, self); }
javascript
function () { var self = this, c = self.io.config, uri = c.uri, hostname = uri.hostname, iframe, iframeUri, iframeDesc = iframeMap[hostname]; var proxy = PROXY_PAGE; if (c.xdr && c.xdr.subDomain && c.xdr.subDomain.proxy) { proxy = c.xdr.subDomain.proxy; } if (iframeDesc && iframeDesc.ready) { self.nativeXhr = XhrTransportBase.nativeXhr(0, iframeDesc.iframe.contentWindow); if (self.nativeXhr) { self.sendInternal(); } else { LoggerManager.error('document.domain not set correctly!'); } return; } if (!iframeDesc) { iframeDesc = iframeMap[hostname] = {}; iframe = iframeDesc.iframe = doc.createElement('iframe'); Dom.css(iframe, { position: 'absolute', left: '-9999px', top: '-9999px' }); Dom.prepend(iframe, doc.body || doc.documentElement); iframeUri = {}; iframeUri.protocol = uri.protocol; iframeUri.host = uri.host; iframeUri.pathname = proxy; iframe.src = url.stringify(iframeUri); } else { iframe = iframeDesc.iframe; } Event.on(iframe, 'load', _onLoad, self); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "c", "=", "self", ".", "io", ".", "config", ",", "uri", "=", "c", ".", "uri", ",", "hostname", "=", "uri", ".", "hostname", ",", "iframe", ",", "iframeUri", ",", "iframeDesc", "=", "iframeMap", "[", "hostname", "]", ";", "var", "proxy", "=", "PROXY_PAGE", ";", "if", "(", "c", ".", "xdr", "&&", "c", ".", "xdr", ".", "subDomain", "&&", "c", ".", "xdr", ".", "subDomain", ".", "proxy", ")", "{", "proxy", "=", "c", ".", "xdr", ".", "subDomain", ".", "proxy", ";", "}", "if", "(", "iframeDesc", "&&", "iframeDesc", ".", "ready", ")", "{", "self", ".", "nativeXhr", "=", "XhrTransportBase", ".", "nativeXhr", "(", "0", ",", "iframeDesc", ".", "iframe", ".", "contentWindow", ")", ";", "if", "(", "self", ".", "nativeXhr", ")", "{", "self", ".", "sendInternal", "(", ")", ";", "}", "else", "{", "LoggerManager", ".", "error", "(", "'document.domain not set correctly!'", ")", ";", "}", "return", ";", "}", "if", "(", "!", "iframeDesc", ")", "{", "iframeDesc", "=", "iframeMap", "[", "hostname", "]", "=", "{", "}", ";", "iframe", "=", "iframeDesc", ".", "iframe", "=", "doc", ".", "createElement", "(", "'iframe'", ")", ";", "Dom", ".", "css", "(", "iframe", ",", "{", "position", ":", "'absolute'", ",", "left", ":", "'-9999px'", ",", "top", ":", "'-9999px'", "}", ")", ";", "Dom", ".", "prepend", "(", "iframe", ",", "doc", ".", "body", "||", "doc", ".", "documentElement", ")", ";", "iframeUri", "=", "{", "}", ";", "iframeUri", ".", "protocol", "=", "uri", ".", "protocol", ";", "iframeUri", ".", "host", "=", "uri", ".", "host", ";", "iframeUri", ".", "pathname", "=", "proxy", ";", "iframe", ".", "src", "=", "url", ".", "stringify", "(", "iframeUri", ")", ";", "}", "else", "{", "iframe", "=", "iframeDesc", ".", "iframe", ";", "}", "Event", ".", "on", "(", "iframe", ",", "'load'", ",", "_onLoad", ",", "self", ")", ";", "}" ]
get nativeXhr from iframe document not from current document directly like XhrTransport
[ "get", "nativeXhr", "from", "iframe", "document", "not", "from", "current", "document", "directly", "like", "XhrTransport" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L1427-L1460
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function (name) { var match, responseHeaders, self = this; // ie8 will be lowercase for content-type // ie8 will be lowercase for content-type name = name.toLowerCase(); if (self.state === 2) { if (!(responseHeaders = self.responseHeaders)) { responseHeaders = self.responseHeaders = {}; while (match = HEADER_REG.exec(self.responseHeadersString)) { responseHeaders[match[1].toLowerCase()] = match[2]; } } match = responseHeaders[name]; } return match === undefined ? null : match; }
javascript
function (name) { var match, responseHeaders, self = this; // ie8 will be lowercase for content-type // ie8 will be lowercase for content-type name = name.toLowerCase(); if (self.state === 2) { if (!(responseHeaders = self.responseHeaders)) { responseHeaders = self.responseHeaders = {}; while (match = HEADER_REG.exec(self.responseHeadersString)) { responseHeaders[match[1].toLowerCase()] = match[2]; } } match = responseHeaders[name]; } return match === undefined ? null : match; }
[ "function", "(", "name", ")", "{", "var", "match", ",", "responseHeaders", ",", "self", "=", "this", ";", "name", "=", "name", ".", "toLowerCase", "(", ")", ";", "if", "(", "self", ".", "state", "===", "2", ")", "{", "if", "(", "!", "(", "responseHeaders", "=", "self", ".", "responseHeaders", ")", ")", "{", "responseHeaders", "=", "self", ".", "responseHeaders", "=", "{", "}", ";", "while", "(", "match", "=", "HEADER_REG", ".", "exec", "(", "self", ".", "responseHeadersString", ")", ")", "{", "responseHeaders", "[", "match", "[", "1", "]", ".", "toLowerCase", "(", ")", "]", "=", "match", "[", "2", "]", ";", "}", "}", "match", "=", "responseHeaders", "[", "name", "]", ";", "}", "return", "match", "===", "undefined", "?", "null", ":", "match", ";", "}" ]
get header value in response to specified header name @param {String} name header name @return {String} header value @member KISSY.IO
[ "get", "header", "value", "in", "response", "to", "specified", "header", "name" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L2035-L2049
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/io-debug.js
function (statusText) { var self = this; statusText = statusText || 'abort'; if (self.transport) { self.transport.abort(statusText); } self._ioReady(0, statusText); return self; }
javascript
function (statusText) { var self = this; statusText = statusText || 'abort'; if (self.transport) { self.transport.abort(statusText); } self._ioReady(0, statusText); return self; }
[ "function", "(", "statusText", ")", "{", "var", "self", "=", "this", ";", "statusText", "=", "statusText", "||", "'abort'", ";", "if", "(", "self", ".", "transport", ")", "{", "self", ".", "transport", ".", "abort", "(", "statusText", ")", ";", "}", "self", ".", "_ioReady", "(", "0", ",", "statusText", ")", ";", "return", "self", ";", "}" ]
cancel this request @member KISSY.IO @param {String} [statusText=abort] error reason as current request object's statusText @chainable
[ "cancel", "this", "request" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/io-debug.js#L2064-L2072
train
jonschlinkert/inquirer2
lib/prompts/checkbox.js
getCheckbox
function getCheckbox(checked) { return checked ? utils.chalk.green(utils.figures.radioOn) : utils.figures.radioOff; }
javascript
function getCheckbox(checked) { return checked ? utils.chalk.green(utils.figures.radioOn) : utils.figures.radioOff; }
[ "function", "getCheckbox", "(", "checked", ")", "{", "return", "checked", "?", "utils", ".", "chalk", ".", "green", "(", "utils", ".", "figures", ".", "radioOn", ")", ":", "utils", ".", "figures", ".", "radioOff", ";", "}" ]
Get the checkbox @param {Boolean} checked - add a X or not to the checkbox @return {String} Composited checkbox string
[ "Get", "the", "checkbox" ]
9b4985f5bf7c8590bb79e039de1acab5719ae3fc
https://github.com/jonschlinkert/inquirer2/blob/9b4985f5bf7c8590bb79e039de1acab5719ae3fc/lib/prompts/checkbox.js#L205-L207
train
bq/corbel-js
src/ec/paymentPlanBuilder.js
function (params) { console.log('ecInterface.paymentplan.getAll'); return this.request({ url: this._buildUri(this.uri, 'all'), method: corbel.request.method.GET, query: params ? corbel.utils.serializeParams(params) : null }); }
javascript
function (params) { console.log('ecInterface.paymentplan.getAll'); return this.request({ url: this._buildUri(this.uri, 'all'), method: corbel.request.method.GET, query: params ? corbel.utils.serializeParams(params) : null }); }
[ "function", "(", "params", ")", "{", "console", ".", "log", "(", "'ecInterface.paymentplan.getAll'", ")", ";", "return", "this", ".", "request", "(", "{", "url", ":", "this", ".", "_buildUri", "(", "this", ".", "uri", ",", "'all'", ")", ",", "method", ":", "corbel", ".", "request", ".", "method", ".", "GET", ",", "query", ":", "params", "?", "corbel", ".", "utils", ".", "serializeParams", "(", "params", ")", ":", "null", "}", ")", ";", "}" ]
Gets payment plans paginated, this endpoint is only for admins @method @memberOf corbel.Ec.PaymentPlanBuilder @param {Object} params The params filter @param {Integer} params.api:pageSize Number of result returned in the page (>0 , default: 10) @param {String} params.api:query A search query expressed in silkroad query language @param {Integer} params.api:page The page to be returned. Pages are zero-indexed (>0, default:0) @param {String} params.api:sort Results orders. JSON with field to order and direction, asc or desc @return {Promise} Q promise that resolves to a Payment {Object} or rejects with a {@link SilkRoadError}
[ "Gets", "payment", "plans", "paginated", "this", "endpoint", "is", "only", "for", "admins" ]
00074882676b592d2ac16868279c58b0c4faf1e2
https://github.com/bq/corbel-js/blob/00074882676b592d2ac16868279c58b0c4faf1e2/src/ec/paymentPlanBuilder.js#L141-L149
train
faucet-pipeline/faucet-pipeline-static
index.js
determineTargetDir
function determineTargetDir(source, target) { return stat(source). then(results => results.isDirectory() ? target : path.dirname(target)); }
javascript
function determineTargetDir(source, target) { return stat(source). then(results => results.isDirectory() ? target : path.dirname(target)); }
[ "function", "determineTargetDir", "(", "source", ",", "target", ")", "{", "return", "stat", "(", "source", ")", ".", "then", "(", "results", "=>", "results", ".", "isDirectory", "(", ")", "?", "target", ":", "path", ".", "dirname", "(", "target", ")", ")", ";", "}" ]
If `source` is a directory, `target` is used as target directory - otherwise, `target`'s parent directory is used
[ "If", "source", "is", "a", "directory", "target", "is", "used", "as", "target", "directory", "-", "otherwise", "target", "s", "parent", "directory", "is", "used" ]
69cd6f6a8577b4ac095e6737aadfa27642df1a95
https://github.com/faucet-pipeline/faucet-pipeline-static/blob/69cd6f6a8577b4ac095e6737aadfa27642df1a95/index.js#L57-L60
train
jonschlinkert/benchmarked
index.js
Benchmarked
function Benchmarked(options) { if (!(this instanceof Benchmarked)) { return new Benchmarked(options); } Emitter.call(this); this.options = Object.assign({}, options); this.results = []; this.defaults(this); }
javascript
function Benchmarked(options) { if (!(this instanceof Benchmarked)) { return new Benchmarked(options); } Emitter.call(this); this.options = Object.assign({}, options); this.results = []; this.defaults(this); }
[ "function", "Benchmarked", "(", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "Benchmarked", ")", ")", "{", "return", "new", "Benchmarked", "(", "options", ")", ";", "}", "Emitter", ".", "call", "(", "this", ")", ";", "this", ".", "options", "=", "Object", ".", "assign", "(", "{", "}", ",", "options", ")", ";", "this", ".", "results", "=", "[", "]", ";", "this", ".", "defaults", "(", "this", ")", ";", "}" ]
Create an instance of Benchmarked with the given `options`. ```js const suite = new Suite(); ``` @param {Object} `options` @api public
[ "Create", "an", "instance", "of", "Benchmarked", "with", "the", "given", "options", "." ]
521fc9c2b86e0a0f0ea03ded855076aa98f16df0
https://github.com/jonschlinkert/benchmarked/blob/521fc9c2b86e0a0f0ea03ded855076aa98f16df0/index.js#L41-L49
train
kissyteam/kissy-xtemplate
lib/xtemplate/1.3.2/runtime.js
XTemplateRuntime
function XTemplateRuntime(tpl, option) { var self = this; self.tpl = tpl; option = S.merge(defaultConfig, option); option.subTpls = S.merge(option.subTpls, XTemplateRuntime.subTpls); option.commands = S.merge(option.commands, XTemplateRuntime.commands); this.option = option; }
javascript
function XTemplateRuntime(tpl, option) { var self = this; self.tpl = tpl; option = S.merge(defaultConfig, option); option.subTpls = S.merge(option.subTpls, XTemplateRuntime.subTpls); option.commands = S.merge(option.commands, XTemplateRuntime.commands); this.option = option; }
[ "function", "XTemplateRuntime", "(", "tpl", ",", "option", ")", "{", "var", "self", "=", "this", ";", "self", ".", "tpl", "=", "tpl", ";", "option", "=", "S", ".", "merge", "(", "defaultConfig", ",", "option", ")", ";", "option", ".", "subTpls", "=", "S", ".", "merge", "(", "option", ".", "subTpls", ",", "XTemplateRuntime", ".", "subTpls", ")", ";", "option", ".", "commands", "=", "S", ".", "merge", "(", "option", ".", "commands", ",", "XTemplateRuntime", ".", "commands", ")", ";", "this", ".", "option", "=", "option", ";", "}" ]
XTemplate runtime. only accept tpl as function. @example new XTemplateRuntime(tplFunction, config); @class KISSY.XTemplate.Runtime
[ "XTemplate", "runtime", ".", "only", "accept", "tpl", "as", "function", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/xtemplate/1.3.2/runtime.js#L109-L116
train
poegroup/poe-ui-kit
index.js
initFeatureFlags
function initFeatureFlags(enabled) { return function features(req, res, next) { if (req.get('x-env') !== 'production') return next(); if (enabled && enabled !== req.cookies.features) res.cookie('features', enabled); next(); }; }
javascript
function initFeatureFlags(enabled) { return function features(req, res, next) { if (req.get('x-env') !== 'production') return next(); if (enabled && enabled !== req.cookies.features) res.cookie('features', enabled); next(); }; }
[ "function", "initFeatureFlags", "(", "enabled", ")", "{", "return", "function", "features", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "get", "(", "'x-env'", ")", "!==", "'production'", ")", "return", "next", "(", ")", ";", "if", "(", "enabled", "&&", "enabled", "!==", "req", ".", "cookies", ".", "features", ")", "res", ".", "cookie", "(", "'features'", ",", "enabled", ")", ";", "next", "(", ")", ";", "}", ";", "}" ]
Initialize the feature flags middleware
[ "Initialize", "the", "feature", "flags", "middleware" ]
985daf3bfdc72c52da88affc77c8c6b41b44c6c2
https://github.com/poegroup/poe-ui-kit/blob/985daf3bfdc72c52da88affc77c8c6b41b44c6c2/index.js#L161-L167
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
function () { var self = this, attrs = self.getAttrs(), attr, m; for (attr in attrs) { m = ON_SET + ucfirst(attr); if (self[m]) { // 自动绑定事件到对应函数 self.on('after' + ucfirst(attr) + 'Change', onSetAttrChange); } } }
javascript
function () { var self = this, attrs = self.getAttrs(), attr, m; for (attr in attrs) { m = ON_SET + ucfirst(attr); if (self[m]) { // 自动绑定事件到对应函数 self.on('after' + ucfirst(attr) + 'Change', onSetAttrChange); } } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "attrs", "=", "self", ".", "getAttrs", "(", ")", ",", "attr", ",", "m", ";", "for", "(", "attr", "in", "attrs", ")", "{", "m", "=", "ON_SET", "+", "ucfirst", "(", "attr", ")", ";", "if", "(", "self", "[", "m", "]", ")", "{", "self", ".", "on", "(", "'after'", "+", "ucfirst", "(", "attr", ")", "+", "'Change'", ",", "onSetAttrChange", ")", ";", "}", "}", "}" ]
bind attribute change event @protected
[ "bind", "attribute", "change", "event" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L100-L109
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
function () { var self = this, cs = [], i, c = self.constructor, attrs = self.getAttrs(); while (c) { cs.push(c); c = c.superclass && c.superclass.constructor; } cs.reverse(); // from super class to sub class // from super class to sub class for (i = 0; i < cs.length; i++) { var ATTRS = cs[i].ATTRS || {}; for (var attributeName in ATTRS) { if (attributeName in attrs) { var attributeValue, onSetMethod; var onSetMethodName = ON_SET + ucfirst(attributeName); // 存在方法,并且用户设置了初始值或者存在默认值,就同步状态 // 存在方法,并且用户设置了初始值或者存在默认值,就同步状态 if ((onSetMethod = self[onSetMethodName]) && // 用户如果设置了显式不同步,就不同步, // 比如一些值从 html 中读取,不需要同步再次设置 attrs[attributeName].sync !== 0 && (attributeValue = self.get(attributeName)) !== undefined) { onSetMethod.call(self, attributeValue); } } } } }
javascript
function () { var self = this, cs = [], i, c = self.constructor, attrs = self.getAttrs(); while (c) { cs.push(c); c = c.superclass && c.superclass.constructor; } cs.reverse(); // from super class to sub class // from super class to sub class for (i = 0; i < cs.length; i++) { var ATTRS = cs[i].ATTRS || {}; for (var attributeName in ATTRS) { if (attributeName in attrs) { var attributeValue, onSetMethod; var onSetMethodName = ON_SET + ucfirst(attributeName); // 存在方法,并且用户设置了初始值或者存在默认值,就同步状态 // 存在方法,并且用户设置了初始值或者存在默认值,就同步状态 if ((onSetMethod = self[onSetMethodName]) && // 用户如果设置了显式不同步,就不同步, // 比如一些值从 html 中读取,不需要同步再次设置 attrs[attributeName].sync !== 0 && (attributeValue = self.get(attributeName)) !== undefined) { onSetMethod.call(self, attributeValue); } } } } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ",", "cs", "=", "[", "]", ",", "i", ",", "c", "=", "self", ".", "constructor", ",", "attrs", "=", "self", ".", "getAttrs", "(", ")", ";", "while", "(", "c", ")", "{", "cs", ".", "push", "(", "c", ")", ";", "c", "=", "c", ".", "superclass", "&&", "c", ".", "superclass", ".", "constructor", ";", "}", "cs", ".", "reverse", "(", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "cs", ".", "length", ";", "i", "++", ")", "{", "var", "ATTRS", "=", "cs", "[", "i", "]", ".", "ATTRS", "||", "{", "}", ";", "for", "(", "var", "attributeName", "in", "ATTRS", ")", "{", "if", "(", "attributeName", "in", "attrs", ")", "{", "var", "attributeValue", ",", "onSetMethod", ";", "var", "onSetMethodName", "=", "ON_SET", "+", "ucfirst", "(", "attributeName", ")", ";", "if", "(", "(", "onSetMethod", "=", "self", "[", "onSetMethodName", "]", ")", "&&", "attrs", "[", "attributeName", "]", ".", "sync", "!==", "0", "&&", "(", "attributeValue", "=", "self", ".", "get", "(", "attributeName", ")", ")", "!==", "undefined", ")", "{", "onSetMethod", ".", "call", "(", "self", ",", "attributeValue", ")", ";", "}", "}", "}", "}", "}" ]
sync attribute change event @protected
[ "sync", "attribute", "change", "event" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L114-L137
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
function (plugin) { var self = this; if (typeof plugin === 'function') { var Plugin = plugin; plugin = new Plugin(); } // initialize plugin //noinspection JSUnresolvedVariable // initialize plugin //noinspection JSUnresolvedVariable if (plugin.pluginInitializer) { // noinspection JSUnresolvedFunction plugin.pluginInitializer(self); } self.get('plugins').push(plugin); return self; }
javascript
function (plugin) { var self = this; if (typeof plugin === 'function') { var Plugin = plugin; plugin = new Plugin(); } // initialize plugin //noinspection JSUnresolvedVariable // initialize plugin //noinspection JSUnresolvedVariable if (plugin.pluginInitializer) { // noinspection JSUnresolvedFunction plugin.pluginInitializer(self); } self.get('plugins').push(plugin); return self; }
[ "function", "(", "plugin", ")", "{", "var", "self", "=", "this", ";", "if", "(", "typeof", "plugin", "===", "'function'", ")", "{", "var", "Plugin", "=", "plugin", ";", "plugin", "=", "new", "Plugin", "(", ")", ";", "}", "if", "(", "plugin", ".", "pluginInitializer", ")", "{", "plugin", ".", "pluginInitializer", "(", "self", ")", ";", "}", "self", ".", "get", "(", "'plugins'", ")", ".", "push", "(", "plugin", ")", ";", "return", "self", ";", "}" ]
plugin a new plugins to current instance @param {Function|Object} plugin @chainable
[ "plugin", "a", "new", "plugins", "to", "current", "instance" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L143-L158
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
function (plugin) { var plugins = [], self = this, isString = typeof plugin === 'string'; util.each(self.get('plugins'), function (p) { var keep = 0, pluginId; if (plugin) { if (isString) { // user defined takes priority pluginId = p.get && p.get('pluginId') || p.pluginId; if (pluginId !== plugin) { plugins.push(p); keep = 1; } } else { if (p !== plugin) { plugins.push(p); keep = 1; } } } if (!keep) { p.pluginDestructor(self); } }); self.setInternal('plugins', plugins); return self; }
javascript
function (plugin) { var plugins = [], self = this, isString = typeof plugin === 'string'; util.each(self.get('plugins'), function (p) { var keep = 0, pluginId; if (plugin) { if (isString) { // user defined takes priority pluginId = p.get && p.get('pluginId') || p.pluginId; if (pluginId !== plugin) { plugins.push(p); keep = 1; } } else { if (p !== plugin) { plugins.push(p); keep = 1; } } } if (!keep) { p.pluginDestructor(self); } }); self.setInternal('plugins', plugins); return self; }
[ "function", "(", "plugin", ")", "{", "var", "plugins", "=", "[", "]", ",", "self", "=", "this", ",", "isString", "=", "typeof", "plugin", "===", "'string'", ";", "util", ".", "each", "(", "self", ".", "get", "(", "'plugins'", ")", ",", "function", "(", "p", ")", "{", "var", "keep", "=", "0", ",", "pluginId", ";", "if", "(", "plugin", ")", "{", "if", "(", "isString", ")", "{", "pluginId", "=", "p", ".", "get", "&&", "p", ".", "get", "(", "'pluginId'", ")", "||", "p", ".", "pluginId", ";", "if", "(", "pluginId", "!==", "plugin", ")", "{", "plugins", ".", "push", "(", "p", ")", ";", "keep", "=", "1", ";", "}", "}", "else", "{", "if", "(", "p", "!==", "plugin", ")", "{", "plugins", ".", "push", "(", "p", ")", ";", "keep", "=", "1", ";", "}", "}", "}", "if", "(", "!", "keep", ")", "{", "p", ".", "pluginDestructor", "(", "self", ")", ";", "}", "}", ")", ";", "self", ".", "setInternal", "(", "'plugins'", ",", "plugins", ")", ";", "return", "self", ";", "}" ]
unplug by pluginId or plugin instance. if called with no parameter, then destroy all plugins. @param {Object|String} [plugin] @chainable
[ "unplug", "by", "pluginId", "or", "plugin", "instance", ".", "if", "called", "with", "no", "parameter", "then", "destroy", "all", "plugins", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L165-L190
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
function (id) { var plugin = null; util.each(this.get('plugins'), function (p) { // user defined takes priority var pluginId = p.get && p.get('pluginId') || p.pluginId; if (pluginId === id) { plugin = p; return false; } return undefined; }); return plugin; }
javascript
function (id) { var plugin = null; util.each(this.get('plugins'), function (p) { // user defined takes priority var pluginId = p.get && p.get('pluginId') || p.pluginId; if (pluginId === id) { plugin = p; return false; } return undefined; }); return plugin; }
[ "function", "(", "id", ")", "{", "var", "plugin", "=", "null", ";", "util", ".", "each", "(", "this", ".", "get", "(", "'plugins'", ")", ",", "function", "(", "p", ")", "{", "var", "pluginId", "=", "p", ".", "get", "&&", "p", ".", "get", "(", "'pluginId'", ")", "||", "p", ".", "pluginId", ";", "if", "(", "pluginId", "===", "id", ")", "{", "plugin", "=", "p", ";", "return", "false", ";", "}", "return", "undefined", ";", "}", ")", ";", "return", "plugin", ";", "}" ]
get specified plugin instance by id @param {String} id pluginId of plugin instance @return {Object}
[ "get", "specified", "plugin", "instance", "by", "id" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L196-L208
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/base-debug.js
onSetAttrChange
function onSetAttrChange(e) { var self = this, method; // ignore bubbling // ignore bubbling if (e.target === self) { method = self[ON_SET + e.type.slice(5).slice(0, -6)]; method.call(self, e.newVal, e); } }
javascript
function onSetAttrChange(e) { var self = this, method; // ignore bubbling // ignore bubbling if (e.target === self) { method = self[ON_SET + e.type.slice(5).slice(0, -6)]; method.call(self, e.newVal, e); } }
[ "function", "onSetAttrChange", "(", "e", ")", "{", "var", "self", "=", "this", ",", "method", ";", "if", "(", "e", ".", "target", "===", "self", ")", "{", "method", "=", "self", "[", "ON_SET", "+", "e", ".", "type", ".", "slice", "(", "5", ")", ".", "slice", "(", "0", ",", "-", "6", ")", "]", ";", "method", ".", "call", "(", "self", ",", "e", ".", "newVal", ",", "e", ")", ";", "}", "}" ]
The default set of attributes which will be available for instances of this class, and their configuration By default if the value is an object literal or an array it will be 'shallow' cloned, to protect the default value. for example: @example { x:{ value: // default value valueFn: // default function to get value getter: // getter function setter: // setter function } } @property ATTRS @member KISSY.Base @static @type {Object} The default set of attributes which will be available for instances of this class, and their configuration By default if the value is an object literal or an array it will be 'shallow' cloned, to protect the default value. for example: @example { x:{ value: // default value valueFn: // default function to get value getter: // getter function setter: // setter function } } @property ATTRS @member KISSY.Base @static @type {Object}
[ "The", "default", "set", "of", "attributes", "which", "will", "be", "available", "for", "instances", "of", "this", "class", "and", "their", "configuration" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/base-debug.js#L398-L405
train
craterdog-bali/js-bali-component-framework
src/abstractions/Component.js
Component
function Component(type, parameters) { this.getTypeId = function() { return type; }; this.getParameters = function() { return parameters; }; this.setParameters = function(newParameters) { parameters = newParameters; }; return this; }
javascript
function Component(type, parameters) { this.getTypeId = function() { return type; }; this.getParameters = function() { return parameters; }; this.setParameters = function(newParameters) { parameters = newParameters; }; return this; }
[ "function", "Component", "(", "type", ",", "parameters", ")", "{", "this", ".", "getTypeId", "=", "function", "(", ")", "{", "return", "type", ";", "}", ";", "this", ".", "getParameters", "=", "function", "(", ")", "{", "return", "parameters", ";", "}", ";", "this", ".", "setParameters", "=", "function", "(", "newParameters", ")", "{", "parameters", "=", "newParameters", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC FUNCTIONS This constructor creates a new component of the specified type with the optional parameters that are used to parameterize its type. @param {Number} type The type of component. @param {Parameters} parameters Optional parameters used to parameterize this component. @returns {Component} The new component.
[ "PUBLIC", "FUNCTIONS", "This", "constructor", "creates", "a", "new", "component", "of", "the", "specified", "type", "with", "the", "optional", "parameters", "that", "are", "used", "to", "parameterize", "its", "type", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/abstractions/Component.js#L29-L34
train
apostrophecms-legacy/apostrophe-people
public/js/editor.js
updateUsername
function updateUsername() { var $username = $el.findByName('username'); if ((!usernameFocused) && (snippet.username === undefined)) { var username = apos.slugify($firstName.val() + $lastName.val()); $.post(self._action + '/username-unique', { username: username }, function(data) { $username.val(data.username); }); } $username.on('focus', function() { usernameFocused = true; }); }
javascript
function updateUsername() { var $username = $el.findByName('username'); if ((!usernameFocused) && (snippet.username === undefined)) { var username = apos.slugify($firstName.val() + $lastName.val()); $.post(self._action + '/username-unique', { username: username }, function(data) { $username.val(data.username); }); } $username.on('focus', function() { usernameFocused = true; }); }
[ "function", "updateUsername", "(", ")", "{", "var", "$username", "=", "$el", ".", "findByName", "(", "'username'", ")", ";", "if", "(", "(", "!", "usernameFocused", ")", "&&", "(", "snippet", ".", "username", "===", "undefined", ")", ")", "{", "var", "username", "=", "apos", ".", "slugify", "(", "$firstName", ".", "val", "(", ")", "+", "$lastName", ".", "val", "(", ")", ")", ";", "$", ".", "post", "(", "self", ".", "_action", "+", "'/username-unique'", ",", "{", "username", ":", "username", "}", ",", "function", "(", "data", ")", "{", "$username", ".", "val", "(", "data", ".", "username", ")", ";", "}", ")", ";", "}", "$username", ".", "on", "(", "'focus'", ",", "function", "(", ")", "{", "usernameFocused", "=", "true", ";", "}", ")", ";", "}" ]
Keep updating the username suggestion until they focus that field. Of course we don't mess with existing usernames.
[ "Keep", "updating", "the", "username", "suggestion", "until", "they", "focus", "that", "field", ".", "Of", "course", "we", "don", "t", "mess", "with", "existing", "usernames", "." ]
06c359db5fdc30e6b71f005901e88da7f81e1422
https://github.com/apostrophecms-legacy/apostrophe-people/blob/06c359db5fdc30e6b71f005901e88da7f81e1422/public/js/editor.js#L90-L101
train
lyveminds/scamandrios
lib/marshal/index.js
getInnerType
function getInnerType(str){ var index = str.indexOf('('); return index > 0 ? str.substring(index + 1, str.length - 1) : str; }
javascript
function getInnerType(str){ var index = str.indexOf('('); return index > 0 ? str.substring(index + 1, str.length - 1) : str; }
[ "function", "getInnerType", "(", "str", ")", "{", "var", "index", "=", "str", ".", "indexOf", "(", "'('", ")", ";", "return", "index", ">", "0", "?", "str", ".", "substring", "(", "index", "+", "1", ",", "str", ".", "length", "-", "1", ")", ":", "str", ";", "}" ]
Returns the type string inside of the parentheses @private @memberOf Marshal
[ "Returns", "the", "type", "string", "inside", "of", "the", "parentheses" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/marshal/index.js#L44-L47
train
lyveminds/scamandrios
lib/marshal/index.js
getCompositeTypes
function getCompositeTypes(str){ var type = getInnerType(str); if (type === str) { return getType(str); } var types = type.split(','), i = 0, ret = [], typeLength = types.length; for(; i < typeLength; i += 1){ ret.push( parseTypeString(types[i]) ); } return ret; }
javascript
function getCompositeTypes(str){ var type = getInnerType(str); if (type === str) { return getType(str); } var types = type.split(','), i = 0, ret = [], typeLength = types.length; for(; i < typeLength; i += 1){ ret.push( parseTypeString(types[i]) ); } return ret; }
[ "function", "getCompositeTypes", "(", "str", ")", "{", "var", "type", "=", "getInnerType", "(", "str", ")", ";", "if", "(", "type", "===", "str", ")", "{", "return", "getType", "(", "str", ")", ";", "}", "var", "types", "=", "type", ".", "split", "(", "','", ")", ",", "i", "=", "0", ",", "ret", "=", "[", "]", ",", "typeLength", "=", "types", ".", "length", ";", "for", "(", ";", "i", "<", "typeLength", ";", "i", "+=", "1", ")", "{", "ret", ".", "push", "(", "parseTypeString", "(", "types", "[", "i", "]", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Returns an array of types for composite columns @private @memberOf Marshal
[ "Returns", "an", "array", "of", "types", "for", "composite", "columns" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/marshal/index.js#L54-L68
train
lyveminds/scamandrios
lib/marshal/index.js
parseTypeString
function parseTypeString(type){ if (type.indexOf('CompositeType') > -1){ return getCompositeTypes(type); } else if(type.indexOf('ReversedType') > -1){ return getType(getInnerType(type)); } else if(type.indexOf('org.apache.cassandra.db.marshal.SetType') > -1){ return getSetType(type); } else if(type.indexOf('org.apache.cassandra.db.marshal.ListType') > -1){ return getListType(type); } else if(type.indexOf('org.apache.cassandra.db.marshal.MapType') > -1){ return getMapType(type); } else if(type === null || type === undefined) { return 'BytesType'; } else { return getType(type); } }
javascript
function parseTypeString(type){ if (type.indexOf('CompositeType') > -1){ return getCompositeTypes(type); } else if(type.indexOf('ReversedType') > -1){ return getType(getInnerType(type)); } else if(type.indexOf('org.apache.cassandra.db.marshal.SetType') > -1){ return getSetType(type); } else if(type.indexOf('org.apache.cassandra.db.marshal.ListType') > -1){ return getListType(type); } else if(type.indexOf('org.apache.cassandra.db.marshal.MapType') > -1){ return getMapType(type); } else if(type === null || type === undefined) { return 'BytesType'; } else { return getType(type); } }
[ "function", "parseTypeString", "(", "type", ")", "{", "if", "(", "type", ".", "indexOf", "(", "'CompositeType'", ")", ">", "-", "1", ")", "{", "return", "getCompositeTypes", "(", "type", ")", ";", "}", "else", "if", "(", "type", ".", "indexOf", "(", "'ReversedType'", ")", ">", "-", "1", ")", "{", "return", "getType", "(", "getInnerType", "(", "type", ")", ")", ";", "}", "else", "if", "(", "type", ".", "indexOf", "(", "'org.apache.cassandra.db.marshal.SetType'", ")", ">", "-", "1", ")", "{", "return", "getSetType", "(", "type", ")", ";", "}", "else", "if", "(", "type", ".", "indexOf", "(", "'org.apache.cassandra.db.marshal.ListType'", ")", ">", "-", "1", ")", "{", "return", "getListType", "(", "type", ")", ";", "}", "else", "if", "(", "type", ".", "indexOf", "(", "'org.apache.cassandra.db.marshal.MapType'", ")", ">", "-", "1", ")", "{", "return", "getMapType", "(", "type", ")", ";", "}", "else", "if", "(", "type", "===", "null", "||", "type", "===", "undefined", ")", "{", "return", "'BytesType'", ";", "}", "else", "{", "return", "getType", "(", "type", ")", ";", "}", "}" ]
Parses the type string and decides what types to return @private @memberOf Marshal
[ "Parses", "the", "type", "string", "and", "decides", "what", "types", "to", "return" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/marshal/index.js#L75-L95
train
lyveminds/scamandrios
lib/marshal/index.js
compositeSerializer
function compositeSerializer(serializers){ return function(vals, sliceStart){ var i = 0, buffers = [], totalLength = 0, valLength = vals.length, val; if(!Array.isArray(vals)){ vals = [vals]; valLength = vals.length; } for(; i < valLength; i += 1){ if (Array.isArray(vals[i])){ val = [serializers[i](vals[i][0]), vals[i][1]]; totalLength += val[0].length + 3; } else { val = serializers[i](vals[i]); totalLength += val.length + 3; } buffers.push(val); } var buf = new Buffer(totalLength), buffersLength = buffers.length, writtenLength = 0, eoc, inclusive; i = 0; for(; i < buffersLength; i += 1){ val = buffers[i]; eoc = new Buffer('00', 'hex'); inclusive = true; if (Array.isArray(val)){ inclusive = val[1]; val = val[0]; if(inclusive){ if (sliceStart){ eoc = new Buffer('ff', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('01', 'hex'); } } else { if (sliceStart){ eoc = new Buffer('01', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('ff', 'hex'); } } } else if (i === buffersLength - 1){ if (sliceStart){ eoc = new Buffer('ff', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('01', 'hex'); } } buf.writeUInt16BE(val.length, writtenLength); writtenLength += 2; val.copy(buf, writtenLength, 0); writtenLength += val.length; eoc.copy(buf, writtenLength, 0); writtenLength += 1; } return buf; }; }
javascript
function compositeSerializer(serializers){ return function(vals, sliceStart){ var i = 0, buffers = [], totalLength = 0, valLength = vals.length, val; if(!Array.isArray(vals)){ vals = [vals]; valLength = vals.length; } for(; i < valLength; i += 1){ if (Array.isArray(vals[i])){ val = [serializers[i](vals[i][0]), vals[i][1]]; totalLength += val[0].length + 3; } else { val = serializers[i](vals[i]); totalLength += val.length + 3; } buffers.push(val); } var buf = new Buffer(totalLength), buffersLength = buffers.length, writtenLength = 0, eoc, inclusive; i = 0; for(; i < buffersLength; i += 1){ val = buffers[i]; eoc = new Buffer('00', 'hex'); inclusive = true; if (Array.isArray(val)){ inclusive = val[1]; val = val[0]; if(inclusive){ if (sliceStart){ eoc = new Buffer('ff', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('01', 'hex'); } } else { if (sliceStart){ eoc = new Buffer('01', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('ff', 'hex'); } } } else if (i === buffersLength - 1){ if (sliceStart){ eoc = new Buffer('ff', 'hex'); } else if (sliceStart === false){ eoc = new Buffer('01', 'hex'); } } buf.writeUInt16BE(val.length, writtenLength); writtenLength += 2; val.copy(buf, writtenLength, 0); writtenLength += val.length; eoc.copy(buf, writtenLength, 0); writtenLength += 1; } return buf; }; }
[ "function", "compositeSerializer", "(", "serializers", ")", "{", "return", "function", "(", "vals", ",", "sliceStart", ")", "{", "var", "i", "=", "0", ",", "buffers", "=", "[", "]", ",", "totalLength", "=", "0", ",", "valLength", "=", "vals", ".", "length", ",", "val", ";", "if", "(", "!", "Array", ".", "isArray", "(", "vals", ")", ")", "{", "vals", "=", "[", "vals", "]", ";", "valLength", "=", "vals", ".", "length", ";", "}", "for", "(", ";", "i", "<", "valLength", ";", "i", "+=", "1", ")", "{", "if", "(", "Array", ".", "isArray", "(", "vals", "[", "i", "]", ")", ")", "{", "val", "=", "[", "serializers", "[", "i", "]", "(", "vals", "[", "i", "]", "[", "0", "]", ")", ",", "vals", "[", "i", "]", "[", "1", "]", "]", ";", "totalLength", "+=", "val", "[", "0", "]", ".", "length", "+", "3", ";", "}", "else", "{", "val", "=", "serializers", "[", "i", "]", "(", "vals", "[", "i", "]", ")", ";", "totalLength", "+=", "val", ".", "length", "+", "3", ";", "}", "buffers", ".", "push", "(", "val", ")", ";", "}", "var", "buf", "=", "new", "Buffer", "(", "totalLength", ")", ",", "buffersLength", "=", "buffers", ".", "length", ",", "writtenLength", "=", "0", ",", "eoc", ",", "inclusive", ";", "i", "=", "0", ";", "for", "(", ";", "i", "<", "buffersLength", ";", "i", "+=", "1", ")", "{", "val", "=", "buffers", "[", "i", "]", ";", "eoc", "=", "new", "Buffer", "(", "'00'", ",", "'hex'", ")", ";", "inclusive", "=", "true", ";", "if", "(", "Array", ".", "isArray", "(", "val", ")", ")", "{", "inclusive", "=", "val", "[", "1", "]", ";", "val", "=", "val", "[", "0", "]", ";", "if", "(", "inclusive", ")", "{", "if", "(", "sliceStart", ")", "{", "eoc", "=", "new", "Buffer", "(", "'ff'", ",", "'hex'", ")", ";", "}", "else", "if", "(", "sliceStart", "===", "false", ")", "{", "eoc", "=", "new", "Buffer", "(", "'01'", ",", "'hex'", ")", ";", "}", "}", "else", "{", "if", "(", "sliceStart", ")", "{", "eoc", "=", "new", "Buffer", "(", "'01'", ",", "'hex'", ")", ";", "}", "else", "if", "(", "sliceStart", "===", "false", ")", "{", "eoc", "=", "new", "Buffer", "(", "'ff'", ",", "'hex'", ")", ";", "}", "}", "}", "else", "if", "(", "i", "===", "buffersLength", "-", "1", ")", "{", "if", "(", "sliceStart", ")", "{", "eoc", "=", "new", "Buffer", "(", "'ff'", ",", "'hex'", ")", ";", "}", "else", "if", "(", "sliceStart", "===", "false", ")", "{", "eoc", "=", "new", "Buffer", "(", "'01'", ",", "'hex'", ")", ";", "}", "}", "buf", ".", "writeUInt16BE", "(", "val", ".", "length", ",", "writtenLength", ")", ";", "writtenLength", "+=", "2", ";", "val", ".", "copy", "(", "buf", ",", "writtenLength", ",", "0", ")", ";", "writtenLength", "+=", "val", ".", "length", ";", "eoc", ".", "copy", "(", "buf", ",", "writtenLength", ",", "0", ")", ";", "writtenLength", "+=", "1", ";", "}", "return", "buf", ";", "}", ";", "}" ]
Creates a serializer for composite types @private @memberOf Marshal
[ "Creates", "a", "serializer", "for", "composite", "types" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/marshal/index.js#L102-L168
train
lyveminds/scamandrios
lib/marshal/index.js
compositeDeserializer
function compositeDeserializer(deserializers){ return function(str){ var buf = new Buffer(str, 'binary'), pos = 0, len, vals = [], i = 0; while( pos < buf.length){ len = buf.readUInt16BE(pos); pos += 2; vals.push(deserializers[i](buf.slice(pos, len + pos))); i += 1; pos += len + 1; } return vals; }; }
javascript
function compositeDeserializer(deserializers){ return function(str){ var buf = new Buffer(str, 'binary'), pos = 0, len, vals = [], i = 0; while( pos < buf.length){ len = buf.readUInt16BE(pos); pos += 2; vals.push(deserializers[i](buf.slice(pos, len + pos))); i += 1; pos += len + 1; } return vals; }; }
[ "function", "compositeDeserializer", "(", "deserializers", ")", "{", "return", "function", "(", "str", ")", "{", "var", "buf", "=", "new", "Buffer", "(", "str", ",", "'binary'", ")", ",", "pos", "=", "0", ",", "len", ",", "vals", "=", "[", "]", ",", "i", "=", "0", ";", "while", "(", "pos", "<", "buf", ".", "length", ")", "{", "len", "=", "buf", ".", "readUInt16BE", "(", "pos", ")", ";", "pos", "+=", "2", ";", "vals", ".", "push", "(", "deserializers", "[", "i", "]", "(", "buf", ".", "slice", "(", "pos", ",", "len", "+", "pos", ")", ")", ")", ";", "i", "+=", "1", ";", "pos", "+=", "len", "+", "1", ";", "}", "return", "vals", ";", "}", ";", "}" ]
Creates a deserializer for composite types @private @memberOf Marshal
[ "Creates", "a", "deserializer", "for", "composite", "types" ]
a1b643c68d3d88e608c610d4ce5f96e7142972cd
https://github.com/lyveminds/scamandrios/blob/a1b643c68d3d88e608c610d4ce5f96e7142972cd/lib/marshal/index.js#L175-L190
train
netbek/penrose
lib/penrose.js
function(uri) { const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } return uri; }
javascript
function(uri) { const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } return uri; }
[ "function", "(", "uri", ")", "{", "const", "scheme", "=", "this", ".", "getScheme", "(", "uri", ")", ";", "if", "(", "PUBLIC", "===", "scheme", "||", "TEMPORARY", "===", "scheme", ")", "{", "return", "'/'", "+", "this", ".", "resolvePath", "(", "uri", ")", ";", "}", "return", "uri", ";", "}" ]
Returns absolute URL. @param {string} uri @returns {string}
[ "Returns", "absolute", "URL", "." ]
d68cd2340684dc97e6093b3380de72fb85d949d5
https://github.com/netbek/penrose/blob/d68cd2340684dc97e6093b3380de72fb85d949d5/lib/penrose.js#L412-L420
train
netbek/penrose
lib/penrose.js
function(styleName, path, format) { const uri = this.getStylePath(styleName, path, format); const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } throw new Error('Scheme `' + scheme + '` not supported'); }
javascript
function(styleName, path, format) { const uri = this.getStylePath(styleName, path, format); const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } throw new Error('Scheme `' + scheme + '` not supported'); }
[ "function", "(", "styleName", ",", "path", ",", "format", ")", "{", "const", "uri", "=", "this", ".", "getStylePath", "(", "styleName", ",", "path", ",", "format", ")", ";", "const", "scheme", "=", "this", ".", "getScheme", "(", "uri", ")", ";", "if", "(", "PUBLIC", "===", "scheme", "||", "TEMPORARY", "===", "scheme", ")", "{", "return", "'/'", "+", "this", ".", "resolvePath", "(", "uri", ")", ";", "}", "throw", "new", "Error", "(", "'Scheme `'", "+", "scheme", "+", "'` not supported'", ")", ";", "}" ]
Returns absolute URL to derivative image. @param {string} styleName @param {string} path @param {string} format @returns {string}
[ "Returns", "absolute", "URL", "to", "derivative", "image", "." ]
d68cd2340684dc97e6093b3380de72fb85d949d5
https://github.com/netbek/penrose/blob/d68cd2340684dc97e6093b3380de72fb85d949d5/lib/penrose.js#L476-L485
train
eface2face/meteor-observe-sequence
observe_sequence.js
function (sequenceFunc, callbacks) { var lastSeq = null; var activeObserveHandle = null; // 'lastSeqArray' contains the previous value of the sequence // we're observing. It is an array of objects with '_id' and // 'item' fields. 'item' is the element in the array, or the // document in the cursor. // // '_id' is whichever of the following is relevant, unless it has // already appeared -- in which case it's randomly generated. // // * if 'item' is an object: // * an '_id' field, if present // * otherwise, the index in the array // // * if 'item' is a number or string, use that value // // XXX this can be generalized by allowing {{#each}} to accept a // general 'key' argument which could be a function, a dotted // field name, or the special @index value. var lastSeqArray = []; // elements are objects of form {_id, item} var computation = Tracker.autorun(function () { var seq = sequenceFunc(); Tracker.nonreactive(function () { var seqArray; // same structure as `lastSeqArray` above. if (activeObserveHandle) { // If we were previously observing a cursor, replace lastSeqArray with // more up-to-date information. Then stop the old observe. lastSeqArray = _.map(lastSeq.fetch(), function (doc) { return {_id: doc._id, item: doc}; }); activeObserveHandle.stop(); activeObserveHandle = null; } if (!seq) { seqArray = seqChangedToEmpty(lastSeqArray, callbacks); } else if (seq instanceof Array) { seqArray = seqChangedToArray(lastSeqArray, seq, callbacks); } else if (isStoreCursor(seq)) { var result /* [seqArray, activeObserveHandle] */ = seqChangedToCursor(lastSeqArray, seq, callbacks); seqArray = result[0]; activeObserveHandle = result[1]; } else { throw badSequenceError(); } diffArray(lastSeqArray, seqArray, callbacks); lastSeq = seq; lastSeqArray = seqArray; }); }); return { stop: function () { computation.stop(); if (activeObserveHandle) activeObserveHandle.stop(); } }; }
javascript
function (sequenceFunc, callbacks) { var lastSeq = null; var activeObserveHandle = null; // 'lastSeqArray' contains the previous value of the sequence // we're observing. It is an array of objects with '_id' and // 'item' fields. 'item' is the element in the array, or the // document in the cursor. // // '_id' is whichever of the following is relevant, unless it has // already appeared -- in which case it's randomly generated. // // * if 'item' is an object: // * an '_id' field, if present // * otherwise, the index in the array // // * if 'item' is a number or string, use that value // // XXX this can be generalized by allowing {{#each}} to accept a // general 'key' argument which could be a function, a dotted // field name, or the special @index value. var lastSeqArray = []; // elements are objects of form {_id, item} var computation = Tracker.autorun(function () { var seq = sequenceFunc(); Tracker.nonreactive(function () { var seqArray; // same structure as `lastSeqArray` above. if (activeObserveHandle) { // If we were previously observing a cursor, replace lastSeqArray with // more up-to-date information. Then stop the old observe. lastSeqArray = _.map(lastSeq.fetch(), function (doc) { return {_id: doc._id, item: doc}; }); activeObserveHandle.stop(); activeObserveHandle = null; } if (!seq) { seqArray = seqChangedToEmpty(lastSeqArray, callbacks); } else if (seq instanceof Array) { seqArray = seqChangedToArray(lastSeqArray, seq, callbacks); } else if (isStoreCursor(seq)) { var result /* [seqArray, activeObserveHandle] */ = seqChangedToCursor(lastSeqArray, seq, callbacks); seqArray = result[0]; activeObserveHandle = result[1]; } else { throw badSequenceError(); } diffArray(lastSeqArray, seqArray, callbacks); lastSeq = seq; lastSeqArray = seqArray; }); }); return { stop: function () { computation.stop(); if (activeObserveHandle) activeObserveHandle.stop(); } }; }
[ "function", "(", "sequenceFunc", ",", "callbacks", ")", "{", "var", "lastSeq", "=", "null", ";", "var", "activeObserveHandle", "=", "null", ";", "var", "lastSeqArray", "=", "[", "]", ";", "var", "computation", "=", "Tracker", ".", "autorun", "(", "function", "(", ")", "{", "var", "seq", "=", "sequenceFunc", "(", ")", ";", "Tracker", ".", "nonreactive", "(", "function", "(", ")", "{", "var", "seqArray", ";", "if", "(", "activeObserveHandle", ")", "{", "lastSeqArray", "=", "_", ".", "map", "(", "lastSeq", ".", "fetch", "(", ")", ",", "function", "(", "doc", ")", "{", "return", "{", "_id", ":", "doc", ".", "_id", ",", "item", ":", "doc", "}", ";", "}", ")", ";", "activeObserveHandle", ".", "stop", "(", ")", ";", "activeObserveHandle", "=", "null", ";", "}", "if", "(", "!", "seq", ")", "{", "seqArray", "=", "seqChangedToEmpty", "(", "lastSeqArray", ",", "callbacks", ")", ";", "}", "else", "if", "(", "seq", "instanceof", "Array", ")", "{", "seqArray", "=", "seqChangedToArray", "(", "lastSeqArray", ",", "seq", ",", "callbacks", ")", ";", "}", "else", "if", "(", "isStoreCursor", "(", "seq", ")", ")", "{", "var", "result", "=", "seqChangedToCursor", "(", "lastSeqArray", ",", "seq", ",", "callbacks", ")", ";", "seqArray", "=", "result", "[", "0", "]", ";", "activeObserveHandle", "=", "result", "[", "1", "]", ";", "}", "else", "{", "throw", "badSequenceError", "(", ")", ";", "}", "diffArray", "(", "lastSeqArray", ",", "seqArray", ",", "callbacks", ")", ";", "lastSeq", "=", "seq", ";", "lastSeqArray", "=", "seqArray", ";", "}", ")", ";", "}", ")", ";", "return", "{", "stop", ":", "function", "(", ")", "{", "computation", ".", "stop", "(", ")", ";", "if", "(", "activeObserveHandle", ")", "activeObserveHandle", ".", "stop", "(", ")", ";", "}", "}", ";", "}" ]
A mechanism similar to cursor.observe which receives a reactive function returning a sequence type and firing appropriate callbacks when the value changes. @param sequenceFunc {Function} a reactive function returning a sequence type. The currently supported sequence types are: Array, Cursor, and null. @param callbacks {Object} similar to a specific subset of callbacks passed to `cursor.observe` (http://docs.meteor.com/#observe), with minor variations to support the fact that not all sequences contain objects with _id fields. Specifically: * addedAt(id, item, atIndex, beforeId) * changedAt(id, newItem, oldItem, atIndex) * removedAt(id, oldItem, atIndex) * movedTo(id, item, fromIndex, toIndex, beforeId) @returns {Object(stop: Function)} call 'stop' on the return value to stop observing this sequence function. We don't make any assumptions about our ability to compare sequence elements (ie, we don't assume EJSON.equals works; maybe there is extra state/random methods on the objects) so unlike cursor.observe, we may sometimes call changedAt() when nothing actually changed. XXX consider if we *can* make the stronger assumption and avoid no-op changedAt calls (in some cases?) XXX currently only supports the callbacks used by our implementation of {{#each}}, but this can be expanded. XXX #each doesn't use the indices (though we'll eventually need a way to get them when we support `@index`), but calling `cursor.observe` causes the index to be calculated on every callback using a linear scan (unless you turn it off by passing `_no_indices`). Any way to avoid calculating indices on a pure cursor observe like we used to?
[ "A", "mechanism", "similar", "to", "cursor", ".", "observe", "which", "receives", "a", "reactive", "function", "returning", "a", "sequence", "type", "and", "firing", "appropriate", "callbacks", "when", "the", "value", "changes", "." ]
df002d472b858c441700600facdea4154a26f77f
https://github.com/eface2face/meteor-observe-sequence/blob/df002d472b858c441700600facdea4154a26f77f/observe_sequence.js#L150-L214
train
eface2face/meteor-observe-sequence
observe_sequence.js
function (seq) { if (!seq) { return []; } else if (seq instanceof Array) { return seq; } else if (isStoreCursor(seq)) { return seq.fetch(); } else { throw badSequenceError(); } }
javascript
function (seq) { if (!seq) { return []; } else if (seq instanceof Array) { return seq; } else if (isStoreCursor(seq)) { return seq.fetch(); } else { throw badSequenceError(); } }
[ "function", "(", "seq", ")", "{", "if", "(", "!", "seq", ")", "{", "return", "[", "]", ";", "}", "else", "if", "(", "seq", "instanceof", "Array", ")", "{", "return", "seq", ";", "}", "else", "if", "(", "isStoreCursor", "(", "seq", ")", ")", "{", "return", "seq", ".", "fetch", "(", ")", ";", "}", "else", "{", "throw", "badSequenceError", "(", ")", ";", "}", "}" ]
Fetch the items of `seq` into an array, where `seq` is of one of the sequence types accepted by `observe`. If `seq` is a cursor, a dependency is established.
[ "Fetch", "the", "items", "of", "seq", "into", "an", "array", "where", "seq", "is", "of", "one", "of", "the", "sequence", "types", "accepted", "by", "observe", ".", "If", "seq", "is", "a", "cursor", "a", "dependency", "is", "established", "." ]
df002d472b858c441700600facdea4154a26f77f
https://github.com/eface2face/meteor-observe-sequence/blob/df002d472b858c441700600facdea4154a26f77f/observe_sequence.js#L219-L229
train
KleeGroup/focus-notifications
src/index.js
NotificationCenterDev
function NotificationCenterDev({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <div> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleClick} panelHeader={panelHeader} panelFooter={panelFooter} /> <DevTools /> </div> </Provider> ); }
javascript
function NotificationCenterDev({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <div> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleClick} panelHeader={panelHeader} panelFooter={panelFooter} /> <DevTools /> </div> </Provider> ); }
[ "function", "NotificationCenterDev", "(", "{", "iconName", ",", "onSingleClick", ",", "store", ",", "panelFooter", ",", "panelHeader", "}", ")", "{", "return", "(", "<", "Provider", "store", "=", "{", "store", "}", ">", " ", "<", "div", ">", " ", "<", "NotificationCenter", "iconName", "=", "{", "iconName", "}", "hasAddNotif", "=", "{", "false", "}", "onSingleClick", "=", "{", "onSingleClick", "}", "panelHeader", "=", "{", "panelHeader", "}", "panelFooter", "=", "{", "panelFooter", "}", "/", ">", " ", "<", "DevTools", "/", ">", " ", "<", "/", "div", ">", " ", "<", "/", "Provider", ">", ")", ";", "}" ]
Render notification center in dev mode. @param {object} props props. @returns {JsxElement} element.
[ "Render", "notification", "center", "in", "dev", "mode", "." ]
b9a529264b625a12c3d8d479f839f36f77b674f6
https://github.com/KleeGroup/focus-notifications/blob/b9a529264b625a12c3d8d479f839f36f77b674f6/src/index.js#L19-L34
train
KleeGroup/focus-notifications
src/index.js
NotificationCenterProd
function NotificationCenterProd({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleClick} panelHeader={panelHeader} panelFooter={panelFooter} /> </Provider> ); }
javascript
function NotificationCenterProd({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleClick} panelHeader={panelHeader} panelFooter={panelFooter} /> </Provider> ); }
[ "function", "NotificationCenterProd", "(", "{", "iconName", ",", "onSingleClick", ",", "store", ",", "panelFooter", ",", "panelHeader", "}", ")", "{", "return", "(", "<", "Provider", "store", "=", "{", "store", "}", ">", " ", "<", "NotificationCenter", "iconName", "=", "{", "iconName", "}", "hasAddNotif", "=", "{", "false", "}", "onSingleClick", "=", "{", "onSingleClick", "}", "panelHeader", "=", "{", "panelHeader", "}", "panelFooter", "=", "{", "panelFooter", "}", "/", ">", " ", "<", "/", "Provider", ">", ")", ";", "}" ]
Render notification center in production mode. @param {object} props props. @returns {JsxElement} element.
[ "Render", "notification", "center", "in", "production", "mode", "." ]
b9a529264b625a12c3d8d479f839f36f77b674f6
https://github.com/KleeGroup/focus-notifications/blob/b9a529264b625a12c3d8d479f839f36f77b674f6/src/index.js#L53-L65
train
Automattic/wpcom-unpublished
lib/site.post.subscriber.js
Subscriber
function Subscriber( pid, sid, wpcom ) { if ( ! sid ) { throw new Error( '`side id` is not correctly defined' ); } if ( ! pid ) { throw new Error( '`post id` is not correctly defined' ); } if ( ! ( this instanceof Subscriber ) ) { return new Subscriber( pid, sid, wpcom ); } this.wpcom = wpcom; this._pid = pid; this._sid = sid; }
javascript
function Subscriber( pid, sid, wpcom ) { if ( ! sid ) { throw new Error( '`side id` is not correctly defined' ); } if ( ! pid ) { throw new Error( '`post id` is not correctly defined' ); } if ( ! ( this instanceof Subscriber ) ) { return new Subscriber( pid, sid, wpcom ); } this.wpcom = wpcom; this._pid = pid; this._sid = sid; }
[ "function", "Subscriber", "(", "pid", ",", "sid", ",", "wpcom", ")", "{", "if", "(", "!", "sid", ")", "{", "throw", "new", "Error", "(", "'`side id` is not correctly defined'", ")", ";", "}", "if", "(", "!", "pid", ")", "{", "throw", "new", "Error", "(", "'`post id` is not correctly defined'", ")", ";", "}", "if", "(", "!", "(", "this", "instanceof", "Subscriber", ")", ")", "{", "return", "new", "Subscriber", "(", "pid", ",", "sid", ",", "wpcom", ")", ";", "}", "this", ".", "wpcom", "=", "wpcom", ";", "this", ".", "_pid", "=", "pid", ";", "this", ".", "_sid", "=", "sid", ";", "}" ]
`Subscriber` constructor. @param {String} pid - post identifier @param {String} sid - site identifier @param {WPCOM} wpcom - wpcom instance @api public
[ "Subscriber", "constructor", "." ]
9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e
https://github.com/Automattic/wpcom-unpublished/blob/9d3112f0e647cf2a9d5a9aa5fc1d7cda66ef185e/lib/site.post.subscriber.js#L10-L26
train
cainus/detour
route.js
Route
function Route(path, resource, options) { options = options || {}; this.path = path; this.resource = resource; this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
javascript
function Route(path, resource, options) { options = options || {}; this.path = path; this.resource = resource; this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
[ "function", "Route", "(", "path", ",", "resource", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "this", ".", "path", "=", "path", ";", "this", ".", "resource", "=", "resource", ";", "this", ".", "regexp", "=", "pathRegexp", "(", "path", ",", "this", ".", "keys", "=", "[", "]", ",", "options", ".", "sensitive", ",", "options", ".", "strict", ")", ";", "}" ]
Initialize `Route` with the given HTTP `path`, `resource`, and `options`. Options: - `sensitive` enable case-sensitive routes - `strict` enable strict matching for trailing slashes @param {String} path @param {Object} resource @param {Object} options @api private
[ "Initialize", "Route", "with", "the", "given", "HTTP", "path", "resource", "and", "options", "." ]
ee7a1b33ed61f7da3defa6e23cea65e8babbda0e
https://github.com/cainus/detour/blob/ee7a1b33ed61f7da3defa6e23cea65e8babbda0e/route.js#L25-L33
train
goliatone/core.io-pubsub-mqtt
lib/init.js
$createClient
function $createClient(options) { /* * Ensure we have default options. */ options = extend({}, {}, options); const { url, transport } = options; if (_clients[url]) { return _clients[url]; } const client = mqtt.connect(url, transport); _clients[url] = client; return client; }
javascript
function $createClient(options) { /* * Ensure we have default options. */ options = extend({}, {}, options); const { url, transport } = options; if (_clients[url]) { return _clients[url]; } const client = mqtt.connect(url, transport); _clients[url] = client; return client; }
[ "function", "$createClient", "(", "options", ")", "{", "options", "=", "extend", "(", "{", "}", ",", "{", "}", ",", "options", ")", ";", "const", "{", "url", ",", "transport", "}", "=", "options", ";", "if", "(", "_clients", "[", "url", "]", ")", "{", "return", "_clients", "[", "url", "]", ";", "}", "const", "client", "=", "mqtt", ".", "connect", "(", "url", ",", "transport", ")", ";", "_clients", "[", "url", "]", "=", "client", ";", "return", "client", ";", "}" ]
Factory function to create MQTT client. The default factory creates a regular MQTT.js client. @param {Object} options MQTT configuration object
[ "Factory", "function", "to", "create", "MQTT", "client", ".", "The", "default", "factory", "creates", "a", "regular", "MQTT", ".", "js", "client", "." ]
aecb67a4d2715c712292ca61f8722eb62ab21f88
https://github.com/goliatone/core.io-pubsub-mqtt/blob/aecb67a4d2715c712292ca61f8722eb62ab21f88/lib/init.js#L39-L56
train
JS-DevTools/browserify-banner
lib/index.js
browserifyBanner
function browserifyBanner (browserify, options) { options = options || {}; if (typeof browserify === "string") { // browserify-banner was loaded as a transform, not a plug-in. // So return a stream that does nothing. return through(); } browserify.on("package", setPackageOption); browserify.on("file", setFileOption); browserify.on("bundle", wrapBundle); browserify.on("reset", wrapBundle); /** * If the `pkg` option isn't set, then it defaults to the first package that's read * * @param {object} pkg - The parsed package.json file */ function setPackageOption (pkg) { if (!options.pkg) { options.pkg = pkg; } } /** * If the `file` option isn't set, then it defaults to "banner.txt" in the same directory * as the first entry file. We'll crawl up the directory tree from there if necessary. * * @param {string} file - The full file path */ function setFileOption (file) { if (!options.file) { options.file = path.join(path.dirname(file), "banner.txt"); } } /** * Adds transforms to the Browserify "wrap" pipeline */ function wrapBundle () { let wrap = browserify.pipeline.get("wrap"); let bannerAlreadyAdded = false; let banner; wrap.push(through(addBannerToBundle)); if (browserify._options.debug) { wrap.push(through(addBannerToSourcemap)); } /** * Injects the banner comment block into the Browserify bundle */ function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); } /** * Adjusts the sourcemap to account for the banner comment block */ function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); } } }
javascript
function browserifyBanner (browserify, options) { options = options || {}; if (typeof browserify === "string") { // browserify-banner was loaded as a transform, not a plug-in. // So return a stream that does nothing. return through(); } browserify.on("package", setPackageOption); browserify.on("file", setFileOption); browserify.on("bundle", wrapBundle); browserify.on("reset", wrapBundle); /** * If the `pkg` option isn't set, then it defaults to the first package that's read * * @param {object} pkg - The parsed package.json file */ function setPackageOption (pkg) { if (!options.pkg) { options.pkg = pkg; } } /** * If the `file` option isn't set, then it defaults to "banner.txt" in the same directory * as the first entry file. We'll crawl up the directory tree from there if necessary. * * @param {string} file - The full file path */ function setFileOption (file) { if (!options.file) { options.file = path.join(path.dirname(file), "banner.txt"); } } /** * Adds transforms to the Browserify "wrap" pipeline */ function wrapBundle () { let wrap = browserify.pipeline.get("wrap"); let bannerAlreadyAdded = false; let banner; wrap.push(through(addBannerToBundle)); if (browserify._options.debug) { wrap.push(through(addBannerToSourcemap)); } /** * Injects the banner comment block into the Browserify bundle */ function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); } /** * Adjusts the sourcemap to account for the banner comment block */ function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); } } }
[ "function", "browserifyBanner", "(", "browserify", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "if", "(", "typeof", "browserify", "===", "\"string\"", ")", "{", "return", "through", "(", ")", ";", "}", "browserify", ".", "on", "(", "\"package\"", ",", "setPackageOption", ")", ";", "browserify", ".", "on", "(", "\"file\"", ",", "setFileOption", ")", ";", "browserify", ".", "on", "(", "\"bundle\"", ",", "wrapBundle", ")", ";", "browserify", ".", "on", "(", "\"reset\"", ",", "wrapBundle", ")", ";", "function", "setPackageOption", "(", "pkg", ")", "{", "if", "(", "!", "options", ".", "pkg", ")", "{", "options", ".", "pkg", "=", "pkg", ";", "}", "}", "function", "setFileOption", "(", "file", ")", "{", "if", "(", "!", "options", ".", "file", ")", "{", "options", ".", "file", "=", "path", ".", "join", "(", "path", ".", "dirname", "(", "file", ")", ",", "\"banner.txt\"", ")", ";", "}", "}", "function", "wrapBundle", "(", ")", "{", "let", "wrap", "=", "browserify", ".", "pipeline", ".", "get", "(", "\"wrap\"", ")", ";", "let", "bannerAlreadyAdded", "=", "false", ";", "let", "banner", ";", "wrap", ".", "push", "(", "through", "(", "addBannerToBundle", ")", ")", ";", "if", "(", "browserify", ".", "_options", ".", "debug", ")", "{", "wrap", ".", "push", "(", "through", "(", "addBannerToSourcemap", ")", ")", ";", "}", "function", "addBannerToBundle", "(", "chunk", ",", "enc", ",", "next", ")", "{", "if", "(", "!", "bannerAlreadyAdded", ")", "{", "bannerAlreadyAdded", "=", "true", ";", "try", "{", "banner", "=", "getBanner", "(", "options", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "banner", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "next", "(", "e", ")", ";", "}", "}", "this", ".", "push", "(", "chunk", ")", ";", "next", "(", ")", ";", "}", "function", "addBannerToSourcemap", "(", "chunk", ",", "enc", ",", "next", ")", "{", "let", "pushed", "=", "false", ";", "if", "(", "banner", ")", "{", "let", "conv", "=", "convertSourcemap", ".", "fromSource", "(", "chunk", ".", "toString", "(", "\"utf8\"", ")", ")", ";", "if", "(", "conv", ")", "{", "let", "offsetMap", "=", "offsetSourcemap", "(", "conv", ".", "toObject", "(", ")", ",", "countLines", "(", "banner", ")", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "\"\\n\"", "+", "\\n", "+", "convertSourcemap", ".", "fromObject", "(", "offsetMap", ")", ".", "toComment", "(", ")", ")", ")", ";", "\"\\n\"", "}", "}", "\\n", "pushed", "=", "true", ";", "}", "}", "}" ]
Browserify plugin that adds a banner comment block to the top of the bundle. @param {Browserify} browserify - The Browserify instance @param {object} options - The plugin options
[ "Browserify", "plugin", "that", "adds", "a", "banner", "comment", "block", "to", "the", "top", "of", "the", "bundle", "." ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L20-L113
train
JS-DevTools/browserify-banner
lib/index.js
setFileOption
function setFileOption (file) { if (!options.file) { options.file = path.join(path.dirname(file), "banner.txt"); } }
javascript
function setFileOption (file) { if (!options.file) { options.file = path.join(path.dirname(file), "banner.txt"); } }
[ "function", "setFileOption", "(", "file", ")", "{", "if", "(", "!", "options", ".", "file", ")", "{", "options", ".", "file", "=", "path", ".", "join", "(", "path", ".", "dirname", "(", "file", ")", ",", "\"banner.txt\"", ")", ";", "}", "}" ]
If the `file` option isn't set, then it defaults to "banner.txt" in the same directory as the first entry file. We'll crawl up the directory tree from there if necessary. @param {string} file - The full file path
[ "If", "the", "file", "option", "isn", "t", "set", "then", "it", "defaults", "to", "banner", ".", "txt", "in", "the", "same", "directory", "as", "the", "first", "entry", "file", ".", "We", "ll", "crawl", "up", "the", "directory", "tree", "from", "there", "if", "necessary", "." ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L51-L55
train
JS-DevTools/browserify-banner
lib/index.js
wrapBundle
function wrapBundle () { let wrap = browserify.pipeline.get("wrap"); let bannerAlreadyAdded = false; let banner; wrap.push(through(addBannerToBundle)); if (browserify._options.debug) { wrap.push(through(addBannerToSourcemap)); } /** * Injects the banner comment block into the Browserify bundle */ function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); } /** * Adjusts the sourcemap to account for the banner comment block */ function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); } }
javascript
function wrapBundle () { let wrap = browserify.pipeline.get("wrap"); let bannerAlreadyAdded = false; let banner; wrap.push(through(addBannerToBundle)); if (browserify._options.debug) { wrap.push(through(addBannerToSourcemap)); } /** * Injects the banner comment block into the Browserify bundle */ function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); } /** * Adjusts the sourcemap to account for the banner comment block */ function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); } }
[ "function", "wrapBundle", "(", ")", "{", "let", "wrap", "=", "browserify", ".", "pipeline", ".", "get", "(", "\"wrap\"", ")", ";", "let", "bannerAlreadyAdded", "=", "false", ";", "let", "banner", ";", "wrap", ".", "push", "(", "through", "(", "addBannerToBundle", ")", ")", ";", "if", "(", "browserify", ".", "_options", ".", "debug", ")", "{", "wrap", ".", "push", "(", "through", "(", "addBannerToSourcemap", ")", ")", ";", "}", "function", "addBannerToBundle", "(", "chunk", ",", "enc", ",", "next", ")", "{", "if", "(", "!", "bannerAlreadyAdded", ")", "{", "bannerAlreadyAdded", "=", "true", ";", "try", "{", "banner", "=", "getBanner", "(", "options", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "banner", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "next", "(", "e", ")", ";", "}", "}", "this", ".", "push", "(", "chunk", ")", ";", "next", "(", ")", ";", "}", "function", "addBannerToSourcemap", "(", "chunk", ",", "enc", ",", "next", ")", "{", "let", "pushed", "=", "false", ";", "if", "(", "banner", ")", "{", "let", "conv", "=", "convertSourcemap", ".", "fromSource", "(", "chunk", ".", "toString", "(", "\"utf8\"", ")", ")", ";", "if", "(", "conv", ")", "{", "let", "offsetMap", "=", "offsetSourcemap", "(", "conv", ".", "toObject", "(", ")", ",", "countLines", "(", "banner", ")", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "\"\\n\"", "+", "\\n", "+", "convertSourcemap", ".", "fromObject", "(", "offsetMap", ")", ".", "toComment", "(", ")", ")", ")", ";", "\"\\n\"", "}", "}", "\\n", "pushed", "=", "true", ";", "}", "}" ]
Adds transforms to the Browserify "wrap" pipeline
[ "Adds", "transforms", "to", "the", "Browserify", "wrap", "pipeline" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L60-L112
train
JS-DevTools/browserify-banner
lib/index.js
addBannerToBundle
function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); }
javascript
function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); }
[ "function", "addBannerToBundle", "(", "chunk", ",", "enc", ",", "next", ")", "{", "if", "(", "!", "bannerAlreadyAdded", ")", "{", "bannerAlreadyAdded", "=", "true", ";", "try", "{", "banner", "=", "getBanner", "(", "options", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "banner", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "next", "(", "e", ")", ";", "}", "}", "this", ".", "push", "(", "chunk", ")", ";", "next", "(", ")", ";", "}" ]
Injects the banner comment block into the Browserify bundle
[ "Injects", "the", "banner", "comment", "block", "into", "the", "Browserify", "bundle" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L73-L86
train
JS-DevTools/browserify-banner
lib/index.js
addBannerToSourcemap
function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); }
javascript
function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner)); this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n")); pushed = true; } } if (!pushed) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this.push(chunk); } next(); }
[ "function", "addBannerToSourcemap", "(", "chunk", ",", "enc", ",", "next", ")", "{", "let", "pushed", "=", "false", ";", "if", "(", "banner", ")", "{", "let", "conv", "=", "convertSourcemap", ".", "fromSource", "(", "chunk", ".", "toString", "(", "\"utf8\"", ")", ")", ";", "if", "(", "conv", ")", "{", "let", "offsetMap", "=", "offsetSourcemap", "(", "conv", ".", "toObject", "(", ")", ",", "countLines", "(", "banner", ")", ")", ";", "this", ".", "push", "(", "new", "Buffer", "(", "\"\\n\"", "+", "\\n", "+", "convertSourcemap", ".", "fromObject", "(", "offsetMap", ")", ".", "toComment", "(", ")", ")", ")", ";", "\"\\n\"", "}", "}", "\\n", "pushed", "=", "true", ";", "}" ]
Adjusts the sourcemap to account for the banner comment block
[ "Adjusts", "the", "sourcemap", "to", "account", "for", "the", "banner", "comment", "block" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L91-L111
train
JS-DevTools/browserify-banner
lib/index.js
getBanner
function getBanner (options) { if (!options.banner) { if (typeof options.pkg === "string") { // Read the package.json file options.pkg = readJSON(options.pkg); } if (!options.template) { // Read the banner template from a file options.template = findFile(options.file); } if (options.template) { // Compile the banner template options.banner = _.template(options.template)({ moment, pkg: options.pkg, }); // Convert the banner to a comment block, if it's not already if (!/^\s*(\/\/|\/\*)/.test(options.banner)) { options.banner = "/*!\n * " + options.banner.trim().replace(/\n/g, "\n * ") + "\n */\n"; } } } return options.banner; }
javascript
function getBanner (options) { if (!options.banner) { if (typeof options.pkg === "string") { // Read the package.json file options.pkg = readJSON(options.pkg); } if (!options.template) { // Read the banner template from a file options.template = findFile(options.file); } if (options.template) { // Compile the banner template options.banner = _.template(options.template)({ moment, pkg: options.pkg, }); // Convert the banner to a comment block, if it's not already if (!/^\s*(\/\/|\/\*)/.test(options.banner)) { options.banner = "/*!\n * " + options.banner.trim().replace(/\n/g, "\n * ") + "\n */\n"; } } } return options.banner; }
[ "function", "getBanner", "(", "options", ")", "{", "if", "(", "!", "options", ".", "banner", ")", "{", "if", "(", "typeof", "options", ".", "pkg", "===", "\"string\"", ")", "{", "options", ".", "pkg", "=", "readJSON", "(", "options", ".", "pkg", ")", ";", "}", "if", "(", "!", "options", ".", "template", ")", "{", "options", ".", "template", "=", "findFile", "(", "options", ".", "file", ")", ";", "}", "if", "(", "options", ".", "template", ")", "{", "options", ".", "banner", "=", "_", ".", "template", "(", "options", ".", "template", ")", "(", "{", "moment", ",", "pkg", ":", "options", ".", "pkg", ",", "}", ")", ";", "if", "(", "!", "/", "^\\s*(\\/\\/|\\/\\*)", "/", ".", "test", "(", "options", ".", "banner", ")", ")", "{", "options", ".", "banner", "=", "\"/*!\\n * \"", "+", "\\n", "+", "options", ".", "banner", ".", "trim", "(", ")", ".", "replace", "(", "/", "\\n", "/", "g", ",", "\"\\n * \"", ")", ";", "}", "}", "}", "\\n", "}" ]
Returns the banner comment block, based on the given options @param {object} options @param {string} [options.banner] - If set, then this banner will be used exactly as-is @param {string} [options.template] - A Lodash template that will be compiled to build the banner @param {string} [options.file] - A file containing the Lodash template @param {string|object} [options.pkg] - The path (or parsed contents) of the package.json file @returns {string|undefiend}
[ "Returns", "the", "banner", "comment", "block", "based", "on", "the", "given", "options" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L126-L150
train
JS-DevTools/browserify-banner
lib/index.js
readJSON
function readJSON (filePath) { let json = fs.readFileSync(filePath, "utf8"); try { return JSON.parse(json); } catch (e) { throw ono(e, `Error parsing ${filePath}`); } }
javascript
function readJSON (filePath) { let json = fs.readFileSync(filePath, "utf8"); try { return JSON.parse(json); } catch (e) { throw ono(e, `Error parsing ${filePath}`); } }
[ "function", "readJSON", "(", "filePath", ")", "{", "let", "json", "=", "fs", ".", "readFileSync", "(", "filePath", ",", "\"utf8\"", ")", ";", "try", "{", "return", "JSON", ".", "parse", "(", "json", ")", ";", "}", "catch", "(", "e", ")", "{", "throw", "ono", "(", "e", ",", "`", "${", "filePath", "}", "`", ")", ";", "}", "}" ]
Reads and parses a JSON file @param {string} filePath @returns {object}
[ "Reads", "and", "parses", "a", "JSON", "file" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L158-L167
train
JS-DevTools/browserify-banner
lib/index.js
findFile
function findFile (startingPath) { try { return fs.readFileSync(startingPath, "utf8"); } catch (e) { let fileName = path.basename(startingPath); let startingDir = path.dirname(startingPath); let parentDir = path.dirname(startingDir); if (parentDir === startingDir) { // We're recursed all the way to the root directory throw e; } else { try { // Search for the file in the parent directories return findFile(path.join(parentDir, fileName)); } catch (e2) { // The file wasn't found in any of the parent directories throw ono(e, `Unable to find a file named "${fileName}" in "${startingDir}" or any of its parent directories.` ); } } } }
javascript
function findFile (startingPath) { try { return fs.readFileSync(startingPath, "utf8"); } catch (e) { let fileName = path.basename(startingPath); let startingDir = path.dirname(startingPath); let parentDir = path.dirname(startingDir); if (parentDir === startingDir) { // We're recursed all the way to the root directory throw e; } else { try { // Search for the file in the parent directories return findFile(path.join(parentDir, fileName)); } catch (e2) { // The file wasn't found in any of the parent directories throw ono(e, `Unable to find a file named "${fileName}" in "${startingDir}" or any of its parent directories.` ); } } } }
[ "function", "findFile", "(", "startingPath", ")", "{", "try", "{", "return", "fs", ".", "readFileSync", "(", "startingPath", ",", "\"utf8\"", ")", ";", "}", "catch", "(", "e", ")", "{", "let", "fileName", "=", "path", ".", "basename", "(", "startingPath", ")", ";", "let", "startingDir", "=", "path", ".", "dirname", "(", "startingPath", ")", ";", "let", "parentDir", "=", "path", ".", "dirname", "(", "startingDir", ")", ";", "if", "(", "parentDir", "===", "startingDir", ")", "{", "throw", "e", ";", "}", "else", "{", "try", "{", "return", "findFile", "(", "path", ".", "join", "(", "parentDir", ",", "fileName", ")", ")", ";", "}", "catch", "(", "e2", ")", "{", "throw", "ono", "(", "e", ",", "`", "${", "fileName", "}", "${", "startingDir", "}", "`", ")", ";", "}", "}", "}", "}" ]
Searches for the given file, starting in the given directory and crawling up from there, and reads its contents. @param {string} startingPath - The file path to start at @returns {string|undefined}
[ "Searches", "for", "the", "given", "file", "starting", "in", "the", "given", "directory", "and", "crawling", "up", "from", "there", "and", "reads", "its", "contents", "." ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L176-L202
train
JS-DevTools/browserify-banner
lib/index.js
countLines
function countLines (str) { if (str) { let lines = str.match(/\n/g); if (lines) { return lines.length; } } return 0; }
javascript
function countLines (str) { if (str) { let lines = str.match(/\n/g); if (lines) { return lines.length; } } return 0; }
[ "function", "countLines", "(", "str", ")", "{", "if", "(", "str", ")", "{", "let", "lines", "=", "str", ".", "match", "(", "/", "\\n", "/", "g", ")", ";", "if", "(", "lines", ")", "{", "return", "lines", ".", "length", ";", "}", "}", "return", "0", ";", "}" ]
Counts the number of lines in the given string @param {string} str @returns {number}
[ "Counts", "the", "number", "of", "lines", "in", "the", "given", "string" ]
f30b0ecead5a6937e9aa7a2542f225b9f7c56902
https://github.com/JS-DevTools/browserify-banner/blob/f30b0ecead5a6937e9aa7a2542f225b9f7c56902/lib/index.js#L210-L218
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function () { var hsl = this.getHSL(); return 'hsl(' + Math.round(hsl.h || 0) + ', ' + percentage(hsl.s) + ', ' + percentage(hsl.l) + ')'; }
javascript
function () { var hsl = this.getHSL(); return 'hsl(' + Math.round(hsl.h || 0) + ', ' + percentage(hsl.s) + ', ' + percentage(hsl.l) + ')'; }
[ "function", "(", ")", "{", "var", "hsl", "=", "this", ".", "getHSL", "(", ")", ";", "return", "'hsl('", "+", "Math", ".", "round", "(", "hsl", ".", "h", "||", "0", ")", "+", "', '", "+", "percentage", "(", "hsl", ".", "s", ")", "+", "', '", "+", "percentage", "(", "hsl", ".", "l", ")", "+", "')'", ";", "}" ]
To hsl string format @return {String}
[ "To", "hsl", "string", "format" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L34-L37
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function () { var self = this; return '#' + padding2(Number(self.get('r')).toString(16)) + padding2(Number(self.get('g')).toString(16)) + padding2(Number(self.get('b')).toString(16)); }
javascript
function () { var self = this; return '#' + padding2(Number(self.get('r')).toString(16)) + padding2(Number(self.get('g')).toString(16)) + padding2(Number(self.get('b')).toString(16)); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "return", "'#'", "+", "padding2", "(", "Number", "(", "self", ".", "get", "(", "'r'", ")", ")", ".", "toString", "(", "16", ")", ")", "+", "padding2", "(", "Number", "(", "self", ".", "get", "(", "'g'", ")", ")", ".", "toString", "(", "16", ")", ")", "+", "padding2", "(", "Number", "(", "self", ".", "get", "(", "'b'", ")", ")", ".", "toString", "(", "16", ")", ")", ";", "}" ]
To hex string format @return {String}
[ "To", "hex", "string", "format" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L66-L69
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'v' in cfg)) { current = self.getHSV(); util.each([ 'h', 's', 'v' ], function (x) { if (x in cfg) { current[x] = cfg[x]; } }); cfg = current; } self.set(hsv2rgb(cfg)); }
javascript
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'v' in cfg)) { current = self.getHSV(); util.each([ 'h', 's', 'v' ], function (x) { if (x in cfg) { current[x] = cfg[x]; } }); cfg = current; } self.set(hsv2rgb(cfg)); }
[ "function", "(", "cfg", ")", "{", "var", "self", "=", "this", ",", "current", ";", "if", "(", "!", "(", "'h'", "in", "cfg", "&&", "'s'", "in", "cfg", "&&", "'v'", "in", "cfg", ")", ")", "{", "current", "=", "self", ".", "getHSV", "(", ")", ";", "util", ".", "each", "(", "[", "'h'", ",", "'s'", ",", "'v'", "]", ",", "function", "(", "x", ")", "{", "if", "(", "x", "in", "cfg", ")", "{", "current", "[", "x", "]", "=", "cfg", "[", "x", "]", ";", "}", "}", ")", ";", "cfg", "=", "current", ";", "}", "self", ".", "set", "(", "hsv2rgb", "(", "cfg", ")", ")", ";", "}" ]
Set value by hsv @param cfg @param cfg.h @param cfg.s @param cfg.v
[ "Set", "value", "by", "hsv" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L119-L135
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'l' in cfg)) { current = self.getHSL(); util.each([ 'h', 's', 'l' ], function (x) { if (x in cfg) { current[x] = cfg[x]; } }); cfg = current; } self.set(hsl2rgb(cfg)); }
javascript
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'l' in cfg)) { current = self.getHSL(); util.each([ 'h', 's', 'l' ], function (x) { if (x in cfg) { current[x] = cfg[x]; } }); cfg = current; } self.set(hsl2rgb(cfg)); }
[ "function", "(", "cfg", ")", "{", "var", "self", "=", "this", ",", "current", ";", "if", "(", "!", "(", "'h'", "in", "cfg", "&&", "'s'", "in", "cfg", "&&", "'l'", "in", "cfg", ")", ")", "{", "current", "=", "self", ".", "getHSL", "(", ")", ";", "util", ".", "each", "(", "[", "'h'", ",", "'s'", ",", "'l'", "]", ",", "function", "(", "x", ")", "{", "if", "(", "x", "in", "cfg", ")", "{", "current", "[", "x", "]", "=", "cfg", "[", "x", "]", ";", "}", "}", ")", ";", "cfg", "=", "current", ";", "}", "self", ".", "set", "(", "hsl2rgb", "(", "cfg", ")", ")", ";", "}" ]
Set value by hsl @param cfg @param cfg.h @param cfg.s @param cfg.l
[ "Set", "value", "by", "hsl" ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L143-L159
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function (str) { var values, r, g, b, a = 1; if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') { values = str.match(hexRe); if (values) { r = parseHex(values[1]); g = parseHex(values[2]); b = parseHex(values[3]); if (str.length === 4) { r = paddingHex(r); g = paddingHex(g); b = paddingHex(b); } } } else { values = str.match(rgbaRe); if (values) { r = parseInt(values[1], 10); g = parseInt(values[2], 10); b = parseInt(values[3], 10); a = parseFloat(values[4]) || 1; } } return typeof r === 'undefined' ? undefined : new Color({ r: r, g: g, b: b, a: a }); }
javascript
function (str) { var values, r, g, b, a = 1; if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') { values = str.match(hexRe); if (values) { r = parseHex(values[1]); g = parseHex(values[2]); b = parseHex(values[3]); if (str.length === 4) { r = paddingHex(r); g = paddingHex(g); b = paddingHex(b); } } } else { values = str.match(rgbaRe); if (values) { r = parseInt(values[1], 10); g = parseInt(values[2], 10); b = parseInt(values[3], 10); a = parseFloat(values[4]) || 1; } } return typeof r === 'undefined' ? undefined : new Color({ r: r, g: g, b: b, a: a }); }
[ "function", "(", "str", ")", "{", "var", "values", ",", "r", ",", "g", ",", "b", ",", "a", "=", "1", ";", "if", "(", "(", "str", ".", "length", "===", "4", "||", "str", ".", "length", "===", "7", ")", "&&", "str", ".", "substr", "(", "0", ",", "1", ")", "===", "'#'", ")", "{", "values", "=", "str", ".", "match", "(", "hexRe", ")", ";", "if", "(", "values", ")", "{", "r", "=", "parseHex", "(", "values", "[", "1", "]", ")", ";", "g", "=", "parseHex", "(", "values", "[", "2", "]", ")", ";", "b", "=", "parseHex", "(", "values", "[", "3", "]", ")", ";", "if", "(", "str", ".", "length", "===", "4", ")", "{", "r", "=", "paddingHex", "(", "r", ")", ";", "g", "=", "paddingHex", "(", "g", ")", ";", "b", "=", "paddingHex", "(", "b", ")", ";", "}", "}", "}", "else", "{", "values", "=", "str", ".", "match", "(", "rgbaRe", ")", ";", "if", "(", "values", ")", "{", "r", "=", "parseInt", "(", "values", "[", "1", "]", ",", "10", ")", ";", "g", "=", "parseInt", "(", "values", "[", "2", "]", ",", "10", ")", ";", "b", "=", "parseInt", "(", "values", "[", "3", "]", ",", "10", ")", ";", "a", "=", "parseFloat", "(", "values", "[", "4", "]", ")", "||", "1", ";", "}", "}", "return", "typeof", "r", "===", "'undefined'", "?", "undefined", ":", "new", "Color", "(", "{", "r", ":", "r", ",", "g", ":", "g", ",", "b", ":", "b", ",", "a", ":", "a", "}", ")", ";", "}" ]
Construct color object from String. @static @param {String} str string format color( '#rrggbb' '#rgb' or 'rgb(r,g,b)' 'rgba(r,g,b,a)' )
[ "Construct", "color", "object", "from", "String", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L248-L277
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function (cfg) { var rgb = hsl2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
javascript
function (cfg) { var rgb = hsl2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
[ "function", "(", "cfg", ")", "{", "var", "rgb", "=", "hsl2rgb", "(", "cfg", ")", ";", "rgb", ".", "a", "=", "cfg", ".", "a", ";", "return", "new", "Color", "(", "rgb", ")", ";", "}" ]
Construct color object from hsl. @static @param {Object} cfg @param {Number} cfg.h Hue @param {Number} cfg.s Saturation @param {Number} cfg.l lightness @param {Number} cfg.a alpha
[ "Construct", "color", "object", "from", "hsl", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L287-L291
train
kissyteam/kissy-xtemplate
lib/kissy/5.0.0-alpha.3/build/color-debug.js
function (cfg) { var rgb = hsv2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
javascript
function (cfg) { var rgb = hsv2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
[ "function", "(", "cfg", ")", "{", "var", "rgb", "=", "hsv2rgb", "(", "cfg", ")", ";", "rgb", ".", "a", "=", "cfg", ".", "a", ";", "return", "new", "Color", "(", "rgb", ")", ";", "}" ]
Construct color object from hsv. @static @param {Object} cfg @param {Number} cfg.h Hue @param {Number} cfg.s Saturation @param {Number} cfg.v value @param {Number} cfg.a alpha
[ "Construct", "color", "object", "from", "hsv", "." ]
1d454ab624c867d6a862d63dba576f8d24c6dcfc
https://github.com/kissyteam/kissy-xtemplate/blob/1d454ab624c867d6a862d63dba576f8d24c6dcfc/lib/kissy/5.0.0-alpha.3/build/color-debug.js#L301-L305
train
craterdog-bali/js-bali-component-framework
src/elements/Binary.js
Binary
function Binary(value, parameters) { abstractions.Element.call(this, utilities.types.BINARY, parameters); // analyze the value value = value || Buffer.alloc(0); // the default value is an empty buffer // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
javascript
function Binary(value, parameters) { abstractions.Element.call(this, utilities.types.BINARY, parameters); // analyze the value value = value || Buffer.alloc(0); // the default value is an empty buffer // since this element is immutable the value must be read-only this.getValue = function() { return value; }; return this; }
[ "function", "Binary", "(", "value", ",", "parameters", ")", "{", "abstractions", ".", "Element", ".", "call", "(", "this", ",", "utilities", ".", "types", ".", "BINARY", ",", "parameters", ")", ";", "value", "=", "value", "||", "Buffer", ".", "alloc", "(", "0", ")", ";", "this", ".", "getValue", "=", "function", "(", ")", "{", "return", "value", ";", "}", ";", "return", "this", ";", "}" ]
PUBLIC CONSTRUCTOR This constructor creates an immutable instance of a binary string using the specified value. @constructor @param {Buffer} value a buffer containing the bytes for the binary string. @param {Parameters} parameters Optional parameters used to parameterize this element. @returns {Binary} The new binary string.
[ "PUBLIC", "CONSTRUCTOR", "This", "constructor", "creates", "an", "immutable", "instance", "of", "a", "binary", "string", "using", "the", "specified", "value", "." ]
57279245e44d6ceef4debdb1d6132f48e464dcb8
https://github.com/craterdog-bali/js-bali-component-framework/blob/57279245e44d6ceef4debdb1d6132f48e464dcb8/src/elements/Binary.js#L32-L42
train