repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
eaze/potluck-opentok-adapter | vendor/opentok.js | DataChanneMessageEvent | function DataChanneMessageEvent (event) {
this.data = event.data;
this.source = event.source;
this.lastEventId = event.lastEventId;
this.origin = event.origin;
this.timeStamp = event.timeStamp;
this.type = event.type;
this.ports = event.ports;
this.path = event.path;
} | javascript | function DataChanneMessageEvent (event) {
this.data = event.data;
this.source = event.source;
this.lastEventId = event.lastEventId;
this.origin = event.origin;
this.timeStamp = event.timeStamp;
this.type = event.type;
this.ports = event.ports;
this.path = event.path;
} | [
"function",
"DataChanneMessageEvent",
"(",
"event",
")",
"{",
"this",
".",
"data",
"=",
"event",
".",
"data",
";",
"this",
".",
"source",
"=",
"event",
".",
"source",
";",
"this",
".",
"lastEventId",
"=",
"event",
".",
"lastEventId",
";",
"this",
".",
... | Wraps up a native RTCDataChannelEvent object for the message event. This is so we never accidentally leak the native DataChannel. @constructor @private | [
"Wraps",
"up",
"a",
"native",
"RTCDataChannelEvent",
"object",
"for",
"the",
"message",
"event",
".",
"This",
"is",
"so",
"we",
"never",
"accidentally",
"leak",
"the",
"native",
"DataChannel",
"."
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L12866-L12875 | train |
eaze/potluck-opentok-adapter | vendor/opentok.js | PeerConnectionChannels | function PeerConnectionChannels (pc) {
/// Private Data
var channels = [],
api = {};
/// Private API
var remove = function remove (channel) {
OT.$.filter(channels, function(c) {
return channel !== c;
});
};
var add = function add (nativeChannel) {
var channe... | javascript | function PeerConnectionChannels (pc) {
/// Private Data
var channels = [],
api = {};
/// Private API
var remove = function remove (channel) {
OT.$.filter(channels, function(c) {
return channel !== c;
});
};
var add = function add (nativeChannel) {
var channe... | [
"function",
"PeerConnectionChannels",
"(",
"pc",
")",
"{",
"/// Private Data",
"var",
"channels",
"=",
"[",
"]",
",",
"api",
"=",
"{",
"}",
";",
"/// Private API",
"var",
"remove",
"=",
"function",
"remove",
"(",
"channel",
")",
"{",
"OT",
".",
"$",
".",... | Contains a collection of DataChannels for a particular RTCPeerConnection @param [RTCPeerConnection] pc A native peer connection object @constructor @private | [
"Contains",
"a",
"collection",
"of",
"DataChannels",
"for",
"a",
"particular",
"RTCPeerConnection"
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L13023-L13094 | train |
eaze/potluck-opentok-adapter | vendor/opentok.js | function(messageDelegate) {
return function(event) {
if (event.candidate) {
messageDelegate(OT.Raptor.Actions.CANDIDATE, {
candidate: event.candidate.candidate,
sdpMid: event.candidate.sdpMid || '',
sdpMLineIndex: event.candidate.sdpMLineIndex || 0
});
} els... | javascript | function(messageDelegate) {
return function(event) {
if (event.candidate) {
messageDelegate(OT.Raptor.Actions.CANDIDATE, {
candidate: event.candidate.candidate,
sdpMid: event.candidate.sdpMid || '',
sdpMLineIndex: event.candidate.sdpMLineIndex || 0
});
} els... | [
"function",
"(",
"messageDelegate",
")",
"{",
"return",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"candidate",
")",
"{",
"messageDelegate",
"(",
"OT",
".",
"Raptor",
".",
"Actions",
".",
"CANDIDATE",
",",
"{",
"candidate",
":",
"event"... | Helper function to forward Ice Candidates via +messageDelegate+ | [
"Helper",
"function",
"to",
"forward",
"Ice",
"Candidates",
"via",
"+",
"messageDelegate",
"+"
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L13208-L13220 | train | |
eaze/potluck-opentok-adapter | vendor/opentok.js | fixFitModeCover | function fixFitModeCover(element, containerWidth, containerHeight, intrinsicRatio, rotated) {
var $video = OT.$('.OT_video-element', element);
if ($video.length > 0) {
var cssProps = {left: '', top: ''};
if (OTPlugin.isInstalled()) {
cssProps.width = '100%';
cssProps.... | javascript | function fixFitModeCover(element, containerWidth, containerHeight, intrinsicRatio, rotated) {
var $video = OT.$('.OT_video-element', element);
if ($video.length > 0) {
var cssProps = {left: '', top: ''};
if (OTPlugin.isInstalled()) {
cssProps.width = '100%';
cssProps.... | [
"function",
"fixFitModeCover",
"(",
"element",
",",
"containerWidth",
",",
"containerHeight",
",",
"intrinsicRatio",
",",
"rotated",
")",
"{",
"var",
"$video",
"=",
"OT",
".",
"$",
"(",
"'.OT_video-element'",
",",
"element",
")",
";",
"if",
"(",
"$video",
".... | Sets the video element size so by preserving the intrinsic aspect ratio of the element content
but altering the width and height so that the video completely covers the container.
@param {Element} element the container of the video element
@param {number} containerWidth
@param {number} containerHeight
@param {number} ... | [
"Sets",
"the",
"video",
"element",
"size",
"so",
"by",
"preserving",
"the",
"intrinsic",
"aspect",
"ratio",
"of",
"the",
"element",
"content",
"but",
"altering",
"the",
"width",
"and",
"height",
"so",
"that",
"the",
"video",
"completely",
"covers",
"the",
"c... | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L15203-L15253 | train |
eaze/potluck-opentok-adapter | vendor/opentok.js | function(config) {
_cleanup();
if (!config) config = {};
_global = config.global || {};
_partners = config.partners || {};
if (!_loaded) _loaded = true;
this.trigger('dynamicConfigChanged');
} | javascript | function(config) {
_cleanup();
if (!config) config = {};
_global = config.global || {};
_partners = config.partners || {};
if (!_loaded) _loaded = true;
this.trigger('dynamicConfigChanged');
} | [
"function",
"(",
"config",
")",
"{",
"_cleanup",
"(",
")",
";",
"if",
"(",
"!",
"config",
")",
"config",
"=",
"{",
"}",
";",
"_global",
"=",
"config",
".",
"global",
"||",
"{",
"}",
";",
"_partners",
"=",
"config",
".",
"partners",
"||",
"{",
"}"... | This is public so that the dynamic config file can load itself. Using it for other purposes is discouraged, but not forbidden. | [
"This",
"is",
"public",
"so",
"that",
"the",
"dynamic",
"config",
"file",
"can",
"load",
"itself",
".",
"Using",
"it",
"for",
"other",
"purposes",
"is",
"discouraged",
"but",
"not",
"forbidden",
"."
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L16681-L16691 | train | |
eaze/potluck-opentok-adapter | vendor/opentok.js | function(key, value, oldValue) {
if (oldValue) {
self.trigger('styleValueChanged', key, value, oldValue);
} else {
self.trigger('styleValueChanged', key, value);
}
} | javascript | function(key, value, oldValue) {
if (oldValue) {
self.trigger('styleValueChanged', key, value, oldValue);
} else {
self.trigger('styleValueChanged', key, value);
}
} | [
"function",
"(",
"key",
",",
"value",
",",
"oldValue",
")",
"{",
"if",
"(",
"oldValue",
")",
"{",
"self",
".",
"trigger",
"(",
"'styleValueChanged'",
",",
"key",
",",
"value",
",",
"oldValue",
")",
";",
"}",
"else",
"{",
"self",
".",
"trigger",
"(",
... | Broadcast style changes as the styleValueChanged event | [
"Broadcast",
"style",
"changes",
"as",
"the",
"styleValueChanged",
"event"
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L17068-L17074 | train | |
eaze/potluck-opentok-adapter | vendor/opentok.js | handleInvalidStateChanges | function handleInvalidStateChanges(newState) {
if (!isValidState(newState)) {
signalChangeFailed('\'' + newState + '\' is not a valid state', newState);
return false;
}
if (!isValidTransition(currentState, newState)) {
signalChangeFailed('\'' + currentState + '\' ... | javascript | function handleInvalidStateChanges(newState) {
if (!isValidState(newState)) {
signalChangeFailed('\'' + newState + '\' is not a valid state', newState);
return false;
}
if (!isValidTransition(currentState, newState)) {
signalChangeFailed('\'' + currentState + '\' ... | [
"function",
"handleInvalidStateChanges",
"(",
"newState",
")",
"{",
"if",
"(",
"!",
"isValidState",
"(",
"newState",
")",
")",
"{",
"signalChangeFailed",
"(",
"'\\''",
"+",
"newState",
"+",
"'\\' is not a valid state'",
",",
"newState",
")",
";",
"return",
"fals... | Validates +newState+. If it's invalid it triggers stateChangeFailed and returns false. | [
"Validates",
"+",
"newState",
"+",
".",
"If",
"it",
"s",
"invalid",
"it",
"triggers",
"stateChangeFailed",
"and",
"returns",
"false",
"."
] | 2b88a58ec0a8588955ee99004bc7d4bc361c5b12 | https://github.com/eaze/potluck-opentok-adapter/blob/2b88a58ec0a8588955ee99004bc7d4bc361c5b12/vendor/opentok.js#L17477-L17492 | train |
zjgnlzq/serve-index-prefix | index.js | fileSort | function fileSort(a, b) {
return Number(b.stat && b.stat.isDirectory()) - Number(a.stat && a.stat.isDirectory()) ||
String(a.name).toLocaleLowerCase().localeCompare(String(b.name).toLocaleLowerCase());
} | javascript | function fileSort(a, b) {
return Number(b.stat && b.stat.isDirectory()) - Number(a.stat && a.stat.isDirectory()) ||
String(a.name).toLocaleLowerCase().localeCompare(String(b.name).toLocaleLowerCase());
} | [
"function",
"fileSort",
"(",
"a",
",",
"b",
")",
"{",
"return",
"Number",
"(",
"b",
".",
"stat",
"&&",
"b",
".",
"stat",
".",
"isDirectory",
"(",
")",
")",
"-",
"Number",
"(",
"a",
".",
"stat",
"&&",
"a",
".",
"stat",
".",
"isDirectory",
"(",
"... | Sort function for with directories first. | [
"Sort",
"function",
"for",
"with",
"directories",
"first",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L222-L225 | train |
zjgnlzq/serve-index-prefix | index.js | htmlPath | function htmlPath(dir) {
var parts = dir.split('/');
var crumb = new Array(parts.length);
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
if (part) {
parts[i] = encodeURIComponent(part);
crumb[i] = '<a href="' + escapeHtml(parts.slice(0, i + 1).join('/')) + '">' + escapeHtml(pa... | javascript | function htmlPath(dir) {
var parts = dir.split('/');
var crumb = new Array(parts.length);
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
if (part) {
parts[i] = encodeURIComponent(part);
crumb[i] = '<a href="' + escapeHtml(parts.slice(0, i + 1).join('/')) + '">' + escapeHtml(pa... | [
"function",
"htmlPath",
"(",
"dir",
")",
"{",
"var",
"parts",
"=",
"dir",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"crumb",
"=",
"new",
"Array",
"(",
"parts",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
... | Map html `dir`, returning a linked path. | [
"Map",
"html",
"dir",
"returning",
"a",
"linked",
"path",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L231-L245 | train |
zjgnlzq/serve-index-prefix | index.js | iconLookup | function iconLookup(filename) {
var ext = extname(filename);
// try by extension
if (icons[ext]) {
return {
className: 'icon-' + ext.substring(1),
fileName: icons[ext]
};
}
var mimetype = mime.lookup(ext);
// default if no mime type
if (mimetype === false) {
return {
class... | javascript | function iconLookup(filename) {
var ext = extname(filename);
// try by extension
if (icons[ext]) {
return {
className: 'icon-' + ext.substring(1),
fileName: icons[ext]
};
}
var mimetype = mime.lookup(ext);
// default if no mime type
if (mimetype === false) {
return {
class... | [
"function",
"iconLookup",
"(",
"filename",
")",
"{",
"var",
"ext",
"=",
"extname",
"(",
"filename",
")",
";",
"// try by extension",
"if",
"(",
"icons",
"[",
"ext",
"]",
")",
"{",
"return",
"{",
"className",
":",
"'icon-'",
"+",
"ext",
".",
"substring",
... | Get the icon data for the file name. | [
"Get",
"the",
"icon",
"data",
"for",
"the",
"file",
"name",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L251-L303 | train |
zjgnlzq/serve-index-prefix | index.js | iconStyle | function iconStyle (files, useIcons) {
if (!useIcons) return '';
var className;
var i;
var iconName;
var list = [];
var rules = {};
var selector;
var selectors = {};
var style = '';
for (i = 0; i < files.length; i++) {
var file = files[i];
var isDir = '..' == file.name || (file.stat && fil... | javascript | function iconStyle (files, useIcons) {
if (!useIcons) return '';
var className;
var i;
var iconName;
var list = [];
var rules = {};
var selector;
var selectors = {};
var style = '';
for (i = 0; i < files.length; i++) {
var file = files[i];
var isDir = '..' == file.name || (file.stat && fil... | [
"function",
"iconStyle",
"(",
"files",
",",
"useIcons",
")",
"{",
"if",
"(",
"!",
"useIcons",
")",
"return",
"''",
";",
"var",
"className",
";",
"var",
"i",
";",
"var",
"iconName",
";",
"var",
"list",
"=",
"[",
"]",
";",
"var",
"rules",
"=",
"{",
... | Load icon images, return css string. | [
"Load",
"icon",
"images",
"return",
"css",
"string",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L309-L348 | train |
zjgnlzq/serve-index-prefix | index.js | html | function html(files, dir, useIcons, view, req) {
return '<ul id="files" class="view-' + escapeHtml(view) + '">'
+ (view == 'details' ? (
'<li class="header">'
+ '<span class="name">Name</span>'
+ '<span class="size">Size</span>'
+ '<span class="date">Modified</span>'
+ '</li>') : '')... | javascript | function html(files, dir, useIcons, view, req) {
return '<ul id="files" class="view-' + escapeHtml(view) + '">'
+ (view == 'details' ? (
'<li class="header">'
+ '<span class="name">Name</span>'
+ '<span class="size">Size</span>'
+ '<span class="date">Modified</span>'
+ '</li>') : '')... | [
"function",
"html",
"(",
"files",
",",
"dir",
",",
"useIcons",
",",
"view",
",",
"req",
")",
"{",
"return",
"'<ul id=\"files\" class=\"view-'",
"+",
"escapeHtml",
"(",
"view",
")",
"+",
"'\">'",
"+",
"(",
"view",
"==",
"'details'",
"?",
"(",
"'<li class=\"... | Map html `files`, returning an html unordered list. | [
"Map",
"html",
"files",
"returning",
"an",
"html",
"unordered",
"list",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L354-L404 | train |
zjgnlzq/serve-index-prefix | index.js | load | function load(icon) {
if (cache[icon]) return cache[icon];
return cache[icon] = fs.readFileSync(__dirname + '/public/icons/' + icon, 'base64');
} | javascript | function load(icon) {
if (cache[icon]) return cache[icon];
return cache[icon] = fs.readFileSync(__dirname + '/public/icons/' + icon, 'base64');
} | [
"function",
"load",
"(",
"icon",
")",
"{",
"if",
"(",
"cache",
"[",
"icon",
"]",
")",
"return",
"cache",
"[",
"icon",
"]",
";",
"return",
"cache",
"[",
"icon",
"]",
"=",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/public/icons/'",
"+",
"icon... | Load and cache the given `icon`.
@param {String} icon
@return {String}
@api private | [
"Load",
"and",
"cache",
"the",
"given",
"icon",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L414-L417 | train |
zjgnlzq/serve-index-prefix | index.js | stat | function stat(dir, files, cb) {
var batch = new Batch();
batch.concurrency(10);
files.forEach(function(file){
batch.push(function(done){
fs.stat(join(dir, file), function(err, stat){
if (err && err.code !== 'ENOENT') return done(err);
// pass ENOENT as null stat, not error
don... | javascript | function stat(dir, files, cb) {
var batch = new Batch();
batch.concurrency(10);
files.forEach(function(file){
batch.push(function(done){
fs.stat(join(dir, file), function(err, stat){
if (err && err.code !== 'ENOENT') return done(err);
// pass ENOENT as null stat, not error
don... | [
"function",
"stat",
"(",
"dir",
",",
"files",
",",
"cb",
")",
"{",
"var",
"batch",
"=",
"new",
"Batch",
"(",
")",
";",
"batch",
".",
"concurrency",
"(",
"10",
")",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"batch",
"."... | Stat all files and return array of stat
in same order. | [
"Stat",
"all",
"files",
"and",
"return",
"array",
"of",
"stat",
"in",
"same",
"order",
"."
] | 0a37c2bc4df5e46e1b509a37697edbff1b3e519d | https://github.com/zjgnlzq/serve-index-prefix/blob/0a37c2bc4df5e46e1b509a37697edbff1b3e519d/index.js#L452-L469 | train |
skerit/alchemy | lib/core/middleware.js | getMiddlePaths | function getMiddlePaths(paths, ext, new_ext) {
if (Array.isArray(paths)) {
return paths.map(function eachEntry(entry) {
return getMiddlePaths(entry, ext, new_ext);
});
}
if (ext && new_ext) {
paths = paths.replace(ext, new_ext);
}
return paths;
} | javascript | function getMiddlePaths(paths, ext, new_ext) {
if (Array.isArray(paths)) {
return paths.map(function eachEntry(entry) {
return getMiddlePaths(entry, ext, new_ext);
});
}
if (ext && new_ext) {
paths = paths.replace(ext, new_ext);
}
return paths;
} | [
"function",
"getMiddlePaths",
"(",
"paths",
",",
"ext",
",",
"new_ext",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"paths",
")",
")",
"{",
"return",
"paths",
".",
"map",
"(",
"function",
"eachEntry",
"(",
"entry",
")",
"{",
"return",
"getMiddle... | Get an array of paths, optionally replace text
@author Jelle De Loecker <jelle@develry.be>
@since 0.2.3
@version 0.2.3 | [
"Get",
"an",
"array",
"of",
"paths",
"optionally",
"replace",
"text"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/core/middleware.js#L46-L59 | train |
SpaceRhino/localstorage-plus | src/store.js | function(name, autoFlushExpired) {
var storeName;
function __construct(name) {
try {
storeName = validateStoreName(name);
if (autoFlushExpired === undefined || autoFlushExpired !== false) {
flushExpired();
}
... | javascript | function(name, autoFlushExpired) {
var storeName;
function __construct(name) {
try {
storeName = validateStoreName(name);
if (autoFlushExpired === undefined || autoFlushExpired !== false) {
flushExpired();
}
... | [
"function",
"(",
"name",
",",
"autoFlushExpired",
")",
"{",
"var",
"storeName",
";",
"function",
"__construct",
"(",
"name",
")",
"{",
"try",
"{",
"storeName",
"=",
"validateStoreName",
"(",
"name",
")",
";",
"if",
"(",
"autoFlushExpired",
"===",
"undefined"... | Define a new store
@class
@param {string} name The name of the store
@param {boolean} [flushExpired] should the flush expired not run
@return {Store} The store instance | [
"Define",
"a",
"new",
"store"
] | 7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a | https://github.com/SpaceRhino/localstorage-plus/blob/7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a/src/store.js#L48-L205 | train | |
SpaceRhino/localstorage-plus | src/store.js | set | function set(key, data, expiresAt) {
try {
if (expiresAt !== undefined && typeof expiresAt === 'number') {
STORE.setItem(storeName + key + EXPIRE_KEY, expiresAt.toString());
}
STORE.setItem(storeName + key, decodeObjectString(data));... | javascript | function set(key, data, expiresAt) {
try {
if (expiresAt !== undefined && typeof expiresAt === 'number') {
STORE.setItem(storeName + key + EXPIRE_KEY, expiresAt.toString());
}
STORE.setItem(storeName + key, decodeObjectString(data));... | [
"function",
"set",
"(",
"key",
",",
"data",
",",
"expiresAt",
")",
"{",
"try",
"{",
"if",
"(",
"expiresAt",
"!==",
"undefined",
"&&",
"typeof",
"expiresAt",
"===",
"'number'",
")",
"{",
"STORE",
".",
"setItem",
"(",
"storeName",
"+",
"key",
"+",
"EXPIR... | Set a defined key with the given value
@param {string} key The name of the value
@param {mixed} data The data to store, can be any datatype
@param {int} [expiresAt] When should this value expire
@return {void} | [
"Set",
"a",
"defined",
"key",
"with",
"the",
"given",
"value"
] | 7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a | https://github.com/SpaceRhino/localstorage-plus/blob/7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a/src/store.js#L70-L83 | train |
SpaceRhino/localstorage-plus | src/store.js | get | function get(key) {
try {
if (key !== undefined) {
var result = encodeObjectString(STORE.getItem(storeName + key));
return result !== null ? result : false;
} else {
var resultAll = {};
O... | javascript | function get(key) {
try {
if (key !== undefined) {
var result = encodeObjectString(STORE.getItem(storeName + key));
return result !== null ? result : false;
} else {
var resultAll = {};
O... | [
"function",
"get",
"(",
"key",
")",
"{",
"try",
"{",
"if",
"(",
"key",
"!==",
"undefined",
")",
"{",
"var",
"result",
"=",
"encodeObjectString",
"(",
"STORE",
".",
"getItem",
"(",
"storeName",
"+",
"key",
")",
")",
";",
"return",
"result",
"!==",
"nu... | Get the value stored under the given key, or the whole store
@param {string} [key] Index defined in @set
@return {mixed} Stored value | [
"Get",
"the",
"value",
"stored",
"under",
"the",
"given",
"key",
"or",
"the",
"whole",
"store"
] | 7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a | https://github.com/SpaceRhino/localstorage-plus/blob/7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a/src/store.js#L90-L111 | train |
SpaceRhino/localstorage-plus | src/store.js | validateStoreName | function validateStoreName(storeName) {
if (storeName === undefined) {
throw new TypeError('Please provide a storename');
}
if (typeof(storeName) !== 'string') {
throw new TypeError('The storename has to be a string');
}
... | javascript | function validateStoreName(storeName) {
if (storeName === undefined) {
throw new TypeError('Please provide a storename');
}
if (typeof(storeName) !== 'string') {
throw new TypeError('The storename has to be a string');
}
... | [
"function",
"validateStoreName",
"(",
"storeName",
")",
"{",
"if",
"(",
"storeName",
"===",
"undefined",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Please provide a storename'",
")",
";",
"}",
"if",
"(",
"typeof",
"(",
"storeName",
")",
"!==",
"'string'",
... | generate a store name
@param {string} storeName The name of the store instance
@return {string} The generated name
@throws {TypeError} | [
"generate",
"a",
"store",
"name"
] | 7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a | https://github.com/SpaceRhino/localstorage-plus/blob/7d0fd7d533980f5de0f98de3c5bf4665f14b2e0a/src/store.js#L153-L164 | train |
7anshuai/html5-gen | index.js | invert | function invert(obj) {
let result = {};
let keys = Object.keys(obj);
for (let i = 0, length = keys.length; i < length; i++) {
result[obj[keys[i]]] = keys[i];
}
return result;
} | javascript | function invert(obj) {
let result = {};
let keys = Object.keys(obj);
for (let i = 0, length = keys.length; i < length; i++) {
result[obj[keys[i]]] = keys[i];
}
return result;
} | [
"function",
"invert",
"(",
"obj",
")",
"{",
"let",
"result",
"=",
"{",
"}",
";",
"let",
"keys",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"length",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"len... | Invert the keys and values of an object. The values must be serializable. | [
"Invert",
"the",
"keys",
"and",
"values",
"of",
"an",
"object",
".",
"The",
"values",
"must",
"be",
"serializable",
"."
] | ed6286073e30be4bdf6a667f77defccbb240bc9a | https://github.com/7anshuai/html5-gen/blob/ed6286073e30be4bdf6a667f77defccbb240bc9a/index.js#L166-L173 | train |
alexpods/ClazzJS | src/components/clazz/Base.js | function(context, property, params) {
context = context || this;
var parent = context.__isClazz ? this.__parent : this.__parent.prototype;
if (!property) {
return parent;
}
if (!(property in parent)) {
... | javascript | function(context, property, params) {
context = context || this;
var parent = context.__isClazz ? this.__parent : this.__parent.prototype;
if (!property) {
return parent;
}
if (!(property in parent)) {
... | [
"function",
"(",
"context",
",",
"property",
",",
"params",
")",
"{",
"context",
"=",
"context",
"||",
"this",
";",
"var",
"parent",
"=",
"context",
".",
"__isClazz",
"?",
"this",
".",
"__parent",
":",
"this",
".",
"__parent",
".",
"prototype",
";",
"i... | Gets parent clazz, calls parent clazz method or gets parent clazz property
@param {object} context Context for parent clazz calling
@param {string} property Parent clazz method or property.
If it does not specified - parent clazz is returning.
@param {array} params Params for passing to parent clazz method call
*
... | [
"Gets",
"parent",
"clazz",
"calls",
"parent",
"clazz",
"method",
"or",
"gets",
"parent",
"clazz",
"property"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/clazz/Base.js#L32-L48 | train | |
vkiding/jud-vue-render | src/render/browser/base/component/lazyload.js | loadIfNeeded | function loadIfNeeded (elementScope) {
const notPreProcessed = elementScope.querySelectorAll('[img-src]')
// image elements which have attribute 'i-lazy-src' were elements
// that had been preprocessed by lib-img-core, but not loaded yet, and
// must be loaded when 'appear' events were fired. It turns out the
... | javascript | function loadIfNeeded (elementScope) {
const notPreProcessed = elementScope.querySelectorAll('[img-src]')
// image elements which have attribute 'i-lazy-src' were elements
// that had been preprocessed by lib-img-core, but not loaded yet, and
// must be loaded when 'appear' events were fired. It turns out the
... | [
"function",
"loadIfNeeded",
"(",
"elementScope",
")",
"{",
"const",
"notPreProcessed",
"=",
"elementScope",
".",
"querySelectorAll",
"(",
"'[img-src]'",
")",
"// image elements which have attribute 'i-lazy-src' were elements",
"// that had been preprocessed by lib-img-core, but not l... | for a scope of element, not for a image. | [
"for",
"a",
"scope",
"of",
"element",
"not",
"for",
"a",
"image",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/base/component/lazyload.js#L35-L47 | train |
filmic/Robol | lib/robol.js | function(configArray, validExt) {
var success = true,
fileMask,
filePath,
dirContent;
configArray.forEach(function(cfg) {
var files = [];
// setup files' paths (join file's input directory path with name)
// check for the wildcards
... | javascript | function(configArray, validExt) {
var success = true,
fileMask,
filePath,
dirContent;
configArray.forEach(function(cfg) {
var files = [];
// setup files' paths (join file's input directory path with name)
// check for the wildcards
... | [
"function",
"(",
"configArray",
",",
"validExt",
")",
"{",
"var",
"success",
"=",
"true",
",",
"fileMask",
",",
"filePath",
",",
"dirContent",
";",
"configArray",
".",
"forEach",
"(",
"function",
"(",
"cfg",
")",
"{",
"var",
"files",
"=",
"[",
"]",
";"... | prepare and check input files | [
"prepare",
"and",
"check",
"input",
"files"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L148-L192 | train | |
filmic/Robol | lib/robol.js | function(prefix, obj) {
return '\n'+prefix.cyan+'\n - '+
(Array.isArray(obj) ? obj.join('\n - ') : obj.toString());
} | javascript | function(prefix, obj) {
return '\n'+prefix.cyan+'\n - '+
(Array.isArray(obj) ? obj.join('\n - ') : obj.toString());
} | [
"function",
"(",
"prefix",
",",
"obj",
")",
"{",
"return",
"'\\n'",
"+",
"prefix",
".",
"cyan",
"+",
"'\\n - '",
"+",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
"?",
"obj",
".",
"join",
"(",
"'\\n - '",
")",
":",
"obj",
".",
"toString",
"(",
... | Formats output for the log function
@param {String} prefix Prefix
@param {Array|String} obj Array of file names or String | [
"Formats",
"output",
"for",
"the",
"log",
"function"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L225-L228 | train | |
filmic/Robol | lib/robol.js | function(cfg, callback) {
var lessCompiledCode = "";
// Filter all Less files
var lessFiles = filterInput(cfg.input_files, '.less');
// Filter all Css files
var cssFiles = filterInput(cfg.input_files, '.css');
// Output file path
var outputPath = path.join(cfg.output_dir, cfg.output_file);
// Callba... | javascript | function(cfg, callback) {
var lessCompiledCode = "";
// Filter all Less files
var lessFiles = filterInput(cfg.input_files, '.less');
// Filter all Css files
var cssFiles = filterInput(cfg.input_files, '.css');
// Output file path
var outputPath = path.join(cfg.output_dir, cfg.output_file);
// Callba... | [
"function",
"(",
"cfg",
",",
"callback",
")",
"{",
"var",
"lessCompiledCode",
"=",
"\"\"",
";",
"// Filter all Less files",
"var",
"lessFiles",
"=",
"filterInput",
"(",
"cfg",
".",
"input_files",
",",
"'.less'",
")",
";",
"// Filter all Css files",
"var",
"cssFi... | Loads, compiles, concatenates and minifies style files
@param {Object} cfg Build configuration
@param {Function} callback Task complete callback | [
"Loads",
"compiles",
"concatenates",
"and",
"minifies",
"style",
"files"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L303-L357 | train | |
filmic/Robol | lib/robol.js | function(cfg, callback) {
// Input dir
var inputPath = cfg.input_dir;
// Output dir
var outputPath = cfg.output_dir;
if (inputPath && outputPath) {
new gear.Queue({registry: taskRegistry}) // register tasks
.log(formatLog('Copying directory:', inputPath))
.copyDir({input: inputPath, output: outp... | javascript | function(cfg, callback) {
// Input dir
var inputPath = cfg.input_dir;
// Output dir
var outputPath = cfg.output_dir;
if (inputPath && outputPath) {
new gear.Queue({registry: taskRegistry}) // register tasks
.log(formatLog('Copying directory:', inputPath))
.copyDir({input: inputPath, output: outp... | [
"function",
"(",
"cfg",
",",
"callback",
")",
"{",
"// Input dir",
"var",
"inputPath",
"=",
"cfg",
".",
"input_dir",
";",
"// Output dir",
"var",
"outputPath",
"=",
"cfg",
".",
"output_dir",
";",
"if",
"(",
"inputPath",
"&&",
"outputPath",
")",
"{",
"new",... | Copies single directory
@param {Object} cfg Build configuration
@param {Function} callback Task complete callback | [
"Copies",
"single",
"directory"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L413-L429 | train | |
filmic/Robol | lib/robol.js | function(cfg, callback) {
// Input dir
var inputPath = cfg.input_dir;
if (inputPath) {
new gear.Queue({registry: taskRegistry}) // register tasks
.log(formatLog('Removing directory:', inputPath))
.removeDir({input: inputPath}, callback)
.run(callback);
} else {
callback();
}
} | javascript | function(cfg, callback) {
// Input dir
var inputPath = cfg.input_dir;
if (inputPath) {
new gear.Queue({registry: taskRegistry}) // register tasks
.log(formatLog('Removing directory:', inputPath))
.removeDir({input: inputPath}, callback)
.run(callback);
} else {
callback();
}
} | [
"function",
"(",
"cfg",
",",
"callback",
")",
"{",
"// Input dir",
"var",
"inputPath",
"=",
"cfg",
".",
"input_dir",
";",
"if",
"(",
"inputPath",
")",
"{",
"new",
"gear",
".",
"Queue",
"(",
"{",
"registry",
":",
"taskRegistry",
"}",
")",
"// register tas... | Removes single directory
@param {Object} cfg Build configuration
@param {Function} callback Task complete callback | [
"Removes",
"single",
"directory"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L458-L470 | train | |
filmic/Robol | lib/robol.js | function(cfg, callback) {
var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
if (!Array.isArray(paths)) {
paths = [paths];
}
watchr.watch({
paths: paths,
listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
console.log(formatLog('File changed:', filePath));
... | javascript | function(cfg, callback) {
var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
if (!Array.isArray(paths)) {
paths = [paths];
}
watchr.watch({
paths: paths,
listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
console.log(formatLog('File changed:', filePath));
... | [
"function",
"(",
"cfg",
",",
"callback",
")",
"{",
"var",
"paths",
"=",
"cfg",
".",
"input_files",
"||",
"cfg",
".",
"input_file",
"||",
"cfg",
".",
"input_dir",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"paths",
")",
")",
"{",
"paths",
"=... | Setup watching of changes in the input files
@param {Object} cfg Build configuration
@param {Function} callback Task complete callback | [
"Setup",
"watching",
"of",
"changes",
"in",
"the",
"input",
"files"
] | f0611bcabda7f8009a04063a0661b7daed603b5e | https://github.com/filmic/Robol/blob/f0611bcabda7f8009a04063a0661b7daed603b5e/lib/robol.js#L479-L546 | train | |
joscha/html-context | src/index.js | getWindowForElement | function getWindowForElement(element) {
const e = element.documentElement || element;
const doc = e.ownerDocument;
return doc.defaultView;
} | javascript | function getWindowForElement(element) {
const e = element.documentElement || element;
const doc = e.ownerDocument;
return doc.defaultView;
} | [
"function",
"getWindowForElement",
"(",
"element",
")",
"{",
"const",
"e",
"=",
"element",
".",
"documentElement",
"||",
"element",
";",
"const",
"doc",
"=",
"e",
".",
"ownerDocument",
";",
"return",
"doc",
".",
"defaultView",
";",
"}"
] | Gets the window object from a given element or document
@private
@param {!HTMLDocument|HTMLElement} element The element to get the window object for
@return {Window|null} the window object for the given element | [
"Gets",
"the",
"window",
"object",
"from",
"a",
"given",
"element",
"or",
"document"
] | e1d6dd64f10f33cf619c1dcd7363fcfcee6daa4d | https://github.com/joscha/html-context/blob/e1d6dd64f10f33cf619c1dcd7363fcfcee6daa4d/src/index.js#L13-L17 | train |
quantumpayments/media | lib/handlers/rate.js | handler | function handler(req, res) {
var origin = req.headers.origin
if (origin) {
res.setHeader('Access-Control-Allow-Origin', origin)
}
var rating = {}
rating.uri = req.body.uri
rating.rating = req.body.rating
rating.reviewer = req.session.userId
debug(rating)
if (!rating.reviewer) {
res.s... | javascript | function handler(req, res) {
var origin = req.headers.origin
if (origin) {
res.setHeader('Access-Control-Allow-Origin', origin)
}
var rating = {}
rating.uri = req.body.uri
rating.rating = req.body.rating
rating.reviewer = req.session.userId
debug(rating)
if (!rating.reviewer) {
res.s... | [
"function",
"handler",
"(",
"req",
",",
"res",
")",
"{",
"var",
"origin",
"=",
"req",
".",
"headers",
".",
"origin",
"if",
"(",
"origin",
")",
"{",
"res",
".",
"setHeader",
"(",
"'Access-Control-Allow-Origin'",
",",
"origin",
")",
"}",
"var",
"rating",
... | Rating hander.
@param {Object} req The request.
@param {Object} res The response. | [
"Rating",
"hander",
"."
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/lib/handlers/rate.js#L13-L56 | train |
vmarkdown/vremark-parse | packages/vremark-toc/mdast-util-toc/lib/index.js | toc | function toc(node, options) {
var settings = options || {};
var heading = settings.heading ? toExpression(settings.heading) : null;
var result = search(node, heading, settings.maxDepth || 6);
var map = result.map;
result.map = map.length === 0 ? null : contents(map, settings.tight);
/* No give... | javascript | function toc(node, options) {
var settings = options || {};
var heading = settings.heading ? toExpression(settings.heading) : null;
var result = search(node, heading, settings.maxDepth || 6);
var map = result.map;
result.map = map.length === 0 ? null : contents(map, settings.tight);
/* No give... | [
"function",
"toc",
"(",
"node",
",",
"options",
")",
"{",
"var",
"settings",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"heading",
"=",
"settings",
".",
"heading",
"?",
"toExpression",
"(",
"settings",
".",
"heading",
")",
":",
"null",
";",
"var",
"... | Get a TOC representation of `node`.
@param {Mdast} node - MDAST.
@param {Object} options - Configuration.
@return {Array} - TOC Markdown. | [
"Get",
"a",
"TOC",
"representation",
"of",
"node",
"."
] | d7b353dcb5d021eeceb40f3c505ece893202db7a | https://github.com/vmarkdown/vremark-parse/blob/d7b353dcb5d021eeceb40f3c505ece893202db7a/packages/vremark-toc/mdast-util-toc/lib/index.js#L24-L39 | train |
the-terribles/evergreen | lib/configurator.js | Configurator | function Configurator(){
// Store reference to the tree/template
this.__tree = {};
// Cached instance of the fully rendered tree.
this.__cachedResolvedTree = null;
// Configuration for the GraphBuilder
this.__config = {
directives: {
file: new (require('./directives/file.js')),
http: new (requi... | javascript | function Configurator(){
// Store reference to the tree/template
this.__tree = {};
// Cached instance of the fully rendered tree.
this.__cachedResolvedTree = null;
// Configuration for the GraphBuilder
this.__config = {
directives: {
file: new (require('./directives/file.js')),
http: new (requi... | [
"function",
"Configurator",
"(",
")",
"{",
"// Store reference to the tree/template",
"this",
".",
"__tree",
"=",
"{",
"}",
";",
"// Cached instance of the fully rendered tree.",
"this",
".",
"__cachedResolvedTree",
"=",
"null",
";",
"// Configuration for the GraphBuilder",
... | Main interface for interacting with Evergreen.
@constructor | [
"Main",
"interface",
"for",
"interacting",
"with",
"Evergreen",
"."
] | c1adaea1ce825727c5c5ed75d858e2f0d22657e2 | https://github.com/the-terribles/evergreen/blob/c1adaea1ce825727c5c5ed75d858e2f0d22657e2/lib/configurator.js#L16-L43 | train |
jmendiara/gitftw | src/commands.js | commit | function commit(options) {
assert.ok(options.message, 'message is mandatory');
var args = [
'commit',
options.force ? '--amend' : null,
options.noVerify ? '-n' : null,
options.message ? '-m' : null,
options.message ? options.message : null
];
return git(args)
.cat... | javascript | function commit(options) {
assert.ok(options.message, 'message is mandatory');
var args = [
'commit',
options.force ? '--amend' : null,
options.noVerify ? '-n' : null,
options.message ? '-m' : null,
options.message ? options.message : null
];
return git(args)
.cat... | [
"function",
"commit",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"message",
",",
"'message is mandatory'",
")",
";",
"var",
"args",
"=",
"[",
"'commit'",
",",
"options",
".",
"force",
"?",
"'--amend'",
":",
"null",
",",
"options"... | Commits the staging area
Executes `git commit -m "First commit"`
It does not fail when there is not anything to commit
@example
var git = require('gitftw');
git.commit({
message: 'First commit'
});
@memberof git
@type {command}
@param {Object} options The options object. All its properties are {@link Resolvable}
@... | [
"Commits",
"the",
"staging",
"area",
"Executes",
"git",
"commit",
"-",
"m",
"First",
"commit"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L88-L102 | train |
jmendiara/gitftw | src/commands.js | clone | function clone(options) {
assert.ok(options.repository, 'repository is mandatory');
var branchOrTag = options.branch || options.tag;
var args = [
'clone',
options.repository,
options.directory,
branchOrTag ? ('-b' + branchOrTag) : null,
options.origin ? ('-o' + options.origin)... | javascript | function clone(options) {
assert.ok(options.repository, 'repository is mandatory');
var branchOrTag = options.branch || options.tag;
var args = [
'clone',
options.repository,
options.directory,
branchOrTag ? ('-b' + branchOrTag) : null,
options.origin ? ('-o' + options.origin)... | [
"function",
"clone",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"repository",
",",
"'repository is mandatory'",
")",
";",
"var",
"branchOrTag",
"=",
"options",
".",
"branch",
"||",
"options",
".",
"tag",
";",
"var",
"args",
"=",
... | Clones a git repo
If both a branch and a tag are specified, the branch takes precedence
@example
var git = require('gitftw');
git.clone({
repository: 'git@github.com:jmendiara/node-lru-cache.git',
directory: './cache' //optional
});
@memberof git
@type {command}
@param {Object} options The options object. All its ... | [
"Clones",
"a",
"git",
"repo"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L136-L154 | train |
jmendiara/gitftw | src/commands.js | add | function add(options) {
assert.ok(options.files, 'files is mandatory');
return options.files
.filter(function(file) {
//Git exits OK with empty filenames.
//Avoid an unnecessary call to git in these cases by removing the filename
return !!file;
})
.reduce(f... | javascript | function add(options) {
assert.ok(options.files, 'files is mandatory');
return options.files
.filter(function(file) {
//Git exits OK with empty filenames.
//Avoid an unnecessary call to git in these cases by removing the filename
return !!file;
})
.reduce(f... | [
"function",
"add",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"files",
",",
"'files is mandatory'",
")",
";",
"return",
"options",
".",
"files",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"//Git exits OK with empty filena... | Adds filenames to the stashing area
Issues `git add README.md`
@example
var git = require('gitftw');
git.add({
files: ['README.md', 'index.js']
});
@memberof git
@type {command}
@param {Object} options The options object. All its properties are {@link Resolvable}
@param {Resolvable|Array<String>} options.files The ... | [
"Adds",
"filenames",
"to",
"the",
"stashing",
"area",
"Issues",
"git",
"add",
"README",
".",
"md"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L175-L190 | train |
jmendiara/gitftw | src/commands.js | push | function push(options) {
var branchOrTag = options.branch || options.tag;
var args = [
'push',
options.remote || 'origin',
branchOrTag || 'HEAD',
options.force ? '--force' : null
];
return git(args)
.then(silent);
} | javascript | function push(options) {
var branchOrTag = options.branch || options.tag;
var args = [
'push',
options.remote || 'origin',
branchOrTag || 'HEAD',
options.force ? '--force' : null
];
return git(args)
.then(silent);
} | [
"function",
"push",
"(",
"options",
")",
"{",
"var",
"branchOrTag",
"=",
"options",
".",
"branch",
"||",
"options",
".",
"tag",
";",
"var",
"args",
"=",
"[",
"'push'",
",",
"options",
".",
"remote",
"||",
"'origin'",
",",
"branchOrTag",
"||",
"'HEAD'",
... | Push the change sets to server
Executes `git push origin master`
Defaults to "origin", and don't follow configured refspecs
for the upstream
If both a branch and a tag are specified, the branch takes precedence
@example
var git = require('gitftw');
git.push(); //the current branch to `origin`
@memberof git
@type {... | [
"Push",
"the",
"change",
"sets",
"to",
"server",
"Executes",
"git",
"push",
"origin",
"master"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L219-L231 | train |
jmendiara/gitftw | src/commands.js | pull | function pull(options) {
options = options || {};
var branchOrTag = options.branch || options.tag;
var args = [
'pull',
options.rebase ? '--rebase' : null,
options.remote || 'origin',
branchOrTag || git.getCurrentBranch
];
return git(args)
.then(silent);
} | javascript | function pull(options) {
options = options || {};
var branchOrTag = options.branch || options.tag;
var args = [
'pull',
options.rebase ? '--rebase' : null,
options.remote || 'origin',
branchOrTag || git.getCurrentBranch
];
return git(args)
.then(silent);
} | [
"function",
"pull",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"branchOrTag",
"=",
"options",
".",
"branch",
"||",
"options",
".",
"tag",
";",
"var",
"args",
"=",
"[",
"'pull'",
",",
"options",
".",
"rebase",
"?"... | Pulls a remote branch into the current one
Executes `git pull origin master`
remote defaults to "origin", and don't follow configured refspecs
for the upstream
If both a branch and a tag are specified, the branch takes precedence
When no branch and tag are specifies, this command will try
to pull the actual local br... | [
"Pulls",
"a",
"remote",
"branch",
"into",
"the",
"current",
"one",
"Executes",
"git",
"pull",
"origin",
"master"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L266-L280 | train |
jmendiara/gitftw | src/commands.js | checkout | function checkout(options) {
var branchOrTag = options.branch || options.tag;
assert.ok(branchOrTag, 'branch or tag is mandatory');
if ((options.create || options.oldCreate) && options.orphan) {
throw new Error('create and orphan cannot be specified both together');
}
if (options.create && ... | javascript | function checkout(options) {
var branchOrTag = options.branch || options.tag;
assert.ok(branchOrTag, 'branch or tag is mandatory');
if ((options.create || options.oldCreate) && options.orphan) {
throw new Error('create and orphan cannot be specified both together');
}
if (options.create && ... | [
"function",
"checkout",
"(",
"options",
")",
"{",
"var",
"branchOrTag",
"=",
"options",
".",
"branch",
"||",
"options",
".",
"tag",
";",
"assert",
".",
"ok",
"(",
"branchOrTag",
",",
"'branch or tag is mandatory'",
")",
";",
"if",
"(",
"(",
"options",
".",... | Checkout a local branch
Executes `git checkout -B issues/12`
If you specify create, it will try to create the branch,
or will checkout it if it already exists
If both a branch and a tag are specified, the branch takes precedence
Cannot use create and orphan both together
@example
var git = require('gitftw');
git.... | [
"Checkout",
"a",
"local",
"branch"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L317-L340 | train |
jmendiara/gitftw | src/commands.js | removeLocalBranch | function removeLocalBranch(options) {
assert.ok(options.branch, 'branch is mandatory');
var args = [
'branch',
options.force ? '-D' : '-d',
options.branch
];
return git(args)
.then(silent);
} | javascript | function removeLocalBranch(options) {
assert.ok(options.branch, 'branch is mandatory');
var args = [
'branch',
options.force ? '-D' : '-d',
options.branch
];
return git(args)
.then(silent);
} | [
"function",
"removeLocalBranch",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"branch",
",",
"'branch is mandatory'",
")",
";",
"var",
"args",
"=",
"[",
"'branch'",
",",
"options",
".",
"force",
"?",
"'-D'",
":",
"'-d'",
",",
"opti... | Removes a local branch
@example
var git = require('gitftw');
//while in master...
git.removeLocalBranch({
branch: 'master'
});
@memberof git
@type {command}
@param {Object} options The options object. All its properties are {@link Resolvable}
@param {Resolvable|String} options.branch The branch name
@param {Resolva... | [
"Removes",
"a",
"local",
"branch"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L466-L477 | train |
jmendiara/gitftw | src/commands.js | removeRemoteBranch | function removeRemoteBranch(options) {
assert.ok(options.branch, 'branch is mandatory');
var args = [
'push',
options.remote || 'origin',
':' + options.branch
];
return git(args)
.then(silent);
} | javascript | function removeRemoteBranch(options) {
assert.ok(options.branch, 'branch is mandatory');
var args = [
'push',
options.remote || 'origin',
':' + options.branch
];
return git(args)
.then(silent);
} | [
"function",
"removeRemoteBranch",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"branch",
",",
"'branch is mandatory'",
")",
";",
"var",
"args",
"=",
"[",
"'push'",
",",
"options",
".",
"remote",
"||",
"'origin'",
",",
"':'",
"+",
"... | Removes a remote branch
@example
var git = require('gitftw');
//while in master...
git.removeRemoteBranch({
branch: 'master'
});
@memberof git
@type {command}
@param {Object} options The options object. All its properties are {@link Resolvable}
@param {Resolvable|String} options.branch The branch name
@param {Resol... | [
"Removes",
"a",
"remote",
"branch"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L499-L510 | train |
jmendiara/gitftw | src/commands.js | tag | function tag(options) {
assert.ok(options.tag, 'tag name is mandatory');
if (options.annotated) {
assert.ok(options.message, 'message is mandatory when creating an annotated tag');
}
var args = [
'tag',
options.tag,
options.annotated ? '-a' : null,
options.message ? '-m' :... | javascript | function tag(options) {
assert.ok(options.tag, 'tag name is mandatory');
if (options.annotated) {
assert.ok(options.message, 'message is mandatory when creating an annotated tag');
}
var args = [
'tag',
options.tag,
options.annotated ? '-a' : null,
options.message ? '-m' :... | [
"function",
"tag",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"tag",
",",
"'tag name is mandatory'",
")",
";",
"if",
"(",
"options",
".",
"annotated",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"message",
",",
"'messag... | Creates a git tag
Executes `git tag v1.0.0 -m "v1.0.0" -a`
@example
var git = require('gitftw');
git.tag({
tag: 'v1.2.0'
})
@memberof git
@type {command}
@param {Object} options The options object. All its properties are {@link Resolvable}
@param {Resolvable|String} options.tag The tag name
@param {Resolvable|Strin... | [
"Creates",
"a",
"git",
"tag",
"Executes",
"git",
"tag",
"v1",
".",
"0",
".",
"0",
"-",
"m",
"v1",
".",
"0",
".",
"0",
"-",
"a"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L637-L653 | train |
jmendiara/gitftw | src/commands.js | removeLocalTags | function removeLocalTags(options) {
assert.ok(options.tags, 'tags is mandatory');
return options.tags
.reduce(function(soFar, tag) {
var args = [
'tag',
'-d',
tag
];
return soFar
.then(gitFn(args))
.catch(pass... | javascript | function removeLocalTags(options) {
assert.ok(options.tags, 'tags is mandatory');
return options.tags
.reduce(function(soFar, tag) {
var args = [
'tag',
'-d',
tag
];
return soFar
.then(gitFn(args))
.catch(pass... | [
"function",
"removeLocalTags",
"(",
"options",
")",
"{",
"assert",
".",
"ok",
"(",
"options",
".",
"tags",
",",
"'tags is mandatory'",
")",
";",
"return",
"options",
".",
"tags",
".",
"reduce",
"(",
"function",
"(",
"soFar",
",",
"tag",
")",
"{",
"var",
... | Removes a set of tags from the local repo
Executes `git tag -d v1.0.0`
It does not fail when the tag does not exists
@example
var git = require('gitftw');
//remove all local tags
git.removeLocalTags({
tags: git.getTags //It's a resolvable. You can specify also ['v1.0.0', 'v1.0.1']
});
@memberof git
@type {command}... | [
"Removes",
"a",
"set",
"of",
"tags",
"from",
"the",
"local",
"repo",
"Executes",
"git",
"tag",
"-",
"d",
"v1",
".",
"0",
".",
"0"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L702-L717 | train |
jmendiara/gitftw | src/commands.js | removeTags | function removeTags(options) {
return Promise.resolve()
.then(git.removeLocalTags.bind(null, options))
.then(git.removeRemoteTags.bind(null, options));
} | javascript | function removeTags(options) {
return Promise.resolve()
.then(git.removeLocalTags.bind(null, options))
.then(git.removeRemoteTags.bind(null, options));
} | [
"function",
"removeTags",
"(",
"options",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
".",
"then",
"(",
"git",
".",
"removeLocalTags",
".",
"bind",
"(",
"null",
",",
"options",
")",
")",
".",
"then",
"(",
"git",
".",
"removeRemoteTags",
".... | Removes a set of tags from the remote and local repo
@example
var git = require('gitftw');
//remove all local tags in local and remote 'origin'
git.removeTags({
tags: git.getTags //It's a resolvable. You can specify also ['v1.0.0', 'v1.0.1']
});
@memberof git
@type {command}
@param {Object} options The options obje... | [
"Removes",
"a",
"set",
"of",
"tags",
"from",
"the",
"remote",
"and",
"local",
"repo"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L777-L781 | train |
jmendiara/gitftw | src/commands.js | parseVersion | function parseVersion(str) {
var match = /git version ([0-9\.]+)/.exec(str);
if (match) {
return match[1];
} else {
throw new Error('Unable to parse version response', str);
}
} | javascript | function parseVersion(str) {
var match = /git version ([0-9\.]+)/.exec(str);
if (match) {
return match[1];
} else {
throw new Error('Unable to parse version response', str);
}
} | [
"function",
"parseVersion",
"(",
"str",
")",
"{",
"var",
"match",
"=",
"/",
"git version ([0-9\\.]+)",
"/",
".",
"exec",
"(",
"str",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"E... | Parses the git version
@private
@param {Resolvable|String} str The 'git version' command output
@throws {Error} parsing error
@returns {String} the version number | [
"Parses",
"the",
"git",
"version"
] | ba91b0d68b7791b5b557addc685737f6c912b4f3 | https://github.com/jmendiara/gitftw/blob/ba91b0d68b7791b5b557addc685737f6c912b4f3/src/commands.js#L823-L831 | train |
ergo-cms/ergo-core | lib/plugins/collate.js | _render | function _render(text, fields, fileInfo, context)
{
var options = _.extend({}, default_options, this.plugin_options);
if (options.disable === true)
return text;
//l.vvlogd(l.dump(options));
_collateData(fields, options, fileInfo, context);
if (!fields.dynamic_list)
fields.dynamic_list = _field_dynamic_list;
... | javascript | function _render(text, fields, fileInfo, context)
{
var options = _.extend({}, default_options, this.plugin_options);
if (options.disable === true)
return text;
//l.vvlogd(l.dump(options));
_collateData(fields, options, fileInfo, context);
if (!fields.dynamic_list)
fields.dynamic_list = _field_dynamic_list;
... | [
"function",
"_render",
"(",
"text",
",",
"fields",
",",
"fileInfo",
",",
"context",
")",
"{",
"var",
"options",
"=",
"_",
".",
"extend",
"(",
"{",
"}",
",",
"default_options",
",",
"this",
".",
"plugin_options",
")",
";",
"if",
"(",
"options",
".",
"... | the main entry point for the plugin | [
"the",
"main",
"entry",
"point",
"for",
"the",
"plugin"
] | 8ed4d087554b5f8cd93f0765719ecee14164ca71 | https://github.com/ergo-cms/ergo-core/blob/8ed4d087554b5f8cd93f0765719ecee14164ca71/lib/plugins/collate.js#L348-L366 | train |
piranna/WebhookPost | index.js | getHostname | function getHostname()
{
var interfaces = networkInterfaces()
for(var name in interfaces)
{
var info = interfaces[name].filter(filterIPv4)[0]
if(info) return info.address
}
} | javascript | function getHostname()
{
var interfaces = networkInterfaces()
for(var name in interfaces)
{
var info = interfaces[name].filter(filterIPv4)[0]
if(info) return info.address
}
} | [
"function",
"getHostname",
"(",
")",
"{",
"var",
"interfaces",
"=",
"networkInterfaces",
"(",
")",
"for",
"(",
"var",
"name",
"in",
"interfaces",
")",
"{",
"var",
"info",
"=",
"interfaces",
"[",
"name",
"]",
".",
"filter",
"(",
"filterIPv4",
")",
"[",
... | Get the adfress of an external IPv4 network interface in the current system
@return {string|undefined} | [
"Get",
"the",
"adfress",
"of",
"an",
"external",
"IPv4",
"network",
"interface",
"in",
"the",
"current",
"system"
] | b9348d58cb1304663e81cde89d092542050bd199 | https://github.com/piranna/WebhookPost/blob/b9348d58cb1304663e81cde89d092542050bd199/index.js#L33-L41 | train |
piranna/WebhookPost | index.js | createEventSource | function createEventSource(webhook, options)
{
var self = this
var eventSource = new EventSource(webhook, options)
eventSource.addEventListener('open', this.emit.bind(this, 'open', webhook))
eventSource.addEventListener('message', function(message)
{
self.push(message.data)
})
return eventSource
} | javascript | function createEventSource(webhook, options)
{
var self = this
var eventSource = new EventSource(webhook, options)
eventSource.addEventListener('open', this.emit.bind(this, 'open', webhook))
eventSource.addEventListener('message', function(message)
{
self.push(message.data)
})
return eventSource
} | [
"function",
"createEventSource",
"(",
"webhook",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
"var",
"eventSource",
"=",
"new",
"EventSource",
"(",
"webhook",
",",
"options",
")",
"eventSource",
".",
"addEventListener",
"(",
"'open'",
",",
"this",
"... | Connect to a remove SSE server to receive the webhook notifications
@param {string} webhook
@param {Object} [options]
@param {Boolean} [options.withCredentials=false]
@return {EventSource} | [
"Connect",
"to",
"a",
"remove",
"SSE",
"server",
"to",
"receive",
"the",
"webhook",
"notifications"
] | b9348d58cb1304663e81cde89d092542050bd199 | https://github.com/piranna/WebhookPost/blob/b9348d58cb1304663e81cde89d092542050bd199/index.js#L53-L66 | train |
piranna/WebhookPost | index.js | createServer | function createServer(webhook)
{
var self = this
var onError = this.emit.bind(this, 'error')
var port = webhook.port || 0
var hostname = webhook.hostname || HOSTNAME
var server = http.createServer(function(req, res)
{
if(req.method === 'GET')
{
res.end()
return self.push(pars... | javascript | function createServer(webhook)
{
var self = this
var onError = this.emit.bind(this, 'error')
var port = webhook.port || 0
var hostname = webhook.hostname || HOSTNAME
var server = http.createServer(function(req, res)
{
if(req.method === 'GET')
{
res.end()
return self.push(pars... | [
"function",
"createServer",
"(",
"webhook",
")",
"{",
"var",
"self",
"=",
"this",
"var",
"onError",
"=",
"this",
".",
"emit",
".",
"bind",
"(",
"this",
",",
"'error'",
")",
"var",
"port",
"=",
"webhook",
".",
"port",
"||",
"0",
"var",
"hostname",
"="... | Create an ad-hoc web server where to receive the webhook notifications
@param {Object} webhook
@param {string} [webhook.hostname='0.0.0.0']
@param {Number} [webhook.port=0]
@return {http.Server} | [
"Create",
"an",
"ad",
"-",
"hoc",
"web",
"server",
"where",
"to",
"receive",
"the",
"webhook",
"notifications"
] | b9348d58cb1304663e81cde89d092542050bd199 | https://github.com/piranna/WebhookPost/blob/b9348d58cb1304663e81cde89d092542050bd199/index.js#L77-L121 | train |
piranna/WebhookPost | index.js | WebhookPost | function WebhookPost(webhook, options)
{
if(!(this instanceof WebhookPost)) return new WebhookPost(webhook, options)
var self = this
options = options || {}
options.objectMode = true
WebhookPost.super_.call(this, options)
// Remote ServerSendEvent server
if(typeof webhook === 'string')
{
var ev... | javascript | function WebhookPost(webhook, options)
{
if(!(this instanceof WebhookPost)) return new WebhookPost(webhook, options)
var self = this
options = options || {}
options.objectMode = true
WebhookPost.super_.call(this, options)
// Remote ServerSendEvent server
if(typeof webhook === 'string')
{
var ev... | [
"function",
"WebhookPost",
"(",
"webhook",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"WebhookPost",
")",
")",
"return",
"new",
"WebhookPost",
"(",
"webhook",
",",
"options",
")",
"var",
"self",
"=",
"this",
"options",
"=",
"opt... | Create a stream of webhook notifications
@constructor
@param {Object|string|Number} [webhook={}]
@param {string} [webhook.hostname='0.0.0.0']
@param {Number} [webhook.port=0]
@param {Object} [options]
@param {Boolean} [options.withCredentials=false]
@emits WebhookPost#open
@emits WebhookPost#data
@emits WebhookPost#... | [
"Create",
"a",
"stream",
"of",
"webhook",
"notifications"
] | b9348d58cb1304663e81cde89d092542050bd199 | https://github.com/piranna/WebhookPost/blob/b9348d58cb1304663e81cde89d092542050bd199/index.js#L140-L196 | train |
cli-kit/cli-env | index.js | function(conf) {
Object.defineProperty(this, 'conf',
{
enumerable: false,
configurable: false,
writable: false,
value: conf || {}
}
);
if(this.conf.initialize) {
this.load();
}
} | javascript | function(conf) {
Object.defineProperty(this, 'conf',
{
enumerable: false,
configurable: false,
writable: false,
value: conf || {}
}
);
if(this.conf.initialize) {
this.load();
}
} | [
"function",
"(",
"conf",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'conf'",
",",
"{",
"enumerable",
":",
"false",
",",
"configurable",
":",
"false",
",",
"writable",
":",
"false",
",",
"value",
":",
"conf",
"||",
"{",
"}",
"}",
")... | Helper class for accessing environment variables
using a defined prefix.
@param conf The configuration object. | [
"Helper",
"class",
"for",
"accessing",
"environment",
"variables",
"using",
"a",
"defined",
"prefix",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L33-L45 | train | |
cli-kit/cli-env | index.js | getKey | function getKey(key) {
if(this.conf.transform) {
if(typeof(this.conf.transform.key) == 'function') {
return this.conf.transform.key.call(this, key);
}
}
key = delimited(key, this.conf.delimiter);
key = key.replace(/- /, this.conf.delimiter);
key = key.replace(/[^a-zA-Z0-9_]/, '');
if(this.conf... | javascript | function getKey(key) {
if(this.conf.transform) {
if(typeof(this.conf.transform.key) == 'function') {
return this.conf.transform.key.call(this, key);
}
}
key = delimited(key, this.conf.delimiter);
key = key.replace(/- /, this.conf.delimiter);
key = key.replace(/[^a-zA-Z0-9_]/, '');
if(this.conf... | [
"function",
"getKey",
"(",
"key",
")",
"{",
"if",
"(",
"this",
".",
"conf",
".",
"transform",
")",
"{",
"if",
"(",
"typeof",
"(",
"this",
".",
"conf",
".",
"transform",
".",
"key",
")",
"==",
"'function'",
")",
"{",
"return",
"this",
".",
"conf",
... | Retrieve a suitable key for setting an environment
variable.
@api private
@param key The candidate key.
@return A converted key. | [
"Retrieve",
"a",
"suitable",
"key",
"for",
"setting",
"an",
"environment",
"variable",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L57-L70 | train |
cli-kit/cli-env | index.js | getValue | function getValue (key, name, raw) {
if(this.conf.transform) {
if(typeof(this.conf.transform.value) == 'function') {
return this.conf.transform.value.call(this, key, name, raw);
}
}
var value = process.env[raw] || this[name];
if(this.conf.native && typeof(value) == 'string') {
value = native.t... | javascript | function getValue (key, name, raw) {
if(this.conf.transform) {
if(typeof(this.conf.transform.value) == 'function') {
return this.conf.transform.value.call(this, key, name, raw);
}
}
var value = process.env[raw] || this[name];
if(this.conf.native && typeof(value) == 'string') {
value = native.t... | [
"function",
"getValue",
"(",
"key",
",",
"name",
",",
"raw",
")",
"{",
"if",
"(",
"this",
".",
"conf",
".",
"transform",
")",
"{",
"if",
"(",
"typeof",
"(",
"this",
".",
"conf",
".",
"transform",
".",
"value",
")",
"==",
"'function'",
")",
"{",
"... | Retrieve the value of a variable from the environment.
@api private
@param key The key that has already been passed through
the key transformation function.
@param property The name of a property corresponding to the key.
@param raw The raw untouched key.
@return The value of the environment variable. | [
"Retrieve",
"the",
"value",
"of",
"a",
"variable",
"from",
"the",
"environment",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L84-L96 | train |
cli-kit/cli-env | index.js | getName | function getName(key) {
if(key == '_') return key;
if(this.conf.transform) {
if(typeof(this.conf.transform.name) == 'function') {
return this.conf.transform.name.call(this, key);
}
}
if(this.conf.prefix) {
key = key.replace(this.conf.prefix + '_', '');
}
// guard against silly variables su... | javascript | function getName(key) {
if(key == '_') return key;
if(this.conf.transform) {
if(typeof(this.conf.transform.name) == 'function') {
return this.conf.transform.name.call(this, key);
}
}
if(this.conf.prefix) {
key = key.replace(this.conf.prefix + '_', '');
}
// guard against silly variables su... | [
"function",
"getName",
"(",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"'_'",
")",
"return",
"key",
";",
"if",
"(",
"this",
".",
"conf",
".",
"transform",
")",
"{",
"if",
"(",
"typeof",
"(",
"this",
".",
"conf",
".",
"transform",
".",
"name",
")",
... | Convert a key into a property name.
@param key The property key.
@return A camel case property name. | [
"Convert",
"a",
"key",
"into",
"a",
"property",
"name",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L105-L120 | train |
cli-kit/cli-env | index.js | set | function set(key, value) {
var k = this.getKey(key);
var name = this.getName(key);
if(this.conf.native && typeof(value) == 'string') {
try {
value = native.to(
value, this.conf.native.delimiter, this.conf.native.json);
}catch(e){}
}
this[name] = process.env[k] = value;
} | javascript | function set(key, value) {
var k = this.getKey(key);
var name = this.getName(key);
if(this.conf.native && typeof(value) == 'string') {
try {
value = native.to(
value, this.conf.native.delimiter, this.conf.native.json);
}catch(e){}
}
this[name] = process.env[k] = value;
} | [
"function",
"set",
"(",
"key",
",",
"value",
")",
"{",
"var",
"k",
"=",
"this",
".",
"getKey",
"(",
"key",
")",
";",
"var",
"name",
"=",
"this",
".",
"getName",
"(",
"key",
")",
";",
"if",
"(",
"this",
".",
"conf",
".",
"native",
"&&",
"typeof"... | Set an environment variable using the transform
set function.
@param key The variable key.
@param value The variable value. | [
"Set",
"an",
"environment",
"variable",
"using",
"the",
"transform",
"set",
"function",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L129-L139 | train |
cli-kit/cli-env | index.js | get | function get(key) {
var k = this.getKey(key);
var name = this.getName(key);
var value = this.getValue(k, name, key);
return value;
} | javascript | function get(key) {
var k = this.getKey(key);
var name = this.getName(key);
var value = this.getValue(k, name, key);
return value;
} | [
"function",
"get",
"(",
"key",
")",
"{",
"var",
"k",
"=",
"this",
".",
"getKey",
"(",
"key",
")",
";",
"var",
"name",
"=",
"this",
".",
"getName",
"(",
"key",
")",
";",
"var",
"value",
"=",
"this",
".",
"getValue",
"(",
"k",
",",
"name",
",",
... | Get an environment variable using the transform
get function.
@param key The variable key.
@return The variable value. | [
"Get",
"an",
"environment",
"variable",
"using",
"the",
"transform",
"get",
"function",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L149-L154 | train |
cli-kit/cli-env | index.js | load | function load(match) {
match = match || this.conf.match;
for(var z in process.env) {
if(match instanceof RegExp) {
if(match.test(z)) {
this.set(z.toLowerCase(), process.env[z]);
}
}else{
this.set(z.toLowerCase(), process.env[z]);
}
}
// expand out camel case strings using ... | javascript | function load(match) {
match = match || this.conf.match;
for(var z in process.env) {
if(match instanceof RegExp) {
if(match.test(z)) {
this.set(z.toLowerCase(), process.env[z]);
}
}else{
this.set(z.toLowerCase(), process.env[z]);
}
}
// expand out camel case strings using ... | [
"function",
"load",
"(",
"match",
")",
"{",
"match",
"=",
"match",
"||",
"this",
".",
"conf",
".",
"match",
";",
"for",
"(",
"var",
"z",
"in",
"process",
".",
"env",
")",
"{",
"if",
"(",
"match",
"instanceof",
"RegExp",
")",
"{",
"if",
"(",
"matc... | Load variables from the environment into this
instance.
@param match A regular expression test determining
which variables to load. | [
"Load",
"variables",
"from",
"the",
"environment",
"into",
"this",
"instance",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L163-L189 | train |
cli-kit/cli-env | index.js | env | function env(root, env, escaping) {
walk(root, function visit(props) {
return (props.value instanceof String) || typeof props.value === 'string';
}, function transform(props) {
props.parent[props.name] = replace(props.value, env, escaping);
})
} | javascript | function env(root, env, escaping) {
walk(root, function visit(props) {
return (props.value instanceof String) || typeof props.value === 'string';
}, function transform(props) {
props.parent[props.name] = replace(props.value, env, escaping);
})
} | [
"function",
"env",
"(",
"root",
",",
"env",
",",
"escaping",
")",
"{",
"walk",
"(",
"root",
",",
"function",
"visit",
"(",
"props",
")",
"{",
"return",
"(",
"props",
".",
"value",
"instanceof",
"String",
")",
"||",
"typeof",
"props",
".",
"value",
"=... | Performs recursive substitution of environment variables within
complex objects.
@param root The root object.
@param env An object containing environment variables
default is process.env.
@param escaping Whether escaped dollars indicate replacement
should be ignored. | [
"Performs",
"recursive",
"substitution",
"of",
"environment",
"variables",
"within",
"complex",
"objects",
"."
] | 53681525ce05205e42a77c1d5cc846b5f21d7fb1 | https://github.com/cli-kit/cli-env/blob/53681525ce05205e42a77c1d5cc846b5f21d7fb1/index.js#L250-L256 | train |
origin1tech/chek | build/bump.js | isTruthy | function isTruthy(val) {
return val >= 0 && !isNaN(val) && val !== false
&& val !== undefined && val !== null && val !== '';
} | javascript | function isTruthy(val) {
return val >= 0 && !isNaN(val) && val !== false
&& val !== undefined && val !== null && val !== '';
} | [
"function",
"isTruthy",
"(",
"val",
")",
"{",
"return",
"val",
">=",
"0",
"&&",
"!",
"isNaN",
"(",
"val",
")",
"&&",
"val",
"!==",
"false",
"&&",
"val",
"!==",
"undefined",
"&&",
"val",
"!==",
"null",
"&&",
"val",
"!==",
"''",
";",
"}"
] | Check for truthy value. | [
"Check",
"for",
"truthy",
"value",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/build/bump.js#L28-L31 | train |
origin1tech/chek | build/bump.js | parseVer | function parseVer(idx, set, setting) {
var parsed = tryParseInt(idx);
if (parsed === false || parsed < 0 || isNaN(parsed))
return false;
if (set)
return parseVer(argv[parsed + 1], null, true);
if (setting)
return parsed;
return true;
} | javascript | function parseVer(idx, set, setting) {
var parsed = tryParseInt(idx);
if (parsed === false || parsed < 0 || isNaN(parsed))
return false;
if (set)
return parseVer(argv[parsed + 1], null, true);
if (setting)
return parsed;
return true;
} | [
"function",
"parseVer",
"(",
"idx",
",",
"set",
",",
"setting",
")",
"{",
"var",
"parsed",
"=",
"tryParseInt",
"(",
"idx",
")",
";",
"if",
"(",
"parsed",
"===",
"false",
"||",
"parsed",
"<",
"0",
"||",
"isNaN",
"(",
"parsed",
")",
")",
"return",
"f... | Parse the version from command line. | [
"Parse",
"the",
"version",
"from",
"command",
"line",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/build/bump.js#L43-L52 | train |
origin1tech/chek | build/bump.js | setVersion | function setVersion(type, ver) {
const idx = verMap[type];
let cur = verArr[idx];
let next = cur + 1;
if (isTruthy(ver))
next = ver;
if (isTruthy(ver)) {
verArr[idx] = ver;
}
else {
if (type === 'patch') {
if (next > maxPatch) {
// zero current stepping
// up to minor... | javascript | function setVersion(type, ver) {
const idx = verMap[type];
let cur = verArr[idx];
let next = cur + 1;
if (isTruthy(ver))
next = ver;
if (isTruthy(ver)) {
verArr[idx] = ver;
}
else {
if (type === 'patch') {
if (next > maxPatch) {
// zero current stepping
// up to minor... | [
"function",
"setVersion",
"(",
"type",
",",
"ver",
")",
"{",
"const",
"idx",
"=",
"verMap",
"[",
"type",
"]",
";",
"let",
"cur",
"=",
"verArr",
"[",
"idx",
"]",
";",
"let",
"next",
"=",
"cur",
"+",
"1",
";",
"if",
"(",
"isTruthy",
"(",
"ver",
"... | Recursive for setting version. | [
"Recursive",
"for",
"setting",
"version",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/build/bump.js#L62-L103 | train |
Mike96Angelo/CompileIt | lib/utils.js | repeat | function repeat(str, n) {
var result = '';
for (var i = 0; i < n; i++) {
result += str;
}
return result;
} | javascript | function repeat(str, n) {
var result = '';
for (var i = 0; i < n; i++) {
result += str;
}
return result;
} | [
"function",
"repeat",
"(",
"str",
",",
"n",
")",
"{",
"var",
"result",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"str",
";",
"}",
"return",
"result",
";",
"}"
] | Repeats a string `n` time.
@param {String} str String to be repeated.
@param {Number} n Number of times to repeat. | [
"Repeats",
"a",
"string",
"n",
"time",
"."
] | 7c2e79d67d7d25fcfe66aaf25648afece804b5c4 | https://github.com/Mike96Angelo/CompileIt/blob/7c2e79d67d7d25fcfe66aaf25648afece804b5c4/lib/utils.js#L32-L40 | train |
Mike96Angelo/CompileIt | lib/utils.js | bufferSlice | function bufferSlice(code, range, format) {
format = format || varThrough;
return JSON.stringify(
code.slice(Math.max(0, code.index - range), code.index)
)
.slice(1, -1) +
format(
JSON.stringify(code.charAt(code.index) || 'EOF')
.slice(1, -1)
)... | javascript | function bufferSlice(code, range, format) {
format = format || varThrough;
return JSON.stringify(
code.slice(Math.max(0, code.index - range), code.index)
)
.slice(1, -1) +
format(
JSON.stringify(code.charAt(code.index) || 'EOF')
.slice(1, -1)
)... | [
"function",
"bufferSlice",
"(",
"code",
",",
"range",
",",
"format",
")",
"{",
"format",
"=",
"format",
"||",
"varThrough",
";",
"return",
"JSON",
".",
"stringify",
"(",
"code",
".",
"slice",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"code",
".",
"inde... | Stringified CodeBuffer slice.
@param {CodeBuffer} code CodeBuffer to slice.
@param {Number} range Range to slice before and after `code.index`. | [
"Stringified",
"CodeBuffer",
"slice",
"."
] | 7c2e79d67d7d25fcfe66aaf25648afece804b5c4 | https://github.com/Mike96Angelo/CompileIt/blob/7c2e79d67d7d25fcfe66aaf25648afece804b5c4/lib/utils.js#L57-L74 | train |
Kashio/fspvr | index.js | function(segment, strict) {
if (!_.isString(segment)) {
throw new TypeError('segment must be of type string');
}
if (!_.isBoolean(strict)) {
strict = true;
}
segment = segment.replace(illegalCharacters, '');
if (strict && osType === "Windows_NT") {
segment = segment.replace(illegalNames, '');
wh... | javascript | function(segment, strict) {
if (!_.isString(segment)) {
throw new TypeError('segment must be of type string');
}
if (!_.isBoolean(strict)) {
strict = true;
}
segment = segment.replace(illegalCharacters, '');
if (strict && osType === "Windows_NT") {
segment = segment.replace(illegalNames, '');
wh... | [
"function",
"(",
"segment",
",",
"strict",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"segment",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'segment must be of type string'",
")",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isBoolean",
"(",
... | Reformat fs segment to be valid
@param {String} segment
@param {Boolean=true} strict
@return {String} | [
"Reformat",
"fs",
"segment",
"to",
"be",
"valid"
] | 3777dedc7f25ec6d596b6011a954724e77cb0258 | https://github.com/Kashio/fspvr/blob/3777dedc7f25ec6d596b6011a954724e77cb0258/index.js#L35-L50 | train | |
Kashio/fspvr | index.js | function(fsPath, strict) {
if (!_.isString(fsPath)) {
throw new TypeError('path must be of type string');
}
var segments = _.filter(fsPath.substring(fsPath.indexOf(path.sep) + 1).split(path.sep), function(segment) {
return segment !== '';
});
for (var i = 0; i < segments.length; i++) {
var replaceWit... | javascript | function(fsPath, strict) {
if (!_.isString(fsPath)) {
throw new TypeError('path must be of type string');
}
var segments = _.filter(fsPath.substring(fsPath.indexOf(path.sep) + 1).split(path.sep), function(segment) {
return segment !== '';
});
for (var i = 0; i < segments.length; i++) {
var replaceWit... | [
"function",
"(",
"fsPath",
",",
"strict",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"fsPath",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'path must be of type string'",
")",
";",
"}",
"var",
"segments",
"=",
"_",
".",
"filter",
"(",
... | Reformat fs path to be valid
@param {String} fsPath
@param {Boolean=true} strict
@return {String} | [
"Reformat",
"fs",
"path",
"to",
"be",
"valid"
] | 3777dedc7f25ec6d596b6011a954724e77cb0258 | https://github.com/Kashio/fspvr/blob/3777dedc7f25ec6d596b6011a954724e77cb0258/index.js#L58-L71 | train | |
Kashio/fspvr | index.js | function(fsPath, strict) {
if (!_.isString(fsPath)) {
throw new TypeError('path must be of type string');
}
return fsPath === module.exports.reformatPath(fsPath, strict);
} | javascript | function(fsPath, strict) {
if (!_.isString(fsPath)) {
throw new TypeError('path must be of type string');
}
return fsPath === module.exports.reformatPath(fsPath, strict);
} | [
"function",
"(",
"fsPath",
",",
"strict",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"fsPath",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'path must be of type string'",
")",
";",
"}",
"return",
"fsPath",
"===",
"module",
".",
"exports",... | Checks if fs path is valid
@param {String} fsPath
@param {Boolean=true} strict
@return {Boolean} | [
"Checks",
"if",
"fs",
"path",
"is",
"valid"
] | 3777dedc7f25ec6d596b6011a954724e77cb0258 | https://github.com/Kashio/fspvr/blob/3777dedc7f25ec6d596b6011a954724e77cb0258/index.js#L79-L84 | train | |
Kashio/fspvr | index.js | function(segment, strict) {
if (!_.isString(segment)) {
throw new TypeError('segment must be of type string');
}
return segment === module.exports.reformatSegment(segment, strict);
} | javascript | function(segment, strict) {
if (!_.isString(segment)) {
throw new TypeError('segment must be of type string');
}
return segment === module.exports.reformatSegment(segment, strict);
} | [
"function",
"(",
"segment",
",",
"strict",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"segment",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'segment must be of type string'",
")",
";",
"}",
"return",
"segment",
"===",
"module",
".",
"exp... | Checks if fs segment is valid
@param {String} segment
@param {Boolean=true} strict
@return {Boolean} | [
"Checks",
"if",
"fs",
"segment",
"is",
"valid"
] | 3777dedc7f25ec6d596b6011a954724e77cb0258 | https://github.com/Kashio/fspvr/blob/3777dedc7f25ec6d596b6011a954724e77cb0258/index.js#L92-L97 | train | |
Ivshti/named-queue | index.js | update | function update() {
while (waiting.length && count < concurrency) (function() {
var t = waiting.shift()
if (inProg[t.task.id]) {
inProg[t.task.id].push(t.cb)
return
} else {
inProg[t.task.id] = [t.cb]
count++
processor(t.task, function() {
var args = arguments
if (!inProg[t... | javascript | function update() {
while (waiting.length && count < concurrency) (function() {
var t = waiting.shift()
if (inProg[t.task.id]) {
inProg[t.task.id].push(t.cb)
return
} else {
inProg[t.task.id] = [t.cb]
count++
processor(t.task, function() {
var args = arguments
if (!inProg[t... | [
"function",
"update",
"(",
")",
"{",
"while",
"(",
"waiting",
".",
"length",
"&&",
"count",
"<",
"concurrency",
")",
"(",
"function",
"(",
")",
"{",
"var",
"t",
"=",
"waiting",
".",
"shift",
"(",
")",
"if",
"(",
"inProg",
"[",
"t",
".",
"task",
"... | var paused = false | [
"var",
"paused",
"=",
"false"
] | 3dfd103466a869a3c6dd23012813ac11cb4fe906 | https://github.com/Ivshti/named-queue/blob/3dfd103466a869a3c6dd23012813ac11cb4fe906/index.js#L11-L34 | train |
Nazariglez/perenquen | lib/pixi/src/core/math/shapes/Circle.js | Circle | function Circle(x, y, radius)
{
/**
* @member {number}
* @default 0
*/
this.x = x || 0;
/**
* @member {number}
* @default 0
*/
this.y = y || 0;
/**
* @member {number}
* @default 0
*/
this.radius = radius || 0;
/**
* The type of the object,... | javascript | function Circle(x, y, radius)
{
/**
* @member {number}
* @default 0
*/
this.x = x || 0;
/**
* @member {number}
* @default 0
*/
this.y = y || 0;
/**
* @member {number}
* @default 0
*/
this.radius = radius || 0;
/**
* The type of the object,... | [
"function",
"Circle",
"(",
"x",
",",
"y",
",",
"radius",
")",
"{",
"/**\n * @member {number}\n * @default 0\n */",
"this",
".",
"x",
"=",
"x",
"||",
"0",
";",
"/**\n * @member {number}\n * @default 0\n */",
"this",
".",
"y",
"=",
"y",
"||",
... | The Circle object can be used to specify a hit area for displayObjects
@class
@memberof PIXI
@param x {number} The X coordinate of the center of this circle
@param y {number} The Y coordinate of the center of this circle
@param radius {number} The radius of the circle | [
"The",
"Circle",
"object",
"can",
"be",
"used",
"to",
"specify",
"a",
"hit",
"area",
"for",
"displayObjects"
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/core/math/shapes/Circle.js#L13-L39 | train |
haztivity/hz-soupletter | src/lib/wordfind.js | function (words, options) {
var puzzle = [], i, j, len;
// initialize the puzzle with blanks
for (i = 0; i < options.height; i++) {
puzzle.push([]);
for (j = 0; j < options.width; j++) {
puzzle[i].push('');
}
... | javascript | function (words, options) {
var puzzle = [], i, j, len;
// initialize the puzzle with blanks
for (i = 0; i < options.height; i++) {
puzzle.push([]);
for (j = 0; j < options.width; j++) {
puzzle[i].push('');
}
... | [
"function",
"(",
"words",
",",
"options",
")",
"{",
"var",
"puzzle",
"=",
"[",
"]",
",",
"i",
",",
"j",
",",
"len",
";",
"// initialize the puzzle with blanks",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"height",
";",
"i",
"++",
")"... | Initializes the puzzle and places words in the puzzle one at a time.
Returns either a valid puzzle with all of the words or null if a valid
puzzle was not found.
@param {[String]} words: The list of words to fit into the puzzle
@param {[Options]} options: The options to use when filling the puzzle | [
"Initializes",
"the",
"puzzle",
"and",
"places",
"words",
"in",
"the",
"puzzle",
"one",
"at",
"a",
"time",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L82-L100 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (puzzle, options, word) {
// find all of the best locations where this word would fit
var locations = findBestLocations(puzzle, options, word);
if (locations.length === 0) {
return false;
}
// select a location at random and place the ... | javascript | function (puzzle, options, word) {
// find all of the best locations where this word would fit
var locations = findBestLocations(puzzle, options, word);
if (locations.length === 0) {
return false;
}
// select a location at random and place the ... | [
"function",
"(",
"puzzle",
",",
"options",
",",
"word",
")",
"{",
"// find all of the best locations where this word would fit",
"var",
"locations",
"=",
"findBestLocations",
"(",
"puzzle",
",",
"options",
",",
"word",
")",
";",
"if",
"(",
"locations",
".",
"lengt... | Adds the specified word to the puzzle by finding all of the possible
locations where the word will fit and then randomly selecting one. Options
controls whether or not word overlap should be maximized.
Returns true if the word was successfully placed, false otherwise.
@param {[[String]]} puzzle: The current state of ... | [
"Adds",
"the",
"specified",
"word",
"to",
"the",
"puzzle",
"by",
"finding",
"all",
"of",
"the",
"possible",
"locations",
"where",
"the",
"word",
"will",
"fit",
"and",
"then",
"randomly",
"selecting",
"one",
".",
"Options",
"controls",
"whether",
"or",
"not",... | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L112-L122 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (puzzle, options, word) {
var locations = [], height = options.height, width = options.width, wordLength = word.length, maxOverlap = 0; // we'll start looking at overlap = 0
// loop through all of the possible orientations at this position
for (var k = 0, len = options.orien... | javascript | function (puzzle, options, word) {
var locations = [], height = options.height, width = options.width, wordLength = word.length, maxOverlap = 0; // we'll start looking at overlap = 0
// loop through all of the possible orientations at this position
for (var k = 0, len = options.orien... | [
"function",
"(",
"puzzle",
",",
"options",
",",
"word",
")",
"{",
"var",
"locations",
"=",
"[",
"]",
",",
"height",
"=",
"options",
".",
"height",
",",
"width",
"=",
"options",
".",
"width",
",",
"wordLength",
"=",
"word",
".",
"length",
",",
"maxOve... | Iterates through the puzzle and determines all of the locations where
the word will fit. Options determines if overlap should be maximized or
not.
Returns a list of location objects which contain an x,y cooridinate
indicating the start of the word, the orientation of the word, and the
number of letters that overlapped... | [
"Iterates",
"through",
"the",
"puzzle",
"and",
"determines",
"all",
"of",
"the",
"locations",
"where",
"the",
"word",
"will",
"fit",
".",
"Options",
"determines",
"if",
"overlap",
"should",
"be",
"maximized",
"or",
"not",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L136-L173 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (word, puzzle, x, y, fnGetSquare) {
var overlap = 0;
// traverse the squares to determine if the word fits
for (var i = 0, len = word.length; i < len; i++) {
var next = fnGetSquare(x, y, i), square = puzzle[next.y][next.x];
// if the puzzle sq... | javascript | function (word, puzzle, x, y, fnGetSquare) {
var overlap = 0;
// traverse the squares to determine if the word fits
for (var i = 0, len = word.length; i < len; i++) {
var next = fnGetSquare(x, y, i), square = puzzle[next.y][next.x];
// if the puzzle sq... | [
"function",
"(",
"word",
",",
"puzzle",
",",
"x",
",",
"y",
",",
"fnGetSquare",
")",
"{",
"var",
"overlap",
"=",
"0",
";",
"// traverse the squares to determine if the word fits",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"word",
".",
"length",
... | Determines whether or not a particular word fits in a particular
orientation within the puzzle.
Returns the number of letters overlapped with existing words if the word
fits in the specified position, -1 if the word does not fit.
@param {String} word: The word to fit into the puzzle.
@param {[[String]]} puzzle: The c... | [
"Determines",
"whether",
"or",
"not",
"a",
"particular",
"word",
"fits",
"in",
"a",
"particular",
"orientation",
"within",
"the",
"puzzle",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L187-L204 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (locations, overlap) {
var pruned = [];
for (var i = 0, len = locations.length; i < len; i++) {
if (locations[i].overlap >= overlap) {
pruned.push(locations[i]);
}
}
return pruned;
} | javascript | function (locations, overlap) {
var pruned = [];
for (var i = 0, len = locations.length; i < len; i++) {
if (locations[i].overlap >= overlap) {
pruned.push(locations[i]);
}
}
return pruned;
} | [
"function",
"(",
"locations",
",",
"overlap",
")",
"{",
"var",
"pruned",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"locations",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"locations",
... | If overlap maximization was indicated, this function is used to prune the
list of valid locations down to the ones that contain the maximum overlap
that was previously calculated.
Returns the pruned set of locations.
@param {[Location]} locations: The set of locations to prune
@param {int} overlap: The required level... | [
"If",
"overlap",
"maximization",
"was",
"indicated",
"this",
"function",
"is",
"used",
"to",
"prune",
"the",
"list",
"of",
"valid",
"locations",
"down",
"to",
"the",
"ones",
"that",
"contain",
"the",
"maximum",
"overlap",
"that",
"was",
"previously",
"calculat... | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L215-L223 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (puzzle) {
for (var i = 0, height = puzzle.length; i < height; i++) {
var row = puzzle[i];
for (var j = 0, width = row.length; j < width; j++) {
if (!puzzle[i][j]) {
var randomLetter = Math.floor(Math.ra... | javascript | function (puzzle) {
for (var i = 0, height = puzzle.length; i < height; i++) {
var row = puzzle[i];
for (var j = 0, width = row.length; j < width; j++) {
if (!puzzle[i][j]) {
var randomLetter = Math.floor(Math.ra... | [
"function",
"(",
"puzzle",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"height",
"=",
"puzzle",
".",
"length",
";",
"i",
"<",
"height",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"puzzle",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"j",
... | Fills in any empty spaces in the puzzle with random letters.
@param {[[String]]} puzzle: The current state of the puzzle
@api public | [
"Fills",
"in",
"any",
"empty",
"spaces",
"in",
"the",
"puzzle",
"with",
"random",
"letters",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L309-L319 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (puzzle, words) {
var options = {
height: puzzle.length,
width: puzzle[0].length,
orientations: allOrientations,
preferOverlap: true
}, found = [], notFound = [];
for (var i = 0, len ... | javascript | function (puzzle, words) {
var options = {
height: puzzle.length,
width: puzzle[0].length,
orientations: allOrientations,
preferOverlap: true
}, found = [], notFound = [];
for (var i = 0, len ... | [
"function",
"(",
"puzzle",
",",
"words",
")",
"{",
"var",
"options",
"=",
"{",
"height",
":",
"puzzle",
".",
"length",
",",
"width",
":",
"puzzle",
"[",
"0",
"]",
".",
"length",
",",
"orientations",
":",
"allOrientations",
",",
"preferOverlap",
":",
"t... | Returns the starting location and orientation of the specified words
within the puzzle. Any words that are not found are returned in the
notFound array.
Returns
x position of start of word
y position of start of word
orientation of word
word
overlap (always equal to word.length)
@param {[[String]]} puzzle: The curren... | [
"Returns",
"the",
"starting",
"location",
"and",
"orientation",
"of",
"the",
"specified",
"words",
"within",
"the",
"puzzle",
".",
"Any",
"words",
"that",
"are",
"not",
"found",
"are",
"returned",
"in",
"the",
"notFound",
"array",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L336-L356 | train | |
haztivity/hz-soupletter | src/lib/wordfind.js | function (puzzle) {
var puzzleString = '';
for (var i = 0, height = puzzle.length; i < height; i++) {
var row = puzzle[i];
for (var j = 0, width = row.length; j < width; j++) {
puzzleString += (row[j] === '' ? ' ' : row[j]) ... | javascript | function (puzzle) {
var puzzleString = '';
for (var i = 0, height = puzzle.length; i < height; i++) {
var row = puzzle[i];
for (var j = 0, width = row.length; j < width; j++) {
puzzleString += (row[j] === '' ? ' ' : row[j]) ... | [
"function",
"(",
"puzzle",
")",
"{",
"var",
"puzzleString",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"height",
"=",
"puzzle",
".",
"length",
";",
"i",
"<",
"height",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"puzzle",
"[",
"i",... | Outputs a puzzle to the console, useful for debugging.
Returns a formatted string representing the puzzle.
@param {[[String]]} puzzle: The current state of the puzzle
@api public | [
"Outputs",
"a",
"puzzle",
"to",
"the",
"console",
"useful",
"for",
"debugging",
".",
"Returns",
"a",
"formatted",
"string",
"representing",
"the",
"puzzle",
"."
] | 38cbcd0c6e9ad029b7e74ce9e9e75f8775870956 | https://github.com/haztivity/hz-soupletter/blob/38cbcd0c6e9ad029b7e74ce9e9e75f8775870956/src/lib/wordfind.js#L364-L375 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function (connection, attempt) {
var clonedAttempt = EJSON.clone(attempt);
clonedAttempt.connection = connection;
return clonedAttempt;
} | javascript | function (connection, attempt) {
var clonedAttempt = EJSON.clone(attempt);
clonedAttempt.connection = connection;
return clonedAttempt;
} | [
"function",
"(",
"connection",
",",
"attempt",
")",
"{",
"var",
"clonedAttempt",
"=",
"EJSON",
".",
"clone",
"(",
"attempt",
")",
";",
"clonedAttempt",
".",
"connection",
"=",
"connection",
";",
"return",
"clonedAttempt",
";",
"}"
] | Give each login hook callback a fresh cloned copy of the attempt object, but don't clone the connection. | [
"Give",
"each",
"login",
"hook",
"callback",
"a",
"fresh",
"cloned",
"copy",
"of",
"the",
"attempt",
"object",
"but",
"don",
"t",
"clone",
"the",
"connection",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L77-L81 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function (methodInvocation, options) {
for (var i = 0; i < loginHandlers.length; ++i) {
var handler = loginHandlers[i];
var result = tryLoginMethod(
handler.name,
function () {
return handler.handler.call(methodInvocation, options);
}
);
if (result)
return result;
... | javascript | function (methodInvocation, options) {
for (var i = 0; i < loginHandlers.length; ++i) {
var handler = loginHandlers[i];
var result = tryLoginMethod(
handler.name,
function () {
return handler.handler.call(methodInvocation, options);
}
);
if (result)
return result;
... | [
"function",
"(",
"methodInvocation",
",",
"options",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"loginHandlers",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"handler",
"=",
"loginHandlers",
"[",
"i",
"]",
";",
"var",
"result",
"... | Try all of the registered login handlers until one of them doesn't return `undefined`, meaning it handled this call to `login`. Return that return value. | [
"Try",
"all",
"of",
"the",
"registered",
"login",
"handlers",
"until",
"one",
"of",
"them",
"doesn",
"t",
"return",
"undefined",
"meaning",
"it",
"handled",
"this",
"call",
"to",
"login",
".",
"Return",
"that",
"return",
"value",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L376-L397 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function () {
var self = this;
var user = Meteor.users.findOne(self.userId, {
fields: { "services.resume.loginTokens": 1 }
});
if (! self.userId || ! user) {
throw new Meteor.Error("You are not logged in.");
}
// Be careful not to generate a new token that has a later
// expirati... | javascript | function () {
var self = this;
var user = Meteor.users.findOne(self.userId, {
fields: { "services.resume.loginTokens": 1 }
});
if (! self.userId || ! user) {
throw new Meteor.Error("You are not logged in.");
}
// Be careful not to generate a new token that has a later
// expirati... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"user",
"=",
"Meteor",
".",
"users",
".",
"findOne",
"(",
"self",
".",
"userId",
",",
"{",
"fields",
":",
"{",
"\"services.resume.loginTokens\"",
":",
"1",
"}",
"}",
")",
";",
"if",
... | Generates a new login token with the same expiration as the connection's current token and saves it to the database. Associates the connection with this new token and returns it. Throws an error if called on a connection that isn't logged in. @returns Object If successful, returns { token: <new token>, id: <user id>, ... | [
"Generates",
"a",
"new",
"login",
"token",
"with",
"the",
"same",
"expiration",
"as",
"the",
"connection",
"s",
"current",
"token",
"and",
"saves",
"it",
"to",
"the",
"database",
".",
"Associates",
"the",
"connection",
"with",
"this",
"new",
"token",
"and",
... | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L513-L539 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function () {
var self = this;
if (! self.userId) {
throw new Meteor.Error("You are not logged in.");
}
var currentToken = Accounts._getLoginToken(self.connection.id);
Meteor.users.update(self.userId, {
$pull: {
"services.resume.loginTokens": { hashedToken: { $ne: currentToken } ... | javascript | function () {
var self = this;
if (! self.userId) {
throw new Meteor.Error("You are not logged in.");
}
var currentToken = Accounts._getLoginToken(self.connection.id);
Meteor.users.update(self.userId, {
$pull: {
"services.resume.loginTokens": { hashedToken: { $ne: currentToken } ... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"self",
".",
"userId",
")",
"{",
"throw",
"new",
"Meteor",
".",
"Error",
"(",
"\"You are not logged in.\"",
")",
";",
"}",
"var",
"currentToken",
"=",
"Accounts",
".",
"_getLog... | Removes all tokens except the token associated with the current connection. Throws an error if the connection is not logged in. Returns nothing on success. | [
"Removes",
"all",
"tokens",
"except",
"the",
"token",
"associated",
"with",
"the",
"current",
"connection",
".",
"Throws",
"an",
"error",
"if",
"the",
"connection",
"is",
"not",
"logged",
"in",
".",
"Returns",
"nothing",
"on",
"success",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L544-L555 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function (serviceData, userId) {
_.each(_.keys(serviceData), function (key) {
var value = serviceData[key];
if (OAuthEncryption && OAuthEncryption.isSealed(value))
value = OAuthEncryption.seal(OAuthEncryption.open(value), userId);
serviceData[key] = value;
});
} | javascript | function (serviceData, userId) {
_.each(_.keys(serviceData), function (key) {
var value = serviceData[key];
if (OAuthEncryption && OAuthEncryption.isSealed(value))
value = OAuthEncryption.seal(OAuthEncryption.open(value), userId);
serviceData[key] = value;
});
} | [
"function",
"(",
"serviceData",
",",
"userId",
")",
"{",
"_",
".",
"each",
"(",
"_",
".",
"keys",
"(",
"serviceData",
")",
",",
"function",
"(",
"key",
")",
"{",
"var",
"value",
"=",
"serviceData",
"[",
"key",
"]",
";",
"if",
"(",
"OAuthEncryption",
... | OAuth service data is temporarily stored in the pending credentials collection during the oauth authentication process. Sensitive data such as access tokens are encrypted without the user id because we don't know the user id yet. We re-encrypt these fields with the user id included when storing the service data perma... | [
"OAuth",
"service",
"data",
"is",
"temporarily",
"stored",
"in",
"the",
"pending",
"credentials",
"collection",
"during",
"the",
"oauth",
"authentication",
"process",
".",
"Sensitive",
"data",
"such",
"as",
"access",
"tokens",
"are",
"encrypted",
"without",
"the",... | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L933-L940 | train | |
xiamidaxia/xiami | meteor/accounts-base/accounts_server.js | function (userId, user, fields, modifier) {
// make sure it is our record
if (user._id !== userId)
return false;
// user can only modify the 'profile' field. sets to multiple
// sub-keys (eg profile.foo and profile.bar) are merged into entry
// in the fields list.
if (fields.length !== 1 ... | javascript | function (userId, user, fields, modifier) {
// make sure it is our record
if (user._id !== userId)
return false;
// user can only modify the 'profile' field. sets to multiple
// sub-keys (eg profile.foo and profile.bar) are merged into entry
// in the fields list.
if (fields.length !== 1 ... | [
"function",
"(",
"userId",
",",
"user",
",",
"fields",
",",
"modifier",
")",
"{",
"// make sure it is our record",
"if",
"(",
"user",
".",
"_id",
"!==",
"userId",
")",
"return",
"false",
";",
"// user can only modify the 'profile' field. sets to multiple",
"// sub-key... | clients can modify the profile field of their own document, and nothing else. | [
"clients",
"can",
"modify",
"the",
"profile",
"field",
"of",
"their",
"own",
"document",
"and",
"nothing",
"else",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/accounts-base/accounts_server.js#L1304-L1316 | train | |
Digznav/bilberry | log.js | logMessage | function logMessage(fig, st, lns) {
return lns.reduce((a, b) => a.concat(` ${b}`), [`\n${fig} ${st}`]);
} | javascript | function logMessage(fig, st, lns) {
return lns.reduce((a, b) => a.concat(` ${b}`), [`\n${fig} ${st}`]);
} | [
"function",
"logMessage",
"(",
"fig",
",",
"st",
",",
"lns",
")",
"{",
"return",
"lns",
".",
"reduce",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"a",
".",
"concat",
"(",
"`",
"${",
"b",
"}",
"`",
")",
",",
"[",
"`",
"\\n",
"${",
"fig",
"}",
"${",... | It adds an icon and tabulates the log massage.
@param {string} fig Icon.
@param {string} st First line of the log message.
@param {array} lns Rest of the message.
@return {array} Parsed message. | [
"It",
"adds",
"an",
"icon",
"and",
"tabulates",
"the",
"log",
"massage",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/log.js#L11-L13 | train |
Digznav/bilberry | log.js | log | function log(first, ...lines) {
console.log(logMessage(figures.bullet, first, lines).join('\n'));
} | javascript | function log(first, ...lines) {
console.log(logMessage(figures.bullet, first, lines).join('\n'));
} | [
"function",
"log",
"(",
"first",
",",
"...",
"lines",
")",
"{",
"console",
".",
"log",
"(",
"logMessage",
"(",
"figures",
".",
"bullet",
",",
"first",
",",
"lines",
")",
".",
"join",
"(",
"'\\n'",
")",
")",
";",
"}"
] | Console log custom wrapper.
@param {string} first First line.
@param {args} lines Rest of the lines.
@return {log} Log message. | [
"Console",
"log",
"custom",
"wrapper",
"."
] | ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4 | https://github.com/Digznav/bilberry/blob/ef6db49de6c8b0d2f4f9d3e10e8a8153e39ffcc4/log.js#L21-L23 | train |
PeterNaydenov/ask-for-promise | src/askForPromise.js | _singlePromise | function _singlePromise () {
let done, cancel;
const x = new Promise ( (resolve, reject ) => {
done = resolve
cancel = reject
})
return {
promise : x
... | javascript | function _singlePromise () {
let done, cancel;
const x = new Promise ( (resolve, reject ) => {
done = resolve
cancel = reject
})
return {
promise : x
... | [
"function",
"_singlePromise",
"(",
")",
"{",
"let",
"done",
",",
"cancel",
";",
"const",
"x",
"=",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"done",
"=",
"resolve",
"cancel",
"=",
"reject",
"}",
")",
"return",
"{",
"promis... | askForPromise func. | [
"askForPromise",
"func",
"."
] | 2aca2eaf947c234ec7ea3b6f3e95ec6f09634354 | https://github.com/PeterNaydenov/ask-for-promise/blob/2aca2eaf947c234ec7ea3b6f3e95ec6f09634354/src/askForPromise.js#L32-L45 | train |
PeterNaydenov/ask-for-promise | src/askForPromise.js | _manyPromises | function _manyPromises ( list ) {
let askObject = list.map ( el => _singlePromise() )
let askList = askObject.map ( o => o.promise )
askObject [ 'promises' ] = askList
... | javascript | function _manyPromises ( list ) {
let askObject = list.map ( el => _singlePromise() )
let askList = askObject.map ( o => o.promise )
askObject [ 'promises' ] = askList
... | [
"function",
"_manyPromises",
"(",
"list",
")",
"{",
"let",
"askObject",
"=",
"list",
".",
"map",
"(",
"el",
"=>",
"_singlePromise",
"(",
")",
")",
"let",
"askList",
"=",
"askObject",
".",
"map",
"(",
"o",
"=>",
"o",
".",
"promise",
")",
"askObject",
... | _singlePromise func. | [
"_singlePromise",
"func",
"."
] | 2aca2eaf947c234ec7ea3b6f3e95ec6f09634354 | https://github.com/PeterNaydenov/ask-for-promise/blob/2aca2eaf947c234ec7ea3b6f3e95ec6f09634354/src/askForPromise.js#L49-L56 | train |
skerit/alchemy | lib/core/discovery.js | onServerMessage | function onServerMessage(message, rinfo) {
var packet,
respond;
alchemy.setStatus('multicast_messages', ++messages);
try {
packet = bson.deserialize(message);
} catch(err) {
log.warn('Received corrupt multicast message from ' + rinfo.address);
return;
}
// Ignore packets that come from here
if (pa... | javascript | function onServerMessage(message, rinfo) {
var packet,
respond;
alchemy.setStatus('multicast_messages', ++messages);
try {
packet = bson.deserialize(message);
} catch(err) {
log.warn('Received corrupt multicast message from ' + rinfo.address);
return;
}
// Ignore packets that come from here
if (pa... | [
"function",
"onServerMessage",
"(",
"message",
",",
"rinfo",
")",
"{",
"var",
"packet",
",",
"respond",
";",
"alchemy",
".",
"setStatus",
"(",
"'multicast_messages'",
",",
"++",
"messages",
")",
";",
"try",
"{",
"packet",
"=",
"bson",
".",
"deserialize",
"... | Listen for messages
@author Jelle De Loecker <jelle@develry.be>
@since 0.1.0
@version 0.4.3 | [
"Listen",
"for",
"messages"
] | ede1dad07a5a737d5d1e10c2ff87fdfb057443f8 | https://github.com/skerit/alchemy/blob/ede1dad07a5a737d5d1e10c2ff87fdfb057443f8/lib/core/discovery.js#L74-L119 | train |
CoderByBlood/deified | scanner.js | tree | async function tree(dir, files) {
log.trace.configure({ reading: dir });
const { filter } = conf;
const ls = await readdir(dir, conf.options);
for (let i = 0; i < ls.length; i += 1) {
const file = path.join(dir, ls[i]);
if (!filter || filter([file]).length) {
log.trac... | javascript | async function tree(dir, files) {
log.trace.configure({ reading: dir });
const { filter } = conf;
const ls = await readdir(dir, conf.options);
for (let i = 0; i < ls.length; i += 1) {
const file = path.join(dir, ls[i]);
if (!filter || filter([file]).length) {
log.trac... | [
"async",
"function",
"tree",
"(",
"dir",
",",
"files",
")",
"{",
"log",
".",
"trace",
".",
"configure",
"(",
"{",
"reading",
":",
"dir",
"}",
")",
";",
"const",
"{",
"filter",
"}",
"=",
"conf",
";",
"const",
"ls",
"=",
"await",
"readdir",
"(",
"d... | Recursively builds a list of files and directories for the specified
directory and all subdirectors - can be optionally filtered.
@param {string} dir - The directory to list (ls)
@param {array} files - The array for appending files/directors
@return {array} The files argument | [
"Recursively",
"builds",
"a",
"list",
"of",
"files",
"and",
"directories",
"for",
"the",
"specified",
"directory",
"and",
"all",
"subdirectors",
"-",
"can",
"be",
"optionally",
"filtered",
"."
] | f2d212ffe111b8dfb4872819afe3d5a7a3b8a1b6 | https://github.com/CoderByBlood/deified/blob/f2d212ffe111b8dfb4872819afe3d5a7a3b8a1b6/scanner.js#L56-L78 | train |
Bartozzz/get-link | dist/index.js | regenerateLink | function regenerateLink(base, link) {
const parsedBase = (0, _url.parse)(base);
const parsedLink = link.split("/");
let parts = [];
let port = "";
if (!link.startsWith("/")) {
parts = parsedBase.pathname.split("/");
parts.pop();
}
for (const part of parsedLink) {
// Current directory:
if... | javascript | function regenerateLink(base, link) {
const parsedBase = (0, _url.parse)(base);
const parsedLink = link.split("/");
let parts = [];
let port = "";
if (!link.startsWith("/")) {
parts = parsedBase.pathname.split("/");
parts.pop();
}
for (const part of parsedLink) {
// Current directory:
if... | [
"function",
"regenerateLink",
"(",
"base",
",",
"link",
")",
"{",
"const",
"parsedBase",
"=",
"(",
"0",
",",
"_url",
".",
"parse",
")",
"(",
"base",
")",
";",
"const",
"parsedLink",
"=",
"link",
".",
"split",
"(",
"\"/\"",
")",
";",
"let",
"parts",
... | Regenerates an absolute URL from `base` and relative `link`.
@param {string} base Absolute base url
@param {string} link Relative link
@return {string|null} | [
"Regenerates",
"an",
"absolute",
"URL",
"from",
"base",
"and",
"relative",
"link",
"."
] | 4506cfade27e420e51774978b9761f089d47965a | https://github.com/Bartozzz/get-link/blob/4506cfade27e420e51774978b9761f089d47965a/dist/index.js#L44-L78 | train |
Bartozzz/get-link | dist/index.js | _default | function _default(base, link) {
// Dynamic stuff:
if (typeof link !== "string" || link.match(REGEX_DYNAMIC)) {
return base;
} // Link is absolute:
if (link.match(REGEX_ABSOLUTE)) {
try {
const parsedBase = parseLink(base);
const parsedLink = parseLink(link); // Both `base` and `link` are o... | javascript | function _default(base, link) {
// Dynamic stuff:
if (typeof link !== "string" || link.match(REGEX_DYNAMIC)) {
return base;
} // Link is absolute:
if (link.match(REGEX_ABSOLUTE)) {
try {
const parsedBase = parseLink(base);
const parsedLink = parseLink(link); // Both `base` and `link` are o... | [
"function",
"_default",
"(",
"base",
",",
"link",
")",
"{",
"// Dynamic stuff:",
"if",
"(",
"typeof",
"link",
"!==",
"\"string\"",
"||",
"link",
".",
"match",
"(",
"REGEX_DYNAMIC",
")",
")",
"{",
"return",
"base",
";",
"}",
"// Link is absolute:",
"if",
"(... | Transform a relative path into an absolute url.
@param {string} base Absolute base url
@param {string} link Link to parse
@return {string|false} Absolute path | [
"Transform",
"a",
"relative",
"path",
"into",
"an",
"absolute",
"url",
"."
] | 4506cfade27e420e51774978b9761f089d47965a | https://github.com/Bartozzz/get-link/blob/4506cfade27e420e51774978b9761f089d47965a/dist/index.js#L88-L118 | train |
benignware-legacy/broccoli-mincer | index.js | gzip | function gzip(data) {
var unit8Array = new Uint8Array(toBuffer(data));
return new Buffer(pako.gzip(unit8Array));
} | javascript | function gzip(data) {
var unit8Array = new Uint8Array(toBuffer(data));
return new Buffer(pako.gzip(unit8Array));
} | [
"function",
"gzip",
"(",
"data",
")",
"{",
"var",
"unit8Array",
"=",
"new",
"Uint8Array",
"(",
"toBuffer",
"(",
"data",
")",
")",
";",
"return",
"new",
"Buffer",
"(",
"pako",
".",
"gzip",
"(",
"unit8Array",
")",
")",
";",
"}"
] | Compress given String or Buffer | [
"Compress",
"given",
"String",
"or",
"Buffer"
] | fc8b59bb7b13c9bf419f3fe4e8c858a3ac90b2ea | https://github.com/benignware-legacy/broccoli-mincer/blob/fc8b59bb7b13c9bf419f3fe4e8c858a3ac90b2ea/index.js#L168-L171 | train |
MostlyJS/mostly-poplarjs | src/context.js | dynamic | function dynamic (val, toType, ctx) {
if (Array.isArray(val)) {
return _.map(val, function (v) {
return dynamic(v, toType, ctx);
});
}
return (new Dynamic(val, ctx)).to(toType);
} | javascript | function dynamic (val, toType, ctx) {
if (Array.isArray(val)) {
return _.map(val, function (v) {
return dynamic(v, toType, ctx);
});
}
return (new Dynamic(val, ctx)).to(toType);
} | [
"function",
"dynamic",
"(",
"val",
",",
"toType",
",",
"ctx",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"val",
")",
")",
"{",
"return",
"_",
".",
"map",
"(",
"val",
",",
"function",
"(",
"v",
")",
"{",
"return",
"dynamic",
"(",
"v",
",... | Use dynamic to coerce a value or array of values. | [
"Use",
"dynamic",
"to",
"coerce",
"a",
"value",
"or",
"array",
"of",
"values",
"."
] | bda12a72891e8c8d338e7560e7fe9e11ad74a2d9 | https://github.com/MostlyJS/mostly-poplarjs/blob/bda12a72891e8c8d338e7560e7fe9e11ad74a2d9/src/context.js#L194-L201 | train |
Holusion/node-xdg-apps | lib/MimeType.js | glob2regexp | function glob2regexp(glob, sensitive){
return new RegExp('^' + glob.replace(ESCAPE_REG_EXP, '\\$1').replace(/\*/g, '.*') + '$', sensitive ? '' : 'i')
} | javascript | function glob2regexp(glob, sensitive){
return new RegExp('^' + glob.replace(ESCAPE_REG_EXP, '\\$1').replace(/\*/g, '.*') + '$', sensitive ? '' : 'i')
} | [
"function",
"glob2regexp",
"(",
"glob",
",",
"sensitive",
")",
"{",
"return",
"new",
"RegExp",
"(",
"'^'",
"+",
"glob",
".",
"replace",
"(",
"ESCAPE_REG_EXP",
",",
"'\\\\$1'",
")",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"'.*'",
")",
"+",
"'$... | CHeck it's not bracketed | [
"CHeck",
"it",
"s",
"not",
"bracketed"
] | 875c9614c6359cbbc22c986acd88ed3d387aea66 | https://github.com/Holusion/node-xdg-apps/blob/875c9614c6359cbbc22c986acd88ed3d387aea66/lib/MimeType.js#L11-L13 | train |
halfblood369/monitor | lib/systemMonitor.js | getSysInfo | function getSysInfo(callback) {
if (process.platform === 'windows') return;
var reData = getBasicInfo();
exec('iostat ', function(err, output) {
if (!!err) {
console.error('getSysInfo failed! ' + err.stack);
} else {
reData.iostat = format(output);
}
callback(reData);
});
} | javascript | function getSysInfo(callback) {
if (process.platform === 'windows') return;
var reData = getBasicInfo();
exec('iostat ', function(err, output) {
if (!!err) {
console.error('getSysInfo failed! ' + err.stack);
} else {
reData.iostat = format(output);
}
callback(reData);
});
} | [
"function",
"getSysInfo",
"(",
"callback",
")",
"{",
"if",
"(",
"process",
".",
"platform",
"===",
"'windows'",
")",
"return",
";",
"var",
"reData",
"=",
"getBasicInfo",
"(",
")",
";",
"exec",
"(",
"'iostat '",
",",
"function",
"(",
"err",
",",
"output",... | get information of operating-system
@param {Function} callback
@api public | [
"get",
"information",
"of",
"operating",
"-",
"system"
] | 900b5cadf59edcccac4754e5706a22719925ddb9 | https://github.com/halfblood369/monitor/blob/900b5cadf59edcccac4754e5706a22719925ddb9/lib/systemMonitor.js#L24-L35 | train |
PeerioTechnologies/peerio-updater | signing.js | verify | function verify(publicKeys, sig, text) {
// Parse signature.
validateBase64(sig);
const binsig = Buffer.from(sig, 'base64');
// Check signature length.
if (binsig.length !== 10 + nacl.sign.signatureLength) {
throw new Error('Bad signature length');
}
// Check signature algorithm.
... | javascript | function verify(publicKeys, sig, text) {
// Parse signature.
validateBase64(sig);
const binsig = Buffer.from(sig, 'base64');
// Check signature length.
if (binsig.length !== 10 + nacl.sign.signatureLength) {
throw new Error('Bad signature length');
}
// Check signature algorithm.
... | [
"function",
"verify",
"(",
"publicKeys",
",",
"sig",
",",
"text",
")",
"{",
"// Parse signature.",
"validateBase64",
"(",
"sig",
")",
";",
"const",
"binsig",
"=",
"Buffer",
".",
"from",
"(",
"sig",
",",
"'base64'",
")",
";",
"// Check signature length.",
"if... | Verifies signature.
Throws if signature is invalid.
@param {Array<string>} publicKeys list of base64-encoded public key in signify format
@param {string} sig base64-encoded signature in signify format
@param {string} text message to verify | [
"Verifies",
"signature",
".",
"Throws",
"if",
"signature",
"is",
"invalid",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/signing.js#L24-L65 | train |
PeerioTechnologies/peerio-updater | signing.js | sign | function sign(secretKey, text) {
const sec = parseSecretKey(secretKey);
const bintext = Buffer.from(text, 'utf8');
const sig = nacl.sign.detached(bintext, sec.key);
// Full signature includes algorithm id ('Ed'), key number,
// and the signature itself.
const fullsig = new Uint8Array(2 + 8 + 64)... | javascript | function sign(secretKey, text) {
const sec = parseSecretKey(secretKey);
const bintext = Buffer.from(text, 'utf8');
const sig = nacl.sign.detached(bintext, sec.key);
// Full signature includes algorithm id ('Ed'), key number,
// and the signature itself.
const fullsig = new Uint8Array(2 + 8 + 64)... | [
"function",
"sign",
"(",
"secretKey",
",",
"text",
")",
"{",
"const",
"sec",
"=",
"parseSecretKey",
"(",
"secretKey",
")",
";",
"const",
"bintext",
"=",
"Buffer",
".",
"from",
"(",
"text",
",",
"'utf8'",
")",
";",
"const",
"sig",
"=",
"nacl",
".",
"s... | Signs text with the given secret key, returning signature.
Note that secret key is stored in the same format as signify,
but requires rounds = 0, so it is unencrypted.
Secret key format:
2 bytes - signature algorithm
2 bytes - kdf algorithm ('B', 'K')
4 bytes - kdf rounds (00 00 00 00)
16 bytes - salt (any bytes, ig... | [
"Signs",
"text",
"with",
"the",
"given",
"secret",
"key",
"returning",
"signature",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/signing.js#L87-L99 | train |
PeerioTechnologies/peerio-updater | signing.js | parseSecretKey | function parseSecretKey(secretKey) {
const k = Buffer.from(secretKey, 'base64');
if (k.length < 2 + 2 + 4 + 16 + 8 + 8 + 64) {
throw new Error('Incorrect secret key length');
}
// Check signature algorithm.
if (k[0] !== 69 /* 'E' */ || k[1] !== 100 /* 'd' */) {
throw new Error('Unk... | javascript | function parseSecretKey(secretKey) {
const k = Buffer.from(secretKey, 'base64');
if (k.length < 2 + 2 + 4 + 16 + 8 + 8 + 64) {
throw new Error('Incorrect secret key length');
}
// Check signature algorithm.
if (k[0] !== 69 /* 'E' */ || k[1] !== 100 /* 'd' */) {
throw new Error('Unk... | [
"function",
"parseSecretKey",
"(",
"secretKey",
")",
"{",
"const",
"k",
"=",
"Buffer",
".",
"from",
"(",
"secretKey",
",",
"'base64'",
")",
";",
"if",
"(",
"k",
".",
"length",
"<",
"2",
"+",
"2",
"+",
"4",
"+",
"16",
"+",
"8",
"+",
"8",
"+",
"6... | Converts secretKey from base64-encoded representation
into a Uint8Array acceptable for nacl.sign.
Returns an object with key num and secret key.
{
num: Uint8Array
key: Uint8Array
}
Throws if key format is incorrect.
@param {string} secretKey
@returns {Object} object { num, key } | [
"Converts",
"secretKey",
"from",
"base64",
"-",
"encoded",
"representation",
"into",
"a",
"Uint8Array",
"acceptable",
"for",
"nacl",
".",
"sign",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/signing.js#L117-L153 | train |
ergo-cms/ergo-core | api/plugin.js | _normaliseExt | function _normaliseExt(ext) { // we don't use '.' in our extension info... but some might leak in here and there
ext = (ext||'').trim();
if (ext.length && ext[0]=='.')
return ext.substr(1);
return ext;
} | javascript | function _normaliseExt(ext) { // we don't use '.' in our extension info... but some might leak in here and there
ext = (ext||'').trim();
if (ext.length && ext[0]=='.')
return ext.substr(1);
return ext;
} | [
"function",
"_normaliseExt",
"(",
"ext",
")",
"{",
"// we don't use '.' in our extension info... but some might leak in here and there",
"ext",
"=",
"(",
"ext",
"||",
"''",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"ext",
".",
"length",
"&&",
"ext",
"[",
"0",
... | l.color = l._colors.Dim+l._colors.FgRed; | [
"l",
".",
"color",
"=",
"l",
".",
"_colors",
".",
"Dim",
"+",
"l",
".",
"_colors",
".",
"FgRed",
";"
] | 8ed4d087554b5f8cd93f0765719ecee14164ca71 | https://github.com/ergo-cms/ergo-core/blob/8ed4d087554b5f8cd93f0765719ecee14164ca71/api/plugin.js#L24-L29 | train |
origin1tech/pargv | build/index.js | normalize | function normalize(def) {
if (~noMergeCmds.indexOf(command))
return stiks.argv.splitArgs(def);
return stiks.argv.mergeArgs(def, input);
} | javascript | function normalize(def) {
if (~noMergeCmds.indexOf(command))
return stiks.argv.splitArgs(def);
return stiks.argv.mergeArgs(def, input);
} | [
"function",
"normalize",
"(",
"def",
")",
"{",
"if",
"(",
"~",
"noMergeCmds",
".",
"indexOf",
"(",
"command",
")",
")",
"return",
"stiks",
".",
"argv",
".",
"splitArgs",
"(",
"def",
")",
";",
"return",
"stiks",
".",
"argv",
".",
"mergeArgs",
"(",
"de... | Merges default args with any input args. | [
"Merges",
"default",
"args",
"with",
"any",
"input",
"args",
"."
] | 3dfe91190b843e9b0d84f9a65bcd45a86617cc05 | https://github.com/origin1tech/pargv/blob/3dfe91190b843e9b0d84f9a65bcd45a86617cc05/build/index.js#L27-L31 | train |
jasonsites/proxy-es-aws | src/aws.js | createSignedAWSRequest | function createSignedAWSRequest(params) {
const { body, credentials, endpoint, headers, method = 'GET', path, region } = params
const request = new AWS.HttpRequest(endpoint)
Object.assign(request, {
body,
headers: {
Host: endpoint.host,
'presigned-expires': false,
},
method,
path,... | javascript | function createSignedAWSRequest(params) {
const { body, credentials, endpoint, headers, method = 'GET', path, region } = params
const request = new AWS.HttpRequest(endpoint)
Object.assign(request, {
body,
headers: {
Host: endpoint.host,
'presigned-expires': false,
},
method,
path,... | [
"function",
"createSignedAWSRequest",
"(",
"params",
")",
"{",
"const",
"{",
"body",
",",
"credentials",
",",
"endpoint",
",",
"headers",
",",
"method",
"=",
"'GET'",
",",
"path",
",",
"region",
"}",
"=",
"params",
"const",
"request",
"=",
"new",
"AWS",
... | Compose the request data to be sent to the AWS Node HTTP Client
@param {String} params.body - raw client request body
@param {Object} params.credentials - aws credentials
@param {String} params.endpoint - aws elasticsearch endpoint
@param {Object} params.headers - client request headers
@param {String} pa... | [
"Compose",
"the",
"request",
"data",
"to",
"be",
"sent",
"to",
"the",
"AWS",
"Node",
"HTTP",
"Client"
] | b2625106d877fea76f74b0b88ed8568a8ff61612 | https://github.com/jasonsites/proxy-es-aws/blob/b2625106d877fea76f74b0b88ed8568a8ff61612/src/aws.js#L22-L39 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.