_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q10400
train
function (expressServer, settings) { return new Promise((resolve, reject) => { autoloader.run(expressServer, settings).then((success) => {
javascript
{ "resource": "" }
q10401
execute
train
function execute (str, { cwd }) { // command = replace(command, options); // command = prepend(command, options); let args = str.split(' ') const command = args.shift() args = [args.join(' ')] const subprocess
javascript
{ "resource": "" }
q10402
train
function() { var editDataSource = this.getProperty( 'editDataSource' ); var destinationDataSource = this.getProperty( 'destinationDataSource' ); var destinationProperty = this.getProperty( 'destinationProperty' ) || ''; if( !destinationDataSource ) { return; } ...
javascript
{ "resource": "" }
q10403
train
function(capture) { // If compareTo{Page|Viewport} option is set, gets the filepath corresponding // to the capture index (page, capture, viewport): if (options.compareToViewport || options.compareToPage) { var pageReference = options.compareToPage || capture.page.name;
javascript
{ "resource": "" }
q10404
Class
train
function Class(name, superClasses, attributes, references, flexible) { /** The generic class instances Class * @constructor * @param {Object} attr The initial values of the instance */ function ClassInstance(attr) { Object.defineProperties(this, { __jsmf__: {value: elementMeta(ClassInstance)} ...
javascript
{ "resource": "" }
q10405
ClassInstance
train
function ClassInstance(attr) { Object.defineProperties(this, { __jsmf__: {value: elementMeta(ClassInstance)}
javascript
{ "resource": "" }
q10406
getInheritanceChain
train
function getInheritanceChain() { return _(this.superClasses) .reverse()
javascript
{ "resource": "" }
q10407
getAllReferences
train
function getAllReferences() { return _.reduce( this.getInheritanceChain(),
javascript
{ "resource": "" }
q10408
getAllAttributes
train
function getAllAttributes() { return _.reduce( this.getInheritanceChain(),
javascript
{ "resource": "" }
q10409
getAssociated
train
function getAssociated(name) { const path = ['__jsmf__', 'associated'] if (name !== undefined) {
javascript
{ "resource": "" }
q10410
addReferences
train
function addReferences(descriptor) { _.forEach(descriptor, (desc, k) => this.addReference( k, desc.target || desc.type, desc.cardinality, desc.opposite,
javascript
{ "resource": "" }
q10411
addReference
train
function addReference(name, target, sourceCardinality, opposite, oppositeCardinality, associated, errorCallback, oppositeErrorCallback) { this.references[name] = { type: target || Type.JSMFAny , cardinality: Cardinality.check(sourceCardinality) } if (opposite !== ...
javascript
{ "resource": "" }
q10412
removeReference
train
function removeReference(name, opposite) { const ref = this.references[name] _.unset(this.references, name) if (ref.opposite !==
javascript
{ "resource": "" }
q10413
setSuperType
train
function setSuperType(s) { const ss = _.isArray(s)
javascript
{ "resource": "" }
q10414
addAttribute
train
function addAttribute(name, type, mandatory, errorCallback) { this.attributes[name] = { type: Type.normalizeType(type) ,
javascript
{ "resource": "" }
q10415
addAttributes
train
function addAttributes(attrs) { _.forEach(attrs, (v, k) => { if (v.type !== undefined) { this.addAttribute(k, v.type,
javascript
{ "resource": "" }
q10416
setFlexible
train
function setFlexible(b) { this.errorCallback = b ? onError.silent : onError.throw _.forEach(this.references,
javascript
{ "resource": "" }
q10417
ResultSet
train
function ResultSet(conn, query, values, options, rs) { this.query = query; this.metadata = rs.metadata; this.rows = rs.rows;
javascript
{ "resource": "" }
q10418
train
function(client, method, url, payload, query) { // Add query to url if present if (query) { query = querystring.stringify(query); if (query.length > 0) { url += '?' + query; } } // Construct request object var req = request(method.toUpperCase(), url); // Set the http agent for this reques...
javascript
{ "resource": "" }
q10419
train
function (attr, expr, context, data) { var val = this.exprEvaluator(expr, context, data); if (val || typeof val === 'string' || typeof val === 'number') {
javascript
{ "resource": "" }
q10420
train
function (dom) { var html = ''; dom.forEach(function (node) { if (node.type === 'tag') { var tag = node.name; html += '<' + tag; Object.keys(node.attribs).forEach(function (attr) { html += ' ' + a...
javascript
{ "resource": "" }
q10421
train
function (nodes, parent) { var copy = nodes.map(function (node, index) { var clone = {}; //Shallow copy Object.keys(node).forEach(function (prop) { clone[prop] = node[prop]; }); return clone; }); ...
javascript
{ "resource": "" }
q10422
train
function (objectLiteral, callback, scope) { if (objectLiteral) { parseObjectLiteral(objectLiteral).some(function (tuple) {
javascript
{ "resource": "" }
q10423
funcToString
train
function funcToString(func) { var str = func.toString(); return
javascript
{ "resource": "" }
q10424
traverse
train
function traverse(object, visitor) { let child; if (!object) return; let r = visitor.call(null, object); if (r === STOP) return STOP; // stop whole traverse immediately if (r === SKIP_BRANCH) return; // skip going into AST branch for (let i = 0, keys = Object.keys(object); i < keys.length; i++) { let ...
javascript
{ "resource": "" }
q10425
extract
train
function extract(pattern, part) { if (!pattern) throw new Error('missing pattern'); // no match if (!part) return STOP; let term = matchTerm(pattern); if (term) { // if single __any if (term.type === ANY) { if (term.name) { // if __any_foo // get result {foo: astNode} le...
javascript
{ "resource": "" }
q10426
compilePattern
train
function compilePattern(pattern) { // pass estree syntax tree obj if (pattern && pattern.type) return pattern; if (typeof pattern !== 'string') { throw new Error('input pattern is neither a string nor an estree node.'); } let exp = parser(pattern); if (exp.type !== 'Program' || !exp.body) { throw...
javascript
{ "resource": "" }
q10427
tock
train
function tock() { var tockPeriod = process.hrtime(tickTime); var tockPeriodMs = hrtimeAsMs(tockPeriod); process.send({ cmd: 'CLUSTER_PULSE',
javascript
{ "resource": "" }
q10428
train
function( id, text, order, path, hidden, umbel ) { MenuProto.call( this, id, text, order, hidden ); /** * Gets the paths of the menu item. * @type {Array.<string>} */ this.paths = createPathList( path
javascript
{ "resource": "" }
q10429
Ping
train
function Ping(url, driver) { if (!(this instanceof Ping)) { return new Ping(url, driver); } driver = driver || request; this.url = url; this.driver = driver; this.successCodes = SUCCESS; this.started = false; this.validators = []; var self = this; var textCheck = function(err, res, body) { ...
javascript
{ "resource": "" }
q10430
loadEnv
train
function loadEnv(name) { var fullEnvPath = path.resolve(applicationRoot, './configs/' + name); try { debug('Loaded environment: ' + fullEnvPath); fs.statSync(fullEnvPath); dotenv.config({ path:
javascript
{ "resource": "" }
q10431
field
train
function field(x, y) { var ux = 0; var uy = 0; for(var a = 0; a < attractors.length; a++) { var attractor = attractors[a]; var d2 = (x - attractor.x) * (x - attractor.x) + (y - attractor.y) * (y - attractor.y); var d = Math.sqrt(d2); var weight = attractor.weight * Math.exp( -1 * d2 / (attracto...
javascript
{ "resource": "" }
q10432
createNoGoCircleSpecialAttractors
train
function createNoGoCircleSpecialAttractors(x, y, radius, impactDistance, type, direction) { var circleSubDiv = radius * SUBDIVISE_NOGO / 20; for( var i = 0; i < circleSubDiv; i++ ) { var specialAttractor = {}; specialAttractor.x1 = (x + radius * Math.cos(2*Math.PI / circleSubDiv * i)) * pixelRatio; spec...
javascript
{ "resource": "" }
q10433
findClosestPointOnSpecialAttractor
train
function findClosestPointOnSpecialAttractor(x,y) { var nSpecialAttractor = specialAttractors.length; var currentMinDistance = 0; var currentSpecialAttractor; var ox = 0; var oy = 0; for(var a=0; a<nSpecialAttractor; a++) { var specialAttractor = specialAttractors[a]; var closestSegmentPoint = distan...
javascript
{ "resource": "" }
q10434
initPopupForm
train
function initPopupForm(){ var popUpIsAlreadyVisible = $('#ep_email_form_popup').is(":visible"); if(!popUpIsAlreadyVisible){ // if the popup isn't already visible var cookieVal = pad.getPadId() + "email"; if(cookie.getPref(cookieVal) !== "true"){ //
javascript
{ "resource": "" }
q10435
train
function(e){ $('#ep_email_form_popup').submit(function(){ sendEmailToServer('ep_email_form_popup'); return false; }); // Prepare subscription before submit form $('#ep_email_form_popup [name=ep_email_subscribe]').on('click', function(e) { $('#ep_email_form_popup [name=ep...
javascript
{ "resource": "" }
q10436
checkAndSend
train
function checkAndSend(e) { var formName = $(e.currentTarget.parentNode).attr('id'); var email = $('#' + formName + ' [name=ep_email]').val(); if (email && $('#' + formName + ' [name=ep_email_option]').val() == 'subscribe' && !$('#' + formName + ' [name=ep_email_onStart]').is(':checked') && !$('#' + ...
javascript
{ "resource": "" }
q10437
sendEmailToServer
train
function sendEmailToServer(formName){ var email = $('#' + formName + ' [name=ep_email]').val(); var userId = pad.getUserId(); var message = {}; message.type = 'USERINFO_UPDATE'; message.userInfo = {}; message.padId = pad.getPadId(); message.userInfo.email = email; message.userInfo.email_option = $('#' +...
javascript
{ "resource": "" }
q10438
getDataForUserId
train
function getDataForUserId(formName) { var userId = pad.getUserId(); var message = {}; message.type = 'USERINFO_GET'; message.padId = pad.getPadId(); message.userInfo =
javascript
{ "resource": "" }
q10439
showAlreadyRegistered
train
function showAlreadyRegistered(type){ if (type == "malformedEmail") { var msg = window._('ep_email_notifications.msgEmailMalformed'); } else if (type == "alreadyRegistered") { var msg = window._('ep_email_notifications.msgAlreadySubscr'); } else { var msg = window._('ep_email_notifications.msgUnknownE...
javascript
{ "resource": "" }
q10440
resolveBase
train
function resolveBase(app) { const paths = [ { name: 'base', path: path.resolve(cwd, 'node_modules/base') }, { name: 'base-app', path: path.resolve(cwd, 'node_modules/base-app') }, { name: 'assemble-core', path: path.resolve(cwd, 'node_modules/assemble-core') }, { name: 'assemble', path: path...
javascript
{ "resource": "" }
q10441
resolveApp
train
function resolveApp(file) { if (fs.existsSync(file.path)) { const Base = require(file.path); const base = new Base(null, opts); base.define('log', log); if (typeof base.name === 'undefined') { base.name = file.name; } // if this is not an instance
javascript
{ "resource": "" }
q10442
train
function(svg, options) { // the svg element to render charts to this._svg = svg; this._attributes = options || {}; // outer margins this._margin =
javascript
{ "resource": "" }
q10443
allStars
train
function allStars (query) { if (typeof query === 'string') return lookupString(query) else
javascript
{ "resource": "" }
q10444
ParseOfflineRequest
train
function ParseOfflineRequest (requestType, options) { if (!(this instanceof ParseOfflineRequest)) { return new ParseOfflineRequest(requestType, options); } this.requestType = requestType;
javascript
{ "resource": "" }
q10445
requireJslint
train
function requireJslint(jslintFileName) { /*jslint stupid: true */// JSLint doesn't like "*Sync" functions, but in this require-like function async would be overkill var jslintCode = bufferToScript( fs.readFileSync( path.join(__dirname, jslintFileName) )
javascript
{ "resource": "" }
q10446
unpckItem
train
function unpckItem(reader) { const bitSet0 = pck.readU8(reader); const time = pck.readU32(reader); const descendants = pck.readUVar(reader); const id = pck.readUVar(reader); const score = pck.readUVar(reader); const by =
javascript
{ "resource": "" }
q10447
AccessContext
train
function AccessContext(context, app) { if (!(this instanceof AccessContext)) { return new AccessContext(context, app); } context = context || {}; this.app = app; this.principals = context.principals || []; var model = context.model; model = ('string' === typeof model) ? app.model(mo...
javascript
{ "resource": "" }
q10448
Principal
train
function Principal(type, id, name) { if (!(this instanceof Principal)) { return new Principal(type, id, name); }
javascript
{ "resource": "" }
q10449
AccessRequest
train
function AccessRequest(model, property, accessType, permission, methodNames) { if (!(this instanceof AccessRequest)) { return new AccessRequest(model, property, accessType, permission, methodNames); } if (arguments.length === 1 && typeof model === 'object') { // The argument is an object tha...
javascript
{ "resource": "" }
q10450
ChangeRecord
train
function ChangeRecord(object, type, name, oldValue) { this.object = object; this.type = type;
javascript
{ "resource": "" }
q10451
Splice
train
function Splice(object, index, removed, addedCount) { ChangeRecord.call(this, object, 'splice', String(index)); this.index = index;
javascript
{ "resource": "" }
q10452
diffBasic
train
function diffBasic(value, oldValue) { if (value && oldValue && typeof value === 'object' && typeof oldValue === 'object') { // Allow dates and Number/String objects to be compared var valueValue = value.valueOf(); var oldValueValue = oldValue.valueOf(); // Allow dates and Number/String obje...
javascript
{ "resource": "" }
q10453
sharedPrefix
train
function sharedPrefix(current, old, searchLength) { for (var i = 0; i < searchLength; i++) { if
javascript
{ "resource": "" }
q10454
readControls
train
function readControls( controlPath, filingCabinet ) { logger.showInfo( '*** Reading controls...' ); // Initialize the store - engine controls. logger.showInfo( 'Engine controls:' ); getControls( '/node_modules/md-site-engine/controls', '',
javascript
{ "resource": "" }
q10455
stopSeries
train
function stopSeries(err) { if(err instanceof Error || (typeof err ===
javascript
{ "resource": "" }
q10456
train
function() { var editDataSource = this.getProperty( 'editDataSource' ); var destinationDataSource = this.getProperty( 'destinationDataSource' ); var destinationProperty = this.getProperty( 'destinationProperty' ); if( this._isObjectDataSource( editDataSource ) ) { var edited...
javascript
{ "resource": "" }
q10457
getContent
train
function getContent( contentFile, source ) { // Determine the path. var contentPath = path.join( process.cwd(), contentFile ); // Get the file content. var html = fs.readFileSync( contentPath, { encoding: 'utf-8' } ); // Find tokens. var re = /(\{\{\s*[=#.]?[\w-\/]+\s*}})/g; var tokens = [ ]; var j =...
javascript
{ "resource": "" }
q10458
train
function(uri, _method){ if (!(this instanceof Verity)) { return new Verity(uri, _method); } this.uri = urlgrey(uri || 'http://localhost:80'); this._method = _method || 'GET'; this._body = ''; this.cookieJar = request.jar(); this.client = request.defaults({ timeout:3000, jar: this.cookieJar }...
javascript
{ "resource": "" }
q10459
type
train
function type(filename, opts) { opts = opts || {}; if (opts.parse && typeof opts.parse
javascript
{ "resource": "" }
q10460
startServer
train
function startServer() { var defer = q.defer(); var serverConfig = { server: { baseDir: wpath, directory: true }, startPath: 'docs/index.html', // browser: "google chrome",
javascript
{ "resource": "" }
q10461
ChunkedStreamManager_requestRange
train
function ChunkedStreamManager_requestRange( begin, end, callback) { end = Math.min(end, this.length); var beginChunk = this.getBeginChunk(begin);
javascript
{ "resource": "" }
q10462
ChunkedStreamManager_groupChunks
train
function ChunkedStreamManager_groupChunks(chunks) { var groupedChunks = []; var beginChunk = -1; var prevChunk = -1; for (var i = 0; i < chunks.length; ++i) { var chunk = chunks[i]; if (beginChunk < 0) { beginChunk = chunk; } if (prevChunk >= 0 && prev...
javascript
{ "resource": "" }
q10463
PDFDocument_checkHeader
train
function PDFDocument_checkHeader() { var stream = this.stream; stream.reset(); if (find(stream, '%PDF-', 1024)) { // Found the header, trim off any garbage before it. stream.moveStart(); // Reading file format version var MAX_VERSION_LENGTH = 12; var version = '...
javascript
{ "resource": "" }
q10464
Dict
train
function Dict(xref) { // Map should only be used internally, use functions below to access. this.map = Object.create(null); this.xref = xref; this.objId = null;
javascript
{ "resource": "" }
q10465
Dict_get
train
function Dict_get(key1, key2, key3) { var value; var xref = this.xref; if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') { return xref ? xref.fetchIfRef(value) : value; } if (typeof (value = this.map[key2]) !== 'undefi...
javascript
{ "resource": "" }
q10466
Dict_getAll
train
function Dict_getAll() { var all = Object.create(null); var queue = null; var key, obj; for (key in this.map) { obj = this.get(key); if (obj instanceof Dict) { if (isRecursionAllowedFor(obj)) { (queue || (queue = [])).push({target: all, key: key, obj: obj});...
javascript
{ "resource": "" }
q10467
readToken
train
function readToken(data, offset) { var token = '', ch = data[offset]; while (ch !== 13 && ch !== 10) { if (++offset >= data.length) { break; }
javascript
{ "resource": "" }
q10468
convertToRgb
train
function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) { // XXX: Lab input is in the range of [0, 100], [amin, amax], [bmin, bmax] // not the usual [0, 1]. If a command like setFillColor is used the src // values will already be within the correct range. However, if we are // converting an ...
javascript
{ "resource": "" }
q10469
getTransfers
train
function getTransfers(queue) { var transfers = []; var fnArray = queue.fnArray, argsArray = queue.argsArray; for (var i = 0, ii = queue.length; i < ii; i++) { switch (fnArray[i]) { case OPS.paintInlineImageXObject: case OPS.paintInlineImageXObjectGroup: case OPS.paintImageMaskX...
javascript
{ "resource": "" }
q10470
isProblematicUnicodeLocation
train
function isProblematicUnicodeLocation(code) { if (code <= 0x1F) { // Control chars return true; } if (code >= 0x80 && code <= 0x9F) { // Control chars return true; } if ((code >= 0x2000 && code <= 0x200F) || // General punctuation chars (code >= 0x2028 && code <= 0x202F) || ...
javascript
{ "resource": "" }
q10471
type1FontGlyphMapping
train
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) { var charCodeToGlyphId = Object.create(null); var glyphId, charCode, baseEncoding; if (properties.baseEncodingName) { // If a valid base encoding name was used, the mapping is initialized with // that. baseEncoding = Encodings[p...
javascript
{ "resource": "" }
q10472
Type1Font
train
function Type1Font(name, file, properties) { // Some bad generators embed pfb file as is, we have to strip 6-byte headers. // Also, length1 and length2 might be off by 6 bytes as well. // http://www.math.ubc.ca/~cass/piscript/type1.pdf var PFB_HEADER_SIZE = 6; var headerBlockLength = properties.length1; var...
javascript
{ "resource": "" }
q10473
CFFDict_setByKey
train
function CFFDict_setByKey(key, value) { if (!(key in this.keyToNameMap)) { return false; } // ignore empty values if (value.length === 0) { return true; } var type = this.types[key]; // remove the array wrapping these types of values
javascript
{ "resource": "" }
q10474
handleImageData
train
function handleImageData(handler, xref, res, image) { if (image instanceof JpegStream && image.isNativelyDecodable(xref, res)) { // For natively supported jpegs send them to the main thread for decoding. var dict = image.dict; var colorSpace = dict.get('ColorSpace', 'CS'); colorSpace = Color...
javascript
{ "resource": "" }
q10475
formatName
train
function formatName(input, noCamelCase){ input = input.replace(/^-+/, ""); // Convert kebab-case to camelCase
javascript
{ "resource": "" }
q10476
match
train
function match(input, patterns = []){ if(!patterns || 0 === patterns.length) return false; input = String(input); patterns = arrayify(patterns).filter(Boolean); for(const pattern of patterns) if((pattern ===
javascript
{ "resource": "" }
q10477
uniqueStrings
train
function uniqueStrings(input){ const output = {}; for(let i = 0, l = input.length; i < l; ++i)
javascript
{ "resource": "" }
q10478
unstringify
train
function unstringify(input){ input = String(input || ""); const tokens = []; const {length} = input; let quoteChar = ""; // Quote-type enclosing current region let tokenData = ""; // Characters currently being collected let isEscaped = false; // Flag identifying an escape sequence for(let i = 0; i...
javascript
{ "resource": "" }
q10479
autoOpts
train
function autoOpts(input, config = {}){ const opts = new Object(null); const argv = []; let argvEnd; // Bail early if passed a blank string if(!input) return opts; // Stop parsing options after a double-dash const stopAt = input.indexOf("--"); if(stopAt !== -1){ argvEnd = input.slice(stopAt + 1); input =...
javascript
{ "resource": "" }
q10480
resolveDuplicate
train
function resolveDuplicate(option, name, value){ switch(duplicates){ // Use the first value (or set of values); discard any following duplicates case "use-first": return result.options[name]; // Use the last value (or set of values); discard any preceding duplicates. Default. case "use-last": ...
javascript
{ "resource": "" }
q10481
setValue
train
function setValue(option, value){ // Assign the value only to the option name it matched if(noAliasPropagation){ let name = option.lastMatchedName; // Special alternative: // In lieu of using the matched option name, use the first --long-name only if("first-only" === noAliasPropagation) name ...
javascript
{ "resource": "" }
q10482
wrapItUp
train
function wrapItUp(){ let optValue = currentOption.values; // Don't store solitary values in an array. Store them directly as strings if(1 === currentOption.arity && !currentOption.variadic)
javascript
{ "resource": "" }
q10483
flip
train
function flip(input){ input = input.reverse(); // Flip any options back into the right order for(let i = 0, l = input.length; i < l; ++i){ const arg = input[i]; const opt = shortNames[arg] || longNames[arg]; if(opt){ const from = Math.max(0, i - opt.arity); const to
javascript
{ "resource": "" }
q10484
readReferences
train
function readReferences( componentPath, referenceFile, filingCabinet ) { logger.showInfo( '*** Reading references...' ); // Initialize the
javascript
{ "resource": "" }
q10485
getReferences
train
function getReferences( componentDir, level, levelPath, referenceFile, referenceDrawer ) { // Read directory items. var componentPath = path.join( process.cwd(), componentDir ); var items = fs.readdirSync( componentPath ); items.forEach( function ( item ) { var itemPath = path.join( componentDir, item );...
javascript
{ "resource": "" }
q10486
train
function() { this.addController(jsCow.res.controller.buttongroup); this.addModel(jsCow.res.model.buttongroup);
javascript
{ "resource": "" }
q10487
fetchAuthors
train
function fetchAuthors (forPackages, opts) { opts = normalizeOpts(opts) // start with npmUser and email from registry return fetchRegistry(forPackages, {}, opts) .then(persons => { // reduce duplicates and add pre-known aliases return reduceDuplicates(persons, opts) }) .then(persons => { ...
javascript
{ "resource": "" }
q10488
train
function (color, func) { exports[color] = function(str) { return func.apply(str);
javascript
{ "resource": "" }
q10489
create
train
function create(r, g, b, a) { return [r || 0, g || 0, b || 0,
javascript
{ "resource": "" }
q10490
setRGB
train
function setRGB(color, r, g, b, a) { color[0] = r; color[1] =
javascript
{ "resource": "" }
q10491
fromHSV
train
function fromHSV(h, s, v, a) { var color = create();
javascript
{ "resource": "" }
q10492
setHSV
train
function setHSV(color, h, s, v, a) { a = a || 1; var i = Math.floor(h * 6); var f = h * 6 - i; var p = v * (1 - s); var q = v * (1 - f * s); var t = v * (1 - (1 - f) * s); switch (i % 6) { case 0: color[0] = v; color[1] = t; color[2] = p; break; case 1: color[0] = q; color[1] = v; color[2] = p; ...
javascript
{ "resource": "" }
q10493
fromHSL
train
function fromHSL(h, s, l, a) { var color
javascript
{ "resource": "" }
q10494
setHSL
train
function setHSL(color, h, s, l, a) { a = a || 1; function hue2rgb(p, q, t) { if (t < 0) { t += 1; } if (t > 1) { t -= 1; } if (t < 1/6) { return p + (q - p) * 6 * t; } if (t < 1/2) { return q; } if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; } return p; }...
javascript
{ "resource": "" }
q10495
getHex
train
function getHex(color) { var c = [ color[0], color[1], color[2] ].map(function(val) { return Math.floor(val * 255); }); return "#" + ((c[2] | c[1]
javascript
{ "resource": "" }
q10496
fromXYZ
train
function fromXYZ(x, y, z) { var color = create();
javascript
{ "resource": "" }
q10497
setXYZ
train
function setXYZ(color, x, y, z) { var r = x * 3.2406 + y * -1.5372 + z * -0.4986; var g = x * -0.9689 + y * 1.8758 + z * 0.0415;
javascript
{ "resource": "" }
q10498
getXYZ
train
function getXYZ(color) { var r = toXYZValue(color[0]); var g = toXYZValue(color[1]); var b = toXYZValue(color[2]); return [ r * 0.4124 + g * 0.3576 + b * 0.1805, r *
javascript
{ "resource": "" }
q10499
fromLab
train
function fromLab(l, a, b) { var color = create();
javascript
{ "resource": "" }