_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q14600
|
extend
|
train
|
function extend () {
var depth = 0
var args = arrayify(arguments)
if (!args.length) return {}
var last = args[args.length - 1]
if (t.isPlainObject(last) && '__depth' in last) {
depth = last.__depth
args.pop()
}
return args.reduce(function (output, curr) {
if (typeof curr !== 'object') return output
for (var prop in curr) {
var value = curr[prop]
if (value === undefined) break
if (t.isObject(value) && !Array.isArray(value) && depth < 10) {
if (!output[prop]) output[prop] = {}
output[prop] = extend(output[prop], value, { __depth: ++depth })
} else {
output[prop] = value
}
}
return output
}, {})
}
|
javascript
|
{
"resource": ""
}
|
q14601
|
clone
|
train
|
function clone (input) {
var output
if (typeof input === 'object' && !Array.isArray(input) && input !== null) {
output = {}
for (var prop in input) {
output[prop] = input[prop]
}
return output
} else if (Array.isArray(input)) {
output = []
input.forEach(function (item) {
output.push(clone(item))
})
return output
} else {
return input
}
}
|
javascript
|
{
"resource": ""
}
|
q14602
|
every
|
train
|
function every (object, iterator) {
var result = true
for (var prop in object) {
result = result && iterator(object[prop], prop)
}
return result
}
|
javascript
|
{
"resource": ""
}
|
q14603
|
HandlerChain
|
train
|
function HandlerChain() {
var handlers = this._handlers = [];
//`handlerChain.handlers` is a promised for the handlers that will be
//resolved in the nextTick, to give the user time to call `addHandler`.
this.handlers = new Promise(function(resolve) {
//Give the user time to register some handlers
process.nextTick(function() {
resolve(handlers);
});
});
}
|
javascript
|
{
"resource": ""
}
|
q14604
|
restifyHandler
|
train
|
function restifyHandler(handler, req, res, next) {
Promise.method(handler).call(this, req, res)
.then(function(result) {
next(result);
})
.catch(function(error) {
//FIXME ensure error is an error instance.
next(error);
});
}
|
javascript
|
{
"resource": ""
}
|
q14605
|
paramsFromRegexPath
|
train
|
function paramsFromRegexPath(paramsObj) {
var paramNames = Object.keys(paramsObj);
var params = paramNames.reduce(function(params, paramName) {
if ((/^\d+$/).test(paramName)) {
params.push(paramsObj[paramName]);
}
return params;
}, []);
return params;
}
|
javascript
|
{
"resource": ""
}
|
q14606
|
train
|
function() {
var manager, name;
manager = this.configManager();
if (manager == null) {
return;
}
name = this.configName();
if (name == null) {
return;
}
return manager.get(name);
}
|
javascript
|
{
"resource": ""
}
|
|
q14607
|
train
|
function() {
var i = 0,
Y = this,
args = arguments,
l = args.length,
gconf = (typeof YUI_config !== 'undefined') && YUI_config;
if (!(Y instanceof YUI)) {
Y = new YUI();
} else {
// set up the core environment
Y._init();
if (gconf) {
Y.applyConfig(gconf);
}
// bind the specified additional modules for this instance
if (!l) {
Y._setup();
}
}
if (l) {
for (; i<l; i++) {
Y.applyConfig(args[i]);
}
Y._setup();
}
return Y;
}
|
javascript
|
{
"resource": ""
}
|
|
q14608
|
train
|
function(o) {
var i, Y = this,
core = [],
mods = YUI.Env.mods,
extras = Y.config.core || [ 'get',
'rls',
'intl-base',
'loader',
'yui-log',
'yui-later',
'yui-throttle' ];
for (i=0; i<extras.length; i++) {
if (mods[extras[i]]) {
core.push(extras[i]);
}
}
Y._attach(['yui-base']);
Y._attach(core);
}
|
javascript
|
{
"resource": ""
}
|
|
q14609
|
train
|
function(id, method, args) {
if (!(method in APPLY_TO_AUTH)) {
this.log(method + ': applyTo not allowed', 'warn', 'yui');
return null;
}
var instance = instances[id], nest, m, i;
if (instance) {
nest = method.split('.');
m = instance;
for (i=0; i<nest.length; i=i+1) {
m = m[nest[i]];
if (!m) {
this.log('applyTo not found: ' + method, 'warn', 'yui');
}
}
return m.apply(instance, args);
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
|
q14610
|
train
|
function(name, fn, version, details) {
details = details || {};
var env = YUI.Env,
mod = {
name: name,
fn: fn,
version: version,
details: details
},
loader,
i;
env.mods[name] = mod;
env.versions[version] = env.versions[version] || {};
env.versions[version][name] = mod;
for (i in instances) {
if (instances.hasOwnProperty(i)) {
loader = instances[i].Env._loader;
if (loader) {
if (!loader.moduleInfo[name]) {
loader.addModule(details, name);
}
}
}
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14611
|
train
|
function(r, fromLoader) {
var i, name, mod, details, req, use,
mods = YUI.Env.mods,
Y = this,
done = Y.Env._attached,
len = r.length;
for (i=0; i<len; i++) {
name = r[i];
mod = mods[name];
if (!done[name] && mod) {
done[name] = true;
details = mod.details;
req = details.requires;
use = details.use;
if (req && req.length) {
if (!Y._attach(req)) {
return false;
}
}
if (mod.fn) {
try {
mod.fn(Y, name);
} catch (e) {
Y.error('Attach error: ' + name, e, name);
return false;
}
}
if (use && use.length) {
if (!Y._attach(use)) {
return false;
}
}
}
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q14612
|
train
|
function(msg, e) {
var Y = this, ret;
if (Y.config.errorFn) {
ret = Y.config.errorFn.apply(Y, arguments);
}
if (Y.config.throwFail && !ret) {
throw (e || new Error(msg));
} else {
Y.message(msg, "error"); // don't scrub this one
}
return Y;
}
|
javascript
|
{
"resource": ""
}
|
|
q14613
|
train
|
function(pre) {
var id = this.Env._guidp + (++this.Env._uidx);
return (pre) ? (pre + id) : id;
}
|
javascript
|
{
"resource": ""
}
|
|
q14614
|
train
|
function(o, readOnly) {
var uid;
if (!o) {
return o;
}
// IE generates its own unique ID for dom nodes
// The uniqueID property of a document node returns a new ID
if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
uid = o.uniqueID;
} else {
uid = (typeof o === 'string') ? o : o._yuid;
}
if (!uid) {
uid = this.guid();
if (!readOnly) {
try {
o._yuid = uid;
} catch(e) {
uid = null;
}
}
}
return uid;
}
|
javascript
|
{
"resource": ""
}
|
|
q14615
|
train
|
function () {
Y.Array.each(Y.Array(arguments,0,true),function (fn) {
this._q.push(fn);
},this);
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14616
|
train
|
function(o) {
var id = (L.isString(o)) ? o : o.tId,
q = queues[id];
if (q) {
q.aborted = true;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14617
|
train
|
function (preferredLanguages, availableLanguages) {
var i, language, result, index;
// check whether the list of available languages contains language; if so return it
function scan(language) {
var i;
for (i = 0; i < availableLanguages.length; i += 1) {
if (language.toLowerCase() === availableLanguages[i].toLowerCase()) {
return availableLanguages[i];
}
}
}
if (Y.Lang.isString(preferredLanguages)) {
preferredLanguages = preferredLanguages.split(SPLIT_REGEX);
}
for (i = 0; i < preferredLanguages.length; i += 1) {
language = preferredLanguages[i];
if (!language || language === "*") {
continue;
}
// check the fallback sequence for one language
while (language.length > 0) {
result = scan(language);
if (result) {
return result;
} else {
index = language.lastIndexOf("-");
if (index >= 0) {
language = language.substring(0, index);
// one-character subtags get cut along with the following subtag
if (index >= 2 && language.charAt(index - 2) === "-") {
language = language.substring(0, index - 2);
}
} else {
// nothing available for this language
break;
}
}
}
}
return "";
}
|
javascript
|
{
"resource": ""
}
|
|
q14618
|
scan
|
train
|
function scan(language) {
var i;
for (i = 0; i < availableLanguages.length; i += 1) {
if (language.toLowerCase() === availableLanguages[i].toLowerCase()) {
return availableLanguages[i];
}
}
}
|
javascript
|
{
"resource": ""
}
|
q14619
|
train
|
function(o, f, c, proto, action) {
if (o && o[action] && o !== Y) {
return o[action].call(o, f, c);
} else {
switch (A.test(o)) {
case 1:
return A[action](o, f, c);
case 2:
return A[action](Y.Array(o, 0, true), f, c);
default:
return Y.Object[action](o, f, c, proto);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14620
|
train
|
function(element, axis, fn, all) {
while (element && (element = element[axis])) { // NOTE: assignment
if ( (all || element[TAG_NAME]) && (!fn || fn(element)) ) {
return element;
}
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
|
q14621
|
train
|
function(element, needle) {
var ret = false;
if ( !needle || !element || !needle[NODE_TYPE] || !element[NODE_TYPE]) {
ret = false;
} else if (element[CONTAINS]) {
if (Y.UA.opera || needle[NODE_TYPE] === 1) { // IE & SAF contains fail if needle not an ELEMENT_NODE
ret = element[CONTAINS](needle);
} else {
ret = Y.DOM._bruteContains(element, needle);
}
} else if (element[COMPARE_DOCUMENT_POSITION]) { // gecko
if (element === needle || !!(element[COMPARE_DOCUMENT_POSITION](needle) & 16)) {
ret = true;
}
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14622
|
train
|
function(element, doc) {
var ret = false,
rootNode;
if (element && element.nodeType) {
(doc) || (doc = element[OWNER_DOCUMENT]);
rootNode = doc[DOCUMENT_ELEMENT];
// contains only works with HTML_ELEMENT
if (rootNode && rootNode.contains && element.tagName) {
ret = rootNode.contains(element);
} else {
ret = Y.DOM.contains(rootNode, element);
}
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14623
|
train
|
function(html, doc) {
if (typeof html === 'string') {
html = Y.Lang.trim(html); // match IE which trims whitespace from innerHTML
}
doc = doc || Y.config.doc;
var m = re_tag.exec(html),
create = Y.DOM._create,
custom = Y.DOM.creators,
ret = null,
tag, nodes;
if (html != undefined) { // not undefined or null
if (m && custom[m[1]]) {
if (typeof custom[m[1]] === 'function') {
create = custom[m[1]];
} else {
tag = custom[m[1]];
}
}
nodes = create(html, doc, tag).childNodes;
if (nodes.length === 1) { // return single node, breaking parentNode ref from "fragment"
ret = nodes[0].parentNode.removeChild(nodes[0]);
} else if (nodes[0] && nodes[0].className === 'yui3-big-dummy') { // using dummy node to preserve some attributes (e.g. OPTION not selected)
if (nodes.length === 2) {
ret = nodes[0].nextSibling;
} else {
nodes[0].parentNode.removeChild(nodes[0]);
ret = Y.DOM._nl2frag(nodes, doc);
}
} else { // return multiple nodes as a fragment
ret = Y.DOM._nl2frag(nodes, doc);
}
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14624
|
train
|
function(node, content, where) {
var nodeParent = node.parentNode,
newNode;
if (content !== undefined && content !== null) {
if (content.nodeType) { // domNode
newNode = content;
} else { // create from string and cache
newNode = Y.DOM.create(content);
}
}
if (where) {
if (where.nodeType) { // insert regardless of relationship to node
// TODO: check if node.contains(where)?
where.parentNode.insertBefore(newNode, where);
} else {
switch (where) {
case 'replace':
while (node.firstChild) {
node.removeChild(node.firstChild);
}
if (newNode) { // allow empty content to clear node
node.appendChild(newNode);
}
break;
case 'before':
nodeParent.insertBefore(newNode, node);
break;
case 'after':
if (node.nextSibling) { // IE errors if refNode is null
nodeParent.insertBefore(newNode, node.nextSibling);
} else {
nodeParent.appendChild(newNode);
}
break;
default:
node.appendChild(newNode);
}
}
} else {
node.appendChild(newNode);
}
return newNode;
}
|
javascript
|
{
"resource": ""
}
|
|
q14625
|
train
|
function(element) {
var doc = Y.DOM._getDoc(element);
return doc[DEFAULT_VIEW] || doc[PARENT_WINDOW] || Y.config.win;
}
|
javascript
|
{
"resource": ""
}
|
|
q14626
|
train
|
function(node, className) {
var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
return re.test(node.className);
}
|
javascript
|
{
"resource": ""
}
|
|
q14627
|
train
|
function(node, className) {
if (!Y.DOM.hasClass(node, className)) { // skip if already present
node.className = Y.Lang.trim([node.className, className].join(' '));
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14628
|
train
|
function(node, className) {
if (className && hasClass(node, className)) {
node.className = Y.Lang.trim(node.className.replace(Y.DOM._getRegExp('(?:^|\\s+)' +
className + '(?:\\s+|$)'), ' '));
if ( hasClass(node, className) ) { // in case of multiple adjacent
removeClass(node, className);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14629
|
train
|
function(node, className, force) {
var add = (force !== undefined) ? force :
!(hasClass(node, className));
if (add) {
addClass(node, className);
} else {
removeClass(node, className);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14630
|
train
|
function(node, att, val, style) {
style = style || node.style;
var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES,
current;
if (style) {
if (val === null || val === '') { // normalize unsetting
val = '';
} else if (!isNaN(new Number(val)) && re_unit.test(att)) { // number values may need a unit
val += Y_DOM.DEFAULT_UNIT;
}
if (att in CUSTOM_STYLES) {
if (CUSTOM_STYLES[att].set) {
CUSTOM_STYLES[att].set(node, val, style);
return; // NOTE: return
} else if (typeof CUSTOM_STYLES[att] === 'string') {
att = CUSTOM_STYLES[att];
}
}
style[att] = val;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14631
|
train
|
function(node, att, style) {
style = style || node.style;
var CUSTOM_STYLES = Y_DOM.CUSTOM_STYLES,
val = '';
if (style) {
if (att in CUSTOM_STYLES) {
if (CUSTOM_STYLES[att].get) {
return CUSTOM_STYLES[att].get(node, att, style); // NOTE: return
} else if (typeof CUSTOM_STYLES[att] === 'string') {
att = CUSTOM_STYLES[att];
}
}
val = style[att];
if (val === '') { // TODO: is empty string sufficient?
val = Y_DOM[GET_COMPUTED_STYLE](node, att);
}
}
return val;
}
|
javascript
|
{
"resource": ""
}
|
|
q14632
|
train
|
function(node, hash) {
var style = node.style;
Y.each(hash, function(v, n) {
Y_DOM.setStyle(node, n, v, style);
}, Y_DOM);
}
|
javascript
|
{
"resource": ""
}
|
|
q14633
|
train
|
function(node, att) {
var val = '',
doc = node[OWNER_DOCUMENT];
if (node[STYLE]) {
val = doc[DEFAULT_VIEW][GET_COMPUTED_STYLE](node, null)[att];
}
return val;
}
|
javascript
|
{
"resource": ""
}
|
|
q14634
|
train
|
function(node, doc) {
doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization
var dv = doc.defaultView,
pageOffset = (dv) ? dv.pageXOffset : 0;
return Math.max(doc[DOCUMENT_ELEMENT].scrollLeft, doc.body.scrollLeft, pageOffset);
}
|
javascript
|
{
"resource": ""
}
|
|
q14635
|
train
|
function(node, doc) {
doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization
var dv = doc.defaultView,
pageOffset = (dv) ? dv.pageYOffset : 0;
return Math.max(doc[DOCUMENT_ELEMENT].scrollTop, doc.body.scrollTop, pageOffset);
}
|
javascript
|
{
"resource": ""
}
|
|
q14636
|
train
|
function(node, node2, altRegion) {
var r = altRegion || DOM.region(node), region = {},
n = node2,
off;
if (n.tagName) {
region = DOM.region(n);
} else if (Y.Lang.isObject(node2)) {
region = node2;
} else {
return false;
}
off = getOffsets(region, r);
return {
top: off[TOP],
right: off[RIGHT],
bottom: off[BOTTOM],
left: off[LEFT],
area: ((off[BOTTOM] - off[TOP]) * (off[RIGHT] - off[LEFT])),
yoff: ((off[BOTTOM] - off[TOP])),
xoff: (off[RIGHT] - off[LEFT]),
inRegion: DOM.inRegion(node, node2, false, altRegion)
};
}
|
javascript
|
{
"resource": ""
}
|
|
q14637
|
train
|
function(node, node2, all, altRegion) {
var region = {},
r = altRegion || DOM.region(node),
n = node2,
off;
if (n.tagName) {
region = DOM.region(n);
} else if (Y.Lang.isObject(node2)) {
region = node2;
} else {
return false;
}
if (all) {
return (
r[LEFT] >= region[LEFT] &&
r[RIGHT] <= region[RIGHT] &&
r[TOP] >= region[TOP] &&
r[BOTTOM] <= region[BOTTOM] );
} else {
off = getOffsets(region, r);
if (off[BOTTOM] >= off[TOP] && off[RIGHT] >= off[LEFT]) {
return true;
} else {
return false;
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14638
|
train
|
function(node, all, altRegion) {
return DOM.inRegion(node, DOM.viewportRegion(node), all, altRegion);
}
|
javascript
|
{
"resource": ""
}
|
|
q14639
|
train
|
function(selector) {
selector = selector || '';
selector = Selector._replaceShorthand(Y.Lang.trim(selector));
var token = Selector._getToken(), // one token per simple selector (left selector holds combinator)
query = selector, // original query for debug report
tokens = [], // array of tokens
found = false, // whether or not any matches were found this pass
match, // the regex match
test,
i, parser;
/*
Search for selector patterns, store, and strip them from the selector string
until no patterns match (invalid selector) or we run out of chars.
Multiple attributes and pseudos are allowed, in any order.
for example:
'form:first-child[type=button]:not(button)[lang|=en]'
*/
outer:
do {
found = false; // reset after full pass
for (i = 0; (parser = Selector._parsers[i++]);) {
if ( (match = parser.re.exec(selector)) ) { // note assignment
if (parser.name !== COMBINATOR ) {
token.selector = selector;
}
selector = selector.replace(match[0], ''); // strip current match from selector
if (!selector.length) {
token.last = true;
}
if (Selector._attrFilters[match[1]]) { // convert class to className, etc.
match[1] = Selector._attrFilters[match[1]];
}
test = parser.fn(match, token);
if (test === false) { // selector not supported
found = false;
break outer;
} else if (test) {
token.tests.push(test);
}
if (!selector.length || parser.name === COMBINATOR) {
tokens.push(token);
token = Selector._getToken(token);
if (parser.name === COMBINATOR) {
token.combinator = Y.Selector.combinators[match[1]];
}
}
found = true;
}
}
} while (found && selector.length);
if (!found || selector.length) { // not fully parsed
tokens = [];
}
return tokens;
}
|
javascript
|
{
"resource": ""
}
|
|
q14640
|
train
|
function(fn, obj, sFn, c) {
var f = fn, a;
if (c) {
a = [fn, c].concat(Y.Array(arguments, 4, true));
f = Y.rbind.apply(Y, a);
}
return this._inject(BEFORE, f, obj, sFn);
}
|
javascript
|
{
"resource": ""
}
|
|
q14641
|
train
|
function(when, fn, obj, sFn) {
// object id
var id = Y.stamp(obj), o, sid;
if (! this.objs[id]) {
// create a map entry for the obj if it doesn't exist
this.objs[id] = {};
}
o = this.objs[id];
if (! o[sFn]) {
// create a map entry for the method if it doesn't exist
o[sFn] = new Y.Do.Method(obj, sFn);
// re-route the method to our wrapper
obj[sFn] =
function() {
return o[sFn].exec.apply(o[sFn], arguments);
};
}
// subscriber id
sid = id + Y.stamp(fn) + sFn;
// register the callback
o[sFn].register(sid, fn, when);
return new Y.EventHandle(o[sFn], sid);
}
|
javascript
|
{
"resource": ""
}
|
|
q14642
|
train
|
function() {
var evt = this.evt, detached = 0, i;
if (evt) {
if (Y.Lang.isArray(evt)) {
for (i=0; i<evt.length; i++) {
detached += evt[i].detach();
}
} else {
evt._delete(this.sub);
detached = 1;
}
}
return detached;
}
|
javascript
|
{
"resource": ""
}
|
|
q14643
|
train
|
function(what) {
this.monitored = true;
var type = this.id + '|' + this.type + '_' + what,
args = Y.Array(arguments, 0, true);
args[0] = type;
return this.host.on.apply(this.host, args);
}
|
javascript
|
{
"resource": ""
}
|
|
q14644
|
train
|
function() {
var s = Y.merge(this.subscribers), a = Y.merge(this.afters), sib = this.sibling;
if (sib) {
Y.mix(s, sib.subscribers);
Y.mix(a, sib.afters);
}
return [s, a];
}
|
javascript
|
{
"resource": ""
}
|
|
q14645
|
train
|
function(fn, context) {
// unsubscribe handle
if (fn && fn.detach) {
return fn.detach();
}
var i, s,
found = 0,
subs = Y.merge(this.subscribers, this.afters);
for (i in subs) {
if (subs.hasOwnProperty(i)) {
s = subs[i];
if (s && (!fn || fn === s.fn)) {
this._delete(s);
found++;
}
}
}
return found;
}
|
javascript
|
{
"resource": ""
}
|
|
q14646
|
train
|
function(s, args, ef) {
this.log(this.type + "->" + "sub: " + s.id);
var ret;
ret = s.notify(args, this);
if (false === ret || this.stopped > 1) {
this.log(this.type + " cancelled by subscriber");
return false;
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q14647
|
train
|
function(args, ce) {
var c = this.context,
ret = true;
if (!c) {
c = (ce.contextFn) ? ce.contextFn() : ce.context;
}
// only catch errors if we will not re-throw them.
if (Y.config.throwFail) {
ret = this._notify(c, args, ce);
} else {
try {
ret = this._notify(c, args, ce);
} catch(e) {
Y.error(this + ' failed: ' + e.message, e);
}
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14648
|
train
|
function(opts) {
var o = (L.isObject(opts)) ? opts : {};
this._yuievt = this._yuievt || {
id: Y.guid(),
events: {},
targets: {},
config: o,
chain: ('chain' in o) ? o.chain : Y.config.chain,
bubbling: false,
defaults: {
context: o.context || this,
host: this,
emitFacade: o.emitFacade,
fireOnce: o.fireOnce,
queuable: o.queuable,
monitored: o.monitored,
broadcast: o.broadcast,
defaultTargetOnly: o.defaultTargetOnly,
bubbles: ('bubbles' in o) ? o.bubbles : true
}
};
}
|
javascript
|
{
"resource": ""
}
|
|
q14649
|
train
|
function(type) {
var typeIncluded = L.isString(type),
t = (typeIncluded) ? type : (type && type.type),
ce, ret, pre = this._yuievt.config.prefix, ce2,
args = (typeIncluded) ? YArray(arguments, 1, true) : arguments;
t = (pre) ? _getType(t, pre) : t;
this._monitor('fire', t, {
args: args
});
ce = this.getEvent(t, true);
ce2 = this.getSibling(t, ce);
if (ce2 && !ce) {
ce = this.publish(t);
}
// this event has not been published or subscribed to
if (!ce) {
if (this._yuievt.hasTargets) {
return this.bubble({ type: t }, args, this);
}
// otherwise there is nothing to be done
ret = true;
} else {
ce.sibling = ce2;
ret = ce.fire.apply(ce, args);
}
return (this._yuievt.chain) ? this : ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14650
|
train
|
function(type, prefixed) {
var pre, e;
if (!prefixed) {
pre = this._yuievt.config.prefix;
type = (pre) ? _getType(type, pre) : type;
}
e = this._yuievt.events;
return e[type] || null;
}
|
javascript
|
{
"resource": ""
}
|
|
q14651
|
train
|
function(type, fn) {
var a = YArray(arguments, 0, true);
switch (L.type(type)) {
case 'function':
return Y.Do.after.apply(Y.Do, arguments);
case 'array':
// YArray.each(a[0], function(v) {
// v = AFTER_PREFIX + v;
// });
// break;
case 'object':
a[0]._after = true;
break;
default:
a[0] = AFTER_PREFIX + type;
}
return this.on.apply(this, a);
}
|
javascript
|
{
"resource": ""
}
|
|
q14652
|
train
|
function(type, fn, el, obj) {
var args=Y.Array(arguments, 0, true), compat, l, ok, i,
id, ce;
if (args[args.length-1] === COMPAT_ARG) {
compat = true;
// args.pop();
}
if (type && type.detach) {
return type.detach();
}
// The el argument can be a string
if (typeof el == "string") {
// el = (compat) ? Y.DOM.byId(el) : Y.all(el);
if (compat) {
el = Y.DOM.byId(el);
} else {
el = Y.Selector.query(el);
l = el.length;
if (l < 1) {
el = null;
} else if (l == 1) {
el = el[0];
}
}
// return Event.detach.apply(Event, args);
}
if (!el) {
return false;
}
if (el.detach) {
args.splice(2, 1);
return el.detach.apply(el, args);
// The el argument can be an array of elements or element ids.
} else if (shouldIterate(el)) {
ok = true;
for (i=0, l=el.length; i<l; ++i) {
args[2] = el[i];
ok = ( Y.Event.detach.apply(Y.Event, args) && ok );
}
return ok;
}
if (!type || !fn || !fn.call) {
return this.purgeElement(el, false, type);
}
id = 'event:' + Y.stamp(el) + type;
ce = _wrappers[id];
if (ce) {
return ce.detach(fn);
} else {
return false;
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14653
|
train
|
function(p, config) {
if (p) {
if (L.isFunction(p)) {
this._plug(p, config);
} else if (L.isArray(p)) {
for (var i = 0, ln = p.length; i < ln; i++) {
this.plug(p[i]);
}
} else {
this._plug(p.fn, p.cfg);
}
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14654
|
train
|
function(plugin) {
if (plugin) {
this._unplug(plugin);
} else {
var ns;
for (ns in this._plugins) {
if (this._plugins.hasOwnProperty(ns)) {
this._unplug(ns);
}
}
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14655
|
train
|
function(PluginClass, config) {
if (PluginClass && PluginClass.NS) {
var ns = PluginClass.NS;
config = config || {};
config.host = this;
if (this.hasPlugin(ns)) {
// Update config
this[ns].setAttrs(config);
} else {
// Create new instance
this[ns] = new PluginClass(config);
this._plugins[ns] = PluginClass;
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14656
|
train
|
function(plugin) {
var ns = plugin,
plugins = this._plugins;
if (L.isFunction(plugin)) {
ns = plugin.NS;
if (ns && (!plugins[ns] || plugins[ns] !== plugin)) {
ns = null;
}
}
if (ns) {
if (this[ns]) {
this[ns].destroy();
delete this[ns];
}
if (plugins[ns]) {
delete plugins[ns];
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14657
|
train
|
function() {
var str = this[UID] + ': not bound to a node',
node = this._node,
attrs, id, className;
if (node) {
attrs = node.attributes;
id = (attrs && attrs.id) ? node.getAttribute('id') : null;
className = (attrs && attrs.className) ? node.getAttribute('className') : null;
str = node[NODE_NAME];
if (id) {
str += '#' + id;
}
if (className) {
str += '.' + className.replace(' ', '.');
}
// TODO: add yuid?
str += ' ' + this[UID];
}
return str;
}
|
javascript
|
{
"resource": ""
}
|
|
q14658
|
train
|
function(attr) {
var attrConfig = Y_Node.ATTRS[attr],
val;
if (attrConfig && attrConfig.getter) {
val = attrConfig.getter.call(this);
} else if (Y_Node.re_aria.test(attr)) {
val = this._node.getAttribute(attr, 2);
} else {
val = Y_Node.DEFAULT_GETTER.apply(this, arguments);
}
return val;
}
|
javascript
|
{
"resource": ""
}
|
|
q14659
|
train
|
function(attrMap) {
if (this._setAttrs) { // use Attribute imple
this._setAttrs(attrMap);
} else { // use setters inline
Y.Object.each(attrMap, function(v, n) {
this.set(n, v);
}, this);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14660
|
train
|
function(attrs) {
var ret = {};
if (this._getAttrs) { // use Attribute imple
this._getAttrs(attrs);
} else { // use setters inline
Y.Array.each(attrs, function(v, n) {
ret[v] = this.get(v);
}, this);
}
return ret;
}
|
javascript
|
{
"resource": ""
}
|
|
q14661
|
train
|
function(doc) {
var node = this._node;
doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT];
if (doc.documentElement) {
return Y_DOM.contains(doc.documentElement, node);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14662
|
train
|
function(fn, testSelf) {
return Y.one(Y_DOM.ancestor(this._node, _wrapFn(fn), testSelf));
}
|
javascript
|
{
"resource": ""
}
|
|
q14663
|
train
|
function(fn, all) {
return Y.one(Y_DOM.elementByAxis(this._node, 'previousSibling', _wrapFn(fn), all));
}
|
javascript
|
{
"resource": ""
}
|
|
q14664
|
train
|
function(content, where) {
var node = this._node;
if (content) {
if (typeof where === 'number') { // allow index
where = this._node.childNodes[where];
} else if (where && where._node) { // Node
where = where._node;
}
if (typeof content !== 'string') { // allow Node or NodeList/Array instances
if (content._node) { // Node
content = content._node;
} else if (content._nodes || (!content.nodeType && content.length)) { // NodeList or Array
content = Y.all(content);
Y.each(content._nodes, function(n) {
Y_DOM.addHTML(node, n, where);
});
return this; // NOTE: early return
}
}
Y_DOM.addHTML(node, content, where);
} else {
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14665
|
train
|
function(content) {
if (content) {
if (content._node) { // map to DOMNode
content = content._node;
} else if (content._nodes) { // convert DOMNodeList to documentFragment
content = Y_DOM._nl2frag(content._nodes);
}
}
Y_DOM.addHTML(this._node, content, 'replace');
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14666
|
train
|
function(fn, context) {
var instance = this;
return Y.Array.some(this._nodes, function(node, index) {
node = Y.one(node);
context = context || node;
return fn.call(context, node, index, instance);
});
}
|
javascript
|
{
"resource": ""
}
|
|
q14667
|
train
|
function() {
var doc,
nodes = this._nodes,
query = this._query,
root = this._queryRoot;
if (query) {
if (!root) {
if (nodes && nodes[0] && nodes[0].ownerDocument) {
root = nodes[0].ownerDocument;
}
}
this._nodes = Y.Selector.query(query, root);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14668
|
train
|
function(type, fn, context) {
return Y.on.apply(Y, this._prepEvtArgs.apply(this, arguments));
}
|
javascript
|
{
"resource": ""
}
|
|
q14669
|
train
|
function (s,reviver) {
// Replace certain Unicode characters that are otherwise handled
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
replace(_BRACKETS,''))) {
// Eval the text into a JavaScript data structure, apply any
// reviver function, and return
return _revive( _eval('(' + s + ')'), reviver );
}
throw new SyntaxError('JSON.parse');
}
|
javascript
|
{
"resource": ""
}
|
|
q14670
|
train
|
function (s) {
return s.replace(re_NewLine, NewLine).replace(re_quot, quot).replace(re_apos, apos).replace(re_acute, acute).replace(re_sbquo, sbquo).replace(re_bdquo, bdquo).replace(re_hellip, hellip).replace(re_dagger, dagger).replace(re_Dagger, Dagger).replace(re_lsquo, lsquo).replace(re_rsquo, rsquo).replace(re_ldquo, ldquo).replace(re_rdquo, rdquo).replace(re_bull, bull).replace(re_ndash, ndash).replace(re_mdash, mdash).replace(re_copy, copyright_mark).replace(re_nbsp, nbsp).replace(re_laquo, laquo).replace(re_raquo, raquo);
}
|
javascript
|
{
"resource": ""
}
|
|
q14671
|
train
|
function (options) {
poolId++;
return new Pool(
options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId,
options.factory,
options.initialize || noop,
options.firstAllocationNumber || 20,
options.allocationNumber || 1
);
}
|
javascript
|
{
"resource": ""
}
|
|
q14672
|
RelayStream
|
train
|
function RelayStream(option) {
Stream.apply(this, arguments);
this.writable = true;
this.readable = true;
this.store = [];
this.paused = !!option.paused;
this.closed = false;
}
|
javascript
|
{
"resource": ""
}
|
q14673
|
validate
|
train
|
function validate(cmd, args, info) {
info = info || {};
var conf = info.conf || {}
, authrequired = typeof conf.requirepass === 'string'
, db = info.db
, result;
// handle quit command special case
if(cmd === COMMANDS.QUIT) {
// reply with an object that mimics succesful validation
info.command = {
cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
return info;
// validate command is known
}else{
info.command = validators.command(cmd, args, info);
}
// check args length (arity)
info.command.arity = validators.arity(cmd, args, info);
// handle authentication requests
if(cmd === COMMANDS.AUTH) {
info.conn.authenticated =
validators.auth(cmd, args, info);
// handle unauthenticated requests when auth is enabled
}else if(authrequired && !info.conn.authenticated) {
throw AuthRequired;
}
// check operation on the correct type of value
// this validation extracts keys, looks up the values
// to determine the type of the existing value
// the val array (or null) is assigned to the command
// info object so that calling code may re-use it and
// save looking up keys and values again where necessary
info.command.value = validators.type(cmd, args, info);
return info;
}
|
javascript
|
{
"resource": ""
}
|
q14674
|
indexOf
|
train
|
function indexOf(match) {
var i = matches.length;
while (i--) {
if (matches[i] === match) {
return i;
}
}
return -1;
}
|
javascript
|
{
"resource": ""
}
|
q14675
|
filter
|
train
|
function filter(callback) {
var filteredMatches = [];
each(function (match, i) {
if (callback(match, i)) {
filteredMatches.push(match);
}
});
matches = filteredMatches;
/*jshint validthis:true*/
return this;
}
|
javascript
|
{
"resource": ""
}
|
q14676
|
each
|
train
|
function each(callback) {
for (var i = 0, l = matches.length; i < l; i++) {
if (callback(matches[i], i) === false) {
break;
}
}
/*jshint validthis:true*/
return this;
}
|
javascript
|
{
"resource": ""
}
|
q14677
|
find
|
train
|
function find(regex, data) {
if (text && regex.global) {
while ((m = regex.exec(text))) {
matches.push(createMatch(m, data));
}
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
q14678
|
unwrap
|
train
|
function unwrap(match) {
var i, elements = getWrappersByIndex(match ? indexOf(match) : null);
i = elements.length;
while (i--) {
unwrapElement(elements[i]);
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
q14679
|
add
|
train
|
function add(start, length, data) {
matches.push({
start: start,
end: start + length,
text: text.substr(start, length),
data: data
});
return this;
}
|
javascript
|
{
"resource": ""
}
|
q14680
|
rangeFromMatch
|
train
|
function rangeFromMatch(match) {
var wrappers = getWrappersByIndex(indexOf(match));
var rng = editor.dom.createRng();
rng.setStartBefore(wrappers[0]);
rng.setEndAfter(wrappers[wrappers.length - 1]);
return rng;
}
|
javascript
|
{
"resource": ""
}
|
q14681
|
replace
|
train
|
function replace(match, text) {
var rng = rangeFromMatch(match);
rng.deleteContents();
if (text.length > 0) {
rng.insertNode(editor.dom.doc.createTextNode(text));
}
return rng;
}
|
javascript
|
{
"resource": ""
}
|
q14682
|
markErrors
|
train
|
function markErrors(data) {
var suggestions;
if (data.words) {
hasDictionarySupport = !!data.dictionary;
suggestions = data.words;
} else {
// Fallback to old format
suggestions = data;
}
editor.setProgressState(false);
if (isEmpty(suggestions)) {
var message = editor.translate('No misspellings found.');
editor.notificationManager.open({ text: message, type: 'info' });
started = false;
return;
}
lastSuggestions = suggestions;
getTextMatcher().find(getWordCharPattern()).filter(function (match) {
return !!suggestions[match.text];
}).wrap(function (match) {
return editor.dom.create('span', {
"class": 'mce-spellchecker-word',
"data-mce-bogus": 1,
"data-mce-word": match.text
});
});
started = true;
editor.fire('SpellcheckStart');
}
|
javascript
|
{
"resource": ""
}
|
q14683
|
train
|
function( filter, context ) {
var element = this,
originalName, name;
context = element.getFilterContext( context );
// Do not process elements with data-cke-processor attribute set to off.
if ( context.off )
return true;
// Filtering if it's the root node.
if ( !element.parent )
filter.onRoot( context, element );
while ( true ) {
originalName = element.name;
if ( !( name = filter.onElementName( context, originalName ) ) ) {
this.remove();
return false;
}
element.name = name;
if ( !( element = filter.onElement( context, element ) ) ) {
this.remove();
return false;
}
// New element has been returned - replace current one
// and process it (stop processing this and return false, what
// means that element has been removed).
if ( element !== this ) {
this.replaceWith( element );
return false;
}
// If name has been changed - continue loop, so in next iteration
// filters for new name will be applied to this element.
// If name hasn't been changed - stop.
if ( element.name == originalName )
break;
// If element has been replaced with something of a
// different type, then make the replacement filter itself.
if ( element.type != CKEDITOR.NODE_ELEMENT ) {
this.replaceWith( element );
return false;
}
// This indicate that the element has been dropped by
// filter but not the children.
if ( !element.name ) {
this.replaceWithChildren();
return false;
}
}
var attributes = element.attributes,
a, value, newAttrName;
for ( a in attributes ) {
newAttrName = a;
value = attributes[ a ];
// Loop until name isn't modified.
// A little bit senseless, but IE would do that anyway
// because it iterates with for-in loop even over properties
// created during its run.
while ( true ) {
if ( !( newAttrName = filter.onAttributeName( context, a ) ) ) {
delete attributes[ a ];
break;
} else if ( newAttrName != a ) {
delete attributes[ a ];
a = newAttrName;
continue;
} else {
break;
}
}
if ( newAttrName ) {
if ( ( value = filter.onAttribute( context, element, newAttrName, value ) ) === false )
delete attributes[ newAttrName ];
else
attributes[ newAttrName ] = value;
}
}
if ( !element.isEmpty )
this.filterChildren( filter, false, context );
return true;
}
|
javascript
|
{
"resource": ""
}
|
|
q14684
|
train
|
function( writer, filter ) {
if ( filter )
this.filter( filter );
var name = this.name,
attribsArray = [],
attributes = this.attributes,
attrName,
attr, i, l;
// Open element tag.
writer.openTag( name, attributes );
// Copy all attributes to an array.
for ( attrName in attributes )
attribsArray.push( [ attrName, attributes[ attrName ] ] );
// Sort the attributes by name.
if ( writer.sortAttributes )
attribsArray.sort( sortAttribs );
// Send the attributes.
for ( i = 0, l = attribsArray.length; i < l; i++ ) {
attr = attribsArray[ i ];
writer.attribute( attr[ 0 ], attr[ 1 ] );
}
// Close the tag.
writer.openTagClose( name, this.isEmpty );
this.writeChildrenHtml( writer );
// Close the element.
if ( !this.isEmpty )
writer.closeTag( name );
}
|
javascript
|
{
"resource": ""
}
|
|
q14685
|
train
|
function() {
var children = this.children;
for ( var i = children.length; i; )
children[ --i ].insertAfter( this );
this.remove();
}
|
javascript
|
{
"resource": ""
}
|
|
q14686
|
train
|
function( condition ) {
if ( !condition )
return this.children.length ? this.children[ 0 ] : null;
if ( typeof condition != 'function' )
condition = nameCondition( condition );
for ( var i = 0, l = this.children.length; i < l; ++i ) {
if ( condition( this.children[ i ] ) )
return this.children[ i ];
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
|
q14687
|
train
|
function( html ) {
var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children;
for ( var i = 0, l = children.length; i < l; ++i )
children[ i ].parent = this;
}
|
javascript
|
{
"resource": ""
}
|
|
q14688
|
train
|
function( index ) {
var cloneChildren = this.children.splice( index, this.children.length - index ),
clone = this.clone();
for ( var i = 0; i < cloneChildren.length; ++i )
cloneChildren[ i ].parent = clone;
clone.children = cloneChildren;
if ( cloneChildren[ 0 ] )
cloneChildren[ 0 ].previous = null;
if ( index > 0 )
this.children[ index - 1 ].next = null;
this.parent.add( clone, this.getIndex() + 1 );
return clone;
}
|
javascript
|
{
"resource": ""
}
|
|
q14689
|
train
|
function( className ) {
var classes = this.attributes[ 'class' ];
if ( !classes )
return;
// We can safely assume that className won't break regexp.
// http://stackoverflow.com/questions/448981/what-characters-are-valid-in-css-class-names
classes = CKEDITOR.tools.trim( classes.replace( new RegExp( '(?:\\s+|^)' + className + '(?:\\s+|$)' ), ' ' ) );
if ( classes )
this.attributes[ 'class' ] = classes;
else
delete this.attributes[ 'class' ];
}
|
javascript
|
{
"resource": ""
}
|
|
q14690
|
train
|
function(outname, imagedata) {
var frames = [];
var animations = {};
// first pass: set up frame for each image, ensure an animation array is present
imagedata.forEach(function(im) {
var ox = Math.floor(im.width / 2);
var oy = Math.floor(im.height / 2);
im.frame = frames.length;
frames.push([im.x, im.y, im.width, im.height, 0, im.ox, im.oy]);
if(!animations[im.animname]) {
animations[im.animname] = { frames: [] };
}
});
// re-sort the images to frame order and then push their frame indices
// into the respective arrays.
imagedata.sort(function(a, b) { return a.animidx - b.animidx; });
imagedata.forEach(function(im) {
animations[im.animname].frames.push(im.frame);
});
// put all the data in its appropriate groups and JSONify
var data = {
frames: frames,
animations: animations,
images: [ outname + ".png" ]
};
return JSON.stringify(data, null, 2);
}
|
javascript
|
{
"resource": ""
}
|
|
q14691
|
phaserShim
|
train
|
function phaserShim(source) {
this.cacheable && this.cacheable();
source = source
.replace(/"object"==typeof exports/, 'false')
.replace(/(var\s+\w+\s*=\s*)Phaser(\s*\|\|\s*\{)/, 'var PIXI = exports.PIXI; $1Phaser$2')
.replace(/typeof module !== 'undefined' && module\.exports/g, "false /* typeof module !== 'undefined' && module.exports */")
.replace(/require\('nw\.gui'\)/g, "undefined /* require('nw.gui') */")
.replace(/(p2\.Body\.prototype)/, 'var Phaser = require("Phaser").Phaser; var p2 = require("p2"); $1');
source = 'var document = global.document;\n\n' + source;
return source;
}
|
javascript
|
{
"resource": ""
}
|
q14692
|
train
|
function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
const oldGetAccountsMethod = providerObject.getAccounts;
// fix get accounts
if (typeof fixedProviderObject.getAccounts !== 'undefined') {
fixedProviderObject.getAccounts = function(getAccountsCallback) {
const oldCallback = getAccountsCallback;
// build fixed callback with lowercased accounts
const fixedCallback = function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
}
// fire get accounts method
oldGetAccountsMethod(fixedCallback);
};
}
// return fixed provider object
return fixedProviderObject;
}
|
javascript
|
{
"resource": ""
}
|
|
q14693
|
train
|
function(accountsError, accountsResult) {
const fixedAccountsResult = accountsResult.slice(0);
// if no error, fixed result
if (!accountsError) {
fixedAccountsResult.map(function(item) {
return String(item.toLowerCase());
});
}
// fire oldd callback with new fix
oldCallback(accountsError, fixedAccountsResult);
}
|
javascript
|
{
"resource": ""
}
|
|
q14694
|
train
|
function(rawTx) {
const rawTxMutation = Object.assign({}, rawTx);
// fix rawTx gaslimit
if (typeof rawTxMutation.gas !== 'undefined') {
rawTxMutation.gasLimit = rawTxMutation.gas;
delete rawTxMutation.gas;
}
// fix data by prefixing it with zero
if (typeof rawTxMutation.data !== 'undefined'
&& rawTxMutation.data.slice(0, 2) !== '0x') {
rawTxMutation.data = '0x' + rawTxMutation.data;
}
// return new mutated raw tx object
return rawTxMutation;
}
|
javascript
|
{
"resource": ""
}
|
|
q14695
|
train
|
function(providerObject) {
const fixedProviderObject = Object.assign({}, providerObject);
// object has signTransaction
if (typeof fixedProviderObject.signTransaction !== 'undefined') {
// store old sign transaction method
const oldSignTransactionMethod = fixedProviderObject.signTransaction;
// build new provider object signTransaciton method
fixedProviderObject.signTransaction = function(rawTx, cb) {
// fire old callback
oldSignTransactionMethod(fixEthereumJSTxObject(rawTx), cb);
};
}
// return fixed provider object
return fixedProviderObject;
}
|
javascript
|
{
"resource": ""
}
|
|
q14696
|
train
|
function(xmlString) {
var error, parser, xmlDoc;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
try {
xmlDoc = Ti.XML.parseString(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.DOMParser != null) {
try {
parser = new window.DOMParser();
xmlDoc = parser.parseFromString(xmlString, "text/xml");
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else if (window.ActiveXObject && window.GetObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
try {
xmlDoc.loadXML(xmlString);
} catch (_error) {
error = _error;
xmlDoc = null;
}
return xmlDoc;
} else {
throw new Error("No XML parser available");
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14697
|
train
|
function(xmlNode) {
var noNativeXml, noXMLSerializer;
if ((typeof Ti !== "undefined" && Ti !== null) && Ti.XML) {
return Ti.XML.serializeToString(xmlNode);
} else {
try {
return (new XMLSerializer()).serializeToString(xmlNode);
} catch (_error) {
noXMLSerializer = _error;
try {
return xmlNode.xml;
} catch (_error) {
noNativeXml = _error;
throw new Error("No XML serialization support");
}
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14698
|
train
|
function(space, type, path, value, index) {
// console.log('context.notifyUpstream : ', space, type, path, value, index);
for (var i = 0, len = space._upstreams.length; i < len; ++i) {
var upstream = space._upstreams[i];
if (!upstream) {
// maybe it's because upstreams length has change so update it
// (probably a (or more) previous listener has removed some listeners through cascade)
len = space._upstreams.length;
continue;
}
// path is local to notified node. value is the modified value. index is the one from modification point.
upstream.call(this, value, type, path, index);
}
}
|
javascript
|
{
"resource": ""
}
|
|
q14699
|
random
|
train
|
function random (seed) {
/**
* Creates a subgenerator from the current one
*
* @param {string} key Key of the subgenerator
* @param {...number} params Parameters affecting the subgenerator's seed
*/
function subgen (key, ...params) {
return random(createSeed([...seed, keygen(key), ...params], seed.length))
}
/**
* Retrieves a value from the random generator
*
* **Warning:** keys are cached indefinitely, keep them constant
*
* @param {string} key Key of the random value
* @param {...number} params Parameters affecting the value
*/
function value (key, ...params) {
return murmur([...seed, keygen(key), ...params])
}
return { seed, subgen, value, util }
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.