repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
taylor1791/promissory-arbiter | src/promissory-arbiter.js | unsubscribe | function unsubscribe (state, tokens, suspend) {
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(
{topics: state._topics, suspend: suspend}, removeSubscriber, tokens
);
return result.length === 1 ? result[... | javascript | function unsubscribe (state, tokens, suspend) {
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(
{topics: state._topics, suspend: suspend}, removeSubscriber, tokens
);
return result.length === 1 ? result[... | [
"function",
"unsubscribe",
"(",
"state",
",",
"tokens",
",",
"suspend",
")",
"{",
"tokens",
"=",
"typeof",
"tokens",
"===",
"'string'",
"?",
"tokens",
".",
"split",
"(",
"/",
",\\s*",
"/",
")",
":",
"tokens",
";",
"tokens",
"=",
"!",
"tokens",
".",
"... | `Arbiter.unsubscribe` removes the subscribers associated with a token or
a topic. This prevents them from being notified when a publication
occurs. By default these cannot be recovered, however this also allows
us to temporarily suspend them instead.
@function unsubscribe
@memberof Arbiter
@param {Token|Topic} token ... | [
"Arbiter",
".",
"unsubscribe",
"removes",
"the",
"subscribers",
"associated",
"with",
"a",
"token",
"or",
"a",
"topic",
".",
"This",
"prevents",
"them",
"from",
"being",
"notified",
"when",
"a",
"publication",
"occurs",
".",
"By",
"default",
"these",
"cannot",... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L265-L274 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | resubscribe | function resubscribe (state, tokens) {
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(state._topics, unsuspendSubscriber, tokens);
return result.length === 1 ? result[0] : result;
} | javascript | function resubscribe (state, tokens) {
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(state._topics, unsuspendSubscriber, tokens);
return result.length === 1 ? result[0] : result;
} | [
"function",
"resubscribe",
"(",
"state",
",",
"tokens",
")",
"{",
"tokens",
"=",
"typeof",
"tokens",
"===",
"'string'",
"?",
"tokens",
".",
"split",
"(",
"/",
",\\s*",
"/",
")",
":",
"tokens",
";",
"tokens",
"=",
"!",
"tokens",
".",
"length",
"?",
"[... | Reactivates all subscriptions associated with a token or all
subscriptions that are descendants of a topic.
@function resubscribe
@memberof Arbiter
@param {Token|Topic} token The token or topic to reactivates
@return {Boolean} Returns false if the token's subscription cannot be
located and true otherwise. This return... | [
"Reactivates",
"all",
"subscriptions",
"associated",
"with",
"a",
"token",
"or",
"all",
"subscriptions",
"that",
"are",
"descendants",
"of",
"a",
"topic",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L294-L301 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | create | function create () {
/**
* Arbiter has a few options to affect the way that subscribers are
* notified and PublicationPromises are resolved.
*
* @typedef Options
* @memberof Arbiter
*
* @property {boolean} persist=false When true, subscribers are notified
* of past messages... | javascript | function create () {
/**
* Arbiter has a few options to affect the way that subscribers are
* notified and PublicationPromises are resolved.
*
* @typedef Options
* @memberof Arbiter
*
* @property {boolean} persist=false When true, subscribers are notified
* of past messages... | [
"function",
"create",
"(",
")",
"{",
"/**\n * Arbiter has a few options to affect the way that subscribers are\n * notified and PublicationPromises are resolved.\n *\n * @typedef Options\n * @memberof Arbiter\n *\n * @property {boolean} persist=false When true, subscribers are ... | Creates a new instance of Arbiter that is completely separate from the
original. It has its own set of topics, subscribers, and options.
@function create
@memberof Arbiter
@return {Arbiter} The new instance.
@example
var arbiter = Arbiter.create();
Arbiter.subscribe('a', function a () {});
arbiter.publish('a'); // ... | [
"Creates",
"a",
"new",
"instance",
"of",
"Arbiter",
"that",
"is",
"completely",
"separate",
"from",
"the",
"original",
".",
"It",
"has",
"its",
"own",
"set",
"of",
"topics",
"subscribers",
"and",
"options",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L363-L428 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | hierarchicalTopicDispatcher | function hierarchicalTopicDispatcher (state, topic, data, options) {
var
lineage = findLineage(getTopic, isAncestorTopic, topic, state._topics),
topicNode = lineage[lineage.length - 1],
subscriptions = options.preventBubble
? topicNode.topic === topic ? topicNode.subscriptions : []
... | javascript | function hierarchicalTopicDispatcher (state, topic, data, options) {
var
lineage = findLineage(getTopic, isAncestorTopic, topic, state._topics),
topicNode = lineage[lineage.length - 1],
subscriptions = options.preventBubble
? topicNode.topic === topic ? topicNode.subscriptions : []
... | [
"function",
"hierarchicalTopicDispatcher",
"(",
"state",
",",
"topic",
",",
"data",
",",
"options",
")",
"{",
"var",
"lineage",
"=",
"findLineage",
"(",
"getTopic",
",",
"isAncestorTopic",
",",
"topic",
",",
"state",
".",
"_topics",
")",
",",
"topicNode",
"=... | Takes care of all the heavy lifting of publishing a message. This includes locating all topics, their subscribers, publishing the data and, if necessary, storing the message for late subscribers. | [
"Takes",
"care",
"of",
"all",
"the",
"heavy",
"lifting",
"of",
"publishing",
"a",
"message",
".",
"This",
"includes",
"locating",
"all",
"topics",
"their",
"subscribers",
"publishing",
"the",
"data",
"and",
"if",
"necessary",
"storing",
"the",
"message",
"for"... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L437-L462 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | resumeSubscriptionDispatcher | function resumeSubscriptionDispatcher (
topic, data, options, subscriptions, resolver, fulfill, reject
) {
var
promise = resolver.promise,
subscription;
for (
;
resolver.i >= 0 && promise.pending < options.semaphor;
resolver.i -= 1
) {
subscription = subscriptions... | javascript | function resumeSubscriptionDispatcher (
topic, data, options, subscriptions, resolver, fulfill, reject
) {
var
promise = resolver.promise,
subscription;
for (
;
resolver.i >= 0 && promise.pending < options.semaphor;
resolver.i -= 1
) {
subscription = subscriptions... | [
"function",
"resumeSubscriptionDispatcher",
"(",
"topic",
",",
"data",
",",
"options",
",",
"subscriptions",
",",
"resolver",
",",
"fulfill",
",",
"reject",
")",
"{",
"var",
"promise",
"=",
"resolver",
".",
"promise",
",",
"subscription",
";",
"for",
"(",
";... | Invokes the next set of subscriptions | [
"Invokes",
"the",
"next",
"set",
"of",
"subscriptions"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L465-L484 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | removePersistedDispatcher | function removePersistedDispatcher (state, tokens) {
tokens = tokens && tokens.token || tokens || '';
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(state._topics, removePersisted, tokens);
return result.lengt... | javascript | function removePersistedDispatcher (state, tokens) {
tokens = tokens && tokens.token || tokens || '';
tokens = typeof tokens === 'string' ? tokens.split(/,\s*/) : tokens;
tokens = !tokens.length ? [tokens] : tokens;
var result = curryMap(state._topics, removePersisted, tokens);
return result.lengt... | [
"function",
"removePersistedDispatcher",
"(",
"state",
",",
"tokens",
")",
"{",
"tokens",
"=",
"tokens",
"&&",
"tokens",
".",
"token",
"||",
"tokens",
"||",
"''",
";",
"tokens",
"=",
"typeof",
"tokens",
"===",
"'string'",
"?",
"tokens",
".",
"split",
"(",
... | Takes care of sending all the requests on their way | [
"Takes",
"care",
"of",
"sending",
"all",
"the",
"requests",
"on",
"their",
"way"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L487-L495 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | subscriptionDispatcher | function subscriptionDispatcher (topic, data, options, subscriptions) {
var
resolver = createResolver(),
fulfill = resolveUse('fulfilledValues', 'fulfilled', options, resolver),
reject = resolveUse('rejectedValues', 'rejected', options, resolver);
resolver.i = subscriptions.length - 1;
re... | javascript | function subscriptionDispatcher (topic, data, options, subscriptions) {
var
resolver = createResolver(),
fulfill = resolveUse('fulfilledValues', 'fulfilled', options, resolver),
reject = resolveUse('rejectedValues', 'rejected', options, resolver);
resolver.i = subscriptions.length - 1;
re... | [
"function",
"subscriptionDispatcher",
"(",
"topic",
",",
"data",
",",
"options",
",",
"subscriptions",
")",
"{",
"var",
"resolver",
"=",
"createResolver",
"(",
")",
",",
"fulfill",
"=",
"resolveUse",
"(",
"'fulfilledValues'",
",",
"'fulfilled'",
",",
"options",
... | Invokes all the subscriptions according to `options` and returns a promise that resolves according to `options`. | [
"Invokes",
"all",
"the",
"subscriptions",
"according",
"to",
"options",
"and",
"returns",
"a",
"promise",
"that",
"resolves",
"according",
"to",
"options",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L499-L520 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | resolveUse | function resolveUse (appendList, increment, options, resolver) {
return function resolveUseClosure (value) {
// TODO This should state.options('update..
// TODO look at all of options.xxxx
if (resolver.settled && !options.updateAfterSettlement) {
return;
}
var promise = resolv... | javascript | function resolveUse (appendList, increment, options, resolver) {
return function resolveUseClosure (value) {
// TODO This should state.options('update..
// TODO look at all of options.xxxx
if (resolver.settled && !options.updateAfterSettlement) {
return;
}
var promise = resolv... | [
"function",
"resolveUse",
"(",
"appendList",
",",
"increment",
",",
"options",
",",
"resolver",
")",
"{",
"return",
"function",
"resolveUseClosure",
"(",
"value",
")",
"{",
"// TODO This should state.options('update..",
"// TODO look at all of options.xxxx",
"if",
"(",
... | Takes care all the bookkeeping work surrounding a subscriber resolving resolving. | [
"Takes",
"care",
"all",
"the",
"bookkeeping",
"work",
"surrounding",
"a",
"subscriber",
"resolving",
"resolving",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L524-L549 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | evaluateLatch | function evaluateLatch (resolver, options) {
var
settlementLatch = options.settlementLatch,
latch = options.latch,
promise = resolver.promise,
fulfilled = promise.fulfilled,
pending = promise.pending,
rejected = promise.rejected,
settled = fulfilled + rejected,
maxFul... | javascript | function evaluateLatch (resolver, options) {
var
settlementLatch = options.settlementLatch,
latch = options.latch,
promise = resolver.promise,
fulfilled = promise.fulfilled,
pending = promise.pending,
rejected = promise.rejected,
settled = fulfilled + rejected,
maxFul... | [
"function",
"evaluateLatch",
"(",
"resolver",
",",
"options",
")",
"{",
"var",
"settlementLatch",
"=",
"options",
".",
"settlementLatch",
",",
"latch",
"=",
"options",
".",
"latch",
",",
"promise",
"=",
"resolver",
".",
"promise",
",",
"fulfilled",
"=",
"pro... | Resolves the latch according to `options`. Computes the hypothetical max and resolves if is not met. | [
"Resolves",
"the",
"latch",
"according",
"to",
"options",
".",
"Computes",
"the",
"hypothetical",
"max",
"and",
"resolves",
"if",
"is",
"not",
"met",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L553-L591 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | subscriptionInvoker | function subscriptionInvoker (subscription, data, topic) {
var result;
if (subscription.fn.length === 3) {
return new Promise(function promiseResolver (fulfill, reject) {
subscription.fn.call(
subscription.context, data, topic, function callback (err, succ) {
return err ? re... | javascript | function subscriptionInvoker (subscription, data, topic) {
var result;
if (subscription.fn.length === 3) {
return new Promise(function promiseResolver (fulfill, reject) {
subscription.fn.call(
subscription.context, data, topic, function callback (err, succ) {
return err ? re... | [
"function",
"subscriptionInvoker",
"(",
"subscription",
",",
"data",
",",
"topic",
")",
"{",
"var",
"result",
";",
"if",
"(",
"subscription",
".",
"fn",
".",
"length",
"===",
"3",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"promiseResolver",
"(... | Invokes a subscription with the required parameters and acts as an adapter for the different asynchronous mechanisms behavior. i.e. node-style callbacks and promises. | [
"Invokes",
"a",
"subscription",
"with",
"the",
"required",
"parameters",
"and",
"acts",
"as",
"an",
"adapter",
"for",
"the",
"different",
"asynchronous",
"mechanisms",
"behavior",
".",
"i",
".",
"e",
".",
"node",
"-",
"style",
"callbacks",
"and",
"promises",
... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L596-L620 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | subscribeDispatcher | function subscribeDispatcher (state, topic, subscriptions, options, context) {
topic = typeof topic === 'string' ? topic.split(/,\s*/) : topic;
topic = topic && topic.length ? topic : [topic];
var result = curryMap(
[state, null, subscriptions, options, context],
subscribeTopicApplier,
to... | javascript | function subscribeDispatcher (state, topic, subscriptions, options, context) {
topic = typeof topic === 'string' ? topic.split(/,\s*/) : topic;
topic = topic && topic.length ? topic : [topic];
var result = curryMap(
[state, null, subscriptions, options, context],
subscribeTopicApplier,
to... | [
"function",
"subscribeDispatcher",
"(",
"state",
",",
"topic",
",",
"subscriptions",
",",
"options",
",",
"context",
")",
"{",
"topic",
"=",
"typeof",
"topic",
"===",
"'string'",
"?",
"topic",
".",
"split",
"(",
"/",
",\\s*",
"/",
")",
":",
"topic",
";",... | This coverts `topic`, which can represent multiple subscriptions and serializes them into individual topics for use with the `subscription` | [
"This",
"coverts",
"topic",
"which",
"can",
"represent",
"multiple",
"subscriptions",
"and",
"serializes",
"them",
"into",
"individual",
"topics",
"for",
"use",
"with",
"the",
"subscription"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L624-L635 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | applyTopicDescendents | function applyTopicDescendents (f, property, topic, topics) {
var node = ancestorTopicSearch(topic, topics);
if (node.topic === topic) {
return curryMap(property, f, descendents(node));
}
return null;
} | javascript | function applyTopicDescendents (f, property, topic, topics) {
var node = ancestorTopicSearch(topic, topics);
if (node.topic === topic) {
return curryMap(property, f, descendents(node));
}
return null;
} | [
"function",
"applyTopicDescendents",
"(",
"f",
",",
"property",
",",
"topic",
",",
"topics",
")",
"{",
"var",
"node",
"=",
"ancestorTopicSearch",
"(",
"topic",
",",
"topics",
")",
";",
"if",
"(",
"node",
".",
"topic",
"===",
"topic",
")",
"{",
"return",
... | For all descendants of `topic` remove all elements of `node[property`. | [
"For",
"all",
"descendants",
"of",
"topic",
"remove",
"all",
"elements",
"of",
"node",
"[",
"property",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L645-L652 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | unsuspendSubscriber | function unsuspendSubscriber (topic, token) {
if (typeof token === 'string') {
return !!applyTopicDescendents(
unsuspendTopic, 'subscriptions', token, topic
);
}
var node = ancestorTopicSearch(token.topic, topic);
if (node.topic !== token.topic) {
return false;
}
var ... | javascript | function unsuspendSubscriber (topic, token) {
if (typeof token === 'string') {
return !!applyTopicDescendents(
unsuspendTopic, 'subscriptions', token, topic
);
}
var node = ancestorTopicSearch(token.topic, topic);
if (node.topic !== token.topic) {
return false;
}
var ... | [
"function",
"unsuspendSubscriber",
"(",
"topic",
",",
"token",
")",
"{",
"if",
"(",
"typeof",
"token",
"===",
"'string'",
")",
"{",
"return",
"!",
"!",
"applyTopicDescendents",
"(",
"unsuspendTopic",
",",
"'subscriptions'",
",",
"token",
",",
"topic",
")",
"... | Finds the subscription associated with a token and unsuspendes it. Returns false if it was removed and true it was unsuspended. | [
"Finds",
"the",
"subscription",
"associated",
"with",
"a",
"token",
"and",
"unsuspendes",
"it",
".",
"Returns",
"false",
"if",
"it",
"was",
"removed",
"and",
"true",
"it",
"was",
"unsuspended",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L656-L680 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | removeSubscriber | function removeSubscriber (args, token) {
var
topics = args.topics,
suspendSubs = args.suspend;
if (typeof token === 'string') {
return !!applyTopicDescendents(
suspendSubs ? suspendTopic : empty, 'subscriptions', token, topics
);
}
var node = ancestorTopicSearch(token.... | javascript | function removeSubscriber (args, token) {
var
topics = args.topics,
suspendSubs = args.suspend;
if (typeof token === 'string') {
return !!applyTopicDescendents(
suspendSubs ? suspendTopic : empty, 'subscriptions', token, topics
);
}
var node = ancestorTopicSearch(token.... | [
"function",
"removeSubscriber",
"(",
"args",
",",
"token",
")",
"{",
"var",
"topics",
"=",
"args",
".",
"topics",
",",
"suspendSubs",
"=",
"args",
".",
"suspend",
";",
"if",
"(",
"typeof",
"token",
"===",
"'string'",
")",
"{",
"return",
"!",
"!",
"appl... | Finds the subscription associated with a token and removes or suspends is. If the subscription associated with a token cannot be found then this returns false. This usually means that the token was already removed. | [
"Finds",
"the",
"subscription",
"associated",
"with",
"a",
"token",
"and",
"removes",
"or",
"suspends",
"is",
".",
"If",
"the",
"subscription",
"associated",
"with",
"a",
"token",
"cannot",
"be",
"found",
"then",
"this",
"returns",
"false",
".",
"This",
"usu... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L685-L717 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | addTopicLine | function addTopicLine (topic, ancestor) {
var
ancestorTopic = ancestor.topic,
additionalTopics = [];
if (ancestorTopic !== topic) {
// All of the generations to add seeded by the youngest existing ancestor
additionalTopics = reduce(
appendPrefixedTopic, [ancestorTopic],
... | javascript | function addTopicLine (topic, ancestor) {
var
ancestorTopic = ancestor.topic,
additionalTopics = [];
if (ancestorTopic !== topic) {
// All of the generations to add seeded by the youngest existing ancestor
additionalTopics = reduce(
appendPrefixedTopic, [ancestorTopic],
... | [
"function",
"addTopicLine",
"(",
"topic",
",",
"ancestor",
")",
"{",
"var",
"ancestorTopic",
"=",
"ancestor",
".",
"topic",
",",
"additionalTopics",
"=",
"[",
"]",
";",
"if",
"(",
"ancestorTopic",
"!==",
"topic",
")",
"{",
"// All of the generations to add seede... | Takes a topic and an ancestor and adds all of the generations from the ancestor to the topic returning the topic that represents the node. | [
"Takes",
"a",
"topic",
"and",
"an",
"ancestor",
"and",
"adds",
"all",
"of",
"the",
"generations",
"from",
"the",
"ancestor",
"to",
"the",
"topic",
"returning",
"the",
"topic",
"that",
"represents",
"the",
"node",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L726-L743 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | isAncestorTopic | function isAncestorTopic (topic, node) {
var nodeTopic = getTopic(node);
return topic === nodeTopic
|| startsWith(topic, nodeTopic + '.')
|| nodeTopic === '';
} | javascript | function isAncestorTopic (topic, node) {
var nodeTopic = getTopic(node);
return topic === nodeTopic
|| startsWith(topic, nodeTopic + '.')
|| nodeTopic === '';
} | [
"function",
"isAncestorTopic",
"(",
"topic",
",",
"node",
")",
"{",
"var",
"nodeTopic",
"=",
"getTopic",
"(",
"node",
")",
";",
"return",
"topic",
"===",
"nodeTopic",
"||",
"startsWith",
"(",
"topic",
",",
"nodeTopic",
"+",
"'.'",
")",
"||",
"nodeTopic",
... | Finds the Ancestor of the specified topic or undefined | [
"Finds",
"the",
"Ancestor",
"of",
"the",
"specified",
"topic",
"or",
"undefined"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L764-L770 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | getFingerArrayOrder | function getFingerArrayOrder (fingerArray) {
var item = getPointedFinger(fingerArray);
return item !== SYMBOL_NOTHING ? getOrder(item) : Infinity;
} | javascript | function getFingerArrayOrder (fingerArray) {
var item = getPointedFinger(fingerArray);
return item !== SYMBOL_NOTHING ? getOrder(item) : Infinity;
} | [
"function",
"getFingerArrayOrder",
"(",
"fingerArray",
")",
"{",
"var",
"item",
"=",
"getPointedFinger",
"(",
"fingerArray",
")",
";",
"return",
"item",
"!==",
"SYMBOL_NOTHING",
"?",
"getOrder",
"(",
"item",
")",
":",
"Infinity",
";",
"}"
] | Given a fingerArray, return the order of current item | [
"Given",
"a",
"fingerArray",
"return",
"the",
"order",
"of",
"current",
"item"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L773-L776 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | getFingerArrayPriority | function getFingerArrayPriority (fingerArray) {
var item = getPointedFinger(fingerArray);
return item !== SYMBOL_NOTHING ? getPriority(item) : Infinity;
} | javascript | function getFingerArrayPriority (fingerArray) {
var item = getPointedFinger(fingerArray);
return item !== SYMBOL_NOTHING ? getPriority(item) : Infinity;
} | [
"function",
"getFingerArrayPriority",
"(",
"fingerArray",
")",
"{",
"var",
"item",
"=",
"getPointedFinger",
"(",
"fingerArray",
")",
";",
"return",
"item",
"!==",
"SYMBOL_NOTHING",
"?",
"getPriority",
"(",
"item",
")",
":",
"Infinity",
";",
"}"
] | Given a fingerArray, return the priority of current item | [
"Given",
"a",
"fingerArray",
"return",
"the",
"priority",
"of",
"current",
"item"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L779-L782 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | createResolver | function createResolver () {
var
resolver = {
settled: false,
fulfilledValues: [],
rejectedValues: []
},
promise = new Promise(function promiseResolver (fulfill, reject) {
resolver.fulfill = fulfill;
resolver.reject = reject;
});
promise.fulfilled... | javascript | function createResolver () {
var
resolver = {
settled: false,
fulfilledValues: [],
rejectedValues: []
},
promise = new Promise(function promiseResolver (fulfill, reject) {
resolver.fulfill = fulfill;
resolver.reject = reject;
});
promise.fulfilled... | [
"function",
"createResolver",
"(",
")",
"{",
"var",
"resolver",
"=",
"{",
"settled",
":",
"false",
",",
"fulfilledValues",
":",
"[",
"]",
",",
"rejectedValues",
":",
"[",
"]",
"}",
",",
"promise",
"=",
"new",
"Promise",
"(",
"function",
"promiseResolver",
... | Creates a resolver object that keeps track of promise related values | [
"Creates",
"a",
"resolver",
"object",
"that",
"keeps",
"track",
"of",
"promise",
"related",
"values"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L837-L855 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | createSubscription | function createSubscription (state, fn, options, context) {
return {
id: state.id(),
fn: typeof fn === 'function' ? fn : noop,
suspended: false,
priority: +options.priority || 0,
context: context || null
};
} | javascript | function createSubscription (state, fn, options, context) {
return {
id: state.id(),
fn: typeof fn === 'function' ? fn : noop,
suspended: false,
priority: +options.priority || 0,
context: context || null
};
} | [
"function",
"createSubscription",
"(",
"state",
",",
"fn",
",",
"options",
",",
"context",
")",
"{",
"return",
"{",
"id",
":",
"state",
".",
"id",
"(",
")",
",",
"fn",
":",
"typeof",
"fn",
"===",
"'function'",
"?",
"fn",
":",
"noop",
",",
"suspended"... | Creates a subscription object | [
"Creates",
"a",
"subscription",
"object"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L858-L866 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | addChild | function addChild (getValue, newChild, tree) {
tree.children.splice(
binaryIndexBy(getValue, getValue(newChild), tree.children),
0, newChild
);
return newChild;
} | javascript | function addChild (getValue, newChild, tree) {
tree.children.splice(
binaryIndexBy(getValue, getValue(newChild), tree.children),
0, newChild
);
return newChild;
} | [
"function",
"addChild",
"(",
"getValue",
",",
"newChild",
",",
"tree",
")",
"{",
"tree",
".",
"children",
".",
"splice",
"(",
"binaryIndexBy",
"(",
"getValue",
",",
"getValue",
"(",
"newChild",
")",
",",
"tree",
".",
"children",
")",
",",
"0",
",",
"ne... | Adds a node child into the tree in order according to `getValue` | [
"Adds",
"a",
"node",
"child",
"into",
"the",
"tree",
"in",
"order",
"according",
"to",
"getValue"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L937-L944 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | insert | function insert (getValue, item, list) {
var index = binaryIndexBy(getValue, getValue(item), list);
list.splice(index, 0, item);
return item;
} | javascript | function insert (getValue, item, list) {
var index = binaryIndexBy(getValue, getValue(item), list);
list.splice(index, 0, item);
return item;
} | [
"function",
"insert",
"(",
"getValue",
",",
"item",
",",
"list",
")",
"{",
"var",
"index",
"=",
"binaryIndexBy",
"(",
"getValue",
",",
"getValue",
"(",
"item",
")",
",",
"list",
")",
";",
"list",
".",
"splice",
"(",
"index",
",",
"0",
",",
"item",
... | Inserts an item in ascending order according to `getValue`. | [
"Inserts",
"an",
"item",
"in",
"ascending",
"order",
"according",
"to",
"getValue",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L968-L973 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | minBy | function minBy (valueComputer, list) {
var
idx = 0,
winner = list[idx],
computedWinner = valueComputer(winner),
computedCurrent;
while (++idx < list.length) {
computedCurrent = valueComputer(list[idx]);
if (computedCurrent < computedWinner) {
computedWinner = compu... | javascript | function minBy (valueComputer, list) {
var
idx = 0,
winner = list[idx],
computedWinner = valueComputer(winner),
computedCurrent;
while (++idx < list.length) {
computedCurrent = valueComputer(list[idx]);
if (computedCurrent < computedWinner) {
computedWinner = compu... | [
"function",
"minBy",
"(",
"valueComputer",
",",
"list",
")",
"{",
"var",
"idx",
"=",
"0",
",",
"winner",
"=",
"list",
"[",
"idx",
"]",
",",
"computedWinner",
"=",
"valueComputer",
"(",
"winner",
")",
",",
"computedCurrent",
";",
"while",
"(",
"++",
"id... | Finds the `minimum` element of an array according to the `valueComputer` function. | [
"Finds",
"the",
"minimum",
"element",
"of",
"an",
"array",
"according",
"to",
"the",
"valueComputer",
"function",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1035-L1053 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | getPointedFinger | function getPointedFinger (fArray) {
var
pointer = fArray.pointer,
array = fArray.array;
return array.length > pointer ? array[pointer] : SYMBOL_NOTHING;
} | javascript | function getPointedFinger (fArray) {
var
pointer = fArray.pointer,
array = fArray.array;
return array.length > pointer ? array[pointer] : SYMBOL_NOTHING;
} | [
"function",
"getPointedFinger",
"(",
"fArray",
")",
"{",
"var",
"pointer",
"=",
"fArray",
".",
"pointer",
",",
"array",
"=",
"fArray",
".",
"array",
";",
"return",
"array",
".",
"length",
">",
"pointer",
"?",
"array",
"[",
"pointer",
"]",
":",
"SYMBOL_NO... | Retrieves the element that is the current focus and apply a | [
"Retrieves",
"the",
"element",
"that",
"is",
"the",
"current",
"focus",
"and",
"apply",
"a"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1056-L1062 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | partial1 | function partial1 (f, x) {
return function partiallyApplied1 () {
// Using slice or splice on `arguments` causes the function to be
// unoptimizable. Who doesn't like optimization?
var args = map(identity, arguments);
args.unshift(x);
return f.apply(null, args);
};
} | javascript | function partial1 (f, x) {
return function partiallyApplied1 () {
// Using slice or splice on `arguments` causes the function to be
// unoptimizable. Who doesn't like optimization?
var args = map(identity, arguments);
args.unshift(x);
return f.apply(null, args);
};
} | [
"function",
"partial1",
"(",
"f",
",",
"x",
")",
"{",
"return",
"function",
"partiallyApplied1",
"(",
")",
"{",
"// Using slice or splice on `arguments` causes the function to be",
"// unoptimizable. Who doesn't like optimization?",
"var",
"args",
"=",
"map",
"(",
"identity... | Partially applies 1 argument to a function. | [
"Partially",
"applies",
"1",
"argument",
"to",
"a",
"function",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1102-L1111 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | merge | function merge (a, b) {
var result = {};
var x;
for (x in a) {
if (a.hasOwnProperty(x)) {
result[x] = a[x];
}
}
for (x in b) {
if (b.hasOwnProperty(x)) {
result[x] = b[x];
}
}
return result;
} | javascript | function merge (a, b) {
var result = {};
var x;
for (x in a) {
if (a.hasOwnProperty(x)) {
result[x] = a[x];
}
}
for (x in b) {
if (b.hasOwnProperty(x)) {
result[x] = b[x];
}
}
return result;
} | [
"function",
"merge",
"(",
"a",
",",
"b",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"var",
"x",
";",
"for",
"(",
"x",
"in",
"a",
")",
"{",
"if",
"(",
"a",
".",
"hasOwnProperty",
"(",
"x",
")",
")",
"{",
"result",
"[",
"x",
"]",
"=",
"... | Returns a new object will all the properties of `a` and `b` giving b the priority. | [
"Returns",
"a",
"new",
"object",
"will",
"all",
"the",
"properties",
"of",
"a",
"and",
"b",
"giving",
"b",
"the",
"priority",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1115-L1132 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | reduce | function reduce (f, seed, arr) {
var result = seed, i, n;
for (i = 0, n = arr.length; i < n; i++) {
result = f(result, arr[i]);
}
return result;
} | javascript | function reduce (f, seed, arr) {
var result = seed, i, n;
for (i = 0, n = arr.length; i < n; i++) {
result = f(result, arr[i]);
}
return result;
} | [
"function",
"reduce",
"(",
"f",
",",
"seed",
",",
"arr",
")",
"{",
"var",
"result",
"=",
"seed",
",",
"i",
",",
"n",
";",
"for",
"(",
"i",
"=",
"0",
",",
"n",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"resul... | Array.prototype.reduce has similar performance to Array.prototype.map, so we define a custom reduce function to increase performance | [
"Array",
".",
"prototype",
".",
"reduce",
"has",
"similar",
"performance",
"to",
"Array",
".",
"prototype",
".",
"map",
"so",
"we",
"define",
"a",
"custom",
"reduce",
"function",
"to",
"increase",
"performance"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1136-L1142 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | curryMap | function curryMap (args, f, arr) {
var result = [], i, n;
for (i = 0, n = arr.length; i < n; i++) {
result.push(f(args, arr[i]));
}
return result;
} | javascript | function curryMap (args, f, arr) {
var result = [], i, n;
for (i = 0, n = arr.length; i < n; i++) {
result.push(f(args, arr[i]));
}
return result;
} | [
"function",
"curryMap",
"(",
"args",
",",
"f",
",",
"arr",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"i",
",",
"n",
";",
"for",
"(",
"i",
"=",
"0",
",",
"n",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
... | A special version of map to get around the performance hit for creating closures as a form of currying | [
"A",
"special",
"version",
"of",
"map",
"to",
"get",
"around",
"the",
"performance",
"hit",
"for",
"creating",
"closures",
"as",
"a",
"form",
"of",
"currying"
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1146-L1152 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | map | function map (f, arr) {
var result = [], i, n;
for (i = 0, n = arr.length; i < n; i++) {
result.push(f(arr[i]));
}
return result;
} | javascript | function map (f, arr) {
var result = [], i, n;
for (i = 0, n = arr.length; i < n; i++) {
result.push(f(arr[i]));
}
return result;
} | [
"function",
"map",
"(",
"f",
",",
"arr",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"i",
",",
"n",
";",
"for",
"(",
"i",
"=",
"0",
",",
"n",
"=",
"arr",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"result",
".",
"pu... | Array.prototype.map is supeeeeer slow. In fact, it is slower than a custom map function, which is usually slower than an inline for loop, but is more maintainable. | [
"Array",
".",
"prototype",
".",
"map",
"is",
"supeeeeer",
"slow",
".",
"In",
"fact",
"it",
"is",
"slower",
"than",
"a",
"custom",
"map",
"function",
"which",
"is",
"usually",
"slower",
"than",
"an",
"inline",
"for",
"loop",
"but",
"is",
"more",
"maintain... | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1157-L1163 | train |
taylor1791/promissory-arbiter | src/promissory-arbiter.js | startsWith | function startsWith (haystack, needle, startPosition) {
startPosition = startPosition || 0;
return haystack.lastIndexOf(needle, startPosition) === startPosition;
} | javascript | function startsWith (haystack, needle, startPosition) {
startPosition = startPosition || 0;
return haystack.lastIndexOf(needle, startPosition) === startPosition;
} | [
"function",
"startsWith",
"(",
"haystack",
",",
"needle",
",",
"startPosition",
")",
"{",
"startPosition",
"=",
"startPosition",
"||",
"0",
";",
"return",
"haystack",
".",
"lastIndexOf",
"(",
"needle",
",",
"startPosition",
")",
"===",
"startPosition",
";",
"}... | Determines whether a string begins with the characters of another string, returning true or false as appropriate. | [
"Determines",
"whether",
"a",
"string",
"begins",
"with",
"the",
"characters",
"of",
"another",
"string",
"returning",
"true",
"or",
"false",
"as",
"appropriate",
"."
] | 6327b87efd9ee997cbfaa009164dac266d9e16c2 | https://github.com/taylor1791/promissory-arbiter/blob/6327b87efd9ee997cbfaa009164dac266d9e16c2/src/promissory-arbiter.js#L1167-L1170 | train |
DavideDaniel/npm-link-extra | lib/index.js | checkNpmVersion | function checkNpmVersion() {
return execa.shell('npm -v')
.then(({ stdout }) => stdout)
.then((v) => {
if (v && !(v.indexOf('3') === 0)) {
log('Use npm v3.10.10 for unobtrusive symlinks: npm i -g npm@3.10.10');
}
});
} | javascript | function checkNpmVersion() {
return execa.shell('npm -v')
.then(({ stdout }) => stdout)
.then((v) => {
if (v && !(v.indexOf('3') === 0)) {
log('Use npm v3.10.10 for unobtrusive symlinks: npm i -g npm@3.10.10');
}
});
} | [
"function",
"checkNpmVersion",
"(",
")",
"{",
"return",
"execa",
".",
"shell",
"(",
"'npm -v'",
")",
".",
"then",
"(",
"(",
"{",
"stdout",
"}",
")",
"=>",
"stdout",
")",
".",
"then",
"(",
"(",
"v",
")",
"=>",
"{",
"if",
"(",
"v",
"&&",
"!",
"("... | check npm version and show warning if needed | [
"check",
"npm",
"version",
"and",
"show",
"warning",
"if",
"needed"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L18-L26 | train |
DavideDaniel/npm-link-extra | lib/index.js | linkPackages | function linkPackages(pathToPkgs) {
const pkgs = pathToPkgs.join(' ');
return execa
.shell(`npm link ${pkgs}`)
.then(() => log('Succesfully linked'));
} | javascript | function linkPackages(pathToPkgs) {
const pkgs = pathToPkgs.join(' ');
return execa
.shell(`npm link ${pkgs}`)
.then(() => log('Succesfully linked'));
} | [
"function",
"linkPackages",
"(",
"pathToPkgs",
")",
"{",
"const",
"pkgs",
"=",
"pathToPkgs",
".",
"join",
"(",
"' '",
")",
";",
"return",
"execa",
".",
"shell",
"(",
"`",
"${",
"pkgs",
"}",
"`",
")",
".",
"then",
"(",
"(",
")",
"=>",
"log",
"(",
... | Execa functions link packages | [
"Execa",
"functions",
"link",
"packages"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L84-L89 | train |
DavideDaniel/npm-link-extra | lib/index.js | getSharedDepDirs | function getSharedDepDirs(pkgs, hash) {
return pkgs.map(({ name, dir }) => {
if (hash[name]) {
return dir;
}
return false;
}).filter(Boolean);
} | javascript | function getSharedDepDirs(pkgs, hash) {
return pkgs.map(({ name, dir }) => {
if (hash[name]) {
return dir;
}
return false;
}).filter(Boolean);
} | [
"function",
"getSharedDepDirs",
"(",
"pkgs",
",",
"hash",
")",
"{",
"return",
"pkgs",
".",
"map",
"(",
"(",
"{",
"name",
",",
"dir",
"}",
")",
"=>",
"{",
"if",
"(",
"hash",
"[",
"name",
"]",
")",
"{",
"return",
"dir",
";",
"}",
"return",
"false",... | getSharedDepDirs selects an array of shared and linked packages
@param {Array} pkgs An array of dependencies
@param {Object} hash A hash map of our deps
@return {Array} A filtered list of shared pkg dirs | [
"getSharedDepDirs",
"selects",
"an",
"array",
"of",
"shared",
"and",
"linked",
"packages"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L117-L124 | train |
DavideDaniel/npm-link-extra | lib/index.js | getSharedLinked | function getSharedLinked(pkgs, hash) {
return pkgs.map((name) => {
const module = hash[name];
if (module && module.isLinked) {
return name;
}
return false;
}).filter(Boolean);
} | javascript | function getSharedLinked(pkgs, hash) {
return pkgs.map((name) => {
const module = hash[name];
if (module && module.isLinked) {
return name;
}
return false;
}).filter(Boolean);
} | [
"function",
"getSharedLinked",
"(",
"pkgs",
",",
"hash",
")",
"{",
"return",
"pkgs",
".",
"map",
"(",
"(",
"name",
")",
"=>",
"{",
"const",
"module",
"=",
"hash",
"[",
"name",
"]",
";",
"if",
"(",
"module",
"&&",
"module",
".",
"isLinked",
")",
"{"... | getSharedLinked selects an array of shared and linked packages
@param {Array} pkgs An array of dependencies
@param {Object} hash A hash map of our deps
@return {Array} A filtered list of packages | [
"getSharedLinked",
"selects",
"an",
"array",
"of",
"shared",
"and",
"linked",
"packages"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L133-L141 | train |
DavideDaniel/npm-link-extra | lib/index.js | getSharedDeps | function getSharedDeps(pkgs, hash) {
return pkgs.map(({ name }) => {
if (hash[name]) {
return name;
}
return false;
}).filter(Boolean);
} | javascript | function getSharedDeps(pkgs, hash) {
return pkgs.map(({ name }) => {
if (hash[name]) {
return name;
}
return false;
}).filter(Boolean);
} | [
"function",
"getSharedDeps",
"(",
"pkgs",
",",
"hash",
")",
"{",
"return",
"pkgs",
".",
"map",
"(",
"(",
"{",
"name",
"}",
")",
"=>",
"{",
"if",
"(",
"hash",
"[",
"name",
"]",
")",
"{",
"return",
"name",
";",
"}",
"return",
"false",
";",
"}",
"... | getSharedDeps will show any shared dependencies between project & target dir
@param {Array} pkgs An array of dependencies
@param {Object} hash A hash map of our deps
@return {Array} Array of shared dep names | [
"getSharedDeps",
"will",
"show",
"any",
"shared",
"dependencies",
"between",
"project",
"&",
"target",
"dir"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L149-L156 | train |
DavideDaniel/npm-link-extra | lib/index.js | getLinkedDeps | function getLinkedDeps(pkgs) {
return pkgs.map((name) => {
const isLinked = checkForLink(name);
return isLinked ? name : false;
}).filter(Boolean);
} | javascript | function getLinkedDeps(pkgs) {
return pkgs.map((name) => {
const isLinked = checkForLink(name);
return isLinked ? name : false;
}).filter(Boolean);
} | [
"function",
"getLinkedDeps",
"(",
"pkgs",
")",
"{",
"return",
"pkgs",
".",
"map",
"(",
"(",
"name",
")",
"=>",
"{",
"const",
"isLinked",
"=",
"checkForLink",
"(",
"name",
")",
";",
"return",
"isLinked",
"?",
"name",
":",
"false",
";",
"}",
")",
".",
... | getLinkedDeps returns a list of linked dependencies
@param {Array} pkgs An array of dependencies
@return {Array} Array of linked dep names | [
"getLinkedDeps",
"returns",
"a",
"list",
"of",
"linked",
"dependencies"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L163-L168 | train |
DavideDaniel/npm-link-extra | lib/index.js | showLinkedDeps | function showLinkedDeps() {
const linkedDeps = getLinkedDeps(packageKeys, packageHash);
if (linkedDeps.length) {
logPkgsMsg('Linked', linkedDeps);
} else {
log('No linked dependencies found');
}
} | javascript | function showLinkedDeps() {
const linkedDeps = getLinkedDeps(packageKeys, packageHash);
if (linkedDeps.length) {
logPkgsMsg('Linked', linkedDeps);
} else {
log('No linked dependencies found');
}
} | [
"function",
"showLinkedDeps",
"(",
")",
"{",
"const",
"linkedDeps",
"=",
"getLinkedDeps",
"(",
"packageKeys",
",",
"packageHash",
")",
";",
"if",
"(",
"linkedDeps",
".",
"length",
")",
"{",
"logPkgsMsg",
"(",
"'Linked'",
",",
"linkedDeps",
")",
";",
"}",
"... | show all linked dependencies in your node_modules | [
"show",
"all",
"linked",
"dependencies",
"in",
"your",
"node_modules"
] | 049112dc145b4325052f4ddf0ceadfa1e206c154 | https://github.com/DavideDaniel/npm-link-extra/blob/049112dc145b4325052f4ddf0ceadfa1e206c154/lib/index.js#L203-L210 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/scayt/dialogs/options.js | function( option, list )
{
var label = doc.createElement( 'label' );
label.setAttribute( 'for', 'cke_option' + option );
label.setHtml( list[ option ] );
if ( dialog.sLang == option ) // Current.
dialog.chosed_lang = option;
var div = doc.createElement( 'div' );
var radio = CKEDITOR.... | javascript | function( option, list )
{
var label = doc.createElement( 'label' );
label.setAttribute( 'for', 'cke_option' + option );
label.setHtml( list[ option ] );
if ( dialog.sLang == option ) // Current.
dialog.chosed_lang = option;
var div = doc.createElement( 'div' );
var radio = CKEDITOR.... | [
"function",
"(",
"option",
",",
"list",
")",
"{",
"var",
"label",
"=",
"doc",
".",
"createElement",
"(",
"'label'",
")",
";",
"label",
".",
"setAttribute",
"(",
"'for'",
",",
"'cke_option'",
"+",
"option",
")",
";",
"label",
".",
"setHtml",
"(",
"list"... | Create languages tab. | [
"Create",
"languages",
"tab",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/scayt/dialogs/options.js#L262-L291 | train | |
Kurento/kurento-module-pointerdetector-js | lib/complexTypes/PointerDetectorWindowMediaParam.js | PointerDetectorWindowMediaParam | function PointerDetectorWindowMediaParam(pointerDetectorWindowMediaParamDict){
if(!(this instanceof PointerDetectorWindowMediaParam))
return new PointerDetectorWindowMediaParam(pointerDetectorWindowMediaParamDict)
pointerDetectorWindowMediaParamDict = pointerDetectorWindowMediaParamDict || {}
// Check point... | javascript | function PointerDetectorWindowMediaParam(pointerDetectorWindowMediaParamDict){
if(!(this instanceof PointerDetectorWindowMediaParam))
return new PointerDetectorWindowMediaParam(pointerDetectorWindowMediaParamDict)
pointerDetectorWindowMediaParamDict = pointerDetectorWindowMediaParamDict || {}
// Check point... | [
"function",
"PointerDetectorWindowMediaParam",
"(",
"pointerDetectorWindowMediaParamDict",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"PointerDetectorWindowMediaParam",
")",
")",
"return",
"new",
"PointerDetectorWindowMediaParam",
"(",
"pointerDetectorWindowMediaParam... | Data structure for UI Pointer detection in video streams.
All the coordinates are in pixels. X is horizontal, Y is vertical, running
from the top of the window. Thus, 0,0 corresponds to the topleft corner.
@constructor module:pointerdetector/complexTypes.PointerDetectorWindowMediaParam
@property {external:String} id
... | [
"Data",
"structure",
"for",
"UI",
"Pointer",
"detection",
"in",
"video",
"streams",
".",
"All",
"the",
"coordinates",
"are",
"in",
"pixels",
".",
"X",
"is",
"horizontal",
"Y",
"is",
"vertical",
"running",
"from",
"the",
"top",
"of",
"the",
"window",
".",
... | b5bce99fcd7087f12d14c39584edd6093099437e | https://github.com/Kurento/kurento-module-pointerdetector-js/blob/b5bce99fcd7087f12d14c39584edd6093099437e/lib/complexTypes/PointerDetectorWindowMediaParam.js#L55-L126 | train |
ohager/stappo | gulpfile.js | renderTemplate | function renderTemplate(impl, targetFile){
var stappoImpl = fs.readFileSync(impl, "utf8");
return gulp.src([targetFile])
.pipe(replace('/*__stappo_impl__*/', stappoImpl));
} | javascript | function renderTemplate(impl, targetFile){
var stappoImpl = fs.readFileSync(impl, "utf8");
return gulp.src([targetFile])
.pipe(replace('/*__stappo_impl__*/', stappoImpl));
} | [
"function",
"renderTemplate",
"(",
"impl",
",",
"targetFile",
")",
"{",
"var",
"stappoImpl",
"=",
"fs",
".",
"readFileSync",
"(",
"impl",
",",
"\"utf8\"",
")",
";",
"return",
"gulp",
".",
"src",
"(",
"[",
"targetFile",
"]",
")",
".",
"pipe",
"(",
"repl... | web-only implementation | [
"web",
"-",
"only",
"implementation"
] | 1e89154e003d99975eeb1ee6ab0d456aea58b7d1 | https://github.com/ohager/stappo/blob/1e89154e003d99975eeb1ee6ab0d456aea58b7d1/gulpfile.js#L17-L21 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser.js | function( html )
{
var parts,
tagName,
nextIndex = 0,
cdata; // The collected data inside a CDATA section.
while ( ( parts = this._.htmlPartsRegex.exec( html ) ) )
{
var tagIndex = parts.index;
if ( tagIndex > nextIndex )
{
var text = html.substring( nextIndex, tagIn... | javascript | function( html )
{
var parts,
tagName,
nextIndex = 0,
cdata; // The collected data inside a CDATA section.
while ( ( parts = this._.htmlPartsRegex.exec( html ) ) )
{
var tagIndex = parts.index;
if ( tagIndex > nextIndex )
{
var text = html.substring( nextIndex, tagIn... | [
"function",
"(",
"html",
")",
"{",
"var",
"parts",
",",
"tagName",
",",
"nextIndex",
"=",
"0",
",",
"cdata",
";",
"// The collected data inside a CDATA section.\r",
"while",
"(",
"(",
"parts",
"=",
"this",
".",
"_",
".",
"htmlPartsRegex",
".",
"exec",
"(",
... | Parses text, looking for HTML tokens, like tag openers or closers,
or comments. This function fires the onTagOpen, onTagClose, onText
and onComment function during its execution.
@param {String} html The HTML to be parsed.
@example
var parser = new CKEDITOR.htmlParser();
// The onTagOpen, onTagClose, onText and onComme... | [
"Parses",
"text",
"looking",
"for",
"HTML",
"tokens",
"like",
"tag",
"openers",
"or",
"closers",
"or",
"comments",
".",
"This",
"function",
"fires",
"the",
"onTagOpen",
"onTagClose",
"onText",
"and",
"onComment",
"function",
"during",
"its",
"execution",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser.js#L120-L222 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var cache = this._.cache;
if ( cache.startElement !== undefined )
return cache.startElement;
var node,
sel = this.getNative();
switch ( this.getType() )
{
case CKEDITOR.SELECTION_ELEMENT :
return this.getSelectedElement();
case CKEDITOR.SELECTION_TEXT ... | javascript | function()
{
var cache = this._.cache;
if ( cache.startElement !== undefined )
return cache.startElement;
var node,
sel = this.getNative();
switch ( this.getType() )
{
case CKEDITOR.SELECTION_ELEMENT :
return this.getSelectedElement();
case CKEDITOR.SELECTION_TEXT ... | [
"function",
"(",
")",
"{",
"var",
"cache",
"=",
"this",
".",
"_",
".",
"cache",
";",
"if",
"(",
"cache",
".",
"startElement",
"!==",
"undefined",
")",
"return",
"cache",
".",
"startElement",
";",
"var",
"node",
",",
"sel",
"=",
"this",
".",
"getNativ... | Gets the DOM element in which the selection starts.
@returns {CKEDITOR.dom.element} The element at the beginning of the
selection.
@example
var element = editor.getSelection().<strong>getStartElement()</strong>;
alert( element.getName() ); | [
"Gets",
"the",
"DOM",
"element",
"in",
"which",
"the",
"selection",
"starts",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1054-L1124 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var root,
retval,
range = self.getRanges()[ 0 ],
ancestor = range.getCommonAncestor( 1, 1 ),
tags = { table:1,ul:1,ol:1,dl:1 };
for ( var t in tags )
{
if ( root = ancestor.getAscendant( t, 1 ) )
break;
}
if ( root )
{... | javascript | function()
{
var root,
retval,
range = self.getRanges()[ 0 ],
ancestor = range.getCommonAncestor( 1, 1 ),
tags = { table:1,ul:1,ol:1,dl:1 };
for ( var t in tags )
{
if ( root = ancestor.getAscendant( t, 1 ) )
break;
}
if ( root )
{... | [
"function",
"(",
")",
"{",
"var",
"root",
",",
"retval",
",",
"range",
"=",
"self",
".",
"getRanges",
"(",
")",
"[",
"0",
"]",
",",
"ancestor",
"=",
"range",
".",
"getCommonAncestor",
"(",
"1",
",",
"1",
")",
",",
"tags",
"=",
"{",
"table",
":",
... | If a table or list is fully selected. | [
"If",
"a",
"table",
"or",
"list",
"is",
"fully",
"selected",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1150-L1216 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var ranges = this.getRanges(),
startNode = ranges[ 0 ].startContainer,
endNode = ranges[ ranges.length - 1 ].endContainer;
return startNode.getCommonAncestor( endNode );
} | javascript | function()
{
var ranges = this.getRanges(),
startNode = ranges[ 0 ].startContainer,
endNode = ranges[ ranges.length - 1 ].endContainer;
return startNode.getCommonAncestor( endNode );
} | [
"function",
"(",
")",
"{",
"var",
"ranges",
"=",
"this",
".",
"getRanges",
"(",
")",
",",
"startNode",
"=",
"ranges",
"[",
"0",
"]",
".",
"startContainer",
",",
"endNode",
"=",
"ranges",
"[",
"ranges",
".",
"length",
"-",
"1",
"]",
".",
"endContainer... | Retrieves the common ancestor node of the first range and the last range.
@returns {CKEDITOR.dom.element} The common ancestor of the selection.
@example
var ancestor = editor.getSelection().<strong>getCommonAncestor()</strong>; | [
"Retrieves",
"the",
"common",
"ancestor",
"node",
"of",
"the",
"first",
"range",
"and",
"the",
"last",
"range",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1577-L1583 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/entities/plugin.js | buildTable | function buildTable( entities, reverse )
{
var table = {},
regex = [];
// Entities that the browsers DOM don't transform to the final char
// automatically.
var specialTable =
{
nbsp : '\u00A0', // IE | FF
shy : '\u00AD', // IE
gt : '\u003E', // IE | FF | -- | Opera
... | javascript | function buildTable( entities, reverse )
{
var table = {},
regex = [];
// Entities that the browsers DOM don't transform to the final char
// automatically.
var specialTable =
{
nbsp : '\u00A0', // IE | FF
shy : '\u00AD', // IE
gt : '\u003E', // IE | FF | -- | Opera
... | [
"function",
"buildTable",
"(",
"entities",
",",
"reverse",
")",
"{",
"var",
"table",
"=",
"{",
"}",
",",
"regex",
"=",
"[",
"]",
";",
"// Entities that the browsers DOM don't transform to the final char\r",
"// automatically.\r",
"var",
"specialTable",
"=",
"{",
"nb... | Create a mapping table between one character and its entity form from a list of entity names.
@param reverse {Boolean} Whether to create a reverse map from the entity string form to an actual character. | [
"Create",
"a",
"mapping",
"table",
"between",
"one",
"character",
"and",
"its",
"entity",
"form",
"from",
"a",
"list",
"of",
"entity",
"names",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/entities/plugin.js#L52-L103 | train |
philmander/inverted | lib/inverted.js | function(config) {
this.config = config;
this.appContext = null;
this.injectAppContext = this.config.injectAppContext === true ? true : false;
//cache of loaded dependencies
this.moduleMap = {};
} | javascript | function(config) {
this.config = config;
this.appContext = null;
this.injectAppContext = this.config.injectAppContext === true ? true : false;
//cache of loaded dependencies
this.moduleMap = {};
} | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"appContext",
"=",
"null",
";",
"this",
".",
"injectAppContext",
"=",
"this",
".",
"config",
".",
"injectAppContext",
"===",
"true",
"?",
"true",
":",
"false",
... | Create a new ProtoFactory with config
@constructor
@param {Object} config | [
"Create",
"a",
"new",
"ProtoFactory",
"with",
"config"
] | af49a1ab2f501a19c457a8b41a40306e12103bf4 | https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/lib/inverted.js#L282-L291 | train | |
philmander/inverted | lib/inverted.js | function(config, protoFactory, originalModule) {
this.config = config;
this.protoFactory = protoFactory;
this.originalModule = originalModule || module;
//defines if circular dependencies should throw an error or be gracefully handled
this.allowCircular = this.config.allowCircular || false;
this.modules =... | javascript | function(config, protoFactory, originalModule) {
this.config = config;
this.protoFactory = protoFactory;
this.originalModule = originalModule || module;
//defines if circular dependencies should throw an error or be gracefully handled
this.allowCircular = this.config.allowCircular || false;
this.modules =... | [
"function",
"(",
"config",
",",
"protoFactory",
",",
"originalModule",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"protoFactory",
"=",
"protoFactory",
";",
"this",
".",
"originalModule",
"=",
"originalModule",
"||",
"module",
";",
"//d... | Create a new AppContext with config
@constructor
@param {Object} config
@param {Object} protoFactory
@param {Object} originalModule The original node module use to load node modules on the right path | [
"Create",
"a",
"new",
"AppContext",
"with",
"config"
] | af49a1ab2f501a19c457a8b41a40306e12103bf4 | https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/lib/inverted.js#L695-L712 | train | |
slideme/rorschach | lib/ConnectionState.js | ConnectionState | function ConnectionState(code, stringId, connected) {
if (arguments.length === 2) {
connected = stringId;
stringId = 'NONAME';
}
if (!(this instanceof ConnectionState)) {
return new ConnectionState(code, stringId, connected);
}
this.id = stringId;
this.code = code;
this.connected = connected;... | javascript | function ConnectionState(code, stringId, connected) {
if (arguments.length === 2) {
connected = stringId;
stringId = 'NONAME';
}
if (!(this instanceof ConnectionState)) {
return new ConnectionState(code, stringId, connected);
}
this.id = stringId;
this.code = code;
this.connected = connected;... | [
"function",
"ConnectionState",
"(",
"code",
",",
"stringId",
",",
"connected",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"connected",
"=",
"stringId",
";",
"stringId",
"=",
"'NONAME'",
";",
"}",
"if",
"(",
"!",
"(",
"this",... | Connection state.
@constructor
@param {Number} code
@param {String} stringId
@param {Boolean} connected | [
"Connection",
"state",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/ConnectionState.js#L12-L24 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser/element.js | function( obj )
{
var style = this.toString();
if ( style )
{
obj instanceof CKEDITOR.dom.element ?
obj.setAttribute( 'style', style ) :
obj instanceof CKEDITOR.htmlParser.element ?
obj.attributes.style = style :
obj.style = style;
}
} | javascript | function( obj )
{
var style = this.toString();
if ( style )
{
obj instanceof CKEDITOR.dom.element ?
obj.setAttribute( 'style', style ) :
obj instanceof CKEDITOR.htmlParser.element ?
obj.attributes.style = style :
obj.style = style;
}
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"style",
"=",
"this",
".",
"toString",
"(",
")",
";",
"if",
"(",
"style",
")",
"{",
"obj",
"instanceof",
"CKEDITOR",
".",
"dom",
".",
"element",
"?",
"obj",
".",
"setAttribute",
"(",
"'style'",
",",
"style",
... | Apply the styles onto the specified element or object.
@param {CKEDITOR.htmlParser.element|CKEDITOR.dom.element|Object} obj | [
"Apply",
"the",
"styles",
"onto",
"the",
"specified",
"element",
"or",
"object",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/element.js#L95-L106 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/clipboard/plugin.js | function( event )
{
if ( this.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode )
{
// Paste
case CKEDITOR.CTRL + 86 : // CTRL+V
case CKEDITOR.SHIFT + 45 : // SHIFT+INS
var body = this.document.getBody();
// Simulate 'beforepaste' event for all none-IEs.
if ( !CKE... | javascript | function( event )
{
if ( this.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode )
{
// Paste
case CKEDITOR.CTRL + 86 : // CTRL+V
case CKEDITOR.SHIFT + 45 : // SHIFT+INS
var body = this.document.getBody();
// Simulate 'beforepaste' event for all none-IEs.
if ( !CKE... | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"mode",
"!=",
"'wysiwyg'",
")",
"return",
";",
"switch",
"(",
"event",
".",
"data",
".",
"keyCode",
")",
"{",
"// Paste\r",
"case",
"CKEDITOR",
".",
"CTRL",
"+",
"86",
":",
"// CTRL+V\r",
"c... | Listens for some clipboard related keystrokes, so they get customized. | [
"Listens",
"for",
"some",
"clipboard",
"related",
"keystrokes",
"so",
"they",
"get",
"customized",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/clipboard/plugin.js#L125-L159 | train | |
hitsujiwool/node-holiday-jp | index.js | function(start, end) {
var date;
var res = [];
for (var key in holidays) {
date = beginningOfDay(new Date(key));
// given `start` and `end` Date object are both normalized to beginning of the day
if (beginningOfDay(start) <= date && date <= beginningOfDay(end)) {
res.push(holiday(d... | javascript | function(start, end) {
var date;
var res = [];
for (var key in holidays) {
date = beginningOfDay(new Date(key));
// given `start` and `end` Date object are both normalized to beginning of the day
if (beginningOfDay(start) <= date && date <= beginningOfDay(end)) {
res.push(holiday(d... | [
"function",
"(",
"start",
",",
"end",
")",
"{",
"var",
"date",
";",
"var",
"res",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"holidays",
")",
"{",
"date",
"=",
"beginningOfDay",
"(",
"new",
"Date",
"(",
"key",
")",
")",
";",
"// given `s... | Find holidays between `start` and `end`.
@param {Date} start
@param {Date} end
@return {Array[Object]}
@api public | [
"Find",
"holidays",
"between",
"start",
"and",
"end",
"."
] | d5d397ddd3a443ce0210ba05dc46a01b0668378d | https://github.com/hitsujiwool/node-holiday-jp/blob/d5d397ddd3a443ce0210ba05dc46a01b0668378d/index.js#L28-L39 | train | |
saggiyogesh/nodeportal | lib/Router.js | Route | function Route(method, route, fn) {
this.method = method;
this.route = route;
this.fn = fn;
return function (app) {
var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
utils.getRequestMiddlewares();
if (method == "get") {
app.ge... | javascript | function Route(method, route, fn) {
this.method = method;
this.route = route;
this.fn = fn;
return function (app) {
var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
utils.getRequestMiddlewares();
if (method == "get") {
app.ge... | [
"function",
"Route",
"(",
"method",
",",
"route",
",",
"fn",
")",
"{",
"this",
".",
"method",
"=",
"method",
";",
"this",
".",
"route",
"=",
"route",
";",
"this",
".",
"fn",
"=",
"fn",
";",
"return",
"function",
"(",
"app",
")",
"{",
"var",
"midd... | Returns a fn, which return the express route object
@param method
@param route
@param fn | [
"Returns",
"a",
"fn",
"which",
"return",
"the",
"express",
"route",
"object"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Router.js#L35-L53 | train |
cloud9ide/frontdoor | lib/route.js | normalizePath | function normalizePath(path, keys, params) {
for (var name in params) {
var param = params[name];
if (typeof param == "string" || param instanceof RegExp)
params[name] = {type: param};
}
path = path
.concat("/?")
.replace(/\/:([\w.... | javascript | function normalizePath(path, keys, params) {
for (var name in params) {
var param = params[name];
if (typeof param == "string" || param instanceof RegExp)
params[name] = {type: param};
}
path = path
.concat("/?")
.replace(/\/:([\w.... | [
"function",
"normalizePath",
"(",
"path",
",",
"keys",
",",
"params",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"params",
")",
"{",
"var",
"param",
"=",
"params",
"[",
"name",
"]",
";",
"if",
"(",
"typeof",
"param",
"==",
"\"string\"",
"||",
"param"... | Creates a rgular expression to match this route.
Url param names are stored in `keys` and the `params` are completed with
the default values for url parameters. | [
"Creates",
"a",
"rgular",
"expression",
"to",
"match",
"this",
"route",
".",
"Url",
"param",
"names",
"are",
"stored",
"in",
"keys",
"and",
"the",
"params",
"are",
"completed",
"with",
"the",
"default",
"values",
"for",
"url",
"parameters",
"."
] | d29907494ef2259235b7f331dd7e225b5c186cd6 | https://github.com/cloud9ide/frontdoor/blob/d29907494ef2259235b7f331dd7e225b5c186cd6/lib/route.js#L54-L89 | train |
dominictarr/web-bootloader | bootloader.js | function (target, cb) {
if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
var cleared = 0, remove = []
function clear () {
var n = remove.length
while(remove.length) store.rm(remove.shift(), function () {
if(--n) return
if(clea... | javascript | function (target, cb) {
if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
var cleared = 0, remove = []
function clear () {
var n = remove.length
while(remove.length) store.rm(remove.shift(), function () {
if(--n) return
if(clea... | [
"function",
"(",
"target",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"target",
")",
"return",
"cb",
"(",
"new",
"Error",
"(",
"'WebBoot.prune: size to clear must be provided'",
")",
")",
"var",
"cleared",
"=",
"0",
",",
"remove",
"=",
"[",
"]",
"function",
"c... | clear target amount of space. | [
"clear",
"target",
"amount",
"of",
"space",
"."
] | de995bc3e41ba4db94a6de41388dfe676ed37a7e | https://github.com/dominictarr/web-bootloader/blob/de995bc3e41ba4db94a6de41388dfe676ed37a7e/bootloader.js#L108-L152 | train | |
jhermsmeier/node-speech | lib/distance/dice.js | dice | function dice( source, target ) {
var sources = dice.prepare( source )
var targets = dice.prepare( target )
var i, k, intersection = 0
var source_count = sources.length
var target_count = targets.length
var union = source_count + target_count
for( i = 0; i < source_count; i++ ) {
source = sou... | javascript | function dice( source, target ) {
var sources = dice.prepare( source )
var targets = dice.prepare( target )
var i, k, intersection = 0
var source_count = sources.length
var target_count = targets.length
var union = source_count + target_count
for( i = 0; i < source_count; i++ ) {
source = sou... | [
"function",
"dice",
"(",
"source",
",",
"target",
")",
"{",
"var",
"sources",
"=",
"dice",
".",
"prepare",
"(",
"source",
")",
"var",
"targets",
"=",
"dice",
".",
"prepare",
"(",
"target",
")",
"var",
"i",
",",
"k",
",",
"intersection",
"=",
"0",
"... | Computes dice's coefficient.
@param {String} source
@param {String} target
@return {Number} dice coefficient | [
"Computes",
"dice",
"s",
"coefficient",
"."
] | 984c4dd6e2fe640c01267f10e3804ef81391e73a | https://github.com/jhermsmeier/node-speech/blob/984c4dd6e2fe640c01267f10e3804ef81391e73a/lib/distance/dice.js#L9-L33 | train |
reklatsmasters/unicast | lib/create-socket.js | createSocket | function createSocket(socket, options = {}) {
if (!isSocket(socket)) {
options = socket; // eslint-disable-line no-param-reassign
if (isSocket(options.socket)) {
// eslint-disable-next-line no-param-reassign, prefer-destructuring
socket = options.socket;
} else {
socket = dgram.createSo... | javascript | function createSocket(socket, options = {}) {
if (!isSocket(socket)) {
options = socket; // eslint-disable-line no-param-reassign
if (isSocket(options.socket)) {
// eslint-disable-next-line no-param-reassign, prefer-destructuring
socket = options.socket;
} else {
socket = dgram.createSo... | [
"function",
"createSocket",
"(",
"socket",
",",
"options",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"isSocket",
"(",
"socket",
")",
")",
"{",
"options",
"=",
"socket",
";",
"// eslint-disable-line no-param-reassign",
"if",
"(",
"isSocket",
"(",
"options",
... | Create a new UDP unicast socket.
@param {dgram.Socket|string|object} socket
@param {object} [options]
@return {Socket} | [
"Create",
"a",
"new",
"UDP",
"unicast",
"socket",
"."
] | fe83eb884bcd8687e50a4b5163a5af584d32444b | https://github.com/reklatsmasters/unicast/blob/fe83eb884bcd8687e50a4b5163a5af584d32444b/lib/create-socket.js#L16-L30 | train |
levilindsey/physx | src/collisions/contact-calculation/src/sphere-contact-calculation.js | sphereVsAabb | function sphereVsAabb(contactPoint, contactNormal, sphere, aabb) {
findClosestPointFromAabbSurfaceToPoint(contactPoint, aabb, sphere.centerOfVolume);
findAabbNormalFromContactPoint(contactNormal, contactPoint, aabb);
vec3.negate(contactNormal, contactNormal);
} | javascript | function sphereVsAabb(contactPoint, contactNormal, sphere, aabb) {
findClosestPointFromAabbSurfaceToPoint(contactPoint, aabb, sphere.centerOfVolume);
findAabbNormalFromContactPoint(contactNormal, contactPoint, aabb);
vec3.negate(contactNormal, contactNormal);
} | [
"function",
"sphereVsAabb",
"(",
"contactPoint",
",",
"contactNormal",
",",
"sphere",
",",
"aabb",
")",
"{",
"findClosestPointFromAabbSurfaceToPoint",
"(",
"contactPoint",
",",
"aabb",
",",
"sphere",
".",
"centerOfVolume",
")",
";",
"findAabbNormalFromContactPoint",
"... | Finds the closest point on the surface of the AABB to the sphere center.
@param {vec3} contactPoint Output param.
@param {vec3} contactNormal Output param.
@param {Sphere} sphere
@param {Aabb} aabb | [
"Finds",
"the",
"closest",
"point",
"on",
"the",
"surface",
"of",
"the",
"AABB",
"to",
"the",
"sphere",
"center",
"."
] | 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/contact-calculation/src/sphere-contact-calculation.js#L48-L52 | train |
imcuttle/tiny-i18n | packages/react-live/src/index.js | argsGetter | function argsGetter(args, lang) {
return args.map(arg =>
rStrip(
String(arg),
(s, a, b, c, count) => {
const data = JSON.parse(s)
return toWrappedString(translatedGetter(data[0], () => data.slice(1), lang), void 0, count)
... | javascript | function argsGetter(args, lang) {
return args.map(arg =>
rStrip(
String(arg),
(s, a, b, c, count) => {
const data = JSON.parse(s)
return toWrappedString(translatedGetter(data[0], () => data.slice(1), lang), void 0, count)
... | [
"function",
"argsGetter",
"(",
"args",
",",
"lang",
")",
"{",
"return",
"args",
".",
"map",
"(",
"arg",
"=>",
"rStrip",
"(",
"String",
"(",
"arg",
")",
",",
"(",
"s",
",",
"a",
",",
"b",
",",
"c",
",",
"count",
")",
"=>",
"{",
"const",
"data",
... | Strips the outermost wrapper | [
"Strips",
"the",
"outermost",
"wrapper"
] | 2b37e4a189918d9e8cd0c9cecb41940c9257e8cb | https://github.com/imcuttle/tiny-i18n/blob/2b37e4a189918d9e8cd0c9cecb41940c9257e8cb/packages/react-live/src/index.js#L91-L102 | train |
mitchwinn/gulp-serve-iis-express | lib/index.js | startSites | function startSites(config){
config.siteNames.forEach(function(item){
var cmd = 'iisexpress /site:"' + item + '"';
if(config.configFile !== ""){
cmd += ' /config:"' + config.configFile + '"';
}
if (config.sysTray){
cmd += ' /syst... | javascript | function startSites(config){
config.siteNames.forEach(function(item){
var cmd = 'iisexpress /site:"' + item + '"';
if(config.configFile !== ""){
cmd += ' /config:"' + config.configFile + '"';
}
if (config.sysTray){
cmd += ' /syst... | [
"function",
"startSites",
"(",
"config",
")",
"{",
"config",
".",
"siteNames",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"cmd",
"=",
"'iisexpress /site:\"'",
"+",
"item",
"+",
"'\"'",
";",
"if",
"(",
"config",
".",
"configFile",
"!==... | starting the sites. | [
"starting",
"the",
"sites",
"."
] | 34e00e8c8a717e82e8b2cd69a98deec1daf41b51 | https://github.com/mitchwinn/gulp-serve-iis-express/blob/34e00e8c8a717e82e8b2cd69a98deec1daf41b51/lib/index.js#L98-L122 | train |
kaelzhang/node-semver-extra | index.js | maxPrerelease | function maxPrerelease (versions, prerelease) {
return first(desc(versions), function (version) {
return isPrerelease(version, prerelease);
});
} | javascript | function maxPrerelease (versions, prerelease) {
return first(desc(versions), function (version) {
return isPrerelease(version, prerelease);
});
} | [
"function",
"maxPrerelease",
"(",
"versions",
",",
"prerelease",
")",
"{",
"return",
"first",
"(",
"desc",
"(",
"versions",
")",
",",
"function",
"(",
"version",
")",
"{",
"return",
"isPrerelease",
"(",
"version",
",",
"prerelease",
")",
";",
"}",
")",
"... | Returns the max prerelease version of the maximun matched prerelease version | [
"Returns",
"the",
"max",
"prerelease",
"version",
"of",
"the",
"maximun",
"matched",
"prerelease",
"version"
] | eb249cfe9c7d32c8141481314d37bd02d619bfd9 | https://github.com/kaelzhang/node-semver-extra/blob/eb249cfe9c7d32c8141481314d37bd02d619bfd9/index.js#L49-L53 | train |
kaelzhang/node-semver-extra | index.js | first | function first (array, filter) {
var i = 0;
var length = array.length;
var item;
for (; i < length; i ++) {
item = array[i];
if (filter(item)) {
return item;
}
}
return null;
} | javascript | function first (array, filter) {
var i = 0;
var length = array.length;
var item;
for (; i < length; i ++) {
item = array[i];
if (filter(item)) {
return item;
}
}
return null;
} | [
"function",
"first",
"(",
"array",
",",
"filter",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"length",
"=",
"array",
".",
"length",
";",
"var",
"item",
";",
"for",
"(",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"array",
... | Returns the first matched array item | [
"Returns",
"the",
"first",
"matched",
"array",
"item"
] | eb249cfe9c7d32c8141481314d37bd02d619bfd9 | https://github.com/kaelzhang/node-semver-extra/blob/eb249cfe9c7d32c8141481314d37bd02d619bfd9/index.js#L66-L78 | train |
creationix/git-node | examples/create.js | serialEach | function serialEach(object, fn, callback) {
var keys = Object.keys(object);
next();
function next(err) {
if (err) return callback(err);
var key = keys.shift();
if (!key) return callback();
fn(key, object[key], next);
}
} | javascript | function serialEach(object, fn, callback) {
var keys = Object.keys(object);
next();
function next(err) {
if (err) return callback(err);
var key = keys.shift();
if (!key) return callback();
fn(key, object[key], next);
}
} | [
"function",
"serialEach",
"(",
"object",
",",
"fn",
",",
"callback",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
";",
"next",
"(",
")",
";",
"function",
"next",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"... | Mini control-flow library | [
"Mini",
"control",
"-",
"flow",
"library"
] | 74d927d0168ce1592303ac2f030e2ee6314ad6c6 | https://github.com/creationix/git-node/blob/74d927d0168ce1592303ac2f030e2ee6314ad6c6/examples/create.js#L51-L60 | train |
saggiyogesh/nodeportal | lib/permissions/Cache.js | CacheItem | function CacheItem(permissionSchemaKey, actionsValue, permissions) {
if (!actionsValue) {
if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
throw new Error("Invalid permissions schema key.")
}
else {
var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[... | javascript | function CacheItem(permissionSchemaKey, actionsValue, permissions) {
if (!actionsValue) {
if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
throw new Error("Invalid permissions schema key.")
}
else {
var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[... | [
"function",
"CacheItem",
"(",
"permissionSchemaKey",
",",
"actionsValue",
",",
"permissions",
")",
"{",
"if",
"(",
"!",
"actionsValue",
")",
"{",
"if",
"(",
"!",
"utils",
".",
"contains",
"(",
"permissionSchemaKey",
",",
"TRIPLE_UNDERSCORE",
")",
")",
"{",
"... | Constructor to create cache item
@param permissionSchemaKey {String} unique key
@param actionsValue {Object} Object to Action key with value
@param permissions {Object} Object having array of permissions to each role.
@constructor | [
"Constructor",
"to",
"create",
"cache",
"item"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/permissions/Cache.js#L21-L82 | train |
saggiyogesh/nodeportal | lib/permissions/Cache.js | storeModel | function storeModel(model, permissionSchemaKey) {
if (model && model.rolePermissions) {
var obj = {
permissionSchemaKey: permissionSchemaKey,
rolePermissions: model.rolePermissions
};
exports.store(obj);
}
} | javascript | function storeModel(model, permissionSchemaKey) {
if (model && model.rolePermissions) {
var obj = {
permissionSchemaKey: permissionSchemaKey,
rolePermissions: model.rolePermissions
};
exports.store(obj);
}
} | [
"function",
"storeModel",
"(",
"model",
",",
"permissionSchemaKey",
")",
"{",
"if",
"(",
"model",
"&&",
"model",
".",
"rolePermissions",
")",
"{",
"var",
"obj",
"=",
"{",
"permissionSchemaKey",
":",
"permissionSchemaKey",
",",
"rolePermissions",
":",
"model",
... | Method storing model's role permissions to cache
@param model {Object}
@param permissionSchemaKey {String} | [
"Method",
"storing",
"model",
"s",
"role",
"permissions",
"to",
"cache"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/permissions/Cache.js#L89-L97 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/stylescombo/plugin.js | function()
{
if ( combo )
{
delete combo._.panel;
delete combo._.list;
combo._.committed = 0;
combo._.items = {};
combo._.state = CKEDITOR.TRISTATE_OFF;
}
styles = {};
stylesList = [];
loadStylesSet();
} | javascript | function()
{
if ( combo )
{
delete combo._.panel;
delete combo._.list;
combo._.committed = 0;
combo._.items = {};
combo._.state = CKEDITOR.TRISTATE_OFF;
}
styles = {};
stylesList = [];
loadStylesSet();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"combo",
")",
"{",
"delete",
"combo",
".",
"_",
".",
"panel",
";",
"delete",
"combo",
".",
"_",
".",
"list",
";",
"combo",
".",
"_",
".",
"committed",
"=",
"0",
";",
"combo",
".",
"_",
".",
"items",
"=",
... | Force a reload of the data | [
"Force",
"a",
"reload",
"of",
"the",
"data"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/stylescombo/plugin.js#L187-L200 | train | |
azu/spellcheck-technical-word | lib/spellcheck-technical-word.js | spellCheckText | function spellCheckText(text) {
var src = new StructuredSource(text);
var results = [];
for (var i = 0, length = dictionaryItems.length; i < length; i++) {
var dictionary = dictionaryItems[i];
var query = new RegExp(dictionary.pattern, dictionary.flag);
var match = query.exec(text);
... | javascript | function spellCheckText(text) {
var src = new StructuredSource(text);
var results = [];
for (var i = 0, length = dictionaryItems.length; i < length; i++) {
var dictionary = dictionaryItems[i];
var query = new RegExp(dictionary.pattern, dictionary.flag);
var match = query.exec(text);
... | [
"function",
"spellCheckText",
"(",
"text",
")",
"{",
"var",
"src",
"=",
"new",
"StructuredSource",
"(",
"text",
")",
";",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"dictionaryItems",
".",
"length",
";... | spell check the text, then return array of result.
@param {string} text
@returns {SpellCheckResult[]} | [
"spell",
"check",
"the",
"text",
"then",
"return",
"array",
"of",
"result",
"."
] | 11aad9e2f89c6cccc0e9387669ce56c83366e204 | https://github.com/azu/spellcheck-technical-word/blob/11aad9e2f89c6cccc0e9387669ce56c83366e204/lib/spellcheck-technical-word.js#L9-L54 | train |
saggiyogesh/nodeportal | lib/Renderer/SettingsErrorRenderer.js | SettingsErrorRenderer | function SettingsErrorRenderer(err, req, res) {
SettingsRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | javascript | function SettingsErrorRenderer(err, req, res) {
SettingsRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | [
"function",
"SettingsErrorRenderer",
"(",
"err",
",",
"req",
",",
"res",
")",
"{",
"SettingsRenderer",
".",
"call",
"(",
"this",
",",
"req",
",",
"res",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"err",
":",
"{",
"value",
":",
... | Constructor to create SettingsErrorRenderer
@param err
@param req
@param res
@constructor | [
"Constructor",
"to",
"create",
"SettingsErrorRenderer"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Renderer/SettingsErrorRenderer.js#L15-L23 | train |
jchook/virtual-dom-handlebars | lib/Template.js | reset | function reset(html) {
this.html = html || this.html;
this.root = new VNode('div');
this.node = this.root; // current working node
this.path = []; // current working node parents
this.blocks = []; // recursive components
} | javascript | function reset(html) {
this.html = html || this.html;
this.root = new VNode('div');
this.node = this.root; // current working node
this.path = []; // current working node parents
this.blocks = []; // recursive components
} | [
"function",
"reset",
"(",
"html",
")",
"{",
"this",
".",
"html",
"=",
"html",
"||",
"this",
".",
"html",
";",
"this",
".",
"root",
"=",
"new",
"VNode",
"(",
"'div'",
")",
";",
"this",
".",
"node",
"=",
"this",
".",
"root",
";",
"// current working ... | Update the HTML | [
"Update",
"the",
"HTML"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L87-L93 | train |
jchook/virtual-dom-handlebars | lib/Template.js | push | function push() {
this.path.push(this.node);
this.node = this.node.children[this.node.children.length - 1];
} | javascript | function push() {
this.path.push(this.node);
this.node = this.node.children[this.node.children.length - 1];
} | [
"function",
"push",
"(",
")",
"{",
"this",
".",
"path",
".",
"push",
"(",
"this",
".",
"node",
")",
";",
"this",
".",
"node",
"=",
"this",
".",
"node",
".",
"children",
"[",
"this",
".",
"node",
".",
"children",
".",
"length",
"-",
"1",
"]",
";... | Move cursor to the latest child of the current node | [
"Move",
"cursor",
"to",
"the",
"latest",
"child",
"of",
"the",
"current",
"node"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L113-L116 | train |
jchook/virtual-dom-handlebars | lib/Template.js | ontext | function ontext(template, text, config) {
var
blockStubPos = -1,
cursor = 0,
children = null,
nodes = []
;
config = extend({virtual: template.virtual}, config);
// Ensures that consecutive textOnly components are merged into a single VText node
function concatText(text) {
if ((nodes.length > 0) && nod... | javascript | function ontext(template, text, config) {
var
blockStubPos = -1,
cursor = 0,
children = null,
nodes = []
;
config = extend({virtual: template.virtual}, config);
// Ensures that consecutive textOnly components are merged into a single VText node
function concatText(text) {
if ((nodes.length > 0) && nod... | [
"function",
"ontext",
"(",
"template",
",",
"text",
",",
"config",
")",
"{",
"var",
"blockStubPos",
"=",
"-",
"1",
",",
"cursor",
"=",
"0",
",",
"children",
"=",
"null",
",",
"nodes",
"=",
"[",
"]",
";",
"config",
"=",
"extend",
"(",
"{",
"virtual"... | ontext helper for html parsing ensure that blocks are handled | [
"ontext",
"helper",
"for",
"html",
"parsing",
"ensure",
"that",
"blocks",
"are",
"handled"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L132-L195 | train |
jchook/virtual-dom-handlebars | lib/Template.js | concatText | function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
} | javascript | function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
} | [
"function",
"concatText",
"(",
"text",
")",
"{",
"if",
"(",
"(",
"nodes",
".",
"length",
">",
"0",
")",
"&&",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".",
"addText",
")",
"{",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".... | Ensures that consecutive textOnly components are merged into a single VText node | [
"Ensures",
"that",
"consecutive",
"textOnly",
"components",
"are",
"merged",
"into",
"a",
"single",
"VText",
"node"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L143-L149 | train |
jchook/virtual-dom-handlebars | lib/Template.js | attributesToJavascript | function attributesToJavascript(template, attr) {
var i, name, value, js = [];
for (i in attr) {
if (attr.hasOwnProperty(i)) {
// Translate
name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;
// Potentially interpolated attributes
if (typeof attr[i] === 'string') {
if (attr[i].le... | javascript | function attributesToJavascript(template, attr) {
var i, name, value, js = [];
for (i in attr) {
if (attr.hasOwnProperty(i)) {
// Translate
name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;
// Potentially interpolated attributes
if (typeof attr[i] === 'string') {
if (attr[i].le... | [
"function",
"attributesToJavascript",
"(",
"template",
",",
"attr",
")",
"{",
"var",
"i",
",",
"name",
",",
"value",
",",
"js",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"in",
"attr",
")",
"{",
"if",
"(",
"attr",
".",
"hasOwnProperty",
"(",
"i",
")",
... | Not particularly proud of this function.. obv it should probably be located in some kind of AttributeList class or something, but as it stands, the use of htmlparser2 requires a more 'aware' parser to do proper block parsing | [
"Not",
"particularly",
"proud",
"of",
"this",
"function",
"..",
"obv",
"it",
"should",
"probably",
"be",
"located",
"in",
"some",
"kind",
"of",
"AttributeList",
"class",
"or",
"something",
"but",
"as",
"it",
"stands",
"the",
"use",
"of",
"htmlparser2",
"requ... | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L201-L223 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var dialog = this.getDialog(),
popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),
targetName = dialog.getContentElement( 'target', 'linkTargetName' ),
value = this.getValue();
if ( !popupFeatures || !targetName )
return;
popupFeatures = popupFeatures.getEl... | javascript | function()
{
var dialog = this.getDialog(),
popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),
targetName = dialog.getContentElement( 'target', 'linkTargetName' ),
value = this.getValue();
if ( !popupFeatures || !targetName )
return;
popupFeatures = popupFeatures.getEl... | [
"function",
"(",
")",
"{",
"var",
"dialog",
"=",
"this",
".",
"getDialog",
"(",
")",
",",
"popupFeatures",
"=",
"dialog",
".",
"getContentElement",
"(",
"'target'",
",",
"'popupFeatures'",
")",
",",
"targetName",
"=",
"dialog",
".",
"getContentElement",
"(",... | Handles the event when the "Target" selection box is changed. | [
"Handles",
"the",
"event",
"when",
"the",
"Target",
"selection",
"box",
"is",
"changed",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L10-L41 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var dialog = this.getDialog(),
partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
typeValue = this.getValue(),
uploadTab = dialog.definition.getContents( 'upload' ),
uploadInitiallyHidden = uploadTab && uploadTab.hidden;
if ( typeValue == 'url' )
{
if ( editor.con... | javascript | function()
{
var dialog = this.getDialog(),
partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
typeValue = this.getValue(),
uploadTab = dialog.definition.getContents( 'upload' ),
uploadInitiallyHidden = uploadTab && uploadTab.hidden;
if ( typeValue == 'url' )
{
if ( editor.con... | [
"function",
"(",
")",
"{",
"var",
"dialog",
"=",
"this",
".",
"getDialog",
"(",
")",
",",
"partIds",
"=",
"[",
"'urlOptions'",
",",
"'anchorOptions'",
",",
"'emailOptions'",
"]",
",",
"typeValue",
"=",
"this",
".",
"getValue",
"(",
")",
",",
"uploadTab",... | Handles the event when the "Type" selection box is changed. | [
"Handles",
"the",
"event",
"when",
"the",
"Type",
"selection",
"box",
"is",
"changed",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L44-L80 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var linkType = this.getContentElement( 'info', 'linkType' ),
urlField;
if ( linkType && linkType.getValue() == 'url' )
{
urlField = this.getContentElement( 'info', 'url' );
urlField.select();
}
} | javascript | function()
{
var linkType = this.getContentElement( 'info', 'linkType' ),
urlField;
if ( linkType && linkType.getValue() == 'url' )
{
urlField = this.getContentElement( 'info', 'url' );
urlField.select();
}
} | [
"function",
"(",
")",
"{",
"var",
"linkType",
"=",
"this",
".",
"getContentElement",
"(",
"'info'",
",",
"'linkType'",
")",
",",
"urlField",
";",
"if",
"(",
"linkType",
"&&",
"linkType",
".",
"getValue",
"(",
")",
"==",
"'url'",
")",
"{",
"urlField",
"... | Inital focus on 'url' field if link is of type URL. | [
"Inital",
"focus",
"on",
"url",
"field",
"if",
"link",
"is",
"of",
"type",
"URL",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L1388-L1397 | train | |
mdreizin/webpack-config-stream | lib/failAfterStream.js | failAfterStream | function failAfterStream(options) {
if (!_.isObject(options)) {
options = {};
}
var files = [];
return through.obj(function(chunk, enc, cb) {
var stats = chunk[processStats.STATS_DATA_FIELD_NAME],
isStats = chunk[processStats.STATS_FLAG_FIELD_NAME],
filename = p... | javascript | function failAfterStream(options) {
if (!_.isObject(options)) {
options = {};
}
var files = [];
return through.obj(function(chunk, enc, cb) {
var stats = chunk[processStats.STATS_DATA_FIELD_NAME],
isStats = chunk[processStats.STATS_FLAG_FIELD_NAME],
filename = p... | [
"function",
"failAfterStream",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"files",
"=",
"[",
"]",
";",
"return",
"through",
".",
"obj",
"(",
"function",
... | Stops a task if some `stats` objects have some errors or warnings. Can be piped.
@function
@alias failAfterStream
@param {Object=} options - Options.
@param {Boolean} [options.errors=false] - Fails build if some `stats` objects have some errors.
@param {Boolean} [options.warnings=false] - Fails build if some `stats` ob... | [
"Stops",
"a",
"task",
"if",
"some",
"stats",
"objects",
"have",
"some",
"errors",
"or",
"warnings",
".",
"Can",
"be",
"piped",
"."
] | f8424f97837a224bc07cc18a03ecf649d708e924 | https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/failAfterStream.js#L40-L82 | train |
campsi/campsi | lib/modules/sortCursor.js | getMongoSortArray | function getMongoSortArray (field, prefix) {
return (!field.startsWith('-'))
? [prefix + field, 1]
: [prefix + field.substr(1), -1];
} | javascript | function getMongoSortArray (field, prefix) {
return (!field.startsWith('-'))
? [prefix + field, 1]
: [prefix + field.substr(1), -1];
} | [
"function",
"getMongoSortArray",
"(",
"field",
",",
"prefix",
")",
"{",
"return",
"(",
"!",
"field",
".",
"startsWith",
"(",
"'-'",
")",
")",
"?",
"[",
"prefix",
"+",
"field",
",",
"1",
"]",
":",
"[",
"prefix",
"+",
"field",
".",
"substr",
"(",
"1"... | flips sorting order if field begins with minus '-'
@param {String} field
@param {String} prefix
@returns {Array<Array>} | [
"flips",
"sorting",
"order",
"if",
"field",
"begins",
"with",
"minus",
"-"
] | 65ff16d267ea7e60bbb9e8959e6805e009202d2c | https://github.com/campsi/campsi/blob/65ff16d267ea7e60bbb9e8959e6805e009202d2c/lib/modules/sortCursor.js#L7-L11 | train |
elwayman02/ember-cli-opinionated | blueprints/ember-cli-opinionated/index.js | function () {
var packages = [
'ember-cli-autoprefixer',
'ember-cli-blanket',
'ember-cli-sass',
'ember-cpm',
'ember-feature-flags',
'ember-metrics',
'ember-moment',
'ember-responsive',
'ember-route-action-helper',
'ember-suave',
'ember-truth-helpers'... | javascript | function () {
var packages = [
'ember-cli-autoprefixer',
'ember-cli-blanket',
'ember-cli-sass',
'ember-cpm',
'ember-feature-flags',
'ember-metrics',
'ember-moment',
'ember-responsive',
'ember-route-action-helper',
'ember-suave',
'ember-truth-helpers'... | [
"function",
"(",
")",
"{",
"var",
"packages",
"=",
"[",
"'ember-cli-autoprefixer'",
",",
"'ember-cli-blanket'",
",",
"'ember-cli-sass'",
",",
"'ember-cpm'",
",",
"'ember-feature-flags'",
",",
"'ember-metrics'",
",",
"'ember-moment'",
",",
"'ember-responsive'",
",",
"'... | no-op since we're just adding dependencies | [
"no",
"-",
"op",
"since",
"we",
"re",
"just",
"adding",
"dependencies"
] | ceb7d0c0fb56406c09009c372dc018e89842c32b | https://github.com/elwayman02/ember-cli-opinionated/blob/ceb7d0c0fb56406c09009c372dc018e89842c32b/blueprints/ember-cli-opinionated/index.js#L10-L46 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/elementpath.js | function( element )
{
var childNodes = element.getChildren();
for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
{
var child = childNodes.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
return true;
}
return false;
} | javascript | function( element )
{
var childNodes = element.getChildren();
for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
{
var child = childNodes.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
return true;
}
return false;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"childNodes",
"=",
"element",
".",
"getChildren",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"childNodes",
".",
"count",
"(",
")",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
... | Check if an element contains any block element. | [
"Check",
"if",
"an",
"element",
"contains",
"any",
"block",
"element",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/elementpath.js#L15-L28 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/elementpath.js | function( otherPath )
{
var thisElements = this.elements;
var otherElements = otherPath && otherPath.elements;
if ( !otherElements || thisElements.length != otherElements.length )
return false;
for ( var i = 0 ; i < thisElements.length ; i++ )
{
if ( !thisElements[ i ].equals( otherElements... | javascript | function( otherPath )
{
var thisElements = this.elements;
var otherElements = otherPath && otherPath.elements;
if ( !otherElements || thisElements.length != otherElements.length )
return false;
for ( var i = 0 ; i < thisElements.length ; i++ )
{
if ( !thisElements[ i ].equals( otherElements... | [
"function",
"(",
"otherPath",
")",
"{",
"var",
"thisElements",
"=",
"this",
".",
"elements",
";",
"var",
"otherElements",
"=",
"otherPath",
"&&",
"otherPath",
".",
"elements",
";",
"if",
"(",
"!",
"otherElements",
"||",
"thisElements",
".",
"length",
"!=",
... | Compares this element path with another one.
@param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be
compared with this one.
@returns {Boolean} "true" if the paths are equal, containing the same
number of elements and the same elements in the same order. | [
"Compares",
"this",
"element",
"path",
"with",
"another",
"one",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/elementpath.js#L91-L106 | train | |
RohanDoshi2018/google_directions | index.js | validateInput | function validateInput(params, cb) {
if (typeof params !== 'object')
return new TypeError("params must be an object");
if (typeof cb !== 'function')
return new TypeError("callback must be a function");
if (params.origin === "")
return new Error("params.origin is required");
if (params.destination === "")
re... | javascript | function validateInput(params, cb) {
if (typeof params !== 'object')
return new TypeError("params must be an object");
if (typeof cb !== 'function')
return new TypeError("callback must be a function");
if (params.origin === "")
return new Error("params.origin is required");
if (params.destination === "")
re... | [
"function",
"validateInput",
"(",
"params",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"params",
"!==",
"'object'",
")",
"return",
"new",
"TypeError",
"(",
"\"params must be an object\"",
")",
";",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"return"... | validation of input | [
"validation",
"of",
"input"
] | 9b0465604d65f26f385072adaf7fce18e1ed4037 | https://github.com/RohanDoshi2018/google_directions/blob/9b0465604d65f26f385072adaf7fce18e1ed4037/index.js#L10-L21 | train |
jlewczyk/git-hooks-js-win | lib/cli.js | outputHelp | function outputHelp() {
console.log(
'\nUsage: git-hooks [options]\n\n' +
'A tool to manage project Git hooks\n\n' +
'Options:\n\n' +
Object.keys(options)
.map(function (key) {
return ' --' + key + '\t' + options[key] + '\n';
})
.j... | javascript | function outputHelp() {
console.log(
'\nUsage: git-hooks [options]\n\n' +
'A tool to manage project Git hooks\n\n' +
'Options:\n\n' +
Object.keys(options)
.map(function (key) {
return ' --' + key + '\t' + options[key] + '\n';
})
.j... | [
"function",
"outputHelp",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'\\nUsage: git-hooks [options]\\n\\n'",
"+",
"'A tool to manage project Git hooks\\n\\n'",
"+",
"'Options:\\n\\n'",
"+",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"map",
"(",
"function",
"(... | Outputs the help to console. | [
"Outputs",
"the",
"help",
"to",
"console",
"."
] | e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/cli.js#L32-L43 | train |
saggiyogesh/nodeportal | plugins/threadComments/ThreadCommentsController.js | function (err, m) {
if (m) {
model = m;
}
else {
err = new Error("Invalid linked model.");
}
n(err, m);
} | javascript | function (err, m) {
if (m) {
model = m;
}
else {
err = new Error("Invalid linked model.");
}
n(err, m);
} | [
"function",
"(",
"err",
",",
"m",
")",
"{",
"if",
"(",
"m",
")",
"{",
"model",
"=",
"m",
";",
"}",
"else",
"{",
"err",
"=",
"new",
"Error",
"(",
"\"Invalid linked model.\"",
")",
";",
"}",
"n",
"(",
"err",
",",
"m",
")",
";",
"}"
] | find model obj | [
"find",
"model",
"obj"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/threadComments/ThreadCommentsController.js#L324-L332 | train | |
ebceu4/waves-crypto | src/libs/blake2b.js | normalizeInput | function normalizeInput(input) {
var ret;
if (input instanceof Uint8Array) {
ret = input;
}
else if (input instanceof Buffer) {
ret = new Uint8Array(input);
}
else if (typeof (input) === 'string') {
ret = new Uint8Array(Buffer.from(input, 'utf8'));
}
else {
... | javascript | function normalizeInput(input) {
var ret;
if (input instanceof Uint8Array) {
ret = input;
}
else if (input instanceof Buffer) {
ret = new Uint8Array(input);
}
else if (typeof (input) === 'string') {
ret = new Uint8Array(Buffer.from(input, 'utf8'));
}
else {
... | [
"function",
"normalizeInput",
"(",
"input",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"input",
"instanceof",
"Uint8Array",
")",
"{",
"ret",
"=",
"input",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"Buffer",
")",
"{",
"ret",
"=",
"new",
"Uint8Arr... | For convenience, let people hash a string, not just a Uint8Array | [
"For",
"convenience",
"let",
"people",
"hash",
"a",
"string",
"not",
"just",
"a",
"Uint8Array"
] | 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L5-L20 | train |
ebceu4/waves-crypto | src/libs/blake2b.js | B2B_GET32 | function B2B_GET32(arr, i) {
return (arr[i] ^
(arr[i + 1] << 8) ^
(arr[i + 2] << 16) ^
(arr[i + 3] << 24));
} | javascript | function B2B_GET32(arr, i) {
return (arr[i] ^
(arr[i + 1] << 8) ^
(arr[i + 2] << 16) ^
(arr[i + 3] << 24));
} | [
"function",
"B2B_GET32",
"(",
"arr",
",",
"i",
")",
"{",
"return",
"(",
"arr",
"[",
"i",
"]",
"^",
"(",
"arr",
"[",
"i",
"+",
"1",
"]",
"<<",
"8",
")",
"^",
"(",
"arr",
"[",
"i",
"+",
"2",
"]",
"<<",
"16",
")",
"^",
"(",
"arr",
"[",
"i"... | Little-endian byte access | [
"Little",
"-",
"endian",
"byte",
"access"
] | 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L104-L109 | train |
ebceu4/waves-crypto | src/libs/blake2b.js | B2B_G | function B2B_G(a, b, c, d, ix, iy) {
var x0 = m[ix];
var x1 = m[ix + 1];
var y0 = m[iy];
var y1 = m[iy + 1];
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
... | javascript | function B2B_G(a, b, c, d, ix, iy) {
var x0 = m[ix];
var x1 = m[ix + 1];
var y0 = m[iy];
var y1 = m[iy + 1];
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
... | [
"function",
"B2B_G",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"ix",
",",
"iy",
")",
"{",
"var",
"x0",
"=",
"m",
"[",
"ix",
"]",
";",
"var",
"x1",
"=",
"m",
"[",
"ix",
"+",
"1",
"]",
";",
"var",
"y0",
"=",
"m",
"[",
"iy",
"]",
";",... | G Mixing function The ROTRs are inlined for speed | [
"G",
"Mixing",
"function",
"The",
"ROTRs",
"are",
"inlined",
"for",
"speed"
] | 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L112-L143 | train |
ebceu4/waves-crypto | src/libs/blake2b.js | blake2bInit | function blake2bInit(outlen, key) {
if (outlen === 0 || outlen > 64) {
throw new Error('Illegal output length, expected 0 < length <= 64');
}
if (key && key.length > 64) {
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64');
}
// state, 'param block'
var ctx... | javascript | function blake2bInit(outlen, key) {
if (outlen === 0 || outlen > 64) {
throw new Error('Illegal output length, expected 0 < length <= 64');
}
if (key && key.length > 64) {
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64');
}
// state, 'param block'
var ctx... | [
"function",
"blake2bInit",
"(",
"outlen",
",",
"key",
")",
"{",
"if",
"(",
"outlen",
"===",
"0",
"||",
"outlen",
">",
"64",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Illegal output length, expected 0 < length <= 64'",
")",
";",
"}",
"if",
"(",
"key",
"&&",... | Creates a BLAKE2b hashing context Requires an output length between 1 and 64 bytes Takes an optional Uint8Array key | [
"Creates",
"a",
"BLAKE2b",
"hashing",
"context",
"Requires",
"an",
"output",
"length",
"between",
"1",
"and",
"64",
"bytes",
"Takes",
"an",
"optional",
"Uint8Array",
"key"
] | 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L219-L247 | train |
ebceu4/waves-crypto | src/libs/blake2b.js | blake2bFinal | function blake2bFinal(ctx) {
ctx.t += ctx.c; // mark last block offset
while (ctx.c < 128) { // fill up with zeros
ctx.b[ctx.c++] = 0;
}
blake2bCompress(ctx, true); // final block flag = 1
// little endian convert and store
var out = new Uint8Array(ctx.outlen);
for (var i = 0; i < ct... | javascript | function blake2bFinal(ctx) {
ctx.t += ctx.c; // mark last block offset
while (ctx.c < 128) { // fill up with zeros
ctx.b[ctx.c++] = 0;
}
blake2bCompress(ctx, true); // final block flag = 1
// little endian convert and store
var out = new Uint8Array(ctx.outlen);
for (var i = 0; i < ct... | [
"function",
"blake2bFinal",
"(",
"ctx",
")",
"{",
"ctx",
".",
"t",
"+=",
"ctx",
".",
"c",
";",
"// mark last block offset",
"while",
"(",
"ctx",
".",
"c",
"<",
"128",
")",
"{",
"// fill up with zeros",
"ctx",
".",
"b",
"[",
"ctx",
".",
"c",
"++",
"]"... | Completes a BLAKE2b streaming hash Returns a Uint8Array containing the message digest | [
"Completes",
"a",
"BLAKE2b",
"streaming",
"hash",
"Returns",
"a",
"Uint8Array",
"containing",
"the",
"message",
"digest"
] | 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L264-L276 | train |
saggiyogesh/nodeportal | lib/static/ThemesWatcher.js | generateIdFromFilePath | function generateIdFromFilePath(filePath) {
var arr = filePath.split("/"), len = arr.length, last = arr[len - 1],
secondLast = arr[len - 2], thirdLast = arr[len - 3];
var isPluginFile = utils.contains(filePath, "/plugins/");
return isPluginFile ? thirdLast + "/" + last : thirdLast + "/" + secondLas... | javascript | function generateIdFromFilePath(filePath) {
var arr = filePath.split("/"), len = arr.length, last = arr[len - 1],
secondLast = arr[len - 2], thirdLast = arr[len - 3];
var isPluginFile = utils.contains(filePath, "/plugins/");
return isPluginFile ? thirdLast + "/" + last : thirdLast + "/" + secondLas... | [
"function",
"generateIdFromFilePath",
"(",
"filePath",
")",
"{",
"var",
"arr",
"=",
"filePath",
".",
"split",
"(",
"\"/\"",
")",
",",
"len",
"=",
"arr",
".",
"length",
",",
"last",
"=",
"arr",
"[",
"len",
"-",
"1",
"]",
",",
"secondLast",
"=",
"arr",... | Returns unique id depends on file location i.e. a theme file or a plugin file
@param filePath | [
"Returns",
"unique",
"id",
"depends",
"on",
"file",
"location",
"i",
".",
"e",
".",
"a",
"theme",
"file",
"or",
"a",
"plugin",
"file"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/static/ThemesWatcher.js#L13-L19 | train |
saggiyogesh/nodeportal | lib/static/ThemesWatcher.js | initThemeFilesWatch | function initThemeFilesWatch(app) {
utils.tick(function () {
var viewsPath = utils.getViewsPath();
var dbAction = new DBActions.DBActions(app.set("db"), {modelName: "Theme"});
dbAction.get("getAll", null, function (err, themes) {
if (err) throw err;
themes.forEach(fun... | javascript | function initThemeFilesWatch(app) {
utils.tick(function () {
var viewsPath = utils.getViewsPath();
var dbAction = new DBActions.DBActions(app.set("db"), {modelName: "Theme"});
dbAction.get("getAll", null, function (err, themes) {
if (err) throw err;
themes.forEach(fun... | [
"function",
"initThemeFilesWatch",
"(",
"app",
")",
"{",
"utils",
".",
"tick",
"(",
"function",
"(",
")",
"{",
"var",
"viewsPath",
"=",
"utils",
".",
"getViewsPath",
"(",
")",
";",
"var",
"dbAction",
"=",
"new",
"DBActions",
".",
"DBActions",
"(",
"app",... | Initiates file watcher and caching of theme's css and js files.
@param app | [
"Initiates",
"file",
"watcher",
"and",
"caching",
"of",
"theme",
"s",
"css",
"and",
"js",
"files",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/static/ThemesWatcher.js#L121-L132 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/tabletools/plugin.js | trimCell | function trimCell( cell )
{
var bogus = cell.getBogus();
bogus && bogus.remove();
cell.trim();
} | javascript | function trimCell( cell )
{
var bogus = cell.getBogus();
bogus && bogus.remove();
cell.trim();
} | [
"function",
"trimCell",
"(",
"cell",
")",
"{",
"var",
"bogus",
"=",
"cell",
".",
"getBogus",
"(",
")",
";",
"bogus",
"&&",
"bogus",
".",
"remove",
"(",
")",
";",
"cell",
".",
"trim",
"(",
")",
";",
"}"
] | Remove filler at end and empty spaces around the cell content. | [
"Remove",
"filler",
"at",
"end",
"and",
"empty",
"spaces",
"around",
"the",
"cell",
"content",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/tabletools/plugin.js#L459-L464 | train |
saggiyogesh/nodeportal | lib/DefaultDataHandler.js | getHandler | function getHandler(app, schema, data) {
function handleSave(err, results, next) {
if (!err) {
delete DependenciesMap[schema];
SavedSchemas.push(schema);
_l('schema saved: ' + schema);
}
next(err, results);
}
// Default handler function
var re... | javascript | function getHandler(app, schema, data) {
function handleSave(err, results, next) {
if (!err) {
delete DependenciesMap[schema];
SavedSchemas.push(schema);
_l('schema saved: ' + schema);
}
next(err, results);
}
// Default handler function
var re... | [
"function",
"getHandler",
"(",
"app",
",",
"schema",
",",
"data",
")",
"{",
"function",
"handleSave",
"(",
"err",
",",
"results",
",",
"next",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"delete",
"DependenciesMap",
"[",
"schema",
"]",
";",
"SavedSchema... | Returns data handler if provided with plugin otherwise return default handler function
@param app
@param schema {String} Schema name
@param data {Object|Array} default data
@returns {*|Function|Function} | [
"Returns",
"data",
"handler",
"if",
"provided",
"with",
"plugin",
"otherwise",
"return",
"default",
"handler",
"function"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L27-L52 | train |
saggiyogesh/nodeportal | lib/DefaultDataHandler.js | function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
} | javascript | function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
} | [
"function",
"(",
"next",
")",
"{",
"data",
"=",
"_",
".",
"isObject",
"(",
"data",
")",
"?",
"_",
".",
"values",
"(",
"data",
")",
":",
"data",
";",
"DBActions",
".",
"getSimpleInstance",
"(",
"app",
",",
"schema",
")",
".",
"multipleSave",
"(",
"d... | Default handler function | [
"Default",
"handler",
"function"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L38-L43 | train | |
saggiyogesh/nodeportal | lib/DefaultDataHandler.js | dependenciesExists | function dependenciesExists(schema) {
var deps = DependenciesMap[schema];
var f = false;
deps.forEach(function (d) {
f = SavedSchemas.indexOf(d) > -1
});
return f;
} | javascript | function dependenciesExists(schema) {
var deps = DependenciesMap[schema];
var f = false;
deps.forEach(function (d) {
f = SavedSchemas.indexOf(d) > -1
});
return f;
} | [
"function",
"dependenciesExists",
"(",
"schema",
")",
"{",
"var",
"deps",
"=",
"DependenciesMap",
"[",
"schema",
"]",
";",
"var",
"f",
"=",
"false",
";",
"deps",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"f",
"=",
"SavedSchemas",
".",
"index... | Checks for required dependencies for the schema are saved.
@param schema {String} schema name
@returns {boolean} | [
"Checks",
"for",
"required",
"dependencies",
"for",
"the",
"schema",
"are",
"saved",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L60-L67 | train |
saggiyogesh/nodeportal | lib/DefaultDataHandler.js | saveSchemas | function saveSchemas(app) {
var keys = Object.keys(DependenciesMap);
if (keys.length == 0) {
_l('Default data saved...');
event.emit(COMPLETED_EVENT);
return;
}
HandlerArray = [];
var errFlag = true;
keys.forEach(function (k) {
dependenciesExists(k) && HandlerArra... | javascript | function saveSchemas(app) {
var keys = Object.keys(DependenciesMap);
if (keys.length == 0) {
_l('Default data saved...');
event.emit(COMPLETED_EVENT);
return;
}
HandlerArray = [];
var errFlag = true;
keys.forEach(function (k) {
dependenciesExists(k) && HandlerArra... | [
"function",
"saveSchemas",
"(",
"app",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"DependenciesMap",
")",
";",
"if",
"(",
"keys",
".",
"length",
"==",
"0",
")",
"{",
"_l",
"(",
"'Default data saved...'",
")",
";",
"event",
".",
"emit",
... | Saves those schemas which depends on other collections data.
@param app | [
"Saves",
"those",
"schemas",
"which",
"depends",
"on",
"other",
"collections",
"data",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L74-L93 | train |
saggiyogesh/nodeportal | lib/DefaultDataHandler.js | init | function init(app) {
var keys = Object.keys(DependenciesMap);
var allDeps = _.uniq(_.flatten(_.values(DependenciesMap)));
allDeps.forEach(function (d) {
if (!_.contains(keys, d)) {
throw new Error("Unresolved dependency: " + d)
}
});
keys.forEach(function (k) {
... | javascript | function init(app) {
var keys = Object.keys(DependenciesMap);
var allDeps = _.uniq(_.flatten(_.values(DependenciesMap)));
allDeps.forEach(function (d) {
if (!_.contains(keys, d)) {
throw new Error("Unresolved dependency: " + d)
}
});
keys.forEach(function (k) {
... | [
"function",
"init",
"(",
"app",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"DependenciesMap",
")",
";",
"var",
"allDeps",
"=",
"_",
".",
"uniq",
"(",
"_",
".",
"flatten",
"(",
"_",
".",
"values",
"(",
"DependenciesMap",
")",
")",
")"... | Start handling default data provided in plugins and save those collections which are not having dependencies.
@param app | [
"Start",
"handling",
"default",
"data",
"provided",
"in",
"plugins",
"and",
"save",
"those",
"collections",
"which",
"are",
"not",
"having",
"dependencies",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L99-L127 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( className )
{
var c = this.$.className;
if ( c )
{
var regex = new RegExp( '(?:^|\\s)' + className + '(?:\\s|$)', '' );
if ( !regex.test( c ) )
c += ' ' + className;
}
this.$.className = c || className;
} | javascript | function( className )
{
var c = this.$.className;
if ( c )
{
var regex = new RegExp( '(?:^|\\s)' + className + '(?:\\s|$)', '' );
if ( !regex.test( c ) )
c += ' ' + className;
}
this.$.className = c || className;
} | [
"function",
"(",
"className",
")",
"{",
"var",
"c",
"=",
"this",
".",
"$",
".",
"className",
";",
"if",
"(",
"c",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"'(?:^|\\\\s)'",
"+",
"className",
"+",
"'(?:\\\\s|$)'",
",",
"''",
")",
";",
"if... | Adds a CSS class to the element. It appends the class to the
already existing names.
@param {String} className The name of the class to be added.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.addClass( 'classA' ); // <div class="classA">
element.addClass( 'classB' ); // <div class="classA... | [
"Adds",
"a",
"CSS",
"class",
"to",
"the",
"element",
".",
"It",
"appends",
"the",
"class",
"to",
"the",
"already",
"existing",
"names",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L129-L139 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( className )
{
var c = this.getAttribute( 'class' );
if ( c )
{
var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', 'i' );
if ( regex.test( c ) )
{
c = c.replace( regex, '' ).replace( /^\s+/, '' );
if ( c )
this.setAttribute( 'class', c );
el... | javascript | function( className )
{
var c = this.getAttribute( 'class' );
if ( c )
{
var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', 'i' );
if ( regex.test( c ) )
{
c = c.replace( regex, '' ).replace( /^\s+/, '' );
if ( c )
this.setAttribute( 'class', c );
el... | [
"function",
"(",
"className",
")",
"{",
"var",
"c",
"=",
"this",
".",
"getAttribute",
"(",
"'class'",
")",
";",
"if",
"(",
"c",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"'(?:^|\\\\s+)'",
"+",
"className",
"+",
"'(?=\\\\s|$)'",
",",
"'i'",
... | Removes a CSS class name from the elements classes. Other classes
remain untouched.
@param {String} className The name of the class to remove.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.addClass( 'classA' ); // <div class="classA">
element.addClass( 'classB' ); // <div class="classA cl... | [
"Removes",
"a",
"CSS",
"class",
"name",
"from",
"the",
"elements",
"classes",
".",
"Other",
"classes",
"remain",
"untouched",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L152-L168 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( text )
{
CKEDITOR.dom.element.prototype.setText = ( this.$.innerText != undefined ) ?
function ( text )
{
return this.$.innerText = text;
} :
function ( text )
{
return this.$.textContent = text;
};
return this.setText( text );
} | javascript | function( text )
{
CKEDITOR.dom.element.prototype.setText = ( this.$.innerText != undefined ) ?
function ( text )
{
return this.$.innerText = text;
} :
function ( text )
{
return this.$.textContent = text;
};
return this.setText( text );
} | [
"function",
"(",
"text",
")",
"{",
"CKEDITOR",
".",
"dom",
".",
"element",
".",
"prototype",
".",
"setText",
"=",
"(",
"this",
".",
"$",
".",
"innerText",
"!=",
"undefined",
")",
"?",
"function",
"(",
"text",
")",
"{",
"return",
"this",
".",
"$",
"... | Sets the element contents as plain text.
@param {String} text The text to be set.
@returns {String} The inserted text.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.setText( 'A > B & C < D' );
alert( element.innerHTML ); // "A &gt; B &amp; C &lt; D" | [
"Sets",
"the",
"element",
"contents",
"as",
"plain",
"text",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L391-L404 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( evaluator )
{
var first = this.$.firstChild,
retval = first && new CKEDITOR.dom.node( first );
if ( retval && evaluator && !evaluator( retval ) )
retval = retval.getNext( evaluator );
return retval;
} | javascript | function( evaluator )
{
var first = this.$.firstChild,
retval = first && new CKEDITOR.dom.node( first );
if ( retval && evaluator && !evaluator( retval ) )
retval = retval.getNext( evaluator );
return retval;
} | [
"function",
"(",
"evaluator",
")",
"{",
"var",
"first",
"=",
"this",
".",
"$",
".",
"firstChild",
",",
"retval",
"=",
"first",
"&&",
"new",
"CKEDITOR",
".",
"dom",
".",
"node",
"(",
"first",
")",
";",
"if",
"(",
"retval",
"&&",
"evaluator",
"&&",
"... | Gets the first child node of this element.
@param {Function} evaluator Filtering the result node.
@returns {CKEDITOR.dom.node} The first child node or null if not
available.
@example
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' );
var first = <b>element.getFirst... | [
"Gets",
"the",
"first",
"child",
"node",
"of",
"this",
"element",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L672-L680 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.