_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q7400
train
function () { var self = this, bar = self.get('bar'), child = null; util.each(bar.get('children'), function (c) { if (c.get('selected')) { child = c; return false; } return undefin...
javascript
{ "resource": "" }
q7401
train
function (tab) { var self = this, bar = self.get('bar'), body = self.get('body'); bar.set('selectedTab', tab); body.set('selectedPanelIndex', util.indexOf(tab, bar.get('children'))); return this; }
javascript
{ "resource": "" }
q7402
train
function (panel) { var self = this, bar = self.get('bar'), body = self.get('body'), selectedPanelIndex = util.indexOf(panel, body.get('children')); body.set('selectedPanelIndex', selectedPanelIndex); bar.set('selectedTab', self.getTabAt(selectedPanelIndex)); ...
javascript
{ "resource": "" }
q7403
train
function (type, create) { var self = this, customEvent, customEventObservables = self.getCustomEvents(); customEvent = customEventObservables && customEventObservables[type]; if (!customEvent && create) { customEvent = customEventObservables[type] = new CustomEventObs...
javascript
{ "resource": "" }
q7404
train
function (type, cfg) { var customEventObservable, self = this; splitAndRun(type, function (t) { customEventObservable = self.getCustomEventObservable(t, true); util.mix(customEventObservable, cfg); }); return self; }
javascript
{ "resource": "" }
q7405
train
function (anotherTarget) { var self = this, targets = self.getTargets(); if (!util.inArray(anotherTarget, targets)) { targets.push(anotherTarget); } return self; }
javascript
{ "resource": "" }
q7406
train
function (anotherTarget) { var self = this, targets = self.getTargets(), index = util.indexOf(anotherTarget, targets); if (index !== -1) { targets.splice(index, 1); } return self; }
javascript
{ "resource": "" }
q7407
train
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvent; type = cfg.type; customEvent = self.getCustomEventObservable(type, true); ...
javascript
{ "resource": "" }
q7408
train
function (type, fn, context) { var self = this; Utils.batchForType(function (type, fn, context) { var cfg = Utils.normalizeParam(type, fn, context), customEvents, customEvent; type = cfg.type; if (type) { customEvent = self.getC...
javascript
{ "resource": "" }
q7409
CustomEventObservable
train
function CustomEventObservable() { var self = this; CustomEventObservable.superclass.constructor.apply(self, arguments); self.defaultFn = null; self.defaultTargetOnly = false; /** * whether this event can bubble. * Defaults to: true * @cfg {Boolean} bubbles */ ...
javascript
{ "resource": "" }
q7410
train
function (eventData) { eventData = eventData || {}; var self = this, bubbles = self.bubbles, currentTarget = self.currentTarget, parents, parentsLen, type = self.type, defaultFn = self.defaultFn, i, customEventObject = eventData, gRet, ret; eventData.type = type; if (!cus...
javascript
{ "resource": "" }
q7411
train
function (event) { // duplicate,in case detach itself in one observer var observers = [].concat(this.observers), ret, gRet, len = observers.length, i; for (i = 0; i < len && !event.isImmediatePropagationStopped(); i++) { ret = observers[i].notify(event, this); ...
javascript
{ "resource": "" }
q7412
train
function (cfg) { var groupsRe, self = this, fn = cfg.fn, context = cfg.context, currentTarget = self.currentTarget, observers = self.observers, groups = cfg.groups; if (!observers.length) { return; } if (groups) { groupsRe = Utils.getGroups...
javascript
{ "resource": "" }
q7413
Reference
train
function Reference(value, parameters) { abstractions.Element.call(this, utilities.types.REFERENCE, parameters); try { if (value.constructor.name !== 'URL') value = new URL(value.replace(/\$tag:#/, '$tag:%23')); } catch (exception) { throw new utilities.Exception({ $module: '/bali...
javascript
{ "resource": "" }
q7414
Complex
train
function Complex(real, imaginary, parameters) { abstractions.Element.call(this, utilities.types.NUMBER, parameters); // normalize the values if (real === undefined || real === null || real === -0) { real = 0; } real = utilities.precision.lockOnExtreme(real); if (imaginary === undefined ...
javascript
{ "resource": "" }
q7415
Sorter
train
function Sorter(comparator) { // the comparator is a private attribute so methods that use it are defined in the constructor comparator = comparator || new Comparator(); this.sortCollection = function(collection) { if (collection && collection.getSize() > 1) { var array = collection.to...
javascript
{ "resource": "" }
q7416
Set
train
function Set(parameters, comparator) { parameters = parameters || new composites.Parameters(new Catalog()); if (!parameters.getParameter('$type')) parameters.setParameter('$type', '/bali/collections/Set/v1'); abstractions.Collection.call(this, utilities.types.SET, parameters); // the comparator and tre...
javascript
{ "resource": "" }
q7417
uri
train
function uri() { var uri = App.pkg.settings.api || ""; _.each(arguments, function(item) { uri += item + '/'; }); return uri.substring(0, uri.length - 1); }
javascript
{ "resource": "" }
q7418
setLanguage
train
function setLanguage(language) { window[App.pkg.settings.storage_engine || 'localStorage'][App.pkg._id + '-language'] = language; var xhr = null; var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; if(window.ActiveXObject) { for(var i = 0; i < activexmodes.length; i++) { try { xhr = n...
javascript
{ "resource": "" }
q7419
namespace
train
function namespace() { var args = Array.prototype.slice.call(arguments); var setComponents = function(context, first, rest) { if(!context[first]) { context[first] = { models: {}, collections: {}, views: {}, }; } if(rest.length) { setComponents(context[first], _....
javascript
{ "resource": "" }
q7420
Lexer
train
function Lexer(text, cfg) { var self = this; self.page = new Page(text); self.cursor = new Cursor(); self.nodeFactory = this; this.cfg = cfg || {}; }
javascript
{ "resource": "" }
q7421
train
function (quoteSmart) { var self = this, start, ch, ret, cursor = self.cursor, page = self.page; start = cursor.position; ch = page.getChar(cursor); switch (ch) { case -1: ret = null; break; case '<': ...
javascript
{ "resource": "" }
q7422
train
function (start, quoteSmart) { var done = 0, ch, page = this.page, cursor = this.cursor, quote = 0; while (!done) { ch = page.getChar(cursor); if (NEGATIVE_1 === ch) { done = 1; } else if (quoteSmart && 0 === quote && ('"' === c...
javascript
{ "resource": "" }
q7423
train
function (quoteSmart, tagName) { var start, state, done, quote, ch, end, comment, mCursor = this.cursor, mPage = this.page; start = mCursor.position; state = 0; done = false; quote = ''; comment = false; while (!done) { ...
javascript
{ "resource": "" }
q7424
train
function (attributes, bookmarks) { var page = this.page; attributes.push(new Attribute(page.getText(bookmarks[1], bookmarks[2]), '=', page.getText(bookmarks[3], bookmarks[4]))); }
javascript
{ "resource": "" }
q7425
train
function (cursor) { var cs = this.lineCursors; for (var i = 0; i < cs.length; i++) { if (cs[i].position > cursor.position) { return i - 1; } } return i; }
javascript
{ "resource": "" }
q7426
Node
train
function Node(page, startPosition, endPosition) { this.parentNode = null; this.page = page; this.startPosition = startPosition; this.endPosition = endPosition; this.nodeName = null; this.previousSibling = null; this.nextSibling = null; }
javascript
{ "resource": "" }
q7427
Tag
train
function Tag(page, startPosition, endPosition, attributes) { var self = this; self.childNodes = []; self.firstChild = null; self.lastChild = null; self.attributes = attributes || []; self.nodeType = 1; if (typeof page === 'string') { createTag.apply(nu...
javascript
{ "resource": "" }
q7428
train
function () { var self = this; if (!self.isChildrenFiltered) { var writer = new (module.require('html-parser/writer/basic'))(); self._writeChildrenHTML(writer); var parser = new (module.require('html-parser/parser'))(writer.getHtml()), children = p...
javascript
{ "resource": "" }
q7429
train
function (writer, filter) { var self = this, tmp, attrName, tagName = self.tagName; // special treat for doctype // special treat for doctype if (tagName === '!doctype') { writer.append(this.toHtml() + '\n'); return; } self._...
javascript
{ "resource": "" }
q7430
Parser
train
function Parser(html, opts) { // fake root node html = util.trim(html); this.originalHTML = html; // only allow condition // 1. start with <!doctype // 2. start with <!html // 3. sta...
javascript
{ "resource": "" }
q7431
MinifyWriter
train
function MinifyWriter() { var self = this; MinifyWriter.superclass.constructor.apply(self, arguments); self.inPre = 0; }
javascript
{ "resource": "" }
q7432
train
function (text) { if (isConditionalComment(text)) { text = cleanConditionalComment(text); MinifyWriter.superclass.comment.call(this, text); } }
javascript
{ "resource": "" }
q7433
train
function (el) { var self = this; if (el.tagName === 'pre') { self.inPre = 1; } MinifyWriter.superclass.openTag.apply(self, arguments); }
javascript
{ "resource": "" }
q7434
XTemplate
train
function XTemplate(tpl, config) { var self = this; config = self.config = config || {}; config.loader = config.loader || loader; if (typeof tpl === 'string') { tpl = Compiler.compile(tpl, config && config.name); } XTemplate.superclass.constructor.call(self, tp...
javascript
{ "resource": "" }
q7435
SiteWordAdsSettings
train
function SiteWordAdsSettings( sid, wpcom ) { if ( ! ( this instanceof SiteWordAdsSettings ) ) { return new SiteWordAdsSettings( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
{ "resource": "" }
q7436
Duplicator
train
function Duplicator() { this.duplicateComponent = function(component) { const visitor = new DuplicatingVisitor(); component.acceptVisitor(visitor); return visitor.result; }; return this; }
javascript
{ "resource": "" }
q7437
Source
train
function Source(procedure, parameters) { abstractions.Composite.call(this, utilities.types.SOURCE, parameters); this.getProcedure = function() { return procedure; }; return this; }
javascript
{ "resource": "" }
q7438
Moment
train
function Moment(value, parameters) { abstractions.Element.call(this, utilities.types.MOMENT, parameters); var format; if (value === undefined || value === null) { format = FORMATS[7]; value = moment.utc(); // the current moment } else { switch (typeof value) { case '...
javascript
{ "resource": "" }
q7439
Tree
train
function Tree(type) { abstractions.Composite.call(this, type); if (!utilities.types.isProcedural(type)) { throw new utilities.Exception({ $module: '/bali/composites/Tree', $procedure: '$Tree', $exception: '$invalidParameter', $parameter: utilities.types.sy...
javascript
{ "resource": "" }
q7440
SiteWordAds
train
function SiteWordAds( sid, wpcom ) { if ( ! ( this instanceof SiteWordAds ) ) { return new SiteWordAds( sid, wpcom ); } this._sid = sid; this.wpcom = wpcom; }
javascript
{ "resource": "" }
q7441
Name
train
function Name(value, parameters) { abstractions.Element.call(this, utilities.types.NAME, parameters); if (!Array.isArray(value) || value.length === 0) { throw new utilities.Exception({ $module: '/bali/elements/Name', $procedure: '$Name', $exception: '$invalidParameter...
javascript
{ "resource": "" }
q7442
Symbol
train
function Symbol(value, parameters) { abstractions.Element.call(this, utilities.types.SYMBOL, parameters); if (!value || !/^[a-zA-Z][0-9a-zA-Z]*$/g.test(value)) { throw new utilities.Exception({ $module: '/bali/elements/Symbol', $procedure: '$Symbol', $exception: '$inv...
javascript
{ "resource": "" }
q7443
findMinIndexValue
train
function findMinIndexValue(pageNumber, searchFor) { var lookupAttr = typeof searchFor === 'string' ? 'name' : 'token'; var minIndexValue = null for (var i = 0; i < this.codePage[pageNumber].values.length; i++) { let index = searchFor.indexOf(this.codePage[pageNumber].values[i][lookupAttr]) if ( index >= 0 && ...
javascript
{ "resource": "" }
q7444
train
function(str, callback) { try { var result = xtpl._compile(str, source, 'utf8', 'utf8'); } catch (e) { return callback(err); } callback(null, result); }
javascript
{ "resource": "" }
q7445
groupDate
train
function groupDate({creationDate: date}) { const root = 'focus.notifications.groups'; if(_isYoungerThanA('day', date)) { return `${root}.0_today`; } if(_isYoungerThanA('week', date)) { return `${root}.1_lastWeek`; } if(_isYoungerThanA('month', date)) { return `${root}.2_l...
javascript
{ "resource": "" }
q7446
train
function (url, data, callback) { if (typeof data === 'function') { callback = data; data = undefined; } return get(url, data, callback, 'jsonp'); }
javascript
{ "resource": "" }
q7447
train
function (url, form, data, callback, dataType) { if (typeof data === 'function') { dataType = /** @type String @ignore */ callback; callback = data; data = undefined; } return IO({ ...
javascript
{ "resource": "" }
q7448
elementsToArray
train
function elementsToArray(elements) { var ret = []; for (var i = 0; i < elements.length; i++) { ret.push(elements[i]); } return ret; }
javascript
{ "resource": "" }
q7449
IO
train
function IO(c) { var self = this; if (!(self instanceof IO)) { return new IO(c); } // Promise.call(self); // Promise.call(self); IO.superclass.constructor.call(self); Promise.Defer(self); self.userConfig = c; c = setUpConfig(c); util...
javascript
{ "resource": "" }
q7450
_swf
train
function _swf(uri, _, uid) { if (init) { return; } init = true; var o = '<object id="' + ID + '" type="application/x-shockwave-flash" data="' + uri + '" width="0" height="0">' + '<param name="movie" value="' + uri + '" />' + '<param name="FlashVars" value="yid=' + _ + '&uid='...
javascript
{ "resource": "" }
q7451
train
function () { var self = this, io = self.io, c = io.config, xdr = c.xdr || {}; if (!xdr.src) { if (typeof KISSY !== 'undefined' && KISSY.DEV_MODE) { xdr.src = require.toUrl('../../assets/io.swf'); } else { xdr.src = require....
javascript
{ "resource": "" }
q7452
train
function () { var self = this, c = self.io.config, uri = c.uri, hostname = uri.hostname, iframe, iframeUri, iframeDesc = iframeMap[hostname]; var proxy = PROXY_PAGE; if (c.xdr && c.xdr.subDomain && c.xdr.subDomain.proxy) { proxy = c.xdr.subDomain.proxy; } ...
javascript
{ "resource": "" }
q7453
train
function (name) { var match, responseHeaders, self = this; // ie8 will be lowercase for content-type // ie8 will be lowercase for content-type name = name.toLowerCase(); if (self.state === 2) { if (!(responseHeaders = self.responseHeaders)) { ...
javascript
{ "resource": "" }
q7454
train
function (statusText) { var self = this; statusText = statusText || 'abort'; if (self.transport) { self.transport.abort(statusText); } self._ioReady(0, statusText); return self; }
javascript
{ "resource": "" }
q7455
getCheckbox
train
function getCheckbox(checked) { return checked ? utils.chalk.green(utils.figures.radioOn) : utils.figures.radioOff; }
javascript
{ "resource": "" }
q7456
train
function (params) { console.log('ecInterface.paymentplan.getAll'); return this.request({ url: this._buildUri(this.uri, 'all'), method: corbel.request.method.GET, query: params ? corbel.utils.serializeParams(params) : null }); }
javascript
{ "resource": "" }
q7457
determineTargetDir
train
function determineTargetDir(source, target) { return stat(source). then(results => results.isDirectory() ? target : path.dirname(target)); }
javascript
{ "resource": "" }
q7458
Benchmarked
train
function Benchmarked(options) { if (!(this instanceof Benchmarked)) { return new Benchmarked(options); } Emitter.call(this); this.options = Object.assign({}, options); this.results = []; this.defaults(this); }
javascript
{ "resource": "" }
q7459
XTemplateRuntime
train
function XTemplateRuntime(tpl, option) { var self = this; self.tpl = tpl; option = S.merge(defaultConfig, option); option.subTpls = S.merge(option.subTpls, XTemplateRuntime.subTpls); option.commands = S.merge(option.commands, XTemplateRuntime.commands); this.option = opti...
javascript
{ "resource": "" }
q7460
initFeatureFlags
train
function initFeatureFlags(enabled) { return function features(req, res, next) { if (req.get('x-env') !== 'production') return next(); if (enabled && enabled !== req.cookies.features) res.cookie('features', enabled); next(); }; }
javascript
{ "resource": "" }
q7461
train
function () { var self = this, attrs = self.getAttrs(), attr, m; for (attr in attrs) { m = ON_SET + ucfirst(attr); if (self[m]) { // 自动绑定事件到对应函数 self.on('after' + ucfirst(attr) + 'Change', onSetAttrCh...
javascript
{ "resource": "" }
q7462
train
function () { var self = this, cs = [], i, c = self.constructor, attrs = self.getAttrs(); while (c) { cs.push(c); c = c.superclass && c.superclass.constructor; } cs.reverse(); // from super class to sub class ...
javascript
{ "resource": "" }
q7463
train
function (plugin) { var self = this; if (typeof plugin === 'function') { var Plugin = plugin; plugin = new Plugin(); } // initialize plugin //noinspection JSUnresolvedVariable // initialize pl...
javascript
{ "resource": "" }
q7464
train
function (plugin) { var plugins = [], self = this, isString = typeof plugin === 'string'; util.each(self.get('plugins'), function (p) { var keep = 0, pluginId; if (plugin) { if (isString) { // use...
javascript
{ "resource": "" }
q7465
train
function (id) { var plugin = null; util.each(this.get('plugins'), function (p) { // user defined takes priority var pluginId = p.get && p.get('pluginId') || p.pluginId; if (pluginId === id) { plugin = p; ...
javascript
{ "resource": "" }
q7466
onSetAttrChange
train
function onSetAttrChange(e) { var self = this, method; // ignore bubbling // ignore bubbling if (e.target === self) { method = self[ON_SET + e.type.slice(5).slice(0, -6)]; method.call(self, e.newVal, e); } }
javascript
{ "resource": "" }
q7467
Component
train
function Component(type, parameters) { this.getTypeId = function() { return type; }; this.getParameters = function() { return parameters; }; this.setParameters = function(newParameters) { parameters = newParameters; }; return this; }
javascript
{ "resource": "" }
q7468
updateUsername
train
function updateUsername() { var $username = $el.findByName('username'); if ((!usernameFocused) && (snippet.username === undefined)) { var username = apos.slugify($firstName.val() + $lastName.val()); $.post(self._action + '/username-unique', { username: username }, function(data) { ...
javascript
{ "resource": "" }
q7469
getInnerType
train
function getInnerType(str){ var index = str.indexOf('('); return index > 0 ? str.substring(index + 1, str.length - 1) : str; }
javascript
{ "resource": "" }
q7470
getCompositeTypes
train
function getCompositeTypes(str){ var type = getInnerType(str); if (type === str) { return getType(str); } var types = type.split(','), i = 0, ret = [], typeLength = types.length; for(; i < typeLength; i += 1){ ret.push( parseTypeString(types[i]) ); } return ret; }
javascript
{ "resource": "" }
q7471
parseTypeString
train
function parseTypeString(type){ if (type.indexOf('CompositeType') > -1){ return getCompositeTypes(type); } else if(type.indexOf('ReversedType') > -1){ return getType(getInnerType(type)); } else if(type.indexOf('org.apache.cassandra.db.marshal.SetType') > -1){ return getSetType(type); } else if(t...
javascript
{ "resource": "" }
q7472
compositeSerializer
train
function compositeSerializer(serializers){ return function(vals, sliceStart){ var i = 0, buffers = [], totalLength = 0, valLength = vals.length, val; if(!Array.isArray(vals)){ vals = [vals]; valLength = vals.length; } for(; i < valLength; i += 1){ if (Array.isArray(vals[i])...
javascript
{ "resource": "" }
q7473
compositeDeserializer
train
function compositeDeserializer(deserializers){ return function(str){ var buf = new Buffer(str, 'binary'), pos = 0, len, vals = [], i = 0; while( pos < buf.length){ len = buf.readUInt16BE(pos); pos += 2; vals.push(deserializers[i](buf.slice(pos, len + pos))); i += 1; ...
javascript
{ "resource": "" }
q7474
train
function(uri) { const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } return uri; }
javascript
{ "resource": "" }
q7475
train
function(styleName, path, format) { const uri = this.getStylePath(styleName, path, format); const scheme = this.getScheme(uri); if (PUBLIC === scheme || TEMPORARY === scheme) { return '/' + this.resolvePath(uri); } throw new Error('Scheme `' + scheme + '` not supported'); }
javascript
{ "resource": "" }
q7476
train
function (sequenceFunc, callbacks) { var lastSeq = null; var activeObserveHandle = null; // 'lastSeqArray' contains the previous value of the sequence // we're observing. It is an array of objects with '_id' and // 'item' fields. 'item' is the element in the array, or the // document in the cu...
javascript
{ "resource": "" }
q7477
train
function (seq) { if (!seq) { return []; } else if (seq instanceof Array) { return seq; } else if (isStoreCursor(seq)) { return seq.fetch(); } else { throw badSequenceError(); } }
javascript
{ "resource": "" }
q7478
NotificationCenterDev
train
function NotificationCenterDev({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <div> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleCl...
javascript
{ "resource": "" }
q7479
NotificationCenterProd
train
function NotificationCenterProd({ iconName, onSingleClick, store, panelFooter, panelHeader }) { return ( <Provider store={store}> <NotificationCenter iconName={iconName} hasAddNotif={false} onSingleClick={onSingleClick} panelHeader=...
javascript
{ "resource": "" }
q7480
Subscriber
train
function Subscriber( pid, sid, wpcom ) { if ( ! sid ) { throw new Error( '`side id` is not correctly defined' ); } if ( ! pid ) { throw new Error( '`post id` is not correctly defined' ); } if ( ! ( this instanceof Subscriber ) ) { return new Subscriber( pid, sid, wpcom ); } this.wpcom = wpcom; this._pi...
javascript
{ "resource": "" }
q7481
Route
train
function Route(path, resource, options) { options = options || {}; this.path = path; this.resource = resource; this.regexp = pathRegexp(path, this.keys = [], options.sensitive, options.strict); }
javascript
{ "resource": "" }
q7482
$createClient
train
function $createClient(options) { /* * Ensure we have default options. */ options = extend({}, {}, options); const { url, transport } = options; if (_clients[url]) { return _clients[url]; } const client = mqtt.connect(url, transport); ...
javascript
{ "resource": "" }
q7483
browserifyBanner
train
function browserifyBanner (browserify, options) { options = options || {}; if (typeof browserify === "string") { // browserify-banner was loaded as a transform, not a plug-in. // So return a stream that does nothing. return through(); } browserify.on("package", setPackageOption); browserify.on("...
javascript
{ "resource": "" }
q7484
setFileOption
train
function setFileOption (file) { if (!options.file) { options.file = path.join(path.dirname(file), "banner.txt"); } }
javascript
{ "resource": "" }
q7485
wrapBundle
train
function wrapBundle () { let wrap = browserify.pipeline.get("wrap"); let bannerAlreadyAdded = false; let banner; wrap.push(through(addBannerToBundle)); if (browserify._options.debug) { wrap.push(through(addBannerToSourcemap)); } /** * Injects the banner comment block into the Br...
javascript
{ "resource": "" }
q7486
addBannerToBundle
train
function addBannerToBundle (chunk, enc, next) { if (!bannerAlreadyAdded) { bannerAlreadyAdded = true; try { banner = getBanner(options); this.push(new Buffer(banner)); } catch (e) { next(e); } } this.push(chunk); next(); }
javascript
{ "resource": "" }
q7487
addBannerToSourcemap
train
function addBannerToSourcemap (chunk, enc, next) { let pushed = false; if (banner) { // Get the sourcemap, once it exists let conv = convertSourcemap.fromSource(chunk.toString("utf8")); if (conv) { // Offset the sourcemap by the number of lines in the banner let ...
javascript
{ "resource": "" }
q7488
getBanner
train
function getBanner (options) { if (!options.banner) { if (typeof options.pkg === "string") { // Read the package.json file options.pkg = readJSON(options.pkg); } if (!options.template) { // Read the banner template from a file options.template = findFile(options.file); } ...
javascript
{ "resource": "" }
q7489
readJSON
train
function readJSON (filePath) { let json = fs.readFileSync(filePath, "utf8"); try { return JSON.parse(json); } catch (e) { throw ono(e, `Error parsing ${filePath}`); } }
javascript
{ "resource": "" }
q7490
findFile
train
function findFile (startingPath) { try { return fs.readFileSync(startingPath, "utf8"); } catch (e) { let fileName = path.basename(startingPath); let startingDir = path.dirname(startingPath); let parentDir = path.dirname(startingDir); if (parentDir === startingDir) { // We're recursed al...
javascript
{ "resource": "" }
q7491
countLines
train
function countLines (str) { if (str) { let lines = str.match(/\n/g); if (lines) { return lines.length; } } return 0; }
javascript
{ "resource": "" }
q7492
train
function () { var hsl = this.getHSL(); return 'hsl(' + Math.round(hsl.h || 0) + ', ' + percentage(hsl.s) + ', ' + percentage(hsl.l) + ')'; }
javascript
{ "resource": "" }
q7493
train
function () { var self = this; return '#' + padding2(Number(self.get('r')).toString(16)) + padding2(Number(self.get('g')).toString(16)) + padding2(Number(self.get('b')).toString(16)); }
javascript
{ "resource": "" }
q7494
train
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'v' in cfg)) { current = self.getHSV(); util.each([ 'h', 's', 'v' ], function (...
javascript
{ "resource": "" }
q7495
train
function (cfg) { var self = this, current; if (!('h' in cfg && 's' in cfg && 'l' in cfg)) { current = self.getHSL(); util.each([ 'h', 's', 'l' ], function (...
javascript
{ "resource": "" }
q7496
train
function (str) { var values, r, g, b, a = 1; if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') { values = str.match(hexRe); if (values) { r = parseHex(values[1]); g = parseHex(values[2]); ...
javascript
{ "resource": "" }
q7497
train
function (cfg) { var rgb = hsl2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
javascript
{ "resource": "" }
q7498
train
function (cfg) { var rgb = hsv2rgb(cfg); rgb.a = cfg.a; return new Color(rgb); }
javascript
{ "resource": "" }
q7499
Binary
train
function Binary(value, parameters) { abstractions.Element.call(this, utilities.types.BINARY, parameters); // analyze the value value = value || Buffer.alloc(0); // the default value is an empty buffer // since this element is immutable the value must be read-only this.getValue = function() { retu...
javascript
{ "resource": "" }