id
int32 0
58k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
45,500 | henrytseng/angular-state-view | src/services/view-manager.js | function(callback) {
// Activate current
var current = $state.current();
if(current) {
// Reset
_resetActive().then(function() {
// Render
var viewsPromised = {};
var templates = current.templates || {};
var controllers = current.controllers || {};
angular.forEach(templates, function(template, id) {
if(_viewHash[id]) {
var view = _viewHash[id];
var controller = controllers[id];
viewsPromised[id] = _renderView(id, view, template, controller);
_activeSet[id] = view;
}
});
$q.all(viewsPromised).then(function() {
callback();
}, callback);
}, callback);
// None
} else {
callback();
}
} | javascript | function(callback) {
// Activate current
var current = $state.current();
if(current) {
// Reset
_resetActive().then(function() {
// Render
var viewsPromised = {};
var templates = current.templates || {};
var controllers = current.controllers || {};
angular.forEach(templates, function(template, id) {
if(_viewHash[id]) {
var view = _viewHash[id];
var controller = controllers[id];
viewsPromised[id] = _renderView(id, view, template, controller);
_activeSet[id] = view;
}
});
$q.all(viewsPromised).then(function() {
callback();
}, callback);
}, callback);
// None
} else {
callback();
}
} | [
"function",
"(",
"callback",
")",
"{",
"// Activate current",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
";",
"if",
"(",
"current",
")",
"{",
"// Reset",
"_resetActive",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// Render",
"var",
"viewsPromised",
"=",
"{",
"}",
";",
"var",
"templates",
"=",
"current",
".",
"templates",
"||",
"{",
"}",
";",
"var",
"controllers",
"=",
"current",
".",
"controllers",
"||",
"{",
"}",
";",
"angular",
".",
"forEach",
"(",
"templates",
",",
"function",
"(",
"template",
",",
"id",
")",
"{",
"if",
"(",
"_viewHash",
"[",
"id",
"]",
")",
"{",
"var",
"view",
"=",
"_viewHash",
"[",
"id",
"]",
";",
"var",
"controller",
"=",
"controllers",
"[",
"id",
"]",
";",
"viewsPromised",
"[",
"id",
"]",
"=",
"_renderView",
"(",
"id",
",",
"view",
",",
"template",
",",
"controller",
")",
";",
"_activeSet",
"[",
"id",
"]",
"=",
"view",
";",
"}",
"}",
")",
";",
"$q",
".",
"all",
"(",
"viewsPromised",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"callback",
"(",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
",",
"callback",
")",
";",
"// None",
"}",
"else",
"{",
"callback",
"(",
")",
";",
"}",
"}"
]
| Update rendered views
@param {Function} callback A completion callback, function(err) | [
"Update",
"rendered",
"views"
]
| cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L72-L104 |
|
45,501 | henrytseng/angular-state-view | src/services/view-manager.js | function(id, view) {
// No id
if(!id) {
throw new Error('View requires an id.');
// Require unique id
} else if(_viewHash[id]) {
throw new Error('View requires a unique id');
// Add
} else {
_viewHash[id] = view;
}
// Check if view is currently active
var current = $state.current() || {};
var templates = current.templates || {};
var controllers = current.controllers || {};
if(!!templates[id]) {
_renderView(id, view, templates[id], controllers[id]);
}
// Implement destroy method
view.destroy = function() {
_unregister(id);
};
return view;
} | javascript | function(id, view) {
// No id
if(!id) {
throw new Error('View requires an id.');
// Require unique id
} else if(_viewHash[id]) {
throw new Error('View requires a unique id');
// Add
} else {
_viewHash[id] = view;
}
// Check if view is currently active
var current = $state.current() || {};
var templates = current.templates || {};
var controllers = current.controllers || {};
if(!!templates[id]) {
_renderView(id, view, templates[id], controllers[id]);
}
// Implement destroy method
view.destroy = function() {
_unregister(id);
};
return view;
} | [
"function",
"(",
"id",
",",
"view",
")",
"{",
"// No id",
"if",
"(",
"!",
"id",
")",
"{",
"throw",
"new",
"Error",
"(",
"'View requires an id.'",
")",
";",
"// Require unique id",
"}",
"else",
"if",
"(",
"_viewHash",
"[",
"id",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"'View requires a unique id'",
")",
";",
"// Add",
"}",
"else",
"{",
"_viewHash",
"[",
"id",
"]",
"=",
"view",
";",
"}",
"// Check if view is currently active",
"var",
"current",
"=",
"$state",
".",
"current",
"(",
")",
"||",
"{",
"}",
";",
"var",
"templates",
"=",
"current",
".",
"templates",
"||",
"{",
"}",
";",
"var",
"controllers",
"=",
"current",
".",
"controllers",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"!",
"templates",
"[",
"id",
"]",
")",
"{",
"_renderView",
"(",
"id",
",",
"view",
",",
"templates",
"[",
"id",
"]",
",",
"controllers",
"[",
"id",
"]",
")",
";",
"}",
"// Implement destroy method",
"view",
".",
"destroy",
"=",
"function",
"(",
")",
"{",
"_unregister",
"(",
"id",
")",
";",
"}",
";",
"return",
"view",
";",
"}"
]
| Register a view, also implements destroy method on view to unregister from manager
@param {String} id Unique identifier for view
@param {View} view A view instance
@return {$viewManager} Itself, chainable | [
"Register",
"a",
"view",
"also",
"implements",
"destroy",
"method",
"on",
"view",
"to",
"unregister",
"from",
"manager"
]
| cf27c3a5cf65289501957e4dce3b75e7abef4def | https://github.com/henrytseng/angular-state-view/blob/cf27c3a5cf65289501957e4dce3b75e7abef4def/src/services/view-manager.js#L124-L152 |
|
45,502 | synder/xpress | demo/body-parser/lib/read.js | read | function read (req, res, next, parse, debug, options) {
var length
var opts = options || {}
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding || 'utf-8'
: null
var verify = opts.verify
try {
// get the content stream
stream = contentstream(req, debug, opts.inflate)
length = stream.length
stream.length = undefined
} catch (err) {
return next(err)
}
// set raw-body options
opts.length = length
opts.encoding = verify
? null
: encoding
// assert charset is supported
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
charset: encoding.toLowerCase()
}))
}
// read body
debug('read body')
getBody(stream, opts, function (err, body) {
if (err) {
// default to 400
setErrorStatus(err, 400)
// echo back charset
if (err.type === 'encoding.unsupported') {
err = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
charset: encoding.toLowerCase()
})
}
// read off entire request
stream.resume()
onFinished(req, function onfinished () {
next(err)
})
return
}
// verify
if (verify) {
try {
debug('verify body')
verify(req, res, body, encoding)
} catch (err) {
// default to 403
setErrorStatus(err, 403)
next(err)
return
}
}
// parse
var str
try {
debug('parse body')
str = typeof body !== 'string' && encoding !== null
? iconv.decode(body, encoding)
: body
req.body = parse(str)
} catch (err) {
err.body = str === undefined
? body
: str
// default to 400
setErrorStatus(err, 400)
next(err)
return
}
next()
})
} | javascript | function read (req, res, next, parse, debug, options) {
var length
var opts = options || {}
var stream
// flag as parsed
req._body = true
// read options
var encoding = opts.encoding !== null
? opts.encoding || 'utf-8'
: null
var verify = opts.verify
try {
// get the content stream
stream = contentstream(req, debug, opts.inflate)
length = stream.length
stream.length = undefined
} catch (err) {
return next(err)
}
// set raw-body options
opts.length = length
opts.encoding = verify
? null
: encoding
// assert charset is supported
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
charset: encoding.toLowerCase()
}))
}
// read body
debug('read body')
getBody(stream, opts, function (err, body) {
if (err) {
// default to 400
setErrorStatus(err, 400)
// echo back charset
if (err.type === 'encoding.unsupported') {
err = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
charset: encoding.toLowerCase()
})
}
// read off entire request
stream.resume()
onFinished(req, function onfinished () {
next(err)
})
return
}
// verify
if (verify) {
try {
debug('verify body')
verify(req, res, body, encoding)
} catch (err) {
// default to 403
setErrorStatus(err, 403)
next(err)
return
}
}
// parse
var str
try {
debug('parse body')
str = typeof body !== 'string' && encoding !== null
? iconv.decode(body, encoding)
: body
req.body = parse(str)
} catch (err) {
err.body = str === undefined
? body
: str
// default to 400
setErrorStatus(err, 400)
next(err)
return
}
next()
})
} | [
"function",
"read",
"(",
"req",
",",
"res",
",",
"next",
",",
"parse",
",",
"debug",
",",
"options",
")",
"{",
"var",
"length",
"var",
"opts",
"=",
"options",
"||",
"{",
"}",
"var",
"stream",
"// flag as parsed",
"req",
".",
"_body",
"=",
"true",
"// read options",
"var",
"encoding",
"=",
"opts",
".",
"encoding",
"!==",
"null",
"?",
"opts",
".",
"encoding",
"||",
"'utf-8'",
":",
"null",
"var",
"verify",
"=",
"opts",
".",
"verify",
"try",
"{",
"// get the content stream",
"stream",
"=",
"contentstream",
"(",
"req",
",",
"debug",
",",
"opts",
".",
"inflate",
")",
"length",
"=",
"stream",
".",
"length",
"stream",
".",
"length",
"=",
"undefined",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"next",
"(",
"err",
")",
"}",
"// set raw-body options",
"opts",
".",
"length",
"=",
"length",
"opts",
".",
"encoding",
"=",
"verify",
"?",
"null",
":",
"encoding",
"// assert charset is supported",
"if",
"(",
"opts",
".",
"encoding",
"===",
"null",
"&&",
"encoding",
"!==",
"null",
"&&",
"!",
"iconv",
".",
"encodingExists",
"(",
"encoding",
")",
")",
"{",
"return",
"next",
"(",
"createError",
"(",
"415",
",",
"'unsupported charset \"'",
"+",
"encoding",
".",
"toUpperCase",
"(",
")",
"+",
"'\"'",
",",
"{",
"charset",
":",
"encoding",
".",
"toLowerCase",
"(",
")",
"}",
")",
")",
"}",
"// read body",
"debug",
"(",
"'read body'",
")",
"getBody",
"(",
"stream",
",",
"opts",
",",
"function",
"(",
"err",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"// default to 400",
"setErrorStatus",
"(",
"err",
",",
"400",
")",
"// echo back charset",
"if",
"(",
"err",
".",
"type",
"===",
"'encoding.unsupported'",
")",
"{",
"err",
"=",
"createError",
"(",
"415",
",",
"'unsupported charset \"'",
"+",
"encoding",
".",
"toUpperCase",
"(",
")",
"+",
"'\"'",
",",
"{",
"charset",
":",
"encoding",
".",
"toLowerCase",
"(",
")",
"}",
")",
"}",
"// read off entire request",
"stream",
".",
"resume",
"(",
")",
"onFinished",
"(",
"req",
",",
"function",
"onfinished",
"(",
")",
"{",
"next",
"(",
"err",
")",
"}",
")",
"return",
"}",
"// verify",
"if",
"(",
"verify",
")",
"{",
"try",
"{",
"debug",
"(",
"'verify body'",
")",
"verify",
"(",
"req",
",",
"res",
",",
"body",
",",
"encoding",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"// default to 403",
"setErrorStatus",
"(",
"err",
",",
"403",
")",
"next",
"(",
"err",
")",
"return",
"}",
"}",
"// parse",
"var",
"str",
"try",
"{",
"debug",
"(",
"'parse body'",
")",
"str",
"=",
"typeof",
"body",
"!==",
"'string'",
"&&",
"encoding",
"!==",
"null",
"?",
"iconv",
".",
"decode",
"(",
"body",
",",
"encoding",
")",
":",
"body",
"req",
".",
"body",
"=",
"parse",
"(",
"str",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"err",
".",
"body",
"=",
"str",
"===",
"undefined",
"?",
"body",
":",
"str",
"// default to 400",
"setErrorStatus",
"(",
"err",
",",
"400",
")",
"next",
"(",
"err",
")",
"return",
"}",
"next",
"(",
")",
"}",
")",
"}"
]
| Read a request into a buffer and parse.
@param {object} req
@param {object} res
@param {function} next
@param {function} parse
@param {function} debug
@param {object} [options]
@api private | [
"Read",
"a",
"request",
"into",
"a",
"buffer",
"and",
"parse",
"."
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L38-L131 |
45,503 | synder/xpress | demo/body-parser/lib/read.js | contentstream | function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
var stream
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content encoding unsupported')
}
switch (encoding) {
case 'deflate':
stream = zlib.createInflate()
debug('inflate body')
req.pipe(stream)
break
case 'gzip':
stream = zlib.createGunzip()
debug('gunzip body')
req.pipe(stream)
break
case 'identity':
stream = req
stream.length = length
break
default:
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
encoding: encoding
})
}
return stream
} | javascript | function contentstream (req, debug, inflate) {
var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
var length = req.headers['content-length']
var stream
debug('content-encoding "%s"', encoding)
if (inflate === false && encoding !== 'identity') {
throw createError(415, 'content encoding unsupported')
}
switch (encoding) {
case 'deflate':
stream = zlib.createInflate()
debug('inflate body')
req.pipe(stream)
break
case 'gzip':
stream = zlib.createGunzip()
debug('gunzip body')
req.pipe(stream)
break
case 'identity':
stream = req
stream.length = length
break
default:
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
encoding: encoding
})
}
return stream
} | [
"function",
"contentstream",
"(",
"req",
",",
"debug",
",",
"inflate",
")",
"{",
"var",
"encoding",
"=",
"(",
"req",
".",
"headers",
"[",
"'content-encoding'",
"]",
"||",
"'identity'",
")",
".",
"toLowerCase",
"(",
")",
"var",
"length",
"=",
"req",
".",
"headers",
"[",
"'content-length'",
"]",
"var",
"stream",
"debug",
"(",
"'content-encoding \"%s\"'",
",",
"encoding",
")",
"if",
"(",
"inflate",
"===",
"false",
"&&",
"encoding",
"!==",
"'identity'",
")",
"{",
"throw",
"createError",
"(",
"415",
",",
"'content encoding unsupported'",
")",
"}",
"switch",
"(",
"encoding",
")",
"{",
"case",
"'deflate'",
":",
"stream",
"=",
"zlib",
".",
"createInflate",
"(",
")",
"debug",
"(",
"'inflate body'",
")",
"req",
".",
"pipe",
"(",
"stream",
")",
"break",
"case",
"'gzip'",
":",
"stream",
"=",
"zlib",
".",
"createGunzip",
"(",
")",
"debug",
"(",
"'gunzip body'",
")",
"req",
".",
"pipe",
"(",
"stream",
")",
"break",
"case",
"'identity'",
":",
"stream",
"=",
"req",
"stream",
".",
"length",
"=",
"length",
"break",
"default",
":",
"throw",
"createError",
"(",
"415",
",",
"'unsupported content encoding \"'",
"+",
"encoding",
"+",
"'\"'",
",",
"{",
"encoding",
":",
"encoding",
"}",
")",
"}",
"return",
"stream",
"}"
]
| Get the content stream of the request.
@param {object} req
@param {function} debug
@param {boolean} [inflate=true]
@return {object}
@api private | [
"Get",
"the",
"content",
"stream",
"of",
"the",
"request",
"."
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L143-L176 |
45,504 | synder/xpress | demo/body-parser/lib/read.js | setErrorStatus | function setErrorStatus (error, status) {
if (!error.status && !error.statusCode) {
error.status = status
error.statusCode = status
}
} | javascript | function setErrorStatus (error, status) {
if (!error.status && !error.statusCode) {
error.status = status
error.statusCode = status
}
} | [
"function",
"setErrorStatus",
"(",
"error",
",",
"status",
")",
"{",
"if",
"(",
"!",
"error",
".",
"status",
"&&",
"!",
"error",
".",
"statusCode",
")",
"{",
"error",
".",
"status",
"=",
"status",
"error",
".",
"statusCode",
"=",
"status",
"}",
"}"
]
| Set a status on an error object, if ones does not exist
@private | [
"Set",
"a",
"status",
"on",
"an",
"error",
"object",
"if",
"ones",
"does",
"not",
"exist"
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/body-parser/lib/read.js#L183-L188 |
45,505 | jonschlinkert/file-contents | utils.js | syncContents | function syncContents(file, val) {
switch (utils.typeOf(val)) {
case 'buffer':
file._contents = val;
file._content = val.toString();
break;
case 'string':
file._contents = new Buffer(val);
file._content = val;
break;
case 'stream':
file._contents = val;
file._content = val;
break;
case 'undefined':
case 'null':
default: {
file._contents = null;
file._content = null;
break;
}
}
} | javascript | function syncContents(file, val) {
switch (utils.typeOf(val)) {
case 'buffer':
file._contents = val;
file._content = val.toString();
break;
case 'string':
file._contents = new Buffer(val);
file._content = val;
break;
case 'stream':
file._contents = val;
file._content = val;
break;
case 'undefined':
case 'null':
default: {
file._contents = null;
file._content = null;
break;
}
}
} | [
"function",
"syncContents",
"(",
"file",
",",
"val",
")",
"{",
"switch",
"(",
"utils",
".",
"typeOf",
"(",
"val",
")",
")",
"{",
"case",
"'buffer'",
":",
"file",
".",
"_contents",
"=",
"val",
";",
"file",
".",
"_content",
"=",
"val",
".",
"toString",
"(",
")",
";",
"break",
";",
"case",
"'string'",
":",
"file",
".",
"_contents",
"=",
"new",
"Buffer",
"(",
"val",
")",
";",
"file",
".",
"_content",
"=",
"val",
";",
"break",
";",
"case",
"'stream'",
":",
"file",
".",
"_contents",
"=",
"val",
";",
"file",
".",
"_content",
"=",
"val",
";",
"break",
";",
"case",
"'undefined'",
":",
"case",
"'null'",
":",
"default",
":",
"{",
"file",
".",
"_contents",
"=",
"null",
";",
"file",
".",
"_content",
"=",
"null",
";",
"break",
";",
"}",
"}",
"}"
]
| Sync the _content and _contents properties on a view to ensure
both are set when setting either.
@param {Object} `view` instance of a `View`
@param {String|Buffer|Stream|null} `contents` contents to set on both properties | [
"Sync",
"the",
"_content",
"and",
"_contents",
"properties",
"on",
"a",
"view",
"to",
"ensure",
"both",
"are",
"set",
"when",
"setting",
"either",
"."
]
| a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa | https://github.com/jonschlinkert/file-contents/blob/a53dcc62a1a529fc5f8b1dc0fa2a76a3196236fa/utils.js#L121-L143 |
45,506 | mchalapuk/hyper-text-slider | lib/utils/elements.spec-helper.js | createElement | function createElement(nodeName) {
var elem = document.createElement(nodeName);
elem.className = [].join.call(arguments, ' ');
return elem;
} | javascript | function createElement(nodeName) {
var elem = document.createElement(nodeName);
elem.className = [].join.call(arguments, ' ');
return elem;
} | [
"function",
"createElement",
"(",
"nodeName",
")",
"{",
"var",
"elem",
"=",
"document",
".",
"createElement",
"(",
"nodeName",
")",
";",
"elem",
".",
"className",
"=",
"[",
"]",
".",
"join",
".",
"call",
"(",
"arguments",
",",
"' '",
")",
";",
"return",
"elem",
";",
"}"
]
| Creates element with given nodeName and className. | [
"Creates",
"element",
"with",
"given",
"nodeName",
"and",
"className",
"."
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/utils/elements.spec-helper.js#L25-L29 |
45,507 | mchalapuk/hyper-text-slider | lib/utils/elements.spec-helper.js | createSliderElement | function createSliderElement(slidesCount) {
var sliderElement = createElement('div', Layout.SLIDER);
for (var i = 0; i < slidesCount; ++i) {
sliderElement.appendChild(createElement('div', Layout.SLIDE));
}
return sliderElement;
} | javascript | function createSliderElement(slidesCount) {
var sliderElement = createElement('div', Layout.SLIDER);
for (var i = 0; i < slidesCount; ++i) {
sliderElement.appendChild(createElement('div', Layout.SLIDE));
}
return sliderElement;
} | [
"function",
"createSliderElement",
"(",
"slidesCount",
")",
"{",
"var",
"sliderElement",
"=",
"createElement",
"(",
"'div'",
",",
"Layout",
".",
"SLIDER",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"slidesCount",
";",
"++",
"i",
")",
"{",
"sliderElement",
".",
"appendChild",
"(",
"createElement",
"(",
"'div'",
",",
"Layout",
".",
"SLIDE",
")",
")",
";",
"}",
"return",
"sliderElement",
";",
"}"
]
| Creates valid slider element containing slides of given count. | [
"Creates",
"valid",
"slider",
"element",
"containing",
"slides",
"of",
"given",
"count",
"."
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/utils/elements.spec-helper.js#L34-L40 |
45,508 | abarth500/density-clustering-kdtree-doping | OPTICS-KDTREE.js | OPTICS | function OPTICS(dataset, epsilon, minPts, distanceFunction) {
this.tree = null;
/** @type {number} */
this.epsilon = 1;
/** @type {number} */
this.minPts = 1;
/** @type {function} */
this.distance = this._euclideanDistance;
// temporary variables used during computation
/** @type {Array} */
this._reachability = [];
/** @type {Array} */
this._processed = [];
/** @type {number} */
this._coreDistance = 0;
/** @type {Array} */
this._orderedList = [];
this._init(dataset, epsilon, minPts, distanceFunction);
} | javascript | function OPTICS(dataset, epsilon, minPts, distanceFunction) {
this.tree = null;
/** @type {number} */
this.epsilon = 1;
/** @type {number} */
this.minPts = 1;
/** @type {function} */
this.distance = this._euclideanDistance;
// temporary variables used during computation
/** @type {Array} */
this._reachability = [];
/** @type {Array} */
this._processed = [];
/** @type {number} */
this._coreDistance = 0;
/** @type {Array} */
this._orderedList = [];
this._init(dataset, epsilon, minPts, distanceFunction);
} | [
"function",
"OPTICS",
"(",
"dataset",
",",
"epsilon",
",",
"minPts",
",",
"distanceFunction",
")",
"{",
"this",
".",
"tree",
"=",
"null",
";",
"/** @type {number} */",
"this",
".",
"epsilon",
"=",
"1",
";",
"/** @type {number} */",
"this",
".",
"minPts",
"=",
"1",
";",
"/** @type {function} */",
"this",
".",
"distance",
"=",
"this",
".",
"_euclideanDistance",
";",
"// temporary variables used during computation",
"/** @type {Array} */",
"this",
".",
"_reachability",
"=",
"[",
"]",
";",
"/** @type {Array} */",
"this",
".",
"_processed",
"=",
"[",
"]",
";",
"/** @type {number} */",
"this",
".",
"_coreDistance",
"=",
"0",
";",
"/** @type {Array} */",
"this",
".",
"_orderedList",
"=",
"[",
"]",
";",
"this",
".",
"_init",
"(",
"dataset",
",",
"epsilon",
",",
"minPts",
",",
"distanceFunction",
")",
";",
"}"
]
| OPTICS - Ordering points to identify the clustering structure
@author Lukasz Krawczyk <[email protected]>
@copyright MIT
OPTICS class constructor
@constructor
@param {Array} dataset
@param {number} epsilon
@param {number} minPts
@param {function} distanceFunction
@returns {OPTICS} | [
"OPTICS",
"-",
"Ordering",
"points",
"to",
"identify",
"the",
"clustering",
"structure"
]
| 48cfdd75a1f71a65738e5ae016488109109bf308 | https://github.com/abarth500/density-clustering-kdtree-doping/blob/48cfdd75a1f71a65738e5ae016488109109bf308/OPTICS-KDTREE.js#L21-L42 |
45,509 | abramz/gulp-render-react | lib/render-react.js | createElement | function createElement(filePath, props) {
if (!filePath || typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a string');
}
// clear the require cache if we have already imported the file (if we are watching it)
if (require.cache[filePath]) {
delete require.cache[filePath];
}
var component = require(filePath); // eslint-disable-line global-require, import/no-dynamic-require
var element = _react2.default.createElement(component.default || component, props || {});
return element;
} | javascript | function createElement(filePath, props) {
if (!filePath || typeof filePath !== 'string' || filePath.length === 0) {
throw new Error('Expected filePath to be a string');
}
// clear the require cache if we have already imported the file (if we are watching it)
if (require.cache[filePath]) {
delete require.cache[filePath];
}
var component = require(filePath); // eslint-disable-line global-require, import/no-dynamic-require
var element = _react2.default.createElement(component.default || component, props || {});
return element;
} | [
"function",
"createElement",
"(",
"filePath",
",",
"props",
")",
"{",
"if",
"(",
"!",
"filePath",
"||",
"typeof",
"filePath",
"!==",
"'string'",
"||",
"filePath",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected filePath to be a string'",
")",
";",
"}",
"// clear the require cache if we have already imported the file (if we are watching it)",
"if",
"(",
"require",
".",
"cache",
"[",
"filePath",
"]",
")",
"{",
"delete",
"require",
".",
"cache",
"[",
"filePath",
"]",
";",
"}",
"var",
"component",
"=",
"require",
"(",
"filePath",
")",
";",
"// eslint-disable-line global-require, import/no-dynamic-require",
"var",
"element",
"=",
"_react2",
".",
"default",
".",
"createElement",
"(",
"component",
".",
"default",
"||",
"component",
",",
"props",
"||",
"{",
"}",
")",
";",
"return",
"element",
";",
"}"
]
| Requires a file containing a React component and create an instance of it
@param {String} filePath file path to the React component to render
@param {Object} props properties to apply to the element
@return {Element} the created React element
/*! Gulp Render React | MIT License | [
"Requires",
"a",
"file",
"containing",
"a",
"React",
"component",
"and",
"create",
"an",
"instance",
"of",
"it"
]
| eff4c10f0070837e704aa766b82221127ef315fd | https://github.com/abramz/gulp-render-react/blob/eff4c10f0070837e704aa766b82221127ef315fd/lib/render-react.js#L14-L28 |
45,510 | MatAtBread/nodent-transform | arboriculture.js | transformForIn | function transformForIn(node, path) {
var label = node.$label;
delete node.$label;
var idx = ident(generateSymbol("idx"));
var inArray = ident(generateSymbol("in"));
var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
inArray,node.right]).body;
var loop = parsePart("for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }", [node.left,
inArray,node.left.type === 'VariableDeclaration' ? node.left.declarations[0].id : node.left,
node.body]).body[0];
loop.$label = label;
for (var b = 0;b < path.length; b++) {
if (examine(path[b].parent).isBlockStatement) {
path[b].parent[path[b].field].splice(path[b].index, 0, declVars[0], declVars[1]);
break;
}
}
coerce(node, loop);
} | javascript | function transformForIn(node, path) {
var label = node.$label;
delete node.$label;
var idx = ident(generateSymbol("idx"));
var inArray = ident(generateSymbol("in"));
var declVars = parsePart("var $0,$1 = [];for ($0 in $2) $1.push($0)", [idx,
inArray,node.right]).body;
var loop = parsePart("for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }", [node.left,
inArray,node.left.type === 'VariableDeclaration' ? node.left.declarations[0].id : node.left,
node.body]).body[0];
loop.$label = label;
for (var b = 0;b < path.length; b++) {
if (examine(path[b].parent).isBlockStatement) {
path[b].parent[path[b].field].splice(path[b].index, 0, declVars[0], declVars[1]);
break;
}
}
coerce(node, loop);
} | [
"function",
"transformForIn",
"(",
"node",
",",
"path",
")",
"{",
"var",
"label",
"=",
"node",
".",
"$label",
";",
"delete",
"node",
".",
"$label",
";",
"var",
"idx",
"=",
"ident",
"(",
"generateSymbol",
"(",
"\"idx\"",
")",
")",
";",
"var",
"inArray",
"=",
"ident",
"(",
"generateSymbol",
"(",
"\"in\"",
")",
")",
";",
"var",
"declVars",
"=",
"parsePart",
"(",
"\"var $0,$1 = [];for ($0 in $2) $1.push($0)\"",
",",
"[",
"idx",
",",
"inArray",
",",
"node",
".",
"right",
"]",
")",
".",
"body",
";",
"var",
"loop",
"=",
"parsePart",
"(",
"\"for ($0; $1.length;){ $2 = $1.shift(); $:3 ; }\"",
",",
"[",
"node",
".",
"left",
",",
"inArray",
",",
"node",
".",
"left",
".",
"type",
"===",
"'VariableDeclaration'",
"?",
"node",
".",
"left",
".",
"declarations",
"[",
"0",
"]",
".",
"id",
":",
"node",
".",
"left",
",",
"node",
".",
"body",
"]",
")",
".",
"body",
"[",
"0",
"]",
";",
"loop",
".",
"$label",
"=",
"label",
";",
"for",
"(",
"var",
"b",
"=",
"0",
";",
"b",
"<",
"path",
".",
"length",
";",
"b",
"++",
")",
"{",
"if",
"(",
"examine",
"(",
"path",
"[",
"b",
"]",
".",
"parent",
")",
".",
"isBlockStatement",
")",
"{",
"path",
"[",
"b",
"]",
".",
"parent",
"[",
"path",
"[",
"b",
"]",
".",
"field",
"]",
".",
"splice",
"(",
"path",
"[",
"b",
"]",
".",
"index",
",",
"0",
",",
"declVars",
"[",
"0",
"]",
",",
"declVars",
"[",
"1",
"]",
")",
";",
"break",
";",
"}",
"}",
"coerce",
"(",
"node",
",",
"loop",
")",
";",
"}"
]
| Transform a for..in into it's iterative equivalent | [
"Transform",
"a",
"for",
"..",
"in",
"into",
"it",
"s",
"iterative",
"equivalent"
]
| 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1152-L1170 |
45,511 | MatAtBread/nodent-transform | arboriculture.js | iterizeForOf | function iterizeForOf(node, path) {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body]
};
}
var index, iterator, initIterator = parsePart("[$0[Symbol.iterator]()]", [node.right]).expr;
if (node.left.type === 'VariableDeclaration') {
if (node.left.kind === 'const')
node.left.kind = 'let';
if (node.left.kind === 'let') {
node.update = literal(null) ;
node.update.$EmptyExpression = true ;
}
index = node.left.declarations[0].id;
var decls = getDeclNames(node.left.declarations[0].id);
iterator = ident(generateSymbol("iterator_" + decls.join('_')));
node.left.declarations = decls.map(function (name) {
return {
type: "VariableDeclarator",
id: ident(name)
};
});
node.left.declarations.push({
type: "VariableDeclarator",
id: iterator,
init: initIterator
});
node.init = node.left;
} else {
index = node.left;
iterator = ident(generateSymbol("iterator_" + index.name));
var declaration = {
type: 'VariableDeclaration',
kind: 'var',
declarations: [{
type: "VariableDeclarator",
id: iterator,
init: initIterator
}]
};
node.init = declaration;
}
node.type = 'ForStatement';
node.test = parsePart("!($0[1] = $0[0].next()).done && (($1 = $0[1].value) || true)", [iterator,
index]).expr;
delete node.left;
delete node.right;
} | javascript | function iterizeForOf(node, path) {
if (node.body.type !== 'BlockStatement') {
node.body = {
type: 'BlockStatement',
body: [node.body]
};
}
var index, iterator, initIterator = parsePart("[$0[Symbol.iterator]()]", [node.right]).expr;
if (node.left.type === 'VariableDeclaration') {
if (node.left.kind === 'const')
node.left.kind = 'let';
if (node.left.kind === 'let') {
node.update = literal(null) ;
node.update.$EmptyExpression = true ;
}
index = node.left.declarations[0].id;
var decls = getDeclNames(node.left.declarations[0].id);
iterator = ident(generateSymbol("iterator_" + decls.join('_')));
node.left.declarations = decls.map(function (name) {
return {
type: "VariableDeclarator",
id: ident(name)
};
});
node.left.declarations.push({
type: "VariableDeclarator",
id: iterator,
init: initIterator
});
node.init = node.left;
} else {
index = node.left;
iterator = ident(generateSymbol("iterator_" + index.name));
var declaration = {
type: 'VariableDeclaration',
kind: 'var',
declarations: [{
type: "VariableDeclarator",
id: iterator,
init: initIterator
}]
};
node.init = declaration;
}
node.type = 'ForStatement';
node.test = parsePart("!($0[1] = $0[0].next()).done && (($1 = $0[1].value) || true)", [iterator,
index]).expr;
delete node.left;
delete node.right;
} | [
"function",
"iterizeForOf",
"(",
"node",
",",
"path",
")",
"{",
"if",
"(",
"node",
".",
"body",
".",
"type",
"!==",
"'BlockStatement'",
")",
"{",
"node",
".",
"body",
"=",
"{",
"type",
":",
"'BlockStatement'",
",",
"body",
":",
"[",
"node",
".",
"body",
"]",
"}",
";",
"}",
"var",
"index",
",",
"iterator",
",",
"initIterator",
"=",
"parsePart",
"(",
"\"[$0[Symbol.iterator]()]\"",
",",
"[",
"node",
".",
"right",
"]",
")",
".",
"expr",
";",
"if",
"(",
"node",
".",
"left",
".",
"type",
"===",
"'VariableDeclaration'",
")",
"{",
"if",
"(",
"node",
".",
"left",
".",
"kind",
"===",
"'const'",
")",
"node",
".",
"left",
".",
"kind",
"=",
"'let'",
";",
"if",
"(",
"node",
".",
"left",
".",
"kind",
"===",
"'let'",
")",
"{",
"node",
".",
"update",
"=",
"literal",
"(",
"null",
")",
";",
"node",
".",
"update",
".",
"$EmptyExpression",
"=",
"true",
";",
"}",
"index",
"=",
"node",
".",
"left",
".",
"declarations",
"[",
"0",
"]",
".",
"id",
";",
"var",
"decls",
"=",
"getDeclNames",
"(",
"node",
".",
"left",
".",
"declarations",
"[",
"0",
"]",
".",
"id",
")",
";",
"iterator",
"=",
"ident",
"(",
"generateSymbol",
"(",
"\"iterator_\"",
"+",
"decls",
".",
"join",
"(",
"'_'",
")",
")",
")",
";",
"node",
".",
"left",
".",
"declarations",
"=",
"decls",
".",
"map",
"(",
"function",
"(",
"name",
")",
"{",
"return",
"{",
"type",
":",
"\"VariableDeclarator\"",
",",
"id",
":",
"ident",
"(",
"name",
")",
"}",
";",
"}",
")",
";",
"node",
".",
"left",
".",
"declarations",
".",
"push",
"(",
"{",
"type",
":",
"\"VariableDeclarator\"",
",",
"id",
":",
"iterator",
",",
"init",
":",
"initIterator",
"}",
")",
";",
"node",
".",
"init",
"=",
"node",
".",
"left",
";",
"}",
"else",
"{",
"index",
"=",
"node",
".",
"left",
";",
"iterator",
"=",
"ident",
"(",
"generateSymbol",
"(",
"\"iterator_\"",
"+",
"index",
".",
"name",
")",
")",
";",
"var",
"declaration",
"=",
"{",
"type",
":",
"'VariableDeclaration'",
",",
"kind",
":",
"'var'",
",",
"declarations",
":",
"[",
"{",
"type",
":",
"\"VariableDeclarator\"",
",",
"id",
":",
"iterator",
",",
"init",
":",
"initIterator",
"}",
"]",
"}",
";",
"node",
".",
"init",
"=",
"declaration",
";",
"}",
"node",
".",
"type",
"=",
"'ForStatement'",
";",
"node",
".",
"test",
"=",
"parsePart",
"(",
"\"!($0[1] = $0[0].next()).done && (($1 = $0[1].value) || true)\"",
",",
"[",
"iterator",
",",
"index",
"]",
")",
".",
"expr",
";",
"delete",
"node",
".",
"left",
";",
"delete",
"node",
".",
"right",
";",
"}"
]
| Transform a for..of into it's iterative equivalent | [
"Transform",
"a",
"for",
"..",
"of",
"into",
"it",
"s",
"iterative",
"equivalent"
]
| 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1173-L1222 |
45,512 | MatAtBread/nodent-transform | arboriculture.js | mappableLoop | function mappableLoop(n) {
return n.type === 'AwaitExpression' && !n.$hidden || inAsyncLoop && (n.type === 'BreakStatement' || n.type === 'ContinueStatement') && n.label;
} | javascript | function mappableLoop(n) {
return n.type === 'AwaitExpression' && !n.$hidden || inAsyncLoop && (n.type === 'BreakStatement' || n.type === 'ContinueStatement') && n.label;
} | [
"function",
"mappableLoop",
"(",
"n",
")",
"{",
"return",
"n",
".",
"type",
"===",
"'AwaitExpression'",
"&&",
"!",
"n",
".",
"$hidden",
"||",
"inAsyncLoop",
"&&",
"(",
"n",
".",
"type",
"===",
"'BreakStatement'",
"||",
"n",
".",
"type",
"===",
"'ContinueStatement'",
")",
"&&",
"n",
".",
"label",
";",
"}"
]
| Check if the loop contains an await, or a labelled exit if we're inside an async loop | [
"Check",
"if",
"the",
"loop",
"contains",
"an",
"await",
"or",
"a",
"labelled",
"exit",
"if",
"we",
"re",
"inside",
"an",
"async",
"loop"
]
| 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1238-L1240 |
45,513 | MatAtBread/nodent-transform | arboriculture.js | function (label) {
return {
type: 'ReturnStatement',
argument: {
type: 'UnaryExpression',
operator: 'void',
prefix: true,
argument: {
type: 'CallExpression',
callee: ident(label || symExit),
arguments: []
}
}
};
} | javascript | function (label) {
return {
type: 'ReturnStatement',
argument: {
type: 'UnaryExpression',
operator: 'void',
prefix: true,
argument: {
type: 'CallExpression',
callee: ident(label || symExit),
arguments: []
}
}
};
} | [
"function",
"(",
"label",
")",
"{",
"return",
"{",
"type",
":",
"'ReturnStatement'",
",",
"argument",
":",
"{",
"type",
":",
"'UnaryExpression'",
",",
"operator",
":",
"'void'",
",",
"prefix",
":",
"true",
",",
"argument",
":",
"{",
"type",
":",
"'CallExpression'",
",",
"callee",
":",
"ident",
"(",
"label",
"||",
"symExit",
")",
",",
"arguments",
":",
"[",
"]",
"}",
"}",
"}",
";",
"}"
]
| How to exit the loop | [
"How",
"to",
"exit",
"the",
"loop"
]
| 40d61ad20b0a87fb83d420fd98ba01adbff73cac | https://github.com/MatAtBread/nodent-transform/blob/40d61ad20b0a87fb83d420fd98ba01adbff73cac/arboriculture.js#L1544-L1558 |
|
45,514 | fknussel/custom-scripts | utils/index.js | checkRequiredFiles | function checkRequiredFiles() {
const indexHtmlExists = fse.existsSync(paths.indexHtml);
const indexJsExists = fse.existsSync(paths.indexJs);
if (!indexHtmlExists || !indexJsExists) {
logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
logError(`\t- ${paths.indexHtml}`);
logError(`\t- ${paths.indexJs}\n`);
process.exit(1);
}
} | javascript | function checkRequiredFiles() {
const indexHtmlExists = fse.existsSync(paths.indexHtml);
const indexJsExists = fse.existsSync(paths.indexJs);
if (!indexHtmlExists || !indexJsExists) {
logError('\nSome required files couldn\'t be found. Make sure these all exist:\n');
logError(`\t- ${paths.indexHtml}`);
logError(`\t- ${paths.indexJs}\n`);
process.exit(1);
}
} | [
"function",
"checkRequiredFiles",
"(",
")",
"{",
"const",
"indexHtmlExists",
"=",
"fse",
".",
"existsSync",
"(",
"paths",
".",
"indexHtml",
")",
";",
"const",
"indexJsExists",
"=",
"fse",
".",
"existsSync",
"(",
"paths",
".",
"indexJs",
")",
";",
"if",
"(",
"!",
"indexHtmlExists",
"||",
"!",
"indexJsExists",
")",
"{",
"logError",
"(",
"'\\nSome required files couldn\\'t be found. Make sure these all exist:\\n'",
")",
";",
"logError",
"(",
"`",
"\\t",
"${",
"paths",
".",
"indexHtml",
"}",
"`",
")",
";",
"logError",
"(",
"`",
"\\t",
"${",
"paths",
".",
"indexJs",
"}",
"\\n",
"`",
")",
";",
"process",
".",
"exit",
"(",
"1",
")",
";",
"}",
"}"
]
| Warn and crash if required files are missing. | [
"Warn",
"and",
"crash",
"if",
"required",
"files",
"are",
"missing",
"."
]
| 801ad6f42bcde265e317d427b7ee0f371eeb0e9b | https://github.com/fknussel/custom-scripts/blob/801ad6f42bcde265e317d427b7ee0f371eeb0e9b/utils/index.js#L41-L52 |
45,515 | fknussel/custom-scripts | utils/index.js | printErrors | function printErrors(summary, errors) {
logError(`${summary}\n`);
errors.forEach(err => {
logError(`\t- ${err.message || err}`);
});
console.log();
} | javascript | function printErrors(summary, errors) {
logError(`${summary}\n`);
errors.forEach(err => {
logError(`\t- ${err.message || err}`);
});
console.log();
} | [
"function",
"printErrors",
"(",
"summary",
",",
"errors",
")",
"{",
"logError",
"(",
"`",
"${",
"summary",
"}",
"\\n",
"`",
")",
";",
"errors",
".",
"forEach",
"(",
"err",
"=>",
"{",
"logError",
"(",
"`",
"\\t",
"${",
"err",
".",
"message",
"||",
"err",
"}",
"`",
")",
";",
"}",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}"
]
| Print out a list of errors to the terminal. | [
"Print",
"out",
"a",
"list",
"of",
"errors",
"to",
"the",
"terminal",
"."
]
| 801ad6f42bcde265e317d427b7ee0f371eeb0e9b | https://github.com/fknussel/custom-scripts/blob/801ad6f42bcde265e317d427b7ee0f371eeb0e9b/utils/index.js#L77-L85 |
45,516 | vid/SenseBase | lib/pubsub.js | changeAnnotationState | function changeAnnotationState(combo, username) {
combo.annotations.forEach(function(anno) {
anno.state = combo.state;
});
contentLib.indexContentItem({uri: combo.uri}, { member: username , annotations: combo.annotations} );
} | javascript | function changeAnnotationState(combo, username) {
combo.annotations.forEach(function(anno) {
anno.state = combo.state;
});
contentLib.indexContentItem({uri: combo.uri}, { member: username , annotations: combo.annotations} );
} | [
"function",
"changeAnnotationState",
"(",
"combo",
",",
"username",
")",
"{",
"combo",
".",
"annotations",
".",
"forEach",
"(",
"function",
"(",
"anno",
")",
"{",
"anno",
".",
"state",
"=",
"combo",
".",
"state",
";",
"}",
")",
";",
"contentLib",
".",
"indexContentItem",
"(",
"{",
"uri",
":",
"combo",
".",
"uri",
"}",
",",
"{",
"member",
":",
"username",
",",
"annotations",
":",
"combo",
".",
"annotations",
"}",
")",
";",
"}"
]
| Annotations functions FIXME change the state of annotations | [
"Annotations",
"functions",
"FIXME",
"change",
"the",
"state",
"of",
"annotations"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L320-L326 |
45,517 | vid/SenseBase | lib/pubsub.js | publishUpdate | function publishUpdate(combo) {
GLOBAL.svc.indexer.retrieveByURI(combo.uri, function(err, res) {
if (!err && res && res._source) {
res = res._source;
combo.selector = 'body';
combo.text = res.text;
combo.content = res.content;
fayeClient.publish('/item/annotations/annotate' + (combo.member ? '/' + combo.member.replace(/ /g, '_') : ''), combo);
debounceUpdate(combo);
} else {
GLOBAL.error('not annotated', err, combo);
}
});
} | javascript | function publishUpdate(combo) {
GLOBAL.svc.indexer.retrieveByURI(combo.uri, function(err, res) {
if (!err && res && res._source) {
res = res._source;
combo.selector = 'body';
combo.text = res.text;
combo.content = res.content;
fayeClient.publish('/item/annotations/annotate' + (combo.member ? '/' + combo.member.replace(/ /g, '_') : ''), combo);
debounceUpdate(combo);
} else {
GLOBAL.error('not annotated', err, combo);
}
});
} | [
"function",
"publishUpdate",
"(",
"combo",
")",
"{",
"GLOBAL",
".",
"svc",
".",
"indexer",
".",
"retrieveByURI",
"(",
"combo",
".",
"uri",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"res",
"&&",
"res",
".",
"_source",
")",
"{",
"res",
"=",
"res",
".",
"_source",
";",
"combo",
".",
"selector",
"=",
"'body'",
";",
"combo",
".",
"text",
"=",
"res",
".",
"text",
";",
"combo",
".",
"content",
"=",
"res",
".",
"content",
";",
"fayeClient",
".",
"publish",
"(",
"'/item/annotations/annotate'",
"+",
"(",
"combo",
".",
"member",
"?",
"'/'",
"+",
"combo",
".",
"member",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"'_'",
")",
":",
"''",
")",
",",
"combo",
")",
";",
"debounceUpdate",
"(",
"combo",
")",
";",
"}",
"else",
"{",
"GLOBAL",
".",
"error",
"(",
"'not annotated'",
",",
"err",
",",
"combo",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Request an update for this URI, optionally from a specific member | [
"Request",
"an",
"update",
"for",
"this",
"URI",
"optionally",
"from",
"a",
"specific",
"member"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L329-L342 |
45,518 | vid/SenseBase | lib/pubsub.js | debounceUpdate | function debounceUpdate(combo) {
bouncedUpdates[combo.uri] = combo;
if (Object.keys(bouncedUpdates).length < bounceHold) {
clearTimeout(bounceTimeout);
bounceTimeout = setTimeout(function() {
var toDebounce = Object.keys(bouncedUpdates).map(function(b) { return bouncedUpdates[b]; });
bouncedUpdates = {};
fayeClient.publish('/item/updated', toDebounce);
}, bounceDelay);
}
} | javascript | function debounceUpdate(combo) {
bouncedUpdates[combo.uri] = combo;
if (Object.keys(bouncedUpdates).length < bounceHold) {
clearTimeout(bounceTimeout);
bounceTimeout = setTimeout(function() {
var toDebounce = Object.keys(bouncedUpdates).map(function(b) { return bouncedUpdates[b]; });
bouncedUpdates = {};
fayeClient.publish('/item/updated', toDebounce);
}, bounceDelay);
}
} | [
"function",
"debounceUpdate",
"(",
"combo",
")",
"{",
"bouncedUpdates",
"[",
"combo",
".",
"uri",
"]",
"=",
"combo",
";",
"if",
"(",
"Object",
".",
"keys",
"(",
"bouncedUpdates",
")",
".",
"length",
"<",
"bounceHold",
")",
"{",
"clearTimeout",
"(",
"bounceTimeout",
")",
";",
"bounceTimeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"toDebounce",
"=",
"Object",
".",
"keys",
"(",
"bouncedUpdates",
")",
".",
"map",
"(",
"function",
"(",
"b",
")",
"{",
"return",
"bouncedUpdates",
"[",
"b",
"]",
";",
"}",
")",
";",
"bouncedUpdates",
"=",
"{",
"}",
";",
"fayeClient",
".",
"publish",
"(",
"'/item/updated'",
",",
"toDebounce",
")",
";",
"}",
",",
"bounceDelay",
")",
";",
"}",
"}"
]
| batch updates per a size or time frame. note bounceHold may be exceeded due to the delay. | [
"batch",
"updates",
"per",
"a",
"size",
"or",
"time",
"frame",
".",
"note",
"bounceHold",
"may",
"be",
"exceeded",
"due",
"to",
"the",
"delay",
"."
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L345-L355 |
45,519 | vid/SenseBase | lib/pubsub.js | adjureAnnotators | function adjureAnnotators(uris, annotators) {
GLOBAL.info('/item/annotations/adjure annotators'.yellow, uris, JSON.stringify(annotators));
uris.forEach(function(uri) {
annotators.forEach(function(member) {
publishUpdate({ uri: uri, member: member});
});
});
} | javascript | function adjureAnnotators(uris, annotators) {
GLOBAL.info('/item/annotations/adjure annotators'.yellow, uris, JSON.stringify(annotators));
uris.forEach(function(uri) {
annotators.forEach(function(member) {
publishUpdate({ uri: uri, member: member});
});
});
} | [
"function",
"adjureAnnotators",
"(",
"uris",
",",
"annotators",
")",
"{",
"GLOBAL",
".",
"info",
"(",
"'/item/annotations/adjure annotators'",
".",
"yellow",
",",
"uris",
",",
"JSON",
".",
"stringify",
"(",
"annotators",
")",
")",
";",
"uris",
".",
"forEach",
"(",
"function",
"(",
"uri",
")",
"{",
"annotators",
".",
"forEach",
"(",
"function",
"(",
"member",
")",
"{",
"publishUpdate",
"(",
"{",
"uri",
":",
"uri",
",",
"member",
":",
"member",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Publish annotation requests for specific annotators for the uris | [
"Publish",
"annotation",
"requests",
"for",
"specific",
"annotators",
"for",
"the",
"uris"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L358-L365 |
45,520 | vid/SenseBase | lib/pubsub.js | adjureAnnotations | function adjureAnnotations(uris, annotations, username) {
GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
try {
var user = GLOBAL.svc.auth.getUserByUsername(username);
if (!user) {
throw new Error("no user " + username);
}
uris.forEach(function(uri) {
var annos = [];
// TODO apply validation state based on user
annotations.forEach(function(p) {
p.roots = p.roots || [username];
p.annotatedBy = username;
p.state = utils.states.annotations.unvalidated;
if (!user.needsValidation) {
p.state = utils.states.annotations.validated;
}
p.hasTarget = uri;
var a = annoLib.createAnnotation(p);
annos.push(a);
});
contentLib.saveAnnotations(uri, { member: username }, annos, function(err, res, cItem) {
if (cItem) {
debounceUpdate(cItem);
} else {
utils.passingError('missing cItem');
}
});
});
} catch (err) {
GLOBAL.error('saveAnnotations failed', err);
console.trace();
}
} | javascript | function adjureAnnotations(uris, annotations, username) {
GLOBAL.info('/item/annotations/adjure annotations'.yellow, username.blue, uris, annotations.length);
try {
var user = GLOBAL.svc.auth.getUserByUsername(username);
if (!user) {
throw new Error("no user " + username);
}
uris.forEach(function(uri) {
var annos = [];
// TODO apply validation state based on user
annotations.forEach(function(p) {
p.roots = p.roots || [username];
p.annotatedBy = username;
p.state = utils.states.annotations.unvalidated;
if (!user.needsValidation) {
p.state = utils.states.annotations.validated;
}
p.hasTarget = uri;
var a = annoLib.createAnnotation(p);
annos.push(a);
});
contentLib.saveAnnotations(uri, { member: username }, annos, function(err, res, cItem) {
if (cItem) {
debounceUpdate(cItem);
} else {
utils.passingError('missing cItem');
}
});
});
} catch (err) {
GLOBAL.error('saveAnnotations failed', err);
console.trace();
}
} | [
"function",
"adjureAnnotations",
"(",
"uris",
",",
"annotations",
",",
"username",
")",
"{",
"GLOBAL",
".",
"info",
"(",
"'/item/annotations/adjure annotations'",
".",
"yellow",
",",
"username",
".",
"blue",
",",
"uris",
",",
"annotations",
".",
"length",
")",
";",
"try",
"{",
"var",
"user",
"=",
"GLOBAL",
".",
"svc",
".",
"auth",
".",
"getUserByUsername",
"(",
"username",
")",
";",
"if",
"(",
"!",
"user",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"no user \"",
"+",
"username",
")",
";",
"}",
"uris",
".",
"forEach",
"(",
"function",
"(",
"uri",
")",
"{",
"var",
"annos",
"=",
"[",
"]",
";",
"// TODO apply validation state based on user",
"annotations",
".",
"forEach",
"(",
"function",
"(",
"p",
")",
"{",
"p",
".",
"roots",
"=",
"p",
".",
"roots",
"||",
"[",
"username",
"]",
";",
"p",
".",
"annotatedBy",
"=",
"username",
";",
"p",
".",
"state",
"=",
"utils",
".",
"states",
".",
"annotations",
".",
"unvalidated",
";",
"if",
"(",
"!",
"user",
".",
"needsValidation",
")",
"{",
"p",
".",
"state",
"=",
"utils",
".",
"states",
".",
"annotations",
".",
"validated",
";",
"}",
"p",
".",
"hasTarget",
"=",
"uri",
";",
"var",
"a",
"=",
"annoLib",
".",
"createAnnotation",
"(",
"p",
")",
";",
"annos",
".",
"push",
"(",
"a",
")",
";",
"}",
")",
";",
"contentLib",
".",
"saveAnnotations",
"(",
"uri",
",",
"{",
"member",
":",
"username",
"}",
",",
"annos",
",",
"function",
"(",
"err",
",",
"res",
",",
"cItem",
")",
"{",
"if",
"(",
"cItem",
")",
"{",
"debounceUpdate",
"(",
"cItem",
")",
";",
"}",
"else",
"{",
"utils",
".",
"passingError",
"(",
"'missing cItem'",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"GLOBAL",
".",
"error",
"(",
"'saveAnnotations failed'",
",",
"err",
")",
";",
"console",
".",
"trace",
"(",
")",
";",
"}",
"}"
]
| apply annotations for the uris | [
"apply",
"annotations",
"for",
"the",
"uris"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L368-L402 |
45,521 | vid/SenseBase | lib/pubsub.js | publish | function publish(channel, data, clientID) {
if (clientID) {
channel += '/' + clientID;
}
fayeClient.publish(channel, data);
} | javascript | function publish(channel, data, clientID) {
if (clientID) {
channel += '/' + clientID;
}
fayeClient.publish(channel, data);
} | [
"function",
"publish",
"(",
"channel",
",",
"data",
",",
"clientID",
")",
"{",
"if",
"(",
"clientID",
")",
"{",
"channel",
"+=",
"'/'",
"+",
"clientID",
";",
"}",
"fayeClient",
".",
"publish",
"(",
"channel",
",",
"data",
")",
";",
"}"
]
| Publish data to a general or client specific channel if clientID is present. | [
"Publish",
"data",
"to",
"a",
"general",
"or",
"client",
"specific",
"channel",
"if",
"clientID",
"is",
"present",
"."
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/lib/pubsub.js#L405-L410 |
45,522 | feedhenry/fh-mbaas-client | lib/MbaasClient.js | MbaasClient | function MbaasClient(envId, mbaasConf) {
this.envId = envId;
this.mbaasConfig = mbaasConf;
this.setMbaasUrl();
this.app = {};
this.admin = {};
proxy(this.app, app, this.mbaasConfig);
proxy(this.admin, admin, this.mbaasConfig);
} | javascript | function MbaasClient(envId, mbaasConf) {
this.envId = envId;
this.mbaasConfig = mbaasConf;
this.setMbaasUrl();
this.app = {};
this.admin = {};
proxy(this.app, app, this.mbaasConfig);
proxy(this.admin, admin, this.mbaasConfig);
} | [
"function",
"MbaasClient",
"(",
"envId",
",",
"mbaasConf",
")",
"{",
"this",
".",
"envId",
"=",
"envId",
";",
"this",
".",
"mbaasConfig",
"=",
"mbaasConf",
";",
"this",
".",
"setMbaasUrl",
"(",
")",
";",
"this",
".",
"app",
"=",
"{",
"}",
";",
"this",
".",
"admin",
"=",
"{",
"}",
";",
"proxy",
"(",
"this",
".",
"app",
",",
"app",
",",
"this",
".",
"mbaasConfig",
")",
";",
"proxy",
"(",
"this",
".",
"admin",
",",
"admin",
",",
"this",
".",
"mbaasConfig",
")",
";",
"}"
]
| Create a new instance of MbaasClient
@param envId the id of the environment
@param mbaasConf the mbaas configuration
@constructor | [
"Create",
"a",
"new",
"instance",
"of",
"MbaasClient"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/MbaasClient.js#L12-L20 |
45,523 | rat-nest/big-rat | to-float.js | roundRat | function roundRat (f) {
var a = f[0]
var b = f[1]
if (a.cmpn(0) === 0) {
return 0
}
var h = a.abs().divmod(b.abs())
var iv = h.div
var x = bn2num(iv)
var ir = h.mod
var sgn = (a.negative !== b.negative) ? -1 : 1
if (ir.cmpn(0) === 0) {
return sgn * x
}
if (x) {
var s = ctz(x) + 4
var y = bn2num(ir.ushln(s).divRound(b))
return sgn * (x + y * Math.pow(2, -s))
} else {
var ybits = b.bitLength() - ir.bitLength() + 53
var y = bn2num(ir.ushln(ybits).divRound(b))
if (ybits < 1023) {
return sgn * y * Math.pow(2, -ybits)
}
y *= Math.pow(2, -1023)
return sgn * y * Math.pow(2, 1023 - ybits)
}
} | javascript | function roundRat (f) {
var a = f[0]
var b = f[1]
if (a.cmpn(0) === 0) {
return 0
}
var h = a.abs().divmod(b.abs())
var iv = h.div
var x = bn2num(iv)
var ir = h.mod
var sgn = (a.negative !== b.negative) ? -1 : 1
if (ir.cmpn(0) === 0) {
return sgn * x
}
if (x) {
var s = ctz(x) + 4
var y = bn2num(ir.ushln(s).divRound(b))
return sgn * (x + y * Math.pow(2, -s))
} else {
var ybits = b.bitLength() - ir.bitLength() + 53
var y = bn2num(ir.ushln(ybits).divRound(b))
if (ybits < 1023) {
return sgn * y * Math.pow(2, -ybits)
}
y *= Math.pow(2, -1023)
return sgn * y * Math.pow(2, 1023 - ybits)
}
} | [
"function",
"roundRat",
"(",
"f",
")",
"{",
"var",
"a",
"=",
"f",
"[",
"0",
"]",
"var",
"b",
"=",
"f",
"[",
"1",
"]",
"if",
"(",
"a",
".",
"cmpn",
"(",
"0",
")",
"===",
"0",
")",
"{",
"return",
"0",
"}",
"var",
"h",
"=",
"a",
".",
"abs",
"(",
")",
".",
"divmod",
"(",
"b",
".",
"abs",
"(",
")",
")",
"var",
"iv",
"=",
"h",
".",
"div",
"var",
"x",
"=",
"bn2num",
"(",
"iv",
")",
"var",
"ir",
"=",
"h",
".",
"mod",
"var",
"sgn",
"=",
"(",
"a",
".",
"negative",
"!==",
"b",
".",
"negative",
")",
"?",
"-",
"1",
":",
"1",
"if",
"(",
"ir",
".",
"cmpn",
"(",
"0",
")",
"===",
"0",
")",
"{",
"return",
"sgn",
"*",
"x",
"}",
"if",
"(",
"x",
")",
"{",
"var",
"s",
"=",
"ctz",
"(",
"x",
")",
"+",
"4",
"var",
"y",
"=",
"bn2num",
"(",
"ir",
".",
"ushln",
"(",
"s",
")",
".",
"divRound",
"(",
"b",
")",
")",
"return",
"sgn",
"*",
"(",
"x",
"+",
"y",
"*",
"Math",
".",
"pow",
"(",
"2",
",",
"-",
"s",
")",
")",
"}",
"else",
"{",
"var",
"ybits",
"=",
"b",
".",
"bitLength",
"(",
")",
"-",
"ir",
".",
"bitLength",
"(",
")",
"+",
"53",
"var",
"y",
"=",
"bn2num",
"(",
"ir",
".",
"ushln",
"(",
"ybits",
")",
".",
"divRound",
"(",
"b",
")",
")",
"if",
"(",
"ybits",
"<",
"1023",
")",
"{",
"return",
"sgn",
"*",
"y",
"*",
"Math",
".",
"pow",
"(",
"2",
",",
"-",
"ybits",
")",
"}",
"y",
"*=",
"Math",
".",
"pow",
"(",
"2",
",",
"-",
"1023",
")",
"return",
"sgn",
"*",
"y",
"*",
"Math",
".",
"pow",
"(",
"2",
",",
"1023",
"-",
"ybits",
")",
"}",
"}"
]
| Round a rational to the closest float | [
"Round",
"a",
"rational",
"to",
"the",
"closest",
"float"
]
| 09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa | https://github.com/rat-nest/big-rat/blob/09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa/to-float.js#L9-L36 |
45,524 | onecommons/base | lib/passport.js | function(req, token, refreshToken, profile, done) {
// asynchronous
process.nextTick(function() {
var User = app.userModel;
// find the user in the database based on their facebook id
User.findOne({ 'facebook.id' : profile.id }, function(err, user) {
// if there is an error, stop everything and return that
// ie an error connecting to the database
if (err)
return done(err);
// if the user is found, then log them in
if (user) {
if (req.session.reauthenticate) {
delete req.session.reauthenticate;
req.session.loginTime = new Date();
}
return done(null, user); // user found, return that user
} else {
// if there is no user found with that facebook id, create them
var newUser = new User();
// set all of the facebook information in our user model
newUser.facebook.id = profile.id; // set the users facebook id
newUser.facebook.token = token; // we will save the token that facebook provides to the user
newUser.facebook.name = profile.name.givenName + ' ' + profile.name.familyName; // look at the passport user profile to see how names are returned
newUser.facebook.email = profile.emails[0].value; // facebook can return multiple emails so we'll take the first
//XXX if the user with that email already exists -- associate with facebook (prompt for password?)
//XXX need a way for a currently logged in user to login to facebook and associate accounts
// save our user to the database
newUser.save(function(err) {
if (err)
return done(err);
if (req.session.reauthenticate) {
delete req.session.reauthenticate;
req.session.loginTime = new Date();
}
// if successful, return the new user
return done(null, newUser);
});
}
});
});
} | javascript | function(req, token, refreshToken, profile, done) {
// asynchronous
process.nextTick(function() {
var User = app.userModel;
// find the user in the database based on their facebook id
User.findOne({ 'facebook.id' : profile.id }, function(err, user) {
// if there is an error, stop everything and return that
// ie an error connecting to the database
if (err)
return done(err);
// if the user is found, then log them in
if (user) {
if (req.session.reauthenticate) {
delete req.session.reauthenticate;
req.session.loginTime = new Date();
}
return done(null, user); // user found, return that user
} else {
// if there is no user found with that facebook id, create them
var newUser = new User();
// set all of the facebook information in our user model
newUser.facebook.id = profile.id; // set the users facebook id
newUser.facebook.token = token; // we will save the token that facebook provides to the user
newUser.facebook.name = profile.name.givenName + ' ' + profile.name.familyName; // look at the passport user profile to see how names are returned
newUser.facebook.email = profile.emails[0].value; // facebook can return multiple emails so we'll take the first
//XXX if the user with that email already exists -- associate with facebook (prompt for password?)
//XXX need a way for a currently logged in user to login to facebook and associate accounts
// save our user to the database
newUser.save(function(err) {
if (err)
return done(err);
if (req.session.reauthenticate) {
delete req.session.reauthenticate;
req.session.loginTime = new Date();
}
// if successful, return the new user
return done(null, newUser);
});
}
});
});
} | [
"function",
"(",
"req",
",",
"token",
",",
"refreshToken",
",",
"profile",
",",
"done",
")",
"{",
"// asynchronous",
"process",
".",
"nextTick",
"(",
"function",
"(",
")",
"{",
"var",
"User",
"=",
"app",
".",
"userModel",
";",
"// find the user in the database based on their facebook id",
"User",
".",
"findOne",
"(",
"{",
"'facebook.id'",
":",
"profile",
".",
"id",
"}",
",",
"function",
"(",
"err",
",",
"user",
")",
"{",
"// if there is an error, stop everything and return that",
"// ie an error connecting to the database",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
";",
"// if the user is found, then log them in",
"if",
"(",
"user",
")",
"{",
"if",
"(",
"req",
".",
"session",
".",
"reauthenticate",
")",
"{",
"delete",
"req",
".",
"session",
".",
"reauthenticate",
";",
"req",
".",
"session",
".",
"loginTime",
"=",
"new",
"Date",
"(",
")",
";",
"}",
"return",
"done",
"(",
"null",
",",
"user",
")",
";",
"// user found, return that user",
"}",
"else",
"{",
"// if there is no user found with that facebook id, create them",
"var",
"newUser",
"=",
"new",
"User",
"(",
")",
";",
"// set all of the facebook information in our user model",
"newUser",
".",
"facebook",
".",
"id",
"=",
"profile",
".",
"id",
";",
"// set the users facebook id",
"newUser",
".",
"facebook",
".",
"token",
"=",
"token",
";",
"// we will save the token that facebook provides to the user",
"newUser",
".",
"facebook",
".",
"name",
"=",
"profile",
".",
"name",
".",
"givenName",
"+",
"' '",
"+",
"profile",
".",
"name",
".",
"familyName",
";",
"// look at the passport user profile to see how names are returned",
"newUser",
".",
"facebook",
".",
"email",
"=",
"profile",
".",
"emails",
"[",
"0",
"]",
".",
"value",
";",
"// facebook can return multiple emails so we'll take the first",
"//XXX if the user with that email already exists -- associate with facebook (prompt for password?)",
"//XXX need a way for a currently logged in user to login to facebook and associate accounts",
"// save our user to the database",
"newUser",
".",
"save",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
";",
"if",
"(",
"req",
".",
"session",
".",
"reauthenticate",
")",
"{",
"delete",
"req",
".",
"session",
".",
"reauthenticate",
";",
"req",
".",
"session",
".",
"loginTime",
"=",
"new",
"Date",
"(",
")",
";",
"}",
"// if successful, return the new user",
"return",
"done",
"(",
"null",
",",
"newUser",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
]
| facebook will send back the token and profile | [
"facebook",
"will",
"send",
"back",
"the",
"token",
"and",
"profile"
]
| 4f35d9f714d0367b0622a3504802363404290246 | https://github.com/onecommons/base/blob/4f35d9f714d0367b0622a3504802363404290246/lib/passport.js#L291-L339 |
|
45,525 | feedhenry/fh-mbaas-client | lib/admin/alerts/notifications.js | listNotifications | function listNotifications(params, cb) {
params.resourcePath = config.addURIParams(constants.NOTIFICATIONS_BASE_PATH, params);
params.method = 'GET';
params.data = params.data || {};
mbaasRequest.admin(params, cb);
} | javascript | function listNotifications(params, cb) {
params.resourcePath = config.addURIParams(constants.NOTIFICATIONS_BASE_PATH, params);
params.method = 'GET';
params.data = params.data || {};
mbaasRequest.admin(params, cb);
} | [
"function",
"listNotifications",
"(",
"params",
",",
"cb",
")",
"{",
"params",
".",
"resourcePath",
"=",
"config",
".",
"addURIParams",
"(",
"constants",
".",
"NOTIFICATIONS_BASE_PATH",
",",
"params",
")",
";",
"params",
".",
"method",
"=",
"'GET'",
";",
"params",
".",
"data",
"=",
"params",
".",
"data",
"||",
"{",
"}",
";",
"mbaasRequest",
".",
"admin",
"(",
"params",
",",
"cb",
")",
";",
"}"
]
| List Notifications on an MBaaS
@param params
@param cb | [
"List",
"Notifications",
"on",
"an",
"MBaaS"
]
| 2d5a9cbb32e1b2464d71ffa18513358fea388859 | https://github.com/feedhenry/fh-mbaas-client/blob/2d5a9cbb32e1b2464d71ffa18513358fea388859/lib/admin/alerts/notifications.js#L10-L16 |
45,526 | mchalapuk/hyper-text-slider | lib/core/boot.js | boot | function boot(containerElement) {
check(containerElement, 'containerElement').is.anInstanceOf(Element)();
var containerOptions = getEnabledOptions(containerElement);
var sliderElems = concatUnique(
[].slice.call(containerElement.querySelectorAll('.'+ Layout.SLIDER)),
[].slice.call(containerElement.querySelectorAll('.'+ Common.SLIDER_SHORT))
);
var sliders = sliderElems.map(function(elem) {
containerOptions.forEach(function(option) {
if (elem.classList.contains(option)) {
return;
}
elem.classList.add(option);
});
return new Slider(elem);
});
sliders.forEach(function(slider) { slider.start(); });
return sliders;
} | javascript | function boot(containerElement) {
check(containerElement, 'containerElement').is.anInstanceOf(Element)();
var containerOptions = getEnabledOptions(containerElement);
var sliderElems = concatUnique(
[].slice.call(containerElement.querySelectorAll('.'+ Layout.SLIDER)),
[].slice.call(containerElement.querySelectorAll('.'+ Common.SLIDER_SHORT))
);
var sliders = sliderElems.map(function(elem) {
containerOptions.forEach(function(option) {
if (elem.classList.contains(option)) {
return;
}
elem.classList.add(option);
});
return new Slider(elem);
});
sliders.forEach(function(slider) { slider.start(); });
return sliders;
} | [
"function",
"boot",
"(",
"containerElement",
")",
"{",
"check",
"(",
"containerElement",
",",
"'containerElement'",
")",
".",
"is",
".",
"anInstanceOf",
"(",
"Element",
")",
"(",
")",
";",
"var",
"containerOptions",
"=",
"getEnabledOptions",
"(",
"containerElement",
")",
";",
"var",
"sliderElems",
"=",
"concatUnique",
"(",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"containerElement",
".",
"querySelectorAll",
"(",
"'.'",
"+",
"Layout",
".",
"SLIDER",
")",
")",
",",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"containerElement",
".",
"querySelectorAll",
"(",
"'.'",
"+",
"Common",
".",
"SLIDER_SHORT",
")",
")",
")",
";",
"var",
"sliders",
"=",
"sliderElems",
".",
"map",
"(",
"function",
"(",
"elem",
")",
"{",
"containerOptions",
".",
"forEach",
"(",
"function",
"(",
"option",
")",
"{",
"if",
"(",
"elem",
".",
"classList",
".",
"contains",
"(",
"option",
")",
")",
"{",
"return",
";",
"}",
"elem",
".",
"classList",
".",
"add",
"(",
"option",
")",
";",
"}",
")",
";",
"return",
"new",
"Slider",
"(",
"elem",
")",
";",
"}",
")",
";",
"sliders",
".",
"forEach",
"(",
"function",
"(",
"slider",
")",
"{",
"slider",
".",
"start",
"(",
")",
";",
"}",
")",
";",
"return",
"sliders",
";",
"}"
]
| Default HyperText Slider boot procedure.
For each element with ${link Layout.SLIDER} class name found in passed container
(typically document's `<body>`):
1. Adds ${link Option options class names} found on container element,
1. Creates ${link Slider} object,
2. Invokes its ${link Slider.prototype.start} method.
If you are using browserify, you may want to call this function at some point...
```javascript
var htSlider = require('hyper-text-slider');
htSlider.boot(document.body);
```
...or even consider implementing bootup by yourself.
@param {Element} containerElement element that contains sliders in (not necessarily immediate) children
@return {Array<Slider>} array containing all created ${link Slider} instances
@see Common.AUTOBOOT
@fqn boot | [
"Default",
"HyperText",
"Slider",
"boot",
"procedure",
"."
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/boot.js#L53-L75 |
45,527 | mchalapuk/hyper-text-slider | lib/core/boot.js | getEnabledOptions | function getEnabledOptions(element) {
var retVal = [];
Object.values(Option).forEach(function(option) {
if (element.classList.contains(option)) {
retVal.push(option);
}
});
return retVal;
} | javascript | function getEnabledOptions(element) {
var retVal = [];
Object.values(Option).forEach(function(option) {
if (element.classList.contains(option)) {
retVal.push(option);
}
});
return retVal;
} | [
"function",
"getEnabledOptions",
"(",
"element",
")",
"{",
"var",
"retVal",
"=",
"[",
"]",
";",
"Object",
".",
"values",
"(",
"Option",
")",
".",
"forEach",
"(",
"function",
"(",
"option",
")",
"{",
"if",
"(",
"element",
".",
"classList",
".",
"contains",
"(",
"option",
")",
")",
"{",
"retVal",
".",
"push",
"(",
"option",
")",
";",
"}",
"}",
")",
";",
"return",
"retVal",
";",
"}"
]
| finds option class names on passed element | [
"finds",
"option",
"class",
"names",
"on",
"passed",
"element"
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/boot.js#L78-L86 |
45,528 | openmason/brook | index.js | publisher | function publisher(port) {
var socket = zeromq.socket('pub');
socket.identity = 'pub' + process.pid;
socket.connect(port);
console.log('publisher connected to ' + port);
// lets count messages / sec
var totalMessages=0;
setInterval(function() {
console.log('total messages sent = '+totalMessages);
totalMessages=0;
// now fire messages
for(var i=0;i<5000;i++) {
var value = Math.random()*1000;
socket.send('log ' + value);
totalMessages++;
}
}, 1000);
} | javascript | function publisher(port) {
var socket = zeromq.socket('pub');
socket.identity = 'pub' + process.pid;
socket.connect(port);
console.log('publisher connected to ' + port);
// lets count messages / sec
var totalMessages=0;
setInterval(function() {
console.log('total messages sent = '+totalMessages);
totalMessages=0;
// now fire messages
for(var i=0;i<5000;i++) {
var value = Math.random()*1000;
socket.send('log ' + value);
totalMessages++;
}
}, 1000);
} | [
"function",
"publisher",
"(",
"port",
")",
"{",
"var",
"socket",
"=",
"zeromq",
".",
"socket",
"(",
"'pub'",
")",
";",
"socket",
".",
"identity",
"=",
"'pub'",
"+",
"process",
".",
"pid",
";",
"socket",
".",
"connect",
"(",
"port",
")",
";",
"console",
".",
"log",
"(",
"'publisher connected to '",
"+",
"port",
")",
";",
"// lets count messages / sec",
"var",
"totalMessages",
"=",
"0",
";",
"setInterval",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'total messages sent = '",
"+",
"totalMessages",
")",
";",
"totalMessages",
"=",
"0",
";",
"// now fire messages",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"5000",
";",
"i",
"++",
")",
"{",
"var",
"value",
"=",
"Math",
".",
"random",
"(",
")",
"*",
"1000",
";",
"socket",
".",
"send",
"(",
"'log '",
"+",
"value",
")",
";",
"totalMessages",
"++",
";",
"}",
"}",
",",
"1000",
")",
";",
"}"
]
| lets do the publisher here | [
"lets",
"do",
"the",
"publisher",
"here"
]
| 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L25-L45 |
45,529 | openmason/brook | index.js | subscriber | function subscriber(port) {
var socket = zeromq.socket('sub');
socket.identity = 'sub' + process.pid;
// have to subscribe, otherwise nothing would show up
// subscribe to everything
socket.subscribe('');
var totalMessages=0;
// receive messages
socket.on('message', function(data) {
//console.log(socket.identity + ': received data ' + data.toString());
totalMessages++;
});
socket.connect(port);
console.log('connected to ' + port);
// lets count messages recvd
setInterval(function() {
console.log('messages received = ' + totalMessages);
totalMessages=0;
}, 1000);
} | javascript | function subscriber(port) {
var socket = zeromq.socket('sub');
socket.identity = 'sub' + process.pid;
// have to subscribe, otherwise nothing would show up
// subscribe to everything
socket.subscribe('');
var totalMessages=0;
// receive messages
socket.on('message', function(data) {
//console.log(socket.identity + ': received data ' + data.toString());
totalMessages++;
});
socket.connect(port);
console.log('connected to ' + port);
// lets count messages recvd
setInterval(function() {
console.log('messages received = ' + totalMessages);
totalMessages=0;
}, 1000);
} | [
"function",
"subscriber",
"(",
"port",
")",
"{",
"var",
"socket",
"=",
"zeromq",
".",
"socket",
"(",
"'sub'",
")",
";",
"socket",
".",
"identity",
"=",
"'sub'",
"+",
"process",
".",
"pid",
";",
"// have to subscribe, otherwise nothing would show up",
"// subscribe to everything",
"socket",
".",
"subscribe",
"(",
"''",
")",
";",
"var",
"totalMessages",
"=",
"0",
";",
"// receive messages",
"socket",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
"data",
")",
"{",
"//console.log(socket.identity + ': received data ' + data.toString());",
"totalMessages",
"++",
";",
"}",
")",
";",
"socket",
".",
"connect",
"(",
"port",
")",
";",
"console",
".",
"log",
"(",
"'connected to '",
"+",
"port",
")",
";",
"// lets count messages recvd",
"setInterval",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'messages received = '",
"+",
"totalMessages",
")",
";",
"totalMessages",
"=",
"0",
";",
"}",
",",
"1000",
")",
";",
"}"
]
| lets do the subscriber here | [
"lets",
"do",
"the",
"subscriber",
"here"
]
| 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L48-L73 |
45,530 | openmason/brook | index.js | forwarder | function forwarder(frontPort, backPort) {
var frontSocket = zeromq.socket('sub'),
backSocket = zeromq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
frontSocket.subscribe('');
frontSocket.bind(frontPort, function (err) {
console.log('bound', frontPort);
});
var totalMessages=0;
frontSocket.on('message', function() {
//pass to back
//console.log('forwarder: recasting', arguments[0].toString());
backSocket.send(Array.prototype.slice.call(arguments));
totalMessages++;
});
backSocket.bind(backPort, function (err) {
console.log('bound', backPort);
});
// lets count messages forwarded
setInterval(function() {
console.log('messages forwarded = ' + totalMessages);
totalMessages=0;
}, 1000);
} | javascript | function forwarder(frontPort, backPort) {
var frontSocket = zeromq.socket('sub'),
backSocket = zeromq.socket('pub');
frontSocket.identity = 'sub' + process.pid;
backSocket.identity = 'pub' + process.pid;
frontSocket.subscribe('');
frontSocket.bind(frontPort, function (err) {
console.log('bound', frontPort);
});
var totalMessages=0;
frontSocket.on('message', function() {
//pass to back
//console.log('forwarder: recasting', arguments[0].toString());
backSocket.send(Array.prototype.slice.call(arguments));
totalMessages++;
});
backSocket.bind(backPort, function (err) {
console.log('bound', backPort);
});
// lets count messages forwarded
setInterval(function() {
console.log('messages forwarded = ' + totalMessages);
totalMessages=0;
}, 1000);
} | [
"function",
"forwarder",
"(",
"frontPort",
",",
"backPort",
")",
"{",
"var",
"frontSocket",
"=",
"zeromq",
".",
"socket",
"(",
"'sub'",
")",
",",
"backSocket",
"=",
"zeromq",
".",
"socket",
"(",
"'pub'",
")",
";",
"frontSocket",
".",
"identity",
"=",
"'sub'",
"+",
"process",
".",
"pid",
";",
"backSocket",
".",
"identity",
"=",
"'pub'",
"+",
"process",
".",
"pid",
";",
"frontSocket",
".",
"subscribe",
"(",
"''",
")",
";",
"frontSocket",
".",
"bind",
"(",
"frontPort",
",",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'bound'",
",",
"frontPort",
")",
";",
"}",
")",
";",
"var",
"totalMessages",
"=",
"0",
";",
"frontSocket",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
")",
"{",
"//pass to back",
"//console.log('forwarder: recasting', arguments[0].toString());",
"backSocket",
".",
"send",
"(",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
")",
";",
"totalMessages",
"++",
";",
"}",
")",
";",
"backSocket",
".",
"bind",
"(",
"backPort",
",",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'bound'",
",",
"backPort",
")",
";",
"}",
")",
";",
"// lets count messages forwarded",
"setInterval",
"(",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'messages forwarded = '",
"+",
"totalMessages",
")",
";",
"totalMessages",
"=",
"0",
";",
"}",
",",
"1000",
")",
";",
"}"
]
| create a forwarder device | [
"create",
"a",
"forwarder",
"device"
]
| 6d4e12d6c27e71948baab91d3e778fbae5a47245 | https://github.com/openmason/brook/blob/6d4e12d6c27e71948baab91d3e778fbae5a47245/index.js#L76-L106 |
45,531 | odogono/elsinore-js | src/util/loader_ex.js | createComponent | function createComponent(loader, obj) {
const entitySet = loader.entitySet;
// determine whether any attributes are refering to marked pois
obj = resolveMarkReferences(loader, obj);
// the alternative form is to use @uri
if (obj[CMD_COMPONENT_URI]) {
obj[CMD_COMPONENT] = obj[CMD_COMPONENT_URI];
delete obj[CMD_COMPONENT_URI];
}
if( obj[CMD_COMPONENT] === undefined ){
throw new Error('invalid create component command');
}
const component = loader.registry.createComponent(obj);
return Promise.resolve(component)
.then(component => {
if (!loader.entity) {
return _createEntity(loader, null, { shadow: true });
}
// Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id);
return component;
})
.then(() => loader.entity.addComponent(component))
.then(() => component);
// loader.entity.addComponent( component );
// return Promise.resolve(component);
} | javascript | function createComponent(loader, obj) {
const entitySet = loader.entitySet;
// determine whether any attributes are refering to marked pois
obj = resolveMarkReferences(loader, obj);
// the alternative form is to use @uri
if (obj[CMD_COMPONENT_URI]) {
obj[CMD_COMPONENT] = obj[CMD_COMPONENT_URI];
delete obj[CMD_COMPONENT_URI];
}
if( obj[CMD_COMPONENT] === undefined ){
throw new Error('invalid create component command');
}
const component = loader.registry.createComponent(obj);
return Promise.resolve(component)
.then(component => {
if (!loader.entity) {
return _createEntity(loader, null, { shadow: true });
}
// Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id);
return component;
})
.then(() => loader.entity.addComponent(component))
.then(() => component);
// loader.entity.addComponent( component );
// return Promise.resolve(component);
} | [
"function",
"createComponent",
"(",
"loader",
",",
"obj",
")",
"{",
"const",
"entitySet",
"=",
"loader",
".",
"entitySet",
";",
"// determine whether any attributes are refering to marked pois",
"obj",
"=",
"resolveMarkReferences",
"(",
"loader",
",",
"obj",
")",
";",
"// the alternative form is to use @uri",
"if",
"(",
"obj",
"[",
"CMD_COMPONENT_URI",
"]",
")",
"{",
"obj",
"[",
"CMD_COMPONENT",
"]",
"=",
"obj",
"[",
"CMD_COMPONENT_URI",
"]",
";",
"delete",
"obj",
"[",
"CMD_COMPONENT_URI",
"]",
";",
"}",
"if",
"(",
"obj",
"[",
"CMD_COMPONENT",
"]",
"===",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"'invalid create component command'",
")",
";",
"}",
"const",
"component",
"=",
"loader",
".",
"registry",
".",
"createComponent",
"(",
"obj",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
"component",
")",
".",
"then",
"(",
"component",
"=>",
"{",
"if",
"(",
"!",
"loader",
".",
"entity",
")",
"{",
"return",
"_createEntity",
"(",
"loader",
",",
"null",
",",
"{",
"shadow",
":",
"true",
"}",
")",
";",
"}",
"// Log.debug('[createComponent]', 'adding to existing entity', loader.entity.id);",
"return",
"component",
";",
"}",
")",
".",
"then",
"(",
"(",
")",
"=>",
"loader",
".",
"entity",
".",
"addComponent",
"(",
"component",
")",
")",
".",
"then",
"(",
"(",
")",
"=>",
"component",
")",
";",
"// loader.entity.addComponent( component );",
"// return Promise.resolve(component);",
"}"
]
| return value; } | [
"return",
"value",
";",
"}"
]
| 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/util/loader_ex.js#L333-L365 |
45,532 | odogono/elsinore-js | src/util/loader_ex.js | retrieveEntityByAttribute | async function retrieveEntityByAttribute(
entitySet,
componentID,
attribute,
value
) {
// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);
const query = Q => [
Q.all(componentID).where(Q.attr(attribute).equals(value)),
Q.limit(1)
];
if (entitySet.isAsync) {
const existing = await entitySet.query(query, { debug: false });
// Log.debug('[retrieveEntityByAttribute]', entityToString( existing));
if (existing.size() === 1) {
return existing.at(0);
}
return null;
} else {
return Promise.resolve(true).then(() => {
const existing = entitySet.query(query);
// Log.debug('[retrieveEntityByAttribute]', 'query result', existing.size(), entityToString(existing), componentID, attribute, value );
if (existing.size() === 1) {
return existing.at(0);
}
return null;
});
}
} | javascript | async function retrieveEntityByAttribute(
entitySet,
componentID,
attribute,
value
) {
// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);
const query = Q => [
Q.all(componentID).where(Q.attr(attribute).equals(value)),
Q.limit(1)
];
if (entitySet.isAsync) {
const existing = await entitySet.query(query, { debug: false });
// Log.debug('[retrieveEntityByAttribute]', entityToString( existing));
if (existing.size() === 1) {
return existing.at(0);
}
return null;
} else {
return Promise.resolve(true).then(() => {
const existing = entitySet.query(query);
// Log.debug('[retrieveEntityByAttribute]', 'query result', existing.size(), entityToString(existing), componentID, attribute, value );
if (existing.size() === 1) {
return existing.at(0);
}
return null;
});
}
} | [
"async",
"function",
"retrieveEntityByAttribute",
"(",
"entitySet",
",",
"componentID",
",",
"attribute",
",",
"value",
")",
"{",
"// Log.debug('[retrieveEntityByAttribute]', componentID, 'where', attribute, 'equals', value);",
"const",
"query",
"=",
"Q",
"=>",
"[",
"Q",
".",
"all",
"(",
"componentID",
")",
".",
"where",
"(",
"Q",
".",
"attr",
"(",
"attribute",
")",
".",
"equals",
"(",
"value",
")",
")",
",",
"Q",
".",
"limit",
"(",
"1",
")",
"]",
";",
"if",
"(",
"entitySet",
".",
"isAsync",
")",
"{",
"const",
"existing",
"=",
"await",
"entitySet",
".",
"query",
"(",
"query",
",",
"{",
"debug",
":",
"false",
"}",
")",
";",
"// Log.debug('[retrieveEntityByAttribute]', entityToString( existing));",
"if",
"(",
"existing",
".",
"size",
"(",
")",
"===",
"1",
")",
"{",
"return",
"existing",
".",
"at",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"true",
")",
".",
"then",
"(",
"(",
")",
"=>",
"{",
"const",
"existing",
"=",
"entitySet",
".",
"query",
"(",
"query",
")",
";",
"// Log.debug('[retrieveEntityByAttribute]', 'query result', existing.size(), entityToString(existing), componentID, attribute, value );",
"if",
"(",
"existing",
".",
"size",
"(",
")",
"===",
"1",
")",
"{",
"return",
"existing",
".",
"at",
"(",
"0",
")",
";",
"}",
"return",
"null",
";",
"}",
")",
";",
"}",
"}"
]
| Retrieves the first entity which has the specified component attribute value | [
"Retrieves",
"the",
"first",
"entity",
"which",
"has",
"the",
"specified",
"component",
"attribute",
"value"
]
| 1ecce67ad0022646419a740def029b1ba92dd558 | https://github.com/odogono/elsinore-js/blob/1ecce67ad0022646419a740def029b1ba92dd558/src/util/loader_ex.js#L533-L564 |
45,533 | webida/webida-restful-api | src/api/SessionApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the closeSessions operation.
* @callback module:api/SessionApi~closeSessionsCallback
* @param {String} error Error message, if any.
* @param {module:model/RestOK} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Closes session with timeout. Targets are selected by same rule to findSessions() op. While targeting multiple sessions, this operation requires same access rights with findSessions(). Closing a single session requires 'same session id' or 'unrestricted workspace acceess'.
* @param {String} sessionId webida session id (usually different from socket id from sock.io)
* @param {String} workspaceId webida workspace id in query part
* @param {Integer} closeAfter Waiting time before actual closing, to let client save files and prevent reconnecting.
* @param {module:api/SessionApi~closeSessionsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {module:model/RestOK}
*/
this.closeSessions = function(sessionId, workspaceId, closeAfter, callback) {
var postBody = null;
// verify the required parameter 'sessionId' is set
if (sessionId == undefined || sessionId == null) {
throw "Missing the required parameter 'sessionId' when calling closeSessions";
}
// verify the required parameter 'workspaceId' is set
if (workspaceId == undefined || workspaceId == null) {
throw "Missing the required parameter 'workspaceId' when calling closeSessions";
}
// verify the required parameter 'closeAfter' is set
if (closeAfter == undefined || closeAfter == null) {
throw "Missing the required parameter 'closeAfter' when calling closeSessions";
}
var pathParams = {
'sessionId': sessionId
};
var queryParams = {
'workspaceId': workspaceId,
'closeAfter': closeAfter
};
var headerParams = {
};
var formParams = {
};
var authNames = ['webida-simple-auth'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = RestOK;
return this.apiClient.callApi(
'/sessions/{sessionId}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the findSessions operation.
* @callback module:api/SessionApi~findSessionsCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/Session>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Finds webida sessions established to server. if session id is given, matched session info will be returned and workspace id parameter will be ignored. To find all sessions of some workspace, set session id to '*' and specify workspace id. This operation requires proper accsss rights. 1) To find all sessions, an unrestricted token is required. 2) To find some workspace sesions, token should have proper access right on the workspace.
* @param {String} sessionId webida session id (usually different from socket id from sock.io)
* @param {String} workspaceId webida workspace id in query part
* @param {module:api/SessionApi~findSessionsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {Array.<module:model/Session>}
*/
this.findSessions = function(sessionId, workspaceId, callback) {
var postBody = null;
// verify the required parameter 'sessionId' is set
if (sessionId == undefined || sessionId == null) {
throw "Missing the required parameter 'sessionId' when calling findSessions";
}
// verify the required parameter 'workspaceId' is set
if (workspaceId == undefined || workspaceId == null) {
throw "Missing the required parameter 'workspaceId' when calling findSessions";
}
var pathParams = {
'sessionId': sessionId
};
var queryParams = {
'workspaceId': workspaceId
};
var headerParams = {
};
var formParams = {
};
var authNames = ['webida-simple-auth'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = [Session];
return this.apiClient.callApi(
'/sessions/{sessionId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
} | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Callback function to receive the result of the closeSessions operation.
* @callback module:api/SessionApi~closeSessionsCallback
* @param {String} error Error message, if any.
* @param {module:model/RestOK} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Closes session with timeout. Targets are selected by same rule to findSessions() op. While targeting multiple sessions, this operation requires same access rights with findSessions(). Closing a single session requires 'same session id' or 'unrestricted workspace acceess'.
* @param {String} sessionId webida session id (usually different from socket id from sock.io)
* @param {String} workspaceId webida workspace id in query part
* @param {Integer} closeAfter Waiting time before actual closing, to let client save files and prevent reconnecting.
* @param {module:api/SessionApi~closeSessionsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {module:model/RestOK}
*/
this.closeSessions = function(sessionId, workspaceId, closeAfter, callback) {
var postBody = null;
// verify the required parameter 'sessionId' is set
if (sessionId == undefined || sessionId == null) {
throw "Missing the required parameter 'sessionId' when calling closeSessions";
}
// verify the required parameter 'workspaceId' is set
if (workspaceId == undefined || workspaceId == null) {
throw "Missing the required parameter 'workspaceId' when calling closeSessions";
}
// verify the required parameter 'closeAfter' is set
if (closeAfter == undefined || closeAfter == null) {
throw "Missing the required parameter 'closeAfter' when calling closeSessions";
}
var pathParams = {
'sessionId': sessionId
};
var queryParams = {
'workspaceId': workspaceId,
'closeAfter': closeAfter
};
var headerParams = {
};
var formParams = {
};
var authNames = ['webida-simple-auth'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = RestOK;
return this.apiClient.callApi(
'/sessions/{sessionId}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the findSessions operation.
* @callback module:api/SessionApi~findSessionsCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/Session>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Finds webida sessions established to server. if session id is given, matched session info will be returned and workspace id parameter will be ignored. To find all sessions of some workspace, set session id to '*' and specify workspace id. This operation requires proper accsss rights. 1) To find all sessions, an unrestricted token is required. 2) To find some workspace sesions, token should have proper access right on the workspace.
* @param {String} sessionId webida session id (usually different from socket id from sock.io)
* @param {String} workspaceId webida workspace id in query part
* @param {module:api/SessionApi~findSessionsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {Array.<module:model/Session>}
*/
this.findSessions = function(sessionId, workspaceId, callback) {
var postBody = null;
// verify the required parameter 'sessionId' is set
if (sessionId == undefined || sessionId == null) {
throw "Missing the required parameter 'sessionId' when calling findSessions";
}
// verify the required parameter 'workspaceId' is set
if (workspaceId == undefined || workspaceId == null) {
throw "Missing the required parameter 'workspaceId' when calling findSessions";
}
var pathParams = {
'sessionId': sessionId
};
var queryParams = {
'workspaceId': workspaceId
};
var headerParams = {
};
var formParams = {
};
var authNames = ['webida-simple-auth'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = [Session];
return this.apiClient.callApi(
'/sessions/{sessionId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
} | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Callback function to receive the result of the closeSessions operation.\n * @callback module:api/SessionApi~closeSessionsCallback\n * @param {String} error Error message, if any.\n * @param {module:model/RestOK} data The data returned by the service call.\n * @param {String} response The complete HTTP response.\n */",
"/**\n * Closes session with timeout. Targets are selected by same rule to findSessions() op. While targeting multiple sessions, this operation requires same access rights with findSessions(). Closing a single session requires 'same session id' or 'unrestricted workspace acceess'.\n * @param {String} sessionId webida session id (usually different from socket id from sock.io)\n * @param {String} workspaceId webida workspace id in query part\n * @param {Integer} closeAfter Waiting time before actual closing, to let client save files and prevent reconnecting. \n * @param {module:api/SessionApi~closeSessionsCallback} callback The callback function, accepting three arguments: error, data, response\n * data is of type: {module:model/RestOK}\n */",
"this",
".",
"closeSessions",
"=",
"function",
"(",
"sessionId",
",",
"workspaceId",
",",
"closeAfter",
",",
"callback",
")",
"{",
"var",
"postBody",
"=",
"null",
";",
"// verify the required parameter 'sessionId' is set",
"if",
"(",
"sessionId",
"==",
"undefined",
"||",
"sessionId",
"==",
"null",
")",
"{",
"throw",
"\"Missing the required parameter 'sessionId' when calling closeSessions\"",
";",
"}",
"// verify the required parameter 'workspaceId' is set",
"if",
"(",
"workspaceId",
"==",
"undefined",
"||",
"workspaceId",
"==",
"null",
")",
"{",
"throw",
"\"Missing the required parameter 'workspaceId' when calling closeSessions\"",
";",
"}",
"// verify the required parameter 'closeAfter' is set",
"if",
"(",
"closeAfter",
"==",
"undefined",
"||",
"closeAfter",
"==",
"null",
")",
"{",
"throw",
"\"Missing the required parameter 'closeAfter' when calling closeSessions\"",
";",
"}",
"var",
"pathParams",
"=",
"{",
"'sessionId'",
":",
"sessionId",
"}",
";",
"var",
"queryParams",
"=",
"{",
"'workspaceId'",
":",
"workspaceId",
",",
"'closeAfter'",
":",
"closeAfter",
"}",
";",
"var",
"headerParams",
"=",
"{",
"}",
";",
"var",
"formParams",
"=",
"{",
"}",
";",
"var",
"authNames",
"=",
"[",
"'webida-simple-auth'",
"]",
";",
"var",
"contentTypes",
"=",
"[",
"'application/json'",
"]",
";",
"var",
"accepts",
"=",
"[",
"'application/json'",
",",
"'application/octet-stream'",
"]",
";",
"var",
"returnType",
"=",
"RestOK",
";",
"return",
"this",
".",
"apiClient",
".",
"callApi",
"(",
"'/sessions/{sessionId}'",
",",
"'DELETE'",
",",
"pathParams",
",",
"queryParams",
",",
"headerParams",
",",
"formParams",
",",
"postBody",
",",
"authNames",
",",
"contentTypes",
",",
"accepts",
",",
"returnType",
",",
"callback",
")",
";",
"}",
"/**\n * Callback function to receive the result of the findSessions operation.\n * @callback module:api/SessionApi~findSessionsCallback\n * @param {String} error Error message, if any.\n * @param {Array.<module:model/Session>} data The data returned by the service call.\n * @param {String} response The complete HTTP response.\n */",
"/**\n * Finds webida sessions established to server. if session id is given, matched session info will be returned and workspace id parameter will be ignored. To find all sessions of some workspace, set session id to '*' and specify workspace id. This operation requires proper accsss rights. 1) To find all sessions, an unrestricted token is required. 2) To find some workspace sesions, token should have proper access right on the workspace. \n * @param {String} sessionId webida session id (usually different from socket id from sock.io)\n * @param {String} workspaceId webida workspace id in query part\n * @param {module:api/SessionApi~findSessionsCallback} callback The callback function, accepting three arguments: error, data, response\n * data is of type: {Array.<module:model/Session>}\n */",
"this",
".",
"findSessions",
"=",
"function",
"(",
"sessionId",
",",
"workspaceId",
",",
"callback",
")",
"{",
"var",
"postBody",
"=",
"null",
";",
"// verify the required parameter 'sessionId' is set",
"if",
"(",
"sessionId",
"==",
"undefined",
"||",
"sessionId",
"==",
"null",
")",
"{",
"throw",
"\"Missing the required parameter 'sessionId' when calling findSessions\"",
";",
"}",
"// verify the required parameter 'workspaceId' is set",
"if",
"(",
"workspaceId",
"==",
"undefined",
"||",
"workspaceId",
"==",
"null",
")",
"{",
"throw",
"\"Missing the required parameter 'workspaceId' when calling findSessions\"",
";",
"}",
"var",
"pathParams",
"=",
"{",
"'sessionId'",
":",
"sessionId",
"}",
";",
"var",
"queryParams",
"=",
"{",
"'workspaceId'",
":",
"workspaceId",
"}",
";",
"var",
"headerParams",
"=",
"{",
"}",
";",
"var",
"formParams",
"=",
"{",
"}",
";",
"var",
"authNames",
"=",
"[",
"'webida-simple-auth'",
"]",
";",
"var",
"contentTypes",
"=",
"[",
"'application/json'",
"]",
";",
"var",
"accepts",
"=",
"[",
"'application/json'",
",",
"'application/octet-stream'",
"]",
";",
"var",
"returnType",
"=",
"[",
"Session",
"]",
";",
"return",
"this",
".",
"apiClient",
".",
"callApi",
"(",
"'/sessions/{sessionId}'",
",",
"'GET'",
",",
"pathParams",
",",
"queryParams",
",",
"headerParams",
",",
"formParams",
",",
"postBody",
",",
"authNames",
",",
"contentTypes",
",",
"accepts",
",",
"returnType",
",",
"callback",
")",
";",
"}",
"}"
]
| Session service.
@module api/SessionApi
@version 0.7.1
Constructs a new SessionApi.
@alias module:api/SessionApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"Session",
"service",
"."
]
| a14385ebe0de025b66fd4ee9655e962313528e28 | https://github.com/webida/webida-restful-api/blob/a14385ebe0de025b66fd4ee9655e962313528e28/src/api/SessionApi.js#L55-L169 |
|
45,534 | yo-components/yo-utils | lib/templating.js | relativePathTo | function relativePathTo(from, to, strip) {
var relPath = path.relative(from.replace(path.basename(from), ''), to);
if (relPath.match(/^\.\.?(\/|\\)/) === null) { relPath = './' + relPath; }
if (strip) { return relPath.replace(/((\/|\\)index\.js|\.js)$/, ''); }
return relPath;
} | javascript | function relativePathTo(from, to, strip) {
var relPath = path.relative(from.replace(path.basename(from), ''), to);
if (relPath.match(/^\.\.?(\/|\\)/) === null) { relPath = './' + relPath; }
if (strip) { return relPath.replace(/((\/|\\)index\.js|\.js)$/, ''); }
return relPath;
} | [
"function",
"relativePathTo",
"(",
"from",
",",
"to",
",",
"strip",
")",
"{",
"var",
"relPath",
"=",
"path",
".",
"relative",
"(",
"from",
".",
"replace",
"(",
"path",
".",
"basename",
"(",
"from",
")",
",",
"''",
")",
",",
"to",
")",
";",
"if",
"(",
"relPath",
".",
"match",
"(",
"/",
"^\\.\\.?(\\/|\\\\)",
"/",
")",
"===",
"null",
")",
"{",
"relPath",
"=",
"'./'",
"+",
"relPath",
";",
"}",
"if",
"(",
"strip",
")",
"{",
"return",
"relPath",
".",
"replace",
"(",
"/",
"((\\/|\\\\)index\\.js|\\.js)$",
"/",
",",
"''",
")",
";",
"}",
"return",
"relPath",
";",
"}"
]
| Templating related utilities
@module yo-utils/lib/templating
Returns a relative path used to require the 'to' file in the 'from' file
@alias module:yo-utils/lib/templating.relativePathTo
@param {String} from - file path to the from file
@param {String} to - file path to the to file
@param {Boolean} strip - whether to strip the index file name and/or the js ext
@return {String} - relative path to be used in require statements | [
"Templating",
"related",
"utilities"
]
| 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L26-L31 |
45,535 | yo-components/yo-utils | lib/templating.js | filterFile | function filterFile(template) {
// Find matches for parans
var filterMatches = template.match(/\(([^)]+)\)/g);
var filters = [];
if (filterMatches) {
filterMatches.forEach(function(filter) {
filters.push(filter.replace('(', '').replace(')', ''));
template = template.replace(filter, '');
});
}
return { name: template, filters: filters };
} | javascript | function filterFile(template) {
// Find matches for parans
var filterMatches = template.match(/\(([^)]+)\)/g);
var filters = [];
if (filterMatches) {
filterMatches.forEach(function(filter) {
filters.push(filter.replace('(', '').replace(')', ''));
template = template.replace(filter, '');
});
}
return { name: template, filters: filters };
} | [
"function",
"filterFile",
"(",
"template",
")",
"{",
"// Find matches for parans",
"var",
"filterMatches",
"=",
"template",
".",
"match",
"(",
"/",
"\\(([^)]+)\\)",
"/",
"g",
")",
";",
"var",
"filters",
"=",
"[",
"]",
";",
"if",
"(",
"filterMatches",
")",
"{",
"filterMatches",
".",
"forEach",
"(",
"function",
"(",
"filter",
")",
"{",
"filters",
".",
"push",
"(",
"filter",
".",
"replace",
"(",
"'('",
",",
"''",
")",
".",
"replace",
"(",
"')'",
",",
"''",
")",
")",
";",
"template",
"=",
"template",
".",
"replace",
"(",
"filter",
",",
"''",
")",
";",
"}",
")",
";",
"}",
"return",
"{",
"name",
":",
"template",
",",
"filters",
":",
"filters",
"}",
";",
"}"
]
| Parse a filtered filename and return the processed name and filters
@param {String} template - the file path to the template
@return {Object} - contains the processed name and filters array | [
"Parse",
"a",
"filtered",
"filename",
"and",
"return",
"the",
"processed",
"name",
"and",
"filters"
]
| 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L161-L173 |
45,536 | yo-components/yo-utils | lib/templating.js | templateIsUsable | function templateIsUsable(self, filteredFile) {
var filters = self.config.get('filters');
var enabledFilters = [];
for (var key in filters) {
if (filters[key]) { enabledFilters.push(key); }
}
var matchedFilters = self._.intersection(filteredFile.filters, enabledFilters);
// check that all filters on file are matched
if (filteredFile.filters.length && matchedFilters.length !== filteredFile.filters.length) {
return false;
}
return true;
} | javascript | function templateIsUsable(self, filteredFile) {
var filters = self.config.get('filters');
var enabledFilters = [];
for (var key in filters) {
if (filters[key]) { enabledFilters.push(key); }
}
var matchedFilters = self._.intersection(filteredFile.filters, enabledFilters);
// check that all filters on file are matched
if (filteredFile.filters.length && matchedFilters.length !== filteredFile.filters.length) {
return false;
}
return true;
} | [
"function",
"templateIsUsable",
"(",
"self",
",",
"filteredFile",
")",
"{",
"var",
"filters",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'filters'",
")",
";",
"var",
"enabledFilters",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"filters",
")",
"{",
"if",
"(",
"filters",
"[",
"key",
"]",
")",
"{",
"enabledFilters",
".",
"push",
"(",
"key",
")",
";",
"}",
"}",
"var",
"matchedFilters",
"=",
"self",
".",
"_",
".",
"intersection",
"(",
"filteredFile",
".",
"filters",
",",
"enabledFilters",
")",
";",
"// check that all filters on file are matched",
"if",
"(",
"filteredFile",
".",
"filters",
".",
"length",
"&&",
"matchedFilters",
".",
"length",
"!==",
"filteredFile",
".",
"filters",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Check whether or not a template is usable based on filters
@param {Object} self - the generator
@param {Object} filteredFile - the processed template object
@return {Boolean} - whether the template is usable based on filters | [
"Check",
"whether",
"or",
"not",
"a",
"template",
"is",
"usable",
"based",
"on",
"filters"
]
| 975801cee23886debf0b43e43cd76e43705f321d | https://github.com/yo-components/yo-utils/blob/975801cee23886debf0b43e43cd76e43705f321d/lib/templating.js#L181-L193 |
45,537 | synder/xpress | demo/content-disposition/index.js | format | function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
throw new TypeError('invalid type')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof parameters === 'object') {
var param
var params = Object.keys(parameters).sort()
for (var i = 0; i < params.length; i++) {
param = params[i]
var val = param.substr(-1) === '*'
? ustring(parameters[param])
: qstring(parameters[param])
string += '; ' + param + '=' + val
}
}
return string
} | javascript | function format(obj) {
var parameters = obj.parameters
var type = obj.type
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
throw new TypeError('invalid type')
}
// start with normalized type
var string = String(type).toLowerCase()
// append parameters
if (parameters && typeof parameters === 'object') {
var param
var params = Object.keys(parameters).sort()
for (var i = 0; i < params.length; i++) {
param = params[i]
var val = param.substr(-1) === '*'
? ustring(parameters[param])
: qstring(parameters[param])
string += '; ' + param + '=' + val
}
}
return string
} | [
"function",
"format",
"(",
"obj",
")",
"{",
"var",
"parameters",
"=",
"obj",
".",
"parameters",
"var",
"type",
"=",
"obj",
".",
"type",
"if",
"(",
"!",
"type",
"||",
"typeof",
"type",
"!==",
"'string'",
"||",
"!",
"tokenRegExp",
".",
"test",
"(",
"type",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'invalid type'",
")",
"}",
"// start with normalized type",
"var",
"string",
"=",
"String",
"(",
"type",
")",
".",
"toLowerCase",
"(",
")",
"// append parameters",
"if",
"(",
"parameters",
"&&",
"typeof",
"parameters",
"===",
"'object'",
")",
"{",
"var",
"param",
"var",
"params",
"=",
"Object",
".",
"keys",
"(",
"parameters",
")",
".",
"sort",
"(",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"++",
")",
"{",
"param",
"=",
"params",
"[",
"i",
"]",
"var",
"val",
"=",
"param",
".",
"substr",
"(",
"-",
"1",
")",
"===",
"'*'",
"?",
"ustring",
"(",
"parameters",
"[",
"param",
"]",
")",
":",
"qstring",
"(",
"parameters",
"[",
"param",
"]",
")",
"string",
"+=",
"'; '",
"+",
"param",
"+",
"'='",
"+",
"val",
"}",
"}",
"return",
"string",
"}"
]
| Format object to Content-Disposition header.
@param {object} obj
@param {string} obj.type
@param {object} [obj.parameters]
@return {string}
@api private | [
"Format",
"object",
"to",
"Content",
"-",
"Disposition",
"header",
"."
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/content-disposition/index.js#L216-L244 |
45,538 | synder/xpress | demo/content-disposition/index.js | pencode | function pencode(char) {
var hex = String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
} | javascript | function pencode(char) {
var hex = String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
return hex.length === 1
? '%0' + hex
: '%' + hex
} | [
"function",
"pencode",
"(",
"char",
")",
"{",
"var",
"hex",
"=",
"String",
"(",
"char",
")",
".",
"charCodeAt",
"(",
"0",
")",
".",
"toString",
"(",
"16",
")",
".",
"toUpperCase",
"(",
")",
"return",
"hex",
".",
"length",
"===",
"1",
"?",
"'%0'",
"+",
"hex",
":",
"'%'",
"+",
"hex",
"}"
]
| Percent encode a single character.
@param {string} char
@return {string}
@api private | [
"Percent",
"encode",
"a",
"single",
"character",
"."
]
| 4b1e89208b6f34cd78ce90b8a858592115b6ccb5 | https://github.com/synder/xpress/blob/4b1e89208b6f34cd78ce90b8a858592115b6ccb5/demo/content-disposition/index.js#L396-L404 |
45,539 | nodejitsu/contour | index.js | Contour | function Contour(options) {
var contour = this
, assets;
this.fuse();
//
// Add the pagelets of the required framework.
//
options = options || {};
//
// Load and optimize the pagelets, extend contour but acknowledge external
// listeners when all pagelets have been fully initialized.
//
assets = new Assets(options.brand, options.mode || 'bigpipe');
assets.on('optimized', this.emits('init'));
this.mixin(this, assets);
} | javascript | function Contour(options) {
var contour = this
, assets;
this.fuse();
//
// Add the pagelets of the required framework.
//
options = options || {};
//
// Load and optimize the pagelets, extend contour but acknowledge external
// listeners when all pagelets have been fully initialized.
//
assets = new Assets(options.brand, options.mode || 'bigpipe');
assets.on('optimized', this.emits('init'));
this.mixin(this, assets);
} | [
"function",
"Contour",
"(",
"options",
")",
"{",
"var",
"contour",
"=",
"this",
",",
"assets",
";",
"this",
".",
"fuse",
"(",
")",
";",
"//",
"// Add the pagelets of the required framework.",
"//",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"//",
"// Load and optimize the pagelets, extend contour but acknowledge external",
"// listeners when all pagelets have been fully initialized.",
"//",
"assets",
"=",
"new",
"Assets",
"(",
"options",
".",
"brand",
",",
"options",
".",
"mode",
"||",
"'bigpipe'",
")",
";",
"assets",
".",
"on",
"(",
"'optimized'",
",",
"this",
".",
"emits",
"(",
"'init'",
")",
")",
";",
"this",
".",
"mixin",
"(",
"this",
",",
"assets",
")",
";",
"}"
]
| Contour will register several default HTML5 templates of Nodejitsu. These
templates can used from inside views of other projects.
Options that can be supplied
- brand {String} framework or brand to use, e.g nodejitsu or opsmezzo
- mode {String} bigpipe or standalone, defaults to bigpipe
@Constructor
@param {Object} options optional, see above
@api public | [
"Contour",
"will",
"register",
"several",
"default",
"HTML5",
"templates",
"of",
"Nodejitsu",
".",
"These",
"templates",
"can",
"used",
"from",
"inside",
"views",
"of",
"other",
"projects",
"."
]
| 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/index.js#L25-L43 |
45,540 | NiklasGollenstede/pbq | require.js | defaultGetCallingScript | function defaultGetCallingScript(offset = 0) {
const stack = (new Error).stack.split(/$/m);
const line = stack[(/^Error/).test(stack[0]) + 1 + offset];
const parts = line.split(/@(?![^/]*?\.xpi)|\(|\s+/g);
return parts[parts.length - 1].replace(/:\d+(?::\d+)?\)?$/, '');
} | javascript | function defaultGetCallingScript(offset = 0) {
const stack = (new Error).stack.split(/$/m);
const line = stack[(/^Error/).test(stack[0]) + 1 + offset];
const parts = line.split(/@(?![^/]*?\.xpi)|\(|\s+/g);
return parts[parts.length - 1].replace(/:\d+(?::\d+)?\)?$/, '');
} | [
"function",
"defaultGetCallingScript",
"(",
"offset",
"=",
"0",
")",
"{",
"const",
"stack",
"=",
"(",
"new",
"Error",
")",
".",
"stack",
".",
"split",
"(",
"/",
"$",
"/",
"m",
")",
";",
"const",
"line",
"=",
"stack",
"[",
"(",
"/",
"^Error",
"/",
")",
".",
"test",
"(",
"stack",
"[",
"0",
"]",
")",
"+",
"1",
"+",
"offset",
"]",
";",
"const",
"parts",
"=",
"line",
".",
"split",
"(",
"/",
"@(?![^/]*?\\.xpi)|\\(|\\s+",
"/",
"g",
")",
";",
"return",
"parts",
"[",
"parts",
".",
"length",
"-",
"1",
"]",
".",
"replace",
"(",
"/",
":\\d+(?::\\d+)?\\)?$",
"/",
",",
"''",
")",
";",
"}"
]
| the other values in `loadConfig` will be interpreted later
string parsers | [
"the",
"other",
"values",
"in",
"loadConfig",
"will",
"be",
"interpreted",
"later",
"string",
"parsers"
]
| bf63f17d63dc6030567a94a61490bec6254d3064 | https://github.com/NiklasGollenstede/pbq/blob/bf63f17d63dc6030567a94a61490bec6254d3064/require.js#L62-L67 |
45,541 | NiklasGollenstede/pbq | require.js | next | function next(exp) {
exp.lastIndex = index;
const match = exp.exec(code)[0];
index = exp.lastIndex;
return match;
} | javascript | function next(exp) {
exp.lastIndex = index;
const match = exp.exec(code)[0];
index = exp.lastIndex;
return match;
} | [
"function",
"next",
"(",
"exp",
")",
"{",
"exp",
".",
"lastIndex",
"=",
"index",
";",
"const",
"match",
"=",
"exp",
".",
"exec",
"(",
"code",
")",
"[",
"0",
"]",
";",
"index",
"=",
"exp",
".",
"lastIndex",
";",
"return",
"match",
";",
"}"
]
| the next position of interest | [
"the",
"next",
"position",
"of",
"interest"
]
| bf63f17d63dc6030567a94a61490bec6254d3064 | https://github.com/NiklasGollenstede/pbq/blob/bf63f17d63dc6030567a94a61490bec6254d3064/require.js#L77-L82 |
45,542 | nodejitsu/contour | assets.js | Assets | function Assets(brand, mode) {
var readable = Assets.predefine(this, Assets.predefine.READABLE)
, enumerable = Assets.predefine(this, { configurable: false })
, self = this
, i = 0
, files;
/**
* Callback to emit optimized event after all Pagelets have been optimized.
*
* @param {Error} error
* @api private
*/
function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
}
//
// Default framework to use with reference to the path to core.styl.
//
readable('brand', brand = brand || 'nodejitsu');
//
// Load all assets of the branch.
//
(files = fs.readdirSync(assets)).forEach(function include(file) {
if ('.js' !== path.extname(file) || ~file.indexOf('pagelet')) return;
//
// Create getter for each pagelet in assets.
//
var Pagelet = require(path.join(assets, file));
enumerable(path.basename(file, '.js'), {
enumerable: true,
value: Pagelet.brand(self.brand, mode === 'standalone', next)
}, true);
});
} | javascript | function Assets(brand, mode) {
var readable = Assets.predefine(this, Assets.predefine.READABLE)
, enumerable = Assets.predefine(this, { configurable: false })
, self = this
, i = 0
, files;
/**
* Callback to emit optimized event after all Pagelets have been optimized.
*
* @param {Error} error
* @api private
*/
function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
}
//
// Default framework to use with reference to the path to core.styl.
//
readable('brand', brand = brand || 'nodejitsu');
//
// Load all assets of the branch.
//
(files = fs.readdirSync(assets)).forEach(function include(file) {
if ('.js' !== path.extname(file) || ~file.indexOf('pagelet')) return;
//
// Create getter for each pagelet in assets.
//
var Pagelet = require(path.join(assets, file));
enumerable(path.basename(file, '.js'), {
enumerable: true,
value: Pagelet.brand(self.brand, mode === 'standalone', next)
}, true);
});
} | [
"function",
"Assets",
"(",
"brand",
",",
"mode",
")",
"{",
"var",
"readable",
"=",
"Assets",
".",
"predefine",
"(",
"this",
",",
"Assets",
".",
"predefine",
".",
"READABLE",
")",
",",
"enumerable",
"=",
"Assets",
".",
"predefine",
"(",
"this",
",",
"{",
"configurable",
":",
"false",
"}",
")",
",",
"self",
"=",
"this",
",",
"i",
"=",
"0",
",",
"files",
";",
"/**\n * Callback to emit optimized event after all Pagelets have been optimized.\n *\n * @param {Error} error\n * @api private\n */",
"function",
"next",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"return",
"self",
".",
"emit",
"(",
"'error'",
",",
"error",
")",
";",
"if",
"(",
"++",
"i",
"===",
"files",
".",
"length",
")",
"self",
".",
"emit",
"(",
"'optimized'",
")",
";",
"}",
"//",
"// Default framework to use with reference to the path to core.styl.",
"//",
"readable",
"(",
"'brand'",
",",
"brand",
"=",
"brand",
"||",
"'nodejitsu'",
")",
";",
"//",
"// Load all assets of the branch.",
"//",
"(",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"assets",
")",
")",
".",
"forEach",
"(",
"function",
"include",
"(",
"file",
")",
"{",
"if",
"(",
"'.js'",
"!==",
"path",
".",
"extname",
"(",
"file",
")",
"||",
"~",
"file",
".",
"indexOf",
"(",
"'pagelet'",
")",
")",
"return",
";",
"//",
"// Create getter for each pagelet in assets.",
"//",
"var",
"Pagelet",
"=",
"require",
"(",
"path",
".",
"join",
"(",
"assets",
",",
"file",
")",
")",
";",
"enumerable",
"(",
"path",
".",
"basename",
"(",
"file",
",",
"'.js'",
")",
",",
"{",
"enumerable",
":",
"true",
",",
"value",
":",
"Pagelet",
".",
"brand",
"(",
"self",
".",
"brand",
",",
"mode",
"===",
"'standalone'",
",",
"next",
")",
"}",
",",
"true",
")",
";",
"}",
")",
";",
"}"
]
| Create new collection of assets from a specific brand.
@param {String} brand nodejitsu by default.
@param {String} mode standalone || bigpipe, defaults to bigpipe.
@api public | [
"Create",
"new",
"collection",
"of",
"assets",
"from",
"a",
"specific",
"brand",
"."
]
| 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/assets.js#L23-L61 |
45,543 | nodejitsu/contour | assets.js | next | function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
} | javascript | function next(error) {
if (error) return self.emit('error', error);
if (++i === files.length) self.emit('optimized');
} | [
"function",
"next",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"return",
"self",
".",
"emit",
"(",
"'error'",
",",
"error",
")",
";",
"if",
"(",
"++",
"i",
"===",
"files",
".",
"length",
")",
"self",
".",
"emit",
"(",
"'optimized'",
")",
";",
"}"
]
| Callback to emit optimized event after all Pagelets have been optimized.
@param {Error} error
@api private | [
"Callback",
"to",
"emit",
"optimized",
"event",
"after",
"all",
"Pagelets",
"have",
"been",
"optimized",
"."
]
| 0828e9bd25ef1eeb97ea231c447118d9867021b6 | https://github.com/nodejitsu/contour/blob/0828e9bd25ef1eeb97ea231c447118d9867021b6/assets.js#L36-L39 |
45,544 | jillix/flow-api | lib/_remove.js | getIn | function getIn (client, from, nodes, callback, remove) {
remove = remove || [];
const outNodes = [];
const nodeIndex = {};
const fromIndex = {};
if (from instanceof Array) {
from.forEach((node) => {fromIndex[node] = true});
} else {
from = null;
}
nodes.forEach((node) => {nodeIndex[node] = true});
client.g.V.apply(client.g, nodes).Tag('o').In(null, 'p').All((err, result) => {
if (err = error(err, result, true)) {
return callback(err);
}
if (result) {
result.forEach((triple) => {
// TODO collect subject (triple.id) for: subject > next > object
// escape quotes
let object = triple.o;
if (triple.o.indexOf('"') > -1) {
triple.o = triple.o.replace(/"/g, '\\"')
}
// remove from > p > node triples
if (!from || fromIndex[triple.id]) {
remove.push({
subject: triple.id,
predicate: triple.p,
object: triple.o
});
// don't delete nodes with more then one in connections
} else {
nodeIndex[object] = false;
}
});
for (let node in nodeIndex) {
if (nodeIndex[node]) {
if (node.indexOf('"') > -1) {
node = node.replace(/"/g, '\\"');
}
outNodes.push(node);
}
};
}
callback(null, outNodes, remove);
});
} | javascript | function getIn (client, from, nodes, callback, remove) {
remove = remove || [];
const outNodes = [];
const nodeIndex = {};
const fromIndex = {};
if (from instanceof Array) {
from.forEach((node) => {fromIndex[node] = true});
} else {
from = null;
}
nodes.forEach((node) => {nodeIndex[node] = true});
client.g.V.apply(client.g, nodes).Tag('o').In(null, 'p').All((err, result) => {
if (err = error(err, result, true)) {
return callback(err);
}
if (result) {
result.forEach((triple) => {
// TODO collect subject (triple.id) for: subject > next > object
// escape quotes
let object = triple.o;
if (triple.o.indexOf('"') > -1) {
triple.o = triple.o.replace(/"/g, '\\"')
}
// remove from > p > node triples
if (!from || fromIndex[triple.id]) {
remove.push({
subject: triple.id,
predicate: triple.p,
object: triple.o
});
// don't delete nodes with more then one in connections
} else {
nodeIndex[object] = false;
}
});
for (let node in nodeIndex) {
if (nodeIndex[node]) {
if (node.indexOf('"') > -1) {
node = node.replace(/"/g, '\\"');
}
outNodes.push(node);
}
};
}
callback(null, outNodes, remove);
});
} | [
"function",
"getIn",
"(",
"client",
",",
"from",
",",
"nodes",
",",
"callback",
",",
"remove",
")",
"{",
"remove",
"=",
"remove",
"||",
"[",
"]",
";",
"const",
"outNodes",
"=",
"[",
"]",
";",
"const",
"nodeIndex",
"=",
"{",
"}",
";",
"const",
"fromIndex",
"=",
"{",
"}",
";",
"if",
"(",
"from",
"instanceof",
"Array",
")",
"{",
"from",
".",
"forEach",
"(",
"(",
"node",
")",
"=>",
"{",
"fromIndex",
"[",
"node",
"]",
"=",
"true",
"}",
")",
";",
"}",
"else",
"{",
"from",
"=",
"null",
";",
"}",
"nodes",
".",
"forEach",
"(",
"(",
"node",
")",
"=>",
"{",
"nodeIndex",
"[",
"node",
"]",
"=",
"true",
"}",
")",
";",
"client",
".",
"g",
".",
"V",
".",
"apply",
"(",
"client",
".",
"g",
",",
"nodes",
")",
".",
"Tag",
"(",
"'o'",
")",
".",
"In",
"(",
"null",
",",
"'p'",
")",
".",
"All",
"(",
"(",
"err",
",",
"result",
")",
"=>",
"{",
"if",
"(",
"err",
"=",
"error",
"(",
"err",
",",
"result",
",",
"true",
")",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"if",
"(",
"result",
")",
"{",
"result",
".",
"forEach",
"(",
"(",
"triple",
")",
"=>",
"{",
"// TODO collect subject (triple.id) for: subject > next > object",
"// escape quotes",
"let",
"object",
"=",
"triple",
".",
"o",
";",
"if",
"(",
"triple",
".",
"o",
".",
"indexOf",
"(",
"'\"'",
")",
">",
"-",
"1",
")",
"{",
"triple",
".",
"o",
"=",
"triple",
".",
"o",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"'\\\\\"'",
")",
"}",
"// remove from > p > node triples",
"if",
"(",
"!",
"from",
"||",
"fromIndex",
"[",
"triple",
".",
"id",
"]",
")",
"{",
"remove",
".",
"push",
"(",
"{",
"subject",
":",
"triple",
".",
"id",
",",
"predicate",
":",
"triple",
".",
"p",
",",
"object",
":",
"triple",
".",
"o",
"}",
")",
";",
"// don't delete nodes with more then one in connections",
"}",
"else",
"{",
"nodeIndex",
"[",
"object",
"]",
"=",
"false",
";",
"}",
"}",
")",
";",
"for",
"(",
"let",
"node",
"in",
"nodeIndex",
")",
"{",
"if",
"(",
"nodeIndex",
"[",
"node",
"]",
")",
"{",
"if",
"(",
"node",
".",
"indexOf",
"(",
"'\"'",
")",
">",
"-",
"1",
")",
"{",
"node",
"=",
"node",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"'\\\\\"'",
")",
";",
"}",
"outNodes",
".",
"push",
"(",
"node",
")",
";",
"}",
"}",
";",
"}",
"callback",
"(",
"null",
",",
"outNodes",
",",
"remove",
")",
";",
"}",
")",
";",
"}"
]
| -> from network | [
"-",
">",
"from",
"network"
]
| 8c80bacbd6ab27a72000dbeaf454800e8e817efa | https://github.com/jillix/flow-api/blob/8c80bacbd6ab27a72000dbeaf454800e8e817efa/lib/_remove.js#L157-L216 |
45,545 | FinalDevStudio/fi-khipu | lib/index.js | createPayment | function createPayment(data, callback) {
var client = new this.clients.Payments();
client.create(data, callback);
} | javascript | function createPayment(data, callback) {
var client = new this.clients.Payments();
client.create(data, callback);
} | [
"function",
"createPayment",
"(",
"data",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"create",
"(",
"data",
",",
"callback",
")",
";",
"}"
]
| Creates a new payment.
@param {Object} data - The payment fields.
@param {Function} callback - The callback method. | [
"Creates",
"a",
"new",
"payment",
"."
]
| 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L49-L52 |
45,546 | FinalDevStudio/fi-khipu | lib/index.js | getPaymentById | function getPaymentById(id, callback) {
var client = new this.clients.Payments();
client.getById(id, callback);
} | javascript | function getPaymentById(id, callback) {
var client = new this.clients.Payments();
client.getById(id, callback);
} | [
"function",
"getPaymentById",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"getById",
"(",
"id",
",",
"callback",
")",
";",
"}"
]
| Obtains a payment by its ID.
@param {String} id - The payment ID.
@param {Function} callback - The callback method. | [
"Obtains",
"a",
"payment",
"by",
"its",
"ID",
"."
]
| 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L60-L63 |
45,547 | FinalDevStudio/fi-khipu | lib/index.js | getPaymentByNotificationToken | function getPaymentByNotificationToken(token, callback) {
var client = new this.clients.Payments();
client.getByNotificationToken(token, callback);
} | javascript | function getPaymentByNotificationToken(token, callback) {
var client = new this.clients.Payments();
client.getByNotificationToken(token, callback);
} | [
"function",
"getPaymentByNotificationToken",
"(",
"token",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"getByNotificationToken",
"(",
"token",
",",
"callback",
")",
";",
"}"
]
| Obtains a payment by its notification token.
@param {String} id - The payment ID.
@param {Function} callback - The callback method. | [
"Obtains",
"a",
"payment",
"by",
"its",
"notification",
"token",
"."
]
| 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L71-L74 |
45,548 | FinalDevStudio/fi-khipu | lib/index.js | refundPayment | function refundPayment(id, callback) {
var client = new this.clients.Payments();
client.refund(id, callback);
} | javascript | function refundPayment(id, callback) {
var client = new this.clients.Payments();
client.refund(id, callback);
} | [
"function",
"refundPayment",
"(",
"id",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"new",
"this",
".",
"clients",
".",
"Payments",
"(",
")",
";",
"client",
".",
"refund",
"(",
"id",
",",
"callback",
")",
";",
"}"
]
| Refunds a payment by its ID.
@param {String} id - The payment's ID.
@param {Function} callback - The callback method. | [
"Refunds",
"a",
"payment",
"by",
"its",
"ID",
"."
]
| 76f5ec38e88dc2053502c320e309b74039b4d517 | https://github.com/FinalDevStudio/fi-khipu/blob/76f5ec38e88dc2053502c320e309b74039b4d517/lib/index.js#L82-L85 |
45,549 | linyngfly/omelo-scheduler | lib/cronTrigger.js | function(trigger, job){
this.trigger = this.decodeTrigger(trigger);
this.nextTime = this.nextExcuteTime(Date.now());
this.job = job;
} | javascript | function(trigger, job){
this.trigger = this.decodeTrigger(trigger);
this.nextTime = this.nextExcuteTime(Date.now());
this.job = job;
} | [
"function",
"(",
"trigger",
",",
"job",
")",
"{",
"this",
".",
"trigger",
"=",
"this",
".",
"decodeTrigger",
"(",
"trigger",
")",
";",
"this",
".",
"nextTime",
"=",
"this",
".",
"nextExcuteTime",
"(",
"Date",
".",
"now",
"(",
")",
")",
";",
"this",
".",
"job",
"=",
"job",
";",
"}"
]
| The constructor of the CronTrigger
@param trigger The trigger str used to build the cronTrigger instance | [
"The",
"constructor",
"of",
"the",
"CronTrigger"
]
| aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L19-L25 |
|
45,550 | linyngfly/omelo-scheduler | lib/cronTrigger.js | timeMatch | function timeMatch(value, cronTime){
if(typeof(cronTime) == 'number'){
if(cronTime == -1)
return true;
if(value == cronTime)
return true;
return false;
}else if(typeof(cronTime) == 'object' && cronTime instanceof Array){
if(value < cronTime[0] || value > cronTime[cronTime.length -1])
return false;
for(let i = 0; i < cronTime.length; i++)
if(value == cronTime[i])
return true;
return false;
}
return null;
} | javascript | function timeMatch(value, cronTime){
if(typeof(cronTime) == 'number'){
if(cronTime == -1)
return true;
if(value == cronTime)
return true;
return false;
}else if(typeof(cronTime) == 'object' && cronTime instanceof Array){
if(value < cronTime[0] || value > cronTime[cronTime.length -1])
return false;
for(let i = 0; i < cronTime.length; i++)
if(value == cronTime[i])
return true;
return false;
}
return null;
} | [
"function",
"timeMatch",
"(",
"value",
",",
"cronTime",
")",
"{",
"if",
"(",
"typeof",
"(",
"cronTime",
")",
"==",
"'number'",
")",
"{",
"if",
"(",
"cronTime",
"==",
"-",
"1",
")",
"return",
"true",
";",
"if",
"(",
"value",
"==",
"cronTime",
")",
"return",
"true",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"typeof",
"(",
"cronTime",
")",
"==",
"'object'",
"&&",
"cronTime",
"instanceof",
"Array",
")",
"{",
"if",
"(",
"value",
"<",
"cronTime",
"[",
"0",
"]",
"||",
"value",
">",
"cronTime",
"[",
"cronTime",
".",
"length",
"-",
"1",
"]",
")",
"return",
"false",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"cronTime",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"value",
"==",
"cronTime",
"[",
"i",
"]",
")",
"return",
"true",
";",
"return",
"false",
";",
"}",
"return",
"null",
";",
"}"
]
| Match the given value to the cronTime
@param value The given value
@param cronTime The cronTime
@return The match result | [
"Match",
"the",
"given",
"value",
"to",
"the",
"cronTime"
]
| aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L186-L205 |
45,551 | linyngfly/omelo-scheduler | lib/cronTrigger.js | decodeRangeTime | function decodeRangeTime(map, timeStr){
let times = timeStr.split('-');
times[0] = Number(times[0]);
times[1] = Number(times[1]);
if(times[0] > times[1]){
console.log("Error time range");
return null;
}
for(let i = times[0]; i <= times[1]; i++){
map[i] = i;
}
} | javascript | function decodeRangeTime(map, timeStr){
let times = timeStr.split('-');
times[0] = Number(times[0]);
times[1] = Number(times[1]);
if(times[0] > times[1]){
console.log("Error time range");
return null;
}
for(let i = times[0]; i <= times[1]; i++){
map[i] = i;
}
} | [
"function",
"decodeRangeTime",
"(",
"map",
",",
"timeStr",
")",
"{",
"let",
"times",
"=",
"timeStr",
".",
"split",
"(",
"'-'",
")",
";",
"times",
"[",
"0",
"]",
"=",
"Number",
"(",
"times",
"[",
"0",
"]",
")",
";",
"times",
"[",
"1",
"]",
"=",
"Number",
"(",
"times",
"[",
"1",
"]",
")",
";",
"if",
"(",
"times",
"[",
"0",
"]",
">",
"times",
"[",
"1",
"]",
")",
"{",
"console",
".",
"log",
"(",
"\"Error time range\"",
")",
";",
"return",
"null",
";",
"}",
"for",
"(",
"let",
"i",
"=",
"times",
"[",
"0",
"]",
";",
"i",
"<=",
"times",
"[",
"1",
"]",
";",
"i",
"++",
")",
"{",
"map",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"}"
]
| Decode time range
@param map The decode map
@param timeStr The range string, like 2-5 | [
"Decode",
"time",
"range"
]
| aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L285-L298 |
45,552 | linyngfly/omelo-scheduler | lib/cronTrigger.js | decodePeriodTime | function decodePeriodTime(map, timeStr, type){
let times = timeStr.split('/');
let min = Limit[type][0];
let max = Limit[type][1];
let remind = Number(times[0]);
let period = Number(times[1]);
if(period==0)
return;
for(let i = min; i <= max; i++){
if(i%period == remind)
map[i] = i;
}
} | javascript | function decodePeriodTime(map, timeStr, type){
let times = timeStr.split('/');
let min = Limit[type][0];
let max = Limit[type][1];
let remind = Number(times[0]);
let period = Number(times[1]);
if(period==0)
return;
for(let i = min; i <= max; i++){
if(i%period == remind)
map[i] = i;
}
} | [
"function",
"decodePeriodTime",
"(",
"map",
",",
"timeStr",
",",
"type",
")",
"{",
"let",
"times",
"=",
"timeStr",
".",
"split",
"(",
"'/'",
")",
";",
"let",
"min",
"=",
"Limit",
"[",
"type",
"]",
"[",
"0",
"]",
";",
"let",
"max",
"=",
"Limit",
"[",
"type",
"]",
"[",
"1",
"]",
";",
"let",
"remind",
"=",
"Number",
"(",
"times",
"[",
"0",
"]",
")",
";",
"let",
"period",
"=",
"Number",
"(",
"times",
"[",
"1",
"]",
")",
";",
"if",
"(",
"period",
"==",
"0",
")",
"return",
";",
"for",
"(",
"let",
"i",
"=",
"min",
";",
"i",
"<=",
"max",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"%",
"period",
"==",
"remind",
")",
"map",
"[",
"i",
"]",
"=",
"i",
";",
"}",
"}"
]
| Compute the period timer | [
"Compute",
"the",
"period",
"timer"
]
| aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L303-L318 |
45,553 | linyngfly/omelo-scheduler | lib/cronTrigger.js | checkNum | function checkNum(nums, min, max){
if(nums == null)
return false;
if(nums == -1)
return true;
for(let i = 0; i < nums.length; i++){
if(nums[i]<min || nums[i]>max)
return false;
}
return true;
} | javascript | function checkNum(nums, min, max){
if(nums == null)
return false;
if(nums == -1)
return true;
for(let i = 0; i < nums.length; i++){
if(nums[i]<min || nums[i]>max)
return false;
}
return true;
} | [
"function",
"checkNum",
"(",
"nums",
",",
"min",
",",
"max",
")",
"{",
"if",
"(",
"nums",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"nums",
"==",
"-",
"1",
")",
"return",
"true",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"nums",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"nums",
"[",
"i",
"]",
"<",
"min",
"||",
"nums",
"[",
"i",
"]",
">",
"max",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Check if the numbers are valid
@param nums The numbers array need to check
@param min Minimus value
@param max Maximam value
@return If all the numbers are in the data range | [
"Check",
"if",
"the",
"numbers",
"are",
"valid"
]
| aa7775eb2b8b31160669c8fedccd84e2108797eb | https://github.com/linyngfly/omelo-scheduler/blob/aa7775eb2b8b31160669c8fedccd84e2108797eb/lib/cronTrigger.js#L327-L340 |
45,554 | vid/SenseBase | web/lib/search.js | setupCronInput | function setupCronInput(val) {
$('input.cron').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
multiple_dow: true,
multiple_time_hours: true,
multiple_time_minutes: true,
default_period: 'week',
default_value: val || '15 12 * * 7',
no_reset_button: true,
lang: 'en'
});
} | javascript | function setupCronInput(val) {
$('input.cron').jqCron({
enabled_minute: true,
multiple_dom: true,
multiple_month: true,
multiple_mins: true,
multiple_dow: true,
multiple_time_hours: true,
multiple_time_minutes: true,
default_period: 'week',
default_value: val || '15 12 * * 7',
no_reset_button: true,
lang: 'en'
});
} | [
"function",
"setupCronInput",
"(",
"val",
")",
"{",
"$",
"(",
"'input.cron'",
")",
".",
"jqCron",
"(",
"{",
"enabled_minute",
":",
"true",
",",
"multiple_dom",
":",
"true",
",",
"multiple_month",
":",
"true",
",",
"multiple_mins",
":",
"true",
",",
"multiple_dow",
":",
"true",
",",
"multiple_time_hours",
":",
"true",
",",
"multiple_time_minutes",
":",
"true",
",",
"default_period",
":",
"'week'",
",",
"default_value",
":",
"val",
"||",
"'15 12 * * 7'",
",",
"no_reset_button",
":",
"true",
",",
"lang",
":",
"'en'",
"}",
")",
";",
"}"
]
| set up the cron scheduler input | [
"set",
"up",
"the",
"cron",
"scheduler",
"input"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L120-L134 |
45,555 | vid/SenseBase | web/lib/search.js | getSearchInput | function getSearchInput() {
var cronValue = $('#scheduleSearch').prop('checked') ? $('input.cron').val() : null, searchName = $('#searchName').val(), targetResults = $('#targetResults').val(), input = $('#searchInput').val(), searchContinue = $('#searchContinue').val(), searchCategories = $('#searchCategories').val().split(',').map(function(t) { return t.trim(); }), searchTeam = $('select.searcher.team option:selected').map(function() { return this.value; }).get();
return { searchName: searchName, cron: cronValue, input: input, relevance: searchContinue, team: searchTeam, categories: searchCategories, targetResults: targetResults, valid: (input.length > 0 && searchContinue.length > 0 && searchTeam.length > 0 && searchCategories.length > 0 && targetResults.length > 0 )};
} | javascript | function getSearchInput() {
var cronValue = $('#scheduleSearch').prop('checked') ? $('input.cron').val() : null, searchName = $('#searchName').val(), targetResults = $('#targetResults').val(), input = $('#searchInput').val(), searchContinue = $('#searchContinue').val(), searchCategories = $('#searchCategories').val().split(',').map(function(t) { return t.trim(); }), searchTeam = $('select.searcher.team option:selected').map(function() { return this.value; }).get();
return { searchName: searchName, cron: cronValue, input: input, relevance: searchContinue, team: searchTeam, categories: searchCategories, targetResults: targetResults, valid: (input.length > 0 && searchContinue.length > 0 && searchTeam.length > 0 && searchCategories.length > 0 && targetResults.length > 0 )};
} | [
"function",
"getSearchInput",
"(",
")",
"{",
"var",
"cronValue",
"=",
"$",
"(",
"'#scheduleSearch'",
")",
".",
"prop",
"(",
"'checked'",
")",
"?",
"$",
"(",
"'input.cron'",
")",
".",
"val",
"(",
")",
":",
"null",
",",
"searchName",
"=",
"$",
"(",
"'#searchName'",
")",
".",
"val",
"(",
")",
",",
"targetResults",
"=",
"$",
"(",
"'#targetResults'",
")",
".",
"val",
"(",
")",
",",
"input",
"=",
"$",
"(",
"'#searchInput'",
")",
".",
"val",
"(",
")",
",",
"searchContinue",
"=",
"$",
"(",
"'#searchContinue'",
")",
".",
"val",
"(",
")",
",",
"searchCategories",
"=",
"$",
"(",
"'#searchCategories'",
")",
".",
"val",
"(",
")",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"function",
"(",
"t",
")",
"{",
"return",
"t",
".",
"trim",
"(",
")",
";",
"}",
")",
",",
"searchTeam",
"=",
"$",
"(",
"'select.searcher.team option:selected'",
")",
".",
"map",
"(",
"function",
"(",
")",
"{",
"return",
"this",
".",
"value",
";",
"}",
")",
".",
"get",
"(",
")",
";",
"return",
"{",
"searchName",
":",
"searchName",
",",
"cron",
":",
"cronValue",
",",
"input",
":",
"input",
",",
"relevance",
":",
"searchContinue",
",",
"team",
":",
"searchTeam",
",",
"categories",
":",
"searchCategories",
",",
"targetResults",
":",
"targetResults",
",",
"valid",
":",
"(",
"input",
".",
"length",
">",
"0",
"&&",
"searchContinue",
".",
"length",
">",
"0",
"&&",
"searchTeam",
".",
"length",
">",
"0",
"&&",
"searchCategories",
".",
"length",
">",
"0",
"&&",
"targetResults",
".",
"length",
">",
"0",
")",
"}",
";",
"}"
]
| convert the form values to data | [
"convert",
"the",
"form",
"values",
"to",
"data"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L137-L140 |
45,556 | vid/SenseBase | web/lib/search.js | submitSearch | function submitSearch() {
var searchInput = getSearchInput();
// FIXME: SUI validation for select2 field
if (!searchInput.valid) {
alert('Please select team members');
return;
}
console.log('publishing', searchInput);
$('.search.message').html('Search results:');
$('.search.message').removeClass('hidden');
context.pubsub.status('queued', function(res) {
console.log(res);
var message = '';
if (res.err) {
message = res.err;
} else {
message = 'found <a target="_searchresult" href="' + res.status.uri + '">' + res.status.uri + '</a> from ' + res.status.source;
}
$('.search.message').append('<div>' + message + '</div>');
});
context.pubsub.search.queue(searchInput);
context.queryLib.setAnnotationTags($('#searchCategories').val().split(','));
context.queryLib.submitQuery();
} | javascript | function submitSearch() {
var searchInput = getSearchInput();
// FIXME: SUI validation for select2 field
if (!searchInput.valid) {
alert('Please select team members');
return;
}
console.log('publishing', searchInput);
$('.search.message').html('Search results:');
$('.search.message').removeClass('hidden');
context.pubsub.status('queued', function(res) {
console.log(res);
var message = '';
if (res.err) {
message = res.err;
} else {
message = 'found <a target="_searchresult" href="' + res.status.uri + '">' + res.status.uri + '</a> from ' + res.status.source;
}
$('.search.message').append('<div>' + message + '</div>');
});
context.pubsub.search.queue(searchInput);
context.queryLib.setAnnotationTags($('#searchCategories').val().split(','));
context.queryLib.submitQuery();
} | [
"function",
"submitSearch",
"(",
")",
"{",
"var",
"searchInput",
"=",
"getSearchInput",
"(",
")",
";",
"// FIXME: SUI validation for select2 field",
"if",
"(",
"!",
"searchInput",
".",
"valid",
")",
"{",
"alert",
"(",
"'Please select team members'",
")",
";",
"return",
";",
"}",
"console",
".",
"log",
"(",
"'publishing'",
",",
"searchInput",
")",
";",
"$",
"(",
"'.search.message'",
")",
".",
"html",
"(",
"'Search results:'",
")",
";",
"$",
"(",
"'.search.message'",
")",
".",
"removeClass",
"(",
"'hidden'",
")",
";",
"context",
".",
"pubsub",
".",
"status",
"(",
"'queued'",
",",
"function",
"(",
"res",
")",
"{",
"console",
".",
"log",
"(",
"res",
")",
";",
"var",
"message",
"=",
"''",
";",
"if",
"(",
"res",
".",
"err",
")",
"{",
"message",
"=",
"res",
".",
"err",
";",
"}",
"else",
"{",
"message",
"=",
"'found <a target=\"_searchresult\" href=\"'",
"+",
"res",
".",
"status",
".",
"uri",
"+",
"'\">'",
"+",
"res",
".",
"status",
".",
"uri",
"+",
"'</a> from '",
"+",
"res",
".",
"status",
".",
"source",
";",
"}",
"$",
"(",
"'.search.message'",
")",
".",
"append",
"(",
"'<div>'",
"+",
"message",
"+",
"'</div>'",
")",
";",
"}",
")",
";",
"context",
".",
"pubsub",
".",
"search",
".",
"queue",
"(",
"searchInput",
")",
";",
"context",
".",
"queryLib",
".",
"setAnnotationTags",
"(",
"$",
"(",
"'#searchCategories'",
")",
".",
"val",
"(",
")",
".",
"split",
"(",
"','",
")",
")",
";",
"context",
".",
"queryLib",
".",
"submitQuery",
"(",
")",
";",
"}"
]
| submit a new search | [
"submit",
"a",
"new",
"search"
]
| d60bcf28239e7dde437d8a6bdae41a6921dcd05b | https://github.com/vid/SenseBase/blob/d60bcf28239e7dde437d8a6bdae41a6921dcd05b/web/lib/search.js#L143-L168 |
45,557 | jonschlinkert/load-helpers | index.js | Loader | function Loader(options) {
if (!(this instanceof Loader)) {
return new Loader(options);
}
this.options = options || {};
this.cache = this.options.helpers || {};
} | javascript | function Loader(options) {
if (!(this instanceof Loader)) {
return new Loader(options);
}
this.options = options || {};
this.cache = this.options.helpers || {};
} | [
"function",
"Loader",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Loader",
")",
")",
"{",
"return",
"new",
"Loader",
"(",
"options",
")",
";",
"}",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"cache",
"=",
"this",
".",
"options",
".",
"helpers",
"||",
"{",
"}",
";",
"}"
]
| Create an instance of `Loader` with the given `options`.
```js
var Loader = require('load-helpers');
var loader = new Loader();
```
@param {Object} `options`
@api public | [
"Create",
"an",
"instance",
"of",
"Loader",
"with",
"the",
"given",
"options",
"."
]
| 271351dfafeae911495465b83a4811f8532ad249 | https://github.com/jonschlinkert/load-helpers/blob/271351dfafeae911495465b83a4811f8532ad249/index.js#L24-L30 |
45,558 | vadr-vr/VR-Analytics-JSCore | js/utils.js | deepClone | function deepClone(inputDict){
if (!inputDict)
return null;
const clonedDict = {};
for (let key in inputDict){
if (typeof(inputDict[key]) == 'object'){
clonedDict[key] = deepClone(inputDict[key]);
}
else{
clonedDict[key] = inputDict[key];
}
}
return clonedDict;
} | javascript | function deepClone(inputDict){
if (!inputDict)
return null;
const clonedDict = {};
for (let key in inputDict){
if (typeof(inputDict[key]) == 'object'){
clonedDict[key] = deepClone(inputDict[key]);
}
else{
clonedDict[key] = inputDict[key];
}
}
return clonedDict;
} | [
"function",
"deepClone",
"(",
"inputDict",
")",
"{",
"if",
"(",
"!",
"inputDict",
")",
"return",
"null",
";",
"const",
"clonedDict",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"key",
"in",
"inputDict",
")",
"{",
"if",
"(",
"typeof",
"(",
"inputDict",
"[",
"key",
"]",
")",
"==",
"'object'",
")",
"{",
"clonedDict",
"[",
"key",
"]",
"=",
"deepClone",
"(",
"inputDict",
"[",
"key",
"]",
")",
";",
"}",
"else",
"{",
"clonedDict",
"[",
"key",
"]",
"=",
"inputDict",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"clonedDict",
";",
"}"
]
| Deep clones dictionary
@memberof Utils
@param {object} inputDict Dictionary to clone
@returns {object} cloned dictionary | [
"Deep",
"clones",
"dictionary"
]
| 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/utils.js#L81-L105 |
45,559 | vadr-vr/VR-Analytics-JSCore | js/utils.js | setCookie | function setCookie(cookieName, value, validity, useAppPrefix = true){
const appPrefix = useAppPrefix ? _getAppPrefix() : '';
const cookieString = appPrefix + cookieName + '=' + value + ';' + 'expires=' +
validity.toUTCString();
document.cookie = cookieString;
} | javascript | function setCookie(cookieName, value, validity, useAppPrefix = true){
const appPrefix = useAppPrefix ? _getAppPrefix() : '';
const cookieString = appPrefix + cookieName + '=' + value + ';' + 'expires=' +
validity.toUTCString();
document.cookie = cookieString;
} | [
"function",
"setCookie",
"(",
"cookieName",
",",
"value",
",",
"validity",
",",
"useAppPrefix",
"=",
"true",
")",
"{",
"const",
"appPrefix",
"=",
"useAppPrefix",
"?",
"_getAppPrefix",
"(",
")",
":",
"''",
";",
"const",
"cookieString",
"=",
"appPrefix",
"+",
"cookieName",
"+",
"'='",
"+",
"value",
"+",
"';'",
"+",
"'expires='",
"+",
"validity",
".",
"toUTCString",
"(",
")",
";",
"document",
".",
"cookie",
"=",
"cookieString",
";",
"}"
]
| Sets the cookie with the given name, value and validity. Appends appId and version information
in the cookie name automatically
@memberof Utils
@param {string} cookieName name of the cookie
@param {string} value value of the cookie
@param {Date} validity valid till date object | [
"Sets",
"the",
"cookie",
"with",
"the",
"given",
"name",
"value",
"and",
"validity",
".",
"Appends",
"appId",
"and",
"version",
"information",
"in",
"the",
"cookie",
"name",
"automatically"
]
| 7e4a493c824c2c1716360dcb6a3bfecfede5df3b | https://github.com/vadr-vr/VR-Analytics-JSCore/blob/7e4a493c824c2c1716360dcb6a3bfecfede5df3b/js/utils.js#L130-L139 |
45,560 | tmorin/ceb | dist/systemjs/builder/template.js | findContentNode | function findContentNode(el) {
if (!el) {
return;
}
var oldCebContentId = el.getAttribute(OLD_CONTENT_ID_ATTR_NAME);
if (oldCebContentId) {
return findContentNode(el.querySelector('[' + oldCebContentId + ']')) || el;
}
return el;
} | javascript | function findContentNode(el) {
if (!el) {
return;
}
var oldCebContentId = el.getAttribute(OLD_CONTENT_ID_ATTR_NAME);
if (oldCebContentId) {
return findContentNode(el.querySelector('[' + oldCebContentId + ']')) || el;
}
return el;
} | [
"function",
"findContentNode",
"(",
"el",
")",
"{",
"if",
"(",
"!",
"el",
")",
"{",
"return",
";",
"}",
"var",
"oldCebContentId",
"=",
"el",
".",
"getAttribute",
"(",
"OLD_CONTENT_ID_ATTR_NAME",
")",
";",
"if",
"(",
"oldCebContentId",
")",
"{",
"return",
"findContentNode",
"(",
"el",
".",
"querySelector",
"(",
"'['",
"+",
"oldCebContentId",
"+",
"']'",
")",
")",
"||",
"el",
";",
"}",
"return",
"el",
";",
"}"
]
| Try to find a light DOM node
@param {!HTMLElement} el the custom element
@returns {HTMLElement} the light DOM node if found otherwise it's the given HTML Element | [
"Try",
"to",
"find",
"a",
"light",
"DOM",
"node"
]
| 7cc0904b482aa99e5123302c5de4401f7a80af02 | https://github.com/tmorin/ceb/blob/7cc0904b482aa99e5123302c5de4401f7a80af02/dist/systemjs/builder/template.js#L61-L70 |
45,561 | tmorin/ceb | dist/systemjs/builder/template.js | cleanOldContentNode | function cleanOldContentNode(el) {
var oldContentNode = el.lightDOM,
lightFrag = document.createDocumentFragment();
while (oldContentNode.childNodes.length > 0) {
lightFrag.appendChild(oldContentNode.removeChild(oldContentNode.childNodes[0]));
}
return lightFrag;
} | javascript | function cleanOldContentNode(el) {
var oldContentNode = el.lightDOM,
lightFrag = document.createDocumentFragment();
while (oldContentNode.childNodes.length > 0) {
lightFrag.appendChild(oldContentNode.removeChild(oldContentNode.childNodes[0]));
}
return lightFrag;
} | [
"function",
"cleanOldContentNode",
"(",
"el",
")",
"{",
"var",
"oldContentNode",
"=",
"el",
".",
"lightDOM",
",",
"lightFrag",
"=",
"document",
".",
"createDocumentFragment",
"(",
")",
";",
"while",
"(",
"oldContentNode",
".",
"childNodes",
".",
"length",
">",
"0",
")",
"{",
"lightFrag",
".",
"appendChild",
"(",
"oldContentNode",
".",
"removeChild",
"(",
"oldContentNode",
".",
"childNodes",
"[",
"0",
"]",
")",
")",
";",
"}",
"return",
"lightFrag",
";",
"}"
]
| Remove and return the children of the light DOM node.
@param {!HTMLElement} el the custom element
@returns {DocumentFragment} the light DOM fragment | [
"Remove",
"and",
"return",
"the",
"children",
"of",
"the",
"light",
"DOM",
"node",
"."
]
| 7cc0904b482aa99e5123302c5de4401f7a80af02 | https://github.com/tmorin/ceb/blob/7cc0904b482aa99e5123302c5de4401f7a80af02/dist/systemjs/builder/template.js#L77-L84 |
45,562 | tmorin/ceb | dist/systemjs/builder/template.js | applyTemplate | function applyTemplate(el, tpl) {
var lightFrag = void 0,
handleContentNode = hasContent(tpl);
if (handleContentNode) {
var newCebContentId = 'ceb-content-' + counter++;
lightFrag = cleanOldContentNode(el);
tpl = replaceContent(tpl, newCebContentId);
el.setAttribute(OLD_CONTENT_ID_ATTR_NAME, newCebContentId);
}
el.innerHTML = tpl;
if (handleContentNode && lightFrag) {
el.lightDOM.appendChild(lightFrag);
}
} | javascript | function applyTemplate(el, tpl) {
var lightFrag = void 0,
handleContentNode = hasContent(tpl);
if (handleContentNode) {
var newCebContentId = 'ceb-content-' + counter++;
lightFrag = cleanOldContentNode(el);
tpl = replaceContent(tpl, newCebContentId);
el.setAttribute(OLD_CONTENT_ID_ATTR_NAME, newCebContentId);
}
el.innerHTML = tpl;
if (handleContentNode && lightFrag) {
el.lightDOM.appendChild(lightFrag);
}
} | [
"function",
"applyTemplate",
"(",
"el",
",",
"tpl",
")",
"{",
"var",
"lightFrag",
"=",
"void",
"0",
",",
"handleContentNode",
"=",
"hasContent",
"(",
"tpl",
")",
";",
"if",
"(",
"handleContentNode",
")",
"{",
"var",
"newCebContentId",
"=",
"'ceb-content-'",
"+",
"counter",
"++",
";",
"lightFrag",
"=",
"cleanOldContentNode",
"(",
"el",
")",
";",
"tpl",
"=",
"replaceContent",
"(",
"tpl",
",",
"newCebContentId",
")",
";",
"el",
".",
"setAttribute",
"(",
"OLD_CONTENT_ID_ATTR_NAME",
",",
"newCebContentId",
")",
";",
"}",
"el",
".",
"innerHTML",
"=",
"tpl",
";",
"if",
"(",
"handleContentNode",
"&&",
"lightFrag",
")",
"{",
"el",
".",
"lightDOM",
".",
"appendChild",
"(",
"lightFrag",
")",
";",
"}",
"}"
]
| Apply the template to the element.
@param {!HTMLElement} el the custom element
@param {!string} tpl the template | [
"Apply",
"the",
"template",
"to",
"the",
"element",
"."
]
| 7cc0904b482aa99e5123302c5de4401f7a80af02 | https://github.com/tmorin/ceb/blob/7cc0904b482aa99e5123302c5de4401f7a80af02/dist/systemjs/builder/template.js#L91-L109 |
45,563 | ngenerio/smsghjs | lib/message.js | isAnImportantParamMissing | function isAnImportantParamMissing (obj) {
var i = 0
var l = Message._importantParams.length
for (; i < l; i++) {
var value = obj[Message._importantParams[i]]
if (value === null || value === undefined) {
return true
}
}
} | javascript | function isAnImportantParamMissing (obj) {
var i = 0
var l = Message._importantParams.length
for (; i < l; i++) {
var value = obj[Message._importantParams[i]]
if (value === null || value === undefined) {
return true
}
}
} | [
"function",
"isAnImportantParamMissing",
"(",
"obj",
")",
"{",
"var",
"i",
"=",
"0",
"var",
"l",
"=",
"Message",
".",
"_importantParams",
".",
"length",
"for",
"(",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"value",
"=",
"obj",
"[",
"Message",
".",
"_importantParams",
"[",
"i",
"]",
"]",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
")",
"{",
"return",
"true",
"}",
"}",
"}"
]
| To check whether the given object contains the necssary params to send a message
@param {Object} obj
@return {Boolean} | [
"To",
"check",
"whether",
"the",
"given",
"object",
"contains",
"the",
"necssary",
"params",
"to",
"send",
"a",
"message"
]
| cfb33bb6b5b02d54125bed67365a5b174a1ad562 | https://github.com/ngenerio/smsghjs/blob/cfb33bb6b5b02d54125bed67365a5b174a1ad562/lib/message.js#L8-L18 |
45,564 | ngenerio/smsghjs | lib/message.js | Message | function Message (opts) {
if (!(this instanceof Message)) return new Message(opts)
this.type = opts.type || 0
this.clientReference = opts.clientReference || null
this.direction = opts.direction || 'out'
this.flashMessage = opts.flash || null
this.messageId = opts.messageId || null
this.networkId = opts.networkId || null
this.rate = opts.rate || null
this.registeredDelivery = opts.registeredDelivery || null
this.status = opts.status || null
this.time = opts.time || null
this.udh = opts.udh || null
this.units = opts.units || null
this.updateTime = opts.updateTime || null
if (isAnImportantParamMissing(opts)) {
throw new SMSGHError('Important message option missing. Required options are: `from`, `to` and `content`')
}
var i = 0
var l = Message._importantParams.length
for (i = 0; i < l; i++) {
this[Message._importantParams[i]] = opts[Message._importantParams[i]]
}
} | javascript | function Message (opts) {
if (!(this instanceof Message)) return new Message(opts)
this.type = opts.type || 0
this.clientReference = opts.clientReference || null
this.direction = opts.direction || 'out'
this.flashMessage = opts.flash || null
this.messageId = opts.messageId || null
this.networkId = opts.networkId || null
this.rate = opts.rate || null
this.registeredDelivery = opts.registeredDelivery || null
this.status = opts.status || null
this.time = opts.time || null
this.udh = opts.udh || null
this.units = opts.units || null
this.updateTime = opts.updateTime || null
if (isAnImportantParamMissing(opts)) {
throw new SMSGHError('Important message option missing. Required options are: `from`, `to` and `content`')
}
var i = 0
var l = Message._importantParams.length
for (i = 0; i < l; i++) {
this[Message._importantParams[i]] = opts[Message._importantParams[i]]
}
} | [
"function",
"Message",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Message",
")",
")",
"return",
"new",
"Message",
"(",
"opts",
")",
"this",
".",
"type",
"=",
"opts",
".",
"type",
"||",
"0",
"this",
".",
"clientReference",
"=",
"opts",
".",
"clientReference",
"||",
"null",
"this",
".",
"direction",
"=",
"opts",
".",
"direction",
"||",
"'out'",
"this",
".",
"flashMessage",
"=",
"opts",
".",
"flash",
"||",
"null",
"this",
".",
"messageId",
"=",
"opts",
".",
"messageId",
"||",
"null",
"this",
".",
"networkId",
"=",
"opts",
".",
"networkId",
"||",
"null",
"this",
".",
"rate",
"=",
"opts",
".",
"rate",
"||",
"null",
"this",
".",
"registeredDelivery",
"=",
"opts",
".",
"registeredDelivery",
"||",
"null",
"this",
".",
"status",
"=",
"opts",
".",
"status",
"||",
"null",
"this",
".",
"time",
"=",
"opts",
".",
"time",
"||",
"null",
"this",
".",
"udh",
"=",
"opts",
".",
"udh",
"||",
"null",
"this",
".",
"units",
"=",
"opts",
".",
"units",
"||",
"null",
"this",
".",
"updateTime",
"=",
"opts",
".",
"updateTime",
"||",
"null",
"if",
"(",
"isAnImportantParamMissing",
"(",
"opts",
")",
")",
"{",
"throw",
"new",
"SMSGHError",
"(",
"'Important message option missing. Required options are: `from`, `to` and `content`'",
")",
"}",
"var",
"i",
"=",
"0",
"var",
"l",
"=",
"Message",
".",
"_importantParams",
".",
"length",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"this",
"[",
"Message",
".",
"_importantParams",
"[",
"i",
"]",
"]",
"=",
"opts",
"[",
"Message",
".",
"_importantParams",
"[",
"i",
"]",
"]",
"}",
"}"
]
| The message object used in the send message api
@param {Object} opts Contains the params to be sent using the message api | [
"The",
"message",
"object",
"used",
"in",
"the",
"send",
"message",
"api"
]
| cfb33bb6b5b02d54125bed67365a5b174a1ad562 | https://github.com/ngenerio/smsghjs/blob/cfb33bb6b5b02d54125bed67365a5b174a1ad562/lib/message.js#L24-L50 |
45,565 | socialally/air | lib/air/val.js | val | function val(value) {
var first = this.get(0);
function getValue(el) {
var nm = el.tagName.toLowerCase()
, type = el.getAttribute('type');
if(nm === SELECT) {
return getSelectValues(el).join(
el.getAttribute('data-delimiter') || ',');
}else if(type === CHECKBOX) {
return Boolean(el.checked);
}
return el.value;
}
function setValue(el, value) {
var nm = el.tagName.toLowerCase()
, type = el.getAttribute('type');
if(nm === TEXTAREA) {
while(el.childNodes.length) {
el.removeChild(el.childNodes[0])
}
el.appendChild(document.createTextNode(value));
}else if(nm === SELECT) {
setSelectValues(el, value);
}else if(type === RADIO) {
el.setAttribute('checked', '');
}else if(type === CHECKBOX && Boolean(value)) {
el.checked = true;
}else{
el.value = value;
}
}
if(value === undefined && first) {
return getValue(first);
}else if(value) {
this.each(function(el) {
setValue(el, value);
})
}
return this;
} | javascript | function val(value) {
var first = this.get(0);
function getValue(el) {
var nm = el.tagName.toLowerCase()
, type = el.getAttribute('type');
if(nm === SELECT) {
return getSelectValues(el).join(
el.getAttribute('data-delimiter') || ',');
}else if(type === CHECKBOX) {
return Boolean(el.checked);
}
return el.value;
}
function setValue(el, value) {
var nm = el.tagName.toLowerCase()
, type = el.getAttribute('type');
if(nm === TEXTAREA) {
while(el.childNodes.length) {
el.removeChild(el.childNodes[0])
}
el.appendChild(document.createTextNode(value));
}else if(nm === SELECT) {
setSelectValues(el, value);
}else if(type === RADIO) {
el.setAttribute('checked', '');
}else if(type === CHECKBOX && Boolean(value)) {
el.checked = true;
}else{
el.value = value;
}
}
if(value === undefined && first) {
return getValue(first);
}else if(value) {
this.each(function(el) {
setValue(el, value);
})
}
return this;
} | [
"function",
"val",
"(",
"value",
")",
"{",
"var",
"first",
"=",
"this",
".",
"get",
"(",
"0",
")",
";",
"function",
"getValue",
"(",
"el",
")",
"{",
"var",
"nm",
"=",
"el",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
",",
"type",
"=",
"el",
".",
"getAttribute",
"(",
"'type'",
")",
";",
"if",
"(",
"nm",
"===",
"SELECT",
")",
"{",
"return",
"getSelectValues",
"(",
"el",
")",
".",
"join",
"(",
"el",
".",
"getAttribute",
"(",
"'data-delimiter'",
")",
"||",
"','",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"CHECKBOX",
")",
"{",
"return",
"Boolean",
"(",
"el",
".",
"checked",
")",
";",
"}",
"return",
"el",
".",
"value",
";",
"}",
"function",
"setValue",
"(",
"el",
",",
"value",
")",
"{",
"var",
"nm",
"=",
"el",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
",",
"type",
"=",
"el",
".",
"getAttribute",
"(",
"'type'",
")",
";",
"if",
"(",
"nm",
"===",
"TEXTAREA",
")",
"{",
"while",
"(",
"el",
".",
"childNodes",
".",
"length",
")",
"{",
"el",
".",
"removeChild",
"(",
"el",
".",
"childNodes",
"[",
"0",
"]",
")",
"}",
"el",
".",
"appendChild",
"(",
"document",
".",
"createTextNode",
"(",
"value",
")",
")",
";",
"}",
"else",
"if",
"(",
"nm",
"===",
"SELECT",
")",
"{",
"setSelectValues",
"(",
"el",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"RADIO",
")",
"{",
"el",
".",
"setAttribute",
"(",
"'checked'",
",",
"''",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"CHECKBOX",
"&&",
"Boolean",
"(",
"value",
")",
")",
"{",
"el",
".",
"checked",
"=",
"true",
";",
"}",
"else",
"{",
"el",
".",
"value",
"=",
"value",
";",
"}",
"}",
"if",
"(",
"value",
"===",
"undefined",
"&&",
"first",
")",
"{",
"return",
"getValue",
"(",
"first",
")",
";",
"}",
"else",
"if",
"(",
"value",
")",
"{",
"this",
".",
"each",
"(",
"function",
"(",
"el",
")",
"{",
"setValue",
"(",
"el",
",",
"value",
")",
";",
"}",
")",
"}",
"return",
"this",
";",
"}"
]
| Get the current value of the first element in the set of
matched elements or set the value of every matched element. | [
"Get",
"the",
"current",
"value",
"of",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"or",
"set",
"the",
"value",
"of",
"every",
"matched",
"element",
"."
]
| a3d94de58aaa4930a425fbcc7266764bf6ca8ca6 | https://github.com/socialally/air/blob/a3d94de58aaa4930a425fbcc7266764bf6ca8ca6/lib/air/val.js#L36-L78 |
45,566 | goliatone/core.io-express-server | lib/getView.js | getView | function getView(app, viewName, defaultView='error'){
/*
* views could be an array...
*/
let views = app.get('views');
const ext = app.get('view engine');
if(!Array.isArray(views)) views = [views];
let view;
for(var i = 0; i < views.length; i++){
view = path.join(views[i], viewName + '.' + ext);
if (exists(view)) return view;
}
if (app.parent) return getView(app.parent, viewName, defaultView);
return defaultView;
} | javascript | function getView(app, viewName, defaultView='error'){
/*
* views could be an array...
*/
let views = app.get('views');
const ext = app.get('view engine');
if(!Array.isArray(views)) views = [views];
let view;
for(var i = 0; i < views.length; i++){
view = path.join(views[i], viewName + '.' + ext);
if (exists(view)) return view;
}
if (app.parent) return getView(app.parent, viewName, defaultView);
return defaultView;
} | [
"function",
"getView",
"(",
"app",
",",
"viewName",
",",
"defaultView",
"=",
"'error'",
")",
"{",
"/*\n * views could be an array...\n */",
"let",
"views",
"=",
"app",
".",
"get",
"(",
"'views'",
")",
";",
"const",
"ext",
"=",
"app",
".",
"get",
"(",
"'view engine'",
")",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"views",
")",
")",
"views",
"=",
"[",
"views",
"]",
";",
"let",
"view",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"views",
".",
"length",
";",
"i",
"++",
")",
"{",
"view",
"=",
"path",
".",
"join",
"(",
"views",
"[",
"i",
"]",
",",
"viewName",
"+",
"'.'",
"+",
"ext",
")",
";",
"if",
"(",
"exists",
"(",
"view",
")",
")",
"return",
"view",
";",
"}",
"if",
"(",
"app",
".",
"parent",
")",
"return",
"getView",
"(",
"app",
".",
"parent",
",",
"viewName",
",",
"defaultView",
")",
";",
"return",
"defaultView",
";",
"}"
]
| This function will try to return a valid path to
a view.
It will recursively call itself while the provided
express instance has a `parent` attribute.
@TODO: Move to it's own package.
@param {Object} app Express instance
@param {String} viewName View name without ext
@param {String} [defaultView='error']
@return {String} Path to a valid view. | [
"This",
"function",
"will",
"try",
"to",
"return",
"a",
"valid",
"path",
"to",
"a",
"view",
"."
]
| 920225b923eaf1f142cd0ee1db78a208f8ecdbe2 | https://github.com/goliatone/core.io-express-server/blob/920225b923eaf1f142cd0ee1db78a208f8ecdbe2/lib/getView.js#L19-L37 |
45,567 | SME-FE/sme-log | src/index.js | logSome | function logSome(env = 'dev', level = 'none') {
let levelNum = 3
const theme = {
normal: '#92e6e6',
error: '#ff5335',
info: '#2994b2',
warn: '#ffb400'
}
const setLevel = level => {
switch (level) {
case 'error':
levelNum = 1
break
case 'warn':
levelNum = 2
break
case 'info':
levelNum = 3
break
default:
levelNum = (env === 'development' || env === 'dev') ? 3 : 1
break
}
}
const getStyle = color => `color:${color || '#8b80f9'};font-weight:bold;`
const isLogEnable = (opts, force, env) => {
if (opts.level) {
return force
} else {
return force || env === 'development' || env === 'dev'
}
}
const logger = (info, force, opts = {}) => {
if (isLogEnable(opts, force, env)) {
if (opts.level && info instanceof Array && info.length === 2) {
console.log('%c%s%o', getStyle(opts.color), `${info[0]} `, info[1])
} else if (typeof info !== 'object' && typeof info !== 'function') {
console.log('%c' + info, getStyle(opts.color))
} else {
console.log('%c%s%o', getStyle(opts.color), `${opts.level || 'log'} `, info)
}
}
}
logger.info = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 3, { color: theme.info, level: 'info' })
}
logger.warn = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 2, { color: theme.warn, level: 'warn' })
}
logger.error = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 1, { color: theme.error, level: 'error' })
}
logger.setLevel = setLevel
logger.toString = logger.valueOf = fstr('logger')
setLevel(level)
return logger
} | javascript | function logSome(env = 'dev', level = 'none') {
let levelNum = 3
const theme = {
normal: '#92e6e6',
error: '#ff5335',
info: '#2994b2',
warn: '#ffb400'
}
const setLevel = level => {
switch (level) {
case 'error':
levelNum = 1
break
case 'warn':
levelNum = 2
break
case 'info':
levelNum = 3
break
default:
levelNum = (env === 'development' || env === 'dev') ? 3 : 1
break
}
}
const getStyle = color => `color:${color || '#8b80f9'};font-weight:bold;`
const isLogEnable = (opts, force, env) => {
if (opts.level) {
return force
} else {
return force || env === 'development' || env === 'dev'
}
}
const logger = (info, force, opts = {}) => {
if (isLogEnable(opts, force, env)) {
if (opts.level && info instanceof Array && info.length === 2) {
console.log('%c%s%o', getStyle(opts.color), `${info[0]} `, info[1])
} else if (typeof info !== 'object' && typeof info !== 'function') {
console.log('%c' + info, getStyle(opts.color))
} else {
console.log('%c%s%o', getStyle(opts.color), `${opts.level || 'log'} `, info)
}
}
}
logger.info = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 3, { color: theme.info, level: 'info' })
}
logger.warn = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 2, { color: theme.warn, level: 'warn' })
}
logger.error = (info, extra) => {
if (extra) info = [info, extra]
logger(info, levelNum >= 1, { color: theme.error, level: 'error' })
}
logger.setLevel = setLevel
logger.toString = logger.valueOf = fstr('logger')
setLevel(level)
return logger
} | [
"function",
"logSome",
"(",
"env",
"=",
"'dev'",
",",
"level",
"=",
"'none'",
")",
"{",
"let",
"levelNum",
"=",
"3",
"const",
"theme",
"=",
"{",
"normal",
":",
"'#92e6e6'",
",",
"error",
":",
"'#ff5335'",
",",
"info",
":",
"'#2994b2'",
",",
"warn",
":",
"'#ffb400'",
"}",
"const",
"setLevel",
"=",
"level",
"=>",
"{",
"switch",
"(",
"level",
")",
"{",
"case",
"'error'",
":",
"levelNum",
"=",
"1",
"break",
"case",
"'warn'",
":",
"levelNum",
"=",
"2",
"break",
"case",
"'info'",
":",
"levelNum",
"=",
"3",
"break",
"default",
":",
"levelNum",
"=",
"(",
"env",
"===",
"'development'",
"||",
"env",
"===",
"'dev'",
")",
"?",
"3",
":",
"1",
"break",
"}",
"}",
"const",
"getStyle",
"=",
"color",
"=>",
"`",
"${",
"color",
"||",
"'#8b80f9'",
"}",
"`",
"const",
"isLogEnable",
"=",
"(",
"opts",
",",
"force",
",",
"env",
")",
"=>",
"{",
"if",
"(",
"opts",
".",
"level",
")",
"{",
"return",
"force",
"}",
"else",
"{",
"return",
"force",
"||",
"env",
"===",
"'development'",
"||",
"env",
"===",
"'dev'",
"}",
"}",
"const",
"logger",
"=",
"(",
"info",
",",
"force",
",",
"opts",
"=",
"{",
"}",
")",
"=>",
"{",
"if",
"(",
"isLogEnable",
"(",
"opts",
",",
"force",
",",
"env",
")",
")",
"{",
"if",
"(",
"opts",
".",
"level",
"&&",
"info",
"instanceof",
"Array",
"&&",
"info",
".",
"length",
"===",
"2",
")",
"{",
"console",
".",
"log",
"(",
"'%c%s%o'",
",",
"getStyle",
"(",
"opts",
".",
"color",
")",
",",
"`",
"${",
"info",
"[",
"0",
"]",
"}",
"`",
",",
"info",
"[",
"1",
"]",
")",
"}",
"else",
"if",
"(",
"typeof",
"info",
"!==",
"'object'",
"&&",
"typeof",
"info",
"!==",
"'function'",
")",
"{",
"console",
".",
"log",
"(",
"'%c'",
"+",
"info",
",",
"getStyle",
"(",
"opts",
".",
"color",
")",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'%c%s%o'",
",",
"getStyle",
"(",
"opts",
".",
"color",
")",
",",
"`",
"${",
"opts",
".",
"level",
"||",
"'log'",
"}",
"`",
",",
"info",
")",
"}",
"}",
"}",
"logger",
".",
"info",
"=",
"(",
"info",
",",
"extra",
")",
"=>",
"{",
"if",
"(",
"extra",
")",
"info",
"=",
"[",
"info",
",",
"extra",
"]",
"logger",
"(",
"info",
",",
"levelNum",
">=",
"3",
",",
"{",
"color",
":",
"theme",
".",
"info",
",",
"level",
":",
"'info'",
"}",
")",
"}",
"logger",
".",
"warn",
"=",
"(",
"info",
",",
"extra",
")",
"=>",
"{",
"if",
"(",
"extra",
")",
"info",
"=",
"[",
"info",
",",
"extra",
"]",
"logger",
"(",
"info",
",",
"levelNum",
">=",
"2",
",",
"{",
"color",
":",
"theme",
".",
"warn",
",",
"level",
":",
"'warn'",
"}",
")",
"}",
"logger",
".",
"error",
"=",
"(",
"info",
",",
"extra",
")",
"=>",
"{",
"if",
"(",
"extra",
")",
"info",
"=",
"[",
"info",
",",
"extra",
"]",
"logger",
"(",
"info",
",",
"levelNum",
">=",
"1",
",",
"{",
"color",
":",
"theme",
".",
"error",
",",
"level",
":",
"'error'",
"}",
")",
"}",
"logger",
".",
"setLevel",
"=",
"setLevel",
"logger",
".",
"toString",
"=",
"logger",
".",
"valueOf",
"=",
"fstr",
"(",
"'logger'",
")",
"setLevel",
"(",
"level",
")",
"return",
"logger",
"}"
]
| more pretty log for console.log
and only log on dev mode
always log if force is true | [
"more",
"pretty",
"log",
"for",
"console",
".",
"log",
"and",
"only",
"log",
"on",
"dev",
"mode",
"always",
"log",
"if",
"force",
"is",
"true"
]
| 02f5cdbffae01a29761856c47fc528430260b8e0 | https://github.com/SME-FE/sme-log/blob/02f5cdbffae01a29761856c47fc528430260b8e0/src/index.js#L7-L67 |
45,568 | nodecraft/spawnpoint-express | spawnpoint-express.js | function(err){
if(!err){
var address = app[serverNS].address();
if(config.port){
app.info('Server online at %s:%s', address.address, address.port);
}else if(config.file){
app.info('Server online via %s', config.file);
}else{
app.info('Server online!');
}
}
app.emit('app.register', 'express');
return callback(err);
} | javascript | function(err){
if(!err){
var address = app[serverNS].address();
if(config.port){
app.info('Server online at %s:%s', address.address, address.port);
}else if(config.file){
app.info('Server online via %s', config.file);
}else{
app.info('Server online!');
}
}
app.emit('app.register', 'express');
return callback(err);
} | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"var",
"address",
"=",
"app",
"[",
"serverNS",
"]",
".",
"address",
"(",
")",
";",
"if",
"(",
"config",
".",
"port",
")",
"{",
"app",
".",
"info",
"(",
"'Server online at %s:%s'",
",",
"address",
".",
"address",
",",
"address",
".",
"port",
")",
";",
"}",
"else",
"if",
"(",
"config",
".",
"file",
")",
"{",
"app",
".",
"info",
"(",
"'Server online via %s'",
",",
"config",
".",
"file",
")",
";",
"}",
"else",
"{",
"app",
".",
"info",
"(",
"'Server online!'",
")",
";",
"}",
"}",
"app",
".",
"emit",
"(",
"'app.register'",
",",
"'express'",
")",
";",
"return",
"callback",
"(",
"err",
")",
";",
"}"
]
| register express with spawnpoint | [
"register",
"express",
"with",
"spawnpoint"
]
| 82ebf14f9d8490f2581032ff79dcb40eeffdadd6 | https://github.com/nodecraft/spawnpoint-express/blob/82ebf14f9d8490f2581032ff79dcb40eeffdadd6/spawnpoint-express.js#L78-L92 |
|
45,569 | rat-nest/big-rat | lib/ctz.js | ctzNumber | function ctzNumber(x) {
var l = ctz(db.lo(x))
if(l < 32) {
return l
}
var h = ctz(db.hi(x))
if(h > 20) {
return 52
}
return h + 32
} | javascript | function ctzNumber(x) {
var l = ctz(db.lo(x))
if(l < 32) {
return l
}
var h = ctz(db.hi(x))
if(h > 20) {
return 52
}
return h + 32
} | [
"function",
"ctzNumber",
"(",
"x",
")",
"{",
"var",
"l",
"=",
"ctz",
"(",
"db",
".",
"lo",
"(",
"x",
")",
")",
"if",
"(",
"l",
"<",
"32",
")",
"{",
"return",
"l",
"}",
"var",
"h",
"=",
"ctz",
"(",
"db",
".",
"hi",
"(",
"x",
")",
")",
"if",
"(",
"h",
">",
"20",
")",
"{",
"return",
"52",
"}",
"return",
"h",
"+",
"32",
"}"
]
| Counts the number of trailing zeros | [
"Counts",
"the",
"number",
"of",
"trailing",
"zeros"
]
| 09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa | https://github.com/rat-nest/big-rat/blob/09aabcf6d51a326dce0e4bdeedb159c9ce6b0efa/lib/ctz.js#L9-L19 |
45,570 | jaredhanson/passport-familysearch | lib/passport-familysearch/legacy-strategy.js | Strategy | function Strategy(options, verify) {
options = options || {};
options.requestTokenURL = options.requestTokenURL || 'https://api.familysearch.org/identity/v2/request_token';
options.accessTokenURL = options.accessTokenURL || 'https://api.familysearch.org/identity/v2/access_token';
options.userAuthorizationURL = options.userAuthorizationURL || 'https://api.familysearch.org/identity/v2/authorize';
options.signatureMethod = options.signatureMethod || 'PLAINTEXT';
options.sessionKey = options.sessionKey || 'oauth:familysearch';
OAuthStrategy.call(this, options, verify);
this.name = 'familysearch';
this._userProfileURL = options.userProfileURL || 'https://api.familysearch.org/identity/v2/user';
// FamilySearch's OAuth implementation does not conform to the specification.
// As a workaround, the underlying node-oauth functions are replaced in order
// to deal with the idiosyncrasies.
this._oauth._buildAuthorizationHeaders = function(orderedParameters) {
var authHeader="OAuth ";
if( this._isEcho ) {
authHeader += 'realm="' + this._realm + '",';
}
for( var i= 0 ; i < orderedParameters.length; i++) {
// Whilst the all the parameters should be included within the signature, only the oauth_ arguments
// should appear within the authorization header.
if( this._isParameterNameAnOAuthParameter(orderedParameters[i][0]) ) {
if (orderedParameters[i][0] === 'oauth_signature') {
// JDH: This is a workaround for FamilySearch's non-conformant OAuth
// implementation, which expects the `oauth_signature` value to
// be unencoded
authHeader+= "" + this._encodeData(orderedParameters[i][0])+"=\""+ orderedParameters[i][1]+"\",";
} else {
authHeader+= "" + this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\",";
}
}
}
authHeader= authHeader.substring(0, authHeader.length-1);
return authHeader;
}
this._oauth._isParameterNameAnOAuthParameter= function(parameter) {
// JDH: This is a workaround to force the `oauth_callback` parameter out of
// the Authorization header and into the request body, where
// FamilySearch expects to find it.
if (parameter === 'oauth_callback') { return false; }
var m = parameter.match('^oauth_');
if( m && ( m[0] === "oauth_" ) ) {
return true;
}
else {
return false;
}
};
} | javascript | function Strategy(options, verify) {
options = options || {};
options.requestTokenURL = options.requestTokenURL || 'https://api.familysearch.org/identity/v2/request_token';
options.accessTokenURL = options.accessTokenURL || 'https://api.familysearch.org/identity/v2/access_token';
options.userAuthorizationURL = options.userAuthorizationURL || 'https://api.familysearch.org/identity/v2/authorize';
options.signatureMethod = options.signatureMethod || 'PLAINTEXT';
options.sessionKey = options.sessionKey || 'oauth:familysearch';
OAuthStrategy.call(this, options, verify);
this.name = 'familysearch';
this._userProfileURL = options.userProfileURL || 'https://api.familysearch.org/identity/v2/user';
// FamilySearch's OAuth implementation does not conform to the specification.
// As a workaround, the underlying node-oauth functions are replaced in order
// to deal with the idiosyncrasies.
this._oauth._buildAuthorizationHeaders = function(orderedParameters) {
var authHeader="OAuth ";
if( this._isEcho ) {
authHeader += 'realm="' + this._realm + '",';
}
for( var i= 0 ; i < orderedParameters.length; i++) {
// Whilst the all the parameters should be included within the signature, only the oauth_ arguments
// should appear within the authorization header.
if( this._isParameterNameAnOAuthParameter(orderedParameters[i][0]) ) {
if (orderedParameters[i][0] === 'oauth_signature') {
// JDH: This is a workaround for FamilySearch's non-conformant OAuth
// implementation, which expects the `oauth_signature` value to
// be unencoded
authHeader+= "" + this._encodeData(orderedParameters[i][0])+"=\""+ orderedParameters[i][1]+"\",";
} else {
authHeader+= "" + this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\",";
}
}
}
authHeader= authHeader.substring(0, authHeader.length-1);
return authHeader;
}
this._oauth._isParameterNameAnOAuthParameter= function(parameter) {
// JDH: This is a workaround to force the `oauth_callback` parameter out of
// the Authorization header and into the request body, where
// FamilySearch expects to find it.
if (parameter === 'oauth_callback') { return false; }
var m = parameter.match('^oauth_');
if( m && ( m[0] === "oauth_" ) ) {
return true;
}
else {
return false;
}
};
} | [
"function",
"Strategy",
"(",
"options",
",",
"verify",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"requestTokenURL",
"=",
"options",
".",
"requestTokenURL",
"||",
"'https://api.familysearch.org/identity/v2/request_token'",
";",
"options",
".",
"accessTokenURL",
"=",
"options",
".",
"accessTokenURL",
"||",
"'https://api.familysearch.org/identity/v2/access_token'",
";",
"options",
".",
"userAuthorizationURL",
"=",
"options",
".",
"userAuthorizationURL",
"||",
"'https://api.familysearch.org/identity/v2/authorize'",
";",
"options",
".",
"signatureMethod",
"=",
"options",
".",
"signatureMethod",
"||",
"'PLAINTEXT'",
";",
"options",
".",
"sessionKey",
"=",
"options",
".",
"sessionKey",
"||",
"'oauth:familysearch'",
";",
"OAuthStrategy",
".",
"call",
"(",
"this",
",",
"options",
",",
"verify",
")",
";",
"this",
".",
"name",
"=",
"'familysearch'",
";",
"this",
".",
"_userProfileURL",
"=",
"options",
".",
"userProfileURL",
"||",
"'https://api.familysearch.org/identity/v2/user'",
";",
"// FamilySearch's OAuth implementation does not conform to the specification.",
"// As a workaround, the underlying node-oauth functions are replaced in order",
"// to deal with the idiosyncrasies.",
"this",
".",
"_oauth",
".",
"_buildAuthorizationHeaders",
"=",
"function",
"(",
"orderedParameters",
")",
"{",
"var",
"authHeader",
"=",
"\"OAuth \"",
";",
"if",
"(",
"this",
".",
"_isEcho",
")",
"{",
"authHeader",
"+=",
"'realm=\"'",
"+",
"this",
".",
"_realm",
"+",
"'\",'",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"orderedParameters",
".",
"length",
";",
"i",
"++",
")",
"{",
"// Whilst the all the parameters should be included within the signature, only the oauth_ arguments",
"// should appear within the authorization header.",
"if",
"(",
"this",
".",
"_isParameterNameAnOAuthParameter",
"(",
"orderedParameters",
"[",
"i",
"]",
"[",
"0",
"]",
")",
")",
"{",
"if",
"(",
"orderedParameters",
"[",
"i",
"]",
"[",
"0",
"]",
"===",
"'oauth_signature'",
")",
"{",
"// JDH: This is a workaround for FamilySearch's non-conformant OAuth",
"// implementation, which expects the `oauth_signature` value to",
"// be unencoded",
"authHeader",
"+=",
"\"\"",
"+",
"this",
".",
"_encodeData",
"(",
"orderedParameters",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"+",
"\"=\\\"\"",
"+",
"orderedParameters",
"[",
"i",
"]",
"[",
"1",
"]",
"+",
"\"\\\",\"",
";",
"}",
"else",
"{",
"authHeader",
"+=",
"\"\"",
"+",
"this",
".",
"_encodeData",
"(",
"orderedParameters",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"+",
"\"=\\\"\"",
"+",
"this",
".",
"_encodeData",
"(",
"orderedParameters",
"[",
"i",
"]",
"[",
"1",
"]",
")",
"+",
"\"\\\",\"",
";",
"}",
"}",
"}",
"authHeader",
"=",
"authHeader",
".",
"substring",
"(",
"0",
",",
"authHeader",
".",
"length",
"-",
"1",
")",
";",
"return",
"authHeader",
";",
"}",
"this",
".",
"_oauth",
".",
"_isParameterNameAnOAuthParameter",
"=",
"function",
"(",
"parameter",
")",
"{",
"// JDH: This is a workaround to force the `oauth_callback` parameter out of",
"// the Authorization header and into the request body, where",
"// FamilySearch expects to find it.",
"if",
"(",
"parameter",
"===",
"'oauth_callback'",
")",
"{",
"return",
"false",
";",
"}",
"var",
"m",
"=",
"parameter",
".",
"match",
"(",
"'^oauth_'",
")",
";",
"if",
"(",
"m",
"&&",
"(",
"m",
"[",
"0",
"]",
"===",
"\"oauth_\"",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
";",
"}"
]
| Legacy `Strategy` constructor.
The FamilySearch legacy authentication strategy authenticates requests by delegating
to FamilySearch using the OAuth 1.0 protocol.
Applications must supply a `verify` callback which accepts a `token`,
`tokenSecret` and service-specific `profile`, and then calls the `done`
callback supplying a `user`, which should be set to `false` if the
credentials are not valid. If an exception occured, `err` should be set.
Options:
- `consumerKey` FamilySearch Developer Key
- `consumerSecret` an empty string, as required by FamilySearch
- `callbackURL` URL to which FamilySearch will redirect the user after obtaining authorization
Examples:
passport.use(new FamilySearchStrategy({
consumerKey: '123-456-789',
consumerSecret: ''
callbackURL: 'https://www.example.net/auth/familysearch/callback'
},
function(token, tokenSecret, profile, done) {
User.findOrCreate(..., function (err, user) {
done(err, user);
});
}
));
@param {Object} options
@param {Function} verify
@api public | [
"Legacy",
"Strategy",
"constructor",
"."
]
| eeb7588ee21b9523c49622aaaffb3a45570dd40f | https://github.com/jaredhanson/passport-familysearch/blob/eeb7588ee21b9523c49622aaaffb3a45570dd40f/lib/passport-familysearch/legacy-strategy.js#L43-L97 |
45,571 | ex-machine/ng-classified | src/ng-classified.js | injectorInjectInvokers | function injectorInjectInvokers(injector) {
var invoke_ = injector.invoke;
injector.instantiate = instantiate;
injector.invoke = invoke;
return injector;
// pasted method that picks up patched 'invoke'
function instantiate(Type, locals, serviceName) {
var instance = Object.create((Array.isArray(Type) ? Type[Type.length - 1] : Type).prototype || null);
var returnedValue = invoke(Type, instance, locals, serviceName);
return (returnedValue !== null && typeof returnedValue === 'object') || (typeof returnedValue === 'function') ? returnedValue : instance;
}
function invoke() {
var argsLength = arguments.length;
var args = new Array(argsLength);
for (var i = 0; i < argsLength; i++) {
args[i] = arguments[i];
}
var nativeClassRegex = /^class/;
var classRegex = /class/i;
var invokeResult;
var fn = args[0];
var skipClassify = !angular.isFunction(fn) || fn.hasOwnProperty('$$classified');
if (!skipClassify) {
if (fn.$classify || nativeClassRegex.test(fn.toString())) {
classifyInvokee(args);
} else if (this.$classify || (this.$classify !== false && classRegex.test(fn.toString()))) {
try {
invokeResult = apply(injector, invoke_, args);
fn.$$classified = false;
} catch (e) {
if (e instanceof TypeError && classRegex.test(e.message)) {
classifyInvokee(args);
} else {
throw e;
}
}
}
}
return invokeResult || apply(injector, invoke_, args);
}
function classifyInvokee(args) {
var fn_ = args[0];
var fn = args[0] = function () {
var fnArgsLength = arguments.length + 1;
var fnArgs = new Array(fnArgsLength);
for (var i = 1; i < fnArgsLength; i++) {
fnArgs[i] = arguments[i - 1];
}
// fnArgs[0] === undefined
return new (apply(fn_, Function.prototype.bind, fnArgs));
};
injector.annotate(fn_);
fn.$inject = fn_.$inject;
fn.$$classified = true;
}
} | javascript | function injectorInjectInvokers(injector) {
var invoke_ = injector.invoke;
injector.instantiate = instantiate;
injector.invoke = invoke;
return injector;
// pasted method that picks up patched 'invoke'
function instantiate(Type, locals, serviceName) {
var instance = Object.create((Array.isArray(Type) ? Type[Type.length - 1] : Type).prototype || null);
var returnedValue = invoke(Type, instance, locals, serviceName);
return (returnedValue !== null && typeof returnedValue === 'object') || (typeof returnedValue === 'function') ? returnedValue : instance;
}
function invoke() {
var argsLength = arguments.length;
var args = new Array(argsLength);
for (var i = 0; i < argsLength; i++) {
args[i] = arguments[i];
}
var nativeClassRegex = /^class/;
var classRegex = /class/i;
var invokeResult;
var fn = args[0];
var skipClassify = !angular.isFunction(fn) || fn.hasOwnProperty('$$classified');
if (!skipClassify) {
if (fn.$classify || nativeClassRegex.test(fn.toString())) {
classifyInvokee(args);
} else if (this.$classify || (this.$classify !== false && classRegex.test(fn.toString()))) {
try {
invokeResult = apply(injector, invoke_, args);
fn.$$classified = false;
} catch (e) {
if (e instanceof TypeError && classRegex.test(e.message)) {
classifyInvokee(args);
} else {
throw e;
}
}
}
}
return invokeResult || apply(injector, invoke_, args);
}
function classifyInvokee(args) {
var fn_ = args[0];
var fn = args[0] = function () {
var fnArgsLength = arguments.length + 1;
var fnArgs = new Array(fnArgsLength);
for (var i = 1; i < fnArgsLength; i++) {
fnArgs[i] = arguments[i - 1];
}
// fnArgs[0] === undefined
return new (apply(fn_, Function.prototype.bind, fnArgs));
};
injector.annotate(fn_);
fn.$inject = fn_.$inject;
fn.$$classified = true;
}
} | [
"function",
"injectorInjectInvokers",
"(",
"injector",
")",
"{",
"var",
"invoke_",
"=",
"injector",
".",
"invoke",
";",
"injector",
".",
"instantiate",
"=",
"instantiate",
";",
"injector",
".",
"invoke",
"=",
"invoke",
";",
"return",
"injector",
";",
"// pasted method that picks up patched 'invoke'\r",
"function",
"instantiate",
"(",
"Type",
",",
"locals",
",",
"serviceName",
")",
"{",
"var",
"instance",
"=",
"Object",
".",
"create",
"(",
"(",
"Array",
".",
"isArray",
"(",
"Type",
")",
"?",
"Type",
"[",
"Type",
".",
"length",
"-",
"1",
"]",
":",
"Type",
")",
".",
"prototype",
"||",
"null",
")",
";",
"var",
"returnedValue",
"=",
"invoke",
"(",
"Type",
",",
"instance",
",",
"locals",
",",
"serviceName",
")",
";",
"return",
"(",
"returnedValue",
"!==",
"null",
"&&",
"typeof",
"returnedValue",
"===",
"'object'",
")",
"||",
"(",
"typeof",
"returnedValue",
"===",
"'function'",
")",
"?",
"returnedValue",
":",
"instance",
";",
"}",
"function",
"invoke",
"(",
")",
"{",
"var",
"argsLength",
"=",
"arguments",
".",
"length",
";",
"var",
"args",
"=",
"new",
"Array",
"(",
"argsLength",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"argsLength",
";",
"i",
"++",
")",
"{",
"args",
"[",
"i",
"]",
"=",
"arguments",
"[",
"i",
"]",
";",
"}",
"var",
"nativeClassRegex",
"=",
"/",
"^class",
"/",
";",
"var",
"classRegex",
"=",
"/",
"class",
"/",
"i",
";",
"var",
"invokeResult",
";",
"var",
"fn",
"=",
"args",
"[",
"0",
"]",
";",
"var",
"skipClassify",
"=",
"!",
"angular",
".",
"isFunction",
"(",
"fn",
")",
"||",
"fn",
".",
"hasOwnProperty",
"(",
"'$$classified'",
")",
";",
"if",
"(",
"!",
"skipClassify",
")",
"{",
"if",
"(",
"fn",
".",
"$classify",
"||",
"nativeClassRegex",
".",
"test",
"(",
"fn",
".",
"toString",
"(",
")",
")",
")",
"{",
"classifyInvokee",
"(",
"args",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"$classify",
"||",
"(",
"this",
".",
"$classify",
"!==",
"false",
"&&",
"classRegex",
".",
"test",
"(",
"fn",
".",
"toString",
"(",
")",
")",
")",
")",
"{",
"try",
"{",
"invokeResult",
"=",
"apply",
"(",
"injector",
",",
"invoke_",
",",
"args",
")",
";",
"fn",
".",
"$$classified",
"=",
"false",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"TypeError",
"&&",
"classRegex",
".",
"test",
"(",
"e",
".",
"message",
")",
")",
"{",
"classifyInvokee",
"(",
"args",
")",
";",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"}",
"}",
"}",
"return",
"invokeResult",
"||",
"apply",
"(",
"injector",
",",
"invoke_",
",",
"args",
")",
";",
"}",
"function",
"classifyInvokee",
"(",
"args",
")",
"{",
"var",
"fn_",
"=",
"args",
"[",
"0",
"]",
";",
"var",
"fn",
"=",
"args",
"[",
"0",
"]",
"=",
"function",
"(",
")",
"{",
"var",
"fnArgsLength",
"=",
"arguments",
".",
"length",
"+",
"1",
";",
"var",
"fnArgs",
"=",
"new",
"Array",
"(",
"fnArgsLength",
")",
";",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"fnArgsLength",
";",
"i",
"++",
")",
"{",
"fnArgs",
"[",
"i",
"]",
"=",
"arguments",
"[",
"i",
"-",
"1",
"]",
";",
"}",
"// fnArgs[0] === undefined \r",
"return",
"new",
"(",
"apply",
"(",
"fn_",
",",
"Function",
".",
"prototype",
".",
"bind",
",",
"fnArgs",
")",
")",
";",
"}",
";",
"injector",
".",
"annotate",
"(",
"fn_",
")",
";",
"fn",
".",
"$inject",
"=",
"fn_",
".",
"$inject",
";",
"fn",
".",
"$$classified",
"=",
"true",
";",
"}",
"}"
]
| Invoker injects invokee,
Injector invokes injectee,
Morrow instantiates. | [
"Invoker",
"injects",
"invokee",
"Injector",
"invokes",
"injectee",
"Morrow",
"instantiates",
"."
]
| 039eb956582ea10d64574bc1d3f047a0abcbd343 | https://github.com/ex-machine/ng-classified/blob/039eb956582ea10d64574bc1d3f047a0abcbd343/src/ng-classified.js#L26-L94 |
45,572 | Whitebolt/require-extra | src/fs.js | _addReadCallback | function _addReadCallback(filename) {
return new Promise((resolve, reject)=> {
readFileCallbacks.get(filename).add((err, data)=> {
if (err) return reject(err);
return resolve(data);
});
});
} | javascript | function _addReadCallback(filename) {
return new Promise((resolve, reject)=> {
readFileCallbacks.get(filename).add((err, data)=> {
if (err) return reject(err);
return resolve(data);
});
});
} | [
"function",
"_addReadCallback",
"(",
"filename",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"readFileCallbacks",
".",
"get",
"(",
"filename",
")",
".",
"add",
"(",
"(",
"err",
",",
"data",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"return",
"reject",
"(",
"err",
")",
";",
"return",
"resolve",
"(",
"data",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Add a callback for reading of given file.
@private
@param {string} filename File to set callback for.
@returns {Promise.<Buffer|*>} The file contents, once loaded. | [
"Add",
"a",
"callback",
"for",
"reading",
"of",
"given",
"file",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L176-L183 |
45,573 | Whitebolt/require-extra | src/fs.js | _addReadCallbacks | function _addReadCallbacks(filename, cache) {
const callbacks = new Set();
cache.set(filename, true);
readFileCallbacks.set(filename, callbacks);
return callbacks;
} | javascript | function _addReadCallbacks(filename, cache) {
const callbacks = new Set();
cache.set(filename, true);
readFileCallbacks.set(filename, callbacks);
return callbacks;
} | [
"function",
"_addReadCallbacks",
"(",
"filename",
",",
"cache",
")",
"{",
"const",
"callbacks",
"=",
"new",
"Set",
"(",
")",
";",
"cache",
".",
"set",
"(",
"filename",
",",
"true",
")",
";",
"readFileCallbacks",
".",
"set",
"(",
"filename",
",",
"callbacks",
")",
";",
"return",
"callbacks",
";",
"}"
]
| Add callbacks set for given file
@private
@param {string} filename File to add for.
@param {Map} cache Cache to use.
@returns {Set} The callbacks. | [
"Add",
"callbacks",
"set",
"for",
"given",
"file"
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L193-L198 |
45,574 | Whitebolt/require-extra | src/fs.js | _fireReadFileCallbacks | function _fireReadFileCallbacks(filename, data, error=false) {
const callbacks = readFileCallbacks.get(filename);
if (callbacks) {
if (callbacks.size) callbacks.forEach(callback=>error?callback(data, null):callback(null, data));
callbacks.clear();
readFileCallbacks.delete(filename);
}
} | javascript | function _fireReadFileCallbacks(filename, data, error=false) {
const callbacks = readFileCallbacks.get(filename);
if (callbacks) {
if (callbacks.size) callbacks.forEach(callback=>error?callback(data, null):callback(null, data));
callbacks.clear();
readFileCallbacks.delete(filename);
}
} | [
"function",
"_fireReadFileCallbacks",
"(",
"filename",
",",
"data",
",",
"error",
"=",
"false",
")",
"{",
"const",
"callbacks",
"=",
"readFileCallbacks",
".",
"get",
"(",
"filename",
")",
";",
"if",
"(",
"callbacks",
")",
"{",
"if",
"(",
"callbacks",
".",
"size",
")",
"callbacks",
".",
"forEach",
"(",
"callback",
"=>",
"error",
"?",
"callback",
"(",
"data",
",",
"null",
")",
":",
"callback",
"(",
"null",
",",
"data",
")",
")",
";",
"callbacks",
".",
"clear",
"(",
")",
";",
"readFileCallbacks",
".",
"delete",
"(",
"filename",
")",
";",
"}",
"}"
]
| Fire any awaiting callbacks for given file data.
@private
@param {string} filename The filename to fire callbacks on.
@param {Buffer|Error} data The received data.
@param {boolean} [error=false] Is this an error or file data? | [
"Fire",
"any",
"awaiting",
"callbacks",
"for",
"given",
"file",
"data",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L221-L228 |
45,575 | Whitebolt/require-extra | src/fs.js | _runFileQueue | function _runFileQueue() {
if (!settings) settings = require('./settings');
const simultaneous = settings.get('load-simultaneously') || 10;
if ((loading < simultaneous) && (fileQueue.length)) {
loading++;
fileQueue.shift()();
}
} | javascript | function _runFileQueue() {
if (!settings) settings = require('./settings');
const simultaneous = settings.get('load-simultaneously') || 10;
if ((loading < simultaneous) && (fileQueue.length)) {
loading++;
fileQueue.shift()();
}
} | [
"function",
"_runFileQueue",
"(",
")",
"{",
"if",
"(",
"!",
"settings",
")",
"settings",
"=",
"require",
"(",
"'./settings'",
")",
";",
"const",
"simultaneous",
"=",
"settings",
".",
"get",
"(",
"'load-simultaneously'",
")",
"||",
"10",
";",
"if",
"(",
"(",
"loading",
"<",
"simultaneous",
")",
"&&",
"(",
"fileQueue",
".",
"length",
")",
")",
"{",
"loading",
"++",
";",
"fileQueue",
".",
"shift",
"(",
")",
"(",
")",
";",
"}",
"}"
]
| File queue handler.
@private | [
"File",
"queue",
"handler",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L235-L243 |
45,576 | Whitebolt/require-extra | src/fs.js | _readFileOnEnd | function _readFileOnEnd(filename, contents, cache) {
loading--;
const data = Buffer.concat(contents);
cache.set(filename, data);
_fireReadFileCallbacks(filename, data);
_runFileQueue();
} | javascript | function _readFileOnEnd(filename, contents, cache) {
loading--;
const data = Buffer.concat(contents);
cache.set(filename, data);
_fireReadFileCallbacks(filename, data);
_runFileQueue();
} | [
"function",
"_readFileOnEnd",
"(",
"filename",
",",
"contents",
",",
"cache",
")",
"{",
"loading",
"--",
";",
"const",
"data",
"=",
"Buffer",
".",
"concat",
"(",
"contents",
")",
";",
"cache",
".",
"set",
"(",
"filename",
",",
"data",
")",
";",
"_fireReadFileCallbacks",
"(",
"filename",
",",
"data",
")",
";",
"_runFileQueue",
"(",
")",
";",
"}"
]
| On end listener for readFile.
@private
@param {string} filename The filename.
@param {Array.<Buffer>} contents The file contents as a series of buffers.
@param {Map} cache The file cache. | [
"On",
"end",
"listener",
"for",
"readFile",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L253-L259 |
45,577 | Whitebolt/require-extra | src/fs.js | readFile | function readFile(filename, cache, encoding=null) {
if (cache.has(filename)) return _handleFileInCache(filename, cache);
_addReadCallbacks(filename, cache);
fileQueue.push(()=>{
const contents = [];
fs.createReadStream(filename, {encoding})
.on('data', chunk=>contents.push(chunk))
.on('end', ()=>_readFileOnEnd(filename, contents, cache))
.on('error', error=>_readFileOnError(filename, error))
});
_runFileQueue();
return _handleFileInCache(filename, cache);
} | javascript | function readFile(filename, cache, encoding=null) {
if (cache.has(filename)) return _handleFileInCache(filename, cache);
_addReadCallbacks(filename, cache);
fileQueue.push(()=>{
const contents = [];
fs.createReadStream(filename, {encoding})
.on('data', chunk=>contents.push(chunk))
.on('end', ()=>_readFileOnEnd(filename, contents, cache))
.on('error', error=>_readFileOnError(filename, error))
});
_runFileQueue();
return _handleFileInCache(filename, cache);
} | [
"function",
"readFile",
"(",
"filename",
",",
"cache",
",",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"cache",
".",
"has",
"(",
"filename",
")",
")",
"return",
"_handleFileInCache",
"(",
"filename",
",",
"cache",
")",
";",
"_addReadCallbacks",
"(",
"filename",
",",
"cache",
")",
";",
"fileQueue",
".",
"push",
"(",
"(",
")",
"=>",
"{",
"const",
"contents",
"=",
"[",
"]",
";",
"fs",
".",
"createReadStream",
"(",
"filename",
",",
"{",
"encoding",
"}",
")",
".",
"on",
"(",
"'data'",
",",
"chunk",
"=>",
"contents",
".",
"push",
"(",
"chunk",
")",
")",
".",
"on",
"(",
"'end'",
",",
"(",
")",
"=>",
"_readFileOnEnd",
"(",
"filename",
",",
"contents",
",",
"cache",
")",
")",
".",
"on",
"(",
"'error'",
",",
"error",
"=>",
"_readFileOnError",
"(",
"filename",
",",
"error",
")",
")",
"}",
")",
";",
"_runFileQueue",
"(",
")",
";",
"return",
"_handleFileInCache",
"(",
"filename",
",",
"cache",
")",
";",
"}"
]
| Load a file synchronously using a cache.
@public
@param {string} filename The file to load.
@param {Map} cache The cache to use.
@param {null|string} [encoding=null] The encoding to load as.
@returns {Promise.<Buffer|*>} The load results. | [
"Load",
"a",
"file",
"synchronously",
"using",
"a",
"cache",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L283-L295 |
45,578 | Whitebolt/require-extra | src/fs.js | readFileSync | function readFileSync(filename, cache, encoding=null) {
if (cache.has(filename) && (cache.get(filename) !== true)) return cache.get(filename);
const data = fs.readFileSync(filename, encoding);
cache.set(filename, data);
return data;
} | javascript | function readFileSync(filename, cache, encoding=null) {
if (cache.has(filename) && (cache.get(filename) !== true)) return cache.get(filename);
const data = fs.readFileSync(filename, encoding);
cache.set(filename, data);
return data;
} | [
"function",
"readFileSync",
"(",
"filename",
",",
"cache",
",",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"cache",
".",
"has",
"(",
"filename",
")",
"&&",
"(",
"cache",
".",
"get",
"(",
"filename",
")",
"!==",
"true",
")",
")",
"return",
"cache",
".",
"get",
"(",
"filename",
")",
";",
"const",
"data",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
",",
"encoding",
")",
";",
"cache",
".",
"set",
"(",
"filename",
",",
"data",
")",
";",
"return",
"data",
";",
"}"
]
| Read a file synchronously using file cache.
@param {string} filename The filename to load.
@param {Map} cache The cache to use.
@param {null|strin} [encoding=null] The encoding to use.
@returns {Buffer\*} The file contents as a buffer. | [
"Read",
"a",
"file",
"synchronously",
"using",
"file",
"cache",
"."
]
| 2a8f737aab67305c9fda3ee56aa7953e97cee859 | https://github.com/Whitebolt/require-extra/blob/2a8f737aab67305c9fda3ee56aa7953e97cee859/src/fs.js#L319-L324 |
45,579 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input) {
debug('booleanFilter(%s)', input);
if (_.isBoolean(input)) return input;
if (_.isString(input)) {
var lc = input.toLocaleLowerCase();
var pos = ['false', 'true'].indexOf(lc);
if (pos > -1) return (pos > 0);
}
return undefined;
} | javascript | function (input) {
debug('booleanFilter(%s)', input);
if (_.isBoolean(input)) return input;
if (_.isString(input)) {
var lc = input.toLocaleLowerCase();
var pos = ['false', 'true'].indexOf(lc);
if (pos > -1) return (pos > 0);
}
return undefined;
} | [
"function",
"(",
"input",
")",
"{",
"debug",
"(",
"'booleanFilter(%s)'",
",",
"input",
")",
";",
"if",
"(",
"_",
".",
"isBoolean",
"(",
"input",
")",
")",
"return",
"input",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
")",
"{",
"var",
"lc",
"=",
"input",
".",
"toLocaleLowerCase",
"(",
")",
";",
"var",
"pos",
"=",
"[",
"'false'",
",",
"'true'",
"]",
".",
"indexOf",
"(",
"lc",
")",
";",
"if",
"(",
"pos",
">",
"-",
"1",
")",
"return",
"(",
"pos",
">",
"0",
")",
";",
"}",
"return",
"undefined",
";",
"}"
]
| If we are given a boolean value return it.
If we are given a string with the value 'false' return false
If we are given a string with the value 'true' return true
Otherwise return undefined
@param {(boolean|string|undefined|null)} input
@returns {(true|false|undefined)} | [
"If",
"we",
"are",
"given",
"a",
"boolean",
"value",
"return",
"it",
".",
"If",
"we",
"are",
"given",
"a",
"string",
"with",
"the",
"value",
"false",
"return",
"false",
"If",
"we",
"are",
"given",
"a",
"string",
"with",
"the",
"value",
"true",
"return",
"true",
"Otherwise",
"return",
"undefined"
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L28-L37 |
|
45,580 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input) {
debug('booleanTextFilter(%s)', input);
var retv = module.exports.booleanFilter(input);
return (retv === undefined
? undefined
: (retv === false
? 'false'
: 'true'));
} | javascript | function (input) {
debug('booleanTextFilter(%s)', input);
var retv = module.exports.booleanFilter(input);
return (retv === undefined
? undefined
: (retv === false
? 'false'
: 'true'));
} | [
"function",
"(",
"input",
")",
"{",
"debug",
"(",
"'booleanTextFilter(%s)'",
",",
"input",
")",
";",
"var",
"retv",
"=",
"module",
".",
"exports",
".",
"booleanFilter",
"(",
"input",
")",
";",
"return",
"(",
"retv",
"===",
"undefined",
"?",
"undefined",
":",
"(",
"retv",
"===",
"false",
"?",
"'false'",
":",
"'true'",
")",
")",
";",
"}"
]
| Same as booleanFilter but but return 'true' and 'false'
in place of true and false respectively.
@param {(boolean|string|undefined|null)} input
@returns {('true'|'false'|undefined)} | [
"Same",
"as",
"booleanFilter",
"but",
"but",
"return",
"true",
"and",
"false",
"in",
"place",
"of",
"true",
"and",
"false",
"respectively",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L46-L54 |
|
45,581 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input, list) {
debug('chooseOneFilter(%s, %s)', input, JSON.stringify(list));
if (input === true) return undefined;
if (_.isString(input)) {
if (_.isEmpty(input)) return undefined;
var ilc = input.toLocaleLowerCase();
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
if (item.toLocaleLowerCase() === ilc) return item;
}
}
return undefined;
} | javascript | function (input, list) {
debug('chooseOneFilter(%s, %s)', input, JSON.stringify(list));
if (input === true) return undefined;
if (_.isString(input)) {
if (_.isEmpty(input)) return undefined;
var ilc = input.toLocaleLowerCase();
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
if (item.toLocaleLowerCase() === ilc) return item;
}
}
return undefined;
} | [
"function",
"(",
"input",
",",
"list",
")",
"{",
"debug",
"(",
"'chooseOneFilter(%s, %s)'",
",",
"input",
",",
"JSON",
".",
"stringify",
"(",
"list",
")",
")",
";",
"if",
"(",
"input",
"===",
"true",
")",
"return",
"undefined",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
")",
"{",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"input",
")",
")",
"return",
"undefined",
";",
"var",
"ilc",
"=",
"input",
".",
"toLocaleLowerCase",
"(",
")",
";",
"for",
"(",
"var",
"idx",
"=",
"0",
";",
"idx",
"<",
"list",
".",
"length",
";",
"idx",
"++",
")",
"{",
"var",
"item",
"=",
"list",
"[",
"idx",
"]",
";",
"if",
"(",
"item",
".",
"toLocaleLowerCase",
"(",
")",
"===",
"ilc",
")",
"return",
"item",
";",
"}",
"}",
"return",
"undefined",
";",
"}"
]
| Check if input exists in list in a case insensitive manner. Will return
the value from the list rather than the user input so the list can control
the final case.
NOTE 1: The list may not contain, undefined, null or the empty string.
NOTE 2: If there are multiple matches, the first one wins.
@param {(string|boolean|undefined|null)} input
@param {string[]} list
@returns {(string|undefined)} | [
"Check",
"if",
"input",
"exists",
"in",
"list",
"in",
"a",
"case",
"insensitive",
"manner",
".",
"Will",
"return",
"the",
"value",
"from",
"the",
"list",
"rather",
"than",
"the",
"user",
"input",
"so",
"the",
"list",
"can",
"control",
"the",
"final",
"case",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L68-L80 |
|
45,582 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input, list) {
debug('chooseOneStartsWithFilter(%s, %s)', input, JSON.stringify(list));
if (input === true) return undefined;
var retv;
if (_.isString(input)) {
if (input === '') return undefined;
var ilc = input.toLocaleLowerCase();
_.forEach(list, function (item) {
var it = item.toLocaleLowerCase();
if (_.startsWith(it, ilc)) retv = retv || item;
if (it === ilc) retv = item;
});
}
return retv;
} | javascript | function (input, list) {
debug('chooseOneStartsWithFilter(%s, %s)', input, JSON.stringify(list));
if (input === true) return undefined;
var retv;
if (_.isString(input)) {
if (input === '') return undefined;
var ilc = input.toLocaleLowerCase();
_.forEach(list, function (item) {
var it = item.toLocaleLowerCase();
if (_.startsWith(it, ilc)) retv = retv || item;
if (it === ilc) retv = item;
});
}
return retv;
} | [
"function",
"(",
"input",
",",
"list",
")",
"{",
"debug",
"(",
"'chooseOneStartsWithFilter(%s, %s)'",
",",
"input",
",",
"JSON",
".",
"stringify",
"(",
"list",
")",
")",
";",
"if",
"(",
"input",
"===",
"true",
")",
"return",
"undefined",
";",
"var",
"retv",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
")",
"{",
"if",
"(",
"input",
"===",
"''",
")",
"return",
"undefined",
";",
"var",
"ilc",
"=",
"input",
".",
"toLocaleLowerCase",
"(",
")",
";",
"_",
".",
"forEach",
"(",
"list",
",",
"function",
"(",
"item",
")",
"{",
"var",
"it",
"=",
"item",
".",
"toLocaleLowerCase",
"(",
")",
";",
"if",
"(",
"_",
".",
"startsWith",
"(",
"it",
",",
"ilc",
")",
")",
"retv",
"=",
"retv",
"||",
"item",
";",
"if",
"(",
"it",
"===",
"ilc",
")",
"retv",
"=",
"item",
";",
"}",
")",
";",
"}",
"return",
"retv",
";",
"}"
]
| Check if any items in the list start with the input in a case insensitive
manner. Will return the value from the list rather than the user input so
the list can control the final case.
NOTE 1: The list may not contain, undefined, null or the empty string.
NOTE 2: If there are multiple partial matches, the first one wins.
NOTE 3: If there is an exact match, it will be returned even if there is
a prior partial match.
@param {(string|boolean|undefined|null)} input
@param {string[]} list
@returns {(string|undefined)} | [
"Check",
"if",
"any",
"items",
"in",
"the",
"list",
"start",
"with",
"the",
"input",
"in",
"a",
"case",
"insensitive",
"manner",
".",
"Will",
"return",
"the",
"value",
"from",
"the",
"list",
"rather",
"than",
"the",
"user",
"input",
"so",
"the",
"list",
"can",
"control",
"the",
"final",
"case",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L101-L115 |
|
45,583 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input, map) {
// TODO(bwavell): write tests
debug('chooseOneMapStartsWithFilter(%s, %s)', input, JSON.stringify(map));
if (input === true) return undefined;
var retv;
if (_.isString(input)) {
if (input === '') return undefined;
var ilc = input.toLocaleLowerCase();
_.forOwn(map, function (value, key) {
var kit = key.toLocaleLowerCase();
var vit = value.toLocaleLowerCase();
if (_.startsWith(kit, ilc)) retv = retv || value;
if (kit === ilc) retv = value;
if (vit === ilc) retv = value;
});
}
return retv;
} | javascript | function (input, map) {
// TODO(bwavell): write tests
debug('chooseOneMapStartsWithFilter(%s, %s)', input, JSON.stringify(map));
if (input === true) return undefined;
var retv;
if (_.isString(input)) {
if (input === '') return undefined;
var ilc = input.toLocaleLowerCase();
_.forOwn(map, function (value, key) {
var kit = key.toLocaleLowerCase();
var vit = value.toLocaleLowerCase();
if (_.startsWith(kit, ilc)) retv = retv || value;
if (kit === ilc) retv = value;
if (vit === ilc) retv = value;
});
}
return retv;
} | [
"function",
"(",
"input",
",",
"map",
")",
"{",
"// TODO(bwavell): write tests",
"debug",
"(",
"'chooseOneMapStartsWithFilter(%s, %s)'",
",",
"input",
",",
"JSON",
".",
"stringify",
"(",
"map",
")",
")",
";",
"if",
"(",
"input",
"===",
"true",
")",
"return",
"undefined",
";",
"var",
"retv",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
")",
"{",
"if",
"(",
"input",
"===",
"''",
")",
"return",
"undefined",
";",
"var",
"ilc",
"=",
"input",
".",
"toLocaleLowerCase",
"(",
")",
";",
"_",
".",
"forOwn",
"(",
"map",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"var",
"kit",
"=",
"key",
".",
"toLocaleLowerCase",
"(",
")",
";",
"var",
"vit",
"=",
"value",
".",
"toLocaleLowerCase",
"(",
")",
";",
"if",
"(",
"_",
".",
"startsWith",
"(",
"kit",
",",
"ilc",
")",
")",
"retv",
"=",
"retv",
"||",
"value",
";",
"if",
"(",
"kit",
"===",
"ilc",
")",
"retv",
"=",
"value",
";",
"if",
"(",
"vit",
"===",
"ilc",
")",
"retv",
"=",
"value",
";",
"}",
")",
";",
"}",
"return",
"retv",
";",
"}"
]
| Check if any keys in the map start with the input in a case insensitive
manner. Will return the value from the map rather than the user input so
the map can control the final case. If there is an exact case insensitive
match to a value, the value will be returned.
NOTE 1: The map may not contain, undefined, null or the empty string.
NOTE 2: If there are multiple partial matches, the first one wins.
NOTE 3: If there is an exact match, it will be returned even if there is
a prior partial match.
NOTE 4: If there are multiple exact matches (e.g. duplicate values) then
the last exact match will be returned.
@param {(string|boolean|undefined|null)} input
@param {Object.<string, string>} map
@returns {(string|undefined)} | [
"Check",
"if",
"any",
"keys",
"in",
"the",
"map",
"start",
"with",
"the",
"input",
"in",
"a",
"case",
"insensitive",
"manner",
".",
"Will",
"return",
"the",
"value",
"from",
"the",
"map",
"rather",
"than",
"the",
"user",
"input",
"so",
"the",
"map",
"can",
"control",
"the",
"final",
"case",
".",
"If",
"there",
"is",
"an",
"exact",
"case",
"insensitive",
"match",
"to",
"a",
"value",
"the",
"value",
"will",
"be",
"returned",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L174-L191 |
|
45,584 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input) {
debug('optionalTextFilter(%s)', input);
if (_.isString(input)) return input;
if (_.isBoolean(input)) return (input ? '' : undefined);
if (_.isNumber(input)) return '' + input;
return undefined;
} | javascript | function (input) {
debug('optionalTextFilter(%s)', input);
if (_.isString(input)) return input;
if (_.isBoolean(input)) return (input ? '' : undefined);
if (_.isNumber(input)) return '' + input;
return undefined;
} | [
"function",
"(",
"input",
")",
"{",
"debug",
"(",
"'optionalTextFilter(%s)'",
",",
"input",
")",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
")",
"return",
"input",
";",
"if",
"(",
"_",
".",
"isBoolean",
"(",
"input",
")",
")",
"return",
"(",
"input",
"?",
"''",
":",
"undefined",
")",
";",
"if",
"(",
"_",
".",
"isNumber",
"(",
"input",
")",
")",
"return",
"''",
"+",
"input",
";",
"return",
"undefined",
";",
"}"
]
| Given some text or the empty string return it.
If we receive true return empty string.
If we receive a number convert it to a string and return it.
Otherwise return undefined.
@param {(string|boolean|number|undefined|null)} input
@returns {(string|undefined)} | [
"Given",
"some",
"text",
"or",
"the",
"empty",
"string",
"return",
"it",
".",
"If",
"we",
"receive",
"true",
"return",
"empty",
"string",
".",
"If",
"we",
"receive",
"a",
"number",
"convert",
"it",
"to",
"a",
"string",
"and",
"return",
"it",
".",
"Otherwise",
"return",
"undefined",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L208-L214 |
|
45,585 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input) {
debug('requiredTextFilter(%s)', input);
if (_.isString(input) && !_.isEmpty(input)) return input;
if (_.isNumber(input)) return '' + input;
return undefined;
} | javascript | function (input) {
debug('requiredTextFilter(%s)', input);
if (_.isString(input) && !_.isEmpty(input)) return input;
if (_.isNumber(input)) return '' + input;
return undefined;
} | [
"function",
"(",
"input",
")",
"{",
"debug",
"(",
"'requiredTextFilter(%s)'",
",",
"input",
")",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
"&&",
"!",
"_",
".",
"isEmpty",
"(",
"input",
")",
")",
"return",
"input",
";",
"if",
"(",
"_",
".",
"isNumber",
"(",
"input",
")",
")",
"return",
"''",
"+",
"input",
";",
"return",
"undefined",
";",
"}"
]
| Given some none empty text return it.
If we receive a number convert it to a string and return it.
Otherwise return undefined.
@param {(string|boolean|undefined|null)} input
@returns {(string|undefined)} | [
"Given",
"some",
"none",
"empty",
"text",
"return",
"it",
".",
"If",
"we",
"receive",
"a",
"number",
"convert",
"it",
"to",
"a",
"string",
"and",
"return",
"it",
".",
"Otherwise",
"return",
"undefined",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L224-L229 |
|
45,586 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input, sep, choices) {
debug('requiredTextListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
// if we already have a list, just return it. We may
// want to add validation that the items are in the
// choices list
if (_.isArray(input) && input.length > 0) return input;
if (!_.isString(input)) return undefined;
var retv = input.split(new RegExp('s*\\' + sep + '\\s*'));
// remove any empty input items
retv = retv.filter(function (r) {
return (!_.isEmpty(r));
});
// If a choice list is provided we will return only items
// that match the choice in a case insensitive way, using
// whatever case is provided in the choice list.
if (choices !== undefined) {
var lcretv = retv.map(function (lc) {
return lc.toLocaleLowerCase();
});
retv = choices.filter(function (c) {
return (lcretv.indexOf(c.toLocaleLowerCase()) > -1);
});
}
if (_.isEmpty(retv)) return undefined;
return retv;
} | javascript | function (input, sep, choices) {
debug('requiredTextListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
// if we already have a list, just return it. We may
// want to add validation that the items are in the
// choices list
if (_.isArray(input) && input.length > 0) return input;
if (!_.isString(input)) return undefined;
var retv = input.split(new RegExp('s*\\' + sep + '\\s*'));
// remove any empty input items
retv = retv.filter(function (r) {
return (!_.isEmpty(r));
});
// If a choice list is provided we will return only items
// that match the choice in a case insensitive way, using
// whatever case is provided in the choice list.
if (choices !== undefined) {
var lcretv = retv.map(function (lc) {
return lc.toLocaleLowerCase();
});
retv = choices.filter(function (c) {
return (lcretv.indexOf(c.toLocaleLowerCase()) > -1);
});
}
if (_.isEmpty(retv)) return undefined;
return retv;
} | [
"function",
"(",
"input",
",",
"sep",
",",
"choices",
")",
"{",
"debug",
"(",
"'requiredTextListFilter(%s, %s, %s)'",
",",
"input",
",",
"sep",
",",
"(",
"choices",
"?",
"JSON",
".",
"stringify",
"(",
"choices",
")",
":",
"'undefined'",
")",
")",
";",
"// if we already have a list, just return it. We may",
"// want to add validation that the items are in the",
"// choices list",
"if",
"(",
"_",
".",
"isArray",
"(",
"input",
")",
"&&",
"input",
".",
"length",
">",
"0",
")",
"return",
"input",
";",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"input",
")",
")",
"return",
"undefined",
";",
"var",
"retv",
"=",
"input",
".",
"split",
"(",
"new",
"RegExp",
"(",
"'s*\\\\'",
"+",
"sep",
"+",
"'\\\\s*'",
")",
")",
";",
"// remove any empty input items",
"retv",
"=",
"retv",
".",
"filter",
"(",
"function",
"(",
"r",
")",
"{",
"return",
"(",
"!",
"_",
".",
"isEmpty",
"(",
"r",
")",
")",
";",
"}",
")",
";",
"// If a choice list is provided we will return only items",
"// that match the choice in a case insensitive way, using",
"// whatever case is provided in the choice list.",
"if",
"(",
"choices",
"!==",
"undefined",
")",
"{",
"var",
"lcretv",
"=",
"retv",
".",
"map",
"(",
"function",
"(",
"lc",
")",
"{",
"return",
"lc",
".",
"toLocaleLowerCase",
"(",
")",
";",
"}",
")",
";",
"retv",
"=",
"choices",
".",
"filter",
"(",
"function",
"(",
"c",
")",
"{",
"return",
"(",
"lcretv",
".",
"indexOf",
"(",
"c",
".",
"toLocaleLowerCase",
"(",
")",
")",
">",
"-",
"1",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"retv",
")",
")",
"return",
"undefined",
";",
"return",
"retv",
";",
"}"
]
| Given some input text, a separator and an optional list of
choices, we split the input using the separator. We remove
any empty items from the list.
If choices are provided then we only provide values that
match the choices in a case insensitive way and we return
in the order provided in the choices list and using the
case provided in the choices list.
An empty list is not allowed (undefined will be returned.)
@param input
@param sep
@param choices
@returns {(string[]|undefined)} | [
"Given",
"some",
"input",
"text",
"a",
"separator",
"and",
"an",
"optional",
"list",
"of",
"choices",
"we",
"split",
"the",
"input",
"using",
"the",
"separator",
".",
"We",
"remove",
"any",
"empty",
"items",
"from",
"the",
"list",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L248-L273 |
|
45,587 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input, sep, choices) {
debug('requiredTextStartsWithListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
// if we already have a list, just return it. We may
// want to add validation that the items are in the
// choices list
if (_.isArray(input) && input.length > 0) return input;
if (choices === undefined) return undefined;
if (!_.isString(input)) return undefined;
var inputs = input.split(new RegExp('s*\\' + sep + '\\s*'));
// remove any empty input items
inputs = inputs.filter(function (i) {
return (!_.isEmpty(i));
});
var lcis = inputs.map(function (i) {
return i.toLocaleLowerCase();
});
var retv = choices.filter(function (c) {
var lc = c.toLocaleLowerCase();
return (_.find(lcis, function (li) {
return (_.startsWith(lc, li));
}) !== undefined);
});
if (_.isEmpty(retv)) return undefined;
return retv;
} | javascript | function (input, sep, choices) {
debug('requiredTextStartsWithListFilter(%s, %s, %s)', input, sep, (choices ? JSON.stringify(choices) : 'undefined'));
// if we already have a list, just return it. We may
// want to add validation that the items are in the
// choices list
if (_.isArray(input) && input.length > 0) return input;
if (choices === undefined) return undefined;
if (!_.isString(input)) return undefined;
var inputs = input.split(new RegExp('s*\\' + sep + '\\s*'));
// remove any empty input items
inputs = inputs.filter(function (i) {
return (!_.isEmpty(i));
});
var lcis = inputs.map(function (i) {
return i.toLocaleLowerCase();
});
var retv = choices.filter(function (c) {
var lc = c.toLocaleLowerCase();
return (_.find(lcis, function (li) {
return (_.startsWith(lc, li));
}) !== undefined);
});
if (_.isEmpty(retv)) return undefined;
return retv;
} | [
"function",
"(",
"input",
",",
"sep",
",",
"choices",
")",
"{",
"debug",
"(",
"'requiredTextStartsWithListFilter(%s, %s, %s)'",
",",
"input",
",",
"sep",
",",
"(",
"choices",
"?",
"JSON",
".",
"stringify",
"(",
"choices",
")",
":",
"'undefined'",
")",
")",
";",
"// if we already have a list, just return it. We may",
"// want to add validation that the items are in the",
"// choices list",
"if",
"(",
"_",
".",
"isArray",
"(",
"input",
")",
"&&",
"input",
".",
"length",
">",
"0",
")",
"return",
"input",
";",
"if",
"(",
"choices",
"===",
"undefined",
")",
"return",
"undefined",
";",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"input",
")",
")",
"return",
"undefined",
";",
"var",
"inputs",
"=",
"input",
".",
"split",
"(",
"new",
"RegExp",
"(",
"'s*\\\\'",
"+",
"sep",
"+",
"'\\\\s*'",
")",
")",
";",
"// remove any empty input items",
"inputs",
"=",
"inputs",
".",
"filter",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"(",
"!",
"_",
".",
"isEmpty",
"(",
"i",
")",
")",
";",
"}",
")",
";",
"var",
"lcis",
"=",
"inputs",
".",
"map",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"i",
".",
"toLocaleLowerCase",
"(",
")",
";",
"}",
")",
";",
"var",
"retv",
"=",
"choices",
".",
"filter",
"(",
"function",
"(",
"c",
")",
"{",
"var",
"lc",
"=",
"c",
".",
"toLocaleLowerCase",
"(",
")",
";",
"return",
"(",
"_",
".",
"find",
"(",
"lcis",
",",
"function",
"(",
"li",
")",
"{",
"return",
"(",
"_",
".",
"startsWith",
"(",
"lc",
",",
"li",
")",
")",
";",
"}",
")",
"!==",
"undefined",
")",
";",
"}",
")",
";",
"if",
"(",
"_",
".",
"isEmpty",
"(",
"retv",
")",
")",
"return",
"undefined",
";",
"return",
"retv",
";",
"}"
]
| Given some input text, a separator and a list of choices, we
split the input using the separator. We remove any empty items
from the list.
We provide all choices that start-with in a case-insensitive
manner one of the inputs. We return in the order provided in
the choices list and using the case provided in the choices list.
An empty list is not allowed (undefined will be returned.)
@param input
@param sep
@param choices
@returns {(string[]|undefined)} | [
"Given",
"some",
"input",
"text",
"a",
"separator",
"and",
"a",
"list",
"of",
"choices",
"we",
"split",
"the",
"input",
"using",
"the",
"separator",
".",
"We",
"remove",
"any",
"empty",
"items",
"from",
"the",
"list",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L296-L320 |
|
45,588 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (input) {
debug('requiredTextFilter(%s)', input);
if (_.isString(input) && !_.isEmpty(input)) {
if (_.startsWith(input, 'VERSION-')) {
return input.substr(8);
}
return input;
}
if (_.isNumber(input)) return '' + input;
return undefined;
} | javascript | function (input) {
debug('requiredTextFilter(%s)', input);
if (_.isString(input) && !_.isEmpty(input)) {
if (_.startsWith(input, 'VERSION-')) {
return input.substr(8);
}
return input;
}
if (_.isNumber(input)) return '' + input;
return undefined;
} | [
"function",
"(",
"input",
")",
"{",
"debug",
"(",
"'requiredTextFilter(%s)'",
",",
"input",
")",
";",
"if",
"(",
"_",
".",
"isString",
"(",
"input",
")",
"&&",
"!",
"_",
".",
"isEmpty",
"(",
"input",
")",
")",
"{",
"if",
"(",
"_",
".",
"startsWith",
"(",
"input",
",",
"'VERSION-'",
")",
")",
"{",
"return",
"input",
".",
"substr",
"(",
"8",
")",
";",
"}",
"return",
"input",
";",
"}",
"if",
"(",
"_",
".",
"isNumber",
"(",
"input",
")",
")",
"return",
"''",
"+",
"input",
";",
"return",
"undefined",
";",
"}"
]
| Given some none empty text return it.
If the text starts with "VERSION-", remove that text
This is a stupid hack because Yeoman is messing
with our numeric options.
If we receive a number convert it to a string and return it.
Otherwise return undefined.
@param {(string|boolean|undefined|null)} input
@returns {(string|undefined)} | [
"Given",
"some",
"none",
"empty",
"text",
"return",
"it",
".",
"If",
"the",
"text",
"starts",
"with",
"VERSION",
"-",
"remove",
"that",
"text",
"This",
"is",
"a",
"stupid",
"hack",
"because",
"Yeoman",
"is",
"messing",
"with",
"our",
"numeric",
"options",
".",
"If",
"we",
"receive",
"a",
"number",
"convert",
"it",
"to",
"a",
"string",
"and",
"return",
"it",
".",
"Otherwise",
"return",
"undefined",
"."
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L338-L348 |
|
45,589 | binduwavell/generator-alfresco-common | lib/prompt-filters.js | function (filterArray) {
return function (input) {
return filterArray.reduce(function (previousValue, filter) {
return filter.call(this, previousValue);
}.bind(this), input);
};
} | javascript | function (filterArray) {
return function (input) {
return filterArray.reduce(function (previousValue, filter) {
return filter.call(this, previousValue);
}.bind(this), input);
};
} | [
"function",
"(",
"filterArray",
")",
"{",
"return",
"function",
"(",
"input",
")",
"{",
"return",
"filterArray",
".",
"reduce",
"(",
"function",
"(",
"previousValue",
",",
"filter",
")",
"{",
"return",
"filter",
".",
"call",
"(",
"this",
",",
"previousValue",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
",",
"input",
")",
";",
"}",
";",
"}"
]
| Given some input text and a array of filters,
we sequentially apply the filters to get the final value
@param filterArray
@returns function | [
"Given",
"some",
"input",
"text",
"and",
"a",
"array",
"of",
"filters",
"we",
"sequentially",
"apply",
"the",
"filters",
"to",
"get",
"the",
"final",
"value"
]
| d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4 | https://github.com/binduwavell/generator-alfresco-common/blob/d9ba309a1b1d26a97268a07a49ac9e5d86b31dc4/lib/prompt-filters.js#L406-L412 |
|
45,590 | Sobesednik/wrote | es5/src/read-dir.js | filterFiles | function filterFiles(files, recursive) {
var fileOrDir = function fileOrDir(lstat) {
return lstat.isFile() || lstat.isDirectory();
};
return files.filter(function (_ref) {
var lstat = _ref.lstat;
return recursive ? fileOrDir(lstat) : lstat.isFile();
});
} | javascript | function filterFiles(files, recursive) {
var fileOrDir = function fileOrDir(lstat) {
return lstat.isFile() || lstat.isDirectory();
};
return files.filter(function (_ref) {
var lstat = _ref.lstat;
return recursive ? fileOrDir(lstat) : lstat.isFile();
});
} | [
"function",
"filterFiles",
"(",
"files",
",",
"recursive",
")",
"{",
"var",
"fileOrDir",
"=",
"function",
"fileOrDir",
"(",
"lstat",
")",
"{",
"return",
"lstat",
".",
"isFile",
"(",
")",
"||",
"lstat",
".",
"isDirectory",
"(",
")",
";",
"}",
";",
"return",
"files",
".",
"filter",
"(",
"function",
"(",
"_ref",
")",
"{",
"var",
"lstat",
"=",
"_ref",
".",
"lstat",
";",
"return",
"recursive",
"?",
"fileOrDir",
"(",
"lstat",
")",
":",
"lstat",
".",
"isFile",
"(",
")",
";",
"}",
")",
";",
"}"
]
| Filter lstat results, taking only files if recursive is false.
@param {lstat[]} files An array with lstat results
@param {boolean} [recursive = false] Whether recursive mode is on
@returns {lstat[]} Filtered array. | [
"Filter",
"lstat",
"results",
"taking",
"only",
"files",
"if",
"recursive",
"is",
"false",
"."
]
| 24992ad3bba4e5959dfb617b6c1f22d9a1306ab9 | https://github.com/Sobesednik/wrote/blob/24992ad3bba4e5959dfb617b6c1f22d9a1306ab9/es5/src/read-dir.js#L16-L25 |
45,591 | plum-css/plum-fixture | lib/generator.js | extractFolders | function extractFolders( files ) {
return files.data.files.map( function extractPath( file ) {
return path.parse( file ).dir;
}).filter( function extractUnique( path, index, array ) {
return array.indexOf( path ) === index;
});
} | javascript | function extractFolders( files ) {
return files.data.files.map( function extractPath( file ) {
return path.parse( file ).dir;
}).filter( function extractUnique( path, index, array ) {
return array.indexOf( path ) === index;
});
} | [
"function",
"extractFolders",
"(",
"files",
")",
"{",
"return",
"files",
".",
"data",
".",
"files",
".",
"map",
"(",
"function",
"extractPath",
"(",
"file",
")",
"{",
"return",
"path",
".",
"parse",
"(",
"file",
")",
".",
"dir",
";",
"}",
")",
".",
"filter",
"(",
"function",
"extractUnique",
"(",
"path",
",",
"index",
",",
"array",
")",
"{",
"return",
"array",
".",
"indexOf",
"(",
"path",
")",
"===",
"index",
";",
"}",
")",
";",
"}"
]
| Parses retrieved KSS meta data and extracts a list of folders to create fixtures for.
@param {array} files - a list of all the files retrieved from the KSS meta data.
@returns {array} a list of all the folders to create fixtures for. | [
"Parses",
"retrieved",
"KSS",
"meta",
"data",
"and",
"extracts",
"a",
"list",
"of",
"folders",
"to",
"create",
"fixtures",
"for",
"."
]
| 2cd69772c7888f2c787641e2ef65d54cb1af839f | https://github.com/plum-css/plum-fixture/blob/2cd69772c7888f2c787641e2ef65d54cb1af839f/lib/generator.js#L71-L77 |
45,592 | plum-css/plum-fixture | lib/generator.js | createFixtures | function createFixtures( path ) {
return parseKSS( path )
.then( extractFixturesData )
.then( function( data ) {
return saveFixture( data[0].name, data, path );
})
} | javascript | function createFixtures( path ) {
return parseKSS( path )
.then( extractFixturesData )
.then( function( data ) {
return saveFixture( data[0].name, data, path );
})
} | [
"function",
"createFixtures",
"(",
"path",
")",
"{",
"return",
"parseKSS",
"(",
"path",
")",
".",
"then",
"(",
"extractFixturesData",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"return",
"saveFixture",
"(",
"data",
"[",
"0",
"]",
".",
"name",
",",
"data",
",",
"path",
")",
";",
"}",
")",
"}"
]
| Parses a folder of stylesheets containing KSS meta data and creates and saves a fixture.
@param {string} path - build and save a fixture for this path. | [
"Parses",
"a",
"folder",
"of",
"stylesheets",
"containing",
"KSS",
"meta",
"data",
"and",
"creates",
"and",
"saves",
"a",
"fixture",
"."
]
| 2cd69772c7888f2c787641e2ef65d54cb1af839f | https://github.com/plum-css/plum-fixture/blob/2cd69772c7888f2c787641e2ef65d54cb1af839f/lib/generator.js#L84-L90 |
45,593 | plum-css/plum-fixture | lib/generator.js | extractFixturesData | function extractFixturesData( data ) {
return Promise.map( data.section(), function( section ) {
var markup = section.markup();
var ext = path.extname( markup );
var testDir = data.data.files[0].split("/")
.filter(function(dir, i) {
return i <= 2;
})
.concat([path.dirname( markup ), (path.basename( markup, ext ) + ext) ])
.join('/');
return Promise.props({
header : section.header(),
description : section.description(),
markup : fs.readFileAsync( testDir, 'utf8' ).then( mustache.render ),
name : path.basename( section.markup(), path.extname( section.markup() ) )
});
});
} | javascript | function extractFixturesData( data ) {
return Promise.map( data.section(), function( section ) {
var markup = section.markup();
var ext = path.extname( markup );
var testDir = data.data.files[0].split("/")
.filter(function(dir, i) {
return i <= 2;
})
.concat([path.dirname( markup ), (path.basename( markup, ext ) + ext) ])
.join('/');
return Promise.props({
header : section.header(),
description : section.description(),
markup : fs.readFileAsync( testDir, 'utf8' ).then( mustache.render ),
name : path.basename( section.markup(), path.extname( section.markup() ) )
});
});
} | [
"function",
"extractFixturesData",
"(",
"data",
")",
"{",
"return",
"Promise",
".",
"map",
"(",
"data",
".",
"section",
"(",
")",
",",
"function",
"(",
"section",
")",
"{",
"var",
"markup",
"=",
"section",
".",
"markup",
"(",
")",
";",
"var",
"ext",
"=",
"path",
".",
"extname",
"(",
"markup",
")",
";",
"var",
"testDir",
"=",
"data",
".",
"data",
".",
"files",
"[",
"0",
"]",
".",
"split",
"(",
"\"/\"",
")",
".",
"filter",
"(",
"function",
"(",
"dir",
",",
"i",
")",
"{",
"return",
"i",
"<=",
"2",
";",
"}",
")",
".",
"concat",
"(",
"[",
"path",
".",
"dirname",
"(",
"markup",
")",
",",
"(",
"path",
".",
"basename",
"(",
"markup",
",",
"ext",
")",
"+",
"ext",
")",
"]",
")",
".",
"join",
"(",
"'/'",
")",
";",
"return",
"Promise",
".",
"props",
"(",
"{",
"header",
":",
"section",
".",
"header",
"(",
")",
",",
"description",
":",
"section",
".",
"description",
"(",
")",
",",
"markup",
":",
"fs",
".",
"readFileAsync",
"(",
"testDir",
",",
"'utf8'",
")",
".",
"then",
"(",
"mustache",
".",
"render",
")",
",",
"name",
":",
"path",
".",
"basename",
"(",
"section",
".",
"markup",
"(",
")",
",",
"path",
".",
"extname",
"(",
"section",
".",
"markup",
"(",
")",
")",
")",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Builds an object out of KSS meta data that can be used to populate a template.
@param {object} - kss meta data object
@returns {Promise.array} array of fixture data that can be used to populate a template. | [
"Builds",
"an",
"object",
"out",
"of",
"KSS",
"meta",
"data",
"that",
"can",
"be",
"used",
"to",
"populate",
"a",
"template",
"."
]
| 2cd69772c7888f2c787641e2ef65d54cb1af839f | https://github.com/plum-css/plum-fixture/blob/2cd69772c7888f2c787641e2ef65d54cb1af839f/lib/generator.js#L98-L116 |
45,594 | plum-css/plum-fixture | lib/generator.js | saveFixture | function saveFixture( name, data, directory ) {
return fs.readFileAsync( template, 'utf8' )
.then( function renderTemplate( template ) {
return mustache.render( template, { stylesheets: stylesheets, sections: data } );
}).then( function saveTemplate( templateData ) {
return fs.outputFileAsync( destination + '/' + name + '.html', templateData );
});
} | javascript | function saveFixture( name, data, directory ) {
return fs.readFileAsync( template, 'utf8' )
.then( function renderTemplate( template ) {
return mustache.render( template, { stylesheets: stylesheets, sections: data } );
}).then( function saveTemplate( templateData ) {
return fs.outputFileAsync( destination + '/' + name + '.html', templateData );
});
} | [
"function",
"saveFixture",
"(",
"name",
",",
"data",
",",
"directory",
")",
"{",
"return",
"fs",
".",
"readFileAsync",
"(",
"template",
",",
"'utf8'",
")",
".",
"then",
"(",
"function",
"renderTemplate",
"(",
"template",
")",
"{",
"return",
"mustache",
".",
"render",
"(",
"template",
",",
"{",
"stylesheets",
":",
"stylesheets",
",",
"sections",
":",
"data",
"}",
")",
";",
"}",
")",
".",
"then",
"(",
"function",
"saveTemplate",
"(",
"templateData",
")",
"{",
"return",
"fs",
".",
"outputFileAsync",
"(",
"destination",
"+",
"'/'",
"+",
"name",
"+",
"'.html'",
",",
"templateData",
")",
";",
"}",
")",
";",
"}"
]
| Populates a template and saves it as a fixture file.
@param {object} name - the name of the data sections.
@param {array} data - template data array.
@param {string} directory - parent directory to save the fixture to.
@returns {Promise} | [
"Populates",
"a",
"template",
"and",
"saves",
"it",
"as",
"a",
"fixture",
"file",
"."
]
| 2cd69772c7888f2c787641e2ef65d54cb1af839f | https://github.com/plum-css/plum-fixture/blob/2cd69772c7888f2c787641e2ef65d54cb1af839f/lib/generator.js#L126-L133 |
45,595 | syntax-tree/hast-util-to-dom | src/index.js | root | function root(node, options = {}) {
const {
fragment,
namespace: optionsNamespace,
} = options;
const { children = [] } = node;
const { length: childrenLength } = children;
let namespace = optionsNamespace;
let rootIsDocument = childrenLength === 0;
for (let i = 0; i < childrenLength; i += 1) {
const {
tagName,
properties: {
xmlns,
} = {},
} = children[i];
if (tagName === 'html') {
// If we have a root HTML node, we don't need to render as a fragment
rootIsDocument = true;
// Take namespace of first child
if (typeof optionsNamespace === 'undefined') {
if (xmlns) {
namespace = xmlns;
} else if (children[0].tagName === 'html') {
namespace = 'http://www.w3.org/1999/xhtml';
}
}
}
}
// The root node will be a Document, DocumentFragment, or HTMLElement
let el;
if (rootIsDocument) {
el = document.implementation.createDocument(namespace, '', null);
} else if (fragment) {
el = document.createDocumentFragment();
} else {
el = document.createElement('html');
}
// Transform children
const childOptions = Object.assign({ fragment, namespace }, options);
for (let i = 0; i < childrenLength; i += 1) {
const childEl = transform(children[i], childOptions);
if (childEl) {
el.appendChild(childEl);
}
}
return el;
} | javascript | function root(node, options = {}) {
const {
fragment,
namespace: optionsNamespace,
} = options;
const { children = [] } = node;
const { length: childrenLength } = children;
let namespace = optionsNamespace;
let rootIsDocument = childrenLength === 0;
for (let i = 0; i < childrenLength; i += 1) {
const {
tagName,
properties: {
xmlns,
} = {},
} = children[i];
if (tagName === 'html') {
// If we have a root HTML node, we don't need to render as a fragment
rootIsDocument = true;
// Take namespace of first child
if (typeof optionsNamespace === 'undefined') {
if (xmlns) {
namespace = xmlns;
} else if (children[0].tagName === 'html') {
namespace = 'http://www.w3.org/1999/xhtml';
}
}
}
}
// The root node will be a Document, DocumentFragment, or HTMLElement
let el;
if (rootIsDocument) {
el = document.implementation.createDocument(namespace, '', null);
} else if (fragment) {
el = document.createDocumentFragment();
} else {
el = document.createElement('html');
}
// Transform children
const childOptions = Object.assign({ fragment, namespace }, options);
for (let i = 0; i < childrenLength; i += 1) {
const childEl = transform(children[i], childOptions);
if (childEl) {
el.appendChild(childEl);
}
}
return el;
} | [
"function",
"root",
"(",
"node",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"fragment",
",",
"namespace",
":",
"optionsNamespace",
",",
"}",
"=",
"options",
";",
"const",
"{",
"children",
"=",
"[",
"]",
"}",
"=",
"node",
";",
"const",
"{",
"length",
":",
"childrenLength",
"}",
"=",
"children",
";",
"let",
"namespace",
"=",
"optionsNamespace",
";",
"let",
"rootIsDocument",
"=",
"childrenLength",
"===",
"0",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"childrenLength",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"{",
"tagName",
",",
"properties",
":",
"{",
"xmlns",
",",
"}",
"=",
"{",
"}",
",",
"}",
"=",
"children",
"[",
"i",
"]",
";",
"if",
"(",
"tagName",
"===",
"'html'",
")",
"{",
"// If we have a root HTML node, we don't need to render as a fragment",
"rootIsDocument",
"=",
"true",
";",
"// Take namespace of first child",
"if",
"(",
"typeof",
"optionsNamespace",
"===",
"'undefined'",
")",
"{",
"if",
"(",
"xmlns",
")",
"{",
"namespace",
"=",
"xmlns",
";",
"}",
"else",
"if",
"(",
"children",
"[",
"0",
"]",
".",
"tagName",
"===",
"'html'",
")",
"{",
"namespace",
"=",
"'http://www.w3.org/1999/xhtml'",
";",
"}",
"}",
"}",
"}",
"// The root node will be a Document, DocumentFragment, or HTMLElement",
"let",
"el",
";",
"if",
"(",
"rootIsDocument",
")",
"{",
"el",
"=",
"document",
".",
"implementation",
".",
"createDocument",
"(",
"namespace",
",",
"''",
",",
"null",
")",
";",
"}",
"else",
"if",
"(",
"fragment",
")",
"{",
"el",
"=",
"document",
".",
"createDocumentFragment",
"(",
")",
";",
"}",
"else",
"{",
"el",
"=",
"document",
".",
"createElement",
"(",
"'html'",
")",
";",
"}",
"// Transform children",
"const",
"childOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"fragment",
",",
"namespace",
"}",
",",
"options",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"childrenLength",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"childEl",
"=",
"transform",
"(",
"children",
"[",
"i",
"]",
",",
"childOptions",
")",
";",
"if",
"(",
"childEl",
")",
"{",
"el",
".",
"appendChild",
"(",
"childEl",
")",
";",
"}",
"}",
"return",
"el",
";",
"}"
]
| Transform a document | [
"Transform",
"a",
"document"
]
| f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62 | https://github.com/syntax-tree/hast-util-to-dom/blob/f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62/src/index.js#L29-L81 |
45,596 | syntax-tree/hast-util-to-dom | src/index.js | doctype | function doctype(node) {
return document.implementation.createDocumentType(
node.name || 'html',
node.public || '',
node.system || '',
);
} | javascript | function doctype(node) {
return document.implementation.createDocumentType(
node.name || 'html',
node.public || '',
node.system || '',
);
} | [
"function",
"doctype",
"(",
"node",
")",
"{",
"return",
"document",
".",
"implementation",
".",
"createDocumentType",
"(",
"node",
".",
"name",
"||",
"'html'",
",",
"node",
".",
"public",
"||",
"''",
",",
"node",
".",
"system",
"||",
"''",
",",
")",
";",
"}"
]
| Transform a DOCTYPE | [
"Transform",
"a",
"DOCTYPE"
]
| f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62 | https://github.com/syntax-tree/hast-util-to-dom/blob/f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62/src/index.js#L86-L92 |
45,597 | syntax-tree/hast-util-to-dom | src/index.js | element | function element(node, options = {}) {
const { namespace } = options;
const { tagName, properties, children = [] } = node;
const el = typeof namespace !== 'undefined'
? document.createElementNS(namespace, tagName)
: document.createElement(tagName);
// Add HTML attributes
const props = Object.keys(properties);
const { length } = props;
for (let i = 0; i < length; i += 1) {
const key = props[i];
const {
attribute,
property,
mustUseAttribute,
mustUseProperty,
boolean,
booleanish,
overloadedBoolean,
// number,
// defined,
commaSeparated,
spaceSeparated,
// commaOrSpaceSeparated,
} = info.find(info.html, key) || {
attribute: key,
property: key,
};
let value = properties[key];
if (Array.isArray(value)) {
if (commaSeparated) {
value = value.join(', ');
} else if (spaceSeparated) {
value = value.join(' ');
} else {
value = value.join(' ');
}
}
try {
if (mustUseProperty) {
el[property] = value;
}
if (boolean || (overloadedBoolean && typeof value === 'boolean')) {
if (value) {
el.setAttribute(attribute, '');
} else {
el.removeAttribute(attribute);
}
} else if (booleanish) {
el.setAttribute(attribute, value);
} else if (value === true) {
el.setAttribute(attribute, '');
} else if (value || value === 0 || value === '') {
el.setAttribute(attribute, value);
}
} catch (e) {
if (!mustUseAttribute && property) {
el[property] = value;
}
// Otherwise silently ignore
}
}
// Transform children
const { length: childrenLength } = children;
for (let i = 0; i < childrenLength; i += 1) {
const childEl = transform(children[i], options);
if (childEl) {
el.appendChild(childEl);
}
}
return el;
} | javascript | function element(node, options = {}) {
const { namespace } = options;
const { tagName, properties, children = [] } = node;
const el = typeof namespace !== 'undefined'
? document.createElementNS(namespace, tagName)
: document.createElement(tagName);
// Add HTML attributes
const props = Object.keys(properties);
const { length } = props;
for (let i = 0; i < length; i += 1) {
const key = props[i];
const {
attribute,
property,
mustUseAttribute,
mustUseProperty,
boolean,
booleanish,
overloadedBoolean,
// number,
// defined,
commaSeparated,
spaceSeparated,
// commaOrSpaceSeparated,
} = info.find(info.html, key) || {
attribute: key,
property: key,
};
let value = properties[key];
if (Array.isArray(value)) {
if (commaSeparated) {
value = value.join(', ');
} else if (spaceSeparated) {
value = value.join(' ');
} else {
value = value.join(' ');
}
}
try {
if (mustUseProperty) {
el[property] = value;
}
if (boolean || (overloadedBoolean && typeof value === 'boolean')) {
if (value) {
el.setAttribute(attribute, '');
} else {
el.removeAttribute(attribute);
}
} else if (booleanish) {
el.setAttribute(attribute, value);
} else if (value === true) {
el.setAttribute(attribute, '');
} else if (value || value === 0 || value === '') {
el.setAttribute(attribute, value);
}
} catch (e) {
if (!mustUseAttribute && property) {
el[property] = value;
}
// Otherwise silently ignore
}
}
// Transform children
const { length: childrenLength } = children;
for (let i = 0; i < childrenLength; i += 1) {
const childEl = transform(children[i], options);
if (childEl) {
el.appendChild(childEl);
}
}
return el;
} | [
"function",
"element",
"(",
"node",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"{",
"namespace",
"}",
"=",
"options",
";",
"const",
"{",
"tagName",
",",
"properties",
",",
"children",
"=",
"[",
"]",
"}",
"=",
"node",
";",
"const",
"el",
"=",
"typeof",
"namespace",
"!==",
"'undefined'",
"?",
"document",
".",
"createElementNS",
"(",
"namespace",
",",
"tagName",
")",
":",
"document",
".",
"createElement",
"(",
"tagName",
")",
";",
"// Add HTML attributes",
"const",
"props",
"=",
"Object",
".",
"keys",
"(",
"properties",
")",
";",
"const",
"{",
"length",
"}",
"=",
"props",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"key",
"=",
"props",
"[",
"i",
"]",
";",
"const",
"{",
"attribute",
",",
"property",
",",
"mustUseAttribute",
",",
"mustUseProperty",
",",
"boolean",
",",
"booleanish",
",",
"overloadedBoolean",
",",
"// number,",
"// defined,",
"commaSeparated",
",",
"spaceSeparated",
",",
"// commaOrSpaceSeparated,",
"}",
"=",
"info",
".",
"find",
"(",
"info",
".",
"html",
",",
"key",
")",
"||",
"{",
"attribute",
":",
"key",
",",
"property",
":",
"key",
",",
"}",
";",
"let",
"value",
"=",
"properties",
"[",
"key",
"]",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"value",
")",
")",
"{",
"if",
"(",
"commaSeparated",
")",
"{",
"value",
"=",
"value",
".",
"join",
"(",
"', '",
")",
";",
"}",
"else",
"if",
"(",
"spaceSeparated",
")",
"{",
"value",
"=",
"value",
".",
"join",
"(",
"' '",
")",
";",
"}",
"else",
"{",
"value",
"=",
"value",
".",
"join",
"(",
"' '",
")",
";",
"}",
"}",
"try",
"{",
"if",
"(",
"mustUseProperty",
")",
"{",
"el",
"[",
"property",
"]",
"=",
"value",
";",
"}",
"if",
"(",
"boolean",
"||",
"(",
"overloadedBoolean",
"&&",
"typeof",
"value",
"===",
"'boolean'",
")",
")",
"{",
"if",
"(",
"value",
")",
"{",
"el",
".",
"setAttribute",
"(",
"attribute",
",",
"''",
")",
";",
"}",
"else",
"{",
"el",
".",
"removeAttribute",
"(",
"attribute",
")",
";",
"}",
"}",
"else",
"if",
"(",
"booleanish",
")",
"{",
"el",
".",
"setAttribute",
"(",
"attribute",
",",
"value",
")",
";",
"}",
"else",
"if",
"(",
"value",
"===",
"true",
")",
"{",
"el",
".",
"setAttribute",
"(",
"attribute",
",",
"''",
")",
";",
"}",
"else",
"if",
"(",
"value",
"||",
"value",
"===",
"0",
"||",
"value",
"===",
"''",
")",
"{",
"el",
".",
"setAttribute",
"(",
"attribute",
",",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"mustUseAttribute",
"&&",
"property",
")",
"{",
"el",
"[",
"property",
"]",
"=",
"value",
";",
"}",
"// Otherwise silently ignore",
"}",
"}",
"// Transform children",
"const",
"{",
"length",
":",
"childrenLength",
"}",
"=",
"children",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"childrenLength",
";",
"i",
"+=",
"1",
")",
"{",
"const",
"childEl",
"=",
"transform",
"(",
"children",
"[",
"i",
"]",
",",
"options",
")",
";",
"if",
"(",
"childEl",
")",
"{",
"el",
".",
"appendChild",
"(",
"childEl",
")",
";",
"}",
"}",
"return",
"el",
";",
"}"
]
| Transform an element | [
"Transform",
"an",
"element"
]
| f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62 | https://github.com/syntax-tree/hast-util-to-dom/blob/f1f7d324df30c3ff6a2ddcc3cfaf387d87627b62/src/index.js#L111-L187 |
45,598 | CollinEstes/astro-cli | src/processCommands.js | processCommand | function processCommand (cmd, options) {
var module = checkForModule(cmd);
// execute module if exists
if (module) {
return executeModule(module, options);
} else {
processInstallCommands(['install', cmd], options, function (err) {
if (err) {
noModuleFound(cmd);
}
module = checkForModule(cmd);
// execute module if exists now
if (module) {
executeModule(module, options);
}
});
}
} | javascript | function processCommand (cmd, options) {
var module = checkForModule(cmd);
// execute module if exists
if (module) {
return executeModule(module, options);
} else {
processInstallCommands(['install', cmd], options, function (err) {
if (err) {
noModuleFound(cmd);
}
module = checkForModule(cmd);
// execute module if exists now
if (module) {
executeModule(module, options);
}
});
}
} | [
"function",
"processCommand",
"(",
"cmd",
",",
"options",
")",
"{",
"var",
"module",
"=",
"checkForModule",
"(",
"cmd",
")",
";",
"// execute module if exists",
"if",
"(",
"module",
")",
"{",
"return",
"executeModule",
"(",
"module",
",",
"options",
")",
";",
"}",
"else",
"{",
"processInstallCommands",
"(",
"[",
"'install'",
",",
"cmd",
"]",
",",
"options",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"noModuleFound",
"(",
"cmd",
")",
";",
"}",
"module",
"=",
"checkForModule",
"(",
"cmd",
")",
";",
"// execute module if exists now",
"if",
"(",
"module",
")",
"{",
"executeModule",
"(",
"module",
",",
"options",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
]
| process the command | [
"process",
"the",
"command"
]
| 261cdecade954f9b4277ccf968b577513edda587 | https://github.com/CollinEstes/astro-cli/blob/261cdecade954f9b4277ccf968b577513edda587/src/processCommands.js#L38-L57 |
45,599 | mchalapuk/hyper-text-slider | lib/core/phaser.js | Phaser | function Phaser(element) {
check(element, 'element').is.anInstanceOf(Element)();
var priv = {};
priv.elem = element;
priv.phase = null;
priv.listeners = [];
priv.phaseTriggers = new MultiMap();
priv.started = false;
var pub = {};
var methods = [
getPhase,
nextPhase,
addPhaseListener,
removePhaseListener,
addPhaseTrigger,
removePhaseTrigger,
startTransition,
];
// This trick binds all methods to the public object
// passing `priv` as the first argument to each call.
methods.forEach(function(method) {
pub[method.name] = method.bind(pub, priv);
});
return pub;
} | javascript | function Phaser(element) {
check(element, 'element').is.anInstanceOf(Element)();
var priv = {};
priv.elem = element;
priv.phase = null;
priv.listeners = [];
priv.phaseTriggers = new MultiMap();
priv.started = false;
var pub = {};
var methods = [
getPhase,
nextPhase,
addPhaseListener,
removePhaseListener,
addPhaseTrigger,
removePhaseTrigger,
startTransition,
];
// This trick binds all methods to the public object
// passing `priv` as the first argument to each call.
methods.forEach(function(method) {
pub[method.name] = method.bind(pub, priv);
});
return pub;
} | [
"function",
"Phaser",
"(",
"element",
")",
"{",
"check",
"(",
"element",
",",
"'element'",
")",
".",
"is",
".",
"anInstanceOf",
"(",
"Element",
")",
"(",
")",
";",
"var",
"priv",
"=",
"{",
"}",
";",
"priv",
".",
"elem",
"=",
"element",
";",
"priv",
".",
"phase",
"=",
"null",
";",
"priv",
".",
"listeners",
"=",
"[",
"]",
";",
"priv",
".",
"phaseTriggers",
"=",
"new",
"MultiMap",
"(",
")",
";",
"priv",
".",
"started",
"=",
"false",
";",
"var",
"pub",
"=",
"{",
"}",
";",
"var",
"methods",
"=",
"[",
"getPhase",
",",
"nextPhase",
",",
"addPhaseListener",
",",
"removePhaseListener",
",",
"addPhaseTrigger",
",",
"removePhaseTrigger",
",",
"startTransition",
",",
"]",
";",
"// This trick binds all methods to the public object",
"// passing `priv` as the first argument to each call.",
"methods",
".",
"forEach",
"(",
"function",
"(",
"method",
")",
"{",
"pub",
"[",
"method",
".",
"name",
"]",
"=",
"method",
".",
"bind",
"(",
"pub",
",",
"priv",
")",
";",
"}",
")",
";",
"return",
"pub",
";",
"}"
]
| Creates Phaser.
This constructor has no side-effects. This means that no ${link Phase phase class name}
is set on given **element** and no eventlistener is set after calling it. For phaser to start
doing some work, ${link Phaser.prototype.setPhase}, ${link Phaser.prototype.startTransition}
or ${link Phaser.prototype.addPhaseTrigger} must be invoked.
@param {Element} element container DOM element that will receive proper phase class names
@fqn Phaser.prototype.constructor | [
"Creates",
"Phaser",
"."
]
| 2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4 | https://github.com/mchalapuk/hyper-text-slider/blob/2711b41b9bbf1d528e4a0bd31b2efdf91dce55b4/lib/core/phaser.js#L81-L109 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.