_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q37000 | parseJson | train | function parseJson(json, cache, cwd)
{
return json.replace(
/"([^"]+\.json)"/gi,
(match, jsonFile) =>
{
const _json = loadJsonFile(jsonFile, cache, cwd);
| javascript | {
"resource": ""
} |
q37001 | train | function(dataset) {
// calculate counts for equation (3):
var mapWordToTotalCount = {};
var totalNumberOfWordsInDataset = 0;
for (var i in dataset) {
var datum = dataset[i];
var totalPerDatum = 0;
// for each input sentence, count the total number of words in it:
for (var word in datum) {
m... | javascript | {
"resource": ""
} | |
q37002 | ErrorRead | train | function ErrorRead (message) {
Error.call(this);
// Add Information
this.name | javascript | {
"resource": ""
} |
q37003 | tryUnshift | train | function tryUnshift(stream, result, desiredLength, emptySlice) {
if (typeof stream.unshift !== 'function') {
debug('Unable to unshift, stream does not have an unshift method.');
return result;
}
const errorListeners = stream.listeners('error');
stream.removeAllListeners('error');
// Note: Don't rel... | javascript | {
"resource": ""
} |
q37004 | checkUntil | train | function checkUntil(resultWithData, data, ended) {
let desiredLength;
try {
desiredLength = until(resultWithData, data, ended);
} catch (errUntil) {
doReject(errUntil, true);
return true;
}
const resultLength = result ? result.length : 0;
if (typeof desiredLe... | javascript | {
"resource": ""
} |
q37005 | read | train | function read(stream, size, options) {
if (!options && typeof size === 'object') {
options = size;
size = null;
} | javascript | {
"resource": ""
} |
q37006 | readUntil | train | function readUntil(stream, until, options) {
if (typeof until !== 'function') {
// Note: Synchronous Yaku emits unhandledRejection before returning.
// Best current option is to use an async promise, even when flowing
const ReadPromise = (options | javascript | {
"resource": ""
} |
q37007 | readTo | train | function readTo(stream, needle, options) {
const endOK = Boolean(options && (options.endOK || options.endOk));
let needleForIndexOf;
let needleLength;
function until(result, chunk, ended) {
if (ended) {
return endOK ? (result ? result.length : 0) : -1;
}
if (Array.isArray(result)) {
// ... | javascript | {
"resource": ""
} |
q37008 | readToEnd | train | function readToEnd(stream, options) {
function until(result, chunk, ended) {
return ended;
| javascript | {
"resource": ""
} |
q37009 | readToMatch | train | function readToMatch(stream, regexp, options) {
const endOK = Boolean(options && (options.endOK || options.endOk));
const maxMatchLen = Number(options && options.maxMatchLen);
// Convert to RegExp where necessary, like String.prototype.match
// Make sure RegExp has global flag so lastIndex will be set
if (!(r... | javascript | {
"resource": ""
} |
q37010 | loadList | train | function loadList(brain) {
const taboolist = brain.get("taboo");
if (taboolist != null) {
for (let topic of taboolist) {
| javascript | {
"resource": ""
} |
q37011 | saveList | train | function saveList(brain) {
const taboolist = [];
taboo.forEach((re, topic) => {
| javascript | {
"resource": ""
} |
q37012 | deleteTopic | train | function deleteTopic(res, topic) {
const keyTopic = topic.toLowerCase();
if (taboo.delete(keyTopic)) {
| javascript | {
"resource": ""
} |
q37013 | addTopic | train | function addTopic(res, topic) {
const keyTopic = topic.toLowerCase();
if (!taboo.has(keyTopic)) {
taboo.set(keyTopic, new | javascript | {
"resource": ""
} |
q37014 | listTopics | train | function listTopics(res) {
loadList(res.robot.brain); // Not necessary, but helps for testing.
if (taboo.size == 0) {
res.reply("Nothing is taboo | javascript | {
"resource": ""
} |
q37015 | extend | train | function extend(what, whit) {
Object.keys(whit).forEach(function(key) {
var def = whit[key];
if (what[key] === undefined) {
if (def.get && def.set) {
// | javascript | {
"resource": ""
} |
q37016 | strings | train | function strings() {
extend(String.prototype, {
trim: function() {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
},
repeat: function(n) {
return new Array(n + 1).join(this);
},
startsWith: function(sub) {
return this.indexOf(sub) === 0;
},
endsWith: function(sub) {
sub = St... | javascript | {
"resource": ""
} |
q37017 | arrays | train | function arrays() {
extend(Array, {
every: function every(array, fun, thisp) {
var res = true,
len = array.length >>> 0;
for (var i = 0; i < len; i++) {
if (array[i] !== undefined) {
if (!fun.call(thisp, array[i], i, array)) {
res = false;
break;
}
}
}
retur... | javascript | {
"resource": ""
} |
q37018 | train | function(action, thisp) {
var is = this.initialized;
if (arguments.length) {
if (is) {
action.call(thisp);
} else {
this._initcallbacks = this._initcallbacks || [];
this._initcallbacks.push(function() {
if (gui.debug) {
try {
action.call(thisp);
} | javascript | {
"resource": ""
} | |
q37019 | train | function(action, thisp) {
this.init(action, thisp);
if(gui.debug) | javascript | {
"resource": ""
} | |
q37020 | train | function(name, module) {
var Module;
if (gui.Type.isString(name) && name.length) {
Module = gui.Module.extend(name, module | javascript | {
"resource": ""
} | |
q37021 | train | function(ns, members) {
var no;
if (gui.Type.isString(ns)) {
no = gui.Object.lookup(ns);
no = new gui.Namespace(ns);
no = gui.Object.assert(ns, no);
} else {
| javascript | {
"resource": ""
} | |
q37022 | train | function(msg, arg) {
if (gui.Type.isEvent(arg)) {
arg = new gui.EventSummary(arg);
}
| javascript | {
"resource": ""
} | |
q37023 | train | function(o, name) {
gui.Object.each(o, function(key, value) {
if (key !== "$superclass" && gui.Type.isConstructor(value)) {
if (value.$classname === gui.Class.ANONYMOUS) { | javascript | {
"resource": ""
} | |
q37024 | train | function(string) {
var hit = null,
looks = false;
if (gui.Type.isString(string)) {
hit = this.extractKey(string);
| javascript | {
"resource": ""
} | |
q37025 | train | function(proto, props) {
var resolved = {};
Object.keys(props).forEach(function(prop) {
resolved[prop] = {
value: props[prop],
writable: true,
| javascript | {
"resource": ""
} | |
q37026 | train | function(source, domap, thisp) {
var result = {},
mapping;
this.each(source, function(key, value) | javascript | {
"resource": ""
} | |
q37027 | train | function(opath, context) {
var result, struct = context || self;
if (gui.Type.isString(opath)) {
if (!opath.contains(".")) {
result = struct[opath];
} else {
var parts = opath.split(".");
parts.every(function(part) {
struct = struct[part];
| javascript | {
"resource": ""
} | |
q37028 | train | function(desc) {
if (desc.value && gui.Type.isFunction(desc.value)) {
if (desc.value.$hidden && desc.configurable) {
| javascript | {
"resource": ""
} | |
q37029 | train | function(o) {
var type = ({}).toString.call(o).match(this._typeexp)[1].toLowerCase();
if (type === "domwindow" && String(typeof o) === "undefined") {
| javascript | {
"resource": ""
} | |
q37030 | train | function(o) {
return o && o.document | javascript | {
"resource": ""
} | |
q37031 | train | function(what) {
return this.isFunction(what) &&
| javascript | {
"resource": ""
} | |
q37032 | train | function(string) {
var result = String(string);
switch (result) {
case "null":
result = null;
break;
case "true":
case "false":
result = (result === "true"); | javascript | {
"resource": ""
} | |
q37033 | train | function(/* ...types */) {
var types = gui.Array.from(arguments);
return function(action) {
return function() {
| javascript | {
"resource": ""
} | |
q37034 | train | function(/* ...types */) {
var types = gui.Array.from(arguments);
return function(action) {
return function() { | javascript | {
"resource": ""
} | |
q37035 | train | function(xpect, arg, index) {
var needs = !xpect.startsWith("(");
var split = this._xtract(xpect, !needs).split("|");
var input = gui.Type.of(arg);
var match = (xpect === "*" ||
(xpect === 'node' && arg && arg.nodeType) ||
(xpect === 'element' && arg && arg.nodeType === Node.ELEMENT_NODE) ||
(xpect =... | javascript | {
"resource": ""
} | |
q37036 | train | function(that) {
var summ = this._bugsummary;
var name = that.constructor.$classname || String(that);
console.error([
"Bad argument " + summ.shift(),
"for " + name + ":",
| javascript | {
"resource": ""
} | |
q37037 | train | function(name, params, body, context) {
var F = context ? context.Function : Function;
name = this.safename(name);
params = params ? params.join(",") : "";
body = body || "";
| javascript | {
"resource": ""
} | |
q37038 | train | function() {
var b = this._breakdown_base(arguments);
var C = this._createclass(null, b.proto, b.name);
gui.Object.extend(C.prototype, b.protos);
gui.Object.extend(C, b.statics);
gui.Property.extendall(b.protos, C.prototype);
if (b.recurring) {
gui.Object.each(b.recurring, function(key, val) {
| javascript | {
"resource": ""
} | |
q37039 | train | function(SuperC, args) {
args = this._breakdown_subs(args);
return this._extendclass(
SuperC,
args.protos, | javascript | {
"resource": ""
} | |
q37040 | train | function(SuperC, protos, recurring, statics, name) {
var C = this._createclass(SuperC, SuperC.prototype, name);
gui.Object.extend(C, statics);
gui.Object.extend(C.$recurring, recurring);
gui.Object.each(C.$recurring, function(key, val) {
var desc = Object.getOwnPropertyDescriptor(C, key);
if | javascript | {
"resource": ""
} | |
q37041 | train | function(C, SuperC) {
C.$super = null; // what's this?
C.$subclasses = [];
C.$superclass = SuperC || null;
C.$recurring = SuperC ?
| javascript | {
"resource": ""
} | |
q37042 | train | function(proto, recurring, statics) {
Array.forEach(arguments, function(mixins, i) {
if (mixins) {
gui.Object.each(mixins, function(name, value) {
if (i === 0) {
// TODO: something more elaborate | javascript | {
"resource": ""
} | |
q37043 | train | function(C, action, thisp) {
var results = [];
action = action || gui.Combo.identity; | javascript | {
"resource": ""
} | |
q37044 | train | function(C, action, thisp, results) {
results = results || [];
action = action || gui.Combo.identity;
C.$subclasses.forEach(function(sub) {
results.push(action.call(thisp, sub));
| javascript | {
"resource": ""
} | |
q37045 | train | function(C, action, thisp) {
var results = [];
action = action || gui.Combo.identity;
results.push(action.call(thisp, C)); | javascript | {
"resource": ""
} | |
q37046 | train | function(C, action, thisp) {
if (C && C.$superclass) {
action | javascript | {
"resource": ""
} | |
q37047 | train | function(C, action, thisp) {
var results = this.ancestorsAndSelf(C).concat(this.descendants(C));
if (action) {
results | javascript | {
"resource": ""
} | |
q37048 | train | function(proto, key, desc) {
var val = desc.value;
if (gui.Type.isObject(val)) {
if (val.getter || | javascript | {
"resource": ""
} | |
q37049 | train | function(proto, key, def) {
var desc;
["getter", "setter"].forEach(function(name, set) {
while (proto && proto[key] && !gui.Type.isDefined(def[name])) {
proto = Object.getPrototypeOf(proto);
desc = Object.getOwnPropertyDescriptor(proto, key);
if (desc) {
def[name] = desc[set ? "set" : "get"];
... | javascript | {
"resource": ""
} | |
q37050 | train | function(interfais, object) {
var is = true;
var expected = interfais.toString();
var type = gui.Type.of(object);
switch (type) {
case "null":
case "string":
case "number":
case "boolean":
case "undefined":
throw new Error("Expected " + expected + ", got " + type + ": " + object);
default:... | javascript | {
"resource": ""
} | |
q37051 | train | function(decoration) {
return function(base) {
return function() {
var result = base.apply(this, arguments);
| javascript | {
"resource": ""
} | |
q37052 | train | function(decoration) {
var slice = [].slice;
return function(base) {
return function() {
var argv, callback, result, that = this;
argv = 1 <= arguments.length ? slice.call(arguments, 0) : [];
result = void 0;
callback | javascript | {
"resource": ""
} | |
q37053 | train | function(condition) {
return function(base, otherwise) {
return function() {
if (condition.apply(this, arguments)) | javascript | {
"resource": ""
} | |
q37054 | train | function(client) {
this.client = client;
if(gui.hasModule('gui-spirits@wunderbyte.com')) {
if(client instanceof gui.Spirit) {
this.spirit = client || null;
this.context = window; | javascript | {
"resource": ""
} | |
q37055 | train | function() {
gui.Plugin.prototype.ondestruct.call(this);
gui.Object.each(this._trackedtypes, function(type, list) {
| javascript | {
"resource": ""
} | |
q37056 | train | function(on /*...rest */ ) {
var rest = gui.Array.from(arguments).slice(1);
if (on) {
return | javascript | {
"resource": ""
} | |
q37057 | train | function(type, checks) {
var result = false;
var list = this._trackedtypes[type];
if (!list) {
list = this._trackedtypes[type] = [];
result = true;
} else {
result = | javascript | {
"resource": ""
} | |
q37058 | train | function(type, checks) {
var result = false;
var list = this._trackedtypes[type];
if (list) {
var index = this._checksindex(list, checks);
if (index | javascript | {
"resource": ""
} | |
q37059 | train | function(type, checks) {
var result = false;
var list = this._trackedtypes[type];
if (list) {
result | javascript | {
"resource": ""
} | |
q37060 | train | function(list, checks) {
var result = !checks || false;
if (!result) {
list.every(function(a) {
if (a.every(function(b, i) {
return b === checks[i]; | javascript | {
"resource": ""
} | |
q37061 | train | function(list, checks) {
var result = -1;
list.every(function(a, index) {
if (a.every(function(b, i) {
return b === checks[i];
})) {
| javascript | {
"resource": ""
} | |
q37062 | train | function(a, key) {
var prefix = "spiritual-action:";
return prefix + (function() {
a.target = null;
a.data = (function(d) {
if (gui.Type.isComplex(d)) {
if (gui.Type.isFunction(d.stringify)) {
d = d.stringify();
} else {
try {
| javascript | {
"resource": ""
} | |
q37063 | train | function(b) {
var prefix = "spiritual-broadcast:";
return prefix + (function() {
b.target = null;
b.data = (function(d) {
if (gui.Type.isComplex(d)) {
if (gui.Type.isFunction(d.stringify)) {
d = d.stringify();
} else {
try {
| javascript | {
"resource": ""
} | |
q37064 | train | function(msg) {
var prefix = "spiritual-broadcast:";
if (msg.startsWith(prefix)) {
| javascript | {
"resource": ""
} | |
q37065 | train | function(b) {
var map = b.global ? this._globals : this._locals[gui.$contextid];
if (gui.hasModule('gui-spirits@wunderbyte.com')) {
if(!gui.spiritualized) {
if(b.type !== gui.BROADCAST_WILL_SPIRITUALIZE) {
// TODO: cache broadcast until spiritualized?
}
}
} | javascript | {
"resource": ""
} | |
q37066 | train | function(b) {
var postmessage = (function stamp() {
b.$contextids.push(gui.$contextid);
return gui.Broadcast.stringify(b);
| javascript | {
"resource": ""
} | |
q37067 | train | function(type, time, sig) {
var map = this._tempname;
var types = map.types;
var tick = new gui.Tick(type);
time = time || 0;
if (!types[type]) { // !!!!!!!!!!!!!!!!!!!!!!!
types[type] = true;
var that = this,
id = null;
if (!time) {
id = setImmediate(function() {
| javascript | {
"resource": ""
} | |
q37068 | train | function(spirit) {
var prefixes = [],
plugins = spirit.life.plugins;
gui.Object.each(plugins, function(prefix, instantiated) {
if (instantiated) {
if (prefix !== "life") {
prefixes.push(prefix);
}
} else {
Object.defineProperty(spirit, prefix, {
enumerable: true,
configurable: tr... | javascript | {
"resource": ""
} | |
q37069 | train | function(plugins, nuke) {
if (nuke) {
plugins.forEach(function(plugin) {
this.$nukeallofit(plugin);
}, this);
} else {
plugins.map(function(plugin) {
plugin.ondestruct();
| javascript | {
"resource": ""
} | |
q37070 | train | function(thing) {
var nativeprops = Object.prototype;
if (!gui.unloading && !thing.$destructed) {
thing.$destructed = true;
for (var prop in thing) {
if (thing.hasOwnProperty(prop) || gui.debug) {
if (nativeprops[prop] === undefined) {
if (prop !== '$destructed') {
var desc = Object.getO... | javascript | {
"resource": ""
} | |
q37071 | train | function(message) {
var stack, e = new Error(
gui.GreatSpirit.DENIAL + (message ? ": " + message : "")
);
if (!gui.Client.isExplorer && (stack = e.stack)) {
if (gui.Client.isWebKit) {
stack = stack.replace(/^[^\(]+?[\n$]/gm, "").
replace(/^\s+at\s+/gm, "").
replace(/^Object.<anonymous>\s*\(/gm, ... | javascript | {
"resource": ""
} | |
q37072 | train | function(thing, prop) {
Object.defineProperty(thing, prop, {
enumerable: true,
configurable: true, | javascript | {
"resource": ""
} | |
q37073 | train | function() {
var spirit, spirits = this._spirits.slice();
if (window.gui) { // hotfix IE window unloaded scenario...
while ((spirit | javascript | {
"resource": ""
} | |
q37074 | train | function() {
var that = this,
add = function(target, events, capture) {
events.split(' ').forEach(function(type) {
target.addEventListener(type, that, capture);
});
};
add(document, 'DOMContentLoaded');
add(document, 'click mousedown mouseup', true);
add(window, 'load hashchange');
... | javascript | {
"resource": ""
} | |
q37075 | train | function() {
this._loaded = true;
dobrodcast(gui.BROADCAST_TOLOAD, gui.BROADCAST_ONLOAD);
| javascript | {
"resource": ""
} | |
q37076 | train | function() {
if (!gui.hosted) {
clearTimeout(this._timeout);
this._timeout | javascript | {
"resource": ""
} | |
q37077 | train | function(spaces) {
var prop, def, metas = document.querySelectorAll('meta[name]');
Array.forEach(metas, function(meta) {
prop = meta.getAttribute('name');
spaces.forEach(function(ns) {
if (prop.startsWith(ns + '.')) {
def = gui.Object.lookup(prop);
if (gui.Type.isDefined(def)) {
gu... | javascript | {
"resource": ""
} | |
q37078 | train | function(callback, thisp) {
this._callback = callback ? callback : null;
this._pointer = thisp ? thisp | javascript | {
"resource": ""
} | |
q37079 | train | function() {
var c = this._callback;
var p = this._pointer;
if (c) {
this.then(null, null);
| javascript | {
"resource": ""
} | |
q37080 | train | function(markup, targetdoc) {
return this.parseToNodes(markup, targetdoc).filter(function(node) {
| javascript | {
"resource": ""
} | |
q37081 | train | function(markup, targetdoc) {
var elm, doc = this._document ||
(this._document = document.implementation.createHTMLDocument(""));
return gui.Guide.suspend(function() {
doc.body.innerHTML = this._unsanitize(markup);
elm = doc.querySelector("." + this._classname) || doc.body;
| javascript | {
"resource": ""
} | |
q37082 | train | function(markup) {
markup = markup || "";
return gui.Guide.suspend(function() {
var doc = document.implementation.createHTMLDocument("");
if (markup.toLowerCase().contains("<!doctype")) {
| javascript | {
"resource": ""
} | |
q37083 | train | function(markup) {
var match, fix;
markup = markup.trim().replace(this._comments, "");
if ((match = markup.match(this._firsttag))) {
if ((fix = this._unsanestructures[match[1]])) {
markup = fix.
| javascript | {
"resource": ""
} | |
q37084 | train | function(start, handler) {
this.direction = gui.Crawler.ASCENDING;
var supports = gui.hasModule('gui-spirits@wunderbyte.com');
var isspirit = supports && start instanceof gui.Spirit;
var win, elm = isspirit ? start.element : start;
do {
if (elm.nodeType === Node.DOCUMENT_NODE) {
if (this.global) {
... | javascript | {
"resource": ""
} | |
q37085 | train | function(start, handler, arg) {
this.direction = gui.Crawler.DESCENDING;
var elm = start instanceof gui.Spirit ? start.element : start;
if (elm.nodeType === | javascript | {
"resource": ""
} | |
q37086 | train | function(start, handler, arg) {
this.global = true;
this.descend(start, | javascript | {
"resource": ""
} | |
q37087 | train | function(element, handler, arg) {
var hasspirit = gui.hasModule('gui-spirits@wunderbyte.com');
var directive = gui.Crawler.CONTINUE;
var spirit = hasspirit ? element.spirit : null;
if (spirit) {
directive = spirit.oncrawler(this);
}
if (!directive) {
if (handler) {
if (gui.Type.isFunction(handler.... | javascript | {
"resource": ""
} | |
q37088 | train | function(text) {
var result = text;
try {
switch (this._headers.Accept) {
case "application/json":
result = JSON.parse(text);
break;
case "text/xml":
| javascript | {
"resource": ""
} | |
q37089 | supports | train | function supports(feature) {
var root = document.documentElement;
var fixt = feature[0].toUpperCase() + feature.substring(1); | javascript | {
"resource": ""
} |
q37090 | train | function(elm) {
var res = null;
if (elm.nodeType === Node.ELEMENT_NODE) {
var doc = elm.ownerDocument;
var win = doc.defaultView;
if (win.gui) {
if (win.gui.attributes.every(function(fix) {
res = this._evaluateinline(elm, win, fix);
return res === null;
}, this)) {
if (gui.hasChannel... | javascript | {
"resource": ""
} | |
q37091 | train | function(spirit) {
var all = this._spirits;
var key = spirit.$instanceid; | javascript | {
"resource": ""
} | |
q37092 | train | function() {
this.spiritualized = true;
var list = this._readycallbacks;
| javascript | {
"resource": ""
} | |
q37093 | train | function(action) {
var list = this._trackedtypes[action.type];
if (list) {
list.forEach(function(checks) {
var handler = checks[0];
var matches = checks[1] === action.global;
var hacking = handler === this.spirit && this.$handleownaction; | javascript | {
"resource": ""
} | |
q37094 | train | function(action, time, thisp) {
return | javascript | {
"resource": ""
} | |
q37095 | train | function(type, handler, one) {
var sig = this.spirit.$contextid;
if (one) {
if (this._global) {
gui.Tick.oneGlobal(type, handler);
} else {
gui.Tick.one(type, handler, sig);
}
} else {
if (this._global) {
| javascript | {
"resource": ""
} | |
q37096 | train | function(type, handler) {
var sig = this.spirit.$contextid;
if (this._global) {
gui.Tick.removeGlobal(type, handler);
| javascript | {
"resource": ""
} | |
q37097 | train | function(type, checks) {
var handler = checks[0];
var bglobal = checks[1];
if (this._remove(type, [handler])) {
if (bglobal) {
gui.Tick.removeGlobal(type, handler);
| javascript | {
"resource": ""
} | |
q37098 | train | function(arg, handler) {
handler = handler ? handler : this.spirit;
gui.Array.make(arg).forEach(function(type) {
if (this._addchecks(type, [handler])) | javascript | {
"resource": ""
} | |
q37099 | train | function(arg, handler) {
handler = handler ? handler : this.spirit;
gui.Array.make(arg).forEach(function(type) {
if (this._removechecks(type, [handler])) {
if (this._handlers[type]) { // weirdo Gecko condition...
var index = this._handlers[type].indexOf(type);
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.