_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q40800 | getParent | train | function getParent(spec_c, className) {
var parent = getChild(spec_c, 'basecompoundref');
if (parent) {
parent = getText(parent);
if (!_.has(xml2js.CLASSES, parent)) {
console.log('WARNING: Class ' + className + ' has unknown parent class ' + parent);
}
}
return parent;
} | javascript | {
"resource": ""
} |
q40801 | getUniqueMethodName | train | function getUniqueMethodName(methodName, module, parent) {
if (methodName in module) {
do {
methodName += '!';
} while (methodName in module);
}
return methodName;
} | javascript | {
"resource": ""
} |
q40802 | getVariables | train | function getVariables(spec_c, parent) {
var spec_js = {};
var vars = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
var kind = getAttr(section, 'kind');
return (kind == 'public-attrib');
});
if (vars) {
_.each(_.filter(vars.children, function(variable) {
return (getAttr(variable... | javascript | {
"resource": ""
} |
q40803 | getReturn | train | function getReturn(spec_c, details, method, parent) {
var retType = getType(getText(spec_c, 'type'), parent);
var retDescription = (details ? getText(details, 'description') : '');
return ((retType == 'void') ? {} : {
type: retType,
description: retDescription
});
} | javascript | {
"resource": ""
} |
q40804 | getParams | train | function getParams(spec_c, details, method, parent) {
var spec_js = {};
_.each(spec_c, function(param) {
try {
var paramType = getType(getText(getChild(param, 'type'), 'type'), parent);
var paramName = getText(getChild(param, 'declname'), 'name');
spec_js[paramName] = { type: paramType };
... | javascript | {
"resource": ""
} |
q40805 | getType | train | function getType(type_c, parent) {
var type_js = type_c;
_.find(xml2js.TYPEMAPS, function(to, from) {
var pattern = new RegExp(from, 'i');
if (type_c.search(pattern) == 0) {
type_js = to;
return true;
}
});
if (isPointer(type_js)) {
var dataType = getPointerDataType(type_js);
var... | javascript | {
"resource": ""
} |
q40806 | hasValidTypes | train | function hasValidTypes(methodSpec, methodName, parent) {
var valid = true;
var msg = (xml2js.opts.strict ? ' is omitted from JS documentation.' : ' has invalid type(s).');
var printIgnoredMethodOnce = _.once(function() { console.log(methodName + msg); });
_.each(methodSpec.params, function(paramSpec, paramName)... | javascript | {
"resource": ""
} |
q40807 | ofValidType | train | function ofValidType(varSpec, varName, parent) {
if (isValidType(varSpec.type, parent)) {
return true;
} else {
var msgAddendum = (xml2js.opts.strict ? ' Omitted from JS documentation.' : '');
console.log('Error: ' + varName + ' is of invalid type ' + typeToString(varSpec.type) + '.' + msgAddendum);
... | javascript | {
"resource": ""
} |
q40808 | isValidType | train | function isValidType(type, parent) {
return (_.contains(_.values(xml2js.TYPEMAPS), type) ||
_.has(xml2js.CLASSES, type) ||
_.has(xml2js.ENUMS_BY_GROUP, type) ||
_.contains(['Buffer', 'Function', 'mraa_result_t'], type) ||
_.has((parent ? xml2js.CLASSES[parent].enums_by_group : ... | javascript | {
"resource": ""
} |
q40809 | getParamsDetails | train | function getParamsDetails(spec_c) {
var paras = getChildren(spec_c, 'para');
var details = _.find(_.map(paras, function(para) {
return getChild(para, 'parameterlist');
}), function(obj) { return (obj != undefined); });
return (details ? details.children : undefined);
} | javascript | {
"resource": ""
} |
q40810 | getReturnDetails | train | function getReturnDetails(spec_c) {
var paras = getChildren(spec_c, 'para');
return _.find(_.map(paras, function(para) {
return getChild(para, 'simplesect');
}), function(obj) { return ((obj != undefined) && (getAttr(obj, 'kind') == 'return')); });
} | javascript | {
"resource": ""
} |
q40811 | getAttr | train | function getAttr(obj, name) {
return _.find(obj.attr, function(item) {
return item.name == name;
}).value;
} | javascript | {
"resource": ""
} |
q40812 | getChild | train | function getChild(obj, name) {
return _.find(obj.children, function(child) {
return child.name == name;
});
} | javascript | {
"resource": ""
} |
q40813 | getChildren | train | function getChildren(obj, name) {
return _.filter(obj.children, function(child) {
return child.name == name;
});
} | javascript | {
"resource": ""
} |
q40814 | train | function(payload) {
console.log('parse',this.defaults)
var toReturn = {};
//todo: will be better to use regular expressions to avoid full witespaces strings
toReturn.caption = payload.caption || ' -x- ';
toReturn.name = payload.name || 'test-action';
toReturn.icon = payload.icon || 'fa-icon';
... | javascript | {
"resource": ""
} | |
q40815 | train | function(clazz, metaData) {
this.applyProperties(clazz, metaData.clazz_properties || {});
this.applyProperties(clazz.prototype, metaData.properties || {});
} | javascript | {
"resource": ""
} | |
q40816 | train | function(object, properties) {
if (!object.__isInterfaceImplemented('properties')) {
object.__implementInterface('properties', this.interface);
}
object.__initProperties();
var processor = this.get();
_.each(properties, function(data, property) {
proce... | javascript | {
"resource": ""
} | |
q40817 | train | function() {
var that = this;
var propertiesParams = that.__getPropertiesParam();
_.each(propertiesParams, function(params, property) {
var value = that.__getPropertyValue(property);
if (_.isUndefined(value) && 'default' in params) {
... | javascript | {
"resource": ""
} | |
q40818 | train | function(parameters) {
var that = this;
_.each(parameters, function(params, property) {
that.__setPropertyParam(property, params);
});
return that;
} | javascript | {
"resource": ""
} | |
q40819 | train | function(property, param, value) {
var params = {};
if (!_.isUndefined(value)) {
params[param] = value;
}
else if (_.isObject(param)) {
_.extend(params, param);
}
if (!(property in this.__properties)) {
... | javascript | {
"resource": ""
} | |
q40820 | train | function(property, param) {
var params = this.__collectAllPropertyValues.apply(this, ['__properties', 2, property].concat(param || []))[property];
return param ? params[param] : params;
} | javascript | {
"resource": ""
} | |
q40821 | train | function(fields, options) {
fields = this.__resolveFields(fields);
options = this.__resolveOptions(options);
var property = fields.shift();
if (options.check) {
this.__checkProperty(property, {
readable: true,
met... | javascript | {
"resource": ""
} | |
q40822 | train | function(fields, compareValue, options) {
fields = this.__resolveFields(fields);
options = this.__resolveOptions(options);
var property = fields.shift();
if (options.check) {
this.__checkProperty(property, {
readable: true,
... | javascript | {
"resource": ""
} | |
q40823 | train | function(fields, options) {
fields = this.__resolveFields(fields);
options = this.__resolveOptions(options);
var property = fields.shift();
if (options.check) {
this.__checkProperty(property, {
writable: true,
met... | javascript | {
"resource": ""
} | |
q40824 | train | function(fields, value, options) {
fields = this.__resolveFields(fields);
options = this.__resolveOptions(options);
var property = fields.shift();
if (options.check) {
this.__checkProperty(property, {
writable: true,
... | javascript | {
"resource": ""
} | |
q40825 | train | function(options) {
if (_.isUndefined(options)) {
options = {};
}
if (!_.isObject(options)) {
options = { emit: options, check: options };
}
return _.extend({ emit: true, check: true }, options);
} | javascript | {
"resource": ""
} | |
q40826 | train | function(property, options, throwError) {
throwError = !_.isUndefined(throwError) ? throwError : true;
var that = this;
try {
if (!this.__hasProperty(property)) {
throw 'Property "' + property + '" does not exists!';
}
... | javascript | {
"resource": ""
} | |
q40827 | train | function(fields, oldValue) {
fields = this.__resolveFields(fields);
var prop, key;
this.__checkEmitEvent(true);
if (fields.length) {
prop = fields.slice(0, -1).join('.');
key = _.last(fields);
this.__emitEvent('property... | javascript | {
"resource": ""
} | |
q40828 | train | function(fields, oldValue) {
fields = this.__resolveFields(fields);
var prop, key, i, ii;
this.__checkEmitEvent(true);
if (_.isSimpleObject(oldValue)) {
for (key in oldValue) {
this.__emitPropertyRemove(fields.concat(key), oldValue[k... | javascript | {
"resource": ""
} | |
q40829 | train | function(fields, newValue, oldValue, wasExists) {
fields = this.__resolveFields(fields);
var prop, event, key, i, ii;
this.__checkEmitEvent(true);
var isEqual = true;
if (_.isSimpleObject(newValue) && _.isSimpleObject(oldValue)) {
for (key ... | javascript | {
"resource": ""
} | |
q40830 | train | function(property, name, weight, callback) {
if (_.isUndefined(callback)) {
callback = weight;
weight = 0;
}
if (_.isArray(callback)) {
weight = callback[0];
callback = callback[1];
}
else if ... | javascript | {
"resource": ""
} | |
q40831 | train | function(property, sorted) {
var setters = this.__collectAllPropertyValues.apply(this, ['__setters', 1].concat(property || []));
if (!property) {
return setters;
}
setters = setters[property];
if (!sorted) {
return setters[pr... | javascript | {
"resource": ""
} | |
q40832 | train | function(property, value, fields) {
fields = fields || [];
var setters = this.__getSetters(property, true);
for (var i = 0, ii = setters.length; i < ii; ++i) {
var result = setters[i].call(this, value, fields);
if (!_.isUndefined(result)) {
... | javascript | {
"resource": ""
} | |
q40833 | train | function(property, sorted) {
var getters = this.__collectAllPropertyValues.apply(this, ['__getters', 1].concat(property || []));
if (!property) {
return getters;
}
getters = getters[property];
if (!sorted) {
return getters[pr... | javascript | {
"resource": ""
} | |
q40834 | train | function(property, value, fields) {
fields = fields || [];
var getters = this.__getGetters(property, true);
for (var i = 0, ii = getters.length; i < ii; ++i) {
var result = getters[i].call(this, value, fields);
if (!_.isUndefined(result)) {
... | javascript | {
"resource": ""
} | |
q40835 | train | function(data, options) {
for (var property in data) {
if (!this.__hasProperty(property.split('.')[0])) {
continue;
}
var value = data[property];
if (_.isUndefined(value) || _.isNull(value)) {
this.__re... | javascript | {
"resource": ""
} | |
q40836 | train | function() {
var data = {};
var properties = this.__getPropertiesParam();
for (var property in properties) {
data[property] = this.__processData(this.__getPropertyValue(property));
}
return data;
} | javascript | {
"resource": ""
} | |
q40837 | self_method | train | function self_method(data, methods) {
if (!data) {
return data;
}
var i, ii, prop;
if (data.constructor === ({}).constructor) {
for (prop in data) {
if (_.isUndefined(data[prop])) {
delete data[... | javascript | {
"resource": ""
} |
q40838 | train | function (ui, opts) {
log("xxmlmirror.init");
var $el = $(ui);
var state = ($("div.xmlmirrorstate:first", $el).html() || "").trim();
opts = $.extend({ defaultScript: state }, opts);
$el.html(template.trim());
var editor = null;
(function iframeImplementation() {
var iframe = $("iframe", ui);
... | javascript | {
"resource": ""
} | |
q40839 | readTargetRc | train | function readTargetRc () {
if (!fs.existsSync('./.dabao.target.json')) {
return {}
}
try {
const content = fs.readFileSync('./.dabao.target.json', { encoding: 'utf-8' })
return JSON.parse(content)
} catch (e) {
console.warn('[Warning] File parsing error: .dabao.target.json')
console.warn(e)
... | javascript | {
"resource": ""
} |
q40840 | copy | train | function copy(src, dest) {
if (!src || !dest)
return false;
try {
fs_extra_1.copySync(src, dest);
logger_1.log.notify("copied " + src + " to " + dest + ".");
return true;
}
catch (ex) {
logger_1.log.warn("failed to copy " + src + " to " + dest + ".");
retu... | javascript | {
"resource": ""
} |
q40841 | copyAll | train | function copyAll(copies) {
var success = 0;
var failed = 0;
var result;
function update(_result) {
if (!_result)
failed++;
else
success++;
}
function logResults() {
// only log if something copied or failed.
if (success || failed) {
... | javascript | {
"resource": ""
} |
q40842 | pkg | train | function pkg(val) {
var filename = path_1.resolve(exports.cwd, 'package.json');
if (!val)
return _pkg || (_pkg = fs_extra_1.readJSONSync(filename));
fs_extra_1.writeJSONSync(filename, val, { spaces: 2 });
} | javascript | {
"resource": ""
} |
q40843 | platform | train | function platform() {
var cpus = os.cpus();
var cpu = cpus[0];
cpu.cores = cpus.length;
var tmpPlatform = os.platform();
if (/^win/.test(tmpPlatform))
tmpPlatform = 'windows';
else if (tmpPlatform === 'darwin' || tmpPlatform === 'freebsd')
tmpPlatform = 'mac';
else if (tmpPla... | javascript | {
"resource": ""
} |
q40844 | colorize | train | function colorize(val) {
var styles = [];
for (var _i = 1; _i < arguments.length; _i++) {
styles[_i - 1] = arguments[_i];
}
styles = chek_1.flatten(styles);
if (chek_1.isObject(val))
return util_1.inspect(val, null, null, true);
if (/\./.test(styles[0]))
styles = styles[0... | javascript | {
"resource": ""
} |
q40845 | findPackage | train | function findPackage(filename) {
if (!ctr)
return;
filename = filename || require.main.filename;
var parsed = path_1.parse(filename);
var curPath = path_1.join(parsed.dir, 'package.json');
if (!fs_1.existsSync(curPath)) {
ctr--;
return findPackage(parsed.dir);
}
else ... | javascript | {
"resource": ""
} |
q40846 | save | train | function save(val) {
if(Array.isArray(val)) {
val.forEach(function(item) {
var seconds = item[0]
, changes = item[1];
if(seconds < 1 || changes < 0) {
throw new Error('Invalid save parameters');
}
})
}
} | javascript | {
"resource": ""
} |
q40847 | dir | train | function dir(val) {
try {
process.chdir(val);
}catch(e) {
throw new Error(
util.format('Can\'t chdir to \'%s\': %s'), val, e.message);
}
} | javascript | {
"resource": ""
} |
q40848 | logfile | train | function logfile(val) {
var fd;
// empty string disables use of log file
if(val) {
try {
fd = fs.openSync(val, 'a');
fs.closeSync(fd);
}catch(e) {
throw new Error(util.format('Can\'t open the log file: %s', val));
}
}
} | javascript | {
"resource": ""
} |
q40849 | include | train | function include(val) {
var i, inc;
// disallow the empty string
if(Array.isArray(val)) {
for(i = 0;i < val.length;i++) {
inc = val[i];
if(!inc) throw new Error('Invalid include value');
}
}
} | javascript | {
"resource": ""
} |
q40850 | requirepass | train | function requirepass(val) {
if(val && val.length > AUTHPASS_MAX_LEN) {
throw new Error(
util.format('Password is longer than %s', AUTHPASS_MAX_LEN));
}
} | javascript | {
"resource": ""
} |
q40851 | clientOutputBufferLimit | train | function clientOutputBufferLimit(val) {
if(Array.isArray(val)) {
val.forEach(function(limit) {
var type = limit[0]
, seconds = limit[3];
if(!~Constants.CLIENT_CLASS.indexOf(type)) {
throw new Error('Unrecognized client limit class');
}
if(seconds < 0) {
throw new Er... | javascript | {
"resource": ""
} |
q40852 | notifyKeyspaceEvents | train | function notifyKeyspaceEvents(val) {
var i, c;
if(val) {
for(i = 0;i < val.length;i++) {
c = val.charAt(i);
if(!~KEYSPACES_EVENTS.indexOf(c)) {
throw new Error('Invalid event class character. Use \'g$lshzxeA\'.');
}
}
}
} | javascript | {
"resource": ""
} |
q40853 | rawLineToText | train | function rawLineToText (line) {
const cut = line.indexOf(' ')
return cut === -1
? ''
: line.slice(cut + 1).trim()
} | javascript | {
"resource": ""
} |
q40854 | calculateMaxValue | train | function calculateMaxValue(precision, scale) {
const arr = _.fill(Array(precision), '9');
if (scale) {
arr.splice(precision - scale, 0, '.');
}
return parseFloat(arr.join(''));
} | javascript | {
"resource": ""
} |
q40855 | open | train | function open(selector) {
if (p["--debug"] && host.runtime == host.RUNTIME_NODEJS) {
return debug(p);
}
if (p["--ui"] && !ui) {
if (!nw) {
allume.update(allume.STATUS_ERROR, MSG_UI_UNAVAILABLE);
return;
... | javascript | {
"resource": ""
} |
q40856 | debug | train | function debug(cmd) {
// start node in debug mode
childProcess = childProcess || require("child_process");
var PATH_CWD = process.cwd();
// splice out allume command
process.argv.splice(0, 1);
// find debug argument
var debugIdx = -1;
for (var a in proc... | javascript | {
"resource": ""
} |
q40857 | train | function (command, params, opts) {
var self = this;
this.cmd = spawn(command, params, opts);
this.cmd.stdout.on('readable', function () {
self.isSpawnReadable = true;
privatePump.apply(self);
});
this.cmd.stdout.on('end', function () {
self.pu... | javascript | {
"resource": ""
} | |
q40858 | addDirective | train | function addDirective(directiveName, dashCase, attrName, filterType, isBind, isBindOnce, isFilter) {
app.directive(directiveName, ['i18n', 'config', function (i18n, config) {
function setValue(scope, element, attrs, value) {
value = !isFilter ? value :
filterType... | javascript | {
"resource": ""
} |
q40859 | apiMethod | train | function apiMethod(path, params, callback) {
var url = config.url + path + '?token=' + config.api_key;
if(params) url = url+= '&'+params;
return apiRequest(url, callback);
} | javascript | {
"resource": ""
} |
q40860 | apiRequest | train | function apiRequest(url, callback) {
var options = {
url: url,
method: 'GET',
timeout: config.timeoutMS,
maxAttempts: 3,
retryDelay: 2000, // (default) wait for 2s before trying again
retryStrategy: request.RetryStrategies.HTTPOrNetworkError // (default) retry on 5xx or netw... | javascript | {
"resource": ""
} |
q40861 | resolve | train | function resolve(file) {
// not too sure about windows, but put the \\
// just in case
if(!/^(\\\\|\/)/.test(file)) {
return path.normalize(path.join(process.cwd(), file));
}
return file;
} | javascript | {
"resource": ""
} |
q40862 | encoding | train | function encoding(rtype, value, conf) {
var enc;
//console.dir('rtype: ' + rtype);
//console.dir(value);
switch(rtype) {
case RTYPE.STRING:
enc = ENCODING.RAW;
// integer encoding
if(typeof value === 'number'
&& parseInt(value) === value
|| (typeof value === 'string'
... | javascript | {
"resource": ""
} |
q40863 | clone | train | function clone(obj) {
if (null == obj || "object" != typeof obj)
return obj;
if (obj instanceof Object) {
var copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = clone(obj[attr]);
}
return copy;
}
throw new Error("Unable to copy obj! Its type isn't supported... | javascript | {
"resource": ""
} |
q40864 | resolvehtml | train | function resolvehtml(html, holders) {
Object.keys(holders).forEach(function(key) {
html = html.replace(placeholder(key), holders[key]);
});
return html;
} | javascript | {
"resource": ""
} |
q40865 | rename | train | function rename(filepath, options) {
var base = filepath.substr(0, filepath.lastIndexOf('.'));
return base + (options.extname || '.html');
} | javascript | {
"resource": ""
} |
q40866 | tabbing | train | function tabbing(script) {
var prev, data;
script = script[0];
if ((prev = script.prev) && (data = prev.data)) {
return data.replace(/\n/g, '');
}
return '';
} | javascript | {
"resource": ""
} |
q40867 | train | function (filename, ext) {
if (!_.isString(filename) || !_.isString(ext)) {
return false;
}
ext = ext.slice(0, 1) === '.' ? ext : ('.' + ext);
return !!(filename && filename.split(ext).pop() === '');
} | javascript | {
"resource": ""
} | |
q40868 | train | function (basepath, action, recursive) {
var isDirectory = function (target) {
return fs.statSync(target).isDirectory();
};
var nextLevel = function (subpath) {
_.each(fs.readdirSync(path.join(basepath, subpath)), function (filename) {
if (isDirectory(path.join(basepath, (filename = path.join(subpat... | javascript | {
"resource": ""
} | |
q40869 | buildScripts | train | function buildScripts(conf, undertaker) {
const uglifyConf = {
mangle: false
};
const typeScriptConf = {
target: 'es5',
allowJs: true
};
const jsSrc = path.join(conf.themeConfig.root, conf.themeConfig.js.src, '**', '*.[tj]s');
const jsDest = path.join(conf.themeConfig.root, conf.themeConfig.j... | javascript | {
"resource": ""
} |
q40870 | hasStyle | train | function hasStyle(element, key) {
assertType(element, Node, false, 'Invalid element specified');
return element.style[key] !== '';
} | javascript | {
"resource": ""
} |
q40871 | convertDomToJyt | train | function convertDomToJyt(dom) {
var i, elems, tempElem;
// if just one element in the array, bump it up a level
if (utils.isArray(dom) && dom.length === 1) {
dom = dom[0];
}
// if multiple, then we create a sibling array of elems and return it
else if (utils.isArray(dom)) {
elem... | javascript | {
"resource": ""
} |
q40872 | parse | train | function parse(html, cb) {
if (!cb) {
throw new Error('Must pass in callback to parse() as 2nd param');
}
var handler = new htmlparser.DefaultHandler(function (error, dom) {
if (error) {
cb('Error while parsing: ' + error);
}
else {
var jytObj = conv... | javascript | {
"resource": ""
} |
q40873 | transform | train | function transform(input, test) {
var i, len, value, keys, key, newInput;
if (Array.isArray(input)) {
newInput = [];
for (i = input.length - 1; i >= 0 ; i--) {
value = input[i];
if (!test(value)) {
newInput.unshift(value);
}
}
input = newInput;
} else if (input && inp... | javascript | {
"resource": ""
} |
q40874 | checkType | train | function checkType(value, type) {
if (typeof type === 'string') {
switch (type) {
case 'string':
case 'object':
case 'number':
case 'boolean':
case 'function':
return typeof value === type;
case 'class':
return typeof value === 'function';
case 'array':
... | javascript | {
"resource": ""
} |
q40875 | send | train | function send(object) {
if (typeof object === 'object') {
return write(this.filepath, JSON.stringify(object, null, ' '));
} else {
return write(this.filepath, object.toString());
}
} | javascript | {
"resource": ""
} |
q40876 | Dynamizer | train | function Dynamizer(options) {
// don"t enforce new
if (!(this instanceof Dynamizer)) return new Dynamizer(options);
if (options) {
this.disableBoolean = options.disableBoolean || false; // maps boolean values to numeric
this.enableSets = options.enableSets || false;
// unsure about this option as yet... | javascript | {
"resource": ""
} |
q40877 | max | train | function max (value, length) {
if (value === null || value === undefined || isNaN(length)) {
return value
}
return String.prototype.substring.call(value, 0, length)
} | javascript | {
"resource": ""
} |
q40878 | train | function (req, res, next) {
// Delayed resolution of the isLoggedIn middleware.
if (server.registry.has('localUserMiddleware')) {
const middleware = server.registry.get('localUserMiddleware');
middleware.isLoggedInMiddleware()(req, res, next);
... | javascript | {
"resource": ""
} | |
q40879 | doWork | train | function doWork(cb) {
async.series([
async.apply(deleteTags),
async.apply(createTag)
], cb);
} | javascript | {
"resource": ""
} |
q40880 | dictify | train | function dictify(serializedFormArray) {
var o = {};
$.each(serializedFormArray, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});... | javascript | {
"resource": ""
} |
q40881 | eachSeries | train | function eachSeries(fn) {
var i = 0;
return this.then(function(object) {
return reduce(object, function(newPromise, value, key) {
// Allow value to be a promise
if (Q.isPromise(value)) return newPromise.then(function() {
return value;
}).then(function(... | javascript | {
"resource": ""
} |
q40882 | mapSeries | train | function mapSeries(fn) {
var newArray = [];
// Allow iterator return to be a promise
function push(value, key) {
value = fn(value, key);
if (Q.isPromise(value)) return value.then(function(v) {
newArray.push(v);
});
newArray.push(value);
}
return this.then... | javascript | {
"resource": ""
} |
q40883 | push | train | function push(value, key) {
value = fn(value, key);
if (Q.isPromise(value)) return value.then(function(v) {
newArray.push(v);
});
newArray.push(value);
} | javascript | {
"resource": ""
} |
q40884 | times | train | function times(n, fn) {
var counter = [];
return this.then(function(last) {
for (var i = 0; i < n; i++) {
counter.push(last || i);
}
return Q(counter).map(fn);
});
} | javascript | {
"resource": ""
} |
q40885 | assign | train | function assign(obj) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
if (Object.assign)
return Object.assign.apply(Object, [obj].concat(args));
return objAssign.apply(void 0, [obj].concat(args));
} | javascript | {
"resource": ""
} |
q40886 | del | train | function del(obj, key, immutable) {
if (immutable)
return _del(assign({}, obj), key);
return _del(obj, key);
} | javascript | {
"resource": ""
} |
q40887 | get | train | function get(obj, key, def) {
var result = _get(assign({}, obj), key);
if (!is_1.isValue(result) && def) {
_set(obj, key, def);
result = def;
}
return result;
} | javascript | {
"resource": ""
} |
q40888 | has | train | function has(obj, key) {
if (!is_1.isObject(obj) || (!is_1.isArray(key) && !is_1.isString(key)))
return false;
obj = assign({}, obj);
var props = is_1.isArray(key) ? key : string_1.split(key);
while (props.length && obj) {
var prop = props.shift(), match = matchIndex(prop);
if (!... | javascript | {
"resource": ""
} |
q40889 | clone | train | function clone(obj, json) {
if (json)
return JSON.parse(JSON.stringify(obj));
return _clone(obj);
} | javascript | {
"resource": ""
} |
q40890 | put | train | function put(obj, key, val, immutable) {
if (immutable)
return _put(assign({}, obj), key, val);
return _put(obj, key, val);
} | javascript | {
"resource": ""
} |
q40891 | reverse | train | function reverse(obj) {
if (!is_1.isValue(obj))
return null;
// Reverse an array.
if (is_1.isArray(obj))
return obj.reverse();
// Reverse a string.
if (is_1.isString(obj)) {
var i = obj.toString().length;
var tmpStr = '';
while (i--)
tmpStr += obj[... | javascript | {
"resource": ""
} |
q40892 | set | train | function set(obj, key, val, immutable) {
if (immutable)
return _set(assign({}, obj), key, val);
return _set(obj, key, val);
} | javascript | {
"resource": ""
} |
q40893 | pick | train | function pick(obj, props) {
props = to_1.toArray(props, []);
if (!is_1.isValue(obj) || !is_1.isObject(obj) || !props || !props.length)
return obj;
return props.reduce(function (a, c) {
var val = get(obj, c, undefined);
if (is_1.isUndefined(val))
return a;
return s... | javascript | {
"resource": ""
} |
q40894 | wrap | train | function wrap (fnName) {
/* dynamic arguments */
return function () {
var args = arguments
return new Recustomize(function () {
var customize = builder()
return customize[fnName].apply(customize, args)
})
}
} | javascript | {
"resource": ""
} |
q40895 | getHtmlFilenames | train | function getHtmlFilenames (directory)
{
return fs.readdirSync(directory).map(function (file) {
return path.join(directory, file);
}).filter(function (file) {
return fs.statSync(file).isFile();
}).filter(function (file) {
return path.extname(file).toLowerCase() == ".html";
});
} | javascript | {
"resource": ""
} |
q40896 | Filecache | train | function Filecache(options) {
options = options || {};
this.directory = options.directory || path.join(__dirname, '/.cache');
this.fresh = +options.fresh || 500000;
} | javascript | {
"resource": ""
} |
q40897 | makePromise | train | async function makePromise(fn, args, resolveValue) {
const er = erotic(true)
if (typeof fn !== 'function') {
throw new Error('Function must be passed.')
}
const { length: fnLength } = fn
if (!fnLength) {
throw new Error('Function does not accept any arguments.')
}
const res = await new Promise((r... | javascript | {
"resource": ""
} |
q40898 | train | function(table, result) {
if (result && result.rows && result.rows.length > 0)
return result.rows[0][table.id];
return -1;
} | javascript | {
"resource": ""
} | |
q40899 | unbindEvents | train | function unbindEvents(target, events, listener) {
events.split(' ').forEach(function (event) {
return target.removeEventListener(event, listener, false);
});
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.