_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q55700
fetchFunction
train
function fetchFunction(url, key, data, fetchLinkNames, recursive, fetchMultiple) { if (config.fetchFunction == undefined) { var promisesArray = []; promisesArray.push($injector.get("$http").get(url) .then(function (responseData) { ...
javascript
{ "resource": "" }
q55701
getProcessedUrl
train
function getProcessedUrl(data, resourceName) { // get the raw URL out of the resource name and check if it is valid var rawUrl = checkUrl(data[config.linksKey][resourceName][config.linksHrefKey], resourceName, config.linksHrefKey);
javascript
{ "resource": "" }
q55702
extractUrlTemplates
train
function extractUrlTemplates(resourceName) { if (hasUrlTemplate(resourceName)) { var indexOfSlash = resourceName.indexOf("/");
javascript
{ "resource": "" }
q55703
train
function(e) { this.hasFocus = true; this.setSelectionIfNeeded(e.target); if (this.props.onFocus) {
javascript
{ "resource": "" }
q55704
train
function(tagName) { return function() { return laconic.apply(this,
javascript
{ "resource": "" }
q55705
extractJsdoc
train
function extractJsdoc(comment) { var docAst = doctrine.parse(comment, { unwrap: true, sloppy: true }); if (!docAst.tags || docAst.tags.length === 0) { return null; } // only interested in @param @property, and @return var paramTags = docAst.tags.filter(function(tag) { return tag.titl...
javascript
{ "resource": "" }
q55706
getCommentedFunctionNode
train
function getCommentedFunctionNode(node) { if (!node.leadingComments) { // JSDoc comments are always before the function, so if there is // nothing here, we ain't interested. return null; } // console.log("================="); // console.log("type: " + node.type); // console.l...
javascript
{ "resource": "" }
q55707
decorateClasses
train
function decorateClasses(node) { // check for class nodes var clsNode = getCommentedClassNode(node); if (!clsNode || !clsNode.jsdoc || clsNode.jsdoc.props.length === 0) { return; } var clsSrc = clsNode.node.source(); if (clsSrc[0] !== "{") { // something isn't right, bail. ...
javascript
{ "resource": "" }
q55708
validate
train
function validate(message, type) { assert( typeOf(message) === 'object', 'You must pass a message object.', ); rules.forEach((rule) => { if (message[rule.name]) { const types = [].concat(rule.types);
javascript
{ "resource": "" }
q55709
merge
train
function merge(src1, src2) { var merged = {}; extend(merged, src1);
javascript
{ "resource": "" }
q55710
getChannelsSchedule
train
function getChannelsSchedule(channel,date){ var p = '/ibl/v1/channels/{channel}/schedule/{date}'; p =
javascript
{ "resource": "" }
q55711
BehaviorInterfaceError
train
function BehaviorInterfaceError(baseBehavior, extendingBehavior, missingProps) { var extendingName = extendingBehavior.behaviorName || 'anonymous behavior', baseName = baseBehavior.__behaviorName || 'anonymous behavior', message = 'can-connect: Extending behavior "' + extendingName + '" found base behavior "' + ba...
javascript
{ "resource": "" }
q55712
enableHID
train
async function enableHID() { const usbConfig = getstrprop('sys.usb.state'); if (!usbConfig.startsWith('hid,')) { log.warn('HID function does not seem to be enabled.'); const usbConfigWithHid = `hid,${usbConfig}`; log.info(`changing USB config to ${usbConfigWithHid}`); // WARNING! If this device is...
javascript
{ "resource": "" }
q55713
ensureSetup
train
function ensureSetup(argv) { const root = findPackageRoot(); const emulatorBin = path.join(root, 'node_modules/silk-sdk-emulator/vendor/bin'); // Additional paths to search for outside of PATH. const additionalPaths = []; if (fs.existsSync(emulatorBin)) { additionalPaths.push(emulatorBin); } argv.a...
javascript
{ "resource": "" }
q55714
fetchCdnVersion
train
function fetchCdnVersion(cdnUrl) { var fullUrl = cdnUrl + path.sep + SONAR_RUNNER_DIST; console.log('Fetching sonar-runner from CDN url [' + fullUrl + '].'); try { var response = request('GET', fullUrl); if(response.statusCode === 200) { var destination = ...
javascript
{ "resource": "" }
q55715
copyFiles
train
function copyFiles(g, defaultOutputDir, targetDir) { var files = glob.sync(g.src.toString(), {cwd: g.cwd, root: '/'}); files.forEach(function (file) { var destinationDirectory = defaultOutputDir + path.sep + targetDir; var fileDirectory = path.dirname(file); ...
javascript
{ "resource": "" }
q55716
mergeJson
train
function mergeJson(original, override) { return _.merge(original, override, function (a, b, key, aParent, bParent) { if (_.isUndefined(b)) {
javascript
{ "resource": "" }
q55717
buildArgs
train
function buildArgs(sonarOptions, data) { // Default arguments var args = [ '-Dsonar.sources=src', '-Dsonar.tests=test', '-Dsonar.javascript.jstestdriver.reportsPath=results', '-Dsonar.genericcoverage.unitTestReportPaths=' + 'results...
javascript
{ "resource": "" }
q55718
createPage
train
function createPage() { var page = new View(view.clone(), lazy.extend({}, view.options, opts));
javascript
{ "resource": "" }
q55719
train
function (prop, fn) { if (typeof prop === 'function') { fn = prop; prop = undefined; } if (typeof prop ===
javascript
{ "resource": "" }
q55720
train
function (fn) { var items = this.items; var sorted = lazy.sortObject(this.keyMap, {prop: undefined, get: fn}); var keys = Object.keys(sorted); var len = keys.length, i = -1; var arr = new Array(len); while (++i < len) {
javascript
{ "resource": "" }
q55721
train
function (prop) { var keys = Object.keys(this.keyMap); var items = this.items.map(function (item, i) { item.key = keys[i]; return item;
javascript
{ "resource": "" }
q55722
File
train
function File(file, options) { Item.call(this, file, options);
javascript
{ "resource": "" }
q55723
train
function (file) { this.src = file.src || {}; if (this.path) { this.src.path = this.path; } if (Buffer.isBuffer(this.contents)) { this.content = this.contents.toString(); } if (this.content) { this.options.orig = this.content; } // ensure that `file` has `path` and `con...
javascript
{ "resource": "" }
q55724
train
function(key) { var fn = this.pickOption('renameKey'); if (!fn) { fn = this.collection.renameKey || this.app.renameKey; }
javascript
{ "resource": "" }
q55725
View
train
function View(view, options) { this.history = []; Item.call(this, view,
javascript
{ "resource": "" }
q55726
train
function (view) { view.base = view.base || view.cwd || process.cwd(); this.src = this.src || {}; // ensure that `view` has `path` and `content` properties this.validate(view); this.options.orig = view.content; this.options.plural = this.collection.options.plural; this.options.viewType = thi...
javascript
{ "resource": "" }
q55727
train
function(locals, cb) { if (typeof locals === 'function') { cb = locals; locals = {};
javascript
{ "resource": "" }
q55728
train
function(locals, fn) { if (typeof locals === 'function') { fn = locals; locals = {}; } var res = this.locals; var data = this.app.cache.data; this.ctx('global', data); // extend context with same-named data-property from `app.cache.data` if (!this.hint('extended')) { this...
javascript
{ "resource": "" }
q55729
Collection
train
function Collection(options) { Base.call(this, options); this.define('lists', {}); this.define('_items', {}); this.define('Item', this.options.Item || require('./item')); this.define('List', this.options.List || require('./list')); mixins(this); /** * Get an object representing the current items on th...
javascript
{ "resource": "" }
q55730
train
function (prop, val) { this.setItem(prop, val); if (prop === 'app' || prop ===
javascript
{ "resource": "" }
q55731
train
function (prop, val) { if (prop === 'app' || prop === 'collection') { utils.defineProp(this._items, prop, val);
javascript
{ "resource": "" }
q55732
train
function (name, items) { var List = this.get('List'); var list = this.lists[name]; if (typeof list === 'undefined') { var opts = lazy.clone(this.options); opts.items
javascript
{ "resource": "" }
q55733
train
function (prop, fn) { if (typeof prop === 'function') { fn = prop; prop = undefined; } var items = this.items;
javascript
{ "resource": "" }
q55734
Item
train
function Item(item, options) { Base.call(this, options); this.define('collection', this.options.collection);
javascript
{ "resource": "" }
q55735
train
function(prop) { var opt = this.option(prop); if (typeof opt === 'undefined') { opt = this.collection &&
javascript
{ "resource": "" }
q55736
train
function (data) { var parse = function() { var parsed = lazy.extend({}, lazy.parseFilepath(this.path), data);
javascript
{ "resource": "" }
q55737
train
function(filepath, fn) { fn = fn || lazy.dashify; if (typeof filepath === 'undefined') { var ctx = this.context();
javascript
{ "resource": "" }
q55738
train
function(str) { if (typeof str !== 'string') { str = this.content; } if (typeof str !== 'string') return '';
javascript
{ "resource": "" }
q55739
train
function (options) { options = options || {}; lazy.extend(options, this.options.excerpt || {}); var re = /<!--+\s*more\s*--+>/; var str = this.content; var view = this; var link = options.link || '<a id="more"></a>'; this.content = str.replace(re, function (match, i) { ...
javascript
{ "resource": "" }
q55740
train
function (structure, locals) { if (typeof structure !== 'string') { locals = structure; structure = null; } var self = this; var data = {}; lazy.extend(data, this); lazy.extend(data, this.parsePath()); lazy.extend(data, this.context(locals)); this.data.d...
javascript
{ "resource": "" }
q55741
Views
train
function Views(options) { Collection.call(this, options); this.options.collection = this.options.collection || this;
javascript
{ "resource": "" }
q55742
train
function (key, val) { if (lazy.typeOf(val) !== 'object') {
javascript
{ "resource": "" }
q55743
train
function (key, val) { var opts = lazy.clone(this.options); var View = this.get('View'); val.path = val.path || key; key = val.key = this.renameKey(key);
javascript
{ "resource": "" }
q55744
train
function(prop) { var res = this[prop]; if (typeof res === 'undefined') { var name = this.renameKey(prop); if (name && name !== prop) { res = this[name]; } } if (typeof res === 'undefined') {
javascript
{ "resource": "" }
q55745
train
function (pattern, options) { var self = this; function find() { var isMatch = lazy.mm.matcher(pattern, options); for (var key in self) { var val = self[key]; if (typeof val === 'object' && isMatch(key)) {
javascript
{ "resource": "" }
q55746
train
function (view/*, locals, fn*/) { var args = [].slice.call(arguments, 1); var app =
javascript
{ "resource": "" }
q55747
train
function (prop, pattern, options) { options = options || {}; var views = this.items; var res = Object.create(this); var matcher = pattern ? lazy.mm.isMatch(pattern, options) : null; for (var key in views) { if (views.hasOwnProperty(key)) { var file = views[key]; if (prop === ...
javascript
{ "resource": "" }
q55748
train
function() { this.options.viewType = utils.arrayify(this.options.viewType || []); if (this.options.viewType.length === 0) {
javascript
{ "resource": "" }
q55749
Base
train
function Base(options) { this.define('options', options || {}); this.define('hints', this.hints || {}); this.define('data', this.data || {}); this.define('app', this.app || this.options.app || {}); this.define('_cache', {});
javascript
{ "resource": "" }
q55750
train
function (key, val) { if (this._cache[key]) { return this._cache[key]; } if (typeof val === 'function') {
javascript
{ "resource": "" }
q55751
train
function (keys) { var Parent = this.constructor; var opts = lazy.clone(this.options);
javascript
{ "resource": "" }
q55752
train
function(prop) { var opt = this.option(prop); if (typeof opt === 'undefined') { return this.app
javascript
{ "resource": "" }
q55753
train
function (key, fn) { if (typeof key === 'function') { fn = key; key = null; } if (typeof fn !== 'function') { fn = this.pickOption('renameKey'); } if (typeof fn !== 'function') { fn = utils.identity; } this.options.renameKey =
javascript
{ "resource": "" }
q55754
shortenUrl
train
function shortenUrl ( url , length ) { if( !isBlank( url ) && url.length > length) {
javascript
{ "resource": "" }
q55755
train
function(helpers, options) { if (typeof helpers === 'object') { this.visit('helper', helpers); return this; } if (lazy.isGlob(helpers)) { this.loader('helpers-glob', ['base-glob'], function (files) { return files.map(function (fp) { return require(path.re...
javascript
{ "resource": "" }
q55756
List
train
function List(options) { Base.call(this, options || {}); this.items = []; this.define('keyMap', {});
javascript
{ "resource": "" }
q55757
train
function(key, value) { if (typeof key !== 'string') { throw new TypeError('item key must be a string.'); } if (typeof value === 'undefined') {
javascript
{ "resource": "" }
q55758
train
function (key, value) { var Item = this.get('Item'); if (!(value instanceof Item)) { value = new Item(value); } value.key = value.key || key; var i = this.indexOf(key); if (i !== -1) { this.items[i] = value; } else {
javascript
{ "resource": "" }
q55759
train
function (locals, cb) { if (typeof locals === 'function') { cb = locals; locals = {}; } lazy.each(this.items, function (item, next) {
javascript
{ "resource": "" }
q55760
train
function(exts, fn, options) { if (arguments.length === 1 && typeof exts === 'string') { return this.getEngine(exts); } exts = utils.arrayify(exts); var len = exts.length; while (len--) { var ext = exts[len];
javascript
{ "resource": "" }
q55761
train
function(ext) { ext = ext || this.option('view engine'); if (ext && ext[0] !== '.') { ext = '.' + ext;
javascript
{ "resource": "" }
q55762
train
function(key, val) { if (arguments.length === 1) { if (typeof key === 'string') { if (key.indexOf('.') === -1) { return this.cache.data[key]; } if (lazy.isGlob(key)) { this.compose('data')(key, val);
javascript
{ "resource": "" }
q55763
train
function (methods) { this.lazyLoaders(); var loaders = this.loaders; var self = this; utils.arrayify(methods).forEach(function (method) { self.define(method,
javascript
{ "resource": "" }
q55764
train
function (name, opts, loaders) { var args = utils.slice(arguments, 1); opts = lazy.clone(args.shift()); loaders = args; var single = lazy.inflect.singularize(name); var plural = lazy.inflect.pluralize(name); this.inflections[single] = plural; if (typeof opts.renameKey === 'undefined' && th...
javascript
{ "resource": "" }
q55765
train
function (method, view, locals, cb) { if (typeof locals === 'function') { cb = locals; locals = {}; } this.lazyRouter(); view.options = view.options || {}; view.options.handled = view.options.handled || []; if (typeof cb !== 'function') { cb = this.handleError(method, view); ...
javascript
{ "resource": "" }
q55766
train
function (method, view, locals/*, cb*/) { if (view.options.handled.indexOf(method) === -1) {
javascript
{ "resource": "" }
q55767
train
function(method, view) { return function (err) { if (err) { err.reason =
javascript
{ "resource": "" }
q55768
train
function(path/*, callback*/) { this.lazyRouter(); var route = this.router.route(path);
javascript
{ "resource": "" }
q55769
train
function(view) { if (view.options.layoutApplied) { return view; } // handle pre-layout middleware this.handle('preLayout', view); var opts = {}; lazy.extend(opts, this.options); lazy.extend(opts, view.options); lazy.extend(opts, view.context()); // get the layout stack v...
javascript
{ "resource": "" }
q55770
train
function(view, locals, isAsync) { if (typeof locals === 'boolean') { isAsync = locals; locals = {}; } // get the engine to use locals = locals || {}; var engine = this.engine(locals.engine ? locals.engine : view.engine); if (typeof engine === 'undefined') { throw this.error('...
javascript
{ "resource": "" }
q55771
train
function (view, locals, cb) { if (typeof locals === 'function') { cb = locals; locals = {}; } // if `view` is a function, it's probably from chaining // a collection method if (typeof view === 'function') { return view.call(this); } // if `view` is a string, see if it's a...
javascript
{ "resource": "" }
q55772
train
function (locals, viewTypes) { var names = viewTypes || this.viewTypes.partial; var opts = lazy.extend({}, this.options, locals); return names.reduce(function (acc, name) { var collection = this.views[name]; lazy.forOwn(collection, function (view, key) { // handle `onMerge` middleware ...
javascript
{ "resource": "" }
q55773
train
function (view, ctx, locals) { var obj = {}; lazy.mixin(obj, ctx); lazy.mixin(obj, this.cache.data); lazy.mixin(obj, view.data);
javascript
{ "resource": "" }
q55774
train
function (view, locals, context, isAsync) { var helpers = {}; lazy.extend(helpers, this.options.helpers); lazy.extend(helpers, this._.helpers.sync); if (isAsync) lazy.extend(helpers, this._.helpers.async); lazy.extend(helpers, locals.helpers); // build the context to expose as `this` in helper...
javascript
{ "resource": "" }
q55775
train
function (methods) { this.lazyRouter(); this.router.method(methods); utils.arrayify(methods).forEach(function (method) { this.define(method, function(path) { var route = this.router.route(path);
javascript
{ "resource": "" }
q55776
train
function(collection, pattern, options) { var views = this.getViews(collection); if (views.hasOwnProperty(pattern)) {
javascript
{ "resource": "" }
q55777
train
function(collection, pattern, options) { var views =
javascript
{ "resource": "" }
q55778
train
function(collection, key, fn) { var views = this.getViews(collection); // if a custom renameKey function is passed, try using it if (typeof fn === 'function') { key = fn(key); } if (views.hasOwnProperty(key)) { return views[key]; } // try again with the default ...
javascript
{ "resource": "" }
q55779
train
function(plural) { if (lazy.isObject(plural)) return plural; if (!this.views.hasOwnProperty(plural)) { plural = this.inflections[plural]; } if (!this.views.hasOwnProperty(plural)) {
javascript
{ "resource": "" }
q55780
train
function (view, collection) { if (typeof view === 'string') { if (typeof collection === 'string') { return this[collection].get(view); } var collections = this.viewTypes.renderable; var len = collections.length, i = 0; while (len--) {
javascript
{ "resource": "" }
q55781
register
train
function register(client) { const appId = client.appId; if (registry[appId] && !registry[appId].isDestroyed) { registry[appId].destroy(); }
javascript
{ "resource": "" }
q55782
removeListener
train
function removeListener(listener) { if (listener) { const index = listeners.indexOf(listener); if (index >= 0) listeners.splice(index,
javascript
{ "resource": "" }
q55783
getBin
train
function getBin(filename) { try { return escape(whichLocal.sync(filename)); } catch (unused) {
javascript
{ "resource": "" }
q55784
train
function (sources, tmp) { var instrumenter = new istanbul.Instrumenter(); var instrumentedSources = []; sources.forEach(function (source) { var instrumentedSource = instrumenter.instrumentSync( grunt.file.read(source), source);
javascript
{ "resource": "" }
q55785
train
function (type, options, collector) { istanbul.Report.create(type,
javascript
{ "resource": "" }
q55786
train
function (collector, options) { if (typeof options == 'string' || options instanceof String) { // default to html report at options directory writeReport('html', { dir: options }, collector); } else if (options instanceof Array) { // multiple reports for (var i = 0; i < options.length; i = i + 1) { va...
javascript
{ "resource": "" }
q55787
train
function (collector, options) { var summaries = []; var thresholds = options.thresholds; var files = collector.files(); files.forEach(function(file) { summaries.push(istanbul.utils.summarizeFileCoverage( collector.fileCoverageFor(file))); }); var finalSummary = istanbul.utils.mergeSummaryObjects.apply(nul...
javascript
{ "resource": "" }
q55788
train
function (grunt, task, context) { var template = context.options.template; if (!template) { template = DEFAULT_TEMPLATE; } // clone context var mixedInContext = JSON.parse(JSON.stringify(context));
javascript
{ "resource": "" }
q55789
parseArgs
train
function parseArgs(obj) { var args = []; _.each(obj, function (val, key) { if (_.isArray(val)) { _.each(val, function (val) {
javascript
{ "resource": "" }
q55790
addArg
train
function addArg(args, name, val) { if (!val && val !== 0) { return; } var arg = name.length > 1 ? '--' + _.kebabCase(name) : '-' + name; // --max-old-space-size argument requires an `=` if (arg === '--max-old-space-size') { args.push(arg + '='
javascript
{ "resource": "" }
q55791
expose
train
function expose(obj, namespace, name) { var app = this.app || this; var req = this.req; app._exposed = app._exposed || {}; // support second arg as name // when a string or function is given if ('string' === typeof obj || 'function' === typeof obj) { name = namespace || _name; } else { name = n...
javascript
{ "resource": "" }
q55792
exposed
train
function exposed(name) { name = name || _name; this.js
javascript
{ "resource": "" }
q55793
renderNamespace
train
function renderNamespace(str) { var parts = []; var split = str.split('.'); var len = split.length; return str.split('.').map(function(part, i)
javascript
{ "resource": "" }
q55794
renderObject
train
function renderObject(obj, namespace) { return Object.keys(obj).map(function(key){
javascript
{ "resource": "" }
q55795
string
train
function string(obj) { if ('function' === typeof obj) { return obj.toString(); } else if (obj instanceof Date) { return 'new Date("' + obj + '")'; } else if (Array.isArray(obj)) { return '[' + obj.map(string).join(', ') + ']'; } else if ('[object Object]' === Object.prototype.toString.call(obj)) {
javascript
{ "resource": "" }
q55796
MurmurHash3
train
function MurmurHash3(seed, data) { /* jshint maxstatements: 32, maxcomplexity: 10 */ var c1 = 0xcc9e2d51; var c2 = 0x1b873593; var r1 = 15; var r2 = 13; var m = 5; var n = 0x6b64e654; var hash = seed; function mul32(a, b) { return (a & 0xffff) * b + (((a >>> 16) * b & 0xffff) << 16) & 0xfffffff...
javascript
{ "resource": "" }
q55797
train
function () { var mask = this.mask; var included = _Array_prototype_every.call ( arguments, function (arg)
javascript
{ "resource": "" }
q55798
train
function (environment, engineFeatureObjs) { var resultMask = maskNew(); var thisMask = this.mask; var attributeCache = createEmpty(); ELEMENTARY.forEach ( function (featureObj) { var otherMask = featu...
javascript
{ "resource": "" }
q55799
train
function () { var name = this.name; if (name === undefined) name = '{' + this.canonicalNames.join(', ') +
javascript
{ "resource": "" }