_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q3000 | getClusterVersion | train | function getClusterVersion(request, mCb) {
delete request.project;
v1Container().projects.zones.getServerconfig(request, function (err, response) {
if (err) {
return mCb(err);
}
let version;
if (response && response.validMasterVersions && Array.isArray(response.validMasterVersions)
&& re... | javascript | {
"resource": ""
} |
q3001 | deleteNetwork | train | function deleteNetwork() {
setTimeout(function () {
//cluster failed, delete network if it was not provided by the user
let networksOptions = Object.assign({}, options);
networksOptions.params = {name: oneDeployment.options.network};
networks.delete(networksOptions, (error) => {
if (error) {
... | javascript | {
"resource": ""
} |
q3002 | train | function (options, region, verbose, mCb) {
infraExtras.getRegion(options, region, verbose, (err, resR) => {
if (err) {
infraExtras.getZone(options, region, verbose, (err, resZ) => {
if (err) {
return mCb(err);
} else {
return mCb(null, resZ);
}
});
} else {
return mCb(null... | javascript | {
"resource": ""
} | |
q3003 | train | function (options, cb) {
//call google api and get the machines
let cluster = options.infra.stack;
//Ref: https://cloud.google.com/compute/docs/reference/latest/instances/list
let request = getConnector(options.infra.api);
request.clusterId = cluster.id;
request.filter = "name eq gke-" + cluster.id.subst... | javascript | {
"resource": ""
} | |
q3004 | train | function (options, cb) {
options.soajs.log.debug("Checking if Cluster is healthy ...");
let stack = options.infra.stack;
let containerOptions = Object.assign({}, options);
containerOptions.technology = (containerOptions && containerOptions.params && containerOptions.params.technology) ? containerOptions.... | javascript | {
"resource": ""
} | |
q3005 | _timestampBeforeNow | train | function _timestampBeforeNow(timestamp) {
if(!(typeof timestamp === 'string' && dateRegEx.test(timestamp))) {
throw new TypeError('`revoked` timestamp must be a string.');
}
const now = new Date();
const tsDate = new Date(timestamp);
return tsDate < now;
} | javascript | {
"resource": ""
} |
q3006 | Cassanova | train | function Cassanova(){
this.tables = {};
this.models = {};
this.schemas = {};
this.client = null;
this.options = null;
EventEmitter.call(this);
} | javascript | {
"resource": ""
} |
q3007 | train | function(callback){
var filePath;
output("Processing arguments...");
if(program.cql){
batchQueries.push(program.cql.toString().trim());
}
if((!program.keyspace || program.keyspace.length === 0)){
output("A keyspace has not been defined. CQL will fail if the keyspace is not defined... | javascript | {
"resource": ""
} | |
q3008 | train | function(callback){
var opts = {};
output("Connecting to database...");
//We need to be able to do anything with any keyspace. We just need a db connection. Just send
//in the hosts, username and password, stripping the keyspace.
opts.username = process.env.CASS_USER || config.db.username;
opts.... | javascript | {
"resource": ""
} | |
q3009 | train | function(callback){
var result,
i;
if(!files || files.length === 0){
return callback(null, true);
}
output("Processing queries...");
for(i=0; i<files.length; i++){
while((result = cqlRegex.exec(files[i])) !== null) {
batchQueries.push(result[1].replace(/\s+/g, ... | javascript | {
"resource": ""
} | |
q3010 | train | function(callback){
output("Initializing queries...");
if(program.keyspace){
batchQueries.unshift("USE " + program.keyspace + ";");
}
if(batchQueries && batchQueries.length > 0){
output("Running queries...");
executeQuery(batchQueries.shift(), callback);
}else{
cal... | javascript | {
"resource": ""
} | |
q3011 | train | function(eQuery, callback){
output("Executing:\t\t" + eQuery);
Cassanova.execute(eQuery, function(err) {
if (err){
return callback(err, null);
} else {
if(batchQueries.length > 0){
executeQuery(batchQueries.shift(), callback);
}else{
... | javascript | {
"resource": ""
} | |
q3012 | Event | train | function Event(type, data){
this._sender = null;
this._type = type;
this._data = data;
for(var prop in data) {
this[prop] = data[prop];
}
this._stopPropagation = false;
} | javascript | {
"resource": ""
} |
q3013 | train | function () {
var cwd = process.cwd();
var rootPath = cwd;
var newRootPath = null;
while (!fs.existsSync(path.join(process.cwd(), "node_modules/grunt"))) {
process.chdir("..");
newRootPath = process.cwd();
if (newRootPath === rootPath) {
return;
}
rootPath = newRootPath;
}
process.chdir(c... | javascript | {
"resource": ""
} | |
q3014 | train | function (grunt, rootPath, tasks) {
tasks.forEach(function (name) {
if (name === 'grunt-cli') return;
var cwd = process.cwd();
process.chdir(rootPath); // load files from proper root, I don't want to install everything locally per module!
grunt.loadNpmTasks(name);
process.chdir(cwd);
});
} | javascript | {
"resource": ""
} | |
q3015 | train | function (next) {
minify(
outputCommonsJsFile,
_.extend({optimize: true},uglifyOptions),
function(err){
if ( err ){
return next(err);
}
return next();
}
);
} | javascript | {
"resource": ""
} | |
q3016 | train | function (next) {
minify(
outputJsFile,
_.extend({optimize: true},uglifyOptions),
function(err){
if ( err ){
return next(err);
}
if ( isForPublish ){
publisher(
outputJsFile,
function (err) {
... | javascript | {
"resource": ""
} | |
q3017 | train | function (next) {
for (var i = 0; i < mapFiles.length; i++) {
fs.unlinkSync(mapFiles[i]);
// console.log( path.resolve(mapFiles[i]) );
}
return next();
} | javascript | {
"resource": ""
} | |
q3018 | minify | train | function minify( file, options, done ){
if (_.isFunction(options)){
done = options;
options = {};
}
if (!_.isObject(options))
options = {};
if (!_.isFunction(done))
done = function(){};
const canOptimize = options.optimize;
delete options.optimize;
console.log(" minify file %s...".grey, fil... | javascript | {
"resource": ""
} |
q3019 | publisher | train | function publisher(outputJsFile, done, forceMinified){
// Check if JSCrambler configs file exist
const time = process.hrtime();
const jscramblerConfigs = path.resolve('jscrambler.json');
fs.stat( jscramblerConfigs, function (err) {
if ( err ){
let newTime =
console.log(' obfuscating code with jScram... | javascript | {
"resource": ""
} |
q3020 | train | function(token,options){
options = options||{};
options.token = token;
var obj = {
type:"rest"
,args:{
url: '/v1/sync',
data: options,
method: 'get'
}
};
var s = through();
repipe(s,function(err,last,done){
o.log('repi... | javascript | {
"resource": ""
} | |
q3021 | train | function(token,o){
/*
o.troop
o.scout
o.reports = [led,..]
o.start = now
o.end = then
o.tail defaults true with no end
*/
o.token = token;
var obj = {
type:"rest"
,args:{
url: '/v1/stats',
data: o,
m... | javascript | {
"resource": ""
} | |
q3022 | _serveFile | train | function _serveFile(requestedFile, done) {
requestedFile.path = transformPath(requestedFile.path);
log.debug(`Fetching ${requestedFile.path} from buffer`);
// We get a requestedFile with an sha when Karma is watching files on
// disk, and the file requested changed. When this happens, we need ... | javascript | {
"resource": ""
} |
q3023 | processServeQueue | train | function processServeQueue() {
while (serveQueue.length) {
const item = serveQueue.shift();
_serveFile(item.file, item.done);
// It is possible start compiling while in release.
if (state.compilationCompleted !== _currentState) {
break;
}
}
} | javascript | {
"resource": ""
} |
q3024 | traverse | train | function traverse(transform, node, parent) {
const type = node && node.type;
assert(type, `Expected node, got '${node}'`);
const baseHandler = transform.handlers[type] || transform.handlers.default;
const userHandler = transform.userHandlers[type] || transform.userHandlers.default;
const starHandle... | javascript | {
"resource": ""
} |
q3025 | Table | train | function Table(name, schema){
if(!name || typeof name !== "string"){
throw new Error("Attempting to instantiate a table without a valid name.");
}
if(!schema || !(schema instanceof Schema)){
throw new Error("Attempting to instantiate a table without a valid schema.");
}
this.name = ... | javascript | {
"resource": ""
} |
q3026 | connect | train | function connect (state) {
return Promise.resolve(state.remote)
.then(function (remote) {
if (state.replication) {
return
}
state.replication = state.db.sync(remote, {
create_target: true,
live: true,
retry: true
})
state.replication.on('error', function (error) {
... | javascript | {
"resource": ""
} |
q3027 | train | function (options, cb) {
options.soajs.log.debug("Generating docker token");
crypto.randomBytes(1024, function (err, buffer) {
if (err) {
return cb(err);
}
options.soajs.registry.deployer.container.docker.remote.apiProtocol = 'https';
options.soajs.registry.deployer.container.docker.remote.apiPor... | javascript | {
"resource": ""
} | |
q3028 | train | function (options, cb) {
let outIP = options.out;
let stack = options.infra.stack;
if (outIP && stack.options.ElbName) {
options.soajs.log.debug("Creating SOAJS network.");
dockerUtils.getDeployer(options, (error, deployer) => {
if(error){
return cb(error);
}
deployer.listNetwor... | javascript | {
"resource": ""
} | |
q3029 | disconnect | train | function disconnect (state) {
if (state.replication) {
state.replication.cancel()
delete state.replication
state.emitter.emit('disconnect')
}
return Promise.resolve()
} | javascript | {
"resource": ""
} |
q3030 | addJwtHandling | train | function addJwtHandling(secrets, app) {
if (!secrets.authTokenSecret) {
log.error(
'Cannot setup token authentication because token secret is not configured.'
);
return;
}
app.use(expressJwt({
secret: secrets.authTokenSecret
}));
app.use(function (req, res, next) {
if (req.user &... | javascript | {
"resource": ""
} |
q3031 | addSessionHandling | train | function addSessionHandling(secrets, app) {
var connection = dbUtils.getConnectionNow();
var sessionStore = new MongoStore({
db: connection.db
});
app.use(cookieParser());
app.use(session({
secret: secrets.cookieSecret,
maxAge: 3600000, // 1 hour
store: sessionStore
}));
app.use(passpor... | javascript | {
"resource": ""
} |
q3032 | mix | train | function mix(receiver, supplier, overwrite) {
var key;
if (!receiver || !supplier) {
return receiver || {};
}
for (key in supplier) {
if (supplier.hasOwnProperty(key)) {
if (overwrite || !receiver.hasOwnProperty(key)) {
receiver[key] = supplier[key];
... | javascript | {
"resource": ""
} |
q3033 | train | function(val) {
let guid = guidFor(val);
if(guid in map) {
return map[guid];
} else if(sort) {
let sibiling = calculateMissingPosition(val, domain, sort);
return map[guidFor(sibiling)];
} else {
return r0;
}
} | javascript | {
"resource": ""
} | |
q3034 | restoreBackup | train | function restoreBackup(backupRecord, mongoUri) {
var receipts = backupRecord.receipts;
var handler = getHandler(backupRecord.type);
var restorePromises = receipts.map(function (receipt) {
var tmpfile = util.getTempFileName() + '.bson';
return R.pPipe(
handler.restore.bind(handler),
R.curry(R.... | javascript | {
"resource": ""
} |
q3035 | autoBox | train | function autoBox(object, model, data) {
if (!object) {
return isArray(data) ? model.collection(data, true) : model.instance(data);
}
if (isArray(data) && isArray(object)) {
return model.collection(data, true);
}
if (data && JSON.stringify(data).length > 3) {
deepExtend(object, data... | javascript | {
"resource": ""
} |
q3036 | train | function(object) {
if (object instanceof ModelClass) {
return object.url();
}
if (object instanceof ModelInstance || isFunc(object.$model)) {
var model = object.$model();
return expr(object, model.$config().identity + '.href').get() || model.url();
}
throw new Error... | javascript | {
"resource": ""
} | |
q3037 | config | train | function config(name, options) {
if (isObject(name)) {
extend(global, name);
return;
}
var previous = (registry[name] && registry[name].$config) ? registry[name].$config() : null,
base = extend({}, previous ? extend({}, previous) : extend({}, DEFAULTS, DEFAULT_METHODS));
options = d... | javascript | {
"resource": ""
} |
q3038 | ModelClassFactory | train | function ModelClassFactory(name, options) {
if (!isUndef(options)) {
return config(name, options);
}
return registry[name] || undefined;
} | javascript | {
"resource": ""
} |
q3039 | train | function (options, mCb) {
const aws = options.infra.api;
getElbMethod(options.params.elbType || 'classic', 'list', (elbResponse) => {
const elb = getConnector({
api: elbResponse.api,
region: options.params.region,
keyId: aws.keyId,
secretAccessKey: aws.secretAccessKey
});
const ec2 = getCon... | javascript | {
"resource": ""
} | |
q3040 | train | function (options, mCb) {
getElbMethod(options.params.elbType || 'classic', 'delete', (elbResponse) => {
const aws = options.infra.api;
const elb = getConnector({
api: elbResponse.api,
region: options.params.region,
keyId: aws.keyId,
secretAccessKey: aws.secretAccessKey
});
let params = {
... | javascript | {
"resource": ""
} | |
q3041 | initcpurow | train | function initcpurow() {
return {
user: 0,
nice: 0,
system: 0,
iowait: 0,
idle: 0,
irq: 0,
softirq: 0,
steal: 0,
guest: 0,
guest_nice: 0
};
} | javascript | {
"resource": ""
} |
q3042 | findname | train | function findname(error, response, body) {
if (error){
return error
}
if (body){
try{
var info = JSON.parse(body)
}
catch(err){
console.log(body)
return
}
if (info.items){
var ilen=info.items.length
while(ilen--... | javascript | {
"resource": ""
} |
q3043 | Temper | train | function Temper(options) {
if (!this) return new Temper(options);
options = options || {};
//
// We only want to cache the templates in production as it's so we can easily
// change templates when we're developing.
//
options.cache = 'cache' in options
? options.cache
: process.env.NODE_ENV !== '... | javascript | {
"resource": ""
} |
q3044 | plugin | train | function plugin(options) {
options = defaultsDeep({}, options, defaults);
this.Compiler = compiler;
function compiler(node, file) {
const root = node && node.type && node.type === 'root';
const bemjson = toBemjson(node, { augment: options.augment });
const bjsonString = options.ex... | javascript | {
"resource": ""
} |
q3045 | handleLogin | train | function handleLogin(user, req, res, next) {
var token;
var profile;
var tokenExpiresInMinutes;
var envelope = {
data: user,
isAuthenticated: true,
meta: {}
};
// First handle the case where the user was not logged in.
if (!user) {
if (authConfig.maintenance === 'c... | javascript | {
"resource": ""
} |
q3046 | Deffy | train | function Deffy(input, def, options) {
// Default is a function
if (typeof def === "function") {
return def(input);
}
options = Typpy(options) === "boolean" ? {
empty: options
} : {
empty: false
};
// Handle empty
if (options.empty) {
return input || def... | javascript | {
"resource": ""
} |
q3047 | generateRandomId | train | function generateRandomId (length) {
var str = ''
length = length || 6
while (str.length < length) {
str += (((1 + Math.random()) * 0x10000) | 0).toString(16)
}
return str.substring(str.length - length, str.length)
} | javascript | {
"resource": ""
} |
q3048 | guessObjectType | train | function guessObjectType(obj, shortname=false) {
var type
if (typeof obj === "string" && obj) {
if (obj in objectTypeUris) {
// given by URI
type = objectTypeUris[obj]
} else {
// given by name
obj = obj.toLowerCase().replace(/s$/,"")
type = Object.keys(objectTypes).find(name =... | javascript | {
"resource": ""
} |
q3049 | MongoAdapter | train | function MongoAdapter(mongooseConnection) {
if (!(this instanceof MongoAdapter)) {
return new MongoAdapter(mongooseConnection);
}
storj.StorageAdapter.call(this);
if (mongooseConnection instanceof Storage) {
this._model = mongooseConnection.models.Shard;
} else {
this._model = Shard(mongooseConn... | javascript | {
"resource": ""
} |
q3050 | constructModel | train | function constructModel(Model, options) {
return construct({
input: Model,
expected: AmpersandModel,
createConstructor: model,
options: options
});
} | javascript | {
"resource": ""
} |
q3051 | constructCollection | train | function constructCollection(Collection, options) {
return construct({
input: Collection,
expected: AmpersandCollection,
createConstructor: collection,
options: options
});
} | javascript | {
"resource": ""
} |
q3052 | train | function(options, cb) {
let template, render;
if(!options.params || !options.params.template || !options.params.template.content) {
return utils.checkError('Missing template content', 727, cb);
}
try {
template = handlebars.compile(options.params.template.content... | javascript | {
"resource": ""
} | |
q3053 | SchemaType | train | function SchemaType(type, validation, wrapper, params){
this.type = type;
this.validate = validation;
this.wrapper = wrapper;
this.parameters = params;
this.isPrimary = false;
chainPrimaryKey();
} | javascript | {
"resource": ""
} |
q3054 | train | function(node, entity, props, content) {
const hasContent = (!entity || entity.content !== null) && content !== null;
const entityContent = hasContent ?
((entity && entity.content) || content || traverse.children(transform, node)) :
null;
const block = parseBemNode(entity... | javascript | {
"resource": ""
} | |
q3055 | augmentFactory | train | function augmentFactory(augmentFunction) {
/**
* Apply custom augmentation and insert back to subtree
*
* @function AugmentFunction
* @param {Object} bemNode - representation of bem entity
* @returns {Object} bemNode
*/
function augment(bemNode) {
... | javascript | {
"resource": ""
} |
q3056 | _hasChildren | train | function _hasChildren(content) {
if (!content) return false;
if (typeof content === 'object') return true;
if (Array.isArray(content) && content.every(item => typeof item === 'string')) return false;
return false;
} | javascript | {
"resource": ""
} |
q3057 | reindexNodes | train | function reindexNodes () {
var child = this.node.firstChild;
this._length = 0;
while (child) {
this[this._length++] = child;
child = child.nextSibling;
}
} | javascript | {
"resource": ""
} |
q3058 | Qlobber | train | function Qlobber (options)
{
options = options || {};
this._separator = options.separator || '.';
this._wildcard_one = options.wildcard_one || '*';
this._wildcard_some = options.wildcard_some || '#';
this._trie = new Map();
if (options.cache_adds instanceof Map)
{
this._shortcuts = ... | javascript | {
"resource": ""
} |
q3059 | train | function(value, i, reads, options) {
return value && value[getValueSymbol] && value[isValueLikeSymbol] !== false && (options.foundAt || !isAt(i, reads) );
} | javascript | {
"resource": ""
} | |
q3060 | train | function(parent, key, value, options) {
var keys = typeof key === "string" ? observeReader.reads(key) : key;
var last;
options = options || {};
if(keys.length > 1) {
last = keys.pop();
parent = observeReader.read(parent, keys, options).value;
keys.push(last);
} else {
last = keys[0];
}
if(!pa... | javascript | {
"resource": ""
} | |
q3061 | assetFile | train | function assetFile(filename, callback) {
const data = {
source: files[filename].source,
destination: files[filename].destination || path.join(path.dirname(filename), '.')
}
delete files[filename]
metalsmithAssets(data)(files, metalsmith, callback)
} | javascript | {
"resource": ""
} |
q3062 | doesObjectListHaveDuplicates | train | function doesObjectListHaveDuplicates(l) {
const mergedList = l.reduce((merged, obj) => (
obj ? merged.concat(Object.keys(obj)) : merged
), []);
// Taken from: http://stackoverflow.com/a/7376645/1263876
// By casting the array to a Set, and then checking if the size of the array
// shrunk i... | javascript | {
"resource": ""
} |
q3063 | safeInvokeForConfig | train | function safeInvokeForConfig({ fn, context, params, onNotInvoked }) {
if (typeof fn === 'function') {
let fnParams = params;
if (typeof params === 'function') {
fnParams = params();
}
// Warn if params or lazily evaluated params were given but not in an array
if ... | javascript | {
"resource": ""
} |
q3064 | populateDefault | train | function populateDefault(message, field) {
const fieldName = field.getName();
if (message.has(fieldName)) {
return true;
}
const defaultValue = field.getDefault(message);
if (defaultValue === null) {
return false;
}
const msg = msgs.get(message);
if (field.isASingleValue()) {
msg.data.set... | javascript | {
"resource": ""
} |
q3065 | resetClock | train | function resetClock() {
for (const key in jasmine.Clock.real) {
if (jasmine.Clock.real.hasOwnProperty(key)) {
window[key] = jasmine.Clock.real[key]
}
}
} | javascript | {
"resource": ""
} |
q3066 | nodeExec | train | function nodeExec() {
var exitCode = nodeCLI.exec.apply(nodeCLI, arguments).code;
if (exitCode > 0) {
exit(1);
}
} | javascript | {
"resource": ""
} |
q3067 | train | function(url, fromFilename, toFilename) {
if (!SKIP_URLS.test(url)) {
var fromDirname = path.dirname(fromFilename),
toDirname = path.dirname(toFilename),
fromPath = path.resolve(fromDirname, url),
toPath = path.resolve(toDirname);
return path.relative(toPath, fromPath).replace(/\\/g, "/");
} el... | javascript | {
"resource": ""
} | |
q3068 | train | function(code) {
var tokens = new TokenStream(code),
hasCRLF = code.indexOf("\r") > -1,
lines = code.split(/\r?\n/),
line,
token,
tt,
replacement,
colAdjust = 0,
lastLine = 0;
while ((tt = tokens.get()) !== 0) {
token = tokens.token();
if (tt === Tokens.URI) { // URI
if (lastLi... | javascript | {
"resource": ""
} | |
q3069 | open | train | function open(url, callback){
var cmd, exec = require('child_process').exec;
switch(process.platform){
case 'darwin':
cmd = 'open';
break;
case 'win32':
case 'win64':
cmd = 'start ""';//加空的双引号可以打开带有 "&" 的地址
break;
case 'cygwin':
cmd = 'cygstart';
break;
default:
c... | javascript | {
"resource": ""
} |
q3070 | aliasExpand | train | function aliasExpand(cmdmap){
var cmds = {}
, twei = require('../')
, alias, apiGroup
;
for(var key in cmdmap){
alias = cmdmap[key];
if(alias.alias){
if(Array.isArray(alias.alias)){
for(var i = 0, l = alias.alias.length; i < l; i++){
cmds[alias.alias[i]] = cmdmap[key].cm... | javascript | {
"resource": ""
} |
q3071 | needRecurseArray | train | function needRecurseArray(arr) {
for (var i = 0; i < arr.length; i++) {
var el = arr[i]
if (typeof el !== 'number' && typeof el !== 'string' && el != null) return true
}
return false
} | javascript | {
"resource": ""
} |
q3072 | generateLetterIcon | train | function generateLetterIcon(letter, cb) {
// Derive SVG from base letter SVG
var letterSVG = baseSVG;
// Get a random Material Design color
var color = getRandomLetterColor();
// Substitude placeholders for color and letter
letterSVG = letterSVG.replace('{c}', color);
letterSVG = l... | javascript | {
"resource": ""
} |
q3073 | getRandomLetterColor | train | function getRandomLetterColor() {
// Reset index if we're at the end of the array
if (currentColorIndex >= colorKeys.length) {
currentColorIndex = 0;
}
// Get current color and increment index for next time
var currentColorKey = colorKeys[currentColorIndex++];
// Return most sa... | javascript | {
"resource": ""
} |
q3074 | compileSass | train | function compileSass(path, ext, file, callback) {
let compiledCss = sass.renderSync({
file: path,
outputStyle: 'compressed',
});
callback(null, compiledCss.css);
} | javascript | {
"resource": ""
} |
q3075 | asyncFor | train | function asyncFor(array, visitCallback, doneCallback, options) {
var start = 0;
var elapsed = 0;
options = options || {};
var step = options.step || 1;
var maxTimeMS = options.maxTimeMS || 8;
var pointsPerLoopCycle = options.probeElements || 5000;
// we should never block main thread for too long...
set... | javascript | {
"resource": ""
} |
q3076 | train | function () {
delete this.gl;
L.DomUtil.remove(this._container);
L.DomEvent.off(this._container);
delete this._container;
} | javascript | {
"resource": ""
} | |
q3077 | Container | train | function Container(parent) {
this.parent = parent;
this.children = [];
this.resolver = parent && parent.resolver || function() {};
this.registry = dictionary(parent ? parent.registry : null);
this.cache = dictionary(parent ? parent.cache : null);
this.factoryCache ... | javascript | {
"resource": ""
} |
q3078 | train | function(fullName, factory, options) {
Ember.assert('fullName must be a proper full name', validateFullName(fullName));
if (factory === undefined) {
throw new TypeError('Attempting to register an unknown factory: `' + fullName + '`');
}
var normalizedName = this.normalize(ful... | javascript | {
"resource": ""
} | |
q3079 | train | function(fullName) {
Ember.assert('fullName must be a proper full name', validateFullName(fullName));
var normalizedName = this.normalize(fullName);
delete this.registry[normalizedName];
delete this.cache[normalizedName];
delete this.factoryCache[normalizedName];
delete... | javascript | {
"resource": ""
} | |
q3080 | train | function(fullName, options) {
Ember.assert('fullName must be a proper full name', validateFullName(fullName));
return lookup(this, this.normalize(fullName), options);
} | javascript | {
"resource": ""
} | |
q3081 | train | function(type, property, fullName) {
Ember.assert('fullName must be a proper full name', validateFullName(fullName));
if (this.parent) { illegalChildOperation('typeInjection'); }
var fullNameType = fullName.split(':')[0];
if (fullNameType === type) {
throw new Error('Cannot i... | javascript | {
"resource": ""
} | |
q3082 | train | function(fullName, property, injectionName) {
if (this.parent) { illegalChildOperation('injection'); }
var normalizedName = this.normalize(fullName);
var normalizedInjectionName = this.normalize(injectionName);
validateFullName(injectionName);
if (fullName.indexOf(':') === -1)... | javascript | {
"resource": ""
} | |
q3083 | train | function() {
for (var i = 0, length = this.children.length; i < length; i++) {
this.children[i].destroy();
}
this.children = [];
eachDestroyable(this, function(item) {
item.destroy();
});
this.parent = undefined;
this.isDestroyed = true;
... | javascript | {
"resource": ""
} | |
q3084 | train | function() {
if (this.isDestroyed) { return; }
// At this point, the App.Router must already be assigned
if (this.Router) {
var container = this.__container__;
container.unregister('router:main');
container.register('router:main', this.Router);
}
t... | javascript | {
"resource": ""
} | |
q3085 | train | function(namespace) {
var container = new Container();
container.set = set;
container.resolver = resolverFor(namespace);
container.normalizeFullName = container.resolver.normalize;
container.describe = container.resolver.describe;
container.makeToString = container.resol... | javascript | {
"resource": ""
} | |
q3086 | train | function() {
var namespaces = emberA(Namespace.NAMESPACES);
var types = emberA();
var self = this;
namespaces.forEach(function(namespace) {
for (var key in namespace) {
if (!namespace.hasOwnProperty(key)) { continue; }
// Even though we will filter agai... | javascript | {
"resource": ""
} | |
q3087 | handlebarsGet | train | function handlebarsGet(root, path, options) {
var data = options && options.data;
var normalizedPath = normalizePath(root, path, data);
var value;
// In cases where the path begins with a keyword, change the
// root to the value represented by that keyword, and ensure
// the path is... | javascript | {
"resource": ""
} |
q3088 | registerBoundHelper | train | function registerBoundHelper(name, fn) {
var boundHelperArgs = slice.call(arguments, 1);
var boundFn = makeBoundHelper.apply(this, boundHelperArgs);
EmberHandlebars.registerHelper(name, boundFn);
} | javascript | {
"resource": ""
} |
q3089 | _triageMustacheHelper | train | function _triageMustacheHelper(property, options) {
Ember.assert("You cannot pass more than one argument to the _triageMustache helper", arguments.length <= 2);
var helper = EmberHandlebars.resolveHelper(options.data.view.container, property);
if (helper) {
return helper.call(this, options);
... | javascript | {
"resource": ""
} |
q3090 | bindClasses | train | function bindClasses(context, classBindings, view, bindAttrId, options) {
var ret = [];
var newClass, value, elem;
// Helper method to retrieve the property from the context and
// determine which class string to return, based on whether it is
// a Boolean or not.
var classStringFor... | javascript | {
"resource": ""
} |
q3091 | train | function(buffer) {
// If not invoked via a triple-mustache ({{{foo}}}), escape
// the content of the template.
var escape = get(this, 'isEscaped');
var shouldDisplay = get(this, 'shouldDisplayFunc');
var preserveContext = get(this, 'preserveContext');
var context = get(t... | javascript | {
"resource": ""
} | |
q3092 | flushPendingChains | train | function flushPendingChains() {
if (pendingQueue.length === 0) { return; } // nothing to do
var queue = pendingQueue;
pendingQueue = [];
forEach.call(queue, function(q) { q[0].add(q[1]); });
warn('Watching an undefined global, Ember expects watched globals to be setup by the time the ru... | javascript | {
"resource": ""
} |
q3093 | deprecateProperty | train | function deprecateProperty(object, deprecatedKey, newKey) {
function deprecate() {
Ember.deprecate('Usage of `' + deprecatedKey + '` is deprecated, use `' + newKey + '` instead.');
}
if (hasPropertyAccessors) {
defineProperty(object, deprecatedKey, {
configurable: true,
... | javascript | {
"resource": ""
} |
q3094 | indexOf | train | function indexOf(obj, element, index) {
return obj.indexOf ? obj.indexOf(element, index) : _indexOf.call(obj, element, index);
} | javascript | {
"resource": ""
} |
q3095 | indexesOf | train | function indexesOf(obj, elements) {
return elements === undefined ? [] : map(elements, function(item) {
return indexOf(obj, item);
});
} | javascript | {
"resource": ""
} |
q3096 | addObject | train | function addObject(array, item) {
var index = indexOf(array, item);
if (index === -1) { array.push(item); }
} | javascript | {
"resource": ""
} |
q3097 | intersection | train | function intersection(array1, array2) {
var result = [];
forEach(array1, function(element) {
if (indexOf(array2, element) >= 0) {
result.push(element);
}
});
return result;
} | javascript | {
"resource": ""
} |
q3098 | watchedEvents | train | function watchedEvents(obj) {
var listeners = obj['__ember_meta__'].listeners, ret = [];
if (listeners) {
for(var eventName in listeners) {
if (listeners[eventName]) { ret.push(eventName); }
}
}
return ret;
} | javascript | {
"resource": ""
} |
q3099 | isEmpty | train | function isEmpty(obj) {
var none = isNone(obj);
if (none) {
return none;
}
if (typeof obj.size === 'number') {
return !obj.size;
}
var objectType = typeof obj;
if (objectType === 'object') {
var size = get(obj, 'size');
if (typeof size === 'nu... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.