_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q9800
buildOpeningElementAttributes
train
function buildOpeningElementAttributes(attribs, file) { let _props = [] let objs = [] function pushProps() { if (_props.length === 0) return objs.push(t.objectExpression(_props)) _props = [] } while (attribs.length) { const prop = attribs.shift() if (t.isJSXSpreadAttr...
javascript
{ "resource": "" }
q9801
decoder
train
function decoder(mtype) { const gen = util.codegen([ 'r', 'l' ], mtype.name + '$decode')('if(!(r instanceof Reader))')('r=Reader.create(r)')('var c=l===undefined?r.len:r.pos+l,m=new this.ctor' + (mtype.fieldsArray.filter(field => field.map).length ? ',k' : ''))('while(r.pos<c){')('var t=r.uint32()'); if (mtype.gro...
javascript
{ "resource": "" }
q9802
populateOptions
train
function populateOptions(node, values) { if (node.tagName !== 'option') { for (var i = 0, len = node.children.length; i < len ; i++) { populateOptions(node.children[i], values); } return; } var value = node.attrs && node.attrs.value; value = value || node.props && node.props.value; if (!val...
javascript
{ "resource": "" }
q9803
train
function(sInput, levels, indentString) { var indentedLineBreak; indentString = indentString || '\t'; indentedLineBreak = '\n'+ ( new Array( levels + 1 ).join( indentString ) ); return indentedLineBreak + sInput.split('\n').join(indentedLineBreak); }
javascript
{ "resource": "" }
q9804
train
function(baseUri, branch, filePath, fileName) { var varPath = fileName ? 'blob/' : 'tree/' ,branch = branch ? branch + '/' : 'develop' ,filePath = path.relative(process.cwd(), filePath) + '/' ; fileName = fileName || ''; return baseUri ? baseUri + varPath + branch + filePath + fileName : null; }
javascript
{ "resource": "" }
q9805
register
train
function register(types, converter) { types.split(' ').forEach(function (type) { converters[type] = converter; }); }
javascript
{ "resource": "" }
q9806
run
train
function run () { var midSequence = this.middlewares.reverse() var initialNext = this.next.bind() var req = this.req var res = this.res var nestedCallSequence // create the call sequence nestedCallSequence = midSequence.reduce(middlewareReducer, initialNext) // call it nestedCallSequence.call() /*...
javascript
{ "resource": "" }
q9807
middlewareReducer
train
function middlewareReducer (callSequence, middleware) { return function nextHandler (err) { // if the previous middleware passed an error argument if (err !== undefined) { if (isErrorHandler(middleware)) { // call the current middleware if it is an error handler middleware mi...
javascript
{ "resource": "" }
q9808
append
train
function append (/* mid_0, ..., mid_n */) { var i for (i = 0; i < arguments.length; i++) { if (typeof arguments[i] !== 'function') { var type = typeof arguments[i] var errMsg = 'Given middlewares must be functions. "' + type + '" given.' throw new TypeError(errMsg) } } for (i = 0; i < ...
javascript
{ "resource": "" }
q9809
appendList
train
function appendList (middlewares) { if (!Array.isArray(middlewares)) { var errorMsg = 'First argument must be an array of middlewares. ' errorMsg += typeof middlewares + ' given.' throw new TypeError(errorMsg) } return this.append.apply(this, middlewares) }
javascript
{ "resource": "" }
q9810
appendIf
train
function appendIf (filter /*, middlewares */) { var errorMsg var middlewares = [] if (arguments.length < 2) { errorMsg = 'ConnectSequence#appendIf() takes 2 arguments. ' errorMsg += arguments.length + ' given.' throw new MissingArgumentError(errorMsg) } if (typeof filter !== 'function') { err...
javascript
{ "resource": "" }
q9811
appendListIf
train
function appendListIf (filter, middlewares) { var args = [filter] for (var i = 0; i < middlewares.length; i++) { args.push(middlewares[i]) } return this.appendIf.apply(this, args) }
javascript
{ "resource": "" }
q9812
isErrorHandler
train
function isErrorHandler (cb) { var str = cb.toString() var args = str.split('(')[1].split(')')[0].split(',') return args.length === 4 }
javascript
{ "resource": "" }
q9813
condense
train
function condense (node) { if (node.nodes.length === 1 && node.nodes[0].nodes.length > 0) { return condense({ label: (node.label || '') + node.nodes[0].label, nodes: node.nodes[0].nodes }) } else { return { label: node.label, nodes: node.nodes.map(condense) } } }
javascript
{ "resource": "" }
q9814
Device
train
function Device(Connection) { var self = this; // call super class EventEmitter2.call(this, { wildcard: true, delimiter: ':', maxListeners: 1000 // default would be 10! }); if (this.log) { this.log = _.wrap(this.log, function(func, msg) { func(self.constructor.name + ': ' + msg); }...
javascript
{ "resource": "" }
q9815
FtdiDevice
train
function FtdiDevice(deviceSettings, connectionSettings, Connection) { // call super class Device.call(this, Connection); if (deviceSettings instanceof ftdi.FtdiDevice) { this.ftdiDevice = deviceSettings; this.set(this.ftdiDevice.deviceSettings); } else { this.set(deviceSettings); } this.set('...
javascript
{ "resource": "" }
q9816
train
function(taskFn, taskParams) { var task = this._buildTask(taskFn, taskParams); if(task.params.weight > this._params.weightLimit) { throw Error('task with weight of ' + task.params.weight + ' can\'t be performed in queue with limit of ' + this....
javascript
{ "resource": "" }
q9817
train
function() { if(!this._isStopped) { return; } this._isStopped = false; var processedBuffer = this._processedBuffer; if(processedBuffer.length) { this._processedBuffer = []; nextTick(function() { while(processedBuffer.length) { ...
javascript
{ "resource": "" }
q9818
countMatches
train
function countMatches(orders) { var matched = 0, dimension = orders[0].length while(matched < dimension) { for(var j=1; j<orders.length; ++j) { if(orders[j][matched] !== orders[0][matched]) { return matched } } ++matched } return matched }
javascript
{ "resource": "" }
q9819
FtdiSerialDevice
train
function FtdiSerialDevice(deviceSettings, connectionSettings, Connection) { if (_.isString(deviceSettings) && (deviceSettings.indexOf('COM') === 0 || deviceSettings.indexOf('/') === 0)) { this.isSerialDevice = true; // call super class SerialDevice.call(this, deviceSettings, connectionSetting...
javascript
{ "resource": "" }
q9820
strongDirFromContent
train
function strongDirFromContent (text) { var m = text.match(strongDirRegExp) if (!m) { return null } if (m[2] === undefined) { return 'ltr' } return 'rtl' }
javascript
{ "resource": "" }
q9821
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomCategory)){ return new AtomCategory(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomCategory.isInstance(json)){ ...
javascript
{ "resource": "" }
q9822
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Agent)){ return new Agent(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Agent.isInstance(json)){ return json; } this.init(json); ...
javascript
{ "resource": "" }
q9823
toSQL
train
function toSQL() { if (this._cached) { return this._cached; } if (Array.isArray(this.bindings)) { this._cached = replaceRawArrBindings(this); } else if (this.bindings && typeof this.bindings === 'object') { this._cached = replaceKeyBindings(this); } else { this._cached = { ...
javascript
{ "resource": "" }
q9824
reqres
train
function reqres(res, req) { if (req && req._headers) { throw new Error('Received response object where request object was expected'); } this.res = res; this.req = req; if (res) { if (res.$ && res.$.data) { this.data = res.$.data; } else { this....
javascript
{ "resource": "" }
q9825
xreqhan
train
function xreqhan(res, req, output) { if (isResHeaderSent(res)) { return console.error('request already closed', new Error().stack); } output = output || ''; var isBinary = output && Buffer.isBuffer(output); if (isBinary) { res.end(output, 'binary'); } else if (res.send) { //E...
javascript
{ "resource": "" }
q9826
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof CollectionContent)){ return new CollectionContent(json); } // If the given object is already an instance then just return it. DON'T copy it. if(CollectionContent.isInstance...
javascript
{ "resource": "" }
q9827
isGoodHash
train
function isGoodHash (hash, target) { hash = new Buffer(hash, 'hex') target = new Buffer(target, 'hex') return _.range(32).some(function (index) { return hash[index] < target[index] }) }
javascript
{ "resource": "" }
q9828
verifyHeader
train
function verifyHeader (currentHash, currentHeader, hashPrevBlock, prevHeader, target, isTestnet) { try { // check hashPrevBlock assert.equal(hashPrevBlock, currentHeader.hashPrevBlock) try { // check difficulty assert.equal(currentHeader.bits, target.bits) // check hash and target ...
javascript
{ "resource": "" }
q9829
clean
train
function clean(source) { if (!source) return BLANK; if (source.charCodeAt(0) === BOM_CODE) source = source.slice(1); source = source.replace(CR_REGEXP, BLANK).replace(TRAILING_WHITESPACE_REGEXP, BLANK); return source; }
javascript
{ "resource": "" }
q9830
lex
train
function lex(source) { var tokens = []; var chunk = clean(source); var total = chunk.length; var iterations = 0; while (chunk.length > 0) { for (var regexpName in REGEXPS) { var regexp = REGEXPS[regexpName]; var match = regexp.exec(chunk); if (match) { ...
javascript
{ "resource": "" }
q9831
Deb
train
function Deb () { this.data = tar.pack() this.control = tar.pack() this.pkgSize = 0 this.controlFile = {} this.filesMd5 = [] this.dirs = {} }
javascript
{ "resource": "" }
q9832
buildControlFile
train
function buildControlFile (tempPath, definition, callback) { var self = this var author = '' if (definition.package.author) { author = typeof definition.package.author === 'string' ? definition.package.author : definition.package.author.name + ' <' + definition.package.author.email + '>' } s...
javascript
{ "resource": "" }
q9833
packFiles
train
function packFiles (tempPath, files, callback) { var self = this async.eachSeries(files, function (crtFile, done) { var filePath = path.resolve(crtFile.src[0]) debug('adding %s', filePath) async.waterfall([ fs.stat.bind(fs, filePath), function (stats, wtfDone) { if (stats.isDirector...
javascript
{ "resource": "" }
q9834
generateSignature
train
function generateSignature(email, password) { let googleDefaultPublicKey = 'AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ=='; let keyBuffer = Buffer.from(googleDefaultPub...
javascript
{ "resource": "" }
q9835
train
function(selectedPort, callback) { if(selectedPort === false) grunt.fatal('No available port was found') self.data.targets.forEach(function(prop) { pp.injectPort(prop, selectedPort) }) if(pp.options.name) { pp.injectPort(pp.options.name, selectedPort) ...
javascript
{ "resource": "" }
q9836
train
function(callback) { var step = 0 async.whilst( function() { return ++step <= pp.options.extra }, function(callback) { pp.tryPorts = [] var c = grunt.config.get('port-pick-' + step) // With multiple tasks, do not find a port...
javascript
{ "resource": "" }
q9837
columnize
train
function columnize(target) { var columns = typeof target === 'string' ? [target] : target; var str = '', i = -1; while (++i < columns.length) { if (i > 0) { str += ', '; } str += this.wrap(columns[i]); } return str; }
javascript
{ "resource": "" }
q9838
parameter
train
function parameter(value) { if (typeof value === 'function') { return this.outputQuery(this.compileCallback(value), true); } return this.unwrapRaw(value, true) || '?'; }
javascript
{ "resource": "" }
q9839
wrap
train
function wrap(value) { var raw; if (typeof value === 'function') { return this.outputQuery(this.compileCallback(value), true); } raw = this.unwrapRaw(value); if (raw) { return raw; } if (typeof value === 'number') { return value; } return this._wrapString(value + ''...
javascript
{ "resource": "" }
q9840
operator
train
function operator(value) { var raw = this.unwrapRaw(value); if (raw) { return raw; } if (operators[(value || '').toLowerCase()] !== true) { throw new TypeError('The operator "' + value + '" is not permitted'); } return value; }
javascript
{ "resource": "" }
q9841
direction
train
function direction(value) { var raw = this.unwrapRaw(value); if (raw) { return raw; } return orderBys.indexOf((value || '').toLowerCase()) !== -1 ? value : 'asc'; }
javascript
{ "resource": "" }
q9842
compileCallback
train
function compileCallback(callback, method) { var client = this.client; // Build the callback var builder = client.queryBuilder(); callback.call(builder, builder); // Compile the callback, using the current formatter (to track all bindings). var compiler = client.queryCompiler(builder); com...
javascript
{ "resource": "" }
q9843
outputQuery
train
function outputQuery(compiled, isParameter) { var sql = compiled.sql || ''; if (sql) { if (compiled.method === 'select' && (isParameter || compiled.as)) { sql = '(' + sql + ')'; if (compiled.as) { return this.alias(sql, this.wrap(compiled.as)); } } } return ...
javascript
{ "resource": "" }
q9844
_wrapString
train
function _wrapString(value) { var segments, asIndex = value.toLowerCase().indexOf(' as '); if (asIndex !== -1) { var first = value.slice(0, asIndex); var second = value.slice(asIndex + 4); return this.alias(this.wrap(first), this.wrap(second)); } var i = -1, wrapped = [...
javascript
{ "resource": "" }
q9845
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Collection)){ return new Collection(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Collection.isInstance(json)){ return...
javascript
{ "resource": "" }
q9846
train
function(xhr) { var response = { headers: {}, statusCode: xhr.status }; var headerPairs = xhr.getAllResponseHeaders().split('\u000d\u000a'); for (var i = 0; i < headerPairs.length; i++) { var headerPair = headerPairs[i], index = headerPair.indexOf('\u003a\u0020'); ...
javascript
{ "resource": "" }
q9847
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Fact)){ return new Fact(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Fact.isInstance(json)){ return json; } this.init(json); }
javascript
{ "resource": "" }
q9848
Handshake
train
function Handshake(context, options) { if (!this) return new Handshake(context, options); options = options || {}; this.stringify = options.stringify || qs.stringify; this.configure = Object.create(null); this.timers = new Tick(context); this.id = options.id || v4; this.context = context; this.payload...
javascript
{ "resource": "" }
q9849
Route
train
function Route(query, node, callbacks, options) { options = options || {}; this.query = query; this.node = node; this.callbacks = callbacks; this.regexp = normalize(node , this.keys = [] , options.sensitive , options.strict); }
javascript
{ "resource": "" }
q9850
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof Root)){ return new Root(json); } // If the given object is already an instance then just return it. DON'T copy it. if(Root.isInstance(json)){ return json; } this.init(json); }
javascript
{ "resource": "" }
q9851
factory
train
function factory( query, context = document ) { const converter = bsc(); const selectorEngine = new SelectorEngine(); const bemQuery = new BEMQuery( query, context, converter, selectorEngine ); return bemQuery; }
javascript
{ "resource": "" }
q9852
addChild
train
function addChild(data) { var child = new TreeNode(data, this); if (!this.children) { this.children = []; } this.children.push(child); return child; }
javascript
{ "resource": "" }
q9853
find
train
function find(data) { if (data === this.data) { return this; } if (this.children) { for (var i = 0, _length = this.children.length, target = null; i < _length; i++) { target = this.children[i].find(data); ...
javascript
{ "resource": "" }
q9854
leaves
train
function leaves() { if (!this.children || this.children.length === 0) { // this is a leaf return [this]; } // if not a leaf, return all children's leaves recursively var leaves = []; if (this.childre...
javascript
{ "resource": "" }
q9855
forEach
train
function forEach(callback) { if (typeof callback !== 'function') { throw new TypeError('forEach() callback must be a function'); } // run this node through function callback(this); // do the same for all children ...
javascript
{ "resource": "" }
q9856
train
function() { var self = this; if (self.filter.get("valid")) { self.$el.removeClass("invalidvalid"); self.$el.addClass("valid"); } else { self.$el.removeClass("valid"); self.$el.addClass("invalid"); } }
javascript
{ "resource": "" }
q9857
train
function(json){ // Protect against forgetting the new keyword when calling the constructor if(!(this instanceof AtomFeed)){ return new AtomFeed(json); } // If the given object is already an instance then just return it. DON'T copy it. if(AtomFeed.isInstance(json)){ return json;...
javascript
{ "resource": "" }
q9858
pad
train
function pad(side, num, ch) { var exp = `${side === 'left' ? '' : '^'}.{${num}}${side === 'right' ? '' : '$'}`, re = new RegExp(exp), pad = ''; do { pad += ch; } while(pad.length < num); return re.exec( (side === 'left') ? (pad + this) : (this + pad) )[0]; }
javascript
{ "resource": "" }
q9859
ImboClient
train
function ImboClient(options, publicKey, privateKey) { // Run a feature check, ensuring all required features are present features.checkFeatures(); // Initialize options var opts = this.options = { hosts: parseUrls(options.hosts || options), publicKey: options.publicKey || publicKey, ...
javascript
{ "resource": "" }
q9860
train
function(file, callback) { if (isBrowser && file instanceof window.File) { // Browser File instance return this.addImageFromBuffer(file, callback); } // File on filesystem. Note: the reason why we need the size of the file // is because of reverse proxies like Va...
javascript
{ "resource": "" }
q9861
train
function(source, callback) { var url = this.getSignedResourceUrl('POST', this.getImagesUrl()), isFile = isBrowser && source instanceof window.File, onComplete = callback.onComplete || callback, onProgress = callback.onProgress || null; request({ method: '...
javascript
{ "resource": "" }
q9862
train
function(url, callback) { if (isBrowser) { // Browser environments can't pipe, so download the file and add it return this.getImageDataFromUrl(url, function(err, data) { if (err) { return callback(err); } this.addImageF...
javascript
{ "resource": "" }
q9863
train
function(callback) { request.get(this.getStatsUrl(), function(err, res, body) { callback(err, body, res); }); return this; }
javascript
{ "resource": "" }
q9864
train
function(callback) { request.get(this.getStatusUrl(), function(err, res, body) { if (err) { return callback(err); } body = body || {}; body.status = res.statusCode; body.date = new Date(body.date); callback(err, body, res)...
javascript
{ "resource": "" }
q9865
train
function(callback) { request.get(this.getUserUrl(), function(err, res, body) { if (body && body.lastModified) { body.lastModified = new Date(body.lastModified); } if (body && !body.user && body.publicKey) { body.user = body.publicKey; ...
javascript
{ "resource": "" }
q9866
train
function(imageIdentifier, callback) { var url = this.getImageUrl(imageIdentifier, { usePrimaryHost: true }), signedUrl = this.getSignedResourceUrl('DELETE', url); request.del(signedUrl, callback); return this; }
javascript
{ "resource": "" }
q9867
train
function(imageIdentifier, callback) { this.headImage(imageIdentifier, function(err, res) { if (err) { return callback(err); } var headers = res.headers, prefix = 'x-imbo-original'; callback(err, { width: parseInt(h...
javascript
{ "resource": "" }
q9868
train
function(imageIdentifier, data, callback, method) { var url = this.getMetadataUrl(imageIdentifier); request({ method: method || 'POST', uri: this.getSignedResourceUrl(method || 'POST', url), json: data, onComplete: function(err, res, body) { ...
javascript
{ "resource": "" }
q9869
train
function(imageIdentifier, callback) { request.get(this.getMetadataUrl(imageIdentifier), function(err, res, body) { callback(err, body, res); }); return this; }
javascript
{ "resource": "" }
q9870
train
function(imageIdentifier, callback) { var url = this.getMetadataUrl(imageIdentifier); request.del(this.getSignedResourceUrl('DELETE', url), callback); return this; }
javascript
{ "resource": "" }
q9871
train
function(query, callback) { if (typeof query === 'function' && !callback) { callback = query; query = null; } // Fetch the response request.get(this.getImagesUrl(query), function(err, res, body) { callback( err, body &&...
javascript
{ "resource": "" }
q9872
train
function(imageIdentifier, options) { if (typeof imageIdentifier !== 'string' || imageIdentifier.length === 0) { throw new Error( '`imageIdentifier` must be a non-empty string, was "' + imageIdentifier + '"' + ' (' + typeof imageIdentifier + ')' ); ...
javascript
{ "resource": "" }
q9873
train
function(options) { return new ImboUrl({ baseUrl: this.options.hosts[0], user: typeof options.user !== 'undefined' ? options.user : this.options.user, publicKey: this.options.publicKey, privateKey: this.options.privateKey, queryString: options.query, ...
javascript
{ "resource": "" }
q9874
train
function(imageIdentifier, callback) { var url = this.getImageUrl(imageIdentifier).setPath('/shorturls'), signed = this.getSignedResourceUrl('DELETE', url); request.del(signed, callback); return this; }
javascript
{ "resource": "" }
q9875
train
function(imageIdentifier, shortUrl, callback) { var id = shortUrl instanceof ShortUrl ? shortUrl.getId() : shortUrl, url = this.getImageUrl(imageIdentifier).setPath('/shorturls/' + id), signed = this.getSignedResourceUrl('DELETE', url); request.del(signed, callback); ret...
javascript
{ "resource": "" }
q9876
train
function(imgPath, callback) { this.getImageChecksum(imgPath, function(err, checksum) { if (err) { return callback(err); } this.imageWithChecksumExists(checksum, callback); }.bind(this)); return this; }
javascript
{ "resource": "" }
q9877
train
function(checksum, callback) { var query = (new ImboQuery()).originalChecksums([checksum]).limit(1); this.getImages(query, function(err, images, search) { if (err) { return callback(err); } var exists = search.hits > 0; callback(err, exist...
javascript
{ "resource": "" }
q9878
train
function(callback) { request.get( this.getResourceUrl({ path: '/groups', user: null }), function onResourceGroupsResponse(err, res, body) { callback( err, body && body.groups, body && body.search, ...
javascript
{ "resource": "" }
q9879
train
function(groupName, callback) { request.get( this.getResourceUrl({ path: '/groups/' + groupName, user: null }), function onResourceGroupResponse(err, res, body) { callback(err, body && body.resources, res); } ); return this; }
javascript
{ "resource": "" }
q9880
train
function(groupName, resources, callback) { this.resourceGroupExists(groupName, function onGroupExistsResponse(err, exists) { if (err) { return callback(err); } if (exists) { return callback(new Error( 'Resource group `' + g...
javascript
{ "resource": "" }
q9881
train
function(groupName, callback) { var url = this.getResourceUrl({ path: '/groups/' + groupName, user: null }); request.del(this.getSignedResourceUrl('DELETE', url), callback); return this; }
javascript
{ "resource": "" }
q9882
train
function(groupName, callback) { request.head( this.getResourceUrl({ path: '/groups/' + groupName, user: null }), get404Handler(callback) ); return this; }
javascript
{ "resource": "" }
q9883
train
function(publicKey, callback) { request.head( this.getResourceUrl({ path: '/keys/' + publicKey, user: null }), get404Handler(callback) ); return this; }
javascript
{ "resource": "" }
q9884
train
function(publicKey, expandGroups, callback) { var qs = ''; if (!callback && typeof expandGroups === 'function') { callback = expandGroups; } else if (expandGroups) { qs = '?expandGroups=1'; } request.get( this.getResourceUrl({ path: '/keys/' +...
javascript
{ "resource": "" }
q9885
train
function(publicKey, aclRuleId, callback) { request.get( this.getResourceUrl({ path: '/keys/' + publicKey + '/access/' + aclRuleId, user: null }), function onAccessControlRulesResponse(err, res, body) { callback(err, body, res); ...
javascript
{ "resource": "" }
q9886
train
function(publicKey, rules, callback) { if (!Array.isArray(rules)) { rules = [rules]; } if (!publicKey) { throw new Error('Public key must be a valid string'); } var url = this.getResourceUrl({ path: '/keys/' + publicKey + '/access', user: null }); ...
javascript
{ "resource": "" }
q9887
train
function(imageUrl, callback) { readers.getContentsFromUrl(imageUrl.toString(), function(err, data) { callback(err, err ? null : data); }); return this; }
javascript
{ "resource": "" }
q9888
train
function(imageIdentifier, usePrimary) { if (usePrimary) { return this.options.hosts[0]; } var dec = imageIdentifier.charCodeAt(imageIdentifier.length - 1); // If this is an old image identifier (32 character hex string), // maintain backwards compatibility i...
javascript
{ "resource": "" }
q9889
train
function(method, url, timestamp) { var data = [method, url, this.options.publicKey, timestamp].join('|'), signature = crypto.sha256(this.options.privateKey, data); return signature; }
javascript
{ "resource": "" }
q9890
train
function(method, url, date) { var timestamp = (date || new Date()).toISOString().replace(/\.\d+Z$/, 'Z'), addPubKey = this.options.user !== this.options.publicKey, qs = url.toString().indexOf('?') > -1 ? '&' : '?', signUrl = addPubKey ? url + qs + 'publicKey=' + this.options....
javascript
{ "resource": "" }
q9891
train
function(options){ var option, o; this.options || (this.options = {}); o = this.options = primish.merge(primish.clone(this.options), options); // add the events as well, if class has events. if ((this.on && this.off)) for (option in o){ if (o.hasOwnProperty(option)){ if (typeof o[opt...
javascript
{ "resource": "" }
q9892
Service
train
function Service(options) { if (!(this instanceof Service)) { return new Service(options); } options = options || {}; debug('New Service: %j', options); // There's no reasonable way to protect this, so we let it be writable with // the understanding that .update is called in the future. TL;DR - Write...
javascript
{ "resource": "" }
q9893
train
function(options) { options = options || {}; var params = [ 'color=' + (options.color || '000000').replace(/^#/, ''), 'width=' + toInt(options.width || 1), 'height=' + toInt(options.height || 1), 'mode=' + (options.mode || 'outbound') ]; ...
javascript
{ "resource": "" }
q9894
train
function(options) { options = options || {}; if (!options.width || !options.height) { throw new Error('width and height must be specified'); } var params = [ 'width=' + toInt(options.width), 'height=' + toInt(options.height) ]; if (o...
javascript
{ "resource": "" }
q9895
train
function(options) { var params = [], opts = options || {}, transform = 'contrast'; if (opts.sharpen) { params.push('sharpen=' + opts.sharpen); } if (params.length) { transform += ':' + params.join(','); } return this.appe...
javascript
{ "resource": "" }
q9896
train
function(options) { var opts = options || {}, mode = opts.mode, x = opts.x, y = opts.y, width = opts.width, height = opts.height; if (!mode && (isNaN(x) || isNaN(y))) { throw new Error('x and y needs to be specified without a crop ...
javascript
{ "resource": "" }
q9897
train
function(options) { var params = []; if (options.width) { params.push('width=' + toInt(options.width)); } if (options.height) { params.push('height=' + toInt(options.height)); } if (!params.length) { throw new Error('width and/or hei...
javascript
{ "resource": "" }
q9898
train
function(options) { if (!options || isNaN(options.angle)) { throw new Error('angle needs to be specified'); } var bg = (options.bg || '000000').replace(/^#/, ''); return this.append('rotate:angle=' + options.angle + ',bg=' + bg); }
javascript
{ "resource": "" }
q9899
train
function(options) { var params = [], opts = options || {}, transform = 'sharpen'; if (opts.preset) { params.push('preset=' + opts.preset); } if (typeof opts.radius !== 'undefined') { params.push('radius=' + opts.radius); } ...
javascript
{ "resource": "" }