_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29000 | getEmberImportAliasName | train | function getEmberImportAliasName(importDeclaration) {
if (!importDeclaration.source) return null;
if (importDeclaration.source.value !== 'ember') return null;
return importDeclaration.specifiers[0].local.name;
} | javascript | {
"resource": ""
} |
q29001 | hasDuplicateDependentKeys | train | function hasDuplicateDependentKeys(callExp) {
if (!isComputedProp(callExp)) return false;
const dependentKeys = parseDependentKeys(callExp);
const uniqueKeys = dependentKeys
.filter((val, index, self) => self.indexOf(val) === index);
return uniqueKeys.length !== dependentKeys.length;
} | javascript | {
"resource": ""
} |
q29002 | parseDependentKeys | train | function parseDependentKeys(callExp) {
// Check whether we have a MemberExpression, eg. computed(...).volatile()
const isMemberExpCallExp = !callExp.arguments.length &&
utils.isMemberExpression(callExp.callee) &&
utils.isCallExpression(callExp.callee.object);
const args = isMemberExpCallExp ? callExp.cal... | javascript | {
"resource": ""
} |
q29003 | unwrapBraceExpressions | train | function unwrapBraceExpressions(dependentKeys) {
const braceExpressionRegexp = /{.+}/g;
const unwrappedExpressions = dependentKeys.map((key) => {
if (typeof key !== 'string' || !braceExpressionRegexp.test(key)) return key;
const braceExpansionPart = key.match(braceExpressionRegexp)[0];
const prefix = ... | javascript | {
"resource": ""
} |
q29004 | findStmtNodes | train | function findStmtNodes(nodeBody) {
const nodes = [];
const fnExpressions = utils.findNodes(nodeBody, 'ExpressionStatement');
const returnStatement = utils.findNodes(nodeBody, 'ReturnStatement');
if (fnExpressions.length !== 0) {
fnExpressions.forEach((item) => {
nodes.push(item);
});
}
if (r... | javascript | {
"resource": ""
} |
q29005 | checkForSuper | train | function checkForSuper(nodes) {
if (nodes.length === 0) return false;
return nodes.some((n) => {
if (utils.isCallExpression(n.expression)) {
const fnCallee = n.expression.callee;
return utils.isMemberExpression(fnCallee) &&
utils.isThisExpression(fnCallee.object) &&
utils.isIdentifi... | javascript | {
"resource": ""
} |
q29006 | saveNewVersion | train | function saveNewVersion(version, versionFile) {
fs.writeFileSync(versionFile, JSON.stringify({
version
}, null, 2), 'UTF-8');
} | javascript | {
"resource": ""
} |
q29007 | getSettings | train | function getSettings(desktopPath) {
let settings = {};
try {
settings = JSON.parse(
fs.readFileSync(path.join(desktopPath, 'settings.json'), 'UTF-8')
);
} catch (e) {
return {};
}
return settings;
} | javascript | {
"resource": ""
} |
q29008 | getFileList | train | function getFileList(dir, sort = true) {
return new Promise((resolve, reject) => {
readdir(dir, (error, files) => {
if (error) {
reject(error);
return;
}
let resultantFilesList;
if (sort) {
const stripLength = (... | javascript | {
"resource": ""
} |
q29009 | readAndHashFiles | train | function readAndHashFiles(files) {
const fileHashes = {};
const fileContents = {};
const promises = [];
function readSingleFile(file) {
return new Promise((resolve, reject) => {
fs.readFile(file, (err, data) => {
if (err) {
console.log(err);
... | javascript | {
"resource": ""
} |
q29010 | readFilesAndComputeDesktopHash | train | function readFilesAndComputeDesktopHash(dir) {
const desktopHash = crypto.createHash('sha1');
return new Promise((resolve, reject) => {
getFileList(dir)
.catch(reject)
.then(readAndHashFiles)
.catch(reject)
.then((result) => {
const hash =... | javascript | {
"resource": ""
} |
q29011 | removeDir | train | function removeDir(dirPath, delay = 0) {
return new Promise((resolve, reject) => {
setTimeout(() => {
rimraf(dirPath, {
maxBusyTries: 100
}, (err) => {
if (err) {
reject(err);
} else {
resolve();
... | javascript | {
"resource": ""
} |
q29012 | ManifestEntry | train | function ManifestEntry(manifestEntry) {
assignIn(this, {
filePath: manifestEntry.path,
urlPath: manifestEntry.url,
fileType: manifestEntry.type,
size: manifestEntry.size,
cacheable: manifestEntry.cacheable,
hash: manifestEntry.hash || null,
sourceMapFilePath: ... | javascript | {
"resource": ""
} |
q29013 | createStreamProtocolResponse | train | function createStreamProtocolResponse(filePath, res, beforeFinalize) {
if (!fs.existsSync(filePath)) {
return;
}
// Setting file size.
const stat = fs.statSync(filePath);
res.setHeader('Content-Length', stat.size);
// Setting last modified date.
const modified = stat.mtime.toUTCStr... | javascript | {
"resource": ""
} |
q29014 | respondWithCode | train | function respondWithCode(res, code, message) {
/* eslint-disable */
res._headers = {};
res._headerNames = {};
res.statusCode = code;
/* eslint-enable */
res.setHeader('Content-Type', 'text/plain; charset=UTF-8');
res.setHeader('Content-... | javascript | {
"resource": ""
} |
q29015 | AssetHandler | train | function AssetHandler(req, res, next, local = false) {
const parsedUrl = url.parse(req.url);
// Check if we have an asset for that url defined.
/** @type {Asset} */
const asset = self.assetBundle.assetForUrlPath(parsedUrl.pathname);
if (!asset) return next();... | javascript | {
"resource": ""
} |
q29016 | WwwHandler | train | function WwwHandler(req, res, next, local = false) {
const parsedUrl = url.parse(req.url);
if (parsedUrl.pathname !== '/cordova.js') {
return next();
}
const parentAssetBundle = self.assetBundle.getParentAssetBundle();
// We need to obtain a p... | javascript | {
"resource": ""
} |
q29017 | FilesystemHandler | train | function FilesystemHandler(req, res, next, urlAlias, localPath, local = false) {
const parsedUrl = url.parse(req.url);
if (!parsedUrl.pathname.startsWith(urlAlias)) {
return next();
}
const bareUrl = parsedUrl.pathname.substr(urlAlias.length);
... | javascript | {
"resource": ""
} |
q29018 | LocalFilesystemHandler | train | function LocalFilesystemHandler(req, res, next, local = false) {
if (!self.settings.localFilesystem) {
return next();
}
return FilesystemHandler(req, res, next, self.localFilesystemUrl, undefined, local);
} | javascript | {
"resource": ""
} |
q29019 | DesktopAssetsHandler | train | function DesktopAssetsHandler(req, res, next, local = false) {
return FilesystemHandler(req, res, next, self.desktopAssetsUrl, path.join(desktopPath, 'assets'), local);
} | javascript | {
"resource": ""
} |
q29020 | IndexHandler | train | function IndexHandler(req, res, next, local = false) {
const parsedUrl = url.parse(req.url);
if (!parsedUrl.pathname.startsWith(self.localFilesystemUrl) &&
parsedUrl.pathname !== '/favicon.ico'
) {
/** @type {Asset} */
const indexFile =... | javascript | {
"resource": ""
} |
q29021 | Asset | train | function Asset(filePath, urlPath, fileType, cacheable, hash, sourceMapUrlPath, size, bundle) {
this.filePath = filePath;
this.urlPath = urlPath;
this.fileType = fileType;
this.cacheable = cacheable;
this.hash = hash;
this.entrySize = size;
this.sourceMapUrlPath = sourceMapUrlPath;
this.b... | javascript | {
"resource": ""
} |
q29022 | isEmptySync | train | function isEmptySync(searchPath) {
let stat;
try {
stat = fs.statSync(searchPath);
} catch (e) {
return true;
}
if (stat.isDirectory()) {
const items = fs.readdirSync(searchPath);
return !items || !items.length;
}
return false;
} | javascript | {
"resource": ""
} |
q29023 | rimrafWithRetries | train | function rimrafWithRetries(...args) {
let retries = 0;
return new Promise((resolve, reject) => {
function rm(...rmArgs) {
try {
rimraf.sync(...rmArgs);
resolve();
} catch (e) {
retries += 1;
if (retries < 5) {
... | javascript | {
"resource": ""
} |
q29024 | setExtMap | train | function setExtMap(map, extname, val) {
if (extname && extname.indexOf('.') === 0) {
extname = extname.substring(1);
}
if (!extname) {
return;
}
map[extname] = val;
} | javascript | {
"resource": ""
} |
q29025 | train | function(json) {
var decoder = AV.Op._opDecoderMap[json.__op];
if (decoder) {
return decoder(json);
} else {
return undefined;
}
} | javascript | {
"resource": ""
} | |
q29026 | train | function(options) {
if (!this.id)
return Promise.reject(new Error('The status id is not exists.'));
var request = AVRequest('statuses', null, this.id, 'DELETE', options);
return request;
} | javascript | {
"resource": ""
} | |
q29027 | train | function(options = {}) {
if (!getSessionToken(options) && !AV.User.current()) {
throw new Error('Please signin an user.');
}
if (!this.query) {
return AV.Status.sendStatusToFollowers(this, options);
}
return getUserPointer(options)
.then(currUser =>... | javascript | {
"resource": ""
} | |
q29028 | train | function(objectId, options) {
if (!objectId) {
var errorObject = new AVError(
AVError.OBJECT_NOT_FOUND,
'Object not found.'
);
throw errorObject;
}
var obj = this._newObject();
obj.id = objectId;
var queryJSON = this.toJSON(... | javascript | {
"resource": ""
} | |
q29029 | train | function() {
var params = {
where: this._where,
};
if (this._include.length > 0) {
params.include = this._include.join(',');
}
if (this._select.length > 0) {
params.keys = this._select.join(',');
}
if (this._includeACL !== undefined)... | javascript | {
"resource": ""
} | |
q29030 | train | function(options) {
var self = this;
return self.find(options).then(function(objects) {
return AV.Object.destroyAll(objects, options);
});
} | javascript | {
"resource": ""
} | |
q29031 | train | function(options) {
var params = this.toJSON();
params.limit = 0;
params.count = 1;
var request = this._createRequest(params, options);
return request.then(function(response) {
return response.count;
});
} | javascript | {
"resource": ""
} | |
q29032 | train | function(options) {
var self = this;
var params = this.toJSON();
params.limit = 1;
var request = this._createRequest(params, options);
return request.then(function(response) {
return _.map(response.results, function(json) {
var obj = self._newObject();
... | javascript | {
"resource": ""
} | |
q29033 | train | function(key, regex, modifiers) {
this._addCondition(key, '$regex', regex);
if (!modifiers) {
modifiers = '';
}
// Javascript regex options support mig as inline options but store them
// as properties of the object. We support mi & should migrate them to
// mod... | javascript | {
"resource": ""
} | |
q29034 | train | function(key, query) {
var queryJSON = query.toJSON();
queryJSON.className = query.className;
this._addCondition(key, '$inQuery', queryJSON);
return this;
} | javascript | {
"resource": ""
} | |
q29035 | train | function(queries) {
var queryJSON = _.map(queries, function(q) {
return q.toJSON().where;
});
this._where.$and = queryJSON;
return this;
} | javascript | {
"resource": ""
} | |
q29036 | train | function(keys) {
requires(keys, 'undefined is not a valid key');
_(arguments).forEach(keys => {
this._include = this._include.concat(ensureArray(keys));
});
return this;
} | javascript | {
"resource": ""
} | |
q29037 | train | function(keys) {
requires(keys, 'undefined is not a valid key');
_(arguments).forEach(keys => {
this._select = this._select.concat(ensureArray(keys));
});
return this;
} | javascript | {
"resource": ""
} | |
q29038 | train | function() {
var self = this;
var request = this._createRequest();
return request.then(function(response) {
//update sid for next querying.
if (response.sid) {
self._oldSid = self._sid;
self._sid = response.sid;
} else {
self._s... | javascript | {
"resource": ""
} | |
q29039 | train | function(events, callback, context) {
var calls, event, node, tail, list;
if (!callback) {
return this;
}
events = events.split(eventSplitter);
calls = this._callbacks || (this._callbacks = {});
// Create an immutable callback list, allowing traversal during
// modific... | javascript | {
"resource": ""
} | |
q29040 | getValue | train | function getValue(object, prop) {
if (!(object && object[prop])) {
return null;
}
return _.isFunction(object[prop]) ? object[prop]() : object[prop];
} | javascript | {
"resource": ""
} |
q29041 | train | function(serverData) {
// Grab a copy of any object referenced by this object. These instances
// may have already been fetched, and we don't want to lose their data.
// Note that doing it like this means we will unify separate copies of the
// same object, but that's a risk we have to t... | javascript | {
"resource": ""
} | |
q29042 | train | function(serverData, hasData) {
// Clear out any changes the user might have made previously.
this._opSetQueue = [{}];
// Bring in all the new server data.
this._mergeMagicFields(serverData);
var self = this;
AV._objectEach(serverData, function(value, key) {
se... | javascript | {
"resource": ""
} | |
q29043 | train | function(opSet, target) {
var self = this;
AV._objectEach(opSet, function(change, key) {
const [value, actualTarget, actualKey] = findValue(target, key);
setValue(target, key, change._estimate(value, self, key));
if (actualTarget && actualTarget[actualKey] === AV.Op._UNSET)... | javascript | {
"resource": ""
} | |
q29044 | train | function(value, attr) {
if (!self._pending[attr] && !self._silent[attr]) {
delete self.changed[attr];
}
} | javascript | {
"resource": ""
} | |
q29045 | train | function(attrs) {
if (attrs.sessionToken) {
this._sessionToken = attrs.sessionToken;
delete attrs.sessionToken;
}
return AV.User.__super__._mergeMagicFields.call(this, attrs);
} | javascript | {
"resource": ""
} | |
q29046 | train | function(provider) {
var authType;
if (_.isString(provider)) {
authType = provider;
} else {
authType = provider.getAuthType();
}
var authData = this.get('authData') || {};
return !!authData[authType];
} | javascript | {
"resource": ""
} | |
q29047 | train | function(options, authOptions) {
if (!this.id) {
throw new Error('Please signin.');
}
let user;
let attributes;
if (options.user) {
user = options.user;
attributes = options.attributes;
} else {
user = options;
}
var... | javascript | {
"resource": ""
} | |
q29048 | train | function(oldPassword, newPassword, options) {
var route = 'users/' + this.id + '/updatePassword';
var params = {
old_password: oldPassword,
new_password: newPassword,
};
var request = AVRequest(route, null, null, 'PUT', params, options);
return request;
... | javascript | {
"resource": ""
} | |
q29049 | train | function(userObjectId) {
if (!userObjectId || !_.isString(userObjectId)) {
throw new Error('Invalid user object id.');
}
var query = new AV.FriendShipQuery('_Follower');
query._friendshipTag = 'follower';
query.equalTo(
'user',
AV.Object.createWithou... | javascript | {
"resource": ""
} | |
q29050 | train | function(email) {
var json = { email: email };
var request = AVRequest(
'requestPasswordReset',
null,
null,
'POST',
json
);
return request;
} | javascript | {
"resource": ""
} | |
q29051 | train | function(code, password) {
var json = { password: password };
var request = AVRequest(
'resetPasswordBySmsCode',
null,
code,
'PUT',
json
);
return request;
} | javascript | {
"resource": ""
} | |
q29052 | train | function(mobilePhoneNumber, options = {}) {
const data = {
mobilePhoneNumber,
};
if (options.validateToken) {
data.validate_token = options.validateToken;
}
var request = AVRequest(
'requestLoginSmsCode',
null,
null,
'PO... | javascript | {
"resource": ""
} | |
q29053 | train | function() {
if (AV._config.disableCurrentUser) {
console.warn(
'AV.User.currentAsync() was disabled in multi-user environment, access user from request instead https://leancloud.cn/docs/leanengine-node-sdk-upgrade-1.html'
);
return Promise.resolve(null);
}
... | javascript | {
"resource": ""
} | |
q29054 | train | function() {
AV.GeoPoint._validate(this.latitude, this.longitude);
return {
__type: 'GeoPoint',
latitude: this.latitude,
longitude: this.longitude,
};
} | javascript | {
"resource": ""
} | |
q29055 | getNextSearchDir | train | function getNextSearchDir( ptA, ptB, dir ){
var ABdotB = ptB.normSq() - ptB.dot( ptA )
,ABdotA = ptB.dot( ptA ) - ptA.normSq()
;
// if the origin is farther than either of these points
// get the direction from one of those points to the origin
if ( ABdotB < 0 )... | javascript | {
"resource": ""
} |
q29056 | Transform | train | function Transform( vect, angle, origin ) {
if (!(this instanceof Transform)){
return new Transform( vect, angle );
}
this.v = new Physics.vector();
this.o = new Physics.vector(); // origin of rotation
if ( vect instanceof Transform ){
this.clo... | javascript | {
"resource": ""
} |
q29057 | wrapDefine | train | function wrapDefine( src, path ){
path = path.replace('src/', '');
var deps = ['physicsjs'];
var l = path.split('/').length;
var pfx = l > 0 ? (new Array( l )).join('../') : './';
src.replace(/@requires\s([\w-_\/]+(\.js)?)/g, function( match, dep ){
var i = dep.ind... | javascript | {
"resource": ""
} |
q29058 | ConnectionTimeoutError | train | function ConnectionTimeoutError(timeout) {
Error.call(this);
Error.captureStackTrace(this, this.constructor);
this.message = 'connection timed out';
if (timeout) {
this.message += '. timeout = ' + timeout + ' ms';
}
this.name = 'ConnectionTimeoutError';
} | javascript | {
"resource": ""
} |
q29059 | ImapSimple | train | function ImapSimple(imap) {
var self = this;
self.imap = imap;
// flag to determine whether we should suppress ECONNRESET from bubbling up to listener
self.ending = false;
// pass most node-imap `Connection` events through 1:1
['alert', 'mail', 'expunge', 'uidvalidity', 'update', 'close', 'end... | javascript | {
"resource": ""
} |
q29060 | connect | train | function connect(options, callback) {
options = options || {};
options.imap = options.imap || {};
// support old connectTimeout config option. Remove in v2.0.0
if (options.hasOwnProperty('connectTimeout')) {
console.warn('[imap-simple] connect: options.connectTimeout is deprecated. ' +
... | javascript | {
"resource": ""
} |
q29061 | getParts | train | function getParts(struct, parts) {
parts = parts || [];
for (var i = 0; i < struct.length; i++) {
if (Array.isArray(struct[i])) {
getParts(struct[i], parts);
} else if (struct[i].partID) {
parts.push(struct[i]);
}
}
return parts;
} | javascript | {
"resource": ""
} |
q29062 | random | train | function random(array, len) {
const size = array.length;
const randomIndexes = crypto.randomBytes(len).toJSON().data;
return randomIndexes.map((char) => array[char % size]).join('');
} | javascript | {
"resource": ""
} |
q29063 | ruleIsMatch | train | function ruleIsMatch(host, port) {
const { host: rHost, port: rPort } = this;
const slashIndex = rHost.indexOf('/');
let isHostMatch = false;
if (slashIndex !== -1 && net.isIP(host)) {
isHostMatch = ip.cidrSubnet(rHost).contains(host);
} else {
isHostMatch = (rHost === host);
}
if (rHost === '*'... | javascript | {
"resource": ""
} |
q29064 | getHostType | train | function getHostType(host) {
if (net.isIPv4(host)) {
return ATYP_V4;
}
if (net.isIPv6(host)) {
return ATYP_V6;
}
return ATYP_DOMAIN;
} | javascript | {
"resource": ""
} |
q29065 | obtainConfig | train | function obtainConfig(file) {
let json;
try {
const jsonFile = fs.readFileSync(file);
json = JSON.parse(jsonFile);
} catch (err) {
throw Error(`fail to load/parse your '${file}': ${err.message}`);
}
return json;
} | javascript | {
"resource": ""
} |
q29066 | ApplicationData | train | function ApplicationData(buffer) {
const len = numberToBuffer(buffer.length);
return Buffer.concat([stb('170303'), len, buffer]);
} | javascript | {
"resource": ""
} |
q29067 | train | function() {
var err = null, status = parseInt(res.statusCode, 10);
if (status > 399) { // Unsuccessful HTTP status? Then pass an error to the callback
var match = data.match(/^\{"message": "(.+)"\}/i);
err = new error.DiscogsError(status, ((match && match[1]) ? m... | javascript | {
"resource": ""
} | |
q29068 | DiscogsError | train | function DiscogsError(statusCode, message){
Error.captureStackTrace(this, this.constructor);
this.statusCode = statusCode||404;
this.message = message||'Unknown error.';
} | javascript | {
"resource": ""
} |
q29069 | calculateSourceAnchor | train | function calculateSourceAnchor (source, startTime) {
if (startTime === undefined || isNaN(startTime)) {
return source;
}
if (windowType === WindowTypes.STATIC) {
return startTime === 0 ? source : source + '#t=' + parseInt(startTime);
}
if (windowType === Win... | javascript | {
"resource": ""
} |
q29070 | toggleControls | train | function toggleControls () {
controlsElement.style.display = controlsElement.style.display == "none" ? "block" : "none";
if (controlsElement.style.display === "block") {
playButton.focus();
}
} | javascript | {
"resource": ""
} |
q29071 | startControlsTimeOut | train | function startControlsTimeOut () {
clearTimeout(controlsTimeout);
if (controlsElement.style.display === "block") {
controlsTimeout = setTimeout(function () {
toggleControls();
}, 5000);
} else {
toggleControls();
}
} | javascript | {
"resource": ""
} |
q29072 | setupControls | train | function setupControls () {
window.addEventListener('keydown', function () {
startControlsTimeOut();
});
playButton.addEventListener('click', function () {
bigscreenPlayer.play();
startControlsTimeOut();
});
pauseButton.addEventListener('click', function () {
... | javascript | {
"resource": ""
} |
q29073 | isNearToCurrentTime | train | function isNearToCurrentTime (seconds) {
var currentTime = getCurrentTime();
var targetTime = getClampedTime(seconds);
return Math.abs(currentTime - targetTime) <= CURRENT_TIME_TOLERANCE;
} | javascript | {
"resource": ""
} |
q29074 | getClampedTime | train | function getClampedTime (seconds) {
var range = getSeekableRange();
var offsetFromEnd = getClampOffsetFromConfig();
var nearToEnd = Math.max(range.end - offsetFromEnd, range.start);
if (seconds < range.start) {
return range.start;
} else if (seconds > nearToEnd) {
... | javascript | {
"resource": ""
} |
q29075 | train | function (skyType, sunHeight) {
var fogColor;
if (skyType == 'color' || skyType == 'none'){
fogColor = new THREE.Color(this.data.skyColor);
}
else if (skyType == 'gradient'){
fogColor = new THREE.Color(this.data.horizonColor);
}
else if (skyType == 'atmosphere')
{
var fogR... | javascript | {
"resource": ""
} | |
q29076 | train | function () {
var str = '{';
for (var i in this.schema){
if (i == 'preset') continue;
str += i + ': ';
var type = this.schema[i].type;
if (type == 'vec3') {
str += '{ x: ' + this.data[i].x + ', y: ' + this.data[i].y + ', z: ' + this.data[i].z + '}';
}
else if (type ==... | javascript | {
"resource": ""
} | |
q29077 | train | function () {
// trim number to 3 decimals
function dec3 (v) {
return Math.floor(v * 1000) / 1000;
}
var params = [];
var usingPreset = this.data.preset != 'none' ? this.presets[this.data.preset] : false;
if (usingPreset) {
params.push('preset: ' + this.data.preset);
}
fo... | javascript | {
"resource": ""
} | |
q29078 | train | function (ctx, size, texMeters) {
if (this.data.grid == 'none') return;
// one grid feature each 2 meters
var num = Math.floor(texMeters / 2);
var step = size / (texMeters / 2); // 2 meters == <step> pixels
var i, j, ii;
ctx.fillStyle = this.data.gridColor;
switch (this.data.grid) {
... | javascript | {
"resource": ""
} | |
q29079 | train | function() {
var numStars = 2000;
var geometry = new THREE.BufferGeometry();
var positions = new Float32Array( numStars * 3 );
var radius = this.STAGE_SIZE - 1;
var v = new THREE.Vector3();
for (var i = 0; i < positions.length; i += 3) {
v.set(this.random(i + 23) - 0.5, this.random(i + 24)... | javascript | {
"resource": ""
} | |
q29080 | checkIfExists | train | function checkIfExists () {
// Create after we check for pre-sleep .dat stuff
var createAfterValid = (createIfMissing && !errorIfExists)
var missingError = new Error('Dat storage does not exist.')
missingError.name = 'MissingError'
var existsError = new Error('Dat storage already exists.')
exis... | javascript | {
"resource": ""
} |
q29081 | defaultStorage | train | function defaultStorage (storage, opts) {
// Use custom storage or ram
if (typeof storage !== 'string') return storage
if (opts.temp) return ram
if (opts.latest === false) {
// Store as SLEEP files inluding content.data
return {
metadata: function (name, opts) {
// I don't think we want th... | javascript | {
"resource": ""
} |
q29082 | polygonClosed | train | function polygonClosed(coordinates) {
var a = coordinates[0],
b = coordinates[coordinates.length - 1];
return !(a[0] - b[0] || a[1] - b[1]);
} | javascript | {
"resource": ""
} |
q29083 | train | function (data){
// set data
if (!arguments.length) {
if (scope.options.chart.type === 'sunburstChart') {
data = angular.copy(scope.data);
} else {
... | javascript | {
"resource": ""
} | |
q29084 | train | function (){
element.find('.title').remove();
element.find('.subtitle').remove();
element.find('.caption').remove();
element.empty();
// remove tooltip if exists
... | javascript | {
"resource": ""
} | |
q29085 | configure | train | function configure(chart, options, chartType){
if (chart && options){
angular.forEach(chart, function(value, key){
if (key[0] === '_');
else if (key === 'dispatch') {
i... | javascript | {
"resource": ""
} |
q29086 | configureWrapper | train | function configureWrapper(name){
var _ = nvd3Utils.deepExtend(defaultWrapper(name), scope.options[name] || {});
if (scope._config.extended) scope.options[name] = _;
var wrapElement = angular.element('<div></div>').html(_['html'] || '')
... | javascript | {
"resource": ""
} |
q29087 | configureStyles | train | function configureStyles(){
var _ = nvd3Utils.deepExtend(defaultStyles(), scope.options['styles'] || {});
if (scope._config.extended) scope.options['styles'] = _;
angular.forEach(_.classes, function(value, key){
value ... | javascript | {
"resource": ""
} |
q29088 | defaultWrapper | train | function defaultWrapper(_){
switch (_){
case 'title': return {
enable: false,
text: 'Write Your Title',
className: 'h4',
css: {
... | javascript | {
"resource": ""
} |
q29089 | dataWatchFn | train | function dataWatchFn(newData, oldData) {
if (newData !== oldData){
if (!scope._config.disabled) {
scope._config.refreshDataOnly ? scope.api.update() : scope.api.refresh(); // if wanted to refresh data only, use update method, otherwise ... | javascript | {
"resource": ""
} |
q29090 | FileKeyInfo | train | function FileKeyInfo(file) {
this.file = file
this.getKeyInfo = function(key, prefix) {
prefix = prefix || ''
prefix = prefix ? prefix + ':' : prefix
return "<" + prefix + "X509Data></" + prefix + "X509Data>"
}
this.getKey = function(keyInfo) {
return fs.readFileSync(this.file)
}
} | javascript | {
"resource": ""
} |
q29091 | RSASHA512 | train | function RSASHA512() {
/**
* Sign the given string using the given key
*
*/
this.getSignature = function(signedInfo, signingKey) {
var signer = crypto.createSign("RSA-SHA512")
signer.update(signedInfo)
var res = signer.sign(signingKey, 'base64')
return res
}
/**
* Verify the given sign... | javascript | {
"resource": ""
} |
q29092 | findAncestorNs | train | function findAncestorNs(doc, docSubsetXpath){
var docSubset = xpath.select(docSubsetXpath, doc);
if(!Array.isArray(docSubset) || docSubset.length < 1){
return [];
}
// Remove duplicate on ancestor namespace
var ancestorNs = collectAncestorNamespaces(docSubset[0]);
var ancestorNsWithoutDuplicate = ... | javascript | {
"resource": ""
} |
q29093 | SignedXml | train | function SignedXml(idMode, options) {
this.options = options || {};
this.idMode = idMode
this.references = []
this.id = 0
this.signingKey = null
this.signatureAlgorithm = this.options.signatureAlgorithm || "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
this.keyInfoProvider = null
this.canonicalizationAlg... | javascript | {
"resource": ""
} |
q29094 | wrap | train | function wrap(text, width, wrapSplitter) {
var lineHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.2;
text.each(function () {
var text = select(this),
words = text.text().split(wrapSplitter || /[ \t\r\n]+/).reverse().filter(function (w) {
return w !== "";
});
... | javascript | {
"resource": ""
} |
q29095 | JstdPlugin | train | function JstdPlugin() {
var nop = function() {};
this.reportResult = nop;
this.reportEnd = nop;
this.runScenario = nop;
this.name = 'Angular Scenario Adapter';
/**
* Called for each JSTD TestCase
*
* Handles only SCENARIO_TYPE test cases. There should be only one fake TestCase.
* Runs all sce... | javascript | {
"resource": ""
} |
q29096 | css_defaultDisplay | train | function css_defaultDisplay( nodeName ) {
var doc = document,
display = elemdisplay[ nodeName ];
if ( !display ) {
display = actualDisplay( nodeName, doc );
// If the simple way fails, read from inside an iframe
if ( display === "none" || !display ) {
// Use the already-created iframe if possible
ifra... | javascript | {
"resource": ""
} |
q29097 | actualDisplay | train | function actualDisplay( name, doc ) {
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
display = jQuery.css( elem[0], "display" );
elem.remove();
return display;
} | javascript | {
"resource": ""
} |
q29098 | train | function( code ) {
var script,
indirect = eval;
code = jQuery.trim( code );
if ( code ) {
// If the code includes a valid, prologue position
// strict mode pragma, execute code by injecting a
// script tag into the document.
if ( code.indexOf("use strict") === 1 ) {
script = document.createE... | javascript | {
"resource": ""
} | |
q29099 | benchmark | train | function benchmark(fn, times, name){
fn = fn.toString();
var s = fn.indexOf('{')+1,
e = fn.lastIndexOf('}');
fn = fn.substring(s,e);
return benchmarkString(fn, times, name);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.