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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34,300 | alltherooms/cached-request | lib/cached-request.js | makeRequest | function makeRequest () {
request = self.request.apply(null, args);
requestMiddleware.use(request);
request.on("response", function (response) {
var contentEncoding, gzipper;
//Only cache successful responses
if (response.statusCode >= 200 && response.statusCode < 300) {
response.on('error', function (error) {
self.handleError(error);
});
fs.writeFile(self.cacheDirectory + key + ".json", JSON.stringify(response.headers), function (error) {
if (error) self.handleError(error);
});
responseWriter = fs.createWriteStream(self.cacheDirectory + key);
responseWriter.on('error', function (error) {
self.handleError(error);
});
contentEncoding = response.headers['content-encoding'] || '';
contentEncoding = contentEncoding.trim().toLowerCase();
if (contentEncoding === 'gzip') {
response.on('error', function (error) {
responseWriter.end();
});
response.pipe(responseWriter);
} else {
gzipper = zlib.createGzip();
response.on('error', function (error) {
gzipper.end();
});
gzipper.on('error', function (error) {
self.handleError(error);
responseWriter.end();
});
responseWriter.on('error', function (error) {
response.unpipe(gzipper);
gzipper.end();
});
response.pipe(gzipper).pipe(responseWriter);
}
}
});
self.emit("request", args[0]);
} | javascript | function makeRequest () {
request = self.request.apply(null, args);
requestMiddleware.use(request);
request.on("response", function (response) {
var contentEncoding, gzipper;
//Only cache successful responses
if (response.statusCode >= 200 && response.statusCode < 300) {
response.on('error', function (error) {
self.handleError(error);
});
fs.writeFile(self.cacheDirectory + key + ".json", JSON.stringify(response.headers), function (error) {
if (error) self.handleError(error);
});
responseWriter = fs.createWriteStream(self.cacheDirectory + key);
responseWriter.on('error', function (error) {
self.handleError(error);
});
contentEncoding = response.headers['content-encoding'] || '';
contentEncoding = contentEncoding.trim().toLowerCase();
if (contentEncoding === 'gzip') {
response.on('error', function (error) {
responseWriter.end();
});
response.pipe(responseWriter);
} else {
gzipper = zlib.createGzip();
response.on('error', function (error) {
gzipper.end();
});
gzipper.on('error', function (error) {
self.handleError(error);
responseWriter.end();
});
responseWriter.on('error', function (error) {
response.unpipe(gzipper);
gzipper.end();
});
response.pipe(gzipper).pipe(responseWriter);
}
}
});
self.emit("request", args[0]);
} | [
"function",
"makeRequest",
"(",
")",
"{",
"request",
"=",
"self",
".",
"request",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"requestMiddleware",
".",
"use",
"(",
"request",
")",
";",
"request",
".",
"on",
"(",
"\"response\"",
",",
"function",
"... | Makes the actual request and caches the response | [
"Makes",
"the",
"actual",
"request",
"and",
"caches",
"the",
"response"
] | 41a841cb05e338dda40a055c682a9ee493757023 | https://github.com/alltherooms/cached-request/blob/41a841cb05e338dda40a055c682a9ee493757023/lib/cached-request.js#L259-L306 |
34,301 | echo008/xmi | packages/xmi-router/src/dynamic.js | dynamicLoad | function dynamicLoad(dynamicOptions, options, defaultOptions) {
let loadableFn = Loadable
let loadableOptions = defaultOptions
if (typeof dynamicOptions.then === 'function') {
// Support for direct import(),
// eg: dynamic(import('../hello-world'))
loadableOptions.loader = () => dynamicOptions
} else if (typeof dynamicOptions === 'object') {
// Support for having first argument being options,
// eg: dynamic({loader: import('../hello-world')})
loadableOptions = { ...loadableOptions, ...dynamicOptions }
}
// Support for passing options,
// eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
loadableOptions = { ...loadableOptions, ...options }
// Support for `render` when using a mapping,
// eg: `dynamic({ modules: () => {return {HelloWorld: import('../hello-world')}, render(props, loaded) {} } })
if (dynamicOptions.render) {
loadableOptions.render = (loaded, props) =>
dynamicOptions.render(props, loaded)
}
// Support for `modules` when using a mapping,
// eg: `dynamic({ modules: () => {return {HelloWorld: import('../hello-world')}, render(props, loaded) {} } })
if (dynamicOptions.modules) {
loadableFn = Loadable.Map
const loadModules = {}
const modules = dynamicOptions.modules()
Object.keys(modules).forEach(key => {
const value = modules[key]
if (typeof value.then === 'function') {
loadModules[key] = () => value.then(mod => mod.default || mod)
return
}
loadModules[key] = value
})
loadableOptions.loader = loadModules
}
return loadableFn(loadableOptions)
} | javascript | function dynamicLoad(dynamicOptions, options, defaultOptions) {
let loadableFn = Loadable
let loadableOptions = defaultOptions
if (typeof dynamicOptions.then === 'function') {
// Support for direct import(),
// eg: dynamic(import('../hello-world'))
loadableOptions.loader = () => dynamicOptions
} else if (typeof dynamicOptions === 'object') {
// Support for having first argument being options,
// eg: dynamic({loader: import('../hello-world')})
loadableOptions = { ...loadableOptions, ...dynamicOptions }
}
// Support for passing options,
// eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
loadableOptions = { ...loadableOptions, ...options }
// Support for `render` when using a mapping,
// eg: `dynamic({ modules: () => {return {HelloWorld: import('../hello-world')}, render(props, loaded) {} } })
if (dynamicOptions.render) {
loadableOptions.render = (loaded, props) =>
dynamicOptions.render(props, loaded)
}
// Support for `modules` when using a mapping,
// eg: `dynamic({ modules: () => {return {HelloWorld: import('../hello-world')}, render(props, loaded) {} } })
if (dynamicOptions.modules) {
loadableFn = Loadable.Map
const loadModules = {}
const modules = dynamicOptions.modules()
Object.keys(modules).forEach(key => {
const value = modules[key]
if (typeof value.then === 'function') {
loadModules[key] = () => value.then(mod => mod.default || mod)
return
}
loadModules[key] = value
})
loadableOptions.loader = loadModules
}
return loadableFn(loadableOptions)
} | [
"function",
"dynamicLoad",
"(",
"dynamicOptions",
",",
"options",
",",
"defaultOptions",
")",
"{",
"let",
"loadableFn",
"=",
"Loadable",
"let",
"loadableOptions",
"=",
"defaultOptions",
"if",
"(",
"typeof",
"dynamicOptions",
".",
"then",
"===",
"'function'",
")",
... | Thanks to umi | [
"Thanks",
"to",
"umi"
] | c751515b537fa713a6df45b30d0767bbb1e8c66c | https://github.com/echo008/xmi/blob/c751515b537fa713a6df45b30d0767bbb1e8c66c/packages/xmi-router/src/dynamic.js#L19-L62 |
34,302 | sebarmeli/bamboo-api | lib/bamboo.js | function(host, username, password) {
var defaultUrl = "http://localhost:8085";
host = host || defaultUrl;
if (username && password) {
var protocol = host.match(/(^|\s)(https?:\/\/)/i);
if (_.isArray(protocol)) {
protocol = _.first(protocol);
var url = host.substr(protocol.length);
host = protocol + username + ":" + password + "@" + url;
}
}
this.host = host || defaultUrl;
} | javascript | function(host, username, password) {
var defaultUrl = "http://localhost:8085";
host = host || defaultUrl;
if (username && password) {
var protocol = host.match(/(^|\s)(https?:\/\/)/i);
if (_.isArray(protocol)) {
protocol = _.first(protocol);
var url = host.substr(protocol.length);
host = protocol + username + ":" + password + "@" + url;
}
}
this.host = host || defaultUrl;
} | [
"function",
"(",
"host",
",",
"username",
",",
"password",
")",
"{",
"var",
"defaultUrl",
"=",
"\"http://localhost:8085\"",
";",
"host",
"=",
"host",
"||",
"defaultUrl",
";",
"if",
"(",
"username",
"&&",
"password",
")",
"{",
"var",
"protocol",
"=",
"host"... | Function defining a Bamboo instance
@param {String} host - hostname. By default "http://localhost:8085"
@param {String=} username - optional param for base HTTP authentication. Username
@param {String=} password - optional param for base HTTP authentication. Password
@constructor | [
"Function",
"defining",
"a",
"Bamboo",
"instance"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L25-L43 | |
34,303 | sebarmeli/bamboo-api | lib/bamboo.js | checkErrorsWithResult | function checkErrorsWithResult(error, response) {
var errors = checkErrors(error, response);
if (errors !== false) {
return errors;
}
try {
var body = JSON.parse(response.body);
} catch (parseError) {
return parseError;
}
var results = body.results;
if (typeof results === "undefined" || results.result.length === 0) {
return new Error("The plan doesn't contain any result");
}
return false;
} | javascript | function checkErrorsWithResult(error, response) {
var errors = checkErrors(error, response);
if (errors !== false) {
return errors;
}
try {
var body = JSON.parse(response.body);
} catch (parseError) {
return parseError;
}
var results = body.results;
if (typeof results === "undefined" || results.result.length === 0) {
return new Error("The plan doesn't contain any result");
}
return false;
} | [
"function",
"checkErrorsWithResult",
"(",
"error",
",",
"response",
")",
"{",
"var",
"errors",
"=",
"checkErrors",
"(",
"error",
",",
"response",
")",
";",
"if",
"(",
"errors",
"!==",
"false",
")",
"{",
"return",
"errors",
";",
"}",
"try",
"{",
"var",
... | Method checks for errors in error and server response
Additionally parsing response body and checking if it contain any results
@param {Error|null} error
@param {Object} response
@returns {Error|Boolean} if error, will return Error otherwise false
@protected | [
"Method",
"checks",
"for",
"errors",
"in",
"error",
"and",
"server",
"response",
"Additionally",
"parsing",
"response",
"body",
"and",
"checking",
"if",
"it",
"contain",
"any",
"results"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L711-L731 |
34,304 | sebarmeli/bamboo-api | lib/bamboo.js | checkErrors | function checkErrors(error, response) {
if (error) {
return error instanceof Error ? error : new Error(error);
}
// Bamboo API enable plan returns 204 with empty response in case of success
if ((response.statusCode !== 200) && (response.statusCode !== 204)) {
return new Error("Unreachable endpoint! Response status code: " + response.statusCode);
}
return false;
} | javascript | function checkErrors(error, response) {
if (error) {
return error instanceof Error ? error : new Error(error);
}
// Bamboo API enable plan returns 204 with empty response in case of success
if ((response.statusCode !== 200) && (response.statusCode !== 204)) {
return new Error("Unreachable endpoint! Response status code: " + response.statusCode);
}
return false;
} | [
"function",
"checkErrors",
"(",
"error",
",",
"response",
")",
"{",
"if",
"(",
"error",
")",
"{",
"return",
"error",
"instanceof",
"Error",
"?",
"error",
":",
"new",
"Error",
"(",
"error",
")",
";",
"}",
"// Bamboo API enable plan returns 204 with empty response... | Method checks for errors in error and server response
@param {Error|null} error
@param {Object} response
@returns {Error|Boolean} if error, will return Error otherwise false
@protected | [
"Method",
"checks",
"for",
"errors",
"in",
"error",
"and",
"server",
"response"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L741-L752 |
34,305 | sebarmeli/bamboo-api | lib/bamboo.js | mergeUrlWithParams | function mergeUrlWithParams(url, params) {
params = params || {};
return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
} | javascript | function mergeUrlWithParams(url, params) {
params = params || {};
return _.isEmpty(params) ? url : url + "?" + qs.stringify(params);
} | [
"function",
"mergeUrlWithParams",
"(",
"url",
",",
"params",
")",
"{",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"return",
"_",
".",
"isEmpty",
"(",
"params",
")",
"?",
"url",
":",
"url",
"+",
"\"?\"",
"+",
"qs",
".",
"stringify",
"(",
"params",
... | Method will add params to the specified url
@param {String} url
@param {Object=} params - optional, object with parameters that should be merged with specified url
@returns {String}
@protected | [
"Method",
"will",
"add",
"params",
"to",
"the",
"specified",
"url"
] | 2ef5a9040dfb1c05dc55d14629db3f544a446f4d | https://github.com/sebarmeli/bamboo-api/blob/2ef5a9040dfb1c05dc55d14629db3f544a446f4d/lib/bamboo.js#L762-L765 |
34,306 | pa11y/pa11y-webservice-client-node | lib/client.js | client | function client (root) {
return {
tasks: {
// Create a new task
create: function (task, done) {
post(root + 'tasks', task, done);
},
// Get all tasks
get: function (query, done) {
get(root + 'tasks', query, done);
},
// Get results for all tasks
results: function (query, done) {
get(root + 'tasks/results', query, done);
}
},
task: function (id) {
return {
// Get a task
get: function (query, done) {
get(root + 'tasks/' + id, query, done);
},
// Edit a task
edit: function (edits, done) {
patch(root + 'tasks/' + id, edits, done);
},
// Remove a task
remove: function (done) {
del(root + 'tasks/' + id, null, done);
},
// Run a task
run: function (done) {
post(root + 'tasks/' + id + '/run', null, done);
},
// Get results for a task
results: function (query, done) {
get(root + 'tasks/' + id + '/results', query, done);
},
result: function (rid) {
return {
// Get a result
get: function (query, done) {
get(root + 'tasks/' + id + '/results/' + rid, query, done);
}
};
}
};
}
};
} | javascript | function client (root) {
return {
tasks: {
// Create a new task
create: function (task, done) {
post(root + 'tasks', task, done);
},
// Get all tasks
get: function (query, done) {
get(root + 'tasks', query, done);
},
// Get results for all tasks
results: function (query, done) {
get(root + 'tasks/results', query, done);
}
},
task: function (id) {
return {
// Get a task
get: function (query, done) {
get(root + 'tasks/' + id, query, done);
},
// Edit a task
edit: function (edits, done) {
patch(root + 'tasks/' + id, edits, done);
},
// Remove a task
remove: function (done) {
del(root + 'tasks/' + id, null, done);
},
// Run a task
run: function (done) {
post(root + 'tasks/' + id + '/run', null, done);
},
// Get results for a task
results: function (query, done) {
get(root + 'tasks/' + id + '/results', query, done);
},
result: function (rid) {
return {
// Get a result
get: function (query, done) {
get(root + 'tasks/' + id + '/results/' + rid, query, done);
}
};
}
};
}
};
} | [
"function",
"client",
"(",
"root",
")",
"{",
"return",
"{",
"tasks",
":",
"{",
"// Create a new task",
"create",
":",
"function",
"(",
"task",
",",
"done",
")",
"{",
"post",
"(",
"root",
"+",
"'tasks'",
",",
"task",
",",
"done",
")",
";",
"}",
",",
... | Create a web-service client | [
"Create",
"a",
"web",
"-",
"service",
"client"
] | 841f1bf26dce4de578add0761fa88e00c7a2d3bf | https://github.com/pa11y/pa11y-webservice-client-node/blob/841f1bf26dce4de578add0761fa88e00c7a2d3bf/lib/client.js#L23-L88 |
34,307 | matrix-org/matrix-react-skin | src/app/index.js | routeUrl | function routeUrl(location) {
if (location.hash.indexOf('#/register') == 0) {
var hashparts = location.hash.split('?');
var params = {};
if (hashparts.length == 2) {
var pairs = hashparts[1].split('&');
for (var i = 0; i < pairs.length; ++i) {
var parts = pairs[i].split('=');
if (parts.length != 2) continue;
params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
}
}
window.matrixChat.showScreen('register', params);
}
} | javascript | function routeUrl(location) {
if (location.hash.indexOf('#/register') == 0) {
var hashparts = location.hash.split('?');
var params = {};
if (hashparts.length == 2) {
var pairs = hashparts[1].split('&');
for (var i = 0; i < pairs.length; ++i) {
var parts = pairs[i].split('=');
if (parts.length != 2) continue;
params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
}
}
window.matrixChat.showScreen('register', params);
}
} | [
"function",
"routeUrl",
"(",
"location",
")",
"{",
"if",
"(",
"location",
".",
"hash",
".",
"indexOf",
"(",
"'#/register'",
")",
"==",
"0",
")",
"{",
"var",
"hashparts",
"=",
"location",
".",
"hash",
".",
"split",
"(",
"'?'",
")",
";",
"var",
"params... | Here, we do some crude URL analysis to allow deep-linking. We only support registration deep-links in this example. | [
"Here",
"we",
"do",
"some",
"crude",
"URL",
"analysis",
"to",
"allow",
"deep",
"-",
"linking",
".",
"We",
"only",
"support",
"registration",
"deep",
"-",
"links",
"in",
"this",
"example",
"."
] | a5b7a790f332d74d74f52b2cbaa1fd68559aae4d | https://github.com/matrix-org/matrix-react-skin/blob/a5b7a790f332d74d74f52b2cbaa1fd68559aae4d/src/app/index.js#L27-L41 |
34,308 | GrosSacASac/DOM99 | documentation/presentation/reveal.js-2.6.2/plugin/markdown/markdown.js | processSlides | function processSlides() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
for( var i = 0, len = sections.length; i < len; i++ ) {
section = sections[i];
if( section.getAttribute( 'data-markdown' ).length ) {
var xhr = new XMLHttpRequest(),
url = section.getAttribute( 'data-markdown' );
datacharset = section.getAttribute( 'data-charset' );
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
if( datacharset != null && datacharset != '' ) {
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
}
xhr.onreadystatechange = function() {
if( xhr.readyState === 4 ) {
if ( xhr.status >= 200 && xhr.status < 300 ) {
section.outerHTML = slidify( xhr.responseText, {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section )
});
}
else {
section.outerHTML = '<section data-state="alert">' +
'ERROR: The attempt to fetch ' + url + ' failed with HTTP status ' + xhr.status + '.' +
'Check your browser\'s JavaScript console for more details.' +
'<p>Remember that you need to serve the presentation HTML from a HTTP server.</p>' +
'</section>';
}
}
};
xhr.open( 'GET', url, false );
try {
xhr.send();
}
catch ( e ) {
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
}
}
else if( section.getAttribute( 'data-separator' ) || section.getAttribute( 'data-vertical' ) || section.getAttribute( 'data-notes' ) ) {
section.outerHTML = slidify( getMarkdownFromSlide( section ), {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section )
});
}
else {
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
}
}
} | javascript | function processSlides() {
var sections = document.querySelectorAll( '[data-markdown]'),
section;
for( var i = 0, len = sections.length; i < len; i++ ) {
section = sections[i];
if( section.getAttribute( 'data-markdown' ).length ) {
var xhr = new XMLHttpRequest(),
url = section.getAttribute( 'data-markdown' );
datacharset = section.getAttribute( 'data-charset' );
// see https://developer.mozilla.org/en-US/docs/Web/API/element.getAttribute#Notes
if( datacharset != null && datacharset != '' ) {
xhr.overrideMimeType( 'text/html; charset=' + datacharset );
}
xhr.onreadystatechange = function() {
if( xhr.readyState === 4 ) {
if ( xhr.status >= 200 && xhr.status < 300 ) {
section.outerHTML = slidify( xhr.responseText, {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section )
});
}
else {
section.outerHTML = '<section data-state="alert">' +
'ERROR: The attempt to fetch ' + url + ' failed with HTTP status ' + xhr.status + '.' +
'Check your browser\'s JavaScript console for more details.' +
'<p>Remember that you need to serve the presentation HTML from a HTTP server.</p>' +
'</section>';
}
}
};
xhr.open( 'GET', url, false );
try {
xhr.send();
}
catch ( e ) {
alert( 'Failed to get the Markdown file ' + url + '. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. ' + e );
}
}
else if( section.getAttribute( 'data-separator' ) || section.getAttribute( 'data-vertical' ) || section.getAttribute( 'data-notes' ) ) {
section.outerHTML = slidify( getMarkdownFromSlide( section ), {
separator: section.getAttribute( 'data-separator' ),
verticalSeparator: section.getAttribute( 'data-vertical' ),
notesSeparator: section.getAttribute( 'data-notes' ),
attributes: getForwardedAttributes( section )
});
}
else {
section.innerHTML = createMarkdownSlide( getMarkdownFromSlide( section ) );
}
}
} | [
"function",
"processSlides",
"(",
")",
"{",
"var",
"sections",
"=",
"document",
".",
"querySelectorAll",
"(",
"'[data-markdown]'",
")",
",",
"section",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"sections",
".",
"length",
";",
"i",
"<",
"l... | Parses any current data-markdown slides, splits
multi-slide markdown into separate sections and
handles loading of external markdown. | [
"Parses",
"any",
"current",
"data",
"-",
"markdown",
"slides",
"splits",
"multi",
"-",
"slide",
"markdown",
"into",
"separate",
"sections",
"and",
"handles",
"loading",
"of",
"external",
"markdown",
"."
] | 0563cb3d4865d968e829d39c68dc62af3fc95cc8 | https://github.com/GrosSacASac/DOM99/blob/0563cb3d4865d968e829d39c68dc62af3fc95cc8/documentation/presentation/reveal.js-2.6.2/plugin/markdown/markdown.js#L199-L269 |
34,309 | rlmv/gitbook-plugin-anchors | index.js | insertAnchors | function insertAnchors(content) {
var $ = cheerio.load(content);
$(':header').each(function(i, elem) {
var header = $(elem);
var id = header.attr("id");
if (!id) {
id = slug(header.text());
header.attr("id", id);
}
header.prepend('<a name="' + id + '" class="plugin-anchor" '
+ 'href="#' + id + '">'
+ '<i class="fa fa-link" aria-hidden="true"></i>'
+ '</a>');
});
return $.html();
} | javascript | function insertAnchors(content) {
var $ = cheerio.load(content);
$(':header').each(function(i, elem) {
var header = $(elem);
var id = header.attr("id");
if (!id) {
id = slug(header.text());
header.attr("id", id);
}
header.prepend('<a name="' + id + '" class="plugin-anchor" '
+ 'href="#' + id + '">'
+ '<i class="fa fa-link" aria-hidden="true"></i>'
+ '</a>');
});
return $.html();
} | [
"function",
"insertAnchors",
"(",
"content",
")",
"{",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"content",
")",
";",
"$",
"(",
"':header'",
")",
".",
"each",
"(",
"function",
"(",
"i",
",",
"elem",
")",
"{",
"var",
"header",
"=",
"$",
"(",
"... | insert anchor link into section | [
"insert",
"anchor",
"link",
"into",
"section"
] | ba139e94705b71d7c752015e6e7407aaaf07528f | https://github.com/rlmv/gitbook-plugin-anchors/blob/ba139e94705b71d7c752015e6e7407aaaf07528f/index.js#L5-L20 |
34,310 | lil5/simple-cryptor-pouch | src/index.js | simplecryptor | function simplecryptor (password, options = {}) {
const db = this
// set default ignore
options.ignore = ['_id', '_rev', '_deleted'].concat(options.ignore)
const simpleCryptoJS = new SimpleCryptoJS(password)
// https://github.com/pouchdb-community/transform-pouch#example-encryption
db.transform({
incoming: function (doc) {
return cryptor(simpleCryptoJS, doc, options.ignore, true)
},
outgoing: function (doc) {
return cryptor(simpleCryptoJS, doc, options.ignore, false)
},
})
} | javascript | function simplecryptor (password, options = {}) {
const db = this
// set default ignore
options.ignore = ['_id', '_rev', '_deleted'].concat(options.ignore)
const simpleCryptoJS = new SimpleCryptoJS(password)
// https://github.com/pouchdb-community/transform-pouch#example-encryption
db.transform({
incoming: function (doc) {
return cryptor(simpleCryptoJS, doc, options.ignore, true)
},
outgoing: function (doc) {
return cryptor(simpleCryptoJS, doc, options.ignore, false)
},
})
} | [
"function",
"simplecryptor",
"(",
"password",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"db",
"=",
"this",
"// set default ignore",
"options",
".",
"ignore",
"=",
"[",
"'_id'",
",",
"'_rev'",
",",
"'_deleted'",
"]",
".",
"concat",
"(",
"options",
... | pouch function to encrypt and decrypt
@param {string} password
@param {Object} [options={}]
@return {Object | Promise} | [
"pouch",
"function",
"to",
"encrypt",
"and",
"decrypt"
] | 15179a510cc707c3402472716ef029d3255b12ee | https://github.com/lil5/simple-cryptor-pouch/blob/15179a510cc707c3402472716ef029d3255b12ee/src/index.js#L12-L29 |
34,311 | nickyout/fast-stable-stringify | cli/files-to-comparison-results.js | mergeToMap | function mergeToMap(arrFileObj) {
return arrFileObj.reduce(function(result, fileObj) {
var name;
var libData;
for (name in fileObj) {
libData = fileObj[name];
obj.setObject(result, [libData.suite, libData.browser, libData.name], libData);
}
return result;
}, {});
} | javascript | function mergeToMap(arrFileObj) {
return arrFileObj.reduce(function(result, fileObj) {
var name;
var libData;
for (name in fileObj) {
libData = fileObj[name];
obj.setObject(result, [libData.suite, libData.browser, libData.name], libData);
}
return result;
}, {});
} | [
"function",
"mergeToMap",
"(",
"arrFileObj",
")",
"{",
"return",
"arrFileObj",
".",
"reduce",
"(",
"function",
"(",
"result",
",",
"fileObj",
")",
"{",
"var",
"name",
";",
"var",
"libData",
";",
"for",
"(",
"name",
"in",
"fileObj",
")",
"{",
"libData",
... | Converts the file contents generated by BenchmarkStatsProcessor to a DataSetComparisonResult array.
@param {Array} arrFileObj
@returns {Object} | [
"Converts",
"the",
"file",
"contents",
"generated",
"by",
"BenchmarkStatsProcessor",
"to",
"a",
"DataSetComparisonResult",
"array",
"."
] | 53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c | https://github.com/nickyout/fast-stable-stringify/blob/53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c/cli/files-to-comparison-results.js#L9-L19 |
34,312 | svagi/redux-routines | lib/index.js | createActionType | function createActionType(prefix, stage, separator) {
if (typeof prefix !== 'string' || typeof stage !== 'string') {
throw new Error('Invalid routine prefix or stage. It should be string.');
}
return '' + prefix + separator + stage;
} | javascript | function createActionType(prefix, stage, separator) {
if (typeof prefix !== 'string' || typeof stage !== 'string') {
throw new Error('Invalid routine prefix or stage. It should be string.');
}
return '' + prefix + separator + stage;
} | [
"function",
"createActionType",
"(",
"prefix",
",",
"stage",
",",
"separator",
")",
"{",
"if",
"(",
"typeof",
"prefix",
"!==",
"'string'",
"||",
"typeof",
"stage",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Invalid routine prefix or stage. It s... | Routine action type factory | [
"Routine",
"action",
"type",
"factory"
] | d9585eab26c15c032a5ca9a759eea35782cc3436 | https://github.com/svagi/redux-routines/blob/d9585eab26c15c032a5ca9a759eea35782cc3436/lib/index.js#L21-L26 |
34,313 | nickyout/fast-stable-stringify | cli/format-table.js | toFixedWidth | function toFixedWidth(value, maxChars) {
var result = value.toFixed(2).substr(0, maxChars);
if (result[result.length - 1] == '.') {
result = result.substr(0, result.length - 2) + ' ';
}
return result;
} | javascript | function toFixedWidth(value, maxChars) {
var result = value.toFixed(2).substr(0, maxChars);
if (result[result.length - 1] == '.') {
result = result.substr(0, result.length - 2) + ' ';
}
return result;
} | [
"function",
"toFixedWidth",
"(",
"value",
",",
"maxChars",
")",
"{",
"var",
"result",
"=",
"value",
".",
"toFixed",
"(",
"2",
")",
".",
"substr",
"(",
"0",
",",
"maxChars",
")",
";",
"if",
"(",
"result",
"[",
"result",
".",
"length",
"-",
"1",
"]",... | Crude, but should be enough internally | [
"Crude",
"but",
"should",
"be",
"enough",
"internally"
] | 53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c | https://github.com/nickyout/fast-stable-stringify/blob/53460c31e7b4b0cccb7c7ddacc89bf42ccd5eb0c/cli/format-table.js#L4-L10 |
34,314 | JamesMGreene/qunit-assert-html | src/qunit-assert-html.js | _getPushContext | function _getPushContext(context) {
var pushContext;
if (context && typeof context.push === "function") {
// `context` is an `Assert` context
pushContext = context;
}
else if (context && context.assert && typeof context.assert.push === "function") {
// `context` is a `Test` context
pushContext = context.assert;
}
else if (
QUnit && QUnit.config && QUnit.config.current && QUnit.config.current.assert &&
typeof QUnit.config.current.assert.push === "function"
) {
// `context` is an unknown context but we can find the `Assert` context via QUnit
pushContext = QUnit.config.current.assert;
}
else if (QUnit && typeof QUnit.push === "function") {
pushContext = QUnit.push;
}
else {
throw new Error("Could not find the QUnit `Assert` context to push results");
}
return pushContext;
} | javascript | function _getPushContext(context) {
var pushContext;
if (context && typeof context.push === "function") {
// `context` is an `Assert` context
pushContext = context;
}
else if (context && context.assert && typeof context.assert.push === "function") {
// `context` is a `Test` context
pushContext = context.assert;
}
else if (
QUnit && QUnit.config && QUnit.config.current && QUnit.config.current.assert &&
typeof QUnit.config.current.assert.push === "function"
) {
// `context` is an unknown context but we can find the `Assert` context via QUnit
pushContext = QUnit.config.current.assert;
}
else if (QUnit && typeof QUnit.push === "function") {
pushContext = QUnit.push;
}
else {
throw new Error("Could not find the QUnit `Assert` context to push results");
}
return pushContext;
} | [
"function",
"_getPushContext",
"(",
"context",
")",
"{",
"var",
"pushContext",
";",
"if",
"(",
"context",
"&&",
"typeof",
"context",
".",
"push",
"===",
"\"function\"",
")",
"{",
"// `context` is an `Assert` context",
"pushContext",
"=",
"context",
";",
"}",
"el... | Find an appropriate `Assert` context to `push` results to.
@param * context - An unknown context, possibly `Assert`, `Test`, or neither
@private | [
"Find",
"an",
"appropriate",
"Assert",
"context",
"to",
"push",
"results",
"to",
"."
] | 670b20e64b68465934d0bfedf5fbf952b45c3b5e | https://github.com/JamesMGreene/qunit-assert-html/blob/670b20e64b68465934d0bfedf5fbf952b45c3b5e/src/qunit-assert-html.js#L36-L62 |
34,315 | yvele/poosh | packages/poosh-core/src/pipeline/appendContentBuffer.js | shouldSkip | function shouldSkip(file, rough) {
// Basically, if rough, any small change should still process the content
return rough
? file.cache.status === LocalStatus.Unchanged
: file.content.status === LocalStatus.Unchanged;
} | javascript | function shouldSkip(file, rough) {
// Basically, if rough, any small change should still process the content
return rough
? file.cache.status === LocalStatus.Unchanged
: file.content.status === LocalStatus.Unchanged;
} | [
"function",
"shouldSkip",
"(",
"file",
",",
"rough",
")",
"{",
"// Basically, if rough, any small change should still process the content",
"return",
"rough",
"?",
"file",
".",
"cache",
".",
"status",
"===",
"LocalStatus",
".",
"Unchanged",
":",
"file",
".",
"content"... | When content status is labeled as unchanged, buffer doesn't need to be processed. | [
"When",
"content",
"status",
"is",
"labeled",
"as",
"unchanged",
"buffer",
"doesn",
"t",
"need",
"to",
"be",
"processed",
"."
] | 1b8a84d2bc38d92711405004270c0dcc84e4dbf0 | https://github.com/yvele/poosh/blob/1b8a84d2bc38d92711405004270c0dcc84e4dbf0/packages/poosh-core/src/pipeline/appendContentBuffer.js#L8-L13 |
34,316 | npm/npm-profile | lib/index.js | login | function login (opener, prompter, opts) {
validate('FFO', arguments)
opts = ProfileConfig(opts)
return loginWeb(opener, opts).catch(er => {
if (er instanceof WebLoginNotSupported) {
process.emit('log', 'verbose', 'web login not supported, trying couch')
return prompter(opts.creds)
.then(data => loginCouch(data.username, data.password, opts))
} else {
throw er
}
})
} | javascript | function login (opener, prompter, opts) {
validate('FFO', arguments)
opts = ProfileConfig(opts)
return loginWeb(opener, opts).catch(er => {
if (er instanceof WebLoginNotSupported) {
process.emit('log', 'verbose', 'web login not supported, trying couch')
return prompter(opts.creds)
.then(data => loginCouch(data.username, data.password, opts))
} else {
throw er
}
})
} | [
"function",
"login",
"(",
"opener",
",",
"prompter",
",",
"opts",
")",
"{",
"validate",
"(",
"'FFO'",
",",
"arguments",
")",
"opts",
"=",
"ProfileConfig",
"(",
"opts",
")",
"return",
"loginWeb",
"(",
"opener",
",",
"opts",
")",
".",
"catch",
"(",
"er",... | try loginWeb, catch the "not supported" message and fall back to couch | [
"try",
"loginWeb",
"catch",
"the",
"not",
"supported",
"message",
"and",
"fall",
"back",
"to",
"couch"
] | 0828ce65c7d0634b27e4a766d3bffb7cc87b3569 | https://github.com/npm/npm-profile/blob/0828ce65c7d0634b27e4a766d3bffb7cc87b3569/lib/index.js#L28-L40 |
34,317 | JamesMGreene/qunit-assert-html | dist/qunit-assert-html.js | function( actual, expected, message ) {
message = message || "HTML should not be equal";
this.notDeepEqual( serializeHtml( actual ), serializeHtml( expected ), message );
} | javascript | function( actual, expected, message ) {
message = message || "HTML should not be equal";
this.notDeepEqual( serializeHtml( actual ), serializeHtml( expected ), message );
} | [
"function",
"(",
"actual",
",",
"expected",
",",
"message",
")",
"{",
"message",
"=",
"message",
"||",
"\"HTML should not be equal\"",
";",
"this",
".",
"notDeepEqual",
"(",
"serializeHtml",
"(",
"actual",
")",
",",
"serializeHtml",
"(",
"expected",
")",
",",
... | Compare two snippets of HTML for inequality after normalization.
@example assert.notHtmlEqual("<b>Hello, <i>QUnit!</i></b>", "<b>Hello, QUnit!</b>", "HTML should not be equal");
@param {String} actual The actual HTML before normalization.
@param {String} expected The excepted HTML before normalization.
@param {String} [message] Optional message to display in the results. | [
"Compare",
"two",
"snippets",
"of",
"HTML",
"for",
"inequality",
"after",
"normalization",
"."
] | 670b20e64b68465934d0bfedf5fbf952b45c3b5e | https://github.com/JamesMGreene/qunit-assert-html/blob/670b20e64b68465934d0bfedf5fbf952b45c3b5e/dist/qunit-assert-html.js#L369-L372 | |
34,318 | lil5/simple-cryptor-pouch | src/cryptor.js | isIgnore | function isIgnore (ignore, str) {
let result = false
let i = 0
while (!result && i < ignore.length) {
if (ignore[i] === str) {
result = true
}
i++
}
return result
} | javascript | function isIgnore (ignore, str) {
let result = false
let i = 0
while (!result && i < ignore.length) {
if (ignore[i] === str) {
result = true
}
i++
}
return result
} | [
"function",
"isIgnore",
"(",
"ignore",
",",
"str",
")",
"{",
"let",
"result",
"=",
"false",
"let",
"i",
"=",
"0",
"while",
"(",
"!",
"result",
"&&",
"i",
"<",
"ignore",
".",
"length",
")",
"{",
"if",
"(",
"ignore",
"[",
"i",
"]",
"===",
"str",
... | check if sting is under ignore Array
@param {array} ignore strings to be ignored
@param {string} str string to check
@return {Boolean} is str in ignore array | [
"check",
"if",
"sting",
"is",
"under",
"ignore",
"Array"
] | 15179a510cc707c3402472716ef029d3255b12ee | https://github.com/lil5/simple-cryptor-pouch/blob/15179a510cc707c3402472716ef029d3255b12ee/src/cryptor.js#L7-L18 |
34,319 | lil5/simple-cryptor-pouch | src/cryptor.js | cryptor | function cryptor (simpleCryptoJS, doc, ignore, isIncoming) {
const resultDoc = {}
Object.keys(doc).map(function (objectKey, index) {
if (isIgnore(ignore, objectKey)) {
resultDoc[objectKey] = doc[objectKey]
} else {
const preKeyText = 'encrypted_'
switch (isIncoming) {
case true:
resultDoc[`${preKeyText}${objectKey}`] =
simpleCryptoJS.encrypt(
JSON.stringify(doc[objectKey])
)
break
case false:
resultDoc[`${objectKey.replace(preKeyText, '')}`] =
JSON.parse(
simpleCryptoJS.decrypt(
doc[objectKey]
)
)
break
}
}
})
return resultDoc
} | javascript | function cryptor (simpleCryptoJS, doc, ignore, isIncoming) {
const resultDoc = {}
Object.keys(doc).map(function (objectKey, index) {
if (isIgnore(ignore, objectKey)) {
resultDoc[objectKey] = doc[objectKey]
} else {
const preKeyText = 'encrypted_'
switch (isIncoming) {
case true:
resultDoc[`${preKeyText}${objectKey}`] =
simpleCryptoJS.encrypt(
JSON.stringify(doc[objectKey])
)
break
case false:
resultDoc[`${objectKey.replace(preKeyText, '')}`] =
JSON.parse(
simpleCryptoJS.decrypt(
doc[objectKey]
)
)
break
}
}
})
return resultDoc
} | [
"function",
"cryptor",
"(",
"simpleCryptoJS",
",",
"doc",
",",
"ignore",
",",
"isIncoming",
")",
"{",
"const",
"resultDoc",
"=",
"{",
"}",
"Object",
".",
"keys",
"(",
"doc",
")",
".",
"map",
"(",
"function",
"(",
"objectKey",
",",
"index",
")",
"{",
... | Does the encryption and decryption
@param {SimpleCryptoJS} simpleCryptoJS object of simple-crypto-js
@param {Object<any>} doc Object from transform-pouch
@param {Array} ignore doc property name not to be changed
@param {Boolean} isIncoming is to be encrypted or decrypted
@return {Object<any>} same as doc with unencrypted values | [
"Does",
"the",
"encryption",
"and",
"decryption"
] | 15179a510cc707c3402472716ef029d3255b12ee | https://github.com/lil5/simple-cryptor-pouch/blob/15179a510cc707c3402472716ef029d3255b12ee/src/cryptor.js#L28-L56 |
34,320 | MeldCE/json-crud | src/lib/common.js | doCreate | function doCreate(data) {
console.log('create called', data);
var i, keys = false;
if (data instanceof Array) {
if (typeof data[0] === 'undefined') {
return Promise.reject(new Error('Can\'t have undefined keys'));
}
// Check if a key is the first element
if (keyTypes.indexOf(typeof data[0]) !== -1) {
// Check for an even amount of elements
if (data.length % 2) {
return Promise.reject(new Error('uneven number of key/values given to create'));
}
// Check every second item are keys
for (i = 2; i < data.length; i = i + 2) {
if (keyTypes.indexOf(typeof data[i]) === -1) {
return Promise.reject(new Error('Invalid key value for key ' + (i + 1)
+ ' (' + typeof data[i] + ' given)'));
}
}
keys = true;
} else {
if (!this.options.id) {
return Promise.reject('Can\'t give an array of data objects if not key has been specified');
}
// Check if each object value has or doesn't have an id
for (i = 0; i < data.length; i++) {
if (typeof data[i][this.options.id] === 'undefined') {
return Promise.reject(new Error('Can\'t have objects in array without a key'));
}
}
}
return this.save.call(this, {
keys: keys,
data: data,
replace: false
});
} else if (data instanceof Object) {
// Find and update
return this.save.call(this, {
keys: true,
data: data,
replace: false
});
} else {
return Promise.reject(new Error('Unknown data type given'));
}
} | javascript | function doCreate(data) {
console.log('create called', data);
var i, keys = false;
if (data instanceof Array) {
if (typeof data[0] === 'undefined') {
return Promise.reject(new Error('Can\'t have undefined keys'));
}
// Check if a key is the first element
if (keyTypes.indexOf(typeof data[0]) !== -1) {
// Check for an even amount of elements
if (data.length % 2) {
return Promise.reject(new Error('uneven number of key/values given to create'));
}
// Check every second item are keys
for (i = 2; i < data.length; i = i + 2) {
if (keyTypes.indexOf(typeof data[i]) === -1) {
return Promise.reject(new Error('Invalid key value for key ' + (i + 1)
+ ' (' + typeof data[i] + ' given)'));
}
}
keys = true;
} else {
if (!this.options.id) {
return Promise.reject('Can\'t give an array of data objects if not key has been specified');
}
// Check if each object value has or doesn't have an id
for (i = 0; i < data.length; i++) {
if (typeof data[i][this.options.id] === 'undefined') {
return Promise.reject(new Error('Can\'t have objects in array without a key'));
}
}
}
return this.save.call(this, {
keys: keys,
data: data,
replace: false
});
} else if (data instanceof Object) {
// Find and update
return this.save.call(this, {
keys: true,
data: data,
replace: false
});
} else {
return Promise.reject(new Error('Unknown data type given'));
}
} | [
"function",
"doCreate",
"(",
"data",
")",
"{",
"console",
".",
"log",
"(",
"'create called'",
",",
"data",
")",
";",
"var",
"i",
",",
"keys",
"=",
"false",
";",
"if",
"(",
"data",
"instanceof",
"Array",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"... | Inserts data into the JSON database.
@param {Array|Object} data Either an object of key-value pairs, an array
containing key/value pairs ([key, value,...]) or, if the key field has
been specified, an array of object values each with the key field set
@returns {Promise} A promise that will resolve with an array containing
keys or errors in creating the data of the inserted data. | [
"Inserts",
"data",
"into",
"the",
"JSON",
"database",
"."
] | 524d0f95dc72b73db4c4571fc03a4d2b30676057 | https://github.com/MeldCE/json-crud/blob/524d0f95dc72b73db4c4571fc03a4d2b30676057/src/lib/common.js#L17-L70 |
34,321 | MeldCE/json-crud | src/lib/common.js | doUpdate | function doUpdate(data, filter) {
console.log('update called', data, filter);
var i, keys = false;
if (data instanceof Array) {
if (typeof data[0] === 'undefined') {
return Promise.reject(new Error('Can\'t have undefined keys'));
}
// Check if a key is the first element
if (keyTypes.indexOf(typeof data[0]) !== -1) {
// Check for an even amount of elements
if (data.length % 2) {
return Promise.reject(new Error('uneven number of key/values given to update'));
}
// Check every second item are keys
for (i = 2; i < data.length; i = i + 2) {
if (keyTypes.indexOf(typeof data[i]) === -1) {
return Promise.reject(new Error('Invalid key value for key ' + ((i/2) + 1)
+ ' (' + typeof data[i] + ' given)'));
}
}
keys = true;
} else {
if (!this.options.id) {
return Promise.reject(new Error('Can\'t give an array of data objects if not key has been specified'));
}
// Check if each object value has or doesn't have an id
for (i = 0; i < data.length; i++) {
if (typeof data[i][this.options.id] === 'undefined') {
return Promise.reject(new Error('Can\'t have objects in array without a key'));
}
}
}
// Check if given a filter object
if (typeof filter === 'object') {
return Promise.reject(new Error('can\'t use a filter with an array keyed objects'));
}
return this.save.call(this, {
keys: keys,
replace: filter === true ? true : undefined,
data: data
});
} else if(data instanceof Object) {
if (this.options.id && typeof data[this.options.id] !== 'undefined') {
return Promise.reject(new Error('Can\'t include key value when updating with object'));
}
if (typeof filter === 'boolean') {
// Object of key value pairs to put into database
return this.save.call(this, {
keys: true,
replace: filter ? true : undefined,
data: data
});
} else if (typeof filter === 'object') {
// Object of fields to update in object values selected with a filter
return this.save.call(this, {
data: data,
filter: filter
});
} else {
// Object of fields to update in all object values
return this.save.call(this, {
data: data
});
}
} else {
return Promise.reject(new Error('Unknown data type given'));
}
} | javascript | function doUpdate(data, filter) {
console.log('update called', data, filter);
var i, keys = false;
if (data instanceof Array) {
if (typeof data[0] === 'undefined') {
return Promise.reject(new Error('Can\'t have undefined keys'));
}
// Check if a key is the first element
if (keyTypes.indexOf(typeof data[0]) !== -1) {
// Check for an even amount of elements
if (data.length % 2) {
return Promise.reject(new Error('uneven number of key/values given to update'));
}
// Check every second item are keys
for (i = 2; i < data.length; i = i + 2) {
if (keyTypes.indexOf(typeof data[i]) === -1) {
return Promise.reject(new Error('Invalid key value for key ' + ((i/2) + 1)
+ ' (' + typeof data[i] + ' given)'));
}
}
keys = true;
} else {
if (!this.options.id) {
return Promise.reject(new Error('Can\'t give an array of data objects if not key has been specified'));
}
// Check if each object value has or doesn't have an id
for (i = 0; i < data.length; i++) {
if (typeof data[i][this.options.id] === 'undefined') {
return Promise.reject(new Error('Can\'t have objects in array without a key'));
}
}
}
// Check if given a filter object
if (typeof filter === 'object') {
return Promise.reject(new Error('can\'t use a filter with an array keyed objects'));
}
return this.save.call(this, {
keys: keys,
replace: filter === true ? true : undefined,
data: data
});
} else if(data instanceof Object) {
if (this.options.id && typeof data[this.options.id] !== 'undefined') {
return Promise.reject(new Error('Can\'t include key value when updating with object'));
}
if (typeof filter === 'boolean') {
// Object of key value pairs to put into database
return this.save.call(this, {
keys: true,
replace: filter ? true : undefined,
data: data
});
} else if (typeof filter === 'object') {
// Object of fields to update in object values selected with a filter
return this.save.call(this, {
data: data,
filter: filter
});
} else {
// Object of fields to update in all object values
return this.save.call(this, {
data: data
});
}
} else {
return Promise.reject(new Error('Unknown data type given'));
}
} | [
"function",
"doUpdate",
"(",
"data",
",",
"filter",
")",
"{",
"console",
".",
"log",
"(",
"'update called'",
",",
"data",
",",
"filter",
")",
";",
"var",
"i",
",",
"keys",
"=",
"false",
";",
"if",
"(",
"data",
"instanceof",
"Array",
")",
"{",
"if",
... | Updates data in the JSON database. Data can either be given as
key-value parameter pairs, OR if the key field has been specified Object
values. New values will be merge into any existing values.
@param {Object|Object[]|Array} data Either:
- an array of key-value pairs,
- an object containing the data to update
- object value(s) containing the key value (if a key has been specified)
@param {Object|true} [filter] If a object containing the data to update, a
filter to select the items that should be updated, or if object value(s)
have been given, true if the existing items should be replaced instead of
merged into
@returns {Promise} A promise that will resolve with an array containing
keys of the updated data. | [
"Updates",
"data",
"in",
"the",
"JSON",
"database",
".",
"Data",
"can",
"either",
"be",
"given",
"as",
"key",
"-",
"value",
"parameter",
"pairs",
"OR",
"if",
"the",
"key",
"field",
"has",
"been",
"specified",
"Object",
"values",
".",
"New",
"values",
"wi... | 524d0f95dc72b73db4c4571fc03a4d2b30676057 | https://github.com/MeldCE/json-crud/blob/524d0f95dc72b73db4c4571fc03a4d2b30676057/src/lib/common.js#L89-L164 |
34,322 | jiahaog/Revenant | lib/checks.js | function (callback) {
getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
if (error) {
callback (error);
return;
}
originalDom = dom;
callback();
});
} | javascript | function (callback) {
getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
if (error) {
callback (error);
return;
}
originalDom = dom;
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"getData",
".",
"takeSnapshot",
"(",
"page",
",",
"ph",
",",
"function",
"(",
"error",
",",
"page",
",",
"ph",
",",
"dom",
")",
"{",
"if",
"(",
"error",
")",
"{",
"callback",
"(",
"error",
")",
";",
"return",
... | save the initial dom | [
"save",
"the",
"initial",
"dom"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/checks.js#L94-L104 | |
34,323 | jiahaog/Revenant | lib/checks.js | function (callback) {
async.until(
// conditions for stopping the poll
function () {
waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
return waitTimeOver || domHasChanged;
},
function (callback) {
// polls the page at an interval
setTimeout(function () {
elapsed += constants.POLL_INTERVAL;
getData.takeSnapshot(page, ph, function (error, page, ph, newDom) {
if (error) {
callback(error);
return;
}
domHasChanged = helpers.domIsDifferent(originalDom, newDom);
callback();
});
}, constants.POLL_INTERVAL);
},
function (error) {
if (waitTimeOver) {
callback('Timeout while waiting for dom to change');
return;
}
callback(error);
}
);
} | javascript | function (callback) {
async.until(
// conditions for stopping the poll
function () {
waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
return waitTimeOver || domHasChanged;
},
function (callback) {
// polls the page at an interval
setTimeout(function () {
elapsed += constants.POLL_INTERVAL;
getData.takeSnapshot(page, ph, function (error, page, ph, newDom) {
if (error) {
callback(error);
return;
}
domHasChanged = helpers.domIsDifferent(originalDom, newDom);
callback();
});
}, constants.POLL_INTERVAL);
},
function (error) {
if (waitTimeOver) {
callback('Timeout while waiting for dom to change');
return;
}
callback(error);
}
);
} | [
"function",
"(",
"callback",
")",
"{",
"async",
".",
"until",
"(",
"// conditions for stopping the poll",
"function",
"(",
")",
"{",
"waitTimeOver",
"=",
"elapsed",
">",
"constants",
".",
"WAIT_TIMEOUT",
";",
"return",
"waitTimeOver",
"||",
"domHasChanged",
";",
... | poll the page for changes in the dom or until timeout | [
"poll",
"the",
"page",
"for",
"changes",
"in",
"the",
"dom",
"or",
"until",
"timeout"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/checks.js#L107-L137 | |
34,324 | jiahaog/Revenant | lib/checks.js | ajaxCallback | function ajaxCallback(page, ph, oldUrl, options, callback) {
// callback for page change
switch(options) {
case 1:
// expect ajax
pageDomHasChanged(page, ph, function (error, page, ph) {
callback(error, page, ph);
});
break;
case 2:
// expect navigation
pageHasChanged(page, oldUrl, function (error) {
callback(error, page, ph);
});
break;
default:
// callback immediately
callback(null, page, ph);
break;
}
} | javascript | function ajaxCallback(page, ph, oldUrl, options, callback) {
// callback for page change
switch(options) {
case 1:
// expect ajax
pageDomHasChanged(page, ph, function (error, page, ph) {
callback(error, page, ph);
});
break;
case 2:
// expect navigation
pageHasChanged(page, oldUrl, function (error) {
callback(error, page, ph);
});
break;
default:
// callback immediately
callback(null, page, ph);
break;
}
} | [
"function",
"ajaxCallback",
"(",
"page",
",",
"ph",
",",
"oldUrl",
",",
"options",
",",
"callback",
")",
"{",
"// callback for page change",
"switch",
"(",
"options",
")",
"{",
"case",
"1",
":",
"// expect ajax",
"pageDomHasChanged",
"(",
"page",
",",
"ph",
... | Waits for a callback based on the options
@param page
@param ph
@param oldUrl
@param options
@param {pageCallback} callback | [
"Waits",
"for",
"a",
"callback",
"based",
"on",
"the",
"options"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/checks.js#L151-L171 |
34,325 | jiahaog/Revenant | lib/checks.js | waitForString | function waitForString(page, ph, str, callback) {
var elapsed = 0;
var currentDom = '';
var timeout = false;
async.until(
function () {
timeout = elapsed > constants.WAIT_TIMEOUT;
return currentDom.indexOf(str) > -1 || timeout;
},
function (callback) {
setTimeout(function () {
getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
if (error) {
callback(error);
return;
}
currentDom = dom;
elapsed += constants.POLL_INTERVAL;
callback();
})
}, constants.POLL_INTERVAL);
},
function (error) {
if (error) {
callback(error, page, ph);
return;
}
if (timeout) {
callback('Timeout while waiting for string', page, ph);
return;
}
callback(null, page, ph);
}
);
} | javascript | function waitForString(page, ph, str, callback) {
var elapsed = 0;
var currentDom = '';
var timeout = false;
async.until(
function () {
timeout = elapsed > constants.WAIT_TIMEOUT;
return currentDom.indexOf(str) > -1 || timeout;
},
function (callback) {
setTimeout(function () {
getData.takeSnapshot(page, ph, function (error, page, ph, dom) {
if (error) {
callback(error);
return;
}
currentDom = dom;
elapsed += constants.POLL_INTERVAL;
callback();
})
}, constants.POLL_INTERVAL);
},
function (error) {
if (error) {
callback(error, page, ph);
return;
}
if (timeout) {
callback('Timeout while waiting for string', page, ph);
return;
}
callback(null, page, ph);
}
);
} | [
"function",
"waitForString",
"(",
"page",
",",
"ph",
",",
"str",
",",
"callback",
")",
"{",
"var",
"elapsed",
"=",
"0",
";",
"var",
"currentDom",
"=",
"''",
";",
"var",
"timeout",
"=",
"false",
";",
"async",
".",
"until",
"(",
"function",
"(",
")",
... | Polls the DOM and wait until a certain string is present
@param page
@param ph
@param str
@param {pageCallback} callback | [
"Polls",
"the",
"DOM",
"and",
"wait",
"until",
"a",
"certain",
"string",
"is",
"present"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/checks.js#L180-L217 |
34,326 | jiahaog/Revenant | lib/checks.js | querySelectorOnBrowser | function querySelectorOnBrowser(selector) {
// stupid error catching here to stop the browser from printing null cannot be found to stdout
var query;
try {
// do this to simulate a scroll to the bottom of the page to trigger loading of certain ajax elements
//todo somehow this still doesnt work
document.body.scrollTop = 0;
document.body.scrollTop = 9999999999;
//window.document.body.scrollTop = document.body.scrollHeight;
query = document.querySelector(selector).innerHTML;
} catch (exception) {
return false;
}
return true;
} | javascript | function querySelectorOnBrowser(selector) {
// stupid error catching here to stop the browser from printing null cannot be found to stdout
var query;
try {
// do this to simulate a scroll to the bottom of the page to trigger loading of certain ajax elements
//todo somehow this still doesnt work
document.body.scrollTop = 0;
document.body.scrollTop = 9999999999;
//window.document.body.scrollTop = document.body.scrollHeight;
query = document.querySelector(selector).innerHTML;
} catch (exception) {
return false;
}
return true;
} | [
"function",
"querySelectorOnBrowser",
"(",
"selector",
")",
"{",
"// stupid error catching here to stop the browser from printing null cannot be found to stdout",
"var",
"query",
";",
"try",
"{",
"// do this to simulate a scroll to the bottom of the page to trigger loading of certain ajax el... | check if the element referenced by the selector exists | [
"check",
"if",
"the",
"element",
"referenced",
"by",
"the",
"selector",
"exists"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/checks.js#L231-L246 |
34,327 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (objectPath) {
var levels = objectPath.split('.');
var currentValue = values;
if (levels.length > 0) {
for (var i = 0; i < levels.length; i++) {
currentValue = currentValue[levels[i]];
}
return currentValue
}
return undefined
} | javascript | function (objectPath) {
var levels = objectPath.split('.');
var currentValue = values;
if (levels.length > 0) {
for (var i = 0; i < levels.length; i++) {
currentValue = currentValue[levels[i]];
}
return currentValue
}
return undefined
} | [
"function",
"(",
"objectPath",
")",
"{",
"var",
"levels",
"=",
"objectPath",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"currentValue",
"=",
"values",
";",
"if",
"(",
"levels",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
... | Helper function which loops trought the object to get a nested attribute value. | [
"Helper",
"function",
"which",
"loops",
"trought",
"the",
"object",
"to",
"get",
"a",
"nested",
"attribute",
"value",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L627-L640 | |
34,328 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (msgctxt, msgid) {
var message;
if (this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt]) {
message = this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt][msgid];
}
if (!message) {
return msgid
} else {
return message.msgstr[0] || message.msgid
}
} | javascript | function (msgctxt, msgid) {
var message;
if (this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt]) {
message = this.$i18n.getLocaleMessage(this.$i18n.activeLocale)[msgctxt][msgid];
}
if (!message) {
return msgid
} else {
return message.msgstr[0] || message.msgid
}
} | [
"function",
"(",
"msgctxt",
",",
"msgid",
")",
"{",
"var",
"message",
";",
"if",
"(",
"this",
".",
"$i18n",
".",
"getLocaleMessage",
"(",
"this",
".",
"$i18n",
".",
"activeLocale",
")",
"[",
"msgctxt",
"]",
")",
"{",
"message",
"=",
"this",
".",
"$i1... | Context + Singular | [
"Context",
"+",
"Singular"
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L708-L719 | |
34,329 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (context, type, value, options) {
var FORMATTER;
switch (type) {
case 'number':
FORMATTER = {
constructor: Intl.NumberFormat,
cachedInstance: context.$i18n.NUMBER_FORMATTER
};
break
case 'currency':
FORMATTER = {
constructor: Intl.CurrencyFormat,
cachedInstance: context.$i18n.CURRENCY_FORMATTER
};
break
case 'date':
FORMATTER = {
constructor: Intl.DateTimeFormat,
cachedInstance: context.$i18n.DATE_TIME_FORMATTER
};
break
}
if (FORMATTER && value !== undefined && value !== null && value !== false) {
if (typeof options === 'object') {
options = Object.assign(context.$i18n[(type + "Format")], options);
} else {
options = undefined;
}
return options ? new FORMATTER.constructor(context.$i18n.activeLocale, options).format(value) : FORMATTER.cachedInstance.format(value)
} else {
return value
}
} | javascript | function (context, type, value, options) {
var FORMATTER;
switch (type) {
case 'number':
FORMATTER = {
constructor: Intl.NumberFormat,
cachedInstance: context.$i18n.NUMBER_FORMATTER
};
break
case 'currency':
FORMATTER = {
constructor: Intl.CurrencyFormat,
cachedInstance: context.$i18n.CURRENCY_FORMATTER
};
break
case 'date':
FORMATTER = {
constructor: Intl.DateTimeFormat,
cachedInstance: context.$i18n.DATE_TIME_FORMATTER
};
break
}
if (FORMATTER && value !== undefined && value !== null && value !== false) {
if (typeof options === 'object') {
options = Object.assign(context.$i18n[(type + "Format")], options);
} else {
options = undefined;
}
return options ? new FORMATTER.constructor(context.$i18n.activeLocale, options).format(value) : FORMATTER.cachedInstance.format(value)
} else {
return value
}
} | [
"function",
"(",
"context",
",",
"type",
",",
"value",
",",
"options",
")",
"{",
"var",
"FORMATTER",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'number'",
":",
"FORMATTER",
"=",
"{",
"constructor",
":",
"Intl",
".",
"NumberFormat",
",",
"cachedInstan... | Expose date and number formatting methods. | [
"Expose",
"date",
"and",
"number",
"formatting",
"methods",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L2955-L2990 | |
34,330 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (name, params) {
return {
name: name || to.name,
params: params ? Object.assign(to.params, params) : to.params,
hash: to.hash,
query: to.query
}
} | javascript | function (name, params) {
return {
name: name || to.name,
params: params ? Object.assign(to.params, params) : to.params,
hash: to.hash,
query: to.query
}
} | [
"function",
"(",
"name",
",",
"params",
")",
"{",
"return",
"{",
"name",
":",
"name",
"||",
"to",
".",
"name",
",",
"params",
":",
"params",
"?",
"Object",
".",
"assign",
"(",
"to",
".",
"params",
",",
"params",
")",
":",
"to",
".",
"params",
","... | Helper for defining the `next` object. | [
"Helper",
"for",
"defining",
"the",
"next",
"object",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L3269-L3276 | |
34,331 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (_changeLocale) {
// If the saved locale is equal to the default locale make sure that the URL format is correct.
if (to.meta.localized && !config.defaultLocaleInRoutes) {
var _next = defineNext(to.meta.seedRoute.name);
if (_changeLocale) {
router.go(_next);
} else {
next(_next);
}
} else if (!to.meta.localized && config.defaultLocaleInRoutes) {
var _next$1 = defineNext('__locale:' + to.meta.i18nId);
if (_changeLocale) {
router.go(_next$1);
} else {
next(_next$1);
}
} else if (_changeLocale) {
router.go(defineNext());
}
} | javascript | function (_changeLocale) {
// If the saved locale is equal to the default locale make sure that the URL format is correct.
if (to.meta.localized && !config.defaultLocaleInRoutes) {
var _next = defineNext(to.meta.seedRoute.name);
if (_changeLocale) {
router.go(_next);
} else {
next(_next);
}
} else if (!to.meta.localized && config.defaultLocaleInRoutes) {
var _next$1 = defineNext('__locale:' + to.meta.i18nId);
if (_changeLocale) {
router.go(_next$1);
} else {
next(_next$1);
}
} else if (_changeLocale) {
router.go(defineNext());
}
} | [
"function",
"(",
"_changeLocale",
")",
"{",
"// If the saved locale is equal to the default locale make sure that the URL format is correct.",
"if",
"(",
"to",
".",
"meta",
".",
"localized",
"&&",
"!",
"config",
".",
"defaultLocaleInRoutes",
")",
"{",
"var",
"_next",
"=",... | Handle the default locale. | [
"Handle",
"the",
"default",
"locale",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L3279-L3300 | |
34,332 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (newLocale) {
if (config.storageMethod !== 'custom') {
switchMethods[config.storageMethod].save(config.storageKey, newLocale, savedLocale, config.cookieExpirationInDays);
} else {
config.storageFunctions.save(config.storageKey, newLocale, savedLocale);
}
} | javascript | function (newLocale) {
if (config.storageMethod !== 'custom') {
switchMethods[config.storageMethod].save(config.storageKey, newLocale, savedLocale, config.cookieExpirationInDays);
} else {
config.storageFunctions.save(config.storageKey, newLocale, savedLocale);
}
} | [
"function",
"(",
"newLocale",
")",
"{",
"if",
"(",
"config",
".",
"storageMethod",
"!==",
"'custom'",
")",
"{",
"switchMethods",
"[",
"config",
".",
"storageMethod",
"]",
".",
"save",
"(",
"config",
".",
"storageKey",
",",
"newLocale",
",",
"savedLocale",
... | Helper for saving the new locale. | [
"Helper",
"for",
"saving",
"the",
"new",
"locale",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L3303-L3309 | |
34,333 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (location) {
if (typeof location === 'string') {
var isRelative = location.charAt(0) !== '/';
var toPath;
if (this.$i18n.routeAutoPrefix) {
toPath = pathToRegexp_1.compile(_path('/:_locale?/' + location));
} else {
toPath = pathToRegexp_1.compile(location.replace('$locale', ':_locale?'));
}
var path = toPath({ _locale: this.$i18n.activeLocale === this.$i18n.defaultLocale ? (this.$i18n.defaultLocaleInRoutes ? this.$i18n.activeLocale : undefined) : this.$i18n.activeLocale });
return path === '' ? '/' : isRelative ? path.substr(1) : path
} else {
return location
}
// TODO: Add support when the object contains name and/or path.
} | javascript | function (location) {
if (typeof location === 'string') {
var isRelative = location.charAt(0) !== '/';
var toPath;
if (this.$i18n.routeAutoPrefix) {
toPath = pathToRegexp_1.compile(_path('/:_locale?/' + location));
} else {
toPath = pathToRegexp_1.compile(location.replace('$locale', ':_locale?'));
}
var path = toPath({ _locale: this.$i18n.activeLocale === this.$i18n.defaultLocale ? (this.$i18n.defaultLocaleInRoutes ? this.$i18n.activeLocale : undefined) : this.$i18n.activeLocale });
return path === '' ? '/' : isRelative ? path.substr(1) : path
} else {
return location
}
// TODO: Add support when the object contains name and/or path.
} | [
"function",
"(",
"location",
")",
"{",
"if",
"(",
"typeof",
"location",
"===",
"'string'",
")",
"{",
"var",
"isRelative",
"=",
"location",
".",
"charAt",
"(",
"0",
")",
"!==",
"'/'",
";",
"var",
"toPath",
";",
"if",
"(",
"this",
".",
"$i18n",
".",
... | Converts a router link to the version of the current locale. | [
"Converts",
"a",
"router",
"link",
"to",
"the",
"version",
"of",
"the",
"current",
"locale",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L3464-L3480 | |
34,334 | eldarc/vue-i18n-gettext | dist/vue-i18n-gettext.esm.js | function (options) {
var _options = {
messages: options.messages || {},
numberFormat: options.numberFormat || {},
currencyFormat: options.currencyFormat || {},
dateFormat: options.dateFormat || {},
numberFormats: options.numberFormats || {},
currencyFormats: options.currencyFormats || {},
currencyLocaleFormats: options.currencyLocaleFormats || {},
dateFormats: options.dateFormats || {},
defaultCurrency: options.defaultCurrency || 'USD',
currencies: options.currencies || {},
persistCurrency: options.persistCurrency === undefined ? true : options.persistCurrency,
defaultLocale: options.defaultLocale || 'en',
allLocales: options.allLocales || (options.defaultLocale ? [options.defaultLocale] : ['en']),
forceReloadOnSwitch: options.forceReloadOnSwitch === undefined ? true : options.forceReloadOnSwitch,
usingRouter: options.usingRouter === undefined ? false : options.usingRouter,
defaultLocaleInRoutes: options.defaultLocaleInRoutes === undefined ? false : options.defaultLocaleInRoutes,
routingStyle: options.routingStyle || 'changeLocale',
routeAutoPrefix: options.routeAutoPrefix === undefined ? true : options.routeAutoPrefix,
// TODO: Implement better storageMethod parsing.
storageMethod: typeof options.storageMethod !== 'object' ? (['session', 'local', 'cookie'].includes(options.storageMethod.trim()) ? options.storageMethod.trim() : 'local') : 'custom',
storageKey: options.storageKey || '_vue_i18n_gettext_locale',
cookieExpirationInDays: options.cookieExpirationInDays || 30,
customOnLoad: options.customOnLoad
};
if (_options.storageMethod === 'custom') {
_options.storageFunctions = options.storageMethod;
}
return _options
} | javascript | function (options) {
var _options = {
messages: options.messages || {},
numberFormat: options.numberFormat || {},
currencyFormat: options.currencyFormat || {},
dateFormat: options.dateFormat || {},
numberFormats: options.numberFormats || {},
currencyFormats: options.currencyFormats || {},
currencyLocaleFormats: options.currencyLocaleFormats || {},
dateFormats: options.dateFormats || {},
defaultCurrency: options.defaultCurrency || 'USD',
currencies: options.currencies || {},
persistCurrency: options.persistCurrency === undefined ? true : options.persistCurrency,
defaultLocale: options.defaultLocale || 'en',
allLocales: options.allLocales || (options.defaultLocale ? [options.defaultLocale] : ['en']),
forceReloadOnSwitch: options.forceReloadOnSwitch === undefined ? true : options.forceReloadOnSwitch,
usingRouter: options.usingRouter === undefined ? false : options.usingRouter,
defaultLocaleInRoutes: options.defaultLocaleInRoutes === undefined ? false : options.defaultLocaleInRoutes,
routingStyle: options.routingStyle || 'changeLocale',
routeAutoPrefix: options.routeAutoPrefix === undefined ? true : options.routeAutoPrefix,
// TODO: Implement better storageMethod parsing.
storageMethod: typeof options.storageMethod !== 'object' ? (['session', 'local', 'cookie'].includes(options.storageMethod.trim()) ? options.storageMethod.trim() : 'local') : 'custom',
storageKey: options.storageKey || '_vue_i18n_gettext_locale',
cookieExpirationInDays: options.cookieExpirationInDays || 30,
customOnLoad: options.customOnLoad
};
if (_options.storageMethod === 'custom') {
_options.storageFunctions = options.storageMethod;
}
return _options
} | [
"function",
"(",
"options",
")",
"{",
"var",
"_options",
"=",
"{",
"messages",
":",
"options",
".",
"messages",
"||",
"{",
"}",
",",
"numberFormat",
":",
"options",
".",
"numberFormat",
"||",
"{",
"}",
",",
"currencyFormat",
":",
"options",
".",
"currenc... | Parse configuration and return normalized values. | [
"Parse",
"configuration",
"and",
"return",
"normalized",
"values",
"."
] | 3432d500065c655c9f6ee54563d18c221449098f | https://github.com/eldarc/vue-i18n-gettext/blob/3432d500065c655c9f6ee54563d18c221449098f/dist/vue-i18n-gettext.esm.js#L3564-L3596 | |
34,335 | jiahaog/Revenant | lib/Revenant.js | function (task, argument, callback) {
var self = this;
var queueArgument = {
task: task,
argument: argument
};
return promiseOrCallback(callback, function (resolve, reject) {
self.taskQueue.push(queueArgument, function (error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
} | javascript | function (task, argument, callback) {
var self = this;
var queueArgument = {
task: task,
argument: argument
};
return promiseOrCallback(callback, function (resolve, reject) {
self.taskQueue.push(queueArgument, function (error, result) {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
} | [
"function",
"(",
"task",
",",
"argument",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"queueArgument",
"=",
"{",
"task",
":",
"task",
",",
"argument",
":",
"argument",
"}",
";",
"return",
"promiseOrCallback",
"(",
"callback",
",",
... | Private helper function to push a task
@param task
@param argument
@param callback
@returns {Promise}
@private | [
"Private",
"helper",
"function",
"to",
"push",
"a",
"task"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/Revenant.js#L101-L117 | |
34,336 | jiahaog/Revenant | lib/Revenant.js | promiseOrCallback | function promiseOrCallback (callback, executor) {
var promise = new Promise(executor);
// no callback: do not attach
if (typeof callback !== 'function') {
return promise;
}
return promise.then(function (value) {
setImmediate(function () {
callback(null, value);
});
return value;
}, function (error) {
setImmediate(function () {
callback(error);
});
throw error;
});
} | javascript | function promiseOrCallback (callback, executor) {
var promise = new Promise(executor);
// no callback: do not attach
if (typeof callback !== 'function') {
return promise;
}
return promise.then(function (value) {
setImmediate(function () {
callback(null, value);
});
return value;
}, function (error) {
setImmediate(function () {
callback(error);
});
throw error;
});
} | [
"function",
"promiseOrCallback",
"(",
"callback",
",",
"executor",
")",
"{",
"var",
"promise",
"=",
"new",
"Promise",
"(",
"executor",
")",
";",
"// no callback: do not attach",
"if",
"(",
"typeof",
"callback",
"!==",
"'function'",
")",
"{",
"return",
"promise",... | Build a promise, with an optional node-style callback attached | [
"Build",
"a",
"promise",
"with",
"an",
"optional",
"node",
"-",
"style",
"callback",
"attached"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/Revenant.js#L218-L237 |
34,337 | tkellen/js-matchdep | lib/matchdep.js | loadConfig | function loadConfig(config, props) {
// The calling module's path. Unfortunately, because modules are cached,
// module.parent is the FIRST calling module parent, not necessarily the
// current one.
var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName());
// If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error.
if (config == null) {
config = findup('package.json', {cwd: callerPath});
if (config == null) {
throw new Error('No package.json found.');
}
}
// If filename was specified with no path parts, make the path absolute so
// that resolve doesn't look in node_module directories for it.
else if (typeof config === 'string' && !/[\\\/]/.test(config)) {
config = path.join(callerPath, config);
}
// If package is a string, try to require it.
if (typeof config === 'string') {
config = require(resolve(config, {basedir: callerPath}));
}
// If config is not an object yet, something is amiss.
if (typeof config !== 'object') {
throw new Error('Invalid configuration specified.');
}
// For all specified props, populate result object.
var result = {};
props.forEach(function(prop) {
result[prop] = config[prop] ? Object.keys(config[prop]) : [];
});
return result;
} | javascript | function loadConfig(config, props) {
// The calling module's path. Unfortunately, because modules are cached,
// module.parent is the FIRST calling module parent, not necessarily the
// current one.
var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName());
// If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error.
if (config == null) {
config = findup('package.json', {cwd: callerPath});
if (config == null) {
throw new Error('No package.json found.');
}
}
// If filename was specified with no path parts, make the path absolute so
// that resolve doesn't look in node_module directories for it.
else if (typeof config === 'string' && !/[\\\/]/.test(config)) {
config = path.join(callerPath, config);
}
// If package is a string, try to require it.
if (typeof config === 'string') {
config = require(resolve(config, {basedir: callerPath}));
}
// If config is not an object yet, something is amiss.
if (typeof config !== 'object') {
throw new Error('Invalid configuration specified.');
}
// For all specified props, populate result object.
var result = {};
props.forEach(function(prop) {
result[prop] = config[prop] ? Object.keys(config[prop]) : [];
});
return result;
} | [
"function",
"loadConfig",
"(",
"config",
",",
"props",
")",
"{",
"// The calling module's path. Unfortunately, because modules are cached,",
"// module.parent is the FIRST calling module parent, not necessarily the",
"// current one.",
"var",
"callerPath",
"=",
"path",
".",
"dirname"... | Ensure configuration has the correct properties. | [
"Ensure",
"configuration",
"has",
"the",
"correct",
"properties",
"."
] | 645b0b1eee69e9779d081248b04f646c80795c94 | https://github.com/tkellen/js-matchdep/blob/645b0b1eee69e9779d081248b04f646c80795c94/lib/matchdep.js#L21-L56 |
34,338 | dragosch/kurento-group-call | example/static/js/participant.js | Participant | function Participant(name) {
this.name = name;
var container = document.createElement('div');
container.className = isPresentMainParticipant() ? PARTICIPANT_CLASS : PARTICIPANT_MAIN_CLASS;
container.id = name;
var span = document.createElement('span');
var video = document.createElement('video');
var rtcPeer;
container.appendChild(video);
container.appendChild(span);
container.onclick = switchContainerClass;
document.getElementById('participants').appendChild(container);
span.appendChild(document.createTextNode(name));
video.id = 'video-' + name;
video.autoplay = true;
video.controls = false;
this.getElement = function() {
return container;
}
this.getVideoElement = function() {
return video;
}
function switchContainerClass() {
if (container.className === PARTICIPANT_CLASS) {
var elements = Array.prototype.slice.call(document.getElementsByClassName(PARTICIPANT_MAIN_CLASS));
elements.forEach(function(item) {
item.className = PARTICIPANT_CLASS;
});
container.className = PARTICIPANT_MAIN_CLASS;
} else {
container.className = PARTICIPANT_CLASS;
}
}
function isPresentMainParticipant() {
return ((document.getElementsByClassName(PARTICIPANT_MAIN_CLASS)).length != 0);
}
this.offerToReceiveVideo = function(offerSdp, wp){
console.log('Invoking SDP offer callback function');
var msg = { id : "receiveVideoFrom",
sender : name,
sdpOffer : offerSdp
};
sendMessage('receiveVideoFrom', msg);
}
Object.defineProperty(this, 'rtcPeer', { writable: true});
this.dispose = function() {
console.log('Disposing participant ' + this.name);
this.rtcPeer.dispose();
container.parentNode.removeChild(container);
};
} | javascript | function Participant(name) {
this.name = name;
var container = document.createElement('div');
container.className = isPresentMainParticipant() ? PARTICIPANT_CLASS : PARTICIPANT_MAIN_CLASS;
container.id = name;
var span = document.createElement('span');
var video = document.createElement('video');
var rtcPeer;
container.appendChild(video);
container.appendChild(span);
container.onclick = switchContainerClass;
document.getElementById('participants').appendChild(container);
span.appendChild(document.createTextNode(name));
video.id = 'video-' + name;
video.autoplay = true;
video.controls = false;
this.getElement = function() {
return container;
}
this.getVideoElement = function() {
return video;
}
function switchContainerClass() {
if (container.className === PARTICIPANT_CLASS) {
var elements = Array.prototype.slice.call(document.getElementsByClassName(PARTICIPANT_MAIN_CLASS));
elements.forEach(function(item) {
item.className = PARTICIPANT_CLASS;
});
container.className = PARTICIPANT_MAIN_CLASS;
} else {
container.className = PARTICIPANT_CLASS;
}
}
function isPresentMainParticipant() {
return ((document.getElementsByClassName(PARTICIPANT_MAIN_CLASS)).length != 0);
}
this.offerToReceiveVideo = function(offerSdp, wp){
console.log('Invoking SDP offer callback function');
var msg = { id : "receiveVideoFrom",
sender : name,
sdpOffer : offerSdp
};
sendMessage('receiveVideoFrom', msg);
}
Object.defineProperty(this, 'rtcPeer', { writable: true});
this.dispose = function() {
console.log('Disposing participant ' + this.name);
this.rtcPeer.dispose();
container.parentNode.removeChild(container);
};
} | [
"function",
"Participant",
"(",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"var",
"container",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"container",
".",
"className",
"=",
"isPresentMainParticipant",
"(",
")",
"?",
"PART... | Creates a video element for a new participant
@param {String} name - the name of the new participant, to be used as tag
name of the video element.
The tag of the new element will be 'video<name>'
@return | [
"Creates",
"a",
"video",
"element",
"for",
"a",
"new",
"participant"
] | b9e4120829964de93c31ceffe2958de76cf2dd03 | https://github.com/dragosch/kurento-group-call/blob/b9e4120829964de93c31ceffe2958de76cf2dd03/example/static/js/participant.js#L27-L89 |
34,339 | superguigui/simple-color-picker | src/index.js | SimpleColorPicker | function SimpleColorPicker(options) {
// Options
options = options || {};
// Properties
this.color = null;
this.width = 0;
this.widthUnits = 'px';
this.height = 0;
this.heightUnits = 'px';
this.hue = 0;
this.position = {x: 0, y: 0};
this.huePosition = 0;
this.saturationWidth = 0;
this.hueHeight = 0;
this.maxHue = 0;
this.inputIsNumber = false;
// Bind methods to scope (if needed)
this._onSaturationMouseDown = this._onSaturationMouseDown.bind(this);
this._onSaturationMouseMove = this._onSaturationMouseMove.bind(this);
this._onSaturationMouseUp = this._onSaturationMouseUp.bind(this);
this._onHueMouseDown = this._onHueMouseDown.bind(this);
this._onHueMouseMove = this._onHueMouseMove.bind(this);
this._onHueMouseUp = this._onHueMouseUp.bind(this);
// Register window and document references in case this is instantiated inside of an iframe
this.window = options.window || window;
this.document = this.window.document
// Create DOM
this.$el = this.document.createElement('div');
this.$el.className = 'Scp';
this.$el.innerHTML = [
'<div class="Scp-saturation">',
'<div class="Scp-brightness"></div>',
'<div class="Scp-sbSelector"></div>',
'</div>',
'<div class="Scp-hue">',
'<div class="Scp-hSelector"></div>',
'</div>'
].join('');
// DOM accessors
this.$saturation = this.$el.querySelector('.Scp-saturation');
this.$hue = this.$el.querySelector('.Scp-hue');
this.$sbSelector = this.$el.querySelector('.Scp-sbSelector');
this.$hSelector = this.$el.querySelector('.Scp-hSelector');
// Event listeners
this.$saturation.addEventListener('mousedown', this._onSaturationMouseDown);
this.$saturation.addEventListener('touchstart', this._onSaturationMouseDown);
this.$hue.addEventListener('mousedown', this._onHueMouseDown);
this.$hue.addEventListener('touchstart', this._onHueMouseDown);
// Some styling and DOMing from options
if (options.el) {
this.appendTo(options.el);
}
if (options.background) {
this.setBackgroundColor(options.background);
}
if (options.widthUnits) {
this.widthUnits = options.widthUnits;
}
if (options.heightUnits) {
this.heightUnits = options.heightUnits;
}
this.setSize(options.width || 175, options.height || 150);
this.setColor(options.color);
return this;
} | javascript | function SimpleColorPicker(options) {
// Options
options = options || {};
// Properties
this.color = null;
this.width = 0;
this.widthUnits = 'px';
this.height = 0;
this.heightUnits = 'px';
this.hue = 0;
this.position = {x: 0, y: 0};
this.huePosition = 0;
this.saturationWidth = 0;
this.hueHeight = 0;
this.maxHue = 0;
this.inputIsNumber = false;
// Bind methods to scope (if needed)
this._onSaturationMouseDown = this._onSaturationMouseDown.bind(this);
this._onSaturationMouseMove = this._onSaturationMouseMove.bind(this);
this._onSaturationMouseUp = this._onSaturationMouseUp.bind(this);
this._onHueMouseDown = this._onHueMouseDown.bind(this);
this._onHueMouseMove = this._onHueMouseMove.bind(this);
this._onHueMouseUp = this._onHueMouseUp.bind(this);
// Register window and document references in case this is instantiated inside of an iframe
this.window = options.window || window;
this.document = this.window.document
// Create DOM
this.$el = this.document.createElement('div');
this.$el.className = 'Scp';
this.$el.innerHTML = [
'<div class="Scp-saturation">',
'<div class="Scp-brightness"></div>',
'<div class="Scp-sbSelector"></div>',
'</div>',
'<div class="Scp-hue">',
'<div class="Scp-hSelector"></div>',
'</div>'
].join('');
// DOM accessors
this.$saturation = this.$el.querySelector('.Scp-saturation');
this.$hue = this.$el.querySelector('.Scp-hue');
this.$sbSelector = this.$el.querySelector('.Scp-sbSelector');
this.$hSelector = this.$el.querySelector('.Scp-hSelector');
// Event listeners
this.$saturation.addEventListener('mousedown', this._onSaturationMouseDown);
this.$saturation.addEventListener('touchstart', this._onSaturationMouseDown);
this.$hue.addEventListener('mousedown', this._onHueMouseDown);
this.$hue.addEventListener('touchstart', this._onHueMouseDown);
// Some styling and DOMing from options
if (options.el) {
this.appendTo(options.el);
}
if (options.background) {
this.setBackgroundColor(options.background);
}
if (options.widthUnits) {
this.widthUnits = options.widthUnits;
}
if (options.heightUnits) {
this.heightUnits = options.heightUnits;
}
this.setSize(options.width || 175, options.height || 150);
this.setColor(options.color);
return this;
} | [
"function",
"SimpleColorPicker",
"(",
"options",
")",
"{",
"// Options",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// Properties",
"this",
".",
"color",
"=",
"null",
";",
"this",
".",
"width",
"=",
"0",
";",
"this",
".",
"widthUnits",
"=",
"'px'",... | Creates a new SimpleColorPicker
@param {Object} options
@param {String|Number|Object} options.color The default color that the picker will display. Default is #FFFFFF. It can be a hexadecimal number or an hex String.
@param {String|Number|Object} options.background The background color of the picker. Default is transparent. It can be a hexadecimal number or an hex String.
@param {HTMLElement} options.el A dom node to add the picker to. You can also use `colorPicker.appendTo(domNode)` afterwards if you prefer.
@param {Number} options.width Desired width of the color picker. Default is 175.
@param {Number} options.height Desired height of the color picker. Default is 150. | [
"Creates",
"a",
"new",
"SimpleColorPicker"
] | db41350abcf3b012f7d4672a151cee90baf20dd8 | https://github.com/superguigui/simple-color-picker/blob/db41350abcf3b012f7d4672a151cee90baf20dd8/src/index.js#L19-L91 |
34,340 | MeldCE/json-crud | src/lib/JsonFileDB.js | has | function has(key) {
if (options.cacheValues) {
return Promise.resolve((cachedData[key] !== undefined));
} else if (options.cacheKeys) {
return Promise.resolve((cachedKeys.indexOf(key) !== -1));
} else {
return readData().then(function(data) {
return (data[key] !== undefined);
});
}
} | javascript | function has(key) {
if (options.cacheValues) {
return Promise.resolve((cachedData[key] !== undefined));
} else if (options.cacheKeys) {
return Promise.resolve((cachedKeys.indexOf(key) !== -1));
} else {
return readData().then(function(data) {
return (data[key] !== undefined);
});
}
} | [
"function",
"has",
"(",
"key",
")",
"{",
"if",
"(",
"options",
".",
"cacheValues",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
"(",
"cachedData",
"[",
"key",
"]",
"!==",
"undefined",
")",
")",
";",
"}",
"else",
"if",
"(",
"options",
".",
"c... | Implements checking for if a value for a key exists
@param {Key} key Key to see if there is a value for
@returns {Promise} A promise that will resolve to a Boolean value of
whether or not a value for the given key exists | [
"Implements",
"checking",
"for",
"if",
"a",
"value",
"for",
"a",
"key",
"exists"
] | 524d0f95dc72b73db4c4571fc03a4d2b30676057 | https://github.com/MeldCE/json-crud/blob/524d0f95dc72b73db4c4571fc03a4d2b30676057/src/lib/JsonFileDB.js#L239-L249 |
34,341 | MeldCE/json-crud | src/lib/JsonFileDB.js | close | function close() {
if (file !== false && options.listen) {
fs.unwatch(file, listener);
}
return Promise.resolve();
} | javascript | function close() {
if (file !== false && options.listen) {
fs.unwatch(file, listener);
}
return Promise.resolve();
} | [
"function",
"close",
"(",
")",
"{",
"if",
"(",
"file",
"!==",
"false",
"&&",
"options",
".",
"listen",
")",
"{",
"fs",
".",
"unwatch",
"(",
"file",
",",
"listener",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}"
] | Cleans up after the CRUD instance. Should be called just before the
instance is deleted
@returns {Promise} A Promise that resolves when the instance is closed | [
"Cleans",
"up",
"after",
"the",
"CRUD",
"instance",
".",
"Should",
"be",
"called",
"just",
"before",
"the",
"instance",
"is",
"deleted"
] | 524d0f95dc72b73db4c4571fc03a4d2b30676057 | https://github.com/MeldCE/json-crud/blob/524d0f95dc72b73db4c4571fc03a4d2b30676057/src/lib/JsonFileDB.js#L498-L504 |
34,342 | erha19/eslint-plugin-weex | lib/rules/vue/comment-directive.js | parse | function parse (pattern, comment) {
const match = pattern.exec(comment)
if (match == null) {
return null
}
const type = match[1]
const rules = (match[2] || '')
.split(',')
.map(s => s.trim())
.filter(Boolean)
return { type, rules }
} | javascript | function parse (pattern, comment) {
const match = pattern.exec(comment)
if (match == null) {
return null
}
const type = match[1]
const rules = (match[2] || '')
.split(',')
.map(s => s.trim())
.filter(Boolean)
return { type, rules }
} | [
"function",
"parse",
"(",
"pattern",
",",
"comment",
")",
"{",
"const",
"match",
"=",
"pattern",
".",
"exec",
"(",
"comment",
")",
"if",
"(",
"match",
"==",
"null",
")",
"{",
"return",
"null",
"}",
"const",
"type",
"=",
"match",
"[",
"1",
"]",
"con... | Parse a given comment.
@param {RegExp} pattern The RegExp pattern to parse.
@param {string} comment The comment value to parse.
@returns {({type:string,rules:string[]})|null} The parsing result. | [
"Parse",
"a",
"given",
"comment",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/comment-directive.js#L21-L34 |
34,343 | erha19/eslint-plugin-weex | lib/rules/vue/comment-directive.js | enable | function enable (context, loc, group, rules) {
if (rules.length === 0) {
context.report({ loc, message: '++ {{group}}', data: { group }})
} else {
context.report({ loc, message: '+ {{group}} {{rules}}', data: { group, rules: rules.join(' ') }})
}
} | javascript | function enable (context, loc, group, rules) {
if (rules.length === 0) {
context.report({ loc, message: '++ {{group}}', data: { group }})
} else {
context.report({ loc, message: '+ {{group}} {{rules}}', data: { group, rules: rules.join(' ') }})
}
} | [
"function",
"enable",
"(",
"context",
",",
"loc",
",",
"group",
",",
"rules",
")",
"{",
"if",
"(",
"rules",
".",
"length",
"===",
"0",
")",
"{",
"context",
".",
"report",
"(",
"{",
"loc",
",",
"message",
":",
"'++ {{group}}'",
",",
"data",
":",
"{"... | Enable rules.
@param {RuleContext} context The rule context.
@param {{line:number,column:number}} loc The location information to enable.
@param {string} group The group to enable.
@param {string[]} rules The rule IDs to enable.
@returns {void} | [
"Enable",
"rules",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/comment-directive.js#L44-L50 |
34,344 | erha19/eslint-plugin-weex | lib/rules/vue/comment-directive.js | processBlock | function processBlock (context, comment) {
const parsed = parse(COMMENT_DIRECTIVE_B, comment.value)
if (parsed != null) {
if (parsed.type === 'eslint-disable') {
disable(context, comment.loc.start, 'block', parsed.rules)
} else {
enable(context, comment.loc.start, 'block', parsed.rules)
}
}
} | javascript | function processBlock (context, comment) {
const parsed = parse(COMMENT_DIRECTIVE_B, comment.value)
if (parsed != null) {
if (parsed.type === 'eslint-disable') {
disable(context, comment.loc.start, 'block', parsed.rules)
} else {
enable(context, comment.loc.start, 'block', parsed.rules)
}
}
} | [
"function",
"processBlock",
"(",
"context",
",",
"comment",
")",
"{",
"const",
"parsed",
"=",
"parse",
"(",
"COMMENT_DIRECTIVE_B",
",",
"comment",
".",
"value",
")",
"if",
"(",
"parsed",
"!=",
"null",
")",
"{",
"if",
"(",
"parsed",
".",
"type",
"===",
... | Process a given comment token.
If the comment is `eslint-disable` or `eslint-enable` then it reports the comment.
@param {RuleContext} context The rule context.
@param {Token} comment The comment token to process.
@returns {void} | [
"Process",
"a",
"given",
"comment",
"token",
".",
"If",
"the",
"comment",
"is",
"eslint",
"-",
"disable",
"or",
"eslint",
"-",
"enable",
"then",
"it",
"reports",
"the",
"comment",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/comment-directive.js#L75-L84 |
34,345 | erha19/eslint-plugin-weex | lib/rules/vue/comment-directive.js | processLine | function processLine (context, comment) {
const parsed = parse(COMMENT_DIRECTIVE_L, comment.value)
if (parsed != null && comment.loc.start.line === comment.loc.end.line) {
const line = comment.loc.start.line + (parsed.type === 'eslint-disable-line' ? 0 : 1)
const column = -1
disable(context, { line, column }, 'line', parsed.rules)
enable(context, { line: line + 1, column }, 'line', parsed.rules)
}
} | javascript | function processLine (context, comment) {
const parsed = parse(COMMENT_DIRECTIVE_L, comment.value)
if (parsed != null && comment.loc.start.line === comment.loc.end.line) {
const line = comment.loc.start.line + (parsed.type === 'eslint-disable-line' ? 0 : 1)
const column = -1
disable(context, { line, column }, 'line', parsed.rules)
enable(context, { line: line + 1, column }, 'line', parsed.rules)
}
} | [
"function",
"processLine",
"(",
"context",
",",
"comment",
")",
"{",
"const",
"parsed",
"=",
"parse",
"(",
"COMMENT_DIRECTIVE_L",
",",
"comment",
".",
"value",
")",
"if",
"(",
"parsed",
"!=",
"null",
"&&",
"comment",
".",
"loc",
".",
"start",
".",
"line"... | Process a given comment token.
If the comment is `eslint-disable-line` or `eslint-disable-next-line` then it reports the comment.
@param {RuleContext} context The rule context.
@param {Token} comment The comment token to process.
@returns {void} | [
"Process",
"a",
"given",
"comment",
"token",
".",
"If",
"the",
"comment",
"is",
"eslint",
"-",
"disable",
"-",
"line",
"or",
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"then",
"it",
"reports",
"the",
"comment",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/comment-directive.js#L93-L101 |
34,346 | jiahaog/Revenant | lib/getData.js | getCurrentUrl | function getCurrentUrl(page, ph, callback) {
page.get('url', function (url) {
callback(null, page, ph, url);
});
} | javascript | function getCurrentUrl(page, ph, callback) {
page.get('url', function (url) {
callback(null, page, ph, url);
});
} | [
"function",
"getCurrentUrl",
"(",
"page",
",",
"ph",
",",
"callback",
")",
"{",
"page",
".",
"get",
"(",
"'url'",
",",
"function",
"(",
"url",
")",
"{",
"callback",
"(",
"null",
",",
"page",
",",
"ph",
",",
"url",
")",
";",
"}",
")",
";",
"}"
] | Gets the current url of the page
@param page
@param ph
@param {pageResultCallback} callback | [
"Gets",
"the",
"current",
"url",
"of",
"the",
"page"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L15-L19 |
34,347 | jiahaog/Revenant | lib/getData.js | takeSnapshot | function takeSnapshot(page, ph, callback) {
page.evaluate(function () {
return document.documentElement.outerHTML;
}, function (document) {
if (document) {
callback(null, page, ph, document);
} else {
callback('Nothing retrieved', page, ph, null);
}
});
} | javascript | function takeSnapshot(page, ph, callback) {
page.evaluate(function () {
return document.documentElement.outerHTML;
}, function (document) {
if (document) {
callback(null, page, ph, document);
} else {
callback('Nothing retrieved', page, ph, null);
}
});
} | [
"function",
"takeSnapshot",
"(",
"page",
",",
"ph",
",",
"callback",
")",
"{",
"page",
".",
"evaluate",
"(",
"function",
"(",
")",
"{",
"return",
"document",
".",
"documentElement",
".",
"outerHTML",
";",
"}",
",",
"function",
"(",
"document",
")",
"{",
... | Takes a static snapshot of the page
@param page
@param ph
@param {pageResultCallback} callback | [
"Takes",
"a",
"static",
"snapshot",
"of",
"the",
"page"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L27-L37 |
34,348 | jiahaog/Revenant | lib/getData.js | getInnerHtmlFromElement | function getInnerHtmlFromElement(page, ph, selector, callback) {
function getInnerHtml(selector) {
return document.querySelector(selector).innerHTML;
}
page.evaluate(getInnerHtml, function (result) {
if (result) {
callback(null, page, ph, result);
} else {
var errorString = 'Error finding innerHTML';
callback(errorString, page, ph, null);
}
}, selector);
} | javascript | function getInnerHtmlFromElement(page, ph, selector, callback) {
function getInnerHtml(selector) {
return document.querySelector(selector).innerHTML;
}
page.evaluate(getInnerHtml, function (result) {
if (result) {
callback(null, page, ph, result);
} else {
var errorString = 'Error finding innerHTML';
callback(errorString, page, ph, null);
}
}, selector);
} | [
"function",
"getInnerHtmlFromElement",
"(",
"page",
",",
"ph",
",",
"selector",
",",
"callback",
")",
"{",
"function",
"getInnerHtml",
"(",
"selector",
")",
"{",
"return",
"document",
".",
"querySelector",
"(",
"selector",
")",
".",
"innerHTML",
";",
"}",
"p... | Evaluates gets the innerHTML of a certain selected element on a apge
@param page
@param ph
@param selector
@param {pageResultCallback} callback | [
"Evaluates",
"gets",
"the",
"innerHTML",
"of",
"a",
"certain",
"selected",
"element",
"on",
"a",
"apge"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L46-L59 |
34,349 | jiahaog/Revenant | lib/getData.js | getSelectorValue | function getSelectorValue(page, ph, selector, callback) {
page.evaluate(function (selector) {
try {
return [null, document.querySelector(selector).value];
} catch (error) {
return [error];
}
}, function (result) {
var error = result[0];
var selectorValue = result[1];
if (error) {
callback(error, page, ph);
return;
}
callback(null, page, ph, selectorValue);
}, selector);
} | javascript | function getSelectorValue(page, ph, selector, callback) {
page.evaluate(function (selector) {
try {
return [null, document.querySelector(selector).value];
} catch (error) {
return [error];
}
}, function (result) {
var error = result[0];
var selectorValue = result[1];
if (error) {
callback(error, page, ph);
return;
}
callback(null, page, ph, selectorValue);
}, selector);
} | [
"function",
"getSelectorValue",
"(",
"page",
",",
"ph",
",",
"selector",
",",
"callback",
")",
"{",
"page",
".",
"evaluate",
"(",
"function",
"(",
"selector",
")",
"{",
"try",
"{",
"return",
"[",
"null",
",",
"document",
".",
"querySelector",
"(",
"selec... | Gets the .value of a selector
@param page
@param ph
@param selector
@param {pageResultCallback} callback | [
"Gets",
"the",
".",
"value",
"of",
"a",
"selector"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L97-L113 |
34,350 | jiahaog/Revenant | lib/getData.js | downloadFromUrl | function downloadFromUrl(page, ph, url, callback) {
async.waterfall([
function (callback) {
page.getCookies(function (cookie) {
callback(null, page, ph, cookie);
});
},
function (page, ph, cookies, callback) {
var cookieString = helpers.cookieToHeader(cookies);
var headers = { Cookie: cookieString };
request.get({
url: url,
headers: headers,
encoding: null
}, function (error, response, downloadedBytes) {
callback(error, page, ph, downloadedBytes);
});
}
], callback);
} | javascript | function downloadFromUrl(page, ph, url, callback) {
async.waterfall([
function (callback) {
page.getCookies(function (cookie) {
callback(null, page, ph, cookie);
});
},
function (page, ph, cookies, callback) {
var cookieString = helpers.cookieToHeader(cookies);
var headers = { Cookie: cookieString };
request.get({
url: url,
headers: headers,
encoding: null
}, function (error, response, downloadedBytes) {
callback(error, page, ph, downloadedBytes);
});
}
], callback);
} | [
"function",
"downloadFromUrl",
"(",
"page",
",",
"ph",
",",
"url",
",",
"callback",
")",
"{",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"callback",
")",
"{",
"page",
".",
"getCookies",
"(",
"function",
"(",
"cookie",
")",
"{",
"callback",
"... | Downloads a file from a url
@param page
@param ph
@param {string} url
@param {pageResultCallback} callback | [
"Downloads",
"a",
"file",
"from",
"a",
"url"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L122-L141 |
34,351 | jiahaog/Revenant | lib/getData.js | downloadFromClick | function downloadFromClick(page, ph, selector, callback) {
const HREF_KEY = 'href';
async.waterfall([
function (callback) {
getSelectorAttribute(page, ph, [selector, HREF_KEY], callback);
},
function (page, ph, relativeHref, callback) {
getCurrentUrl(page, ph, function (error, page, ph, currentUrl) {
if (error) {
callback(error, page, ph);
return;
}
callback(null, page, ph, currentUrl + relativeHref);
});
},
function (page, ph, url, callback) {
downloadFromUrl(page, ph, url, callback);
}
], callback);
} | javascript | function downloadFromClick(page, ph, selector, callback) {
const HREF_KEY = 'href';
async.waterfall([
function (callback) {
getSelectorAttribute(page, ph, [selector, HREF_KEY], callback);
},
function (page, ph, relativeHref, callback) {
getCurrentUrl(page, ph, function (error, page, ph, currentUrl) {
if (error) {
callback(error, page, ph);
return;
}
callback(null, page, ph, currentUrl + relativeHref);
});
},
function (page, ph, url, callback) {
downloadFromUrl(page, ph, url, callback);
}
], callback);
} | [
"function",
"downloadFromClick",
"(",
"page",
",",
"ph",
",",
"selector",
",",
"callback",
")",
"{",
"const",
"HREF_KEY",
"=",
"'href'",
";",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"callback",
")",
"{",
"getSelectorAttribute",
"(",
"page",
"... | Clicks an element on the page and downloads the file behind the element
@param page
@param ph
@param {string} selector
@param {pageResultCallback} callback | [
"Clicks",
"an",
"element",
"on",
"the",
"page",
"and",
"downloads",
"the",
"file",
"behind",
"the",
"element"
] | 562dd4e7a6bacb9c8b51c1344a5e336545177516 | https://github.com/jiahaog/Revenant/blob/562dd4e7a6bacb9c8b51c1344a5e336545177516/lib/getData.js#L150-L169 |
34,352 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | isBeginningOfLine | function isBeginningOfLine (node, index, nodes) {
if (node != null) {
for (let i = index - 1; i >= 0; --i) {
const prevNode = nodes[i]
if (prevNode == null) {
continue
}
return node.loc.start.line !== prevNode.loc.end.line
}
}
return false
} | javascript | function isBeginningOfLine (node, index, nodes) {
if (node != null) {
for (let i = index - 1; i >= 0; --i) {
const prevNode = nodes[i]
if (prevNode == null) {
continue
}
return node.loc.start.line !== prevNode.loc.end.line
}
}
return false
} | [
"function",
"isBeginningOfLine",
"(",
"node",
",",
"index",
",",
"nodes",
")",
"{",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"index",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"const",
"prevNode",
"... | Check whether the node is at the beginning of line.
@param {Node} node The node to check.
@param {number} index The index of the node in the nodes.
@param {Node[]} nodes The array of nodes.
@returns {boolean} `true` if the node is at the beginning of line. | [
"Check",
"whether",
"the",
"node",
"is",
"at",
"the",
"beginning",
"of",
"line",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L214-L226 |
34,353 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | isClosingToken | function isClosingToken (token) {
return token != null && (
token.type === 'HTMLEndTagOpen' ||
token.type === 'VExpressionEnd' ||
(
token.type === 'Punctuator' &&
(
token.value === ')' ||
token.value === '}' ||
token.value === ']'
)
)
)
} | javascript | function isClosingToken (token) {
return token != null && (
token.type === 'HTMLEndTagOpen' ||
token.type === 'VExpressionEnd' ||
(
token.type === 'Punctuator' &&
(
token.value === ')' ||
token.value === '}' ||
token.value === ']'
)
)
)
} | [
"function",
"isClosingToken",
"(",
"token",
")",
"{",
"return",
"token",
"!=",
"null",
"&&",
"(",
"token",
".",
"type",
"===",
"'HTMLEndTagOpen'",
"||",
"token",
".",
"type",
"===",
"'VExpressionEnd'",
"||",
"(",
"token",
".",
"type",
"===",
"'Punctuator'",
... | Check whether a given token is a closing token which triggers unindent.
@param {Token} token The token to check.
@returns {boolean} `true` if the token is a closing token. | [
"Check",
"whether",
"a",
"given",
"token",
"is",
"a",
"closing",
"token",
"which",
"triggers",
"unindent",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L233-L246 |
34,354 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | isTrivialToken | function isTrivialToken (token) {
return token != null && (
(token.type === 'Punctuator' && TRIVIAL_PUNCTUATOR.test(token.value)) ||
token.type === 'HTMLTagOpen' ||
token.type === 'HTMLEndTagOpen' ||
token.type === 'HTMLTagClose' ||
token.type === 'HTMLSelfClosingTagClose'
)
} | javascript | function isTrivialToken (token) {
return token != null && (
(token.type === 'Punctuator' && TRIVIAL_PUNCTUATOR.test(token.value)) ||
token.type === 'HTMLTagOpen' ||
token.type === 'HTMLEndTagOpen' ||
token.type === 'HTMLTagClose' ||
token.type === 'HTMLSelfClosingTagClose'
)
} | [
"function",
"isTrivialToken",
"(",
"token",
")",
"{",
"return",
"token",
"!=",
"null",
"&&",
"(",
"(",
"token",
".",
"type",
"===",
"'Punctuator'",
"&&",
"TRIVIAL_PUNCTUATOR",
".",
"test",
"(",
"token",
".",
"value",
")",
")",
"||",
"token",
".",
"type",... | Check whether a given token is trivial or not.
@param {Token} token The token to check.
@returns {boolean} `true` if the token is trivial. | [
"Check",
"whether",
"a",
"given",
"token",
"is",
"trivial",
"or",
"not",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L253-L261 |
34,355 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | setBaseline | function setBaseline (token, hardTabAdditional) {
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
offsetInfo.baseline = true
}
} | javascript | function setBaseline (token, hardTabAdditional) {
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
offsetInfo.baseline = true
}
} | [
"function",
"setBaseline",
"(",
"token",
",",
"hardTabAdditional",
")",
"{",
"const",
"offsetInfo",
"=",
"offsets",
".",
"get",
"(",
"token",
")",
"if",
"(",
"offsetInfo",
"!=",
"null",
")",
"{",
"offsetInfo",
".",
"baseline",
"=",
"true",
"}",
"}"
] | Set baseline flag to the given token.
@param {Token} token The token to set.
@returns {void} | [
"Set",
"baseline",
"flag",
"to",
"the",
"given",
"token",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L311-L316 |
34,356 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | processTopLevelNode | function processTopLevelNode (node, expectedIndent) {
const token = tokenStore.getFirstToken(node)
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
offsetInfo.expectedIndent = expectedIndent
} else {
offsets.set(token, { baseToken: null, offset: 0, baseline: false, expectedIndent })
}
} | javascript | function processTopLevelNode (node, expectedIndent) {
const token = tokenStore.getFirstToken(node)
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
offsetInfo.expectedIndent = expectedIndent
} else {
offsets.set(token, { baseToken: null, offset: 0, baseline: false, expectedIndent })
}
} | [
"function",
"processTopLevelNode",
"(",
"node",
",",
"expectedIndent",
")",
"{",
"const",
"token",
"=",
"tokenStore",
".",
"getFirstToken",
"(",
"node",
")",
"const",
"offsetInfo",
"=",
"offsets",
".",
"get",
"(",
"token",
")",
"if",
"(",
"offsetInfo",
"!=",... | Set the base indentation to a given top-level AST node.
@param {Node} node The node to set.
@param {number} expectedIndent The number of expected indent.
@returns {void} | [
"Set",
"the",
"base",
"indentation",
"to",
"a",
"given",
"top",
"-",
"level",
"AST",
"node",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L517-L525 |
34,357 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | processIgnores | function processIgnores (visitor) {
for (const ignorePattern of options.ignores) {
const key = `${ignorePattern}:exit`
if (visitor.hasOwnProperty(key)) {
const handler = visitor[key]
visitor[key] = function (node) {
const ret = handler.apply(this, arguments)
ignore(node)
return ret
}
} else {
visitor[key] = ignore
}
}
return visitor
} | javascript | function processIgnores (visitor) {
for (const ignorePattern of options.ignores) {
const key = `${ignorePattern}:exit`
if (visitor.hasOwnProperty(key)) {
const handler = visitor[key]
visitor[key] = function (node) {
const ret = handler.apply(this, arguments)
ignore(node)
return ret
}
} else {
visitor[key] = ignore
}
}
return visitor
} | [
"function",
"processIgnores",
"(",
"visitor",
")",
"{",
"for",
"(",
"const",
"ignorePattern",
"of",
"options",
".",
"ignores",
")",
"{",
"const",
"key",
"=",
"`",
"${",
"ignorePattern",
"}",
"`",
"if",
"(",
"visitor",
".",
"hasOwnProperty",
"(",
"key",
"... | Define functions to ignore nodes into the given visitor.
@param {Object} visitor The visitor to define functions to ignore nodes.
@returns {Object} The visitor. | [
"Define",
"functions",
"to",
"ignore",
"nodes",
"into",
"the",
"given",
"visitor",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L543-L560 |
34,358 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | getExpectedIndent | function getExpectedIndent (tokens) {
const trivial = isTrivialToken(tokens[0])
let expectedIndent = Number.MAX_SAFE_INTEGER
for (let i = 0; i < tokens.length; ++i) {
const token = tokens[i]
const offsetInfo = offsets.get(token)
// If the first token is not trivial then ignore trivial following tokens.
if (offsetInfo != null && (trivial || !isTrivialToken(token))) {
if (offsetInfo.expectedIndent != null) {
expectedIndent = Math.min(expectedIndent, offsetInfo.expectedIndent)
} else {
const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
if (baseOffsetInfo != null && baseOffsetInfo.expectedIndent != null && (i === 0 || !baseOffsetInfo.baseline)) {
expectedIndent = Math.min(expectedIndent, baseOffsetInfo.expectedIndent + offsetInfo.offset * options.indentSize)
if (baseOffsetInfo.baseline) {
break
}
}
}
}
}
return expectedIndent
} | javascript | function getExpectedIndent (tokens) {
const trivial = isTrivialToken(tokens[0])
let expectedIndent = Number.MAX_SAFE_INTEGER
for (let i = 0; i < tokens.length; ++i) {
const token = tokens[i]
const offsetInfo = offsets.get(token)
// If the first token is not trivial then ignore trivial following tokens.
if (offsetInfo != null && (trivial || !isTrivialToken(token))) {
if (offsetInfo.expectedIndent != null) {
expectedIndent = Math.min(expectedIndent, offsetInfo.expectedIndent)
} else {
const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
if (baseOffsetInfo != null && baseOffsetInfo.expectedIndent != null && (i === 0 || !baseOffsetInfo.baseline)) {
expectedIndent = Math.min(expectedIndent, baseOffsetInfo.expectedIndent + offsetInfo.offset * options.indentSize)
if (baseOffsetInfo.baseline) {
break
}
}
}
}
}
return expectedIndent
} | [
"function",
"getExpectedIndent",
"(",
"tokens",
")",
"{",
"const",
"trivial",
"=",
"isTrivialToken",
"(",
"tokens",
"[",
"0",
"]",
")",
"let",
"expectedIndent",
"=",
"Number",
".",
"MAX_SAFE_INTEGER",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"tok... | Calculate correct indentation of the line of the given tokens.
@param {Token[]} tokens Tokens which are on the same line.
@returns {number} Correct indentation. If it failed to calculate then `Number.MAX_SAFE_INTEGER`. | [
"Calculate",
"correct",
"indentation",
"of",
"the",
"line",
"of",
"the",
"given",
"tokens",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L567-L592 |
34,359 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | getIndentText | function getIndentText (firstToken) {
const text = sourceCode.text
let i = firstToken.range[0] - 1
while (i >= 0 && !LT_CHAR.test(text[i])) {
i -= 1
}
return text.slice(i + 1, firstToken.range[0])
} | javascript | function getIndentText (firstToken) {
const text = sourceCode.text
let i = firstToken.range[0] - 1
while (i >= 0 && !LT_CHAR.test(text[i])) {
i -= 1
}
return text.slice(i + 1, firstToken.range[0])
} | [
"function",
"getIndentText",
"(",
"firstToken",
")",
"{",
"const",
"text",
"=",
"sourceCode",
".",
"text",
"let",
"i",
"=",
"firstToken",
".",
"range",
"[",
"0",
"]",
"-",
"1",
"while",
"(",
"i",
">=",
"0",
"&&",
"!",
"LT_CHAR",
".",
"test",
"(",
"... | Get the text of the indentation part of the line which the given token is on.
@param {Token} firstToken The first token on a line.
@returns {string} The text of indentation part. | [
"Get",
"the",
"text",
"of",
"the",
"indentation",
"part",
"of",
"the",
"line",
"which",
"the",
"given",
"token",
"is",
"on",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L599-L608 |
34,360 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | validateCore | function validateCore (token, expectedIndent, optionalExpectedIndent) {
const line = token.loc.start.line
const indentText = getIndentText(token)
// If there is no line terminator after the `<script>` start tag,
// `indentText` contains non-whitespace characters.
// In that case, do nothing in order to prevent removing the `<script>` tag.
if (indentText.trim() !== '') {
return
}
const actualIndent = token.loc.start.column
const unit = (options.indentChar === '\t' ? 'tab' : 'space')
for (let i = 0; i < indentText.length; ++i) {
if (indentText[i] !== options.indentChar) {
context.report({
loc: {
start: { line, column: i },
end: { line, column: i + 1 }
},
message: 'Expected {{expected}} character, but found {{actual}} character.',
data: {
expected: JSON.stringify(options.indentChar),
actual: JSON.stringify(indentText[i])
},
fix: defineFix(token, actualIndent, expectedIndent)
})
return
}
}
if (actualIndent !== expectedIndent && (optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent)) {
context.report({
loc: {
start: { line, column: 0 },
end: { line, column: actualIndent }
},
message: 'Expected indentation of {{expectedIndent}} {{unit}}{{expectedIndentPlural}} but found {{actualIndent}} {{unit}}{{actualIndentPlural}}.',
data: {
expectedIndent,
actualIndent,
unit,
expectedIndentPlural: (expectedIndent === 1) ? '' : 's',
actualIndentPlural: (actualIndent === 1) ? '' : 's'
},
fix: defineFix(token, actualIndent, expectedIndent)
})
}
} | javascript | function validateCore (token, expectedIndent, optionalExpectedIndent) {
const line = token.loc.start.line
const indentText = getIndentText(token)
// If there is no line terminator after the `<script>` start tag,
// `indentText` contains non-whitespace characters.
// In that case, do nothing in order to prevent removing the `<script>` tag.
if (indentText.trim() !== '') {
return
}
const actualIndent = token.loc.start.column
const unit = (options.indentChar === '\t' ? 'tab' : 'space')
for (let i = 0; i < indentText.length; ++i) {
if (indentText[i] !== options.indentChar) {
context.report({
loc: {
start: { line, column: i },
end: { line, column: i + 1 }
},
message: 'Expected {{expected}} character, but found {{actual}} character.',
data: {
expected: JSON.stringify(options.indentChar),
actual: JSON.stringify(indentText[i])
},
fix: defineFix(token, actualIndent, expectedIndent)
})
return
}
}
if (actualIndent !== expectedIndent && (optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent)) {
context.report({
loc: {
start: { line, column: 0 },
end: { line, column: actualIndent }
},
message: 'Expected indentation of {{expectedIndent}} {{unit}}{{expectedIndentPlural}} but found {{actualIndent}} {{unit}}{{actualIndentPlural}}.',
data: {
expectedIndent,
actualIndent,
unit,
expectedIndentPlural: (expectedIndent === 1) ? '' : 's',
actualIndentPlural: (actualIndent === 1) ? '' : 's'
},
fix: defineFix(token, actualIndent, expectedIndent)
})
}
} | [
"function",
"validateCore",
"(",
"token",
",",
"expectedIndent",
",",
"optionalExpectedIndent",
")",
"{",
"const",
"line",
"=",
"token",
".",
"loc",
".",
"start",
".",
"line",
"const",
"indentText",
"=",
"getIndentText",
"(",
"token",
")",
"// If there is no lin... | Validate the given token with the pre-calculated expected indentation.
@param {Token} token The token to validate.
@param {number} expectedIndent The expected indentation.
@param {number|undefined} optionalExpectedIndent The optional expected indentation.
@returns {void} | [
"Validate",
"the",
"given",
"token",
"with",
"the",
"pre",
"-",
"calculated",
"expected",
"indentation",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L649-L698 |
34,361 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | getCommentExpectedIndents | function getCommentExpectedIndents (nextToken, nextExpectedIndent, lastExpectedIndent) {
if (typeof lastExpectedIndent === 'number' && isClosingToken(nextToken)) {
if (nextExpectedIndent === lastExpectedIndent) {
// For solo comment. E.g.,
// <div>
// <!-- comment -->
// </div>
return {
primary: nextExpectedIndent + options.indentSize,
secondary: undefined
}
}
// For last comment. E.g.,
// <div>
// <div></div>
// <!-- comment -->
// </div>
return { primary: lastExpectedIndent, secondary: nextExpectedIndent }
}
// Adjust to next normally. E.g.,
// <div>
// <!-- comment -->
// <div></div>
// </div>
return { primary: nextExpectedIndent, secondary: undefined }
} | javascript | function getCommentExpectedIndents (nextToken, nextExpectedIndent, lastExpectedIndent) {
if (typeof lastExpectedIndent === 'number' && isClosingToken(nextToken)) {
if (nextExpectedIndent === lastExpectedIndent) {
// For solo comment. E.g.,
// <div>
// <!-- comment -->
// </div>
return {
primary: nextExpectedIndent + options.indentSize,
secondary: undefined
}
}
// For last comment. E.g.,
// <div>
// <div></div>
// <!-- comment -->
// </div>
return { primary: lastExpectedIndent, secondary: nextExpectedIndent }
}
// Adjust to next normally. E.g.,
// <div>
// <!-- comment -->
// <div></div>
// </div>
return { primary: nextExpectedIndent, secondary: undefined }
} | [
"function",
"getCommentExpectedIndents",
"(",
"nextToken",
",",
"nextExpectedIndent",
",",
"lastExpectedIndent",
")",
"{",
"if",
"(",
"typeof",
"lastExpectedIndent",
"===",
"'number'",
"&&",
"isClosingToken",
"(",
"nextToken",
")",
")",
"{",
"if",
"(",
"nextExpected... | Get the expected indent of comments.
@param {Token|null} nextToken The next token of comments.
@param {number|undefined} nextExpectedIndent The expected indent of the next token.
@param {number|undefined} lastExpectedIndent The expected indent of the last token.
@returns {{primary:number|undefined,secondary:number|undefined}} | [
"Get",
"the",
"expected",
"indent",
"of",
"comments",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L707-L734 |
34,362 | erha19/eslint-plugin-weex | lib/utils/indent-common.js | validate | function validate (tokens, comments, lastToken) {
// Calculate and save expected indentation.
const firstToken = tokens[0]
const actualIndent = firstToken.loc.start.column
const expectedIndent = getExpectedIndent(tokens)
if (expectedIndent === Number.MAX_SAFE_INTEGER) {
return
}
// Debug log
// console.log('line', firstToken.loc.start.line, '=', { actualIndent, expectedIndent }, 'from:')
// for (const token of tokens) {
// const offsetInfo = offsets.get(token)
// if (offsetInfo == null) {
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is unknown.')
// } else if (offsetInfo.expectedIndent != null) {
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is fixed at', offsetInfo.expectedIndent, '.')
// } else {
// const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is', offsetInfo.offset, 'offset from ', JSON.stringify(sourceCode.getText(offsetInfo.baseToken)), '( line:', offsetInfo.baseToken && offsetInfo.baseToken.loc.start.line, ', indent:', baseOffsetInfo && baseOffsetInfo.expectedIndent, ', baseline:', baseOffsetInfo && baseOffsetInfo.baseline, ')')
// }
// }
// Save.
const baseline = new Set()
for (const token of tokens) {
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
if (offsetInfo.baseline) {
// This is a baseline token, so the expected indent is the column of this token.
if (options.indentChar === ' ') {
offsetInfo.expectedIndent = Math.max(0, token.loc.start.column + expectedIndent - actualIndent)
} else {
// In hard-tabs mode, it cannot align tokens strictly, so use one additional offset.
// But the additional offset isn't needed if it's at the beginning of the line.
offsetInfo.expectedIndent = expectedIndent + (token === tokens[0] ? 0 : 1)
}
baseline.add(token)
} else if (baseline.has(offsetInfo.baseToken)) {
// The base token is a baseline token on this line, so inherit it.
offsetInfo.expectedIndent = offsets.get(offsetInfo.baseToken).expectedIndent
baseline.add(token)
} else {
// Otherwise, set the expected indent of this line.
offsetInfo.expectedIndent = expectedIndent
}
}
}
// Calculate the expected indents for comments.
// It allows the same indent level with the previous line.
const lastOffsetInfo = offsets.get(lastToken)
const lastExpectedIndent = lastOffsetInfo && lastOffsetInfo.expectedIndent
const commentExpectedIndents = getCommentExpectedIndents(firstToken, expectedIndent, lastExpectedIndent)
// Validate.
for (const comment of comments) {
validateCore(comment, commentExpectedIndents.primary, commentExpectedIndents.secondary)
}
validateCore(firstToken, expectedIndent)
} | javascript | function validate (tokens, comments, lastToken) {
// Calculate and save expected indentation.
const firstToken = tokens[0]
const actualIndent = firstToken.loc.start.column
const expectedIndent = getExpectedIndent(tokens)
if (expectedIndent === Number.MAX_SAFE_INTEGER) {
return
}
// Debug log
// console.log('line', firstToken.loc.start.line, '=', { actualIndent, expectedIndent }, 'from:')
// for (const token of tokens) {
// const offsetInfo = offsets.get(token)
// if (offsetInfo == null) {
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is unknown.')
// } else if (offsetInfo.expectedIndent != null) {
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is fixed at', offsetInfo.expectedIndent, '.')
// } else {
// const baseOffsetInfo = offsets.get(offsetInfo.baseToken)
// console.log(' ', JSON.stringify(sourceCode.getText(token)), 'is', offsetInfo.offset, 'offset from ', JSON.stringify(sourceCode.getText(offsetInfo.baseToken)), '( line:', offsetInfo.baseToken && offsetInfo.baseToken.loc.start.line, ', indent:', baseOffsetInfo && baseOffsetInfo.expectedIndent, ', baseline:', baseOffsetInfo && baseOffsetInfo.baseline, ')')
// }
// }
// Save.
const baseline = new Set()
for (const token of tokens) {
const offsetInfo = offsets.get(token)
if (offsetInfo != null) {
if (offsetInfo.baseline) {
// This is a baseline token, so the expected indent is the column of this token.
if (options.indentChar === ' ') {
offsetInfo.expectedIndent = Math.max(0, token.loc.start.column + expectedIndent - actualIndent)
} else {
// In hard-tabs mode, it cannot align tokens strictly, so use one additional offset.
// But the additional offset isn't needed if it's at the beginning of the line.
offsetInfo.expectedIndent = expectedIndent + (token === tokens[0] ? 0 : 1)
}
baseline.add(token)
} else if (baseline.has(offsetInfo.baseToken)) {
// The base token is a baseline token on this line, so inherit it.
offsetInfo.expectedIndent = offsets.get(offsetInfo.baseToken).expectedIndent
baseline.add(token)
} else {
// Otherwise, set the expected indent of this line.
offsetInfo.expectedIndent = expectedIndent
}
}
}
// Calculate the expected indents for comments.
// It allows the same indent level with the previous line.
const lastOffsetInfo = offsets.get(lastToken)
const lastExpectedIndent = lastOffsetInfo && lastOffsetInfo.expectedIndent
const commentExpectedIndents = getCommentExpectedIndents(firstToken, expectedIndent, lastExpectedIndent)
// Validate.
for (const comment of comments) {
validateCore(comment, commentExpectedIndents.primary, commentExpectedIndents.secondary)
}
validateCore(firstToken, expectedIndent)
} | [
"function",
"validate",
"(",
"tokens",
",",
"comments",
",",
"lastToken",
")",
"{",
"// Calculate and save expected indentation.",
"const",
"firstToken",
"=",
"tokens",
"[",
"0",
"]",
"const",
"actualIndent",
"=",
"firstToken",
".",
"loc",
".",
"start",
".",
"co... | Validate indentation of the line that the given tokens are on.
@param {Token[]} tokens The tokens on the same line to validate.
@param {Token[]} comments The comments which are on the immediately previous lines of the tokens.
@param {Token|null} lastToken The last validated token. Comments can adjust to the token.
@returns {void} | [
"Validate",
"indentation",
"of",
"the",
"line",
"that",
"the",
"given",
"tokens",
"are",
"on",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/utils/indent-common.js#L743-L803 |
34,363 | erha19/eslint-plugin-weex | lib/rules/vue/valid-v-model.js | isValidElement | function isValidElement (node) {
const name = node.name
return (
name === 'input' ||
name === 'select' ||
name === 'textarea' ||
(
name !== 'keep-alive' &&
name !== 'slot' &&
name !== 'transition' &&
name !== 'transition-group' &&
utils.isCustomComponent(node)
)
)
} | javascript | function isValidElement (node) {
const name = node.name
return (
name === 'input' ||
name === 'select' ||
name === 'textarea' ||
(
name !== 'keep-alive' &&
name !== 'slot' &&
name !== 'transition' &&
name !== 'transition-group' &&
utils.isCustomComponent(node)
)
)
} | [
"function",
"isValidElement",
"(",
"node",
")",
"{",
"const",
"name",
"=",
"node",
".",
"name",
"return",
"(",
"name",
"===",
"'input'",
"||",
"name",
"===",
"'select'",
"||",
"name",
"===",
"'textarea'",
"||",
"(",
"name",
"!==",
"'keep-alive'",
"&&",
"... | Check whether the given node is valid or not.
@param {ASTNode} node The element node to check.
@returns {boolean} `true` if the node is valid. | [
"Check",
"whether",
"the",
"given",
"node",
"is",
"valid",
"or",
"not",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/valid-v-model.js#L25-L39 |
34,364 | erha19/eslint-plugin-weex | lib/rules/vue/valid-v-model.js | getVariable | function getVariable (name, leafNode) {
let node = leafNode
while (node != null) {
const variables = node.variables
const variable = variables && variables.find(v => v.id.name === name)
if (variable != null) {
return variable
}
node = node.parent
}
return null
} | javascript | function getVariable (name, leafNode) {
let node = leafNode
while (node != null) {
const variables = node.variables
const variable = variables && variables.find(v => v.id.name === name)
if (variable != null) {
return variable
}
node = node.parent
}
return null
} | [
"function",
"getVariable",
"(",
"name",
",",
"leafNode",
")",
"{",
"let",
"node",
"=",
"leafNode",
"while",
"(",
"node",
"!=",
"null",
")",
"{",
"const",
"variables",
"=",
"node",
".",
"variables",
"const",
"variable",
"=",
"variables",
"&&",
"variables",
... | Get the variable by names.
@param {string} name The variable name to find.
@param {ASTNode} leafNode The node to look up.
@returns {Variable|null} The found variable or null. | [
"Get",
"the",
"variable",
"by",
"names",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/valid-v-model.js#L59-L74 |
34,365 | erha19/eslint-plugin-weex | lib/rules/vue/html-self-closing.js | parseOptions | function parseOptions (options) {
return {
[ELEMENT_TYPE.NORMAL]: (options && options.html && options.html.normal) || 'always',
[ELEMENT_TYPE.VOID]: (options && options.html && options.html.void) || 'never',
[ELEMENT_TYPE.COMPONENT]: (options && options.html && options.html.component) || 'always',
[ELEMENT_TYPE.SVG]: (options && options.svg) || 'always',
[ELEMENT_TYPE.MATH]: (options && options.math) || 'always'
}
} | javascript | function parseOptions (options) {
return {
[ELEMENT_TYPE.NORMAL]: (options && options.html && options.html.normal) || 'always',
[ELEMENT_TYPE.VOID]: (options && options.html && options.html.void) || 'never',
[ELEMENT_TYPE.COMPONENT]: (options && options.html && options.html.component) || 'always',
[ELEMENT_TYPE.SVG]: (options && options.svg) || 'always',
[ELEMENT_TYPE.MATH]: (options && options.math) || 'always'
}
} | [
"function",
"parseOptions",
"(",
"options",
")",
"{",
"return",
"{",
"[",
"ELEMENT_TYPE",
".",
"NORMAL",
"]",
":",
"(",
"options",
"&&",
"options",
".",
"html",
"&&",
"options",
".",
"html",
".",
"normal",
")",
"||",
"'always'",
",",
"[",
"ELEMENT_TYPE",... | Normalize the given options.
@param {Object|undefined} options The raw options object.
@returns {Object} Normalized options. | [
"Normalize",
"the",
"given",
"options",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/html-self-closing.js#L34-L42 |
34,366 | erha19/eslint-plugin-weex | lib/rules/vue/html-self-closing.js | getElementType | function getElementType (node) {
if (utils.isCustomComponent(node)) {
return ELEMENT_TYPE.COMPONENT
}
if (utils.isHtmlElementNode(node)) {
if (utils.isHtmlVoidElementName(node.name)) {
return ELEMENT_TYPE.VOID
}
return ELEMENT_TYPE.NORMAL
}
if (utils.isSvgElementNode(node)) {
return ELEMENT_TYPE.SVG
}
if (utils.isMathMLElementNode(node)) {
return ELEMENT_TYPE.MATH
}
return 'unknown elements'
} | javascript | function getElementType (node) {
if (utils.isCustomComponent(node)) {
return ELEMENT_TYPE.COMPONENT
}
if (utils.isHtmlElementNode(node)) {
if (utils.isHtmlVoidElementName(node.name)) {
return ELEMENT_TYPE.VOID
}
return ELEMENT_TYPE.NORMAL
}
if (utils.isSvgElementNode(node)) {
return ELEMENT_TYPE.SVG
}
if (utils.isMathMLElementNode(node)) {
return ELEMENT_TYPE.MATH
}
return 'unknown elements'
} | [
"function",
"getElementType",
"(",
"node",
")",
"{",
"if",
"(",
"utils",
".",
"isCustomComponent",
"(",
"node",
")",
")",
"{",
"return",
"ELEMENT_TYPE",
".",
"COMPONENT",
"}",
"if",
"(",
"utils",
".",
"isHtmlElementNode",
"(",
"node",
")",
")",
"{",
"if"... | Get the elementType of the given element.
@param {VElement} node The element node to get.
@returns {string} The elementType of the element. | [
"Get",
"the",
"elementType",
"of",
"the",
"given",
"element",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/html-self-closing.js#L49-L66 |
34,367 | erha19/eslint-plugin-weex | lib/rules/vue/html-self-closing.js | isEmpty | function isEmpty (node, sourceCode) {
const start = node.startTag.range[1]
const end = (node.endTag != null) ? node.endTag.range[0] : node.range[1]
return sourceCode.text.slice(start, end).trim() === ''
} | javascript | function isEmpty (node, sourceCode) {
const start = node.startTag.range[1]
const end = (node.endTag != null) ? node.endTag.range[0] : node.range[1]
return sourceCode.text.slice(start, end).trim() === ''
} | [
"function",
"isEmpty",
"(",
"node",
",",
"sourceCode",
")",
"{",
"const",
"start",
"=",
"node",
".",
"startTag",
".",
"range",
"[",
"1",
"]",
"const",
"end",
"=",
"(",
"node",
".",
"endTag",
"!=",
"null",
")",
"?",
"node",
".",
"endTag",
".",
"rang... | Check whether the given element is empty or not.
This ignores whitespaces, doesn't ignore comments.
@param {VElement} node The element node to check.
@param {SourceCode} sourceCode The source code object of the current context.
@returns {boolean} `true` if the element is empty. | [
"Check",
"whether",
"the",
"given",
"element",
"is",
"empty",
"or",
"not",
".",
"This",
"ignores",
"whitespaces",
"doesn",
"t",
"ignore",
"comments",
"."
] | 2f7db1812fe66a529c3dc68fd2d22e9e7962d51e | https://github.com/erha19/eslint-plugin-weex/blob/2f7db1812fe66a529c3dc68fd2d22e9e7962d51e/lib/rules/vue/html-self-closing.js#L75-L80 |
34,368 | yoshuawuyts/copy-template-dir | index.js | writeFile | function writeFile (outDir, vars, file) {
return function (done) {
const fileName = file.path
const inFile = file.fullPath
const parentDir = file.parentDir
const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars))
mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) {
if (err) return done(err)
const rs = fs.createReadStream(inFile)
const ts = maxstacheStream(vars)
const ws = fs.createWriteStream(outFile)
pump(rs, ts, ws, done)
})
}
} | javascript | function writeFile (outDir, vars, file) {
return function (done) {
const fileName = file.path
const inFile = file.fullPath
const parentDir = file.parentDir
const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars))
mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) {
if (err) return done(err)
const rs = fs.createReadStream(inFile)
const ts = maxstacheStream(vars)
const ws = fs.createWriteStream(outFile)
pump(rs, ts, ws, done)
})
}
} | [
"function",
"writeFile",
"(",
"outDir",
",",
"vars",
",",
"file",
")",
"{",
"return",
"function",
"(",
"done",
")",
"{",
"const",
"fileName",
"=",
"file",
".",
"path",
"const",
"inFile",
"=",
"file",
".",
"fullPath",
"const",
"parentDir",
"=",
"file",
... | write a file to a directory str -> stream | [
"write",
"a",
"file",
"to",
"a",
"directory",
"str",
"-",
">",
"stream"
] | 73ab57e979994a59f4f211c666cc5700b4e98699 | https://github.com/yoshuawuyts/copy-template-dir/blob/73ab57e979994a59f4f211c666cc5700b4e98699/index.js#L56-L73 |
34,369 | yoshuawuyts/copy-template-dir | index.js | removeUnderscore | function removeUnderscore (filepath) {
const parts = filepath.split(path.sep)
const filename = parts.pop().replace(/^_/, '')
return parts.concat([filename]).join(path.sep)
} | javascript | function removeUnderscore (filepath) {
const parts = filepath.split(path.sep)
const filename = parts.pop().replace(/^_/, '')
return parts.concat([filename]).join(path.sep)
} | [
"function",
"removeUnderscore",
"(",
"filepath",
")",
"{",
"const",
"parts",
"=",
"filepath",
".",
"split",
"(",
"path",
".",
"sep",
")",
"const",
"filename",
"=",
"parts",
".",
"pop",
"(",
")",
".",
"replace",
"(",
"/",
"^_",
"/",
",",
"''",
")",
... | remove a leading underscore str -> str | [
"remove",
"a",
"leading",
"underscore",
"str",
"-",
">",
"str"
] | 73ab57e979994a59f4f211c666cc5700b4e98699 | https://github.com/yoshuawuyts/copy-template-dir/blob/73ab57e979994a59f4f211c666cc5700b4e98699/index.js#L77-L81 |
34,370 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, fieldNames) {
return protocol.implodeMessage(requestId,
metadataMethods.GET_SCHEMA,
protocol.implodeDataArray(fieldNames));
} | javascript | function(requestId, fieldNames) {
return protocol.implodeMessage(requestId,
metadataMethods.GET_SCHEMA,
protocol.implodeDataArray(fieldNames));
} | [
"function",
"(",
"requestId",
",",
"fieldNames",
")",
"{",
"return",
"protocol",
".",
"implodeMessage",
"(",
"requestId",
",",
"metadataMethods",
".",
"GET_SCHEMA",
",",
"protocol",
".",
"implodeDataArray",
"(",
"fieldNames",
")",
")",
";",
"}"
] | Encodes a successful get schema reply.
@param {String} requestId the originating request id
@param {Array} fieldNames an array of field name strings
@return {String} the encoded message
@private | [
"Encodes",
"a",
"successful",
"get",
"schema",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L45-L49 | |
34,371 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, itemNames) {
return protocol.implodeMessage(requestId,
metadataMethods.GET_ITEMS,
protocol.implodeDataArray(itemNames));
} | javascript | function(requestId, itemNames) {
return protocol.implodeMessage(requestId,
metadataMethods.GET_ITEMS,
protocol.implodeDataArray(itemNames));
} | [
"function",
"(",
"requestId",
",",
"itemNames",
")",
"{",
"return",
"protocol",
".",
"implodeMessage",
"(",
"requestId",
",",
"metadataMethods",
".",
"GET_ITEMS",
",",
"protocol",
".",
"implodeDataArray",
"(",
"itemNames",
")",
")",
";",
"}"
] | Encodes a successful get items reply.
@param {String} requestId the originating request id
@param {Array} itemNames an array of item name strings
@return {String} the encoded message
@private | [
"Encodes",
"a",
"successful",
"get",
"items",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L58-L62 | |
34,372 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, itemData) {
var i, payload = [], item;
for (i = 0; i < itemData.length; i = i + 1) {
payload.push(types.INT);
payload.push(protocol.encodeInteger(itemData[i].distinctSnapLen));
payload.push(types.DOUBLE);
payload.push(protocol.encodeDouble(itemData[i].minSourceFreq));
payload.push(types.MODE);
payload.push(protocol.encodePubModes(itemData[i].allowedModes));
}
return protocol.implodeMessage(requestId, metadataMethods.GET_ITEM_DATA,
protocol.implodeArray(payload));
} | javascript | function(requestId, itemData) {
var i, payload = [], item;
for (i = 0; i < itemData.length; i = i + 1) {
payload.push(types.INT);
payload.push(protocol.encodeInteger(itemData[i].distinctSnapLen));
payload.push(types.DOUBLE);
payload.push(protocol.encodeDouble(itemData[i].minSourceFreq));
payload.push(types.MODE);
payload.push(protocol.encodePubModes(itemData[i].allowedModes));
}
return protocol.implodeMessage(requestId, metadataMethods.GET_ITEM_DATA,
protocol.implodeArray(payload));
} | [
"function",
"(",
"requestId",
",",
"itemData",
")",
"{",
"var",
"i",
",",
"payload",
"=",
"[",
"]",
",",
"item",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"itemData",
".",
"length",
";",
"i",
"=",
"i",
"+",
"1",
")",
"{",
"payload",
".",... | Encodes a successful get item data reply.
@param {String} requestId the originating request id
@param {Array} itemData an array of objects with the following structure:
{distinctSnapLen: INTEGER, minSourceFreq: DOUBLE,
allowedModes: {raw: BOOL, merge: BOOL, distinct: BOOL, command: BOOL}}
@return {String} the encoded message
@private | [
"Encodes",
"a",
"successful",
"get",
"item",
"data",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L73-L85 | |
34,373 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, userItemData) {
var i, payload = [], item;
for (i = 0; i < userItemData.length; i = i + 1) {
payload.push(types.INT);
payload.push(protocol.encodeInteger(userItemData[i].allowedBufferSize));
payload.push(types.DOUBLE);
payload.push(protocol.encodeDouble(userItemData[i].allowedMaxItemFreq));
payload.push(types.MODE);
payload.push(protocol.encodePubModes(userItemData[i].allowedModes));
}
return protocol.implodeMessage(requestId, metadataMethods.GET_USER_ITEM_DATA,
protocol.implodeArray(payload));
} | javascript | function(requestId, userItemData) {
var i, payload = [], item;
for (i = 0; i < userItemData.length; i = i + 1) {
payload.push(types.INT);
payload.push(protocol.encodeInteger(userItemData[i].allowedBufferSize));
payload.push(types.DOUBLE);
payload.push(protocol.encodeDouble(userItemData[i].allowedMaxItemFreq));
payload.push(types.MODE);
payload.push(protocol.encodePubModes(userItemData[i].allowedModes));
}
return protocol.implodeMessage(requestId, metadataMethods.GET_USER_ITEM_DATA,
protocol.implodeArray(payload));
} | [
"function",
"(",
"requestId",
",",
"userItemData",
")",
"{",
"var",
"i",
",",
"payload",
"=",
"[",
"]",
",",
"item",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"userItemData",
".",
"length",
";",
"i",
"=",
"i",
"+",
"1",
")",
"{",
"payload"... | Encodes a successful get user item data reply.
@param {String} requestId the originating request id
@param {Array} userItemData an array of objects with the following structure:
{allowedBufferSize: INTEGER, allowedMaxItemFreq: DOUBLE,
allowedModes: {raw: BOOL, merge: BOOL, distinct: BOOL, command: BOOL}}
@return {String} the encoded message
@private | [
"Encodes",
"a",
"successful",
"get",
"user",
"item",
"data",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L96-L108 | |
34,374 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, maxBandwidth, notifyTables) {
return protocol.implodeMessage(requestId, metadataMethods.NOTIFY_USER,
types.DOUBLE, protocol.encodeDouble(maxBandwidth),
types.BOOLEAN, protocol.encodeBoolean(notifyTables));
} | javascript | function(requestId, maxBandwidth, notifyTables) {
return protocol.implodeMessage(requestId, metadataMethods.NOTIFY_USER,
types.DOUBLE, protocol.encodeDouble(maxBandwidth),
types.BOOLEAN, protocol.encodeBoolean(notifyTables));
} | [
"function",
"(",
"requestId",
",",
"maxBandwidth",
",",
"notifyTables",
")",
"{",
"return",
"protocol",
".",
"implodeMessage",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_USER",
",",
"types",
".",
"DOUBLE",
",",
"protocol",
".",
"encodeDouble",
"(",
... | Encodes a successful notify user reply.
@param {String} requestId the originating request id
@param {Number} maxBandwidth the max bandwidth for the user
@param {Boolean} notifyTables if the user wants to be notified about tables
@return {String} the encoded message
@private | [
"Encodes",
"a",
"successful",
"notify",
"user",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L118-L122 | |
34,375 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_USER",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptio... | Encodes an unsuccessful notify user reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: access, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"notify",
"user",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L293-L295 | |
34,376 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER_AUTH, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER_AUTH, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_USER_AUTH",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exc... | Encodes an unsuccessful notify user with SSL reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: access, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"notify",
"user",
"with",
"SSL",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L306-L308 | |
34,377 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER_MESSAGE, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_USER_MESSAGE, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_USER_MESSAGE",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"... | Encodes an unsuccessful notify user message reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"notify",
"user",
"message",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L319-L321 | |
34,378 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_NEW_SESSION, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_NEW_SESSION, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_NEW_SESSION",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"e... | Encodes an unsuccessful notify new session reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits, conflictingSession
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"notify",
"new",
"session",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L332-L334 | |
34,379 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_NEW_TABLES, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_NEW_TABLES, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_NEW_TABLES",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"ex... | Encodes an unsuccessful notify new tables reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"notify",
"new",
"tables",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L357-L359 | |
34,380 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_DEVICE_ACCESS, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_DEVICE_ACCESS, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_MPN_DEVICE_ACCESS",
",",
"exceptionMessage",
",",
"exceptionType",
","... | Encodes an unsuccessful MPN device access reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"MPN",
"device",
"access",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L382-L384 | |
34,381 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_SUBSCRIPTION_ACTIVATION, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_SUBSCRIPTION_ACTIVATION, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_MPN_SUBSCRIPTION_ACTIVATION",
",",
"exceptionMessage",
",",
"exceptionTy... | Encodes an unsuccessful MPN subscription activation reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"MPN",
"subscription",
"activation",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L395-L397 | |
34,382 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_DEVICE_TOKEN_CHANGE, exceptionMessage, exceptionType, exceptionData);
} | javascript | function(requestId, exceptionMessage, exceptionType, exceptionData) {
return writeExtendedException(requestId, metadataMethods.NOTIFY_MPN_DEVICE_TOKEN_CHANGE, exceptionMessage, exceptionType, exceptionData);
} | [
"function",
"(",
"requestId",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"return",
"writeExtendedException",
"(",
"requestId",
",",
"metadataMethods",
".",
"NOTIFY_MPN_DEVICE_TOKEN_CHANGE",
",",
"exceptionMessage",
",",
"exceptionType",... | Encodes an unsuccessful MPN device token change reply.
@param {String} requestId the originating request id
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: notification, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"MPN",
"device",
"token",
"change",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L408-L410 | |
34,383 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | writeDefaultException | function writeDefaultException(requestId, requestType, exceptionMessage) {
return protocol.implodeMessage(requestId, requestType,
exceptions.GENERIC,
protocol.encodeString(exceptionMessage));
} | javascript | function writeDefaultException(requestId, requestType, exceptionMessage) {
return protocol.implodeMessage(requestId, requestType,
exceptions.GENERIC,
protocol.encodeString(exceptionMessage));
} | [
"function",
"writeDefaultException",
"(",
"requestId",
",",
"requestType",
",",
"exceptionMessage",
")",
"{",
"return",
"protocol",
".",
"implodeMessage",
"(",
"requestId",
",",
"requestType",
",",
"exceptions",
".",
"GENERIC",
",",
"protocol",
".",
"encodeString",
... | Encodes an unsuccessful reply of an unspecified type.
@param {String} requestId the originating request id
@param {String} requestType the originating request method name
@param {String} exceptionMessage the exception message
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"reply",
"of",
"an",
"unspecified",
"type",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L422-L426 |
34,384 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | writeSimpleException | function writeSimpleException(requestId, requestType, exceptionMessage, exceptionType) {
return protocol.implodeMessage(requestId, requestType,
protocol.encodeMetadataException(exceptionType),
protocol.encodeString(exceptionMessage));
} | javascript | function writeSimpleException(requestId, requestType, exceptionMessage, exceptionType) {
return protocol.implodeMessage(requestId, requestType,
protocol.encodeMetadataException(exceptionType),
protocol.encodeString(exceptionMessage));
} | [
"function",
"writeSimpleException",
"(",
"requestId",
",",
"requestType",
",",
"exceptionMessage",
",",
"exceptionType",
")",
"{",
"return",
"protocol",
".",
"implodeMessage",
"(",
"requestId",
",",
"requestType",
",",
"protocol",
".",
"encodeMetadataException",
"(",
... | Encodes an unsuccessful reply.
@param {String} requestId the originating request id
@param {String} requestType the originating request method name
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: access, credits
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"reply",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L438-L442 |
34,385 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | writeExtendedException | function writeExtendedException(requestId, requestType, exceptionMessage, exceptionType, exceptionData) {
var encodedExc = protocol.encodeMetadataException(exceptionType);
if (encodedExc == exceptions.CREDITS) {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage),
protocol.encodeString(exceptionData.clientCode),
protocol.encodeString(exceptionData.clientMessage));
} else if (encodedExc === exceptions.CONFLICTING_SESSION) {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage),
protocol.encodeString(exceptionData.clientCode),
protocol.encodeString(exceptionData.clientMessage),
protocol.encodeString(exceptionData.conflictingSessionId));
} else {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage));
}
} | javascript | function writeExtendedException(requestId, requestType, exceptionMessage, exceptionType, exceptionData) {
var encodedExc = protocol.encodeMetadataException(exceptionType);
if (encodedExc == exceptions.CREDITS) {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage),
protocol.encodeString(exceptionData.clientCode),
protocol.encodeString(exceptionData.clientMessage));
} else if (encodedExc === exceptions.CONFLICTING_SESSION) {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage),
protocol.encodeString(exceptionData.clientCode),
protocol.encodeString(exceptionData.clientMessage),
protocol.encodeString(exceptionData.conflictingSessionId));
} else {
return protocol.implodeMessage(requestId, requestType, encodedExc,
protocol.encodeString(exceptionMessage));
}
} | [
"function",
"writeExtendedException",
"(",
"requestId",
",",
"requestType",
",",
"exceptionMessage",
",",
"exceptionType",
",",
"exceptionData",
")",
"{",
"var",
"encodedExc",
"=",
"protocol",
".",
"encodeMetadataException",
"(",
"exceptionType",
")",
";",
"if",
"("... | Encodes an unsuccessful reply that may involve an exception with parameters.
@param {String} requestId the originating request id
@param {String} requestType the originating request method name
@param {String} exceptionMessage the exception message
@param {String} [exceptionType] the exception type. Allowed values: access, credits
@param {Object} [exceptionData] extra information which depends on the exception type
@return {String} the encoded message
@private | [
"Encodes",
"an",
"unsuccessful",
"reply",
"that",
"may",
"involve",
"an",
"exception",
"with",
"parameters",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L455-L472 |
34,386 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readInit | function readInit(message, tokens) {
var i;
message.parameters = {};
for (i = 0; i < tokens.length; i = i + 4) {
message.parameters[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | javascript | function readInit(message, tokens) {
var i;
message.parameters = {};
for (i = 0; i < tokens.length; i = i + 4) {
message.parameters[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | [
"function",
"readInit",
"(",
"message",
",",
"tokens",
")",
"{",
"var",
"i",
";",
"message",
".",
"parameters",
"=",
"{",
"}",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"=",
"i",
"+",
"4",
")",
"{",
"me... | Decode a init request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"init",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L560-L566 |
34,387 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readGetSchema | function readGetSchema(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.groupName = protocol.decodeString(tokens[3]);
message.schemaName = protocol.decodeString(tokens[5]);
message.sessionId = protocol.decodeString(tokens[7]);
} | javascript | function readGetSchema(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.groupName = protocol.decodeString(tokens[3]);
message.schemaName = protocol.decodeString(tokens[5]);
message.sessionId = protocol.decodeString(tokens[7]);
} | [
"function",
"readGetSchema",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"groupName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens"... | Decode an get schema request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"an",
"get",
"schema",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L576-L581 |
34,388 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readGetItemData | function readGetItemData(message, tokens) {
message.itemNames = [];
for (var i = 0; i < tokens.length; i = i + 2) {
message.itemNames.push(protocol.decodeString(tokens[i + 1]));
}
} | javascript | function readGetItemData(message, tokens) {
message.itemNames = [];
for (var i = 0; i < tokens.length; i = i + 2) {
message.itemNames.push(protocol.decodeString(tokens[i + 1]));
}
} | [
"function",
"readGetItemData",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"itemNames",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"=",
"i",
"+",
"2",
")",
"{",
"message",
... | Decode a get item data request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"get",
"item",
"data",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L615-L620 |
34,389 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyUser | function readNotifyUser(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.userPassword = protocol.decodeString(tokens[3]);
readNotifyUserHeaders(message, tokens.slice(4));
} | javascript | function readNotifyUser(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.userPassword = protocol.decodeString(tokens[3]);
readNotifyUserHeaders(message, tokens.slice(4));
} | [
"function",
"readNotifyUser",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"userPassword",
"=",
"protocol",
".",
"decodeString",
"(",
"tok... | Decode a notify user request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"user",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L629-L633 |
34,390 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyUserAuth | function readNotifyUserAuth(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.userPassword = protocol.decodeString(tokens[3]);
message.clientPrincipal = protocol.decodeString(tokens[5]);
readNotifyUserHeaders(message, tokens.slice(6));
} | javascript | function readNotifyUserAuth(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.userPassword = protocol.decodeString(tokens[3]);
message.clientPrincipal = protocol.decodeString(tokens[5]);
readNotifyUserHeaders(message, tokens.slice(6));
} | [
"function",
"readNotifyUserAuth",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"userPassword",
"=",
"protocol",
".",
"decodeString",
"(",
... | Decode a notify user request with SSL auth.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"user",
"request",
"with",
"SSL",
"auth",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L643-L648 |
34,391 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyUserHeaders | function readNotifyUserHeaders(message, tokens) {
var i;
message.headers = {};
for (i = 0; i < tokens.length; i = i + 4) {
message.headers[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | javascript | function readNotifyUserHeaders(message, tokens) {
var i;
message.headers = {};
for (i = 0; i < tokens.length; i = i + 4) {
message.headers[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | [
"function",
"readNotifyUserHeaders",
"(",
"message",
",",
"tokens",
")",
"{",
"var",
"i",
";",
"message",
".",
"headers",
"=",
"{",
"}",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"=",
"i",
"+",
"4",
")",
... | Decode the headers of a notify user request.
@param {Object} message the message object partially initialized
@param {Array} tokens the rest of the headers part of the message already tokenized
@private | [
"Decode",
"the",
"headers",
"of",
"a",
"notify",
"user",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L657-L663 |
34,392 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyUserMessage | function readNotifyUserMessage(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.userMessage = protocol.decodeString(tokens[5]);
} | javascript | function readNotifyUserMessage(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.userMessage = protocol.decodeString(tokens[5]);
} | [
"function",
"readNotifyUserMessage",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeString",
"(",
... | Decode a notify user message request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"user",
"message",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L672-L676 |
34,393 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyNewSession | function readNotifyNewSession(message, tokens) {
var i;
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.contextProperties = {};
tokens = tokens.slice(4);
for (i = 0; i < tokens.length; i = i + 4) {
message.contextProperties[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | javascript | function readNotifyNewSession(message, tokens) {
var i;
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.contextProperties = {};
tokens = tokens.slice(4);
for (i = 0; i < tokens.length; i = i + 4) {
message.contextProperties[protocol.decodeString(tokens[i + 1])] = protocol.decodeString(tokens[i + 3]);
}
} | [
"function",
"readNotifyNewSession",
"(",
"message",
",",
"tokens",
")",
"{",
"var",
"i",
";",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"de... | Decode a notify new session request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"new",
"session",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L685-L694 |
34,394 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyNewTables | function readNotifyNewTables(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
readTableInfos(message, tokens.slice(4));
} | javascript | function readNotifyNewTables(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
readTableInfos(message, tokens.slice(4));
} | [
"function",
"readNotifyNewTables",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeString",
"(",
"t... | Decode a notify new tables request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"new",
"tables",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L714-L718 |
34,395 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyTablesClose | function readNotifyTablesClose(message, tokens) {
message.sessionId = protocol.decodeString(tokens[1]);
readTableInfos(message, tokens.slice(2));
} | javascript | function readNotifyTablesClose(message, tokens) {
message.sessionId = protocol.decodeString(tokens[1]);
readTableInfos(message, tokens.slice(2));
} | [
"function",
"readNotifyTablesClose",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"readTableInfos",
"(",
"message",
",",
"tokens",
".",
"slice",
"(",
"2"... | Decode a notify tables close request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"tables",
"close",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L727-L730 |
34,396 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyMpnDeviceAccess | function readNotifyMpnDeviceAccess(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.device = {};
message.device.mpnPlatformType = protocol.decodeString(tokens[5]);
message.device.applicationId = protocol.decodeString(tokens[7]);
message.device.deviceToken = protocol.decodeString(tokens[9]);
} | javascript | function readNotifyMpnDeviceAccess(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.device = {};
message.device.mpnPlatformType = protocol.decodeString(tokens[5]);
message.device.applicationId = protocol.decodeString(tokens[7]);
message.device.deviceToken = protocol.decodeString(tokens[9]);
} | [
"function",
"readNotifyMpnDeviceAccess",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeString",
"("... | Decode a notify MPN device access request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"MPN",
"device",
"access",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L739-L746 |
34,397 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyMpnSubscriptionActivation | function readNotifyMpnSubscriptionActivation(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.tableInfo = readTableInfo(tokens.slice(4), true);
var base = 16;
message.mpnSubscription = {};
message.mpnSubscription.device = {};
message.mpnSubscription.device.mpnPlatformType = protocol.decodeString(tokens[base + 1]);
message.mpnSubscription.device.applicationId = protocol.decodeString(tokens[base + 3]);
message.mpnSubscription.device.deviceToken = protocol.decodeString(tokens[base + 5]);
message.mpnSubscription.trigger = protocol.decodeString(tokens[base + 7]);
message.mpnSubscription.notificationFormat = protocol.decodeString(tokens[base + 9]);
} | javascript | function readNotifyMpnSubscriptionActivation(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.tableInfo = readTableInfo(tokens.slice(4), true);
var base = 16;
message.mpnSubscription = {};
message.mpnSubscription.device = {};
message.mpnSubscription.device.mpnPlatformType = protocol.decodeString(tokens[base + 1]);
message.mpnSubscription.device.applicationId = protocol.decodeString(tokens[base + 3]);
message.mpnSubscription.device.deviceToken = protocol.decodeString(tokens[base + 5]);
message.mpnSubscription.trigger = protocol.decodeString(tokens[base + 7]);
message.mpnSubscription.notificationFormat = protocol.decodeString(tokens[base + 9]);
} | [
"function",
"readNotifyMpnSubscriptionActivation",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeStri... | Decode a notify MPN subscription activation request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"MPN",
"subscription",
"activation",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L755-L769 |
34,398 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readNotifyMpnDeviceTokenChange | function readNotifyMpnDeviceTokenChange(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.device = {};
message.device.mpnPlatformType = protocol.decodeString(tokens[5]);
message.device.applicationId = protocol.decodeString(tokens[7]);
message.device.deviceToken = protocol.decodeString(tokens[9]);
message.newDeviceToken = protocol.decodeString(tokens[11]);
} | javascript | function readNotifyMpnDeviceTokenChange(message, tokens) {
message.userName = protocol.decodeString(tokens[1]);
message.sessionId = protocol.decodeString(tokens[3]);
message.device = {};
message.device.mpnPlatformType = protocol.decodeString(tokens[5]);
message.device.applicationId = protocol.decodeString(tokens[7]);
message.device.deviceToken = protocol.decodeString(tokens[9]);
message.newDeviceToken = protocol.decodeString(tokens[11]);
} | [
"function",
"readNotifyMpnDeviceTokenChange",
"(",
"message",
",",
"tokens",
")",
"{",
"message",
".",
"userName",
"=",
"protocol",
".",
"decodeString",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"message",
".",
"sessionId",
"=",
"protocol",
".",
"decodeString",
... | Decode a notify MPN device token change request.
@param {Object} message the message object partially initialized with the id and the verb
@param {Array} tokens the rest of the message already tokenized
@private | [
"Decode",
"a",
"notify",
"MPN",
"device",
"token",
"change",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L778-L786 |
34,399 | Lightstreamer/Lightstreamer-lib-node-adapter | lib/metadataprotocol.js | readTableInfos | function readTableInfos(message, tokens) {
var tableInfo, i;
message.tableInfos = [];
while (tokens.length >= 14) {
tableInfo = readTableInfo(tokens);
message.tableInfos.push(tableInfo);
tokens = tokens.slice(14);
}
} | javascript | function readTableInfos(message, tokens) {
var tableInfo, i;
message.tableInfos = [];
while (tokens.length >= 14) {
tableInfo = readTableInfo(tokens);
message.tableInfos.push(tableInfo);
tokens = tokens.slice(14);
}
} | [
"function",
"readTableInfos",
"(",
"message",
",",
"tokens",
")",
"{",
"var",
"tableInfo",
",",
"i",
";",
"message",
".",
"tableInfos",
"=",
"[",
"]",
";",
"while",
"(",
"tokens",
".",
"length",
">=",
"14",
")",
"{",
"tableInfo",
"=",
"readTableInfo",
... | Decode the tables info part of a notify tables request.
@param {Object} message the message object partially initialized
@param {Array} tokens the table infos part of the message already tokenized
@private | [
"Decode",
"the",
"tables",
"info",
"part",
"of",
"a",
"notify",
"tables",
"request",
"."
] | 5fa5dbf983e169b7b0204eaa360c0d1c446d9b00 | https://github.com/Lightstreamer/Lightstreamer-lib-node-adapter/blob/5fa5dbf983e169b7b0204eaa360c0d1c446d9b00/lib/metadataprotocol.js#L795-L803 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.