_id
stringlengths 2
6
| title
stringlengths 0
58
| partition
stringclasses 3
values | text
stringlengths 52
373k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q63500
|
test
|
function(){
_a(oj.isDOM(this.el), this.typeName, 'constructor did not set this.el')
// Set instance on @el
_setInstanceOnElement(this.el, this)
var u = oj.unionArguments(arguments),
options = u.options,
args = u.args
// Emit as a tag if it isn't quiet or used new keyword
if (this.__autonew__ && !options.__quiet__)
this.emit()
// Remove quiet flag as it has served its purpose
if (options.__quiet__ != null)
delete options.__quiet__
// Add class oj-typeName
this.$el.addClass("oj-" + this.typeName)
// Views automatically set all options to their properties
// arguments directly to properties
this.set(options)
// Remove options that were set
options = _clone(options)
this.properties.forEach(function(v){return delete options[v]})
// Views pass through remaining options to be attributes on the root element
// This can include jquery events and interpreted arguments
this.addAttributes(options)
// Record if view is fully constructed
return this._isConstructed = true
}
|
javascript
|
{
"resource": ""
}
|
|
q63501
|
test
|
function($el, args){
// No arguments return the first instance
if (args.length === 0)
return $el[0].oj
// Compile ojml
var r = oj.compile.apply(oj, [{dom: 1, html: 0, cssMap: 1 }].concat(slice.call(args)))
_insertStyles(r.cssMap, {global: 0})
// Reset content and append to dom
$el.html('')
// Ensure r.dom is an array
if (!oj.isArray(r.dom))
r.dom = [r.dom]
// Append resulting dom elements
for (var ix = 0; ix < r.dom.length; ix++)
$el.append(r.dom[ix])
// Trigger inserted events
_triggerInserted(r.types, r.inserts)
}
|
javascript
|
{
"resource": ""
}
|
|
q63502
|
_jqGetValue
|
test
|
function _jqGetValue($el, args){
var el = $el[0],
child = el.firstChild
// Return the instance if the element has an oj instance
if (oj.isOJInstance(_getInstanceOnElement(el)))
return _getInstanceOnElement(el)
// Parse the text to turn it into bool, number, or string
else if (oj.isDOMText(child))
return oj.parse(child.nodeValue)
// Return the first child otherwise as an oj instance or child element
else if (oj.isDOMElement(child))
return _d(_getInstanceOnElement(child), child)
}
|
javascript
|
{
"resource": ""
}
|
q63503
|
test
|
function(describe) {
if (!Array.isArray(describe.m)) {
return when.reject('no modules in describe message');
}
var allDeps = [];
var modules = describe.m;
for(var i=0;i<modules.length;i++) {
var checkModule = modules[i];
// don't look for dependencies of things that don't have dependencies.
// they'll never cause safe mode as a result of their requirements,
// and they're probably referenced by other things
for(var d = 0; d < checkModule.d.length; d++) {
var moduleNeeds = checkModule.d[d];
// what things do we need that we don't have?
var deps = this._walkChain(modules, moduleNeeds);
if (deps && (deps.length > 0)) {
allDeps = allDeps.concat(deps);
}
}
}
var keyFn = function(dep) {
// todo - location should also be taken into account
return [dep.f, dep.n, dep.v].join('_');
};
return utilities.dedupArray(allDeps, keyFn);
}
|
javascript
|
{
"resource": ""
}
|
|
q63504
|
main
|
test
|
async function main() {
// Initialize the application.
process.title = 'Coveralls.js';
// Parse the command line arguments.
program.name('coveralls')
.description('Send a coverage report to the Coveralls service.')
.version(packageVersion, '-v, --version')
.arguments('<file>').action(file => program.file = file)
.parse(process.argv);
if (!program.file) {
program.outputHelp();
process.exitCode = 64;
return null;
}
// Run the program.
const client = new Client('COVERALLS_ENDPOINT' in process.env ? new URL(process.env.COVERALLS_ENDPOINT) : Client.defaultEndPoint);
const coverage = await promises.readFile(program.file, 'utf8');
console.log(`[Coveralls] Submitting to ${client.endPoint}`);
return client.upload(coverage);
}
|
javascript
|
{
"resource": ""
}
|
q63505
|
Shortline
|
test
|
function Shortline(options) {
const self = this;
self._input = (options && options.input) || process.stdin;
self._output = (options && options.output) || process.stderr;
/** Most recent error emitted by the input stream.
* @type {Error}
*/
self.inputError = null;
self._input.on('end', () => {
self.inputError = new EOFError(EOF_MESSAGE);
});
// Note: Can't listen for 'error' since it changes behavior if there are no
// other listeners. Listen for it only when reading from input (since that
// is our error and will be returned to the caller).
}
|
javascript
|
{
"resource": ""
}
|
q63506
|
findElements
|
test
|
function findElements(node, name) {
return name in node && Array.isArray(node[name]) ? node[name] : [];
}
|
javascript
|
{
"resource": ""
}
|
q63507
|
main
|
test
|
async function main() { // eslint-disable-line no-unused-vars
try {
const coverage = await promises.readFile('/path/to/coverage.report', 'utf8');
await new Client().upload(coverage);
console.log('The report was sent successfully.');
}
catch (error) {
console.log(`An error occurred: ${error.message}`);
if (error instanceof ClientError) console.log(`From: ${error.uri}`);
}
}
|
javascript
|
{
"resource": ""
}
|
q63508
|
TravisStatusHttp
|
test
|
function TravisStatusHttp(endpoint, options) {
if (endpoint && typeof endpoint !== 'string') {
throw new TypeError('endpoint must be a string');
}
endpoint = endpoint && trimSlash(endpoint);
if (options && typeof options !== 'object') {
throw new TypeError('options must be an object');
}
options = Object.assign({gzip: true}, options);
options.headers = Object.assign({}, options.headers);
// Careful about providing default values for case-insensitive headers
const caselessHeaders = caseless(options.headers);
// The Travis CI API docs say
// "Always set the Accept header to application/vnd.travis-ci.2+json"
// but the API actually sends Content-Type application/json.
// Declare that we accept either.
if (!caselessHeaders.has('Accept')) {
options.headers.Accept =
'application/vnd.travis-ci.2+json, application/json';
}
if (!caselessHeaders.has('User-Agent')) {
options.headers['User-Agent'] = DEFAULT_USER_AGENT;
}
TravisHttp.call(
this,
endpoint === constants.PRO_URI,
options.headers
);
this._endpoint = endpoint || constants.ORG_URI;
// Set this._headers as TravisHttp does
this._headers = options.headers;
delete options.headers;
this._options = options;
}
|
javascript
|
{
"resource": ""
}
|
q63509
|
git
|
test
|
function git(...args) {
return new Promise((resolve, reject) => {
const child = execFile('git', args, (err, stdout, stderr) => {
if (err) {
reject(err);
} else {
// Creating an object with named properties would probably be clearer
// but this is compatible with thenify/promisify if we switch later.
resolve([stdout, stderr]);
}
});
child.stdin.end();
});
}
|
javascript
|
{
"resource": ""
}
|
q63510
|
SlugDetectionError
|
test
|
function SlugDetectionError(message) {
if (!(this instanceof SlugDetectionError)) {
return new SlugDetectionError(message);
}
Error.captureStackTrace(this, SlugDetectionError);
// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message
if (message !== undefined) {
Object.defineProperty(this, 'message', {
value: String(message),
configurable: true,
writable: true
});
}
}
|
javascript
|
{
"resource": ""
}
|
q63511
|
createScopedCss
|
test
|
function createScopedCss(html, scope, filepath, cssVariables) {
scope = typeof scope === 'string' ? {ns: scope, vars: new Map()} : scope;
const style = html.match(styleMatcher);
if (!style) {
return [{}, scope.vars, ''];
}
const cssom = css.parse(style[1], {source: filepath});
const vars = new Map(scope.vars.entries());
getVariables(cssom).forEach((value, key) => vars.set(key, value));
if (cssVariables) {
resolveScopeVariables(cssom, vars);
}
const [classes, transformMap] = rewriteSelectors(`${decamelize(scope.ns, '-')}`, cssom);
return [classes, vars, css.stringify(cssom), transformMap];
}
|
javascript
|
{
"resource": ""
}
|
q63512
|
combineCss
|
test
|
function combineCss(templates, scopedCss) {
if (!Array.isArray(scopedCss)) {
scopedCss = [scopedCss];
}
return [
...Object.keys(templates).map(name => templates[name].css),
...scopedCss
]
.join('\n').trim();
}
|
javascript
|
{
"resource": ""
}
|
q63513
|
InvalidSlugError
|
test
|
function InvalidSlugError(message) {
if (!(this instanceof InvalidSlugError)) {
return new InvalidSlugError(message);
}
Error.captureStackTrace(this, InvalidSlugError);
// Like http://www.ecma-international.org/ecma-262/6.0/#sec-error-message
if (message !== undefined) {
Object.defineProperty(this, 'message', {
value: String(message),
configurable: true,
writable: true
});
}
}
|
javascript
|
{
"resource": ""
}
|
q63514
|
checkBuildCommit
|
test
|
function checkBuildCommit(build, localCommit) {
const buildCommit = build.commit;
let message = `Build commit ${buildCommit.sha
} does not match ${localCommit.sha}`;
if (localCommit.name) {
message += ` (${localCommit.name})`;
}
// assert gives us useful exception properties for callers
assert.strictEqual(
buildCommit.sha,
localCommit.sha,
message
);
return build;
}
|
javascript
|
{
"resource": ""
}
|
q63515
|
trimSlash
|
test
|
function trimSlash(string) {
if (typeof string !== 'string') {
return string;
}
if (string.length > 0 && string.charAt(string.length - 1) === '/') {
return string.slice(0, string.length - 1);
}
return string;
}
|
javascript
|
{
"resource": ""
}
|
q63516
|
parseOptions
|
test
|
function parseOptions (opts) {
return removeEmpty({
plugins: convertFn.call(this, opts.plugins),
locals: convertFn.call(this, opts.locals),
filename: convertFn.call(this, opts.filename),
parserOptions: convertFn.call(this, opts.parserOptions),
generatorOptions: convertFn.call(this, opts.generatorOptions),
runtime: convertFn.call(this, opts.runtime),
parser: convertFnSpecial.call(this, opts.parser),
multi: convertFn.call(this, opts.multi)
})
}
|
javascript
|
{
"resource": ""
}
|
q63517
|
serializeVerbatim
|
test
|
function serializeVerbatim (obj) {
let i = 0
const fns = []
let res = JSON.stringify(obj, (k, v) => {
if (typeof v === 'function') {
fns.push(v.toString())
return `__REPLACE${i++}`
} else {
return v
}
})
res = res.replace(/"__REPLACE(\d{1})"/g, (m, v) => {
return fns[v]
})
return res
}
|
javascript
|
{
"resource": ""
}
|
q63518
|
renderPages
|
test
|
function renderPages(filepaths, dest, {templates, vars, statics, disableValidation, cssVariables, host}) {
console.log(`\nGenerating pages...`);
return Promise.all(filepaths.map(filepath => {
return sander.readFile(filepath)
.then(content => renderPage(content, filepath, {templates, vars, dest, cssVariables}))
.then(([html, destinationPath, cssParts]) => sander.writeFile(destinationPath, html)
.then(() => [destinationPath, cssParts]))
.then(([destinationPath, cssParts]) => {
console.log(` ${chalk.bold.green(figures.tick)} ${filepath} -> ${destinationPath}`);
return [destinationPath, cssParts];
});
}))
.then(pageResults => disableValidation ||
validatePages(host, dest, pageResults.map(result => result[0]), statics)
.then(() => pageResults.map(result => result[1])));
}
|
javascript
|
{
"resource": ""
}
|
q63519
|
gitUrlPath
|
test
|
function gitUrlPath(gitUrl) {
// Foreign URL for remote helper
// See transport_get in transport.c
// Note: url.parse considers second : as part of path. So check this first.
const foreignParts = /^([A-Za-z0-9][A-Za-z0-9+.-]*)::(.*)$/.exec(gitUrl);
if (foreignParts) {
return foreignParts[2];
}
// Typical URL
const gitUrlObj = url.parse(gitUrl);
if (gitUrlObj.protocol) {
return gitUrlObj.path;
}
// SCP-like syntax. Host can be wrapped in [] to disambiguate path.
// See parse_connect_url and host_end in connect.c
const scpParts = /^([^@/]+)@(\[[^]\/]+\]|[^:/]+):(.*)$/.exec(gitUrl);
if (scpParts) {
return scpParts[3];
}
// Assume URL is a local path
return gitUrl;
}
|
javascript
|
{
"resource": ""
}
|
q63520
|
test
|
function() {
var appEnv = this.app.env;
if (process.env.DEPLOY_TARGET) {
appEnv = process.env.DEPLOY_TARGET;
}
var publicFiles = new Funnel(this.app.trees.public);
this._requireBuildPackages();
fs.stat(
path.join(this.project.root, 'public', 'robots.txt'),
function(err, stats) {
if (stats && stats.isFile()) {
console.log(chalk.yellow('There is a robots.txt in /public and ENV specific robots.txt are ignored!'));
}
}
);
publicFiles = stew.rename(
publicFiles,
'robots-' + appEnv + '.txt',
'robots.txt'
);
return new Funnel(publicFiles, {
srcDir: '/',
destDir: '/'
});
}
|
javascript
|
{
"resource": ""
}
|
|
q63521
|
compileIndex
|
test
|
function compileIndex() {
fs.readFile(path.join(__dirname, 'templates', 'index.hogan'), function(err, data) {
if (err) throw err;
// write rendered result to index.html
fs.writeFile(path.join(__dirname, 'index.html'),
hogan.compile(data.toString()).render({
'schemes': schemes,
'variations': variations,
'colors': colors,
'variants': variants,
}),
function(err) {if (err) throw err});
// open index.html in browser
open(path.join(__dirname, 'index.html'));
});
}
|
javascript
|
{
"resource": ""
}
|
q63522
|
sortMentions
|
test
|
function sortMentions(mentions) {
return mentions.slice().sort((a, b) => b.length - a.length);
}
|
javascript
|
{
"resource": ""
}
|
q63523
|
findEmoji
|
test
|
function findEmoji(names, match) {
const compare = match.toLowerCase();
for (let i = 0; i < names.length; i += 1) {
const name = names[i].toLowerCase();
if (name === compare) {
return names[i];
}
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q63524
|
fiberize
|
test
|
function fiberize(fn){
return function(done){
var self = this;
Fiber(function(){
try{
if(fn.length == 1){
fn.call(self, done);
} else {
fn.call(self);
done();
}
} catch(e) {
process.nextTick(function(){
throw(e);
});
}
}).run();
};
}
|
javascript
|
{
"resource": ""
}
|
q63525
|
test
|
function(regex, type, types, selector) {
var matches = selector.match(regex);
if (matches) {
for (var i = 0; i < matches.length; i++) {
types[type]++;
// Replace this simple selector with whitespace so it won't be counted in further simple selectors
selector = selector.replace(matches[i], ' ');
}
}
return selector;
}
|
javascript
|
{
"resource": ""
}
|
|
q63526
|
test
|
function(selector) {
var commaIndex = selector.indexOf(',');
if (commaIndex !== -1) {
selector = selector.substring(0, commaIndex);
}
var types = {
a: 0,
b: 0,
c: 0
};
// Remove the negation psuedo-class (:not) but leave its argument because specificity is calculated on its argument
selector = selector.replace(notRegex, ' $1 ');
// Remove anything after a left brace in case a user has pasted in a rule, not just a selector
selector = selector.replace(ruleRegex, ' ');
// Add attribute selectors to parts collection (type b)
selector = findMatch(attributeRegex, 'b', types, selector);
// Add ID selectors to parts collection (type a)
selector = findMatch(idRegex, 'a', types, selector);
// Add class selectors to parts collection (type b)
selector = findMatch(classRegex, 'b', types, selector);
// Add pseudo-element selectors to parts collection (type c)
selector = findMatch(pseudoElementRegex, 'c', types, selector);
// Add pseudo-class selectors to parts collection (type b)
selector = findMatch(pseudoClassRegex, 'b', types, selector);
// Remove universal selector and separator characters
selector = selector.replace(separatorRegex, ' ');
// Remove any stray dots or hashes which aren't attached to words
// These may be present if the user is live-editing this selector
selector = selector.replace(straysRegex, ' ');
// The only things left should be element selectors (type c)
findMatch(elementRegex, 'c', types, selector);
return (types.a * 100) + (types.b * 10) + (types.c * 1);
}
|
javascript
|
{
"resource": ""
}
|
|
q63527
|
test
|
function(collectionName, indexName, columns, unique, callback) {
var options = {
indexName: indexName,
columns: columns,
unique: unique
};
return this._run('createIndex', collectionName, options)
.nodeify(callback);
}
|
javascript
|
{
"resource": ""
}
|
|
q63528
|
test
|
function (name, callback) {
return this._run('insert', this.internals.migrationTable, {name: name, run_on: new Date()})
.nodeify(callback);
}
|
javascript
|
{
"resource": ""
}
|
|
q63529
|
test
|
function (name, callback) {
return this._run('insert', this.internals.seedTable, {name: name, run_on: new Date()})
.nodeify(callback);
}
|
javascript
|
{
"resource": ""
}
|
|
q63530
|
test
|
function(err, data) {
if(err) {
prCB(err);
}
prCB(null, data);
db.close();
}
|
javascript
|
{
"resource": ""
}
|
|
q63531
|
parseParameters
|
test
|
function parseParameters(options) {
var opt = {
maximumAge: 0,
enableHighAccuracy: true,
timeout: Infinity,
interval: 6000,
fastInterval: 1000,
priority: PRIORITY_HIGH_ACCURACY
};
if (options) {
if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
opt.maximumAge = options.maximumAge;
}
if (options.enableHighAccuracy !== undefined) {
opt.enableHighAccuracy = options.enableHighAccuracy;
}
if (options.timeout !== undefined && !isNaN(options.timeout)) {
if (options.timeout < 0) {
opt.timeout = 0;
} else {
opt.timeout = options.timeout;
}
}
if (options.interval !== undefined && !isNaN(options.interval) && options.interval > 0) {
opt.interval = options.interval;
}
if (options.fastInterval !== undefined && !isNaN(options.fastInterval) && options.fastInterval > 0) {
opt.fastInterval = options.fastInterval;
}
if (options.priority !== undefined && !isNaN(options.priority) && options.priority >= PRIORITY_NO_POWER && options.priority <= PRIORITY_HIGH_ACCURACY) {
if (options.priority === PRIORITY_NO_POWER) {
opt.priority = PRIORITY_NO_POWER;
}
if (options.priority === PRIORITY_LOW_POWER) {
opt.priority = PRIORITY_LOW_POWER;
}
if (options.priority === PRIORITY_BALANCED_POWER_ACCURACY) {
opt.priority = PRIORITY_BALANCED_POWER_ACCURACY;
}
if (options.priority === PRIORITY_HIGH_ACCURACY) {
opt.priority = PRIORITY_HIGH_ACCURACY;
}
}
}
return opt;
}
|
javascript
|
{
"resource": ""
}
|
q63532
|
noProp
|
test
|
function noProp(props, propNameOrFunction) {
if (!props) {
throw new Error('Headful: You must pass all declared props when you use headful.props.x() calls.');
}
const propName = typeof propNameOrFunction === 'function' ? propNameOrFunction.name : propNameOrFunction;
return !props.hasOwnProperty(propName);
}
|
javascript
|
{
"resource": ""
}
|
q63533
|
GifCli
|
test
|
function GifCli(path, callback) {
var frames = [];
OneByOne([
Tmp.dir
, function (next, tmpDir) {
var str = Fs.createReadStream(path)
, isFinished = false
, complete = []
, i = 0
;
str.on("end", function () {
isFinished = true;
});
str.pipe(
GifExplode(function (frame) {
Tmp.file({ postfix: ".gif", }, function (err, cImg) {
(function (i, cImg) {
if (err) { return next(err); }
var wStr = Fs.createWriteStream(cImg);
frame.pipe(wStr);
complete[i] = false;
wStr.on("close", function () {
// TODO Allow passing options
ImageToAscii(cImg, function (err, asciified) {
complete[i] = true;
frames[i] = asciified || "";
// TODO https://github.com/hughsk/gif-explode/issues/4
//if (err) { return next(err); }
if (!isFinished) { return; }
if (!complete.filter(function (c) {
return c !== true
}).length) {
next();
}
});
});
})(i++, cImg);
});
})
);
}
, function (next) {
frames = frames.filter(Boolean);
next();
}
], function (err) {
if (err) { return callback(err); }
callback(null, frames);
});
}
|
javascript
|
{
"resource": ""
}
|
q63534
|
shouldLog
|
test
|
function shouldLog(testlevel, thresholdLevel) {
var allowed = logLevelAllowedGranular(testlevel);
if (allowed) {
return true;
}
return logLevelAllowed(testlevel, thresholdLevel);
}
|
javascript
|
{
"resource": ""
}
|
q63535
|
test
|
function() {
if (attrs.type === 'radio') {
return attrs.value || $parse(attrs.ngValue)(scope) || true;
}
var trueValue = ($parse(attrs.ngTrueValue)(scope));
if (angular.isUndefined(trueValue)) {
trueValue = true;
}
return trueValue;
}
|
javascript
|
{
"resource": ""
}
|
|
q63536
|
test
|
function(attrName) {
var map = {
'switchRadioOff': getBooleanFromStringDefTrue,
'switchActive': function(value) {
return !getBooleanFromStringDefTrue(value);
},
'switchAnimate': getBooleanFromStringDefTrue,
'switchLabel': function(value) {
return value ? value : ' ';
},
'switchIcon': function(value) {
if (value) {
return '<span class=\'' + value + '\'></span>';
}
},
'switchWrapper': function(value) {
return value || 'wrapper';
},
'switchInverse': getBooleanFromString,
'switchReadonly': getBooleanFromString,
'switchChange': getExprFromString
};
var transFn = map[attrName] || getValueOrUndefined;
return transFn(attrs[attrName]);
}
|
javascript
|
{
"resource": ""
}
|
|
q63537
|
test
|
function() {
// if it's the first initialization
if (!isInit) {
var viewValue = (controller.$modelValue === getTrueValue());
isInit = !isInit;
// Bootstrap the switch plugin
element.bootstrapSwitch({
radioAllOff: getSwitchAttrValue('switchRadioOff'),
disabled: getSwitchAttrValue('switchActive'),
state: viewValue,
onText: getSwitchAttrValue('switchOnText'),
offText: getSwitchAttrValue('switchOffText'),
onColor: getSwitchAttrValue('switchOnColor'),
offColor: getSwitchAttrValue('switchOffColor'),
animate: getSwitchAttrValue('switchAnimate'),
size: getSwitchAttrValue('switchSize'),
labelText: attrs.switchLabel ? getSwitchAttrValue('switchLabel') : getSwitchAttrValue('switchIcon'),
wrapperClass: getSwitchAttrValue('switchWrapper'),
handleWidth: getSwitchAttrValue('switchHandleWidth'),
labelWidth: getSwitchAttrValue('switchLabelWidth'),
inverse: getSwitchAttrValue('switchInverse'),
readonly: getSwitchAttrValue('switchReadonly')
});
if (attrs.type === 'radio') {
controller.$setViewValue(controller.$modelValue);
} else {
controller.$setViewValue(viewValue);
}
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63538
|
test
|
function () {
attrs.$observe('switchActive', function (newValue) {
var active = getBooleanFromStringDefTrue(newValue);
// if we are disabling the switch, delay the deactivation so that the toggle can be switched
if (!active) {
$timeout(setActive);
} else {
// if we are enabling the switch, set active right away
setActive();
}
});
// When the model changes
controller.$render = function () {
initMaybe();
var newValue = controller.$modelValue;
if (newValue !== undefined && newValue !== null) {
element.bootstrapSwitch('state', newValue === getTrueValue(), true);
} else {
element.bootstrapSwitch('indeterminate', true, true);
controller.$setViewValue(undefined);
}
switchChange();
};
// angular attribute to switch property bindings
var bindings = {
'switchRadioOff': 'radioAllOff',
'switchOnText': 'onText',
'switchOffText': 'offText',
'switchOnColor': 'onColor',
'switchOffColor': 'offColor',
'switchAnimate': 'animate',
'switchSize': 'size',
'switchLabel': 'labelText',
'switchIcon': 'labelText',
'switchWrapper': 'wrapperClass',
'switchHandleWidth': 'handleWidth',
'switchLabelWidth': 'labelWidth',
'switchInverse': 'inverse',
'switchReadonly': 'readonly'
};
var observeProp = function(prop, bindings) {
return function() {
attrs.$observe(prop, function () {
setSwitchParamMaybe(element, bindings[prop], prop);
});
};
};
// for every angular-bound attribute, observe it and trigger the appropriate switch function
for (var prop in bindings) {
attrs.$observe(prop, observeProp(prop, bindings));
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63539
|
test
|
function () {
if (attrs.type === 'radio') {
// when the switch is clicked
element.on('change.bootstrapSwitch', function (e) {
// discard not real change events
if ((controller.$modelValue === controller.$viewValue) && (e.target.checked !== $(e.target).bootstrapSwitch('state'))) {
// $setViewValue --> $viewValue --> $parsers --> $modelValue
// if the switch is indeed selected
if (e.target.checked) {
// set its value into the view
controller.$setViewValue(getTrueValue());
} else if (getTrueValue() === controller.$viewValue) {
// otherwise if it's been deselected, delete the view value
controller.$setViewValue(undefined);
}
switchChange();
}
});
} else {
// When the checkbox switch is clicked, set its value into the ngModel
element.on('switchChange.bootstrapSwitch', function (e) {
// $setViewValue --> $viewValue --> $parsers --> $modelValue
controller.$setViewValue(e.target.checked);
switchChange();
});
}
}
|
javascript
|
{
"resource": ""
}
|
|
q63540
|
test
|
function (n) {
var r,
i,
c = parseCookies();
if (typeof n === 'string') {
r = (c[n] !== undef) ? c[n] : null;
} else if (typeof n === 'object' && n !== null) {
r = {};
for (i in n) {
if (Object.prototype.hasOwnProperty.call(n, i)) {
if (c[n[i]] !== undef) {
r[n[i]] = c[n[i]];
} else {
r[n[i]] = null;
}
}
}
} else {
r = c;
}
return r;
}
|
javascript
|
{
"resource": ""
}
|
|
q63541
|
test
|
function (p) {
var n,
r = {},
c = parseCookies();
if (typeof p === 'string') {
p = new RegExp(p);
}
for (n in c) {
if (Object.prototype.hasOwnProperty.call(c, n) && n.match(p)) {
r[n] = c[n];
}
}
return r;
}
|
javascript
|
{
"resource": ""
}
|
|
q63542
|
test
|
function (n, v, o) {
if (typeof o !== 'object' || o === null) {
o = {};
}
if (v === undef || v === null) {
v = '';
o.expires = new Date();
o.expires.setFullYear(1978);
} else {
/* Logic borrowed from http://jquery.com/ dataAttr method and reversed */
v = (v === true)
? 'true' : (v === false)
? 'false' : !isNaN(v)
? String(v) : v;
if (typeof v !== 'string') {
if (typeof JSON === 'object' && JSON !== null && typeof JSON.stringify === 'function') {
v = JSON.stringify(v);
} else {
throw new Error('cookies.set() could not be serialize the value');
}
}
}
document.cookie = n + '=' + encodeURIComponent(v) + cookieOptions(o);
}
|
javascript
|
{
"resource": ""
}
|
|
q63543
|
test
|
function () {
var r = false,
n = 'test_cookies_jaaulde_js',
v = 'data';
this.set(n, v);
if (this.get(n) === v) {
this.del(n);
r = true;
}
return r;
}
|
javascript
|
{
"resource": ""
}
|
|
q63544
|
formatMessage
|
test
|
function formatMessage (str) {
return String(str).split('\n')
.map(function(s) {
return s.magenta;
})
.join('\n');
}
|
javascript
|
{
"resource": ""
}
|
q63545
|
createZoomRangePath
|
test
|
function createZoomRangePath(options) {
if (!angular.isObject(options.state)) {
options.state = {};
}
if (!angular.isObject(options.state.range)) {
options.state.range = [];
}
}
|
javascript
|
{
"resource": ""
}
|
q63546
|
synchronizeZoom
|
test
|
function synchronizeZoom(options, configuration, watcher) {
if (angular.isObject(options.chart) && angular.isObject(options.chart.zoom) && options.chart.zoom.enabled === true) {
// setup onzoomend listener
configuration.zoom.onzoomend = function (domain) {
// update state
AngularChartWatcher.updateState(watcher, function () {
createZoomRangePath(options);
options.state.range = domain;
});
// call user defined callback
if (angular.isFunction(options.chart.zoom.onzoomend)) {
AngularChartWatcher.applyFunction(watcher, function () {
options.chart.zoom.onzoomend(domain);
});
}
};
}
if (angular.isObject(options.chart) && angular.isObject(options.chart.subchart) && options.chart.subchart.show === true) {
// setup onbrush listener
configuration.subchart.onbrush = function (domain) {
// update state
AngularChartWatcher.updateState(watcher, function () {
createZoomRangePath(options);
options.state.range = domain;
});
// call user defined callback
if (angular.isFunction(options.chart.subchart.onbrush)) {
AngularChartWatcher.applyFunction(watcher, function () {
options.chart.subchart.onbrush(domain);
});
}
};
}
}
|
javascript
|
{
"resource": ""
}
|
q63547
|
addSelections
|
test
|
function addSelections(chart, selections) {
service.disableSelectionListener = true;
selections.forEach(function (selection) {
chart.select([selection.id], [selection.index]);
});
service.disableSelectionListener = false;
}
|
javascript
|
{
"resource": ""
}
|
q63548
|
applySelection
|
test
|
function applySelection(options, chart) {
if (angular.isObject(options.state) && angular.isArray(options.state.selected)) {
// TODO: get new selections
// TODO: get removed selections
// var chartSelections = chart.selected();
// // addedSelections
// var addedSelections = newSelections.filter(function (elm) {
// var isNew = true;
// oldSelections.forEach(function (old) {
// if (old.id === elm.id && old.index === elm.index) {
// isNew = false;
// return isNew;
// }
// });
// return isNew;
// });
//
// // removedSelections
// var removedSelections = oldSelections.filter(function (elm) {
// var isOld = true;
// newSelections.forEach(function (old) {
// if (old.id === elm.id && old.index === elm.index) {
// isOld = false;
// return isOld;
// }
// });
// return isOld;
// });
// alternative: deselect all and select again
//removeAllSelections(chart);
addSelections(chart, options.state.selected);
} else {
removeAllSelections(chart);
}
}
|
javascript
|
{
"resource": ""
}
|
q63549
|
createSelectionsPath
|
test
|
function createSelectionsPath(options) {
if (!angular.isObject(options.state)) {
options.state = {};
}
if (!angular.isArray(options.state.selected)) {
options.state.selected = [];
}
}
|
javascript
|
{
"resource": ""
}
|
q63550
|
synchronizeSelection
|
test
|
function synchronizeSelection(options, configuration, watcher) {
if (angular.isObject(options.chart) && angular.isObject(options.chart.data) && angular.isObject(options.chart.data.selection) && options.chart.data.selection.enabled === true) {
// add onselected listener
configuration.data.onselected = function (data, element) {
// check if listener is disabled currently
if (service.disableSelectionListener) {
return;
}
// update state
AngularChartWatcher.updateState(watcher, function () {
createSelectionsPath(options);
options.state.selected.push(data);
});
// call user defined callback
if (angular.isFunction(options.chart.data.onselected)) {
AngularChartWatcher.applyFunction(watcher, function () {
options.chart.data.onselected(data, element);
});
}
};
// add onunselection listener
configuration.data.onunselected = function (data, element) {
// check if listener is disabled currently
if (service.disableSelectionListener) {
return;
}
// update state
AngularChartWatcher.updateState(watcher, function () {
createSelectionsPath(options);
options.state.selected = options.state.selected.filter(function (selected) {
return selected.id !== data.id || selected.index !== data.index;
});
});
// call user defined callback
if (angular.isFunction(options.chart.data.onunselected)) {
AngularChartWatcher.applyFunction(watcher, function () {
options.chart.data.onunselected(data, element);
});
}
};
}
}
|
javascript
|
{
"resource": ""
}
|
q63551
|
setupDataSmallWatcher
|
test
|
function setupDataSmallWatcher(watcher) {
return watcher.scope.$watch('options.data', function () {
if (angular.isFunction(watcher.dataCallback)) {
watcher.dataCallback();
}
setupDataWatcher(watcher);
}, true);
}
|
javascript
|
{
"resource": ""
}
|
q63552
|
setupDataBigWatcher
|
test
|
function setupDataBigWatcher(watcher) {
return watcher.scope.$watch(function () {
if (watcher.scope.options.data && angular.isArray(watcher.scope.options.data)) {
return watcher.scope.options.data.length;
} else {
return 0;
}
}, function () {
if (angular.isFunction(watcher.dataCallback)) {
watcher.dataCallback();
}
setupDataWatcher(watcher);
});
}
|
javascript
|
{
"resource": ""
}
|
q63553
|
addIdentifier
|
test
|
function addIdentifier() {
$scope.dataAttributeChartID = 'chartid' + Math.floor(Math.random() * 1000000001);
angular.element($element).attr('id', $scope.dataAttributeChartID);
configuration.bindto = '#' + $scope.dataAttributeChartID;
}
|
javascript
|
{
"resource": ""
}
|
q63554
|
loadEntity
|
test
|
function loadEntity(name, promise, options) {
if (!name || typeof name !== 'string') throw new Error('Missing required entity name');
if (!promise || !promise.then) throw new Error('Missing required entity promise');
try {
!(0, _validateOptions.default)(options);
} catch (error) {
throw error;
}
var entityLifecycle = new _entityLifecycle.default(name, options);
return function (dispatch, getState) {
entityLifecycle.setDispatch(dispatch);
entityLifecycle.setGetState(getState);
entityLifecycle.onLoad();
return new Promise(function (resolve, reject) {
promise.then(function (data) {
resolve(entityLifecycle.onSuccess(data));
}).catch(function (error) {
reject(entityLifecycle.onFailure(error));
});
});
};
}
|
javascript
|
{
"resource": ""
}
|
q63555
|
generateAction
|
test
|
function generateAction(action, keys, values) {
var generatedAction = Object.assign({}, action);
keys.forEach(function (arg, index) {
generatedAction[keys[index]] = values[index];
});
return generatedAction;
}
|
javascript
|
{
"resource": ""
}
|
q63556
|
makeActionCreator
|
test
|
function makeActionCreator(type) {
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
keys[_key - 1] = arguments[_key];
}
if (!type) throw new Error('Type cannot be null/undefined');
return function () {
for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
values[_key2] = arguments[_key2];
}
return generateAction({
type: type
}, keys, values);
};
}
|
javascript
|
{
"resource": ""
}
|
q63557
|
_getRandomDelayBetween
|
test
|
function _getRandomDelayBetween (min, max, roundTo) {
return Number(Math.random() * (max - min) + min).toFixed(roundTo);
}
|
javascript
|
{
"resource": ""
}
|
q63558
|
_logDetails
|
test
|
function _logDetails (action) {
if (action) {
console.log(`${chalk.white.bgRed(' Prev State:')}
${__toString(state)}`);
console.log(`${chalk.white.bgBlue(' Action:')}
${__toString(action)}`);
} else {
console.log(`${chalk.white.bgGreen(' Next State:')}
${__toString(state)}`);
console.log('\n');
}
}
|
javascript
|
{
"resource": ""
}
|
q63559
|
_removeSubscribers
|
test
|
function _removeSubscribers(aSubscribers, oSubscriber) {
let nUnsubscribed = 0;
if (!isTypeOf(aSubscribers, sNotDefined)) {
let nIndex = aSubscribers.length - 1;
for (; nIndex >= 0; nIndex--) {
if (aSubscribers[nIndex].subscriber === oSubscriber) {
nUnsubscribed++;
aSubscribers.splice(nIndex, 1);
}
}
}
return nUnsubscribed;
}
|
javascript
|
{
"resource": ""
}
|
q63560
|
_removeSubscribersPerEvent
|
test
|
function _removeSubscribersPerEvent(oEventsCallbacks, sChannelId, oSubscriber) {
let nUnsubscribed = 0;
iterateObject(oEventsCallbacks, function (oItem, sEvent) {
const aEventsParts = sEvent.split(':');
let sChannel = sChannelId;
let sEventType = sEvent;
if (aEventsParts[0] === 'global') {
sChannel = aEventsParts[0];
sEventType = aEventsParts[1];
}
nUnsubscribed += _removeSubscribers(oChannels[sChannel][sEventType], oSubscriber);
});
return nUnsubscribed;
}
|
javascript
|
{
"resource": ""
}
|
q63561
|
_addSubscribers
|
test
|
function _addSubscribers(oEventsCallbacks, sChannelId, oSubscriber) {
iterateObject(oEventsCallbacks, function (oItem, sEvent) {
subscribeTo(sChannelId, sEvent, oItem, oSubscriber);
});
}
|
javascript
|
{
"resource": ""
}
|
q63562
|
_getChannelEvents
|
test
|
function _getChannelEvents(sChannelId, sEvent) {
if (oChannels[sChannelId] === und) {
oChannels[sChannelId] = {};
}
if (oChannels[sChannelId][sEvent] === und) {
oChannels[sChannelId][sEvent] = [];
}
return oChannels[sChannelId][sEvent];
}
|
javascript
|
{
"resource": ""
}
|
q63563
|
subscribersByEvent
|
test
|
function subscribersByEvent(oChannel, sEventName) {
let aSubscribers = [];
if (!isTypeOf(oChannel, sNotDefined)) {
iterateObject(oChannel, function (oItem, sKey) {
if (sKey === sEventName) {
aSubscribers = oItem;
}
});
}
return aSubscribers;
}
|
javascript
|
{
"resource": ""
}
|
q63564
|
subscribeTo
|
test
|
function subscribeTo(sChannelId, sEventType, fpHandler, oSubscriber) {
const aChannelEvents = _getChannelEvents(sChannelId, sEventType);
aChannelEvents.push({
subscriber: oSubscriber,
handler: fpHandler
});
}
|
javascript
|
{
"resource": ""
}
|
q63565
|
unsubscribeFrom
|
test
|
function unsubscribeFrom(sChannelId, sEventType, oSubscriber) {
const aChannelEvents = _getChannelEvents(sChannelId, sEventType);
for (let nEvent = aChannelEvents.length - 1; nEvent >= 0; nEvent--) {
const oItem = aChannelEvents[nEvent];
if (oItem.subscriber === oSubscriber) {
aChannelEvents.splice(nEvent, 1);
}
}
}
|
javascript
|
{
"resource": ""
}
|
q63566
|
subscribe
|
test
|
function subscribe(oSubscriber) {
const oEventsCallbacks = oSubscriber.events;
if (!oSubscriber || oEventsCallbacks === und) {
return false;
}
iterateObject(oEventsCallbacks, function (oItem, sChannelId) {
if (oChannels[sChannelId] === und) {
oChannels[sChannelId] = {};
}
_addSubscribers(oItem, sChannelId, oSubscriber);
});
return true;
}
|
javascript
|
{
"resource": ""
}
|
q63567
|
unsubscribe
|
test
|
function unsubscribe(oSubscriber) {
let nUnsubscribed = 0;
const oEventsCallbacks = oSubscriber.events;
if (!oSubscriber || oEventsCallbacks === und) {
return false;
}
iterateObject(oEventsCallbacks, function (oItem, sChannelId) {
if (oChannels[sChannelId] === und) {
oChannels[sChannelId] = {};
}
nUnsubscribed = _removeSubscribersPerEvent(oItem, sChannelId, oSubscriber);
});
return nUnsubscribed > 0;
}
|
javascript
|
{
"resource": ""
}
|
q63568
|
_executeHandler
|
test
|
function _executeHandler(oHandlerObject, oData, sChannelId, sEvent) {
oHandlerObject.handler.call(oHandlerObject.subscriber, oData);
if (getDebug()) {
const ErrorHandler = errorHandler();
ErrorHandler.log(sChannelId, sEvent, oHandlerObject);
}
}
|
javascript
|
{
"resource": ""
}
|
q63569
|
publish
|
test
|
function publish(sChannelId, sEvent, oData) {
const aSubscribers = copyArray(this.subscribers(sChannelId, sEvent));
let oSubscriber;
const nLenSubscribers = aSubscribers.length;
if (nLenSubscribers === 0) {
return false;
}
oData = preprocessorsPublishData(oData);
while (!!(oSubscriber = aSubscribers.shift())) {
_executeHandler(oSubscriber, oData, sChannelId, sEvent);
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
q63570
|
resolveNamespace
|
test
|
function resolveNamespace(sNamespace) {
var oObj = root,
aElements = sNamespace.split('.'),
sElement;
while (!!( sElement = aElements.shift() )) {
oObj = oObj[sElement] !== und ? oObj[sElement] : oObj[sElement] = {};
}
return oObj;
}
|
javascript
|
{
"resource": ""
}
|
q63571
|
getResolveDICallback
|
test
|
function getResolveDICallback(oMapping) {
return function (sDependency) {
var oPromise = getPromise();
if (!oMapping.__map__[sDependency]) {
return false;
}
oPromise.resolve(oMapping.__map__[sDependency]);
return oPromise;
};
}
|
javascript
|
{
"resource": ""
}
|
q63572
|
getPromiseCallbacks
|
test
|
function getPromiseCallbacks(oContext, sType) {
return function () {
var aCompleted, nLenPromises, oDeferred, aPromises, nPromise, oPromise, aResults = [];
oContext.bCompleted = true;
oContext.sType = sType;
oContext.oResult = arguments;
while (oContext.aPending[0]) {
oContext.aPending.shift()[sType].apply(oContext, arguments);
}
oDeferred = oContext.oDeferred;
if(oDeferred){
aCompleted = [];
aPromises = oDeferred.aPromises;
nLenPromises = aPromises.length;
aResults = [];
for(nPromise = 0; nPromise < nLenPromises; nPromise++){
oPromise = aPromises[nPromise];
aCompleted.push(Number(oPromise.bCompleted));
aResults.push( oPromise.oResult );
}
if(aCompleted.join('').indexOf('0') === -1){
oDeferred[sType].apply(oDeferred, aResults);
}
}
};
}
|
javascript
|
{
"resource": ""
}
|
q63573
|
test
|
function (fpSuccess, fpFailure) {
var oResult = this.oResult;
if (this.bCompleted) {
if (this.sType === 'resolve') {
fpSuccess.apply(fpSuccess, oResult);
} else {
fpFailure.apply(fpFailure, oResult);
}
} else {
this.aPending.push({ resolve: fpSuccess, reject: fpFailure});
}
return this;
}
|
javascript
|
{
"resource": ""
}
|
|
q63574
|
FakeModule
|
test
|
function FakeModule(sModuleId, fpCreator) {
if (isTypeOf(fpCreator, sNotDefined)) {
throw new Error('Something goes wrong!');
}
this.creator = fpCreator;
this.instances = {};
this.sModuleId = sModuleId;
}
|
javascript
|
{
"resource": ""
}
|
q63575
|
isJqueryObject
|
test
|
function isJqueryObject(oObj) {
var isJquery = false,
$ = getRoot().jQuery;
if ($) {
isJquery = isInstanceOf(oObj, $);
}
return isJquery;
}
|
javascript
|
{
"resource": ""
}
|
q63576
|
isEvent
|
test
|
function isEvent(oObj) {
try {
return isInstanceOf(oObj, Event);
} catch (erError) {
// Duck typing detection (If it sounds like a duck and it moves like a duck, it's a duck)
if (oObj.altKey !== und && ( oObj.srcElement || oObj.target )) {
return true;
}
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
q63577
|
addPropertiesAndMethodsToModule
|
test
|
function addPropertiesAndMethodsToModule(sModuleId, aDependencies, fpCallback) {
var oPromise;
function success(mapping) {
const oModules = getModules();
var oModule, fpInitProxy;
oModule = oModules[sModuleId].creator.apply(oModules[sModuleId], [].slice.call(arguments, 1));
oModule.__children__ = [];
oModule.dependencies = aDependencies || [].slice.call(arguments, 1);
oModule.resolvedDependencies = mapping;
oModule.__module_id__ = sModuleId;
fpInitProxy = oModule.init || nullFunc;
// Provide compatibility with old versions of Hydra.js
oModule.__action__ = oModule.__sandbox__ = Bus;
oModule.events = oModule.events || {};
oModule.init = function () {
var aArgs = copyArray(arguments).concat(getVars());
if (oModule.__children__.length === 0) { // Only subscribe last element of inheritance.
Bus.subscribe(oModule);
}
return fpInitProxy.apply(this, aArgs);
};
oModule.handleAction = function (oNotifier) {
var fpCallback = this.events[oNotifier.type];
if (isTypeOf(fpCallback, sNotDefined)) {
return;
}
fpCallback.call(this, oNotifier);
};
// Provide compatibility with old Hydra versions which used to use "destroy" as onDestroy hook.
oModule.onDestroy = oModule.onDestroy || oModule.destroy || function () {
};
oModule.destroy = function () {
this.onDestroy();
Bus.unsubscribe(oModule);
delete oModules[sModuleId].instances[oModule.__instance_id__];
};
fpCallback(oModule);
}
oPromise = resolveDependencies(sModuleId, aDependencies);
oPromise.then(function () {
success.apply(success, arguments);
});
}
|
javascript
|
{
"resource": ""
}
|
q63578
|
wrapMethod
|
test
|
function wrapMethod(oInstance, sName, sModuleId, fpMethod) {
oInstance[sName] = ( function (sName, fpMethod) {
return function () {
var aArgs = copyArray(arguments);
try {
return fpMethod.apply(this, aArgs);
}
catch (erError) {
const ErrorHandler = errorHandler();
ErrorHandler.error(sModuleId, sName, erError);
return false;
}
};
}(sName, fpMethod));
}
|
javascript
|
{
"resource": ""
}
|
q63579
|
register
|
test
|
function register(sModuleId, aDependencies, fpCreator) {
const oModules = getModules();
if (isFunction(aDependencies)) {
fpCreator = aDependencies;
aDependencies = [ '$$_bus', '$$_module', '$$_log', 'gl_Hydra' ];
}
oModules[sModuleId] = new FakeModule(sModuleId, fpCreator);
oModules[sModuleId].dependencies = aDependencies;
return oModules[sModuleId];
}
|
javascript
|
{
"resource": ""
}
|
q63580
|
setInstance
|
test
|
function setInstance(sModuleId, sIdInstance, oInstance) {
const oModules = getModules();
var oModule = oModules[sModuleId];
if (!oModule) {
fpThrowErrorModuleNotRegistered(sModuleId, true);
}
oModule.instances[sIdInstance] = oInstance;
return oModule;
}
|
javascript
|
{
"resource": ""
}
|
q63581
|
_multiModuleStart
|
test
|
function _multiModuleStart(oInstance, aModulesIds, sIdInstance, oData, bSingle) {
var aInstancesIds, aData, aSingle, nIndex, nLenModules, sModuleId;
if (isArray(sIdInstance)) {
aInstancesIds = copyArray(sIdInstance);
}
if (isArray(oData)) {
aData = copyArray(oData);
}
if (isArray(bSingle)) {
aSingle = copyArray(bSingle);
}
for (nIndex = 0, nLenModules = aModulesIds.length; nIndex < nLenModules; nIndex++) {
sModuleId = aModulesIds[nIndex];
sIdInstance = aInstancesIds && aInstancesIds[nIndex] || generateUniqueKey();
oData = aData && aData[nIndex] || oData;
bSingle = aSingle && aSingle[nIndex] || bSingle;
startSingleModule(oInstance, sModuleId, sIdInstance, oData, bSingle);
}
}
|
javascript
|
{
"resource": ""
}
|
q63582
|
beforeInit
|
test
|
function beforeInit(oInstance, oData, bSingle) {
iterateObject(oModifyInit, function (oMember) {
if (oMember && isTypeOf(oMember, sFunctionType)) {
oMember(oInstance, oData, bSingle);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q63583
|
startSingleModule
|
test
|
function startSingleModule(oWrapper, sModuleId, sIdInstance, oData, bSingle) {
const oModules = getModules();
var oModule;
oModule = oModules[sModuleId];
if ( (bSingle && isModuleStarted(sModuleId)) || isModuleStarted(sModuleId, sIdInstance)) {
oWrapper.stop(sModuleId, sIdInstance);
}
if (!isTypeOf(oModule, sNotDefined)) {
createInstance(sModuleId, undefined, function (oInstance) {
oModule.instances[sIdInstance] = oInstance;
oInstance.__instance_id__ = sIdInstance;
beforeInit(oInstance, oData, bSingle);
if (!isTypeOf(oData, sNotDefined)) {
oInstance.init(oData);
} else {
oInstance.init();
}
});
} else {
const ErrorHandler = errorHandler();
ErrorHandler.error(new Error(), fpThrowErrorModuleNotRegistered(sModuleId));
}
}
|
javascript
|
{
"resource": ""
}
|
q63584
|
_singleModuleStart
|
test
|
function _singleModuleStart(oInstance, sModuleId, sIdInstance, oData, bSingle) {
if (!isTypeOf(sIdInstance, 'string')) {
bSingle = oData;
oData = sIdInstance;
sIdInstance = generateUniqueKey();
}
startSingleModule(oInstance, sModuleId, sIdInstance, oData, bSingle);
}
|
javascript
|
{
"resource": ""
}
|
q63585
|
createInstance
|
test
|
function createInstance(sModuleId, aDependencies, fpCallback) {
const oModules = getModules();
if (isTypeOf(oModules[sModuleId], sNotDefined)) {
fpThrowErrorModuleNotRegistered(sModuleId, true);
}
addPropertiesAndMethodsToModule(sModuleId, aDependencies, function (oInstance) {
if (!getDebug()) {
iterateObject(oInstance, function (oItem, sName) {
if (isFunction(oItem)) {
wrapMethod(oInstance, sName, sModuleId, oInstance[sName]);
}
});
}
fpCallback(oInstance);
});
}
|
javascript
|
{
"resource": ""
}
|
q63586
|
getCallbackToSetObjectFromTemplate
|
test
|
function getCallbackToSetObjectFromTemplate(oMethodsObject, oPropertiesObject) {
return function (oValue, sKey) {
if (typeof oValue === 'function') {
oMethodsObject[sKey] = getSimpleFunction(oValue);
} else if (isArray(oValue)) {
oPropertiesObject[sKey] = copyArray(oValue);
} else if (typeof oValue === 'object' && oValue !== null ) {
oPropertiesObject[sKey] = simpleMerge({}, oValue);
} else if (isInstanceOf(oValue, Date)) {
oPropertiesObject[sKey] = new Date();
oPropertiesObject[sKey].setTime(oValue.getTime());
} else {
oPropertiesObject[sKey] = oValue;
}
};
}
|
javascript
|
{
"resource": ""
}
|
q63587
|
startAll
|
test
|
function startAll() {
const oModules = getModules();
iterateObject(oModules, function (_oModule, sModuleId) {
if (!isTypeOf(_oModule, sNotDefined)) {
start(sModuleId, generateUniqueKey());
}
});
}
|
javascript
|
{
"resource": ""
}
|
q63588
|
stop
|
test
|
function stop(sModuleId, sInstanceId) {
const oModules = getModules();
var oModule;
oModule = oModules[sModuleId];
if (isTypeOf(oModule, sNotDefined)) {
return false;
}
if (!isTypeOf(sInstanceId, sNotDefined)) {
_singleModuleStop(oModule, sInstanceId);
} else {
_multiModuleStop(oModule);
}
return true;
}
|
javascript
|
{
"resource": ""
}
|
q63589
|
_multiModuleStop
|
test
|
function _multiModuleStop(oModule) {
iterateObject(oModule.instances, function (oInstance) {
if (!isTypeOf(oModule, sNotDefined) && !isTypeOf(oInstance, sNotDefined)) {
oInstance.destroy();
}
});
oModule.instances = {};
}
|
javascript
|
{
"resource": ""
}
|
q63590
|
_singleModuleStop
|
test
|
function _singleModuleStop(oModule, sInstanceId) {
var oInstance = oModule.instances[sInstanceId];
if (!isTypeOf(oModule, sNotDefined) && !isTypeOf(oInstance, sNotDefined)) {
oInstance.destroy();
delete oModule.instances[sInstanceId];
}
}
|
javascript
|
{
"resource": ""
}
|
q63591
|
stopAll
|
test
|
function stopAll() {
const oModules = getModules();
iterateObject(oModules, function (_oModule, sModuleId) {
if (!isTypeOf(_oModule, sNotDefined)) {
_stopOneByOne(_oModule, sModuleId);
}
});
}
|
javascript
|
{
"resource": ""
}
|
q63592
|
_stopOneByOne
|
test
|
function _stopOneByOne(oModule, sModuleId) {
iterateObject(oModule.instances, function (oItem, sInstanceId) {
stop(sModuleId, sInstanceId);
});
}
|
javascript
|
{
"resource": ""
}
|
q63593
|
remove
|
test
|
function remove(sModuleId) {
const oModules = getModules();
var oModule = oModules[sModuleId];
if (isTypeOf(oModule, sNotDefined)) {
return null;
}
if (!isTypeOf(oModule, sNotDefined)) {
try {
return Module;
}
finally {
_delete(sModuleId);
createMapping(getMappingMaps(), 'hm_', oModules);
}
}
return null;
}
|
javascript
|
{
"resource": ""
}
|
q63594
|
_delete
|
test
|
function _delete(sModuleId) {
const oModules = getModules();
if (!isTypeOf(oModules[sModuleId], sNotDefined)) {
delete oModules[sModuleId];
return true;
}
return false;
}
|
javascript
|
{
"resource": ""
}
|
q63595
|
main
|
test
|
function main() {
return __awaiter(this, void 0, void 0, function () {
var outputDataSize, interval, dataFrame, dateFormat, api;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
outputDataSize = "compact";
if (argv.outputDataSize) {
outputDataSize = argv.outputDataSize;
}
interval = '60min';
if (argv.interval) {
interval = argv.interval;
}
api = new index_1.AlphaVantageAPI(argv.apiKey, outputDataSize, argv.verbose);
if (!(argv.type === 'daily')) return [3 /*break*/, 2];
return [4 /*yield*/, api.getDailyDataFrame(argv.symbol)];
case 1:
dataFrame = _a.sent();
dateFormat = 'YYYY-MM-DD';
return [3 /*break*/, 5];
case 2:
if (!(argv.type === 'intraday')) return [3 /*break*/, 4];
return [4 /*yield*/, api.getIntradayDataFrame(argv.symbol, interval)];
case 3:
dataFrame = _a.sent();
dateFormat = "YYYY-MM-DD HH:mm:ss";
return [3 /*break*/, 5];
case 4: throw new Error("Unexpected data type: " + argv.type + ", expected it to be either 'daily' or 'intrday'");
case 5:
if (!argv.verbose) {
console.log('>> ' + argv.out);
}
dataFrame
.transformSeries({
Timestamp: function (t) { return moment(t).format(dateFormat); },
})
.asCSV()
.writeFileSync(argv.out);
return [2 /*return*/];
}
});
});
}
|
javascript
|
{
"resource": ""
}
|
q63596
|
test
|
function(val) {
// here you may parse your format when you build your plugin
var valueInPicker = this.options.itemProperty ? this.pickerValue[this.options.itemProperty] : this.pickerValue;
return (val ? val : valueInPicker);
}
|
javascript
|
{
"resource": ""
}
|
|
q63597
|
test
|
function(val) {
val = this.setValue(val);
if ((val !== false) && (val !== '')) {
if (this.hasInput()) {
this.input.val(this.getValue());
} else {
this.element.data('pickerValue', this.getValue());
}
this._trigger('pickerSetSourceValue', {
pickerValue: val
});
}
return val;
}
|
javascript
|
{
"resource": ""
}
|
|
q63598
|
test
|
function(defaultValue) {
// returns the input or element value, as string
defaultValue = defaultValue || this.options.defaultValue;
var val = defaultValue;
if (this.hasInput()) {
val = this.input.val();
} else {
val = this.element.data('pickerValue');
val = this.options.itemProperty ? val[this.options.itemProperty] : val;
}
if ((val === undefined) || (val === '') || (val === null) || (val === false)) {
// if not defined or empty, return default
val = defaultValue;
}
return val;
}
|
javascript
|
{
"resource": ""
}
|
|
q63599
|
createMarkdownSerializer
|
test
|
function createMarkdownSerializer(indentCodeBlocks) {
return {
serialize: (name, suite) => snapshotToMarkdown(name, suite, indentCodeBlocks),
deserialize: markdownToSnapshot,
};
}
|
javascript
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.