_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3 values | text stringlengths 52 373k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q33800 | train | function(autoset){
autoset = autoset !== void 0 ? autoset : true;
if(autoset && !this.current && this.targets.length){
this.sort();
this.setCurrent(this.targets[0]);
}
return this.current;
} | javascript | {
"resource": ""
} | |
q33801 | train | function(){
if(!this.current){
return this.getCurrent();
}
var index = this.targets.indexOf(this.current);
if(index === 0){
index = this.targets.length - 1;
} else {
index--;
}
this.setCurrent(this.targets[index]);
return this.current;
} | javascript | {
"resource": ""
} | |
q33802 | train | function(obj){
for(var i = this.typeSortPriority.length - 1; i >= 0; i--){
var type = this.typeSortPriority[i];
if(obj instanceof type){
return i;
}
}
} | javascript | {
"resource": ""
} | |
q33803 | train | function(){
var _this = this;
this.targets.sort(function(a, b){
var aTypeSortPriority = _this.getTypeSortPriority(a.value);
var bTypeSortPriority = _this.getTypeSortPriority(b.value);
if(aTypeSortPriority === bTypeSortPriority){
return a.range - b.range;
}
if(aTypeSortPriority > bTypeSortPriority){
return 1;
}
if(aTypeSortPriority < bTypeSortPriority){
return -1;
}
});
} | javascript | {
"resource": ""
} | |
q33804 | train | function(value){
for(var i = this.targets.length - 1; i >= 0; i--){
var target = this.targets[i];
if(target.value === value){
return target;
}
}
} | javascript | {
"resource": ""
} | |
q33805 | parseTitle | train | function parseTitle (node, nodeType, feedType) {
return utils.stripHtml(utils.get(node.title));
} | javascript | {
"resource": ""
} |
q33806 | parseDescription | train | function parseDescription (node, nodeType, feedType) {
var propOrder = nodeType === 'item' ?
['description', 'summary', 'itunes:summary', 'content:encoded', 'content'] :
['description', 'subtitle', 'itunes:summary'];
return utils.stripHtml(utils.getFirstFoundPropValue(node, propOrder));
} | javascript | {
"resource": ""
} |
q33807 | parseXmlUrl | train | function parseXmlUrl (node, nodeType, feedType) {
var getLink = function (linkNode) {
var link;
utils.parse(linkNode, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.rel === 'self') {
link = linkAttr.href;
return;
}
}, this, true);
return link;
};
return getLink(node.link) || getLink(node['atom:link']) || getLink(node['atom10:link']);
} | javascript | {
"resource": ""
} |
q33808 | parseOrigLink | train | function parseOrigLink (node, nodeType, feedType) {
var origLink;
if (origLink = utils.getFirstFoundPropValue(node, ['feedburner:origlink', 'pheedo:origlink'])) {
return origLink;
} else {
utils.parse(node.link, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.rel === 'canonical') {
origLink = linkAttr.href;
return true;
}
}, this, true);
}
return origLink;
} | javascript | {
"resource": ""
} |
q33809 | parseAuthor | train | function parseAuthor (node, nodeType, feedType) {
var authorNode = node.author,
author;
//Both meta and item have author property as top priority and share parsing logic.
if (authorNode && (author = utils.get(authorNode))) {
author = addressparser(author)[0];
return author.name || author.address;
}
else if (authorNode && (author = utils.get(authorNode.name) || utils.get(authorNode.email))) {
return author;
}
// use addressparser to parse managingeditor or webmaster properties for meta nodes
else if (nodeType === 'meta' && (author = utils.get(node.managingeditor) || utils.get(node.webmaster))) {
author = addressparser(author)[0];
return author.name || author.address;
}
//parse the next properties in order
else if (author = utils.getFirstFoundPropValue(node, ['dc:creator', 'itunes:author', 'dc:publisher'])) {
return author;
}
else if (node['itunes:owner'] && (author = utils.get(node['itunes:owner']['itunes:name']) || utils.get(node['itunes:owner']['itunes:email']))) {
return author;
}
return null;
} | javascript | {
"resource": ""
} |
q33810 | parseLanguage | train | function parseLanguage (node, nodeType, feedType) {
return utils.get(node.language) || utils.getAttr(node, 'xml:lang') || utils.get(node['dc:language']);
} | javascript | {
"resource": ""
} |
q33811 | parseUpdateInfo | train | function parseUpdateInfo (node, nodeType, feedType) {
var updateInfo = {}, temp;
if (temp = utils.get(node['sy:updatefrequency'])) {
updateInfo.frequency = temp;
}
if (temp = utils.get(node['sy:updateperiod'])) {
updateInfo.period = temp;
}
if (temp = utils.get(node['sy:updatebase'])) {
updateInfo.base = temp;
}
if (temp = utils.get(node.ttl)) {
updateInfo.ttl = temp;
}
return Object.keys(updateInfo).length ? updateInfo : null;
} | javascript | {
"resource": ""
} |
q33812 | parseImage | train | function parseImage (node, nodeType, feedType) {
var image, mediaGroup, mediaContent;
if (node.image && (image = utils.get(utils.get(node.image, 'url') || node.image))) {
return image;
} else if (nodeType === 'meta') {
return utils.getAttr(node['itunes:image'], 'href') || utils.getAttr(node['media:thumbnail'], 'url') || utils.get(node.logo);
}
else if (nodeType === 'item') {
mediaGroup = node['media:group'];
mediaContent = node['media:content'];
//search for media:thumbnail url in the following order:. node, node['media:content'], node['media:group'], node['media:group']['media:content']
if (image = utils.getAttr(node['media:thumbnail'] || utils.get(mediaContent || mediaGroup, 'media:thumbnail') ||
utils.get(mediaGroup && mediaGroup['media:content'], 'media:thumbnail'), 'url')) {
return image;
}
//search for itunes:image href
else if (image = utils.getAttr(node['itunes:image'], 'href')) {
return image;
}
//fall back on node['media:content'] or node['media:group']['media:content'] url
else if (image = utils.getAttr(mediaContent || (mediaGroup && mediaGroup['media:content']))) {
if (image.url && (image.medium === 'image' || (image.type && image.type.indexOf('image') === 0) || /\.(jpg|jpeg|png|gif)/.test(image.url))) {
return image.url;
}
}
}
} | javascript | {
"resource": ""
} |
q33813 | parseCloud | train | function parseCloud (node, nodeType, feedType) {
var cloud,
temp = utils.getAttr(node.cloud) || {};
if (Object.keys(temp).length) {
cloud = temp;
cloud.type = 'rsscloud';
} else {
utils.parse(node.link, function (link) {
var attr = utils.getAttr(link);
if (attr && attr.href && attr.rel === 'hub') {
cloud = {type: 'hub', href: attr.href};
return true;
}
}, this, true);
}
return cloud;
} | javascript | {
"resource": ""
} |
q33814 | parseCategories | train | function parseCategories (node, nodeType, feedType) {
var categoryMap = {};
var setCategory = function (category, attrProp) {
if (!category) {
return;
} else if (attrProp) {
category = utils.getAttr(category, attrProp);
}
if (!categoryMap[category]) {
categoryMap[category] = true;
}
};
var splitAndSetCategory = function (category, delimiter) {
category && category.split(delimiter).forEach(function (cat) {
setCategory(cat);
});
};
['category', 'dc:subject', 'itunes:category', 'media:category'].forEach(function (key) {
if (!node[key]) {
return;
}
utils.parse(node[key], function (category) {
if (key === 'category') {
setCategory.apply(null, (feedType === 'atom' ? [category, 'term'] : [utils.get(category)]));
} else if (key === 'dc:subject') {
splitAndSetCategory(utils.get(category), ' ');
} else if (key === 'itunes:category') {
//sometimes itunes:category has it's own itunes:category property
setCategory(category, 'text');
utils.parse(category[key] || category, function (cat) {
setCategory(cat, 'text');
});
} else if (key === 'media:category') {
splitAndSetCategory(utils.get(category), '/');
}
});
});
var categories = Object.keys(categoryMap);
return categories.length && categories.map(function (key) {
return key;
});
} | javascript | {
"resource": ""
} |
q33815 | parseComments | train | function parseComments (node, nodeType, feedType) {
var comments = utils.get(node.comments);
if (!comments && feedType === 'atom') {
utils.parse(node.link, function (link) {
var linkAttr = link['@'];
if (linkAttr && linkAttr.rel === 'replies' && linkAttr.href) {
comments = linkAttr.href;
//if comments are text/html then break out of loop
if (linkAttr.type === 'text/html') {
return true;
}
}
}, this, true);
}
return comments;
} | javascript | {
"resource": ""
} |
q33816 | parseEnclosures | train | function parseEnclosures (node, nodeType, feedType) {
var enclosuresMap = {};
['media:content', 'enclosure', 'link', 'enc:enclosure'].forEach(function (key) {
if (!node[key]) {
return;
}
utils.parse(node[key], function (enc) {
var enclosure,
encAttr = enc['@'];
if (!encAttr) {
return;
}
switch(key) {
case('media:content'):
enclosure = createEnclosure(encAttr.url, encAttr.type || encAttr.medium, encAttr.filesize);
break;
case('enclosure'):
enclosure = createEnclosure(encAttr.url, encAttr.type, encAttr.length);
break;
case('link'):
if (encAttr.rel === 'enclosure' && encAttr.href) {
enclosure = createEnclosure(encAttr.href, encAttr.type, encAttr.length);
}
break;
case('enc:enclosure'):
enclosure = createEnclosure(encAttr.url || encAttr['rdf:resource'], encAttr.type, encAttr.length);
break;
}
if (enclosure) {
enclosuresMap[enclosure.url] = enclosure;
}
});
});
var enclosures = Object.keys(enclosuresMap);
return enclosures.length && enclosures.map(function (key) {
return enclosuresMap[key];
});
} | javascript | {
"resource": ""
} |
q33817 | parseSource | train | function parseSource (node, nodeType, feedType) {
var source = {},
sourceNode = node.source,
temp;
if (!sourceNode) {
return;
}
if (temp = (feedType === 'atom' && utils.get(sourceNode.title)) || utils.get(sourceNode)) {
source.title = temp;
}
if (temp = (feedType === 'atom' && utils.getAttr(sourceNode.link, 'href')) || utils.getAttr(sourceNode, 'url')) {
source.url = temp;
}
return Object.keys(source).length && source;
} | javascript | {
"resource": ""
} |
q33818 | get | train | function get(obj, subkey) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return obj[subkey || '#'];
} | javascript | {
"resource": ""
} |
q33819 | getAttr | train | function getAttr(obj, attr) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return (attr && obj['@']) ? obj['@'][attr] : obj['@'];
} | javascript | {
"resource": ""
} |
q33820 | parse | train | function parse (el, parseFn, context, canBreak) {
if (!el) { return; }
if (!Array.isArray(el)) {
parseFn.call(context, el);
} else if (canBreak) {
el.some(parseFn, context);
} else {
el.forEach(parseFn, context);
}
} | javascript | {
"resource": ""
} |
q33821 | strArrayToObj | train | function strArrayToObj (array) {
return array && array.reduce(function(o, v) {
o[v] = true;
return o;
}, {});
} | javascript | {
"resource": ""
} |
q33822 | createOpenTag | train | function createOpenTag (tagName, attrs) {
var attrString = Object.keys(attrs).map(function (key) {
return ' ' + key + '="' + attrs[key] + '"';
}).join('');
return '<' + tagName + attrString + '>';
} | javascript | {
"resource": ""
} |
q33823 | getStandardTimeOffset | train | function getStandardTimeOffset(date) {
var jan = new Date(date.getFullYear(), 0, 1);
var jul = new Date(date.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
} | javascript | {
"resource": ""
} |
q33824 | fixInvalidDate | train | function fixInvalidDate(dateString) {
if (!dateString) {
return;
}
//Convert invalid dates' timezones to GMT using timezoneMap
dateString = dateString.replace(/BST?/i, function (match) {
return timezoneMap[match];
});
//Some dates come in as ET, CT etc.. and some don't have the correct offset.
//Matches /ET/EDT/EST/CT/CDT/CST/MT/MDT/MST/PT/PDT/PST if found at the end of a date string
var newDateString = dateString.replace(/(E|C|M|P)[DS+]?T$/i, function (match) {
var firstChar = match.charAt(0);
return isDaylightSavingsTime() ? (firstChar + 'DT') : (firstChar + 'ST');
});
return new Date(newDateString);
} | javascript | {
"resource": ""
} |
q33825 | getDate | train | function getDate (dateString) {
var date = new Date(dateString);
if (Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime())) {
return date;
}
//try to fix invalid date
date = fixInvalidDate(dateString);
//if date still isn't valid there's not more we can do..
if (!isNaN(date.getTime())) {
return date;
}
} | javascript | {
"resource": ""
} |
q33826 | makeConcat | train | function makeConcat(chunkType) {
switch (chunkType) {
case BUFFER:
return (a, b) => Buffer.concat([a, b]);
default:
return (a, b) => {
// console.log('[%d, %d]', a.length, b.length);
const t = new Uint8Array(a.length + b.length);
t.set(a);
t.set(b, a.length);
// console.log('%d: %s', t.length, new Buffer(t).toString('utf8'));
return t;
};
}
} | javascript | {
"resource": ""
} |
q33827 | isElementVisible | train | function isElementVisible(el) {
/*
* Checks if element (or an ancestor) is hidden via style properties.
* See https://stackoverflow.com/a/21696585/463471
*/
const isCurrentlyVisible = el.offsetParent !== null;
// Check if any part of the element is vertically within the viewport.
const position = el.getBoundingClientRect();
const wH =
window.innerHeight ||
/* istanbul ignore next */ document.documentElement.clientHeight;
const isWithinViewport =
(position.top >= 0 && position.top <= wH) ||
(position.bottom >= 0 && position.bottom <= wH);
return isCurrentlyVisible && isWithinViewport;
} | javascript | {
"resource": ""
} |
q33828 | Receiver | train | function Receiver() {
stream.Duplex.call(this, {
readableObjectMode: true
});
this._buffer = null;
this._frame = new Frame();
this._state = WAITING_FOR_HEADER;
} | javascript | {
"resource": ""
} |
q33829 | train | function(e){
if(e.type === 'mousemove' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseenter' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseleave' && this.onHover){
this.onHover(false);
}
else if(e.type === 'click' && this.onClick){
this.onClick(e.clientX, e.clientY);
}
} | javascript | {
"resource": ""
} | |
q33830 | train | function(e) {
if(this.onHover){
var coords = this.game.renderer.mouseToTileCoords(e.clientX, e.clientY);
this.onHover(coords);
}
} | javascript | {
"resource": ""
} | |
q33831 | train | function(element){
if(this._boundElement){
this.stopListening();
}
element.addEventListener('mousemove', this);
element.addEventListener('mouseenter', this);
element.addEventListener('mouseleave', this);
element.addEventListener('click', this);
this._boundElement = element;
} | javascript | {
"resource": ""
} | |
q33832 | train | function(){
if(!this._boundElement){
return false;
}
var el = this._boundElement;
el.removeEventListener('mousemove', this);
el.removeEventListener('mouseenter', this);
el.removeEventListener('mouseleave', this);
el.removeEventListener('click', this);
} | javascript | {
"resource": ""
} | |
q33833 | train | function(array, json) {
var i;
if (typeof json === 'object' && typeof json.length === 'number') {
for (i = 0; i < json.length; ++i) {
array.push(json[i]);
}
} else {
array.push(json);
}
} | javascript | {
"resource": ""
} | |
q33834 | train | function(sender, evt)
{
var cand = graph.getSelectionCellsForChanges(evt.getProperty('edit').changes);
var model = graph.getModel();
var cells = [];
for (var i = 0; i < cand.length; i++)
{
if ((model.isVertex(cand[i]) || model.isEdge(cand[i])) && graph.view.getState(cand[i]) != null)
{
cells.push(cand[i]);
}
}
graph.setSelectionCells(cells);
} | javascript | {
"resource": ""
} | |
q33835 | end | train | function end (next) {
filenames(dir, obj).forEach(function (filename) {
sm.emit('file', filename)
})
next()
} | javascript | {
"resource": ""
} |
q33836 | train | function(n){
if(typeof n === 'number'){
return n;
}
if(typeof n !== 'string'){
n = JSON.stringify(n)
}
var res = 0;
n.split("").map(function(bit){
res += bit.charCodeAt(0);
});
return res;
} | javascript | {
"resource": ""
} | |
q33837 | train | function(size){
this.data = [];
if(typeof size === 'undefined'){
return; // Empty instance of a bit array
}
if(typeof size !== 'number'){
size = shred(size);
}
for(var i=0; i<Math.ceil(size/INTEGER_SIZE); ++i){
this.data.push(0);
}
} | javascript | {
"resource": ""
} | |
q33838 | bridge_fetch | train | function bridge_fetch(size) {
var bridge_time = new JuttleMoment(last_seen_timestamp);
var time_filter = {term: {}};
time_filter.term[timeField] = bridge_time.valueOf();
var body = make_body(filter, null, null, direction, time_filter, size, timeField);
body.from = bridge_offset;
if (bridge_offset > deep_paging_limit) {
return Promise.reject(new Error('Cannot fetch more than ' + deep_paging_limit + ' points with the same timestamp'));
}
return common.search(client, indices, type, body)
.then(function(result) {
var processed = points_and_eof_from_es_result(result, body);
bridge_offset += body.size;
if (processed.eof) {
// end of the bridge fetch, not necessarily end of the query
// (if it really is the end of the query then the non-brige-path
// will fetch one more empty batch and return eof)
should_execute_bridge_fetch = false;
query_start = bridge_time.add(JuttleMoment.duration(1, 'milliseconds'));
processed.eof = false;
}
return processed;
});
} | javascript | {
"resource": ""
} |
q33839 | drop_last_time_stamp_and_maybe_bridge_fetch | train | function drop_last_time_stamp_and_maybe_bridge_fetch(processed, size) {
if (processed.eof) { return processed; }
var last = _.last(processed.points);
last_seen_timestamp = last && last.time;
var non_simultaneous_points = processed.points.filter(function(pt) {
return pt.time !== last_seen_timestamp;
});
if (non_simultaneous_points.length === 0 && processed.points.length !== 0) {
should_execute_bridge_fetch = true;
bridge_offset = 0;
return bridge_fetch(size);
} else {
query_start = new JuttleMoment(last_seen_timestamp);
processed.points = non_simultaneous_points;
return processed;
}
} | javascript | {
"resource": ""
} |
q33840 | makeDecoder | train | function makeDecoder(chunkType) {
if (chunkType === BUFFER) {
return function (buf) {
return buf.toString('utf8');
};
}
if (isnode) {
return function (a) {
return new Buffer(a).toString('utf8');
};
}
var decoder = null;
return function (buf) {
if (!decoder) {
decoder = new TextDecoder();
}
return decoder.decode(buf);
};
} | javascript | {
"resource": ""
} |
q33841 | train | function(signal1, signal2, options){
options = options || {};
options = _.defaults(options, defaultOptions);
// ensure signal2 is not longer than signal2
if(signal1.length < signal2.length){
var tmp = signal1;
signal1 = signal2;
signal2 = tmp;
}
if(options.method == "cauchy"){
return cauchy(signal1,signal2,options);
} else {
return specConvolution(signal1, signal2,options);
}
} | javascript | {
"resource": ""
} | |
q33842 | train | function(signal1, signal2, options){
options = options || {};
options.epsilon = options.epsilon || 1E-08;
var sig1 = Signal(signal1);
var sig2 = Signal(signal2);
if(signal1.length != signal2.length) return false;
var diffSQ = _.reduce(_.range(signal1.length), function(d,idx){
var diff = (sig1[idx].value-sig2[idx].value);
return d + diff * diff;
},0);
return diffSQ/signal1.length < options.epsilon;
} | javascript | {
"resource": ""
} | |
q33843 | train | function(callback) {
log('Connecting...');
MongoClient.connect(dbUrl, dbOptions, function(err, dbConn) {
if(err) {
log('Cannot connect: ' + err);
callback(err);
return;
}
log('Connected!');
isConnected = true;
db = dbConn;
// http://stackoverflow.com/a/18715857/446681
db.on('close', function() {
log('Connection was closed!!!');
isConnected = false;
});
log('Executing...');
callback(null, db);
});
} | javascript | {
"resource": ""
} | |
q33844 | train | function(node, msg) {
if (node.complete === "complete") {
return msg;
}
try {
return (node.prop||"payload").split(".").reduce(function (obj, i) {
return obj[i];
}, msg);
} catch (err) {
return; // undefined
}
} | javascript | {
"resource": ""
} | |
q33845 | hook | train | function hook(p, key) {
var h = function h(e) {
// update only when the argument is an Event object
if (e && e instanceof Event) {
// suppress updating on the inherit tag
e.preventUpdate = true;
// call original method
p[key](e);
// update automatically
p.update();
} else {
p[key](e);
}
};
h._inherited = true;
return h;
} | javascript | {
"resource": ""
} |
q33846 | init | train | function init() {
var _this = this;
/** Store the keys originally belonging to the tag */
this.one('update', function () {
_this._ownPropKeys = getAllPropertyNames(_this);
_this._ownOptsKeys = getAllPropertyNames(_this.opts);
});
/** Inherit the properties from parents on each update */
this.on('update', function () {
var ignoreProps = ['root', 'triggerDomEvent'];
getAllPropertyNames(_this.parent)
// TODO:
// Skipping 'triggerDomEvent' is a temporal workaround.
// In some cases function on the child would be overriden.
// This issue needs more study...
.filter(function (key) {
return ! ~_this._ownPropKeys.concat(ignoreProps).indexOf(key);
}).forEach(function (key) {
_this[key] = typeof _this.parent[key] != 'function' || _this.parent[key]._inherited ? _this.parent[key] : hook(_this.parent, key);
});
getAllPropertyNames(_this.parent.opts).filter(function (key) {
return ! ~_this._ownOptsKeys.indexOf(key) && key != 'riotTag';
}).forEach(function (key) {
_this.opts[key] = typeof _this.parent.opts[key] != 'function' || _this.parent.opts[key]._inherited ? _this.parent.opts[key] : hook(_this.parent, key);
});
});
} | javascript | {
"resource": ""
} |
q33847 | querySelector | train | function querySelector(sel, flag) {
var node = this.root.querySelector(normalize(sel));
return !flag ? node : node._tag || undefined;
} | javascript | {
"resource": ""
} |
q33848 | querySelectorAll | train | function querySelectorAll(sel, flag) {
var nodes = this.root.querySelectorAll(normalize(sel));
return !flag ? nodes : Array.prototype.map.call(nodes, function (node) {
return node._tag || undefined;
});
} | javascript | {
"resource": ""
} |
q33849 | fragmentClick | train | function fragmentClick(e) {
var el = e.target;
var href;
while (el && el.nodeName !== 'HTML' && !el.getAttribute('data-render-html')) { el = el.parentNode };
if (el && (href = el.getAttribute('data-render-html'))) {
bindEditor(generator.fragment$[href]);
e.preventDefault(); // will also stop pager because it checks for e.defaultPrevented
}
} | javascript | {
"resource": ""
} |
q33850 | bindEditor | train | function bindEditor(fragment) {
saveBreakHold();
if (fragment) {
editor.$name.text(fragment._href);
if (fragment._holdUpdates) {
editText(fragment._holdText);
}
else {
editText(fragment._hdr + fragment._txt);
}
editor.binding = fragment._href;
}
else {
editor.$name.text('');
editText('');
editor.binding = '';
}
} | javascript | {
"resource": ""
} |
q33851 | editorUpdate | train | function editorUpdate() {
if (editor.binding) {
if ('hold' === generator.clientUpdateFragmentText(editor.binding, editor.$edit.val())) {
editor.holding = true;
}
}
} | javascript | {
"resource": ""
} |
q33852 | saveBreakHold | train | function saveBreakHold() {
if (editor.binding && editor.holding) {
generator.clientUpdateFragmentText(editor.binding, editor.$edit.val(), true);
editor.holding = false;
}
} | javascript | {
"resource": ""
} |
q33853 | train | function(type) {
//define if put type is present in config
if (config.moduleTypes.indexOf(type) > -1) {
config.moduleType = type;
fs.writeFile(path.resolve(__dirname, 'config.json'), JSON.stringify(config, null, 4), 'utf8', function (err) {
if (err) {
return console.log(err);
}
});
} else {
return console.log('Wrong type, available types: %j', config.moduleTypes);
}
} | javascript | {
"resource": ""
} | |
q33854 | train | function(folder) {
var type = config.moduleType;
var appPath;
if (folder) {
if (path.isAbsolute(folder)) {
appPath = path.join(folder);
} else {
appPath = path.join(process.cwd(), folder);
}
} else {
appPath = path.join(process.cwd());
}
var appSrc = config.apps[type];
helpers.gitClone(appSrc, appPath);
} | javascript | {
"resource": ""
} | |
q33855 | train | function (){
var offset = parseInt(self._utcoffset());
var minus = false;
if (offset < 0)
{
minus = true;
offset = -offset;
}
var minutes = offset % 60;
var hours = (offset - minutes) / 60;
offset = self._zeropad(hours) + self._zeropad(minutes);
if (minus) offset = "-"+offset;
else offset = "+"+offset;
return offset;
} | javascript | {
"resource": ""
} | |
q33856 | isFileOfType | train | async function isFileOfType(filename, condition){
try{
// get stats
const stats = await _fs.stat(filename);
// is directory ?
return condition(stats);
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
throw e;
}
}
} | javascript | {
"resource": ""
} |
q33857 | bulkCopy | train | async function bulkCopy(srcset, createDestinationDirs=true, defaultFilemode=0o750, defaultDirmode=0o777){
// create destination directories in advance ?
if (createDestinationDirs === true){
// get unique paths from filelist
const dstDirs = Array.from(new Set(srcset.map((set) => _path.dirname(set[1]))));
// create dirs
for (let i=0;i<dstDirs.length;i++){
await _mkdirp(dstDirs[i], defaultDirmode, true);
}
}
// create tasks
const tasks = srcset.map((set) => _async.PromiseResolver(_copy, set[0], set[1], set[2] || defaultFilemode));
// resolve tasks in parallel with task limit 100
await _async.parallel(tasks, 100);
} | javascript | {
"resource": ""
} |
q33858 | isPrivateBrowsingMode | train | function isPrivateBrowsingMode () {
try {
localStorage.setItem(TEST_KEY, '1')
localStorage.removeItem(TEST_KEY)
return false
} catch (error) {
return true
}
} | javascript | {
"resource": ""
} |
q33859 | extractDomProperties | train | function extractDomProperties(domNode, regex, removeDomAttributes = false) {
if(regex && classof(regex) !== 'RegExp'){
throw Error('Second argument is passed but it must be a Regular-Expression');
}
let domViewAttributes = {};
let toBeRemovedAttributes = [];
for(let key in domNode.attributes) {
if(!domNode.attributes.hasOwnProperty(key)){
continue;
}
let node = domNode.attributes[key];
if(regex){
let matched = regex.exec(node.name);
if(matched !== null) {
let [ ,name ] = matched;
domViewAttributes[name] = node.value;
removeDomAttributes ? toBeRemovedAttributes.push(node.name) : null;
}
}
else if(!regex) {
domViewAttributes[node.name] = node.value;
}
}
if(removeDomAttributes){
for(let attribute of toBeRemovedAttributes){
domNode.removeAttribute(attribute);
}
}
return domViewAttributes;
} | javascript | {
"resource": ""
} |
q33860 | Nello | train | function Nello(token)
{
if (!(this instanceof Nello))
return new Nello(token);
_events.call(this);
this.token = token;
if (!this.token)
throw new Error('Please check the arguments!');
} | javascript | {
"resource": ""
} |
q33861 | RotaryEncoder | train | function RotaryEncoder(pinA, pinB) {
this.gpioA = new Gpio(pinA, 'in', 'both');
this.gpioB = new Gpio(pinB, 'in', 'both');
this.a = 2;
this.b = 2;
this.gpioA.watch((err, value) => {
if (err) {
this.emit('error', err);
return;
}
this.a = value;
});
this.gpioB.watch((err, value) => {
if (err) {
this.emit('error', err);
return;
}
this.b = value;
this.tick();
});
} | javascript | {
"resource": ""
} |
q33862 | serve | train | function serve(res, file, maxAge) {
log.debug(`Serving: ${ file }`)
res.status(200)
.set('Cache-Control', `max-age=${ maxAge }`)
.sendFile(file, err => {
if (err) {
log.error(err)
res.status(err.status).end()
return
}
})
} | javascript | {
"resource": ""
} |
q33863 | find | train | function find(pathname, patterns) {
for (const entry of patterns)
if (minimatch(pathname, entry.pattern))
return entry.handler
return null
} | javascript | {
"resource": ""
} |
q33864 | FileInputStream | train | function FileInputStream(src){
// wrap into Promise
return new Promise(function(resolve, reject){
// open read stream
const istream = _fs.createReadStream(src);
istream.on('error', reject);
istream.on('open', function(){
resolve(istream);
});
});
} | javascript | {
"resource": ""
} |
q33865 | Auth | train | function Auth(clientId, clientSecret)
{
if (!(this instanceof Auth))
return new Auth(clientId, clientSecret);
this.clientId = clientId;
this.clientSecret = clientSecret;
if (!this.clientId || !this.clientSecret)
throw new Error('No Client ID / Client Secret provided!');
} | javascript | {
"resource": ""
} |
q33866 | isSymlink | train | async function isSymlink(filename){
try{
// get stats
const stats = await _fs.lstat(filename);
// is symlink ?
return stats.isSymbolicLink();
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
throw e;
}
}
} | javascript | {
"resource": ""
} |
q33867 | train | function(file, targetPath) {
rigger(
file,
{ output: targetPath},
function(error, content) {
if (error) {
console.log(error);
return;
}
fs.writeFile(targetPath, content, 'utf8');
}
);
} | javascript | {
"resource": ""
} | |
q33868 | renderJSON | train | function renderJSON( request, reply, err, result ){
if(err){
if(err.code === 404){
reply(new hapi.error.notFound(err.message));
}else{
reply(new hapi.error.badRequest(err.message));
}
}else{
reply(result).type('application/json; charset=utf-8');
}
} | javascript | {
"resource": ""
} |
q33869 | _initDefaultConnection | train | function _initDefaultConnection() {
if ('CLOUD_STORAGE_ACCOUNT' in process.env) {
var accountSettings = utils.parseAccountString(process.env.CLOUD_STORAGE_ACCOUNT);
if (accountSettings !== null) {
_defaultClientSetting = _.defaults(_defaultClientSetting, accountSettings);
}
}
} | javascript | {
"resource": ""
} |
q33870 | train | function (a, b) {
var Kernel = [0.05, 0.25, 0.4, 0.25, 0.05];
var width = this.getWidth();
var weight = this.getWeight();
//#pragma omp parallel for
for (var y = 0; y < weight; y++) {
for (var x = 0; x < width; x++) {
var index = y * width + x;
a[index] = 0;
for (var i = -2; i <= 2; i++) {
for (var j = -2; j <= 2; j++) {
var nx = x + i;
var ny = y + j;
if (nx < 0) nx = -nx;
if (ny < 0) ny = -ny;
if (nx >= width) nx = (width << 1) - nx - 1;
if (ny >= weight) ny = (weight << 1) - ny - 1;
a[index] += Kernel[i + 2] * Kernel[j + 2] * b[ny * width + nx];
}
}
}
}
} | javascript | {
"resource": ""
} | |
q33871 | canonical | train | function canonical() {
var tags = document.getElementsByTagName('link');
// eslint-disable-next-line no-cond-assign
for (var i = 0, tag; tag = tags[i]; i++) {
if (tag.getAttribute('rel') === 'canonical') {
return tag.getAttribute('href');
}
}
} | javascript | {
"resource": ""
} |
q33872 | hasChanged | train | function hasChanged(depValues, current, dependencies) {
var len = dependencies.length;
var i = 0;
var result = false;
while (len--) {
var dep = dependencies[i++];
var value = get(current, dep);
if (get(depValues, dep) !== value) {
result = true;
set(depValues, dep, value);
}
}
return result;
} | javascript | {
"resource": ""
} |
q33873 | initWatch | train | function initWatch(obj, depValues, dependencies) {
var len = dependencies.length;
if (len === 0) {
return false;
}
var i = 0;
while (len--) {
var dep = dependencies[i++];
var value = clone(get(obj, dep));
set(depValues, dep, value);
}
return true;
} | javascript | {
"resource": ""
} |
q33874 | timestamp | train | function timestamp(schema, options) {
options = options || {};
// Set defaults
options = Object.assign({
createdName: 'createdAt',
updatedName: 'updatedAt',
disableCreated: false,
disableUpdated: false
}, options);
// Add fields if not disabled
if (!options.disableCreated) {
addSchemaField(schema, options.createdName, {type: Date});
}
if (!options.disableUpdated) {
addSchemaField(schema, options.updatedName, {type: Date});
}
// Add pre-save hook to save dates of creation and modification
schema.pre('save', preSave);
/**
* Callback for the schema pre save
*
* @this mongoose.Schema
* @param {Function} next The next pre save callback in chain
* @returns {undefined}
*/
function preSave(next) {
const _ref = this.get(options.createdName);
if (!options.disableUpdated) {
this[options.updatedName] = new Date();
}
if (!options.disableCreated && (_ref === undefined || _ref === null)) {
this[options.createdName] = new Date();
}
next();
}
} | javascript | {
"resource": ""
} |
q33875 | preSave | train | function preSave(next) {
const _ref = this.get(options.createdName);
if (!options.disableUpdated) {
this[options.updatedName] = new Date();
}
if (!options.disableCreated && (_ref === undefined || _ref === null)) {
this[options.createdName] = new Date();
}
next();
} | javascript | {
"resource": ""
} |
q33876 | train | function(key, path, next) {
this.fileSystem.get(key, function(err, data) {
fs.writeFile(path, data, function(err) {
if (err) {
console.log(err);
}
next(err, data);
});
});
} | javascript | {
"resource": ""
} | |
q33877 | train | function(next) {
var self = this;
var obj = {};
obj.path = path.join(os.tmpdir, randomstring.generate());
obj.original_name = self.document[self.has_attached_file].original_url.split('/').pop();
this.downloadUrl(self.document[self.has_attached_file].original_url, obj.path, function() {
self.identify({input: obj.path}, function(err, identity) {
fs.stat(obj.path, function(err, stats) {
obj.file_size = stats.size;
obj.content_type = 'image/'+identity.format.toLowerCase();
next(err, obj);
})
})
});
} | javascript | {
"resource": ""
} | |
q33878 | train | function (data, trans, key) {
if (typeof data[key] !== "object") {
throw new SyntaxError('Cannot extend a scalar value. Transform: ' + util.getTransDescription(trans) + ' Data: ' + JSON.stringify(data));
}
for (var prop in trans) {
if (typeof data[prop] === "object") {
return extend(data[key], trans[prop], prop);
}
data[key][prop] = trans[prop];
}
} | javascript | {
"resource": ""
} | |
q33879 | train | function (data, transform) {
if (typeof transform.jsontl !== "undefined") {
if (typeof transform.jsontl.transform !== "undefined") {
return locators.in(data, transform.jsontl.transform);
}
}
throw new Error("Tranform definition invalid");
} | javascript | {
"resource": ""
} | |
q33880 | gunzip | train | async function gunzip(input, dst){
// is input a filename or stream ?
if (typeof input === 'string'){
input = await _fileInputStream(input);
}
// decompress
const gzipStream = input.pipe(_zlib.createGunzip());
// write content to file
return _fileOutputStream(gzipStream, dst);
} | javascript | {
"resource": ""
} |
q33881 | targetComplete | train | function targetComplete(target) {
let complete = true;
Object.values(target).forEach((value) => {
if (value > 0)
complete = false;
});
return complete;
} | javascript | {
"resource": ""
} |
q33882 | guid | train | function guid() {
function _s4() {
return Math.floor(
(1 + Math.random()) * 0x10000
).toString(16).substring(1);
}
return _s4() + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + _s4() + _s4();
} | javascript | {
"resource": ""
} |
q33883 | getDecoratorTypeFromArguments | train | function getDecoratorTypeFromArguments(args) {
'use strict';
if (args.length === 0 || args.length > 3) {
return DecoratorType.None;
}
var kind = typeof (args.length === 1 ? args[0] : args[2]);
switch (kind) {
case 'function':
return DecoratorType.Class;
case 'number':
return DecoratorType.Parameter;
case 'undefined':
return DecoratorType.Property;
case 'object':
return DecoratorType.Method;
default:
return DecoratorType.None;
}
} | javascript | {
"resource": ""
} |
q33884 | train | function( tagName, inputString ) {
let ret = inputString;
if ( ret.indexOf( '<' + tagName ) === -1 ) {
ret = `<${tagName}>${ret}`;
}
if ( ret.indexOf( '</' + tagName + '>' ) === -1 ) {
ret = `${ret}</${tagName}>`;
}
return ret;
} | javascript | {
"resource": ""
} | |
q33885 | variance | train | function variance(values) {
let avg = mean(values);
return mean(values.map((e) => Math.pow(e - avg, 2)));
} | javascript | {
"resource": ""
} |
q33886 | train | function (path, image) {
if (image instanceof Buffer) {
return Promise.denodeify(PNGImage.loadImage)(image);
} else if ((typeof path === 'string') && !image) {
return Promise.denodeify(PNGImage.readImage)(path);
} else {
return image;
}
} | javascript | {
"resource": ""
} | |
q33887 | fadeOutScreen | train | function fadeOutScreen(screen) {
var screenElement = document.querySelector(screen);
return Velocity(screenElement, {
opacity: 0,
}, {
display: "none",
duration: 500
});
} | javascript | {
"resource": ""
} |
q33888 | eat | train | function eat(expected) {
if (s[i] !== expected) {
throw new Error("bad JSURL syntax: expected " + expected + ", got " + (s && s[i]));
}
i++;
} | javascript | {
"resource": ""
} |
q33889 | decode | train | function decode() {
var beg = i;
var ch;
var r = "";
// iterate until we reach the end of the string or "~" or ")"
while (i < len && (ch = s[i]) !== "~" && ch !== ")") {
switch (ch) {
case "*":
if (beg < i) {
r += s.substring(beg, i);
}
if (s[i + 1] === "*") {
// Unicode characters > 0xff (255), which are encoded as "**[4-digit code]"
r += String.fromCharCode(parseInt(s.substring(i + 2, i + 6), 16));
beg = (i += 6);
} else {
// Unicode characters <= 0xff (255), which are encoded as "*[2-digit code]"
r += String.fromCharCode(parseInt(s.substring(i + 1, i + 3), 16));
beg = (i += 3);
}
break;
case "!":
if (beg < i) {
r += s.substring(beg, i);
}
r += "$";
beg = ++i;
break;
default:
i++;
}
}
return r + s.substring(beg, i);
} | javascript | {
"resource": ""
} |
q33890 | train | function (_a) {
var _b = _a === void 0 ? {} : _a, baseDir = _b.baseDir, _c = _b.fontsPathToSave, fontsPathToSave = _c === void 0 ? process.cwd() + "/build/static/fonts/" : _c, _d = _b.iconUrl, iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d, _e = _b.fontReg, fontReg = _e === void 0 ? /@font-face{font-family:anticon;src:url(.*)}$/g : _e, _f = _b.urlReg, urlReg = _f === void 0 ? reg : _f, _g = _b.cssPath, cssPath = _g === void 0 ? process.cwd() + "/build/static/css/" : _g, _h = _b.newFontsPath, newFontsPath = _h === void 0 ? "/static/fonts/" : _h;
if (baseDir !== "") {
fontsPathToSave = getPath(baseDir, fontsPathToSave);
cssPath = getPath(baseDir, cssPath);
}
return exports.finder(cssPath, function (content, filePath) {
var cssContents = content.toString();
var m = cssContents.match(urlReg);
if (m) {
// create fonts folder if not exists
if (!fs.existsSync(fontsPathToSave)) {
fs.mkdir(fontsPathToSave, function (err) {
if (err) {
throw err;
}
console.log("mkdir " + fontsPathToSave + " success");
});
}
m.forEach(function (item) {
var itemInfo = path.parse(item);
var shortname = itemInfo.base.replace(/((\?|#).*)/g, "");
exports.downloader(item, fontsPathToSave + "/" + shortname, function (err, c) {
if (err) {
throw err;
}
var replacedContents = cssContents.replace(new RegExp(iconUrl, "gi"), newFontsPath);
fs.writeFile(filePath, replacedContents, function (err) {
if (err) {
throw err;
}
console.log("replace " + shortname + " done.");
});
});
});
}
else {
console.log("no results founded.");
}
});
} | javascript | {
"resource": ""
} | |
q33891 | untar | train | async function untar(istream, dst){
// is destination a directory ?
if (!await _isDirectory(dst)){
throw Error('Destination is not a valid directory: ' + dst);
}
// get instance
const extract = _tar.extract();
// list of extracted files
const items = [];
// wrap into Promise
return new Promise(function(resolve, reject){
// process each tar entry!
extract.on('entry', async function(header, fstream, next){
// add item to list
items.push(header.name);
// directory entry ?
if (header.type == 'directory'){
// create subdirectory
await _mkdirp(_path.join(dst, header.name), header.mode, true);
// file entry ?
}else if (header.type == 'file'){
// redirect content to file
await _fileOutputStream(fstream, _path.join(dst, header.name), header.mode);
}
// next entry
next();
});
// listener
extract.on('finish', function(){
resolve(items);
});
extract.on('error', reject);
// pipe through extractor
istream.pipe(extract);
});
} | javascript | {
"resource": ""
} |
q33892 | zipDirectory | train | function zipDirectory(directories, dest, callback) {
var archive = archiver.create('zip', {gzip: false});
// Where to write the file
var destStream = fs.createWriteStream(dest);
archive.on('error', function(err) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archiving failed', err));
});
archive.on('entry', function(file) {
// do nothing
});
destStream.on('error', function(err) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'WriteStream failed', err));
});
destStream.on('close', function() {
var size = archive.pointer();
gutil.log(PLUGIN_NAME, gutil.colors.green('Created ' + dest + ' (' + size + ' bytes)'));
callback();
});
archive.pipe(destStream);
directories.forEach(function(directory) {
if (fs.lstatSync(directory.src).isDirectory()) {
archive.directory(directory.src, directory.dest);
} else {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, directory.src + ' is not a valid directory'));
return;
}
});
archive.finalize();
} | javascript | {
"resource": ""
} |
q33893 | encode | train | function encode(s) {
if (!/[^\w-.]/.test(s)) {
// if the string is only made up of alpha-numeric, underscore,
// dash or period, we can use it directly.
return s;
}
// we need to escape other characters
s = s.replace(/[^\w-.]/g, function(ch) {
if (ch === "$") {
return "!";
}
// use the character code for this one
ch = ch.charCodeAt(0);
if (ch < 0x100) {
// if less than 256, use "*[2-char code]"
return "*" + ("00" + ch.toString(16)).slice(-2);
} else {
// use "**[4-char code]"
return "**" + ("0000" + ch.toString(16)).slice(-4);
}
});
return s;
} | javascript | {
"resource": ""
} |
q33894 | setupTypedArray | train | function setupTypedArray(name, fallback) {
// check if TypedArray exists
// typeof on Minefield and Chrome return function, typeof on Webkit returns object.
if (typeof this[name] !== "function" && typeof this[name] !== "object") {
// nope.. check if WebGLArray exists
if (typeof this[fallback] === "function" && typeof this[fallback] !== "object") {
this[name] = this[fallback];
} else {
// nope.. set as Native JS array
this[name] = function(obj) {
if (obj instanceof Array) {
return obj;
} else if (typeof obj === "number") {
return new Array(obj);
}
};
}
}
} | javascript | {
"resource": ""
} |
q33895 | DFT | train | function DFT(bufferSize, sampleRate) {
FourierTransform.call(this, bufferSize, sampleRate);
var N = bufferSize/2 * bufferSize;
var TWO_PI = 2 * Math.PI;
this.sinTable = new Float32Array(N);
this.cosTable = new Float32Array(N);
for (var i = 0; i < N; i++) {
this.sinTable[i] = Math.sin(i * TWO_PI / bufferSize);
this.cosTable[i] = Math.cos(i * TWO_PI / bufferSize);
}
} | javascript | {
"resource": ""
} |
q33896 | Oscillator | train | function Oscillator(type, frequency, amplitude, bufferSize, sampleRate) {
this.frequency = frequency;
this.amplitude = amplitude;
this.bufferSize = bufferSize;
this.sampleRate = sampleRate;
//this.pulseWidth = pulseWidth;
this.frameCount = 0;
this.waveTableLength = 2048;
this.cyclesPerSample = frequency / sampleRate;
this.signal = new Float32Array(bufferSize);
this.envelope = null;
switch(parseInt(type, 10)) {
case DSP.TRIANGLE:
this.func = Oscillator.Triangle;
break;
case DSP.SAW:
this.func = Oscillator.Saw;
break;
case DSP.SQUARE:
this.func = Oscillator.Square;
break;
default:
case DSP.SINE:
this.func = Oscillator.Sine;
break;
}
this.generateWaveTable = function() {
Oscillator.waveTable[this.func] = new Float32Array(2048);
var waveTableTime = this.waveTableLength / this.sampleRate;
var waveTableHz = 1 / waveTableTime;
for (var i = 0; i < this.waveTableLength; i++) {
Oscillator.waveTable[this.func][i] = this.func(i * waveTableHz/this.sampleRate);
}
};
if ( typeof Oscillator.waveTable === 'undefined' ) {
Oscillator.waveTable = {};
}
if ( typeof Oscillator.waveTable[this.func] === 'undefined' ) {
this.generateWaveTable();
}
this.waveTable = Oscillator.waveTable[this.func];
} | javascript | {
"resource": ""
} |
q33897 | checkLater | train | function checkLater() {
setTimeout(function () {
ctrl.options(ctrl.searchTerms, function (options) {
ctrl._options = options;
if (options.length === 0) checkLater();
$scope.$apply();
});
}, 1000);
} | javascript | {
"resource": ""
} |
q33898 | checksum | train | function checksum(src, algorithm='sha256', outputFormat='hex'){
return new Promise(async function(resolve, reject){
// hash engine
const hash = _crypto.createHash(algorithm);
// events
hash.on('readable', function(){
// get hashsum
const sum = hash.read();
// data available ?
if (!sum){
return;
}
// hex, base64 or buffer
switch (outputFormat){
case 'base64':
resolve(sum.toString('base64'));
break;
case 'raw':
case 'buffer':
resolve(sum);
break;
default:
resolve(sum.toString('hex'));
break;
}
});
hash.on('error', function(e){
reject(e);
})
try{
// open file input stream
const input = await _fInputStream(src);
// stream hashing
input.pipe(hash);
}catch(e){
reject(e);
}
});
} | javascript | {
"resource": ""
} |
q33899 | mkdirp | train | async function mkdirp(dir, mode=0o777, recursive=false){
// stats command executable ? dir/file exists
const stats = await _statx(dir);
// dir already exists ?
if (stats){
// check if its a directory
if (!stats.isDirectory()){
throw new Error('Requested directory <' + dir + '> already exists and is not of type directory');
}
// check mode
if (stats.mode !== mode){
await _fs.chmod(dir, mode);
}
// create it recursivly
}else if (recursive){
// absolute or relative path ? make it absolute
// split into components
const dirComponents = _path.parse(_path.resolve(dir));
// get root dir (posix + windows)
const rootDir = dirComponents.root;
// extract dir (without root)
const dirRelativePath = _path.join(dirComponents.dir, dirComponents.base).substring(rootDir.length);
// split into parts
const subdirs = dirRelativePath.split(_path.sep);
// minimum of 1 segement required - this function does not create directories within filesystem root
if (subdirs.length < 2){
throw new Error('Recursive mkdir does not create directories within filesystem root!');
}
// build initial directory
let dyndir = _path.join(rootDir, subdirs.shift());
// iterate over path
while (subdirs.length > 0){
// append part
dyndir = _path.join(dyndir, subdirs.shift());
// stats command executable ? dir/file exists
const cstats = await _statx(dyndir);
// dir already exists ?
if (cstats){
// check if its a directory
if (!cstats.isDirectory()){
throw new Error('Requested path <' + dyndir + '> already exists and not of type directory');
}
// create directory
}else{
await _fs.mkdir(dyndir, mode);
}
}
// just create top level
}else{
await _fs.mkdir(dir, mode);
}
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.