_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q6000
inferSettings
train
function inferSettings(graph) { var order = graph.order; return { barnesHutOptimize: order > 2000, strongGravityMode: true,
javascript
{ "resource": "" }
q6001
Page
train
function Page(path, ctx) { events.EventEmitter.call(this);
javascript
{ "resource": "" }
q6002
dispatch
train
function dispatch(req, done) { var site = req.site , path = upath.join(site.path || '', req.path) , parent = site.parent; while (parent) { path = upath.join(parent.path || '', path); parent = parent.parent; } console.log('# '
javascript
{ "resource": "" }
q6003
rewrite_code
train
function rewrite_code(code, node, replacement_string) { return
javascript
{ "resource": "" }
q6004
generateData
train
function generateData( filepath ) { var dataObj = new datauri( filepath ); return {
javascript
{ "resource": "" }
q6005
generateCss
train
function generateCss( filepath, data ) { var filetype = filepath.split( '.' ).pop().toLowerCase(); var className; var template; className = options.classPrefix + path.basename( data.path ).split( '.' )[0] + options.classSuffix; filetype = options.usePlaceholder ? filetype : filetype + '_no'; if (options.variables) {
javascript
{ "resource": "" }
q6006
getHistory
train
function getHistory(callback) { if (_.isUndefined(callback)) { } else { var u = config.baseUrl + ((api_version == "v1") ? "v1.1" : api_version) + "/history",
javascript
{ "resource": "" }
q6007
getUserProfile
train
function getUserProfile(callback) { if (_.isUndefined(callback)) { } else { var u = baseUrl + "/me"; var tokenData = this.getAuthToken(); if (tokenData.type != "bearer") {
javascript
{ "resource": "" }
q6008
train
function() { return new Promise(function(resolve, reject) { exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", { timeout: 3000, cwd: process.cwd() }, function(err, stdout, stdin) { var results = stdout.trim().split('\n'); for (var i = 0; i <
javascript
{ "resource": "" }
q6009
train
function() { return new Promise(function(resolve, reject) { exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", { timeout: 3000, cwd: process.cwd() }, function(err, stdout, stdin) { var results = stdout.trim().split('\n'); var entities = {}; // iterate all found js files and search for CRUD.define calls
javascript
{ "resource": "" }
q6010
Group
train
function Group(props) { var children = React.Children.toArray(props.children).filter(Boolean); if (children.length === 1) { return children; } // Insert separators var separator = props.separator; var separatorIsElement = React.isValidElement(separator); var items = [children.shift()]; children.forEach(function(item, index) { if (separatorIsElement) {
javascript
{ "resource": "" }
q6011
createSite
train
function createSite() { function app(page) { app.handle(page); } mixin(app, EventEmitter.prototype, false);
javascript
{ "resource": "" }
q6012
invalidResponseError
train
function invalidResponseError(result, host) { const message = !!result && !!result.error && !!result.error.message ? `[ethjs-provider-http]
javascript
{ "resource": "" }
q6013
HttpProvider
train
function HttpProvider(host, timeout) { if (!(this instanceof HttpProvider)) { throw new Error('[ethjs-provider-http] the HttpProvider instance requires the "new" flag in order to function normally (e.g. `const eth = new Eth(new HttpProvider());`).'); } if (typeof host !== 'string') { throw new Error('[ethjs-provider-http] the HttpProvider instance requires that the
javascript
{ "resource": "" }
q6014
train
function(ip) { this.connectionparams = { host: ip, port: 23, timeout: 1000, // The RESPONSE should be sent within 200ms of receiving the request
javascript
{ "resource": "" }
q6015
sendKeys
train
function sendKeys(element, str) { return str.split('').reduce(function (promise, char) { return promise.then(function () { return element.sendKeys(char); }); },
javascript
{ "resource": "" }
q6016
insertQuerySuccess
train
function insertQuerySuccess(resultSet) { resultSet.Action = 'inserted'; resultSet.ID = resultSet.rs.insertId;
javascript
{ "resource": "" }
q6017
insertQueryError
train
function insertQueryError(err, tx) { CRUD.stats.writesExecuted++; console.error("Insert
javascript
{ "resource": "" }
q6018
parseSchemaInfo
train
function parseSchemaInfo(resultset) { for (var i = 0; i < resultset.rs.rows.length; i++) { var row = resultset.rs.rows.item(i); if (row.name.indexOf('sqlite_autoindex') > -1 || row.name == '__WebKitDatabaseInfoTable__') continue; if (row.type == 'table') { tables.push(row.tbl_name); } else if (row.type == 'index') {
javascript
{ "resource": "" }
q6019
createTables
train
function createTables() { return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) { var entity = CRUD.EntityManager.entities[entityName]; if (tables.indexOf(entity.table) == -1) { if (!entity.createStatement) { throw "No create statement found for " + entity.getType() + ". Don't know how to create table."; } return db.execute(entity.createStatement).then(function() { tables.push(entity.table); localStorage.setItem('database.version.' + entity.table, ('migrations' in entity) ? Math.max.apply(Math, Object.keys(entity.migrations)) : 1); CRUD.log(entity.table + " table created."); return entity; }, function(err) {
javascript
{ "resource": "" }
q6020
createIndexes
train
function createIndexes() { // create listed indexes if they don't already exist. return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) { var entity = CRUD.EntityManager.entities[entityName]; if (('indexes' in entity)) { return Promise.all(entity.indexes.map(function(index) { var indexName = index.replace(/\W/g, '') + '_idx'; if (!(entity.table in indexes) || indexes[entity.table].indexOf(indexName) == -1) {
javascript
{ "resource": "" }
q6021
createFixtures
train
function createFixtures(entity) { return new Promise(function(resolve, reject) { if (!entity.fixtures) return resolve();
javascript
{ "resource": "" }
q6022
train
function(field, def) { var ret; if (field in this.__dirtyValues__) { ret = this.__dirtyValues__[field]; } else if (field in this.__values__) { ret = this.__values__[field]; } else if (CRUD.EntityManager.entities[this.getType()].fields.indexOf(field) > -1) { ret = (field
javascript
{ "resource": "" }
q6023
Route
train
function Route(path, fns, options) { options = options || {}; this.path = path; this.fns = fns;
javascript
{ "resource": "" }
q6024
buildFile
train
function buildFile() { var reader = readline.createInterface({ input: fs.createReadStream(path.resolve("./src/assets/template.html"))
javascript
{ "resource": "" }
q6025
train
function(moveBack) { return new Promise(function(resolve, reject) {
javascript
{ "resource": "" }
q6026
train
function(packageName, componentName) { return new Promise(function(resolve, reject)
javascript
{ "resource": "" }
q6027
promisePrompt
train
function promisePrompt(questions) { return new Promise(function(resolve, reject) {
javascript
{ "resource": "" }
q6028
buildJsFileContent
train
function buildJsFileContent(lines) { var ls = lines .map(l => l // remove space at beginning of line .replace(/^\s*/g, "") // remove space at end of line .replace(/\s*$/g, "") // convert \ to \\ .replace(/\\/g, "\\\\") // convert " to \" .replace(/"/g, "\\\"") // convert " { " to "{" .replace(/\s*\{\s*/g, "{") // convert " : " to ":" .replace(/\s*:\s*/g, ":")) .join("") // remove comments .replace(/\/\*.+?\*\//g, ""); return [ // add css string `var css = "${ls}";`, "var enabled = false;", "", // add function which injects css into page "function enable () {", "\tif (enabled) return;", "\tenabled = true;", "",
javascript
{ "resource": "" }
q6029
train
function(done, promise, expectedState, expectedData, isNegative) { function verify(promiseState) { return function(data) { var test = verifyState(promiseState, expectedState); if (test.pass) { test = verifyData(data, expectedData); } if (!test.pass && !isNegative) {
javascript
{ "resource": "" }
q6030
train
function(class_data, path) { var implements_source = this._sources[path], name, references_offset; if (Lava.schema.DEBUG) { if (!implements_source) Lava.t('Implements: class not found - "' + path + '"'); for (name in implements_source.shared) Lava.t("Implements: unable to use a class with Shared as mixin."); if (class_data.implements.indexOf(path) !=
javascript
{ "resource": "" }
q6031
train
function(class_data, source_object, is_root) { var name, skeleton = {}, value, type, skeleton_value; for (name in source_object) { if (is_root && (this._reserved_members.indexOf(name) != -1 || (name in class_data.shared))) { continue; } value = source_object[name]; type = Firestorm.getType(value); switch (type) { case 'null': case 'boolean': case 'number': skeleton_value = {type: this.MEMBER_TYPES.PRIMITIVE, value: value}; break; case 'string': skeleton_value = {type: this.MEMBER_TYPES.STRING, value: value}; break; case 'function': skeleton_value = {type: this.MEMBER_TYPES.FUNCTION, index: class_data.references.length}; class_data.references.push(value); break; case 'regexp': skeleton_value = {type: this.MEMBER_TYPES.REGEXP, index: class_data.references.length}; class_data.references.push(value); break; case 'object': skeleton_value = { type: this.MEMBER_TYPES.OBJECT, skeleton: this._disassemble(class_data, value, false) };
javascript
{ "resource": "" }
q6032
train
function(skeleton, class_data, padding, serialized_properties) { var name, serialized_value, uses_references = false, object_properties; for (name in skeleton) { switch (skeleton[name].type) { case this.MEMBER_TYPES.STRING: serialized_value = Firestorm.String.quote(skeleton[name].value); break; case this.MEMBER_TYPES.PRIMITIVE: // null, boolean, number serialized_value = skeleton[name].value + ''; break; case this.MEMBER_TYPES.REGEXP: case this.MEMBER_TYPES.FUNCTION: serialized_value = 'r[' + skeleton[name].index + ']'; uses_references = true; break; case this.MEMBER_TYPES.EMPTY_ARRAY: serialized_value = "[]"; break; case this.MEMBER_TYPES.INLINE_ARRAY: serialized_value = this._serializeInlineArray(skeleton[name].value); break; case this.MEMBER_TYPES.SLICE_ARRAY: serialized_value = 'r[' + skeleton[name].index + '].slice()'; uses_references = true; break; case this.MEMBER_TYPES.OBJECT: object_properties = []; if (this._serializeSkeleton(skeleton[name].skeleton,
javascript
{ "resource": "" }
q6033
train
function(path_segments) { var namespace, segment_name, count = path_segments.length, i = 1; if (!count) Lava.t("ClassManager: class names must include a namespace, even for global classes."); if (!(path_segments[0] in this._root)) Lava.t("[ClassManager] namespace is not registered: " + path_segments[0]); namespace = this._root[path_segments[0]]; for
javascript
{ "resource": "" }
q6034
train
function(class_path, default_namespace) { if (!(class_path in this.constructors) && default_namespace) { class_path = default_namespace
javascript
{ "resource": "" }
q6035
train
function(data) { var tempResult = [], i = 0, count = data.length, type, value; for (; i < count; i++) { type = Firestorm.getType(data[i]); switch (type) { case 'string': value = Firestorm.String.quote(data[i]); break; case 'null': case 'undefined': case 'boolean':
javascript
{ "resource": "" }
q6036
train
function(class_data) { var skeleton = class_data.skeleton, name, serialized_value, serialized_actions = [], is_polymorphic = !class_data.is_monomorphic; for (name in skeleton) { switch (skeleton[name].type) { case this.MEMBER_TYPES.REGEXP: case this.MEMBER_TYPES.FUNCTION: serialized_value = 'r[' + skeleton[name].index + ']'; break; //case 'undefined': case this.MEMBER_TYPES.STRING: if (is_polymorphic) { serialized_value = '"' + skeleton[name].value.replace(/\"/g, "\\\"") + '"'; } break; case this.MEMBER_TYPES.PRIMITIVE: // null, boolean, number if (is_polymorphic) { serialized_value = skeleton[name].value + ''; } break; } if (serialized_value) { if (Lava.VALID_PROPERTY_NAME_REGEX.test(name))
javascript
{ "resource": "" }
q6037
train
function(class_datas) { for (var i = 0, count = class_datas.length;
javascript
{ "resource": "" }
q6038
train
function(class_data) { var class_path = class_data.path, namespace_path, class_name, namespace; if ((class_path in this._sources) || (class_path in this.constructors)) Lava.t("Class is already defined: " + class_path); this._sources[class_path] = class_data; if (class_data.constructor) {
javascript
{ "resource": "" }
q6039
train
function(base_path, suffix) { if (Lava.schema.DEBUG && !(base_path in this._sources)) Lava.t("[getPackageConstructor] Class not found: " + base_path); var path, current_class = this._sources[base_path],
javascript
{ "resource": "" }
q6040
$$core$$ResolveLocale
train
function /* 9.2.5 */$$core$$ResolveLocale (availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) { if (availableLocales.length === 0) { throw new ReferenceError('No locale data has been provided for this object yet.'); } // The following steps are taken: var // 1. Let matcher be the value of options.[[localeMatcher]]. matcher = options['[[localeMatcher]]']; // 2. If matcher is "lookup", then if (matcher === 'lookup') var // a. Let r be the result of calling the LookupMatcher abstract operation // (defined in 9.2.3) with arguments availableLocales and // requestedLocales. r = $$core$$LookupMatcher(availableLocales, requestedLocales); // 3. Else else var // a. Let r be the result of calling the BestFitMatcher abstract // operation (defined in 9.2.4) with arguments availableLocales and // requestedLocales. r = $$core$$BestFitMatcher(availableLocales, requestedLocales); var // 4. Let foundLocale be the value of r.[[locale]]. foundLocale = r['[[locale]]']; // 5. If r has an [[extension]] field, then if ($$core$$hop.call(r, '[[extension]]')) var // a. Let extension be the value of r.[[extension]]. extension = r['[[extension]]'], // b. Let extensionIndex be the value of r.[[extensionIndex]]. extensionIndex = r['[[extensionIndex]]'], // c. Let split be the standard built-in function object defined in ES5, // 15.5.4.14. split = String.prototype.split, // d. Let extensionSubtags be the result of calling the [[Call]] internal // method of split with extension as the this value and an argument // list containing the single item "-". extensionSubtags = split.call(extension, '-'), // e. Let extensionSubtagsLength be the result of calling the [[Get]] // internal method of extensionSubtags with argument "length". extensionSubtagsLength = extensionSubtags.length; var // 6. Let result be a new Record. result = new $$core$$Record(); // 7. Set result.[[dataLocale]] to foundLocale. result['[[dataLocale]]'] = foundLocale; var // 8. Let supportedExtension be "-u". supportedExtension = '-u', // 9. Let i be 0. i = 0, // 10. Let len be the result of calling the [[Get]] internal method of // relevantExtensionKeys with argument "length". len = relevantExtensionKeys.length; // 11 Repeat while i < len: while (i < len) { var // a. Let key be the result of calling the [[Get]] internal method of // relevantExtensionKeys with argument ToString(i). key = relevantExtensionKeys[i], // b. Let foundLocaleData be the result of calling the [[Get]] internal // method of localeData with the argument foundLocale. foundLocaleData = localeData[foundLocale], // c. Let keyLocaleData be the result of calling the [[Get]] internal // method of foundLocaleData with the argument key. keyLocaleData = foundLocaleData[key], // d. Let value be the result of calling the [[Get]] internal method of // keyLocaleData with argument "0". value = keyLocaleData['0'], // e. Let supportedExtensionAddition be "". supportedExtensionAddition = '', // f. Let indexOf be the standard built-in function object defined in // ES5, 15.4.4.14. indexOf = $$core$$arrIndexOf; // g. If extensionSubtags is not undefined, then if (extensionSubtags !== undefined) { var // i. Let keyPos be the result of calling the [[Call]] internal // method of indexOf with extensionSubtags as the this value and // an argument list containing the single item key. keyPos = indexOf.call(extensionSubtags, key); // ii. If keyPos ≠ -1, then if (keyPos !== -1) { // 1. If keyPos + 1 < extensionSubtagsLength and the length of the // result of calling the [[Get]] internal method of // extensionSubtags with argument ToString(keyPos +1) is greater // than 2, then if (keyPos + 1 < extensionSubtagsLength && extensionSubtags[keyPos + 1].length > 2) { var // a. Let requestedValue be the result of calling the [[Get]] // internal method of extensionSubtags with argument // ToString(keyPos + 1). requestedValue = extensionSubtags[keyPos + 1], // b. Let valuePos be the result of calling the [[Call]] // internal method of indexOf with keyLocaleData as the // this value and an argument list containing the single // item requestedValue. valuePos = indexOf.call(keyLocaleData, requestedValue); // c. If valuePos ≠ -1, then if (valuePos !== -1) var // i. Let value be requestedValue. value = requestedValue, // ii. Let supportedExtensionAddition be the // concatenation of "-", key, "-", and value.
javascript
{ "resource": "" }
q6041
$$core$$GetOption
train
function /*9.2.9 */$$core$$GetOption (options, property, type, values, fallback) { var // 1. Let value be the result of calling the [[Get]] internal method of // options with argument property. value = options[property]; // 2. If value is not undefined, then if (value !== undefined) { // a. Assert: type is "boolean" or "string". // b. If type is "boolean", then let value be ToBoolean(value). // c. If type
javascript
{ "resource": "" }
q6042
$$core$$GetNumberOption
train
function /* 9.2.10 */$$core$$GetNumberOption (options, property, minimum, maximum, fallback) { var // 1. Let value be the result of calling the [[Get]] internal method of // options with argument property. value = options[property]; // 2. If value is not undefined, then if (value !== undefined) { // a. Let value be ToNumber(value). value = Number(value); // b. If value is NaN or less than minimum or greater than maximum, throw a
javascript
{ "resource": "" }
q6043
$$core$$calculateScore
train
function $$core$$calculateScore (options, formats, bestFit) { var // Additional penalty type when bestFit === true diffDataTypePenalty = 8, // 1. Let removalPenalty be 120. removalPenalty = 120, // 2. Let additionPenalty be 20. additionPenalty = 20, // 3. Let longLessPenalty be 8. longLessPenalty = 8, // 4. Let longMorePenalty be 6. longMorePenalty = 6, // 5. Let shortLessPenalty be 6. shortLessPenalty = 6, // 6. Let shortMorePenalty be 3. shortMorePenalty = 3, // 7. Let bestScore be -Infinity. bestScore = -Infinity, // 8. Let bestFormat be undefined. bestFormat, // 9. Let i be 0. i = 0, // 10. Let len be the result of calling the [[Get]] internal method of formats with argument "length". len = formats.length; // 11. Repeat while i < len: while (i < len) { var // a. Let format be the result of calling the [[Get]] internal method of formats with argument ToString(i). format = formats[i], // b. Let score be 0. score = 0; // c. For each property shown in Table 3: for (var property in $$core$$dateTimeComponents) { if (!$$core$$hop.call($$core$$dateTimeComponents, property)) continue; var // i. Let optionsProp be options.[[<property>]]. optionsProp = options['[['+ property +']]'], // ii. Let formatPropDesc be the result of calling the [[GetOwnProperty]] internal method of format // with argument property. // iii. If formatPropDesc is not undefined, then // 1. Let formatProp be the result of calling the [[Get]] internal method of format with argument property. formatProp = $$core$$hop.call(format, property) ? format[property] : undefined; // iv. If optionsProp is undefined and formatProp is not undefined,
javascript
{ "resource": "" }
q6044
$$core$$resolveDateString
train
function $$core$$resolveDateString(data, ca, component, width, key) { // From http://www.unicode.org/reports/tr35/tr35.html#Multiple_Inheritance: // 'In clearly specified instances, resources may inherit from within the same locale. // For example, ... the Buddhist calendar inherits from the Gregorian calendar.' var obj = data[ca] && data[ca][component] ? data[ca][component] : data.gregory[component],
javascript
{ "resource": "" }
q6045
$$core$$createRegExpRestore
train
function $$core$$createRegExpRestore () { var esc = /[.?*+^$[\]\\(){}|-]/g, lm = RegExp.lastMatch || '', ml = RegExp.multiline ? 'm' : '', ret = { input: RegExp.input }, reg = new $$core$$List(), has = false, cap = {}; // Create a snapshot of all the 'captured' properties for (var i = 1; i <= 9; i++) has = (cap['$'+i] = RegExp['$'+i]) || has; // Now we've snapshotted some properties, escape the lastMatch string lm = lm.replace(esc, '\\$&'); // If any of the captured strings were non-empty, iterate over them all if (has) { for (var i = 1; i <= 9; i++) { var m = cap['$'+i]; // If it's empty, add an empty capturing group if (!m) lm = '()' + lm; //
javascript
{ "resource": "" }
q6046
$$core$$toLatinUpperCase
train
function $$core$$toLatinUpperCase (str) { var i = str.length; while (i--) { var ch = str.charAt(i); if (ch >= "a" && ch <= "z")
javascript
{ "resource": "" }
q6047
PersistInNode
train
function PersistInNode(n) { RED.nodes.createNode(this,n); var node = this; node.name = n.name; node.storageNode = RED.nodes.getNode(n.storageNode);
javascript
{ "resource": "" }
q6048
PersistOutNode
train
function PersistOutNode(n) { RED.nodes.createNode(this,n); var node = this; node.name = n.name; node.storageNode = RED.nodes.getNode(n.storageNode); node.restore = function() { var msg = node.storageNode.getMessage(node.name); node.send(msg); }; RED.events.on("nodes-started", node.restore);
javascript
{ "resource": "" }
q6049
isMethodCall
train
function isMethodCall(node) { var nodeParentType = node.parent.type, nodeParentParentParentType = node.parent.parent.parent.type; if (nodeParentType === "CallExpression" && nodeParentParentParentType === "BlockStatement" && !variable) {
javascript
{ "resource": "" }
q6050
broadcast
train
function broadcast (subscriptions, type) { return value => { subscriptions.forEach(s => { if
javascript
{ "resource": "" }
q6051
train
function (){ var outputPropertyName, callback, inputPropertyNames, inputs, output; if(arguments.length === 0){ return configurationProperty(); } else if(arguments.length === 1){ if(typeof arguments[0] === "object"){ // The invocation is of the form model(configuration) return setConfiguration(arguments[0]); } else { // The invocation is of the form model(propertyName) return addProperty(arguments[0]); } } else if(arguments.length === 2){ if(typeof arguments[0] === "function"){ // The invocation is of the form model(callback, inputPropertyNames) inputPropertyNames = arguments[1]; callback = arguments[0]; outputPropertyName = undefined; } else { // The invocation is of the form model(propertyName, defaultValue) return addProperty(arguments[0], arguments[1]); } } else if(arguments.length === 3){ outputPropertyName = arguments[0]; callback = arguments[1]; inputPropertyNames = arguments[2]; } // inputPropertyNames may be a string of comma-separated property names, // or an array of property names. if(typeof inputPropertyNames === "string"){ inputPropertyNames = inputPropertyNames.split(",").map(invoke("trim")); } inputs = inputPropertyNames.map(function (propertyName){ var property = getProperty(propertyName); if(typeof property === "undefined"){
javascript
{ "resource": "" }
q6052
addProperty
train
function addProperty(propertyName, defaultValue){ if(model[propertyName]){ throw new Error("The property \"" + propertyName + "\" is already defined."); } var property = ReactiveProperty(defaultValue);
javascript
{ "resource": "" }
q6053
expose
train
function expose(){ // TODO test this // if(!isDefined(defaultValue)){ // throw new Error("model.addPublicProperty() is being " + // "invoked with an undefined default value. Default values for exposed properties " + // "must be defined, to guarantee predictable behavior. For exposed properties that " + // "are optional and should have the semantics of an undefined value, " + // "use null as the default value."); //} // TODO test this if(!lastPropertyAdded){ throw Error("Expose() was called without first adding a property."); } var propertyName = lastPropertyAdded; if(!exposedProperties){ exposedProperties = []; } exposedProperties.push(propertyName); // Destroy the previous reactive function that was listening for changes // in all exposed properties except the newly added one. // TODO think about how this might be done only once, at the same time isFinalized is set. if(configurationReactiveFunction){ configurationReactiveFunction.destroy(); } // Set up the new reactive function
javascript
{ "resource": "" }
q6054
destroy
train
function destroy(){ // Destroy reactive functions. reactiveFunctions.forEach(invoke("destroy")); if(configurationReactiveFunction){ configurationReactiveFunction.destroy(); } // Destroy properties (removes listeners). Object.keys(model).forEach(function (propertyName){ var property =
javascript
{ "resource": "" }
q6055
tiler
train
function tiler(root, options) { this.root = root; options = options || {}; options.packSize = options.packSize || 128; if (!options.storageFormat) {
javascript
{ "resource": "" }
q6056
train
function (id, type) { if (this.state.sourcePageID !== id) { var selectedPage; this.state.pages.forEach(function (page) { if (parseInt(page.id, 10) === parseInt(id, 10)) { selectedPage = page; } }); if (!selectedPage) { console.warn('Page not found.'); return; } var currentZoom = this.state.matrix[0]; var {x,
javascript
{ "resource": "" }
q6057
appendDirEnd
train
function appendDirEnd(str, struct) { if (!struct.block) { return str; } const [rightSpace] = rightWSRgxp.exec(str); str = str.replace(rightPartRgxp, ''); const s = alb + lb, e = rb; let tmp; if (needSpace) { tmp = `${struct.trim.right ? '' : eol}${endDirInit ? '' : `${s}__&+__${e}`}${struct.trim.right ? eol : ''}`; } else
javascript
{ "resource": "" }
q6058
train
function() { var fonts = ["Roboto", "Bitter", "Pacifico"]; var options = fonts.map(name => { // setting style on an <option> does not work in WebView... return <option key={name} value={name}>{name}</option>;
javascript
{ "resource": "" }
q6059
callback
train
function callback(fn, context, event) { //window.setTimeout(function(){ event.target = context;
javascript
{ "resource": "" }
q6060
polyfill
train
function polyfill() { if (navigator.userAgent.match(/MSIE/) || navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Edge/)) {
javascript
{ "resource": "" }
q6061
readBlobAsDataURL
train
function readBlobAsDataURL(blob, path) { var reader = new FileReader(); reader.onloadend = function(loadedEvent) { var dataURL = loadedEvent.target.result; var blobtype = 'Blob'; if (blob instanceof File) {
javascript
{ "resource": "" }
q6062
updateEncodedBlob
train
function updateEncodedBlob(dataURL, path, blobtype) { var encoded = queuedObjects.indexOf(path); path = path.replace('$','derezObj'); eval(path+'.$enc="'+dataURL+'"');
javascript
{ "resource": "" }
q6063
dataURLToBlob
train
function dataURLToBlob(dataURL) { var BASE64_MARKER = ';base64,', contentType, parts, raw; if (dataURL.indexOf(BASE64_MARKER) === -1) { parts = dataURL.split(','); contentType = parts[0].split(':')[1]; raw = parts[1];
javascript
{ "resource": "" }
q6064
train
function(key) { var key32 = Math.abs(key).toString(32); // Get the index of the decimal. var decimalIndex = key32.indexOf("."); // Remove the decimal. key32 = (decimalIndex !== -1) ? key32.replace(".", "") : key32; // Get the index of the first significant digit. var significantDigitIndex = key32.search(/[^0]/); // Truncate leading zeros. key32 = key32.slice(significantDigitIndex); var sign, exponent = zeros(2), mantissa = zeros(11); // Finite cases: if (isFinite(key)) { // Negative cases: if (key < 0) { // Negative exponent case: if (key > -1) { sign = signValues.indexOf("smallNegative"); exponent = padBase32Exponent(significantDigitIndex); mantissa = flipBase32(padBase32Mantissa(key32)); } // Non-negative exponent case: else { sign = signValues.indexOf("bigNegative"); exponent = flipBase32(padBase32Exponent( (decimalIndex !== -1) ? decimalIndex : key32.length )); mantissa = flipBase32(padBase32Mantissa(key32)); } } // Non-negative cases: else
javascript
{ "resource": "" }
q6065
train
function(key) { var sign = +key.substr(2, 1); var exponent = key.substr(3, 2); var mantissa = key.substr(5, 11); switch (signValues[sign]) { case "negativeInfinity": return -Infinity; case "positiveInfinity": return Infinity; case "bigPositive": return pow32(mantissa, exponent); case "smallPositive": exponent = negate(flipBase32(exponent)); return pow32(mantissa, exponent); case "smallNegative": exponent = negate(exponent);
javascript
{ "resource": "" }
q6066
flipBase32
train
function flipBase32(encoded) { var flipped = ""; for (var i = 0; i < encoded.length; i++) { flipped += (31 -
javascript
{ "resource": "" }
q6067
validate
train
function validate(key) { var type = getType(key); if (type === "array") { for (var i = 0; i < key.length; i++) { validate(key[i]); } }
javascript
{ "resource": "" }
q6068
getValue
train
function getValue(source, keyPath) { try { if (keyPath instanceof Array) { var arrayValue = []; for (var i = 0; i < keyPath.length; i++) { arrayValue.push(eval("source." + keyPath[i])); } return arrayValue; } else {
javascript
{ "resource": "" }
q6069
setValue
train
function setValue(source, keyPath, value) { var props = keyPath.split('.'); for (var i = 0; i < props.length - 1;
javascript
{ "resource": "" }
q6070
isMultiEntryMatch
train
function isMultiEntryMatch(encodedEntry, encodedKey) { var keyType = collations[encodedKey.substring(0, 1)]; if (keyType === "array") {
javascript
{ "resource": "" }
q6071
createNativeEvent
train
function createNativeEvent(type, debug) { var event = new Event(type); event.debug = debug; // Make the "target" writable
javascript
{ "resource": "" }
q6072
ShimEvent
train
function ShimEvent(type, debug) { this.type = type; this.debug = debug; this.bubbles = false; this.cancelable = false;
javascript
{ "resource": "" }
q6073
createNativeDOMException
train
function createNativeDOMException(name, message) { var e = new DOMException.prototype.constructor(0, message);
javascript
{ "resource": "" }
q6074
createNativeDOMError
train
function createNativeDOMError(name, message) { name = name || 'DOMError'; var e = new DOMError(name, message); e.name === name || (e.name = name);
javascript
{ "resource": "" }
q6075
createError
train
function createError(name, message) { var e = new Error(message);
javascript
{ "resource": "" }
q6076
createSysDB
train
function createSysDB(success, failure) { function sysDbCreateError(tx, err) { err = idbModules.util.findError(arguments); idbModules.DEBUG && console.log("Error in sysdb transaction - when creating dbVersions", err); failure(err); } if (sysdb) { success(); } else { sysdb = window.openDatabase("__sysdb__", 1, "System Database", DEFAULT_DB_SIZE);
javascript
{ "resource": "" }
q6077
train
function(args) { if (!args.src) { ret = new Error('metalsmith-convert: "src" arg is required'); return; } if (!args.target) { // use source-format for target in convertFile args.target = '__source__'; } var ext = args.extension || '.' + args.target; if (!args.nameFormat) { if (args.resize) { args.nameFormat = '%b_%x_%y%e'; } else { args.nameFormat = '%b%e'; } } if (!!args.remove
javascript
{ "resource": "" }
q6078
timedLog
train
function timedLog(msg) { console.log(Date.now()
javascript
{ "resource": "" }
q6079
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); // Calculate actual height of element so we can calculate bounds properly positionable.rect = positionable.refs.styleWrapper.getBoundingClientRect(); if (debug) { timedLog("startmark"); } if(!evt.touches || evt.touches.length === 1) { if (debug) {
javascript
{ "resource": "" }
q6080
train
function(evt) { if (debug) { timedLog("endmark"); } if(evt.touches && evt.touches.length > 0) { if (handlers.endSecondFinger(evt)) { return; } } if (debug) { timedLog("endmark - continued"); } mark = copy(positionable.state); var modified = transform.modified; transform = resetTransform(); // Only fire a tap
javascript
{ "resource": "" }
q6081
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); if (debug) { timedLog("secondFinger"); } if (evt.touches.length < 2) { return; } // we need to rebind finger 1, because it may have moved! transform.x1 = evt.touches[0].pageX;
javascript
{ "resource": "" }
q6082
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); if (debug) { timedLog("endSecondFinger"); } if (evt.touches.length > 1) { if (debug) { timedLog("endSecondFinger - capped"); } return true; } if (debug) { timedLog("endSecondFinger
javascript
{ "resource": "" }
q6083
tryFormat
train
function tryFormat(body) { try { const parsed = typeof body === 'string' ? JSON.parse(body) : body return
javascript
{ "resource": "" }
q6084
formatReport
train
function formatReport() { // eslint-disable-line no-unused-vars const lineCoverage = new LineCoverage(2, 2, [ new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'), new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w') ]); const record = new Record('/home/cedx/lcov.js/fixture.js', {
javascript
{ "resource": "" }
q6085
parseReport
train
async function parseReport() { // eslint-disable-line no-unused-vars try { const coverage = await promises.readFile('lcov.info', 'utf8'); const report = Report.fromCoverage(coverage); console.log(`The coverage report
javascript
{ "resource": "" }
q6086
range
train
function range(from, to) { // TODO: make this inlined. const list = new Array(to
javascript
{ "resource": "" }
q6087
setupBrowserStorage
train
function setupBrowserStorage(){ if(browser || storageMock){ if(storageMock){ store = storageMock; storageKey = 'cache-module-storage-mock'; } else{ var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null; store = (storageType && typeof Storage !== void(0)) ? window[storageType + 'Storage'] : false; storageKey = (storageType) ? self.type + '-' + storageType + '-storage' : null; } if(store){ var db = store.getItem(storageKey); try { cache =
javascript
{ "resource": "" }
q6088
overwriteBrowserStorage
train
function overwriteBrowserStorage(){ if((browser && store) || storageMock){ var db = cache; try { db =
javascript
{ "resource": "" }
q6089
handleRefreshResponse
train
function handleRefreshResponse (key, data, err, response) { if(!err) { this.set(key, response,
javascript
{ "resource": "" }
q6090
log
train
function log(isError, message, data){ if(self.verbose || isError){ if(data) console.log(self.type + ': ' + message,
javascript
{ "resource": "" }
q6091
WebRequest
train
function WebRequest (options, callback) { request(options, function (err, response, body) { if (err) {
javascript
{ "resource": "" }
q6092
train
function(options) { var out = this.formatEmpty(), data = [], rels; this.init(); options = (options)? options : {}; this.mergeOptions(options); this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ this.errors.push(this.noContentErr); }else{ // only parse h-* microformats if we need to // this is added to speed up parsing if(this.hasMicroformats(this.rootNode, options)){ this.prepareDOM( options ); if(this.options.filters.length > 0){ // parse flat list of items var newRootNode = this.findFilterNodes(this.rootNode, this.options.filters); data = this.walkRoot(newRootNode); }else{ // parse whole document from root data = this.walkRoot(this.rootNode);
javascript
{ "resource": "" }
q6093
train
function(node, options) { this.init(); options = (options)? options : {}; if(node){
javascript
{ "resource": "" }
q6094
train
function( options ) { var out = {}, items, classItems, x, i; this.init(); options = (options)? options : {}; this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ return {'errors': [this.noContentErr]}; }else{ items = this.findRootNodes( this.rootNode, true ); i = items.length; while(i--) { classItems = modules.domUtils.getAttributeList(items[i], 'class'); x = classItems.length; while(x--) { // find v2 names if(modules.utils.startWith( classItems[x], 'h-' )){ this.appendCount(classItems[x], 1, out); } // find v1 names for(var key in modules.maps)
javascript
{ "resource": "" }
q6095
train
function( node, options ) { var classes, i; if(!node){ return false; } // if documemt gets topmost node node = modules.domUtils.getTopMostNode( node ); // look for h-* microformats classes = this.getUfClassNames(node); if(options && options.filters && modules.utils.isArray(options.filters)){ i = options.filters.length;
javascript
{ "resource": "" }
q6096
train
function( node, options ) { var items, i; if(!node){ return false; } // if browser based documemt get topmost node node = modules.domUtils.getTopMostNode( node ); // returns all microformat roots items = this.findRootNodes( node, true ); if(options && options.filters && modules.utils.isArray(options.filters)){
javascript
{ "resource": "" }
q6097
train
function( maps ){ maps.forEach(function(map){ if(map && map.root &&
javascript
{ "resource": "" }
q6098
train
function (node, options, recursive) { options = (options)? options : {}; // recursive calls if (recursive === undefined) { if (node.parentNode && node.nodeName !== 'HTML'){ return this.getParentTreeWalk(node.parentNode, options, true); }else{ return this.formatEmpty();
javascript
{ "resource": "" }
q6099
train
function( options ){ var baseTag, href; // use current document to define baseUrl, try/catch needed for IE10+ error try { if (!options.baseUrl && this.document && this.document.location) { this.options.baseUrl = this.document.location.href; } } catch (e) { // there is no alt action } // find base tag to set baseUrl baseTag = modules.domUtils.querySelector(this.document,'base'); if(baseTag) { href = modules.domUtils.getAttribute(baseTag, 'href'); if(href){ this.options.baseUrl = href; } } // get path to rootNode // then clone document // then reset the rootNode to its cloned version in a new document var path,
javascript
{ "resource": "" }