_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, 'kind') == 'variable');
}), function(variable) {
var varName = getText(getChild(variable, 'name'), 'name');
var varType = getType(getText(getChild(variable, 'type')), parent);
var varDescription = getText(getChild(variable, 'detaileddescription'));
spec_js[varName] = {
type: varType,
description: varDescription
}
});
}
return spec_js;
} | 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 };
} catch(e) {
if (paramType == '...') {
spec_js['arguments'] = { type: paramType };
} else {
throw e;
}
}
});
_.each(details, function(param) {
var getParamName = function(p) { return getText(getChild(getChild(p, 'parameternamelist'), 'parametername'), 'name'); }
var paramName = getParamName(param);
var paramDescription = getText(getChild(param, 'parameterdescription'), 'description');
if (_.has(spec_js, paramName)) {
spec_js[paramName].description = paramDescription;
} else {
var msg = ' has documentation for an unknown parameter: ' + paramName + '. ';
var suggestions = _.difference(_.keys(spec_js), _.map(details, getParamName));
var msgAddendum = (!_.isEmpty(suggestions) ? ('Did you mean ' + suggestions.join(', or ') + '?') : '');
console.log('Warning: ' + (parent ? (parent + '.') : '') + method + msg + msgAddendum);
}
});
return spec_js;
} | 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 className = parent.toLowerCase();
if (_.has(xml2js.ARRAY_TYPEMAPS, dataType) && _.contains(xml2js.ARRAY_TYPEMAPS[dataType].classes, className)) {
type_js = xml2js.ARRAY_TYPEMAPS[dataType].arrayType;
} else if (_.has(xml2js.POINTER_TYPEMAPS, className) && _.has(xml2js.POINTER_TYPEMAPS[className], dataType)) {
type_js = xml2js.POINTER_TYPEMAPS[className][dataType];
} else if (_.has(xml2js.CLASSES, dataType)) { // TODO: verify that swig does this mapping
type_js = dataType;
} else {
type_js = dataType + ' *'
}
}
return type_js;
} | 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) {
if (!isValidType(paramSpec.type, parent)) {
valid = false;
printIgnoredMethodOnce();
console.log(' Error: parameter ' + paramName + ' has invalid type ' + typeToString(paramSpec.type));
}
});
if (!_.isEmpty(methodSpec.return) && !isValidType(methodSpec.return.type, parent)) {
valid = false;
printIgnoredMethodOnce();
console.log(' Error: returns invalid type ' + typeToString(methodSpec.return.type));
}
return valid;
} | 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);
return false;
}
} | 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 : []), type) ||
isValidPointerType(type, parent));
} | 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';
toReturn.status=payload.status || false;
return toReturn;
} | 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) {
processor.process(object, data, property);
});
} | 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) {
var defaultValue = params.default;
if (_.isFunction(defaultValue)) {
defaultValue = defaultValue.call(that);
}
if (defaultValue) {
if ((_.isSimpleObject(defaultValue)) || _.isArray(defaultValue)) {
defaultValue = _.clone(defaultValue)
}
}
that.__setPropertyValue(property, defaultValue, false);
}
});
} | 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)) {
this.__properties[property] = {};
}
_.extend(this.__properties[property], params);
return this;
} | 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,
method: 'get',
params: _.toArray(arguments)
});
}
var value = this.__applyGetters(property, this['_' + property]);
for (var i = 0, ii = fields.length; i < ii; ++i) {
var field = fields[i];
if (!(field in value)) {
throw new Error('Property "' + [property].concat(fields.slice(0, i+1)).join('.') + '" does not exists!');
}
value = this.__applyGetters(property, value[field], fields.slice(0, i+1));
}
if (options.emit && this.__checkEmitEvent()) {
var prop = [property].concat(fields).join('.');
this.__emitEvent('property.' + prop + '.get', value);
this.__emitEvent('property.get', prop, value);
}
return value;
} | 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,
method: 'is',
params: _.toArray(arguments)
});
}
var value = this.__getPropertyValue([property].concat(fields), false);
var result = !_.isUndefined(compareValue) ? value === compareValue : !!value;
if (options.emit && this.__checkEmitEvent()) {
var prop = [property].concat(fields).join('.');
this.__emitEvent('property.' + prop + '.is', result);
this.__emitEvent('property.is', prop, result);
}
return result;
} | 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,
method: 'remove',
params: _.toArray(arguments)
});
}
var field, container;
if (fields.length) {
field = _.last(fields);
container = this.__getPropertyValue([property].concat(fields).slice(0, -1));
if (!(field in container)) {
return this;
}
}
else {
field = '_' + property;
container = this;
}
var oldValue = container[field];
if (fields.length) {
delete container[field]
}
else {
container[field] = undefined;
}
if (options.emit && this.__checkEmitEvent()) {
this.__emitPropertyRemove([property].concat(fields), oldValue);
}
return this;
} | 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,
method: 'set',
params: _.toArray(arguments)
});
}
var field, container;
if (fields.length) {
field = _.last(fields);
container = this.__getPropertyValue([property].concat(fields).slice(0, -1), false);
}
else {
field = '_' + property;
container = this;
}
var wasExisted = field in container;
var oldValue = container[field];
var newValue = this.__applySetters(property, value, fields);
container[field] = newValue;
if (options.emit && this.__checkEmitEvent()) {
this.__emitPropertySet([property].concat(fields), newValue, oldValue, wasExisted);
}
return this;
} | 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!';
}
if ('readable' in options || 'writable' in options) {
var params = this.__getPropertyParam(property);
var rights = ['readable', 'writable'];
for (var i = 0, ii = rights.length; i < ii; ++i) {
if (!checkRight(rights[i], options, params)) {
throw '"' + rights[i] + '" check was failed for property "' + property + '"!';
}
}
}
}
catch (error) {
if (!_.isString(error)) {
throw error;
}
if (throwError) {
throw new Error(error);
}
return false;
}
return true;
function checkRight(right, options, params) {
if (!(right in options)) {
return true;
}
var value = right in params
? (_.isFunction(params[right]) ? params[right].call(that, options.method, options.params) : params[right])
: true;
return options[right] == !!value;
}
} | 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.' + prop + '.item_removed', key, oldValue);
this.__emitEvent('property.item_removed', prop, key, oldValue);
}
prop = fields.join('.');
this.__emitEvent('property.' + prop + '.remove', oldValue);
this.__emitEvent('property.remove', prop, oldValue);
return this;
} | 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[key]);
}
}
else if (_.isArray(oldValue)) {
for (i = 0, ii = oldValue.length; i < ii; ++i) {
this.__emitPropertyRemove(fields.concat(i), oldValue[i]);
}
}
prop = fields.join('.');
this.__emitEvent('property.' + prop + '.clear', oldValue);
this.__emitEvent('property.clear', prop, oldValue);
return this;
} | 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 in oldValue) {
if (newValue[key] !== oldValue[key]) {
isEqual = false;
break;
}
}
}
else if (_.isArray(newValue) && _.isArray(oldValue)) {
for (i = 0, ii = oldValue.length; i < ii; ++i) {
if (newValue[i] !== oldValue[i]) {
isEqual = false;
break;
}
}
}
else if (newValue !== oldValue) {
isEqual = false;
}
if (!isEqual) {
prop = fields.join('.');
this.__emitEvent('property.' + prop + '.' + 'set', newValue, oldValue);
this.__emitEvent('property.set', prop, newValue, oldValue);
if (fields.length && !wasExists) {
prop = fields.slice(0,-1).join('.');
key = _.last(fields);
this.__emitEvent('property.' + prop + '.item_added', key, newValue);
this.__emitEvent('property.item_added', prop, key, newValue);
}
}
return this;
} | 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 (!_.isFunction(callback)) {
throw new Error('Setter callback must be a function!');
}
if (!(property in this.__setters)) {
this.__setters[property] = {};
}
this.__setters[property][name] = [weight, callback];
return this;
} | 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[property];
}
var sortedSetters = [];
for (var name in setters) {
sortedSetters.push(setters[name]);
}
sortedSetters = sortedSetters.sort(function(s1, s2) { return s2[0] - s1[0]; });
for (var i = 0, ii = sortedSetters.length; i < ii; ++i) {
sortedSetters[i] = sortedSetters[i][1];
}
return sortedSetters;
} | 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)) {
value = result;
}
}
return value;
} | 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[property];
}
var sortedGetters = [];
for (var name in getters) {
sortedGetters.push(getters[name]);
}
sortedGetters = sortedGetters.sort(function(s1, s2) { return s2[0] - s1[0]; });
for (var i = 0, ii = sortedGetters.length; i < ii; ++i) {
sortedGetters[i] = sortedGetters[i][1];
}
return sortedGetters;
} | 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)) {
value = result;
}
}
return value;
} | 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.__removePropertyValue(property, options);
}
else if (_.isObject(value) && _.isEmpty(value)) {
this.__clearPropertyValue(property, options)
}
else {
this.__setPropertyValue(property, value, options);
}
}
return this;
} | 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[prop];
continue;
}
data[prop] = self_method(data[prop], methods);
}
}
else if (_.isArray(data)) {
for (i = 0, ii = data.length; i < ii; ++i) {
if (_.isUndefined(data[i])) {
--i; --ii;
continue;
}
data[i] = self_method(data[i], methods);
}
}
else {
methods = _.extend({}, methods, { __getData: null });
_.each(methods, function(params, method) {
if (!_.isFunction(data[method])) {
return;
}
if (_.isNull(params) || _.isUndefined(params)) {
params = [];
}
if (!_.isArray(params)) {
params = [params];
}
data = data[method].apply(data, params);
});
}
return 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);
editor = ns.widgets.xmleditorInitIframe(iframe);
})();
if (opts.defaultScript) {
editor.set(ns.modules.string.htmlDecode(opts.defaultScript));
}
var me = {};
me.refresh = function () { editor.refresh(); };
me.getXml = function () {
var code = editor.get();
return code;
};
me.setXml = function (xml) {
editor.set(xml);
};
return me;
} | 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)
return {}
}
} | 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 + ".");
return false;
}
} | 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) {
if (failed > success) {
if (!success)
logger_1.log.error(failed + " failed to copy with 0 succeeding.");
else
logger_1.log.warn(failed + " failed to copy " + success + " succeeded.");
}
else {
logger_1.log.notify(success + " items copied " + failed + " failed.");
}
}
}
if (chek_1.isPlainObject(copies)) {
chek_1.keys(copies).forEach(function (k) {
var itm = copies[k];
// Check if src is glob.
if (itm.src.indexOf('*') !== -1) {
var arr = glob.sync(itm.src);
arr.forEach(function (str) {
result = copy(str, itm.dest);
update(result);
});
}
else {
result = copy(itm.src, itm.dest);
update(result);
}
});
logResults();
}
else if (chek_1.isArray(copies)) {
// If not array of tuples convert.
if (chek_1.isString(copies[0]))
copies = copies.reduce(function (a, c) {
var tuple = c.split('|');
return a.concat([tuple]);
}, []);
copies.forEach(function (c) {
var tuple = c;
if (tuple[0].indexOf('*') !== -1) {
var arr = glob.sync(tuple[0]);
arr.forEach(function (str) {
result = copy(str, tuple[1]);
update(result);
});
}
else {
result = copy(tuple[0], tuple[1]);
update(result);
}
});
logResults();
}
else {
logger_1.log.warn("copy failed using unknown configuration type.");
}
return {
success: success,
failed: 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 (tmpPlatform === 'linux')
tmpPlatform = 'linux';
return {
platform: tmpPlatform,
arch: os.arch(),
release: os.release(),
hostname: os.hostname(),
homedir: os.homedir(),
cpu: cpu
};
} | 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].split('.');
return colurs.applyAnsi(val, styles);
} | 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 {
return chek_1.tryRequire(curPath, {});
}
} | 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 Error(
'Negative number of seconds in soft limit is invalid');
}
})
}
} | 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;
}
// spawn nw.js process for allume with parameters
var findpath = nw.findpath;
childProcess = childProcess || require("child_process");
path = path || require("path");
var PATH_NW = findpath();
var PATH_APP = path.join(__dirname, "..");
var PATH_CWD = process.cwd();
var env = Object.create(process.env);
env.PWD = process.cwd();
process.argv.splice(1, 1);
process.argv[0] = PATH_APP;
for (var a in process.argv) {
process.argv[a] = process.argv[a].replace(/"/g, "\"");
}
var ls = childProcess.spawn(PATH_NW, process.argv, {"cwd": PATH_CWD, "env" : env});
ls.stdout.on("data", function(data) {
console.log(data.toString().trim());
});
ls.stderr.on("data", function(data) {
console.error(data.toString().trim());
});
return;
}
var requests = [];
var request = selector;
if (p["--config"]) {
var json;
try {
json = JSON.parse(p["--config"].json);
}
catch(e) {
var e = new Error("Make sure the data you pass to the --config switch is valid JSON data.");
e.name = "error-invalid-configuration";
if (typeof document !== "undefined" && firstOpen) {
allume.update(e);
}
else {
console.error(e);
}
firstOpen = false;
return;
}
request = { "package" : selector, "configuration" : json };
}
requests.push(request);
if (requests) {
using.apply(using, requests).then(function () {
if (firstOpen) {
allume.hide();
firstOpen = false;
}
}, function (loader) {
usingFailed(loader);
var e = new Error(err);
e.name = errName;
if (typeof document !== "undefined" && firstOpen) {
allume.update(e);
firstOpen = false;
}
else {
console.error(e);
}
});
}
} | 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 process.argv) {
if (process.argv[a] == "--debug") {
debugIdx = a;
}
process.argv[a] = process.argv[a].replace(/"/g, "\"");
}
if (debugIdx >= 0) {
process.argv.splice(debugIdx, 1);
}
if (!cmd["--debug"].port) {
process.argv.splice(0, 0, "--debug-brk");
//process.argv.splice(0, 0, "--inspect");
}
else {
if (debugIdx >= 0) {
process.argv.splice(debugIdx, 1);
}
process.argv.splice(0, 0, "--debug-brk=" + cmd["--debug"].port);
//process.argv.splice(0, 0, "--inspect=" + cmd["--debug"].port);
}
var ls = childProcess.spawn("node", process.argv, {"cwd": PATH_CWD});
ls.stdout.on("data", function(data) {
console.log(data.toString().trim());
});
ls.stderr.on("data", function(data) {
console.error(data.toString().trim());
});
return;
} | 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.push(null);
});
this.on('finish', function () {
this.cmd.stdin.end();
});
} | 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 === 'file' ?
(config.staticFileRoot + value) :
i18n.translate(value, scope);
attrName === 'text' ?
element.text(value) :
attrName === 'class' ?
attrs.$addClass(value) :
attrs.$set(attrName, value, scope);
}
return {
priority: 101,
link: function linkFn(scope, element, attrs) {
var originalValue = attrs[directiveName];
// if we are binding to the attribute value
if (isBind) {
var unwatch = scope.$watch(originalValue, function (value) {
if (value !== undefined && value !== null) {
setValue(scope, element, attrs, value);
if (isBindOnce && unwatch) { unwatch(); }
}
});
}
// else we are not binding, but we want to do some filtering
else if (!isBind && isFilter && filterType !== null) {
var fTextVal = (element && element.length && element[0].attributes &&
element[0].attributes[dashCase] && element[0].attributes[dashCase].value) || '';
// if the value contains {{ it means there is interpolation
if (fTextVal.indexOf('{{') >= 0) {
var unobserve = attrs.$observe(directiveName, function (value) {
setValue(scope, element, attrs, value);
if (isBindOnce && unobserve) { unobserve(); }
});
}
// else we are very simply setting the value
else {
setValue(scope, element, attrs, originalValue);
}
}
else {
throw new Error('Not bind nor filter in generic addDirective for ' + originalValue);
}
}
};
}]);
} | 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 network errors
};
var req = request(options, function(error, response, body) {
if(typeof callback === 'function') {
var data;
if(error) {
callback.call(self, new Error('Error in server response: ' + JSON.stringify(error)), null);
return;
}
try {
data = JSON.parse(body);
if(data.error != false){
callback.call(self, new Error('API error.'), null);
} else {
// All good.
callback.call(self,null,data.response);
}
}
catch(e) {
callback.call(self, new Error('Could unknown server response occured.'), null);
return;
}
}
});
return req;
} | 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'
&& /^-?\d+$/.test(value))
|| (value instanceof Buffer) && isIntegerBuffer(value)) {
enc = ENCODING.INT;
}
break;
case RTYPE.LIST:
// no ziplist support yet
enc = ENCODING.LINKEDLIST;
break;
case RTYPE.SET:
// no intset support yet
enc = ENCODING.HASHTABLE;
break;
case RTYPE.HASH:
// no zipmap support yet
enc = ENCODING.HASHTABLE;
break;
case RTYPE.ZSET:
// no ziplist support yet
enc = ENCODING.SKIPLIST;
break;
}
return enc;
} | 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(subpath, filename))))) {
if (recursive) {
nextLevel(filename);
}
} else {
action(filename);
}
});
};
nextLevel('./');
} | 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.js.dest);
const useTypescript = Boolean(conf.themeConfig.js.es2015);
// Build the theme scripts.
return undertaker.src(jsSrc)
.pipe(gulpIf(!conf.productionMode, sourcemaps.init()))
.pipe(gulpIf(useTypescript, ts(typeScriptConf)))
.pipe(gulpIf(conf.productionMode, uglify(uglifyConf)))
.pipe(gulpIf(!conf.productionMode, sourcemaps.write('.')))
.pipe(undertaker.dest(jsDest));
} | 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)) {
elems = [];
for (i = 0; i < dom.length; i++) {
tempElem = convertDomToJyt(dom[i]);
if (tempElem !== null) {
elems.push(tempElem);
}
}
return runtime.naked(elems, null);
}
// if type is string, then just return it
if (dom.type === 'text') {
return dom.data;
}
// if no dom name, then just return empty string since it is likely a comment
if (!dom.name) {
return null;
}
// if we get here then we have just one element
var elem = runtime.elem(dom.name);
var childCount = dom.children && dom.children.length;
// attributes should be the same
elem.attributes = dom.attribs;
// recursively add children
if (dom.children && dom.children.length) {
elem.children = [];
for (i = 0; i < childCount; i++) {
tempElem = convertDomToJyt(dom.children[i]);
if (tempElem !== null) {
elem.children.push(tempElem);
}
}
// if one child that is a string, bring it up a level
if (elem.children.length === 1 && utils.isString(elem.children[0])) {
elem.text = elem.children[0];
delete elem.children;
}
// if no children, remove it
else if (elem.children.length === 0) {
delete elem.children;
}
}
return 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 = convertDomToJyt(dom);
cb(null, jytObj);
}
}, { ignoreWhitespace: true });
var parser = new htmlparser.Parser(handler);
parser.parseComplete(html);
} | 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 && input.constructor === Object) {
keys = Object.keys(input);
newInput = {};
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
value = input[keys[i]];
if (!test(value)) {
newInput[key] = value;
}
}
input = newInput;
} else if (test(input)) {
input = null;
}
return input;
} | 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':
return value.constructor === Array;
default:
return false;
}
}
else {
return value instanceof type;
}
} | 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
this.disableLossyFloat = options.disableLossyFloat || false;
}
} | 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);
} else {
next(new restifyErrors.ForbiddenError(`Server configuration error, 'localUserMiddleware' not found.`));
}
} | 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 || '';
}
});
return o;
} | 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(v) {
return fn(v, key || i++);
});
return newPromise.then(function() {
return fn(value, key || i++);;
});
}, Q())
.thenResolve(object)
});
} | 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(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(v) {
return push(v, key);
});
return newPromise.then(function() {
return push(value, key)
});
}, Q());
}).thenResolve(newArray);
} | 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 (!props.length) { // no more props chek path.
var _keys = array_1.keys(obj);
if (match) {
return array_1.contains(_keys, match.name) && is_1.isValue(obj[match.name][match.index]);
}
else {
return array_1.contains(_keys, prop);
}
}
if (match) {
/* istanbul ignore next */
if (!is_1.isUndefined(obj[match.name])) {
obj = obj[match.name][match.index];
// iterate each indices and set obj to that index.
match.indices.forEach(function (i) { return obj = obj[i]; });
}
}
else {
obj = obj[prop];
}
}
} | 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[i];
return tmpStr;
}
// Reverse an object.
var result = {};
for (var p in obj) {
if (is_1.isObject(obj[p]))
continue;
result[obj[p]] = p;
}
return result;
} | 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 set(a, c, val);
}, {});
} | 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((resolve, reject)=> {
const cb = (err, res) => {
if (err) {
const error = er(err)
return reject(error)
}
return resolve(resolveValue || res)
}
let allArgs = [cb]
if (Array.isArray(args)) {
args.forEach((arg, i) => {
checkArgumentIndex(fnLength, i)
})
allArgs = [...args, cb]
} else if (Array.from(arguments).length > 1) { // args passed as a single argument, not array
checkArgumentIndex(fnLength, 0)
allArgs = [args, cb]
}
fn(...allArgs)
})
return res
} | 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.