_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
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 o...
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 = []
javascript
{ "resource": "" }
q14602
every
train
function every (object, iterator) { var result = true for (var prop in object) { 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
javascript
{ "resource": "" }
q14604
restifyHandler
train
function restifyHandler(handler, req, res, next) { Promise.method(handler).call(this, req, res) .then(function(result) { next(result); })
javascript
{ "resource": "" }
q14605
paramsFromRegexPath
train
function paramsFromRegexPath(paramsObj) { var paramNames = Object.keys(paramsObj); var params = paramNames.reduce(function(params, paramName) {
javascript
{ "resource": "" }
q14606
train
function() { var manager, name; manager = this.configManager(); if (manager == null) { return; }
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 environm...
javascript
{ "resource": "" }
q14608
train
function(o) { var i, Y = this, core = [], mods = YUI.Env.mods, extras = Y.config.core || [ 'get', 'rls', 'intl-base', 'loader', ...
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; ...
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;...
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)...
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
javascript
{ "resource": "" }
q14613
train
function(pre) { var id = this.Env._guidp + (++this.Env._uidx);
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; ...
javascript
{ "resource": "" }
q14615
train
function () { Y.Array.each(Y.Array(arguments,0,true),function (fn) {
javascript
{ "resource": "" }
q14616
train
function(o) { var id = (L.isString(o)) ? o : o.tId,
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) { ...
javascript
{ "resource": "" }
q14618
scan
train
function scan(language) { var i; for (i = 0; i < availableLanguages.length; i += 1) { if (language.toLowerCase() === availableLanguages[i].toLowerCase()) {
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:
javascript
{ "resource": "" }
q14620
train
function(element, axis, fn, all) { while (element && (element = element[axis])) { // NOTE: assignment
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 ...
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 &&
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...
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 new...
javascript
{ "resource": "" }
q14625
train
function(element) { var doc = Y.DOM._getDoc(element); return
javascript
{ "resource": "" }
q14626
train
function(node, className) { var re = Y.DOM._getRegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
javascript
{ "resource": "" }
q14627
train
function(node, className) { if (!Y.DOM.hasClass(node, className)) { // skip if already present node.className =
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+|$)'), ' '));
javascript
{ "resource": "" }
q14629
train
function(node, className, force) { var add = (force !== undefined) ? force : !(hasClass(node, className)); if (add) {
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...
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); // NOT...
javascript
{ "resource": "" }
q14632
train
function(node, hash) { var style = node.style; Y.each(hash, function(v,
javascript
{ "resource": "" }
q14633
train
function(node, att) { var val = '', doc = node[OWNER_DOCUMENT]; if (node[STYLE]) {
javascript
{ "resource": "" }
q14634
train
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv
javascript
{ "resource": "" }
q14635
train
function(node, doc) { doc = doc || (node) ? Y_DOM._getDoc(node) : Y.config.doc; // perf optimization var dv
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; ...
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 { retu...
javascript
{ "resource": "" }
q14638
train
function(node, all, altRegion) { return DOM.inRegion(node,
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 ...
javascript
{ "resource": "" }
q14640
train
function(fn, obj, sFn, c) { var f = fn, a; if (c) { a = [fn, c].concat(Y.Array(arguments, 4,
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 f...
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++) {
javascript
{ "resource": "" }
q14643
train
function(what) { this.monitored = true; var type = this.id + '|' + this.type + '_' + what, args = Y.Array(arguments,
javascript
{ "resource": "" }
q14644
train
function() { var s = Y.merge(this.subscribers), a = Y.merge(this.afters), sib = this.sibling; if (sib) {
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);
javascript
{ "resource": "" }
q14646
train
function(s, args, ef) { this.log(this.type + "->" + "sub: " + s.id); var ret; ret = s.notify(args, this);
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 ...
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, def...
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._mo...
javascript
{ "resource": "" }
q14650
train
function(type, prefixed) { var pre, e; if (!prefixed) { pre = this._yuievt.config.prefix; type = (pre) ? _getType(type, pre)
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; ...
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 typ...
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]); }
javascript
{ "resource": "" }
q14654
train
function(plugin) { if (plugin) { this._unplug(plugin); } else { var ns; for (ns in this._plugins) { if (this._plugins.hasOwnProperty(ns)) {
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].setAt...
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 ...
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....
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)) {
javascript
{ "resource": "" }
q14659
train
function(attrMap) { if (this._setAttrs) { // use Attribute imple this._setAttrs(attrMap); } else { // use setters inline
javascript
{ "resource": "" }
q14660
train
function(attrs) { var ret = {}; if (this._getAttrs) { // use Attribute imple this._getAttrs(attrs);
javascript
{ "resource": "" }
q14661
train
function(doc) { var node = this._node; doc = (doc) ? doc._node || doc : node[OWNER_DOCUMENT]; if (doc.documentElement) {
javascript
{ "resource": "" }
q14662
train
function(fn, testSelf) { return Y.one(Y_DOM.ancestor(this._node,
javascript
{ "resource": "" }
q14663
train
function(fn, all) { return Y.one(Y_DOM.elementByAxis(this._node,
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 (t...
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
javascript
{ "resource": "" }
q14666
train
function(fn, context) { var instance = this; return Y.Array.some(this._nodes, function(node, index) {
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) {
javascript
{ "resource": "" }
q14668
train
function(type, fn, context) { return
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 re...
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_ld...
javascript
{ "resource": "" }
q14671
train
function (options) { poolId++; return new Pool( options.name ? options.name + ' (pool #' + poolId + ')' : 'pool #' + poolId, options.factory, options.initialize || noop,
javascript
{ "resource": "" }
q14672
RelayStream
train
function RelayStream(option) { Stream.apply(this, arguments); this.writable = true; this.readable = true; this.store = [];
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.com...
javascript
{ "resource": "" }
q14674
indexOf
train
function indexOf(match) { var i = matches.length; while (i--) { if (matches[i] === match) {
javascript
{ "resource": "" }
q14675
filter
train
function filter(callback) { var filteredMatches = []; each(function (match, i) { if (callback(match, i)) { filteredMatches.push(match); } });
javascript
{ "resource": "" }
q14676
each
train
function each(callback) { for (var i = 0, l = matches.length; i < l; i++) { if (callback(matches[i], i)
javascript
{ "resource": "" }
q14677
find
train
function find(regex, data) { if (text && regex.global) { while ((m =
javascript
{ "resource": "" }
q14678
unwrap
train
function unwrap(match) { var i, elements = getWrappersByIndex(match ? indexOf(match) : null);
javascript
{ "resource": "" }
q14679
add
train
function add(start, length, data) { matches.push({ start: start, end: start + length,
javascript
{ "resource": "" }
q14680
rangeFromMatch
train
function rangeFromMatch(match) { var wrappers = getWrappersByIndex(indexOf(match)); var rng = editor.dom.createRng(); rng.setStartBefore(wrappers[0]);
javascript
{ "resource": "" }
q14681
replace
train
function replace(match, text) { var rng = rangeFromMatch(match); rng.deleteContents(); if (text.length > 0) {
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 (isEmp...
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...
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 attribute...
javascript
{ "resource": "" }
q14685
train
function() { var children = this.children; for ( var i = children.length; i; )
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
javascript
{ "resource": "" }
q14687
train
function( html ) { var children = this.children = CKEDITOR.htmlParser.fragment.fromHtml( html ).children; for ( var
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 (
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(
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); ...
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...
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 ...
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());
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
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; // buil...
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; ...
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) { ...
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) { //
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], s...
javascript
{ "resource": "" }