_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31500 | train | function (data) {
var validData = _.deepMapValues(this.config, function (value, propertyPath) {
return _.deepGet(data, propertyPath.join('.'));
});
_.merge(this.config, validData);
} | javascript | {
"resource": ""
} | |
q31501 | train | function () {
var self = this;
$http.get(settingsApi)
.success(function (data) {
self.set(data);
$timeout(function () {
self.loaded = true;
});
})
.error(function () {
self.reset();
$timeout(function ... | javascript | {
"resource": ""
} | |
q31502 | train | function () {
var searchField = this.config.searchField;
return searchField &&
Object.keys(searchField).every(function (key) {
return searchField[key] === false;
});
} | javascript | {
"resource": ""
} | |
q31503 | train | function (module) {
if (module === SDK_PACKAGE_NAME) {
var packageFile = path.join(__dirname, '..', 'package.json')
if (fs.existsSync(packageFile)) {
var packageInfo = JSON.parse(fs.readFileSync(packageFile))
if (packageInfo.name === SDK_PACKAGE_NAME) {
// Use local library sou... | javascript | {
"resource": ""
} | |
q31504 | train | function (params) {
var self = this;
this.parseParams(params);
if (!this.loaded) {
this.fetchApi(api).success(function (data) {
packages = data;
self.loaded = true;
self.search();
});
}
else {
this.search();
... | javascript | {
"resource": ""
} | |
q31505 | train | function (params) {
this.query = params.q !== undefined ? String(params.q) : defaultParams.query;
this.page = params.p !== undefined ? parseInt(params.p, 10) : defaultParams.page;
switch (params.s) {
case 'name':
case 'owner':
case 'stars':
case 'updated':... | javascript | {
"resource": ""
} | |
q31506 | train | function (url) {
var self = this;
this.searching = true;
this.loadingError = false;
return $http.get(url)
.success(function (res) {
self.searching = false;
return res.data;
})
.error(function () {
self.searching = false;
... | javascript | {
"resource": ""
} | |
q31507 | train | function (items) {
if (!config.ignoreDeprecatedPackages) {
return items;
}
var list = _.filter(items, function (item) {
// Ignore packages
if (ignore.indexOf(item.name) !== -1) {
return false;
}
// Limit to whitelisted packages
... | javascript | {
"resource": ""
} | |
q31508 | train | function (items, query, fields, exact) {
var self = this;
var isTarget = function (fieldName) {
return fields.indexOf(fieldName) !== -1;
};
if (query === '') {
return items;
}
fields = fields || ['name', 'owner', 'description', 'keyword'];
retu... | javascript | {
"resource": ""
} | |
q31509 | train | function (query, string, exact) {
if (typeof string !== 'string' || string === '') {
return false;
}
if (exact) {
return string.toLowerCase() === query.toLowerCase();
}
return string.toLowerCase().indexOf(query.toLowerCase()) !== -1;
} | javascript | {
"resource": ""
} | |
q31510 | train | function (query, array, exact) {
if (!_.isArray(array) || array.length === 0) {
return false;
}
return array.some(function (string) {
if (exact) {
return query.toLowerCase() === string.toLowerCase();
}
return string.toLowerCase().indexOf(query.... | javascript | {
"resource": ""
} | |
q31511 | train | function (items, query) {
if (!config.exactMatch || !config.searchField.name) {
return items;
}
var list = items;
var match = _.findIndex(list, function (item) {
return query.toLowerCase() === item.name.toLowerCase();
});
if (match !== -1) {
... | javascript | {
"resource": ""
} | |
q31512 | processMessage | train | function processMessage(message) {
var recipients = Object.keys(message.recipient_status).filter(function(userId) {
return hook.receipts.reportForStatus.indexOf(message.recipient_status[userId]) !== -1;
});
if (recipients.length) {
var identities = [message.sender.user_id].concat(reci... | javascript | {
"resource": ""
} |
q31513 | train | function() {
var args = Array.prototype.slice.call(arguments, 0),
org = args.shift();
return kwargs.apply(org, args);
} | javascript | {
"resource": ""
} | |
q31514 | DocsRouter | train | function DocsRouter(docs, options) {
debug('create docs router');
options = options || {};
this.docs = docs;
this.prefix = options.prefix || '/';
} | javascript | {
"resource": ""
} |
q31515 | train | function(path, handler) {
var node = trie.define(path)[0];
if (typeof handler !== 'function') {
throw new Error('invalid handler');
}
node.handler = handler;
} | javascript | {
"resource": ""
} | |
q31516 | verifyWebhook | train | function verifyWebhook(hookDef, webhook) {
logger(hookDef.name + ': Webhook already registered: ' + webhook.id + ': ' + webhook.status);
if (webhook.status !== 'active') {
logger(hookDef.name + ': Enabling webhook');
webhooksClient.enable(webhook.id);
}
} | javascript | {
"resource": ""
} |
q31517 | createRequest | train | function createRequest(url, req, { method, query } = {}) {
const request = {
url,
method: method || 'GET',
query: query || {},
};
return new Proxy(req, {
set: (target, name, value, receiver) => {
request[name] = value;
return true;
},
get: (target, name) => {
if (name in... | javascript | {
"resource": ""
} |
q31518 | addSubscription | train | function addSubscription (client, topic, messageType,
callback, subscribeToTopic) {
if (typeof (subscribeToTopic) === 'undefined') { subscribeToTopic = true }
if (callback !== explicitSubscriptionCallback) {
client._callbackManager.addCallback(messageType, topic, callback)
}
if (... | javascript | {
"resource": ""
} |
q31519 | removeSubscription | train | function removeSubscription (client, topic, messageType, callback) {
if (callback !== explicitSubscriptionCallback) {
client._callbackManager.removeCallback(messageType, topic, callback)
}
if (topic) {
var subscriptionsByMessageType = client._subscriptionsByMessageType
var topicMessageTypes = subscri... | javascript | {
"resource": ""
} |
q31520 | publish | train | function publish (client, topic, message) {
if (client._mqttClient) {
client._mqttClient.publish(topic, message)
} else {
throw new DxlError(
'Client not connected, unable to publish data to: ' + topic)
}
} | javascript | {
"resource": ""
} |
q31521 | compile | train | function compile(str, scope) {
if (!/[\(\){}]/.exec(str)) return literal(str);
var nodes = compile2(compile1(str), scope || {});
if (nodes.length === 0) return literal('');
return foldLiterals(nodes)
.reduce(function(c, e) {return binaryExpression('+', c, e)});
} | javascript | {
"resource": ""
} |
q31522 | foldLiterals | train | function foldLiterals(nodes) {
return nodes.reduce(function(c, e) {
if (e.type === 'Literal') {
var last = c[c.length - 1];
if (last && last.type === 'Literal') {
c.pop();
return c.concat(literal(last.value + e.value));
}
}
return c.concat(e);
}, [])
} | javascript | {
"resource": ""
} |
q31523 | compile1 | train | function compile1(str) {
if (!/[{}]/.exec(str)) return [literal(str)];
var depth = 0;
var nodes = [];
var m;
var buffer = '';
while ((m = /[{}]/.exec(str)) && str.length > 0) {
var chunk = str.substring(0, m.index);
switch (m[0]) {
case '{':
depth += 1;
if (depth === 1) {
... | javascript | {
"resource": ""
} |
q31524 | compile2 | train | function compile2(nodes, scope) {
var toks = flatMap(nodes, function(expr) {
return expr.type === 'Literal' ? tokenize2(expr.value) : expr;
});
return parse2(toks, scope);
} | javascript | {
"resource": ""
} |
q31525 | Framework | train | function Framework(spec, options) {
if (!(this instanceof Framework)) {
return new Framework(spec, options);
}
debug('create framework', spec, options);
spec = lodash.cloneDeep(spec || {});
options = lodash.cloneDeep(options || {});
spec = lodash.defaults(spec, {
swaggerVersion: '1.2',
apis: ... | javascript | {
"resource": ""
} |
q31526 | fieldAsOption | train | function fieldAsOption (field) {
var option = ''
for (var i = 0; i < field.length; i++) {
var c = field.charAt(i)
if (c < 'a') {
option = option + '-' + c.toLowerCase()
} else {
option += c
}
}
return option
} | javascript | {
"resource": ""
} |
q31527 | train | function (command) {
command.option('--opensslbin <file>',
'Location of the OpenSSL executable that the command uses. If not ' +
'specified, the command attempts to find an OpenSSL executable in ' +
'the current environment path.')
command.option('-s, --san [value]',
'add Subject Alterna... | javascript | {
"resource": ""
} | |
q31528 | train | function (command, responseCallback) {
if (command.passphrase === true) {
cliUtil.getValueFromPrompt('private key passphrase', true,
function (error, passphrase) {
if (error) {
provisionUtil.invokeCallback(error, responseCallback,
command.verbosity)
} else... | javascript | {
"resource": ""
} | |
q31529 | CFW_transitionCssDuration | train | function CFW_transitionCssDuration($node) {
var durationArray = [0]; // Set a min value -- otherwise get `Infinity`
$node.each(function() {
var durations = $node.css('transition-duration') || $node.css('-webkit-transition-duration') || $node.css('-moz-transition-duration') || $node.css('-ms-... | javascript | {
"resource": ""
} |
q31530 | nameTasks | train | function nameTasks(tasks) { //name tasks that are not already named, validation done elsewhere, ret map
var namesMap = tasks.reduce(function (map, t) {
if (t.name) { map[t.name] = t; }
return map;
}, {});
tasks.forEach(function (t, idx) {
if (!t.name) { //not already named
var name... | javascript | {
"resource": ""
} |
q31531 | validate | train | function validate(ast) {
if (!ast || !ast.inParams || !ast.tasks || !ast.outTask) return [AST_IS_OBJECT];
var errors = [];
errors = errors.concat(validateInParams(ast.inParams));
errors = errors.concat(validateTasks(ast.tasks));
errors = errors.concat(validateTaskNamesUnique(ast.tasks));
errors ... | javascript | {
"resource": ""
} |
q31532 | validateNoMissingNames | train | function validateNoMissingNames(ast) {
var errors = [];
var names = {};
if (ast.locals) {
names = Object.keys(ast.locals).reduce(function (accum, k) { // start with locals
accum[k] = true;
return accum;
}, names);
}
ast.inParams.reduce(function (accum, p) { // add input ... | javascript | {
"resource": ""
} |
q31533 | filterOutTrailingCbParam | train | function filterOutTrailingCbParam(args) { // if has trailing cb | callback param, filter it out
if (args.length && args[args.length - 1].match(CB_NAMES_RE)) args.pop();
return args;
} | javascript | {
"resource": ""
} |
q31534 | CommonJsProject | train | function CommonJsProject(opts) {
this.roots = opts.roots;
this.textPluginPattern = opts.textPluginPattern || /^text!/;
opts.roots = this.roots.map(function(root) {
if (!copy.isDirectory(root)) {
throw new Error('Each commonjs root should be a directory: ' + root);
}
return ensureTrailingSlash(r... | javascript | {
"resource": ""
} |
q31535 | model | train | function model(obj) {
if (!obj) return;
if (obj.$ref) {
obj = obj.$ref;
} else if (obj.type === 'array' && obj.items && obj.items.$ref) {
obj = obj.items.$ref;
} else if (obj.type) {
obj = obj.type;
}
// ensure valid type
if (typeof obj !== 'string') return;
// ensure non-builtin type
if... | javascript | {
"resource": ""
} |
q31536 | models | train | function models(spec) {
var ids = {};
if (!spec) return ids;
var add = function(obj) {
var type = model(obj);
if (type) ids[type] = true;
};
add(spec);
if (spec.properties) {
lodash.forOwn(spec.properties, function(p) { add(p); });
} else if (spec.parameters) {
spec.parameters.forEach(... | javascript | {
"resource": ""
} |
q31537 | getDescription | train | function getDescription(conversation) {
if (conversation.metadata.conversationersationName) {
return 'The Conversation ' + conversation.metadata.conversationersationName + ' has been deleted';
} else {
return 'The Conversation with ' +
conversation.participants.join(', ').replace(/(.*),(.*)/... | javascript | {
"resource": ""
} |
q31538 | cliGenerateCsr | train | function cliGenerateCsr (configDir, commonOrCsrFileName, command) {
cliPki.processPrivateKeyPassphrase(command,
function (error) {
if (error) {
provisionUtil.invokeCallback(error, command.doneCallback,
command.verbosity)
} else {
pki.generatePrivateKeyAndCsr(configDir, common... | javascript | {
"resource": ""
} |
q31539 | train | function(win) {
win = win || window;
this.lastFocus = new Date().getTime();
this._isFocused = true;
var _self = this;
// IE < 9 supports focusin and focusout events
if ("onfocusin" in win.document) {
event.addListener(win.document, "focusin", function(e) {
_self._s... | javascript | {
"resource": ""
} | |
q31540 | train | function(session) {
this.session = session;
this.doc = session.getDocument();
this.clearSelection();
this.selectionLead = this.doc.createAnchor(0, 0);
this.selectionAnchor = this.doc.createAnchor(0, 0);
var _self = this;
this.selectionLead.on("change", function(e) {
_self._emit("ch... | javascript | {
"resource": ""
} | |
q31541 | train | function(data, hashId, key, keyCode, e) {
// If we pressed any command key but no other key, then ignore the input.
// Otherwise "shift-" is added to the buffer, and later on "shift-g"
// which results in "shift-shift-g" which doesn't make sense.
if (hashId != 0 && (key == "" || key == S... | javascript | {
"resource": ""
} | |
q31542 | findInsertLocation | train | function findInsertLocation(matches, score) {
const idx = binarySearch(matches, 0, matches.length, score);
if(idx < 0) {
// If the score was not found
return - idx - 1;
}
/*
* Something with the same score was found, make sure this item is
* added after all previous items with the same score.
*/
for(le... | javascript | {
"resource": ""
} |
q31543 | handleValidation | train | function handleValidation(req, res, next) {
var payload = JSON.stringify(req.body);
var nodeVersion = Number(process.version.replace(/^v/, '').split(/\./)[0]);
var utf8safe = nodeVersion >= 6 ? payload : unescape(encodeURIComponent(payload));
var hash = crypto.createHmac('sha1', secret).update(... | javascript | {
"resource": ""
} |
q31544 | train | function(node) {
var $activeTab = $(node);
var data = $($activeTab).data('cfw.tab');
if (data) {
var $activePane = data.$target;
var $paneContainer = $activePane.closest('.tab-content');
$paneContainer.find('[data-cfw="collapse"]').each... | javascript | {
"resource": ""
} | |
q31545 | train | function(node) {
var $activeCollapse = $(node);
var $paneParent = $activeCollapse.closest('.tab-pane');
var $paneID = $paneParent.attr('id');
var $paneContainer = $activeCollapse.closest('.tab-content');
$paneContainer.find('[data-cfw="collapse"]').each(funct... | javascript | {
"resource": ""
} | |
q31546 | resolveInitialData | train | function resolveInitialData(branches, extra) {
const errors = {};
const { promises, keys } = branches.reduce(
({ promises, keys }, b) => {
const getInitialData = (b.route ? b.route.component : b.component || b)
.getInitialData;
if (getInitialData) {
const { promise, key } = getIniti... | javascript | {
"resource": ""
} |
q31547 | cliUpdateConfig | train | function cliUpdateConfig (configDir, hostname, command) {
cliUtil.fillEmptyServerCredentialsFromPrompt(command,
function (error) {
if (error) {
provisionUtil.invokeCallback(error, command.doneCallback,
command.verbosity)
} else {
updateConfig(configDir,
cliUtil.pull... | javascript | {
"resource": ""
} |
q31548 | FrameworkRouter | train | function FrameworkRouter(framework) {
debug('create framework router');
this.framework = framework;
this.encoder = lodash.clone(http.encoder);
this.decoder = lodash.clone(http.decoder);
} | javascript | {
"resource": ""
} |
q31549 | train | function (message, component, header) {
if (typeof header === 'undefined') {
header = ''
}
if (component) {
if (header) {
header += ' '
}
header += '('
header += component
header += ')'
}
if (header) {
message = header + ': ' + message
}
retu... | javascript | {
"resource": ""
} | |
q31550 | train | function (error, options) {
options = options || {}
var verbosity = options.verbosity || 0
var message = module.exports.getErrorMessage(
typeof error === 'object' ? error.message : error, options.component,
options.header)
if (typeof header === 'undefined') {
message = 'ERROR: ' + mess... | javascript | {
"resource": ""
} | |
q31551 | train | function (file, data) {
module.exports.mkdirRecursive(path.dirname(file))
fs.writeFileSync(file, data, {mode: _0644})
} | javascript | {
"resource": ""
} | |
q31552 | train | function (error, callback, verbosity) {
if (callback) {
callback(error)
} else {
module.exports.logError(error, {verbosity: verbosity})
}
} | javascript | {
"resource": ""
} | |
q31553 | Firewall | train | function Firewall(name, path, authenticationHandler, successHandler, failureHandler) {
this.name = name;
this.path = utils.ensureRegexp(path);
this.rules = [];
// configure handlers
this.authenticationHandler = authenticationHandler || function (req, res, next) {
res.status(40... | javascript | {
"resource": ""
} |
q31554 | exists | train | function exists (path, callback) {
Fs.stat(path, function (err) {
callback(checkErr(err));
});
} | javascript | {
"resource": ""
} |
q31555 | existsSync | train | function existsSync(path) {
if ( path === null || path === undefined )
return false;
try {
Fs.statSync(path);
return true;
} catch (err) {
return checkErr(err);
}
} | javascript | {
"resource": ""
} |
q31556 | cleanup | train | function cleanup(err, compacted, activeCtx, options) {
if(err) {
return callback(err);
}
if(options.compactArrays && !options.graph && _isArray(compacted)) {
// simplify to a single item
if(compacted.length === 1) {
compacted = compacted[0];
}
// simplify to an empty o... | javascript | {
"resource": ""
} |
q31557 | createDocumentLoader | train | function createDocumentLoader(promise) {
return function(url, callback) {
promise(url).then(
// success
function(remoteDocument) {
callback(null, remoteDocument);
},
// failure
callback
);
};
} | javascript | {
"resource": ""
} |
q31558 | train | function(msg, type, details) {
if(_nodejs) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
}
this.name = type || 'jsonld.Error';
this.message = msg || 'An unspecified JSON-LD error occurred.';
this.details = details || {};
} | javascript | {
"resource": ""
} | |
q31559 | hashBlankNodes | train | function hashBlankNodes(unnamed) {
var nextUnnamed = [];
var duplicates = {};
var unique = {};
// hash quads for each unnamed bnode
jsonld.setImmediate(function() {hashUnnamed(0);});
function hashUnnamed(i) {
if(i === unnamed.length) {
// done, name blank nodes
return name... | javascript | {
"resource": ""
} |
q31560 | nameBlankNodes | train | function nameBlankNodes(unique, duplicates, unnamed) {
// name unique bnodes in sorted hash order
var named = false;
var hashes = Object.keys(unique).sort();
for(var i = 0; i < hashes.length; ++i) {
var bnode = unique[hashes[i]];
namer.getName(bnode);
named = true;
}
// contin... | javascript | {
"resource": ""
} |
q31561 | nameDuplicates | train | function nameDuplicates(duplicates) {
// enumerate duplicate hash groups in sorted order
var hashes = Object.keys(duplicates).sort();
// process each group
processGroup(0);
function processGroup(i) {
if(i === hashes.length) {
// done, create JSON-LD array
return createArray();... | javascript | {
"resource": ""
} |
q31562 | createArray | train | function createArray() {
var normalized = [];
/* Note: At this point all bnodes in the set of RDF quads have been
assigned canonical names, which have been stored in the 'namer' object.
Here each quad is updated by assigning each of its bnodes its new name
via the 'namer' object. */
// upda... | javascript | {
"resource": ""
} |
q31563 | _expandLanguageMap | train | function _expandLanguageMap(languageMap) {
var rval = [];
var keys = Object.keys(languageMap).sort();
for(var ki = 0; ki < keys.length; ++ki) {
var key = keys[ki];
var val = languageMap[key];
if(!_isArray(val)) {
val = [val];
}
for(var vi = 0; vi < val.length; ++vi) {
var item = va... | javascript | {
"resource": ""
} |
q31564 | _labelBlankNodes | train | function _labelBlankNodes(namer, element) {
if(_isArray(element)) {
for(var i = 0; i < element.length; ++i) {
element[i] = _labelBlankNodes(namer, element[i]);
}
}
else if(_isList(element)) {
element['@list'] = _labelBlankNodes(namer, element['@list']);
}
else if(_isObject(element)) {
//... | javascript | {
"resource": ""
} |
q31565 | _expandValue | train | function _expandValue(activeCtx, activeProperty, value) {
// nothing to expand
if(value === null) {
return null;
}
// special-case expand @id and @type (skips '@id' expansion)
var expandedProperty = _expandIri(activeCtx, activeProperty, {vocab: true});
if(expandedProperty === '@id') {
return _expan... | javascript | {
"resource": ""
} |
q31566 | _graphToRDF | train | function _graphToRDF(graph, namer) {
var rval = [];
var ids = Object.keys(graph).sort();
for(var i = 0; i < ids.length; ++i) {
var id = ids[i];
var node = graph[id];
var properties = Object.keys(node).sort();
for(var pi = 0; pi < properties.length; ++pi) {
var property = properties[pi];
... | javascript | {
"resource": ""
} |
q31567 | _objectToRDF | train | function _objectToRDF(item) {
var object = {};
// convert value object to RDF
if(_isValue(item)) {
object.type = 'literal';
var value = item['@value'];
var datatype = item['@type'] || null;
// convert to XSD datatypes as appropriate
if(_isBoolean(value)) {
object.value = value.toString... | javascript | {
"resource": ""
} |
q31568 | _RDFToObject | train | function _RDFToObject(o, useNativeTypes) {
// convert IRI/blank node object to JSON-LD
if(o.type === 'IRI' || o.type === 'blank node') {
return {'@id': o.value};
}
// convert literal to JSON-LD
var rval = {'@value': o.value};
// add language
if('language' in o) {
rval['@language'] = o.language;
... | javascript | {
"resource": ""
} |
q31569 | _compareRDFTriples | train | function _compareRDFTriples(t1, t2) {
var attrs = ['subject', 'predicate', 'object'];
for(var i = 0; i < attrs.length; ++i) {
var attr = attrs[i];
if(t1[attr].type !== t2[attr].type || t1[attr].value !== t2[attr].value) {
return false;
}
}
if(t1.object.language !== t2.object.language) {
re... | javascript | {
"resource": ""
} |
q31570 | _hashQuads | train | function _hashQuads(id, bnodes, namer) {
// return cached hash
if('hash' in bnodes[id]) {
return bnodes[id].hash;
}
// serialize all of bnode's quads
var quads = bnodes[id].quads;
var nquads = [];
for(var i = 0; i < quads.length; ++i) {
nquads.push(_toNQuad(
quads[i], quads[i].name ? quads[... | javascript | {
"resource": ""
} |
q31571 | nextPermutation | train | function nextPermutation(skipped) {
if(!skipped && (chosenPath === null || path < chosenPath)) {
chosenPath = path;
chosenNamer = pathNamerCopy;
}
// do next permutation
if(permutator.hasNext()) {
jsonld.setImmediate(function() {permutate();});
}
... | javascript | {
"resource": ""
} |
q31572 | _getFrameFlag | train | function _getFrameFlag(frame, options, name) {
var flag = '@' + name;
return (flag in frame) ? frame[flag][0] : options[name];
} | javascript | {
"resource": ""
} |
q31573 | _validateFrame | train | function _validateFrame(state, frame) {
if(!_isArray(frame) || frame.length !== 1 || !_isObject(frame[0])) {
throw new JsonLdError(
'Invalid JSON-LD syntax; a JSON-LD frame must be a single object.',
'jsonld.SyntaxError', {frame: frame});
}
} | javascript | {
"resource": ""
} |
q31574 | _filterSubjects | train | function _filterSubjects(state, subjects, frame) {
// filter subjects in @id order
var rval = {};
for(var i = 0; i < subjects.length; ++i) {
var id = subjects[i];
var subject = state.subjects[id];
if(_filterSubject(subject, frame)) {
rval[id] = subject;
}
}
return rval;
} | javascript | {
"resource": ""
} |
q31575 | _filterSubject | train | function _filterSubject(subject, frame) {
// check @type (object value means 'any' type, fall through to ducktyping)
if('@type' in frame &&
!(frame['@type'].length === 1 && _isObject(frame['@type'][0]))) {
var types = frame['@type'];
for(var i = 0; i < types.length; ++i) {
// any matching @type is... | javascript | {
"resource": ""
} |
q31576 | _embedValues | train | function _embedValues(state, subject, property, output) {
// embed subject properties in output
var objects = subject[property];
for(var i = 0; i < objects.length; ++i) {
var o = objects[i];
// recurse into @list
if(_isList(o)) {
var list = {'@list': []};
_addFrameOutput(state, output, pr... | javascript | {
"resource": ""
} |
q31577 | _removeEmbed | train | function _removeEmbed(state, id) {
// get existing embed
var embeds = state.embeds;
var embed = embeds[id];
var parent = embed.parent;
var property = embed.property;
// create reference to replace embed
var subject = {'@id': id};
// remove existing embed
if(_isArray(parent)) {
// replace subject... | javascript | {
"resource": ""
} |
q31578 | train | function(id) {
// get embed keys as a separate array to enable deleting keys in map
var ids = Object.keys(embeds);
for(var i = 0; i < ids.length; ++i) {
var next = ids[i];
if(next in embeds && _isObject(embeds[next].parent) &&
embeds[next].parent['@id'] === id) {
delete embeds[ne... | javascript | {
"resource": ""
} | |
q31579 | _addFrameOutput | train | function _addFrameOutput(state, parent, property, output) {
if(_isObject(parent)) {
jsonld.addValue(parent, property, output, {propertyIsArray: true});
}
else {
parent.push(output);
}
} | javascript | {
"resource": ""
} |
q31580 | _selectTerm | train | function _selectTerm(
activeCtx, iri, value, containers, typeOrLanguage, typeOrLanguageValue) {
if(typeOrLanguageValue === null) {
typeOrLanguageValue = '@null';
}
// preferences for the value of @type or @language
var prefs = [];
// determine prefs for @id based on whether or not value compacts to a ... | javascript | {
"resource": ""
} |
q31581 | _expandIri | train | function _expandIri(activeCtx, value, relativeTo, localCtx, defined) {
// already expanded
if(value === null || _isKeyword(value)) {
return value;
}
// define term dependency if not defined
if(localCtx && value in localCtx && defined[value] !== true) {
_createTermDefinition(activeCtx, localCtx, value... | javascript | {
"resource": ""
} |
q31582 | _prependBase | train | function _prependBase(base, iri) {
// already an absolute IRI
if(iri.indexOf(':') !== -1) {
return iri;
}
// parse base if it is a string
if(_isString(base)) {
base = jsonld.url.parse(base || '');
}
// parse given IRI
var rel = jsonld.url.parse(iri);
// start hierarchical part
var hierPar... | javascript | {
"resource": ""
} |
q31583 | _removeBase | train | function _removeBase(base, iri) {
if(_isString(base)) {
base = jsonld.url.parse(base || '');
}
// establish base root
var root = '';
if(base.href !== '') {
root += (base.protocol || '') + '//' + base.authority;
}
// support network-path reference with empty base
else if(iri.indexOf('//')) {
... | javascript | {
"resource": ""
} |
q31584 | _createInverseContext | train | function _createInverseContext() {
var activeCtx = this;
// lazily create inverse
if(activeCtx.inverse) {
return activeCtx.inverse;
}
var inverse = activeCtx.inverse = {};
// handle default language
var defaultLanguage = activeCtx['@language'] || '@none';
// create term selectio... | javascript | {
"resource": ""
} |
q31585 | _addPreferredTerm | train | function _addPreferredTerm(mapping, term, entry, typeOrLanguageValue) {
if(!(typeOrLanguageValue in entry)) {
entry[typeOrLanguageValue] = term;
}
} | javascript | {
"resource": ""
} |
q31586 | _cloneActiveContext | train | function _cloneActiveContext() {
var child = {};
child['@base'] = this['@base'];
child.mappings = _clone(this.mappings);
child.clone = this.clone;
child.inverse = null;
child.getInverse = this.getInverse;
if('@language' in this) {
child['@language'] = this['@language'];
}
if('@... | javascript | {
"resource": ""
} |
q31587 | _isSubject | train | function _isSubject(v) {
// Note: A value is a subject if all of these hold true:
// 1. It is an Object.
// 2. It is not a @value, @set, or @list.
// 3. It has more than 1 key OR any existing key is not @id.
var rval = false;
if(_isObject(v) &&
!(('@value' in v) || ('@set' in v) || ('@list' in v))) {
... | javascript | {
"resource": ""
} |
q31588 | _isBlankNode | train | function _isBlankNode(v) {
// Note: A value is a blank node if all of these hold true:
// 1. It is an Object.
// 2. If it has an @id key its value begins with '_:'.
// 3. It has no keys OR is not a @value, @set, or @list.
var rval = false;
if(_isObject(v)) {
if('@id' in v) {
rval = (v['@id'].index... | javascript | {
"resource": ""
} |
q31589 | _parseNQuads | train | function _parseNQuads(input) {
// define partial regexes
var iri = '(?:<([^:]+:[^>]*)>)';
var bnode = '(_:(?:[A-Za-z][A-Za-z0-9]*))';
var plain = '"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"';
var datatype = '(?:\\^\\^' + iri + ')';
var language = '(?:@([a-z]+(?:-[a-z0-9]+)*))';
var literal = '(?:' + plain + '(?:' +... | javascript | {
"resource": ""
} |
q31590 | _toNQuads | train | function _toNQuads(dataset) {
var quads = [];
for(var graphName in dataset) {
var triples = dataset[graphName];
for(var ti = 0; ti < triples.length; ++ti) {
var triple = triples[ti];
if(graphName === '@default') {
graphName = null;
}
quads.push(_toNQuad(triple, graphName));
... | javascript | {
"resource": ""
} |
q31591 | _parseRdfaApiData | train | function _parseRdfaApiData(data) {
var dataset = {};
dataset['@default'] = [];
var subjects = data.getSubjects();
for(var si = 0; si < subjects.length; ++si) {
var subject = subjects[si];
if(subject === null) {
continue;
}
// get all related triples
var triples = data.getSubjectTripl... | javascript | {
"resource": ""
} |
q31592 | _parseAuthority | train | function _parseAuthority(parsed) {
// parse authority for unparsed relative network-path reference
if(parsed.href.indexOf(':') === -1 && parsed.href.indexOf('//') === 0 &&
!parsed.host) {
// must parse authority from pathname
parsed.pathname = parsed.pathname.substr(2);
var idx = parsed.pathname.ind... | javascript | {
"resource": ""
} |
q31593 | _removeDotSegments | train | function _removeDotSegments(path, hasAuthority) {
var rval = '';
if(path.indexOf('/') === 0) {
rval = '/';
}
// RFC 3986 5.2.4 (reworked)
var input = path.split('/');
var output = [];
while(input.length > 0) {
if(input[0] === '.' || (input[0] === '' && input.length > 1)) {
input.shift();
... | javascript | {
"resource": ""
} |
q31594 | scrollTo | train | function scrollTo({ container, element, key, options }) {
// if duration is ero then set it to very small so that we do not divide by zero
if (options.duration <= 0) options.duration = 0.1;
// width or height
const sizeKey = SIZE_KEYS[key];
// destination measurement
let to = Math.min(
element[`offset$... | javascript | {
"resource": ""
} |
q31595 | train | function (request) {
// Extract information from request. The toString() call converts the
// payload from a binary Buffer into a string, decoded using UTF-8
// character encoding.
console.log('Service received request payload: ' +
request.payload.toString())
// Create the respons... | javascript | {
"resource": ""
} | |
q31596 | train | function (error, response) {
// Destroy the client - frees up resources so that the application
// stops running
client.destroy()
// Display the contents of an error, if one occurred
if (error) {
console.log('Request error: ' + error.message)
... | javascript | {
"resource": ""
} | |
q31597 | train | function (prototype, properties) {
var object = Object.create(prototype);
Object.keys(properties).forEach(function (key) {
object[key] = properties[key];
});
return object;
} | javascript | {
"resource": ""
} | |
q31598 | train | function (descriptor) {
var result = {};
for (var key in descriptor) {
if (Object.prototype.hasOwnProperty.call(descriptor, key)) {
var keys = key.split(',');
for (var i = 0, len = keys.length; i < len; i += 1) {
var method = keys[i];
... | javascript | {
"resource": ""
} | |
q31599 | train | function (route) {
if (route === "/") {
return "root";
}
if (route.indexOf("{") >= 0) {
throw new Error("Unable to guess route name for route " + route);
}
var result = route
.replace(SLASH_PREFIX_REGEX, "")
.replace(GUESS_... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.