repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
emberjs/ember-inspector
skeletons/web-extension/content-script.js
listenToEmberDebugPort
function listenToEmberDebugPort(emberDebugPort) { // listen for messages from EmberDebug, and pass them on to the background-script emberDebugPort.addEventListener('message', function(event) { chrome.runtime.sendMessage(event.data); }); // listen for messages from the EmberInspector, and pass the...
javascript
function listenToEmberDebugPort(emberDebugPort) { // listen for messages from EmberDebug, and pass them on to the background-script emberDebugPort.addEventListener('message', function(event) { chrome.runtime.sendMessage(event.data); }); // listen for messages from the EmberInspector, and pass the...
[ "function", "listenToEmberDebugPort", "(", "emberDebugPort", ")", "{", "// listen for messages from EmberDebug, and pass them on to the background-script", "emberDebugPort", ".", "addEventListener", "(", "'message'", ",", "function", "(", "event", ")", "{", "chrome", ".", "ru...
Listen for messages from EmberDebug. @param {Object} emberDebugPort
[ "Listen", "for", "messages", "from", "EmberDebug", "." ]
2237dc1b4818e31a856f3348f35305b10f42f60a
https://github.com/emberjs/ember-inspector/blob/2237dc1b4818e31a856f3348f35305b10f42f60a/skeletons/web-extension/content-script.js#L40-L55
train
emberjs/ember-inspector
ember_debug/vendor/startup-wrapper.js
onApplicationStart
function onApplicationStart(callback) { if (typeof Ember === 'undefined') { return; } const adapterInstance = requireModule('ember-debug/adapters/' + currentAdapter)['default'].create(); adapterInstance.onMessageReceived(function(message) { if (message.type === 'app-picker-loaded') { ...
javascript
function onApplicationStart(callback) { if (typeof Ember === 'undefined') { return; } const adapterInstance = requireModule('ember-debug/adapters/' + currentAdapter)['default'].create(); adapterInstance.onMessageReceived(function(message) { if (message.type === 'app-picker-loaded') { ...
[ "function", "onApplicationStart", "(", "callback", ")", "{", "if", "(", "typeof", "Ember", "===", "'undefined'", ")", "{", "return", ";", "}", "const", "adapterInstance", "=", "requireModule", "(", "'ember-debug/adapters/'", "+", "currentAdapter", ")", "[", "'de...
There's probably a better way to determine when the application starts but this definitely works
[ "There", "s", "probably", "a", "better", "way", "to", "determine", "when", "the", "application", "starts", "but", "this", "definitely", "works" ]
2237dc1b4818e31a856f3348f35305b10f42f60a
https://github.com/emberjs/ember-inspector/blob/2237dc1b4818e31a856f3348f35305b10f42f60a/ember_debug/vendor/startup-wrapper.js#L131-L177
train
emberjs/ember-inspector
ember_debug/vendor/startup-wrapper.js
getApplications
function getApplications() { var namespaces = Ember.A(Ember.Namespace.NAMESPACES); var apps = namespaces.filter(function(namespace) { return namespace instanceof Ember.Application; }); return apps.map(function(app) { // Add applicationId and applicationName to the app var application...
javascript
function getApplications() { var namespaces = Ember.A(Ember.Namespace.NAMESPACES); var apps = namespaces.filter(function(namespace) { return namespace instanceof Ember.Application; }); return apps.map(function(app) { // Add applicationId and applicationName to the app var application...
[ "function", "getApplications", "(", ")", "{", "var", "namespaces", "=", "Ember", ".", "A", "(", "Ember", ".", "Namespace", ".", "NAMESPACES", ")", ";", "var", "apps", "=", "namespaces", ".", "filter", "(", "function", "(", "namespace", ")", "{", "return"...
Get all the Ember.Application instances from Ember.Namespace.NAMESPACES and add our own applicationId and applicationName to them @return {*}
[ "Get", "all", "the", "Ember", ".", "Application", "instances", "from", "Ember", ".", "Namespace", ".", "NAMESPACES", "and", "add", "our", "own", "applicationId", "and", "applicationName", "to", "them" ]
2237dc1b4818e31a856f3348f35305b10f42f60a
https://github.com/emberjs/ember-inspector/blob/2237dc1b4818e31a856f3348f35305b10f42f60a/ember_debug/vendor/startup-wrapper.js#L200-L219
train
emberjs/ember-inspector
ember_debug/vendor/startup-wrapper.js
sendVersionMiss
function sendVersionMiss() { var adapter = requireModule('ember-debug/adapters/' + currentAdapter)['default'].create(); adapter.onMessageReceived(function(message) { if (message.type === 'check-version') { sendVersionMismatch(); } }); sendVersionMismatch(); function sendVersionM...
javascript
function sendVersionMiss() { var adapter = requireModule('ember-debug/adapters/' + currentAdapter)['default'].create(); adapter.onMessageReceived(function(message) { if (message.type === 'check-version') { sendVersionMismatch(); } }); sendVersionMismatch(); function sendVersionM...
[ "function", "sendVersionMiss", "(", ")", "{", "var", "adapter", "=", "requireModule", "(", "'ember-debug/adapters/'", "+", "currentAdapter", ")", "[", "'default'", "]", ".", "create", "(", ")", ";", "adapter", ".", "onMessageReceived", "(", "function", "(", "m...
This function is called if the app's Ember version is not supported by this version of the inspector. It sends a message to the inspector app to redirect to an inspector version that supports this Ember version.
[ "This", "function", "is", "called", "if", "the", "app", "s", "Ember", "version", "is", "not", "supported", "by", "this", "version", "of", "the", "inspector", "." ]
2237dc1b4818e31a856f3348f35305b10f42f60a
https://github.com/emberjs/ember-inspector/blob/2237dc1b4818e31a856f3348f35305b10f42f60a/ember_debug/vendor/startup-wrapper.js#L228-L244
train
emberjs/ember-inspector
app/adapters/basic.js
compareVersion
function compareVersion(version1, version2) { version1 = cleanupVersion(version1).split('.'); version2 = cleanupVersion(version2).split('.'); for (let i = 0; i < 3; i++) { let compared = compare(+version1[i], +version2[i]); if (compared !== 0) { return compared; } } return 0; }
javascript
function compareVersion(version1, version2) { version1 = cleanupVersion(version1).split('.'); version2 = cleanupVersion(version2).split('.'); for (let i = 0; i < 3; i++) { let compared = compare(+version1[i], +version2[i]); if (compared !== 0) { return compared; } } return 0; }
[ "function", "compareVersion", "(", "version1", ",", "version2", ")", "{", "version1", "=", "cleanupVersion", "(", "version1", ")", ".", "split", "(", "'.'", ")", ";", "version2", "=", "cleanupVersion", "(", "version2", ")", ".", "split", "(", "'.'", ")", ...
Compares two Ember versions. Returns: `-1` if version < version 0 if version1 == version2 1 if version1 > version2 @param {String} version1 @param {String} version2 @return {Boolean} result of the comparison
[ "Compares", "two", "Ember", "versions", "." ]
2237dc1b4818e31a856f3348f35305b10f42f60a
https://github.com/emberjs/ember-inspector/blob/2237dc1b4818e31a856f3348f35305b10f42f60a/app/adapters/basic.js#L119-L129
train
mtth/avsc
etc/browser/avsc-types.js
parse
function parse(any, opts) { var schema; if (typeof any == 'string') { try { schema = JSON.parse(any); } catch (err) { schema = any; } } else { schema = any; } return types.Type.forSchema(schema, opts); }
javascript
function parse(any, opts) { var schema; if (typeof any == 'string') { try { schema = JSON.parse(any); } catch (err) { schema = any; } } else { schema = any; } return types.Type.forSchema(schema, opts); }
[ "function", "parse", "(", "any", ",", "opts", ")", "{", "var", "schema", ";", "if", "(", "typeof", "any", "==", "'string'", ")", "{", "try", "{", "schema", "=", "JSON", ".", "parse", "(", "any", ")", ";", "}", "catch", "(", "err", ")", "{", "sc...
Basic parse method, only supporting JSON parsing.
[ "Basic", "parse", "method", "only", "supporting", "JSON", "parsing", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/browser/avsc-types.js#L15-L27
train
mtth/avsc
lib/utils.js
bufferFrom
function bufferFrom(data, enc) { if (typeof Buffer.from == 'function') { return Buffer.from(data, enc); } else { return new Buffer(data, enc); } }
javascript
function bufferFrom(data, enc) { if (typeof Buffer.from == 'function') { return Buffer.from(data, enc); } else { return new Buffer(data, enc); } }
[ "function", "bufferFrom", "(", "data", ",", "enc", ")", "{", "if", "(", "typeof", "Buffer", ".", "from", "==", "'function'", ")", "{", "return", "Buffer", ".", "from", "(", "data", ",", "enc", ")", ";", "}", "else", "{", "return", "new", "Buffer", ...
Create a new buffer with the input contents. @param data {Array|String} The buffer's data. @param enc {String} Encoding, used if data is a string.
[ "Create", "a", "new", "buffer", "with", "the", "input", "contents", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L35-L41
train
mtth/avsc
lib/utils.js
getOption
function getOption(opts, key, def) { var value = opts[key]; return value === undefined ? def : value; }
javascript
function getOption(opts, key, def) { var value = opts[key]; return value === undefined ? def : value; }
[ "function", "getOption", "(", "opts", ",", "key", ",", "def", ")", "{", "var", "value", "=", "opts", "[", "key", "]", ";", "return", "value", "===", "undefined", "?", "def", ":", "value", ";", "}" ]
Get option or default if undefined. @param opts {Object} Options. @param key {String} Name of the option. @param def {...} Default value. This is useful mostly for true-ish defaults and false-ish values (where the usual `||` idiom breaks down).
[ "Get", "option", "or", "default", "if", "undefined", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L68-L71
train
mtth/avsc
lib/utils.js
getHash
function getHash(str, algorithm) { algorithm = algorithm || 'md5'; var hash = crypto.createHash(algorithm); hash.end(str); return hash.read(); }
javascript
function getHash(str, algorithm) { algorithm = algorithm || 'md5'; var hash = crypto.createHash(algorithm); hash.end(str); return hash.read(); }
[ "function", "getHash", "(", "str", ",", "algorithm", ")", "{", "algorithm", "=", "algorithm", "||", "'md5'", ";", "var", "hash", "=", "crypto", ".", "createHash", "(", "algorithm", ")", ";", "hash", ".", "end", "(", "str", ")", ";", "return", "hash", ...
Compute a string's hash. @param str {String} The string to hash. @param algorithm {String} The algorithm used. Defaults to MD5.
[ "Compute", "a", "string", "s", "hash", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L79-L84
train
mtth/avsc
lib/utils.js
singleIndexOf
function singleIndexOf(arr, v) { var pos = -1; var i, l; if (!arr) { return -1; } for (i = 0, l = arr.length; i < l; i++) { if (arr[i] === v) { if (pos >= 0) { return -2; } pos = i; } } return pos; }
javascript
function singleIndexOf(arr, v) { var pos = -1; var i, l; if (!arr) { return -1; } for (i = 0, l = arr.length; i < l; i++) { if (arr[i] === v) { if (pos >= 0) { return -2; } pos = i; } } return pos; }
[ "function", "singleIndexOf", "(", "arr", ",", "v", ")", "{", "var", "pos", "=", "-", "1", ";", "var", "i", ",", "l", ";", "if", "(", "!", "arr", ")", "{", "return", "-", "1", ";", "}", "for", "(", "i", "=", "0", ",", "l", "=", "arr", ".",...
Find index of value in array. @param arr {Array} Can also be a false-ish value. @param v {Object} Value to find. Returns -1 if not found, -2 if found multiple times.
[ "Find", "index", "of", "value", "in", "array", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L94-L109
train
mtth/avsc
lib/utils.js
toMap
function toMap(arr, fn) { var obj = {}; var i, elem; for (i = 0; i < arr.length; i++) { elem = arr[i]; obj[fn(elem)] = elem; } return obj; }
javascript
function toMap(arr, fn) { var obj = {}; var i, elem; for (i = 0; i < arr.length; i++) { elem = arr[i]; obj[fn(elem)] = elem; } return obj; }
[ "function", "toMap", "(", "arr", ",", "fn", ")", "{", "var", "obj", "=", "{", "}", ";", "var", "i", ",", "elem", ";", "for", "(", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "elem", "=", "arr", "[", "i", ...
Convert array to map. @param arr {Array} Elements. @param fn {Function} Function returning an element's key.
[ "Convert", "array", "to", "map", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L117-L125
train
mtth/avsc
lib/utils.js
hasDuplicates
function hasDuplicates(arr, fn) { var obj = {}; var i, l, elem; for (i = 0, l = arr.length; i < l; i++) { elem = arr[i]; if (fn) { elem = fn(elem); } if (obj[elem]) { return true; } obj[elem] = true; } return false; }
javascript
function hasDuplicates(arr, fn) { var obj = {}; var i, l, elem; for (i = 0, l = arr.length; i < l; i++) { elem = arr[i]; if (fn) { elem = fn(elem); } if (obj[elem]) { return true; } obj[elem] = true; } return false; }
[ "function", "hasDuplicates", "(", "arr", ",", "fn", ")", "{", "var", "obj", "=", "{", "}", ";", "var", "i", ",", "l", ",", "elem", ";", "for", "(", "i", "=", "0", ",", "l", "=", "arr", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")...
Check whether an array has duplicates. @param arr {Array} The array. @param fn {Function} Optional function to apply to each element.
[ "Check", "whether", "an", "array", "has", "duplicates", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L142-L156
train
mtth/avsc
lib/utils.js
copyOwnProperties
function copyOwnProperties(src, dst, overwrite) { var names = Object.getOwnPropertyNames(src); var i, l, name; for (i = 0, l = names.length; i < l; i++) { name = names[i]; if (!dst.hasOwnProperty(name) || overwrite) { var descriptor = Object.getOwnPropertyDescriptor(src, name); Object.definePr...
javascript
function copyOwnProperties(src, dst, overwrite) { var names = Object.getOwnPropertyNames(src); var i, l, name; for (i = 0, l = names.length; i < l; i++) { name = names[i]; if (!dst.hasOwnProperty(name) || overwrite) { var descriptor = Object.getOwnPropertyDescriptor(src, name); Object.definePr...
[ "function", "copyOwnProperties", "(", "src", ",", "dst", ",", "overwrite", ")", "{", "var", "names", "=", "Object", ".", "getOwnPropertyNames", "(", "src", ")", ";", "var", "i", ",", "l", ",", "name", ";", "for", "(", "i", "=", "0", ",", "l", "=", ...
Copy properties from one object to another. @param src {Object} The source object. @param dst {Object} The destination object. @param overwrite {Boolean} Whether to overwrite existing destination properties. Defaults to false.
[ "Copy", "properties", "from", "one", "object", "to", "another", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L166-L177
train
mtth/avsc
lib/utils.js
addDeprecatedGetters
function addDeprecatedGetters(obj, props) { var proto = obj.prototype; var i, l, prop, getter; for (i = 0, l = props.length; i < l; i++) { prop = props[i]; getter = 'get' + capitalize(prop); proto[getter] = util.deprecate( createGetter(prop), 'use `.' + prop + '` instead of `.' + getter + ...
javascript
function addDeprecatedGetters(obj, props) { var proto = obj.prototype; var i, l, prop, getter; for (i = 0, l = props.length; i < l; i++) { prop = props[i]; getter = 'get' + capitalize(prop); proto[getter] = util.deprecate( createGetter(prop), 'use `.' + prop + '` instead of `.' + getter + ...
[ "function", "addDeprecatedGetters", "(", "obj", ",", "props", ")", "{", "var", "proto", "=", "obj", ".", "prototype", ";", "var", "i", ",", "l", ",", "prop", ",", "getter", ";", "for", "(", "i", "=", "0", ",", "l", "=", "props", ".", "length", ";...
Batch-deprecate "getters" from an object's prototype.
[ "Batch", "-", "deprecate", "getters", "from", "an", "object", "s", "prototype", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L239-L259
train
mtth/avsc
lib/utils.js
Lcg
function Lcg(seed) { var a = 1103515245; var c = 12345; var m = Math.pow(2, 31); var state = Math.floor(seed || Math.random() * (m - 1)); this._max = m; this._nextInt = function () { return state = (a * state + c) % m; }; }
javascript
function Lcg(seed) { var a = 1103515245; var c = 12345; var m = Math.pow(2, 31); var state = Math.floor(seed || Math.random() * (m - 1)); this._max = m; this._nextInt = function () { return state = (a * state + c) % m; }; }
[ "function", "Lcg", "(", "seed", ")", "{", "var", "a", "=", "1103515245", ";", "var", "c", "=", "12345", ";", "var", "m", "=", "Math", ".", "pow", "(", "2", ",", "31", ")", ";", "var", "state", "=", "Math", ".", "floor", "(", "seed", "||", "Ma...
Generator of random things. Inspired by: http://stackoverflow.com/a/424445/1062617
[ "Generator", "of", "random", "things", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/utils.js#L289-L297
train
mtth/avsc
lib/index.js
parse
function parse(any, opts) { var schemaOrProtocol = specs.read(any); return schemaOrProtocol.protocol ? services.Service.forProtocol(schemaOrProtocol, opts) : types.Type.forSchema(schemaOrProtocol, opts); }
javascript
function parse(any, opts) { var schemaOrProtocol = specs.read(any); return schemaOrProtocol.protocol ? services.Service.forProtocol(schemaOrProtocol, opts) : types.Type.forSchema(schemaOrProtocol, opts); }
[ "function", "parse", "(", "any", ",", "opts", ")", "{", "var", "schemaOrProtocol", "=", "specs", ".", "read", "(", "any", ")", ";", "return", "schemaOrProtocol", ".", "protocol", "?", "services", ".", "Service", ".", "forProtocol", "(", "schemaOrProtocol", ...
Parse a schema and return the corresponding type or service.
[ "Parse", "a", "schema", "and", "return", "the", "corresponding", "type", "or", "service", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/index.js#L22-L27
train
mtth/avsc
lib/index.js
createFileDecoder
function createFileDecoder(path, opts) { return fs.createReadStream(path) .pipe(new containers.streams.BlockDecoder(opts)); }
javascript
function createFileDecoder(path, opts) { return fs.createReadStream(path) .pipe(new containers.streams.BlockDecoder(opts)); }
[ "function", "createFileDecoder", "(", "path", ",", "opts", ")", "{", "return", "fs", ".", "createReadStream", "(", "path", ")", ".", "pipe", "(", "new", "containers", ".", "streams", ".", "BlockDecoder", "(", "opts", ")", ")", ";", "}" ]
Readable stream of records from a local Avro file.
[ "Readable", "stream", "of", "records", "from", "a", "local", "Avro", "file", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/index.js#L74-L77
train
mtth/avsc
lib/index.js
createFileEncoder
function createFileEncoder(path, schema, opts) { var encoder = new containers.streams.BlockEncoder(schema, opts); encoder.pipe(fs.createWriteStream(path, {defaultEncoding: 'binary'})); return encoder; }
javascript
function createFileEncoder(path, schema, opts) { var encoder = new containers.streams.BlockEncoder(schema, opts); encoder.pipe(fs.createWriteStream(path, {defaultEncoding: 'binary'})); return encoder; }
[ "function", "createFileEncoder", "(", "path", ",", "schema", ",", "opts", ")", "{", "var", "encoder", "=", "new", "containers", ".", "streams", ".", "BlockEncoder", "(", "schema", ",", "opts", ")", ";", "encoder", ".", "pipe", "(", "fs", ".", "createWrit...
Writable stream of records to a local Avro file.
[ "Writable", "stream", "of", "records", "to", "a", "local", "Avro", "file", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/index.js#L80-L84
train
mtth/avsc
lib/types.js
FixedType
function FixedType(schema, opts) { Type.call(this, schema, opts); if (schema.size !== (schema.size | 0) || schema.size < 1) { throw new Error(f('invalid %s size', this.branchName)); } this.size = schema.size | 0; this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
javascript
function FixedType(schema, opts) { Type.call(this, schema, opts); if (schema.size !== (schema.size | 0) || schema.size < 1) { throw new Error(f('invalid %s size', this.branchName)); } this.size = schema.size | 0; this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
[ "function", "FixedType", "(", "schema", ",", "opts", ")", "{", "Type", ".", "call", "(", "this", ",", "schema", ",", "opts", ")", ";", "if", "(", "schema", ".", "size", "!==", "(", "schema", ".", "size", "|", "0", ")", "||", "schema", ".", "size"...
Avro fixed type. Represented simply as a `Buffer`.
[ "Avro", "fixed", "type", ".", "Represented", "simply", "as", "a", "Buffer", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L1704-L1712
train
mtth/avsc
lib/types.js
MapType
function MapType(schema, opts) { Type.call(this); if (!schema.values) { throw new Error(f('missing map values: %j', schema)); } this.valuesType = Type.forSchema(schema.values, opts); this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
javascript
function MapType(schema, opts) { Type.call(this); if (!schema.values) { throw new Error(f('missing map values: %j', schema)); } this.valuesType = Type.forSchema(schema.values, opts); this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
[ "function", "MapType", "(", "schema", ",", "opts", ")", "{", "Type", ".", "call", "(", "this", ")", ";", "if", "(", "!", "schema", ".", "values", ")", "{", "throw", "new", "Error", "(", "f", "(", "'missing map values: %j'", ",", "schema", ")", ")", ...
Avro map. Represented as vanilla objects.
[ "Avro", "map", ".", "Represented", "as", "vanilla", "objects", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L1768-L1776
train
mtth/avsc
lib/types.js
ArrayType
function ArrayType(schema, opts) { Type.call(this); if (!schema.items) { throw new Error(f('missing array items: %j', schema)); } this.itemsType = Type.forSchema(schema.items, opts); this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
javascript
function ArrayType(schema, opts) { Type.call(this); if (!schema.items) { throw new Error(f('missing array items: %j', schema)); } this.itemsType = Type.forSchema(schema.items, opts); this._branchConstructor = this._createBranchConstructor(); Object.freeze(this); }
[ "function", "ArrayType", "(", "schema", ",", "opts", ")", "{", "Type", ".", "call", "(", "this", ")", ";", "if", "(", "!", "schema", ".", "items", ")", "{", "throw", "new", "Error", "(", "f", "(", "'missing array items: %j'", ",", "schema", ")", ")",...
Avro array. Represented as vanilla arrays.
[ "Avro", "array", ".", "Represented", "as", "vanilla", "arrays", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L1906-L1914
train
mtth/avsc
lib/types.js
Field
function Field(schema, opts) { var name = schema.name; if (typeof name != 'string' || !isValidName(name)) { throw new Error(f('invalid field name: %s', name)); } this.name = name; this.type = Type.forSchema(schema.type, opts); this.aliases = schema.aliases || []; this.doc = schema.doc !== undefined ?...
javascript
function Field(schema, opts) { var name = schema.name; if (typeof name != 'string' || !isValidName(name)) { throw new Error(f('invalid field name: %s', name)); } this.name = name; this.type = Type.forSchema(schema.type, opts); this.aliases = schema.aliases || []; this.doc = schema.doc !== undefined ?...
[ "function", "Field", "(", "schema", ",", "opts", ")", "{", "var", "name", "=", "schema", ".", "name", ";", "if", "(", "typeof", "name", "!=", "'string'", "||", "!", "isValidName", "(", "name", ")", ")", "{", "throw", "new", "Error", "(", "f", "(", ...
A record field.
[ "A", "record", "field", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L2768-L2810
train
mtth/avsc
lib/types.js
readValue
function readValue(type, tap, resolver, lazy) { if (resolver) { if (resolver._readerType !== type) { throw new Error('invalid resolver'); } return resolver._read(tap, lazy); } else { return type._read(tap); } }
javascript
function readValue(type, tap, resolver, lazy) { if (resolver) { if (resolver._readerType !== type) { throw new Error('invalid resolver'); } return resolver._read(tap, lazy); } else { return type._read(tap); } }
[ "function", "readValue", "(", "type", ",", "tap", ",", "resolver", ",", "lazy", ")", "{", "if", "(", "resolver", ")", "{", "if", "(", "resolver", ".", "_readerType", "!==", "type", ")", "{", "throw", "new", "Error", "(", "'invalid resolver'", ")", ";",...
Read a value from a tap. @param type {Type} The type to decode. @param tap {Tap} The tap to read from. No checks are performed here. @param resolver {Resolver} Optional resolver. It must match the input type. @param lazy {Boolean} Skip trailing fields when using a resolver.
[ "Read", "a", "value", "from", "a", "tap", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L2863-L2872
train
mtth/avsc
lib/types.js
qualify
function qualify(name, namespace) { if (~name.indexOf('.')) { name = name.replace(/^\./, ''); // Allow absolute referencing. } else if (namespace) { name = namespace + '.' + name; } name.split('.').forEach(function (part) { if (!isValidName(part)) { throw new Error(f('invalid name: %j', name))...
javascript
function qualify(name, namespace) { if (~name.indexOf('.')) { name = name.replace(/^\./, ''); // Allow absolute referencing. } else if (namespace) { name = namespace + '.' + name; } name.split('.').forEach(function (part) { if (!isValidName(part)) { throw new Error(f('invalid name: %j', name))...
[ "function", "qualify", "(", "name", ",", "namespace", ")", "{", "if", "(", "~", "name", ".", "indexOf", "(", "'.'", ")", ")", "{", "name", "=", "name", ".", "replace", "(", "/", "^\\.", "/", ",", "''", ")", ";", "// Allow absolute referencing.", "}",...
Verify and return fully qualified name. @param name {String} Full or short name. It can be prefixed with a dot to force global namespace. @param namespace {String} Optional namespace.
[ "Verify", "and", "return", "fully", "qualified", "name", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L2891-L2905
train
mtth/avsc
lib/types.js
getClassName
function getClassName(typeName) { if (typeName === 'error') { typeName = 'record'; } else { var match = /^([^:]+):(.*)$/.exec(typeName); if (match) { if (match[1] === 'union') { typeName = match[2] + 'Union'; } else { // Logical type. typeName = match[1]; } ...
javascript
function getClassName(typeName) { if (typeName === 'error') { typeName = 'record'; } else { var match = /^([^:]+):(.*)$/.exec(typeName); if (match) { if (match[1] === 'union') { typeName = match[2] + 'Union'; } else { // Logical type. typeName = match[1]; } ...
[ "function", "getClassName", "(", "typeName", ")", "{", "if", "(", "typeName", "===", "'error'", ")", "{", "typeName", "=", "'record'", ";", "}", "else", "{", "var", "match", "=", "/", "^([^:]+):(.*)$", "/", ".", "exec", "(", "typeName", ")", ";", "if",...
Return a type's class name from its Avro type name. We can't simply use `constructor.name` since it isn't supported in all browsers. @param typeName {String} Type name.
[ "Return", "a", "type", "s", "class", "name", "from", "its", "Avro", "type", "name", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L2945-L2960
train
mtth/avsc
lib/types.js
readArraySize
function readArraySize(tap) { var n = tap.readLong(); if (n < 0) { n = -n; tap.skipLong(); // Skip size. } return n; }
javascript
function readArraySize(tap) { var n = tap.readLong(); if (n < 0) { n = -n; tap.skipLong(); // Skip size. } return n; }
[ "function", "readArraySize", "(", "tap", ")", "{", "var", "n", "=", "tap", ".", "readLong", "(", ")", ";", "if", "(", "n", "<", "0", ")", "{", "n", "=", "-", "n", ";", "tap", ".", "skipLong", "(", ")", ";", "// Skip size.", "}", "return", "n", ...
Get the number of elements in an array block. @param tap {Tap} A tap positioned at the beginning of an array block.
[ "Get", "the", "number", "of", "elements", "in", "an", "array", "block", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L2967-L2974
train
mtth/avsc
lib/types.js
isAmbiguous
function isAmbiguous(types) { var buckets = {}; var i, l, bucket, type; for (i = 0, l = types.length; i < l; i++) { type = types[i]; if (!Type.isType(type, 'logical')) { bucket = getTypeBucket(type); if (buckets[bucket]) { return true; } buckets[bucket] = true; } } ...
javascript
function isAmbiguous(types) { var buckets = {}; var i, l, bucket, type; for (i = 0, l = types.length; i < l; i++) { type = types[i]; if (!Type.isType(type, 'logical')) { bucket = getTypeBucket(type); if (buckets[bucket]) { return true; } buckets[bucket] = true; } } ...
[ "function", "isAmbiguous", "(", "types", ")", "{", "var", "buckets", "=", "{", "}", ";", "var", "i", ",", "l", ",", "bucket", ",", "type", ";", "for", "(", "i", "=", "0", ",", "l", "=", "types", ".", "length", ";", "i", "<", "l", ";", "i", ...
Check whether a collection of types leads to an ambiguous union. @param types {Array} Array of types.
[ "Check", "whether", "a", "collection", "of", "types", "leads", "to", "an", "ambiguous", "union", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L3072-L3086
train
mtth/avsc
lib/types.js
combineNumbers
function combineNumbers(types) { var typeNames = ['int', 'long', 'float', 'double']; var superIndex = -1; var superType = null; var i, l, type, index; for (i = 0, l = types.length; i < l; i++) { type = types[i]; index = typeNames.indexOf(type.typeName); if (index > superIndex) { superIndex =...
javascript
function combineNumbers(types) { var typeNames = ['int', 'long', 'float', 'double']; var superIndex = -1; var superType = null; var i, l, type, index; for (i = 0, l = types.length; i < l; i++) { type = types[i]; index = typeNames.indexOf(type.typeName); if (index > superIndex) { superIndex =...
[ "function", "combineNumbers", "(", "types", ")", "{", "var", "typeNames", "=", "[", "'int'", ",", "'long'", ",", "'float'", ",", "'double'", "]", ";", "var", "superIndex", "=", "-", "1", ";", "var", "superType", "=", "null", ";", "var", "i", ",", "l"...
Combine number types. Note that never have to create a new type here, we are guaranteed to be able to reuse one of the input types as super-type.
[ "Combine", "number", "types", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/types.js#L3094-L3108
train
mtth/avsc
etc/benchmarks/js-serialization-libraries/index.js
generateStats
function generateStats(schema, opts) { opts = opts || {}; var type = avro.parse(schema, {wrapUnions: opts.wrapUnions}); return [DecodeSuite, EncodeSuite].map(function (Suite) { var stats = []; var suite = new Suite(type, opts) .on('start', function () { console.error(Suite.key_ + ' ' + type); }) ...
javascript
function generateStats(schema, opts) { opts = opts || {}; var type = avro.parse(schema, {wrapUnions: opts.wrapUnions}); return [DecodeSuite, EncodeSuite].map(function (Suite) { var stats = []; var suite = new Suite(type, opts) .on('start', function () { console.error(Suite.key_ + ' ' + type); }) ...
[ "function", "generateStats", "(", "schema", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "var", "type", "=", "avro", ".", "parse", "(", "schema", ",", "{", "wrapUnions", ":", "opts", ".", "wrapUnions", "}", ")", ";", "return", "...
Generate statistics for a given schema.
[ "Generate", "statistics", "for", "a", "given", "schema", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/benchmarks/js-serialization-libraries/index.js#L30-L53
train
mtth/avsc
etc/benchmarks/js-serialization-libraries/index.js
Suite
function Suite(type, opts) { Benchmark.Suite.call(this); opts = opts || {}; this._type = type; this._compatibleType = avro.parse(type.getSchema(), { typeHook: typeHook, wrapUnions: opts.wrapUnions }); this._value = opts.value ? type.fromString(opts.value) : type.random(); Object.keys(opts).forEa...
javascript
function Suite(type, opts) { Benchmark.Suite.call(this); opts = opts || {}; this._type = type; this._compatibleType = avro.parse(type.getSchema(), { typeHook: typeHook, wrapUnions: opts.wrapUnions }); this._value = opts.value ? type.fromString(opts.value) : type.random(); Object.keys(opts).forEa...
[ "function", "Suite", "(", "type", ",", "opts", ")", "{", "Benchmark", ".", "Suite", ".", "call", "(", "this", ")", ";", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "_type", "=", "type", ";", "this", ".", "_compatibleType", "=", "avro", ...
Custom benchmark suite.
[ "Custom", "benchmark", "suite", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/benchmarks/js-serialization-libraries/index.js#L60-L80
train
mtth/avsc
lib/specs.js
read
function read(str) { var schema; if (typeof str == 'string' && ~str.indexOf(path.sep) && files.existsSync(str)) { // Try interpreting `str` as path to a file contain a JSON schema or an IDL // protocol. Note that we add the second check to skip primitive references // (e.g. `"int"`, the most common use-...
javascript
function read(str) { var schema; if (typeof str == 'string' && ~str.indexOf(path.sep) && files.existsSync(str)) { // Try interpreting `str` as path to a file contain a JSON schema or an IDL // protocol. Note that we add the second check to skip primitive references // (e.g. `"int"`, the most common use-...
[ "function", "read", "(", "str", ")", "{", "var", "schema", ";", "if", "(", "typeof", "str", "==", "'string'", "&&", "~", "str", ".", "indexOf", "(", "path", ".", "sep", ")", "&&", "files", ".", "existsSync", "(", "str", ")", ")", "{", "// Try inter...
Parsing functions. Convenience function to parse multiple inputs into protocols and schemas. It should cover most basic use-cases but has a few limitations: + It doesn't allow passing options to the parsing step. + The protocol/type inference logic can be deceived. The parsing logic is as follows: + If `str` conta...
[ "Parsing", "functions", ".", "Convenience", "function", "to", "parse", "multiple", "inputs", "into", "protocols", "and", "schemas", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/specs.js#L183-L220
train
mtth/avsc
lib/specs.js
extractJavadoc
function extractJavadoc(str) { var lines = str .replace(/^[ \t]+|[ \t]+$/g, '') // Trim whitespace. .split('\n').map(function (line, i) { return i ? line.replace(/^\s*\*\s?/, '') : line; }); while (!lines[0]) { lines.shift(); } while (!lines[lines.length - 1]) { lines.pop(); } retu...
javascript
function extractJavadoc(str) { var lines = str .replace(/^[ \t]+|[ \t]+$/g, '') // Trim whitespace. .split('\n').map(function (line, i) { return i ? line.replace(/^\s*\*\s?/, '') : line; }); while (!lines[0]) { lines.shift(); } while (!lines[lines.length - 1]) { lines.pop(); } retu...
[ "function", "extractJavadoc", "(", "str", ")", "{", "var", "lines", "=", "str", ".", "replace", "(", "/", "^[ \\t]+|[ \\t]+$", "/", "g", ",", "''", ")", "// Trim whitespace.", ".", "split", "(", "'\\n'", ")", ".", "map", "(", "function", "(", "line", "...
Extract Javadoc contents from the comment. The parsing done is very simple and simply removes the line prefixes and leading / trailing empty lines. It's better to be conservative with formatting rather than risk losing information.
[ "Extract", "Javadoc", "contents", "from", "the", "comment", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/specs.js#L713-L726
train
mtth/avsc
etc/browser/avsc.js
BlobReader
function BlobReader(blob, opts) { stream.Readable.call(this); opts = opts || {}; this._batchSize = opts.batchSize || 65536; this._blob = blob; this._pos = 0; }
javascript
function BlobReader(blob, opts) { stream.Readable.call(this); opts = opts || {}; this._batchSize = opts.batchSize || 65536; this._blob = blob; this._pos = 0; }
[ "function", "BlobReader", "(", "blob", ",", "opts", ")", "{", "stream", ".", "Readable", ".", "call", "(", "this", ")", ";", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "_batchSize", "=", "opts", ".", "batchSize", "||", "65536", ";", "th...
Transform stream which lazily reads a blob's contents.
[ "Transform", "stream", "which", "lazily", "reads", "a", "blob", "s", "contents", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/browser/avsc.js#L20-L27
train
mtth/avsc
etc/browser/avsc.js
createBlobDecoder
function createBlobDecoder(blob, opts) { return new BlobReader(blob).pipe(new containers.streams.BlockDecoder(opts)); }
javascript
function createBlobDecoder(blob, opts) { return new BlobReader(blob).pipe(new containers.streams.BlockDecoder(opts)); }
[ "function", "createBlobDecoder", "(", "blob", ",", "opts", ")", "{", "return", "new", "BlobReader", "(", "blob", ")", ".", "pipe", "(", "new", "containers", ".", "streams", ".", "BlockDecoder", "(", "opts", ")", ")", ";", "}" ]
Read an Avro-container stored as a blob.
[ "Read", "an", "Avro", "-", "container", "stored", "as", "a", "blob", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/browser/avsc.js#L70-L72
train
mtth/avsc
etc/browser/avsc.js
createBlobEncoder
function createBlobEncoder(schema, opts) { var encoder = new containers.streams.BlockEncoder(schema, opts); var builder = new BlobWriter(); encoder.pipe(builder); return new stream.Duplex({ objectMode: true, read: function () { // Not the fastest implementation, but it will only be called at most ...
javascript
function createBlobEncoder(schema, opts) { var encoder = new containers.streams.BlockEncoder(schema, opts); var builder = new BlobWriter(); encoder.pipe(builder); return new stream.Duplex({ objectMode: true, read: function () { // Not the fastest implementation, but it will only be called at most ...
[ "function", "createBlobEncoder", "(", "schema", ",", "opts", ")", "{", "var", "encoder", "=", "new", "containers", ".", "streams", ".", "BlockEncoder", "(", "schema", ",", "opts", ")", ";", "var", "builder", "=", "new", "BlobWriter", "(", ")", ";", "enco...
Store Avro values into an Avro-container blob. The returned stream will emit a single value, the blob, when ended.
[ "Store", "Avro", "values", "into", "an", "Avro", "-", "container", "blob", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/etc/browser/avsc.js#L79-L105
train
mtth/avsc
lib/containers.js
BlockData
function BlockData(index, buf, cb, count) { this.index = index; this.buf = buf; this.cb = cb; this.count = count | 0; }
javascript
function BlockData(index, buf, cb, count) { this.index = index; this.buf = buf; this.cb = cb; this.count = count | 0; }
[ "function", "BlockData", "(", "index", ",", "buf", ",", "cb", ",", "count", ")", "{", "this", ".", "index", "=", "index", ";", "this", ".", "buf", "=", "buf", ";", "this", ".", "cb", "=", "cb", ";", "this", ".", "count", "=", "count", "|", "0",...
Helpers. An indexed block. This can be used to preserve block order since compression and decompression can cause some some blocks to be returned out of order.
[ "Helpers", ".", "An", "indexed", "block", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/containers.js#L559-L564
train
mtth/avsc
lib/containers.js
tryReadBlock
function tryReadBlock(tap) { var pos = tap.pos; var block = BLOCK_TYPE._read(tap); if (!tap.isValid()) { tap.pos = pos; return null; } return block; }
javascript
function tryReadBlock(tap) { var pos = tap.pos; var block = BLOCK_TYPE._read(tap); if (!tap.isValid()) { tap.pos = pos; return null; } return block; }
[ "function", "tryReadBlock", "(", "tap", ")", "{", "var", "pos", "=", "tap", ".", "pos", ";", "var", "block", "=", "BLOCK_TYPE", ".", "_read", "(", "tap", ")", ";", "if", "(", "!", "tap", ".", "isValid", "(", ")", ")", "{", "tap", ".", "pos", "=...
Maybe get a block.
[ "Maybe", "get", "a", "block", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/containers.js#L567-L575
train
mtth/avsc
lib/containers.js
copyBuffer
function copyBuffer(buf, pos, len) { var copy = utils.newBuffer(len); buf.copy(copy, 0, pos, pos + len); return copy; }
javascript
function copyBuffer(buf, pos, len) { var copy = utils.newBuffer(len); buf.copy(copy, 0, pos, pos + len); return copy; }
[ "function", "copyBuffer", "(", "buf", ",", "pos", ",", "len", ")", "{", "var", "copy", "=", "utils", ".", "newBuffer", "(", "len", ")", ";", "buf", ".", "copy", "(", "copy", ",", "0", ",", "pos", ",", "pos", "+", "len", ")", ";", "return", "cop...
Copy a buffer. This avoids creating a slice of the original buffer.
[ "Copy", "a", "buffer", ".", "This", "avoids", "creating", "a", "slice", "of", "the", "original", "buffer", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/containers.js#L596-L600
train
mtth/avsc
lib/services.js
Message
function Message(name, reqType, errType, resType, oneWay, doc) { this.name = name; if (!Type.isType(reqType, 'record')) { throw new Error('invalid request type'); } this.requestType = reqType; if ( !Type.isType(errType, 'union') || !Type.isType(errType.getTypes()[0], 'string') ) { throw new ...
javascript
function Message(name, reqType, errType, resType, oneWay, doc) { this.name = name; if (!Type.isType(reqType, 'record')) { throw new Error('invalid request type'); } this.requestType = reqType; if ( !Type.isType(errType, 'union') || !Type.isType(errType.getTypes()[0], 'string') ) { throw new ...
[ "function", "Message", "(", "name", ",", "reqType", ",", "errType", ",", "resType", ",", "oneWay", ",", "doc", ")", "{", "this", ".", "name", "=", "name", ";", "if", "(", "!", "Type", ".", "isType", "(", "reqType", ",", "'record'", ")", ")", "{", ...
An Avro message, containing its request, response, etc.
[ "An", "Avro", "message", "containing", "its", "request", "response", "etc", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L83-L105
train
mtth/avsc
lib/services.js
Service
function Service(name, messages, types, ptcl, server) { if (typeof name != 'string') { // Let's be helpful in case this class is instantiated directly. return Service.forProtocol(name, messages); } this.name = name; this._messagesByName = messages || {}; this.messages = Object.freeze(utils.objectValu...
javascript
function Service(name, messages, types, ptcl, server) { if (typeof name != 'string') { // Let's be helpful in case this class is instantiated directly. return Service.forProtocol(name, messages); } this.name = name; this._messagesByName = messages || {}; this.messages = Object.freeze(utils.objectValu...
[ "function", "Service", "(", "name", ",", "messages", ",", "types", ",", "ptcl", ",", "server", ")", "{", "if", "(", "typeof", "name", "!=", "'string'", ")", "{", "// Let's be helpful in case this class is instantiated directly.", "return", "Service", ".", "forProt...
An Avro RPC service. This constructor shouldn't be called directly, but via the `Service.forProtocol` method. This function performs little logic to better support efficient copy.
[ "An", "Avro", "RPC", "service", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L179-L202
train
mtth/avsc
lib/services.js
discoverProtocol
function discoverProtocol(transport, opts, cb) { if (cb === undefined && typeof opts == 'function') { cb = opts; opts = undefined; } var svc = new Service({protocol: 'Empty'}, OPTS); var ptclStr; svc.createClient({timeout: opts && opts.timeout}) .createChannel(transport, { scope: opts && op...
javascript
function discoverProtocol(transport, opts, cb) { if (cb === undefined && typeof opts == 'function') { cb = opts; opts = undefined; } var svc = new Service({protocol: 'Empty'}, OPTS); var ptclStr; svc.createClient({timeout: opts && opts.timeout}) .createChannel(transport, { scope: opts && op...
[ "function", "discoverProtocol", "(", "transport", ",", "opts", ",", "cb", ")", "{", "if", "(", "cb", "===", "undefined", "&&", "typeof", "opts", "==", "'function'", ")", "{", "cb", "=", "opts", ";", "opts", "=", "undefined", ";", "}", "var", "svc", "...
Function to retrieve a remote service's protocol.
[ "Function", "to", "retrieve", "a", "remote", "service", "s", "protocol", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L429-L454
train
mtth/avsc
lib/services.js
Client
function Client(svc, opts) { opts = opts || {}; events.EventEmitter.call(this); // We have to suffix all client properties to be safe, since the message // names aren't prefixed with clients (unlike servers). this._svc$ = svc; this._channels$ = []; // Active channels. this._fns$ = []; // Middleware funct...
javascript
function Client(svc, opts) { opts = opts || {}; events.EventEmitter.call(this); // We have to suffix all client properties to be safe, since the message // names aren't prefixed with clients (unlike servers). this._svc$ = svc; this._channels$ = []; // Active channels. this._fns$ = []; // Middleware funct...
[ "function", "Client", "(", "svc", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "// We have to suffix all client properties to be safe, since the message", "// names aren't prefixe...
Load-balanced message sender.
[ "Load", "-", "balanced", "message", "sender", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L457-L480
train
mtth/avsc
lib/services.js
Server
function Server(svc, opts) { opts = opts || {}; events.EventEmitter.call(this); this.service = svc; this._handlers = {}; this._fns = []; // Middleware functions. this._channels = {}; // Active channels. this._nextChannelId = 1; this._cache = opts.cache || {}; // Deprecated. this._defaultHandler = op...
javascript
function Server(svc, opts) { opts = opts || {}; events.EventEmitter.call(this); this.service = svc; this._handlers = {}; this._fns = []; // Middleware functions. this._channels = {}; // Active channels. this._nextChannelId = 1; this._cache = opts.cache || {}; // Deprecated. this._defaultHandler = op...
[ "function", "Server", "(", "svc", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "service", "=", "svc", ";", "this", ".", "_handlers", "=", "{", "}"...
Message receiver.
[ "Message", "receiver", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L710-L737
train
mtth/avsc
lib/services.js
ClientChannel
function ClientChannel(client, opts) { opts = opts || {}; events.EventEmitter.call(this); this.client = client; this.timeout = utils.getOption(opts, 'timeout', client._timeout$); this._endWritable = !!utils.getOption(opts, 'endWritable', true); this._prefix = normalizedPrefix(opts.scope); var cache = cl...
javascript
function ClientChannel(client, opts) { opts = opts || {}; events.EventEmitter.call(this); this.client = client; this.timeout = utils.getOption(opts, 'timeout', client._timeout$); this._endWritable = !!utils.getOption(opts, 'endWritable', true); this._prefix = normalizedPrefix(opts.scope); var cache = cl...
[ "function", "ClientChannel", "(", "client", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "events", ".", "EventEmitter", ".", "call", "(", "this", ")", ";", "this", ".", "client", "=", "client", ";", "this", ".", "timeout", "=", ...
Base message emitter class. See below for the two available variants.
[ "Base", "message", "emitter", "class", ".", "See", "below", "for", "the", "two", "available", "variants", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L864-L900
train
mtth/avsc
lib/services.js
StatelessClientChannel
function StatelessClientChannel(client, writableFactory, opts) { ClientChannel.call(this, client, opts); this._writableFactory = writableFactory; if (!opts || !opts.noPing) { // Ping the server to check whether the remote protocol is compatible. // If not, this will throw an error on the channel. deb...
javascript
function StatelessClientChannel(client, writableFactory, opts) { ClientChannel.call(this, client, opts); this._writableFactory = writableFactory; if (!opts || !opts.noPing) { // Ping the server to check whether the remote protocol is compatible. // If not, this will throw an error on the channel. deb...
[ "function", "StatelessClientChannel", "(", "client", ",", "writableFactory", ",", "opts", ")", "{", "ClientChannel", ".", "call", "(", "this", ",", "client", ",", "opts", ")", ";", "this", ".", "_writableFactory", "=", "writableFactory", ";", "if", "(", "!",...
Factory-based client channel. This channel doesn't keep a persistent connection to the server and requires prepending a handshake to each message emitted. Usage examples include talking to an HTTP server (where the factory returns an HTTP request). Since each message will use its own writable/readable stream pair, th...
[ "Factory", "-", "based", "client", "channel", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1090-L1100
train
mtth/avsc
lib/services.js
onMessage
function onMessage(obj) { var id = obj.id; if (!self._matchesPrefix(id)) { debug('discarding unscoped message %s', id); return; } var cb = self._registry.get(id); if (cb) { process.nextTick(function () { debug('received message %s', id); // Ensure that the initial c...
javascript
function onMessage(obj) { var id = obj.id; if (!self._matchesPrefix(id)) { debug('discarding unscoped message %s', id); return; } var cb = self._registry.get(id); if (cb) { process.nextTick(function () { debug('received message %s', id); // Ensure that the initial c...
[ "function", "onMessage", "(", "obj", ")", "{", "var", "id", "=", "obj", ".", "id", ";", "if", "(", "!", "self", ".", "_matchesPrefix", "(", "id", ")", ")", "{", "debug", "(", "'discarding unscoped message %s'", ",", "id", ")", ";", "return", ";", "}"...
Callback used after a connection has been established.
[ "Callback", "used", "after", "a", "connection", "has", "been", "established", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1267-L1284
train
mtth/avsc
lib/services.js
StatelessServerChannel
function StatelessServerChannel(server, readableFactory, opts) { ServerChannel.call(this, server, opts); this._writable = undefined; var self = this; var readable; process.nextTick(function () { // Delay listening to allow handlers to be attached even if the factory is // purely synchronous. rea...
javascript
function StatelessServerChannel(server, readableFactory, opts) { ServerChannel.call(this, server, opts); this._writable = undefined; var self = this; var readable; process.nextTick(function () { // Delay listening to allow handlers to be attached even if the factory is // purely synchronous. rea...
[ "function", "StatelessServerChannel", "(", "server", ",", "readableFactory", ",", "opts", ")", "{", "ServerChannel", ".", "call", "(", "this", ",", "server", ",", "opts", ")", ";", "this", ".", "_writable", "=", "undefined", ";", "var", "self", "=", "this"...
Server channel for stateless transport. This channel expect a handshake to precede each message.
[ "Server", "channel", "for", "stateless", "transport", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1605-L1675
train
mtth/avsc
lib/services.js
WrappedRequest
function WrappedRequest(msg, hdrs, req) { this._msg = msg; this.headers = hdrs || {}; this.request = req || {}; }
javascript
function WrappedRequest(msg, hdrs, req) { this._msg = msg; this.headers = hdrs || {}; this.request = req || {}; }
[ "function", "WrappedRequest", "(", "msg", ",", "hdrs", ",", "req", ")", "{", "this", ".", "_msg", "=", "msg", ";", "this", ".", "headers", "=", "hdrs", "||", "{", "}", ";", "this", ".", "request", "=", "req", "||", "{", "}", ";", "}" ]
Helpers. Enhanced request, used inside forward middleware functions.
[ "Helpers", ".", "Enhanced", "request", "used", "inside", "forward", "middleware", "functions", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1769-L1773
train
mtth/avsc
lib/services.js
WrappedResponse
function WrappedResponse(msg, hdr, err, res) { this._msg = msg; this.headers = hdr; this.error = err; this.response = res; }
javascript
function WrappedResponse(msg, hdr, err, res) { this._msg = msg; this.headers = hdr; this.error = err; this.response = res; }
[ "function", "WrappedResponse", "(", "msg", ",", "hdr", ",", "err", ",", "res", ")", "{", "this", ".", "_msg", "=", "msg", ";", "this", ".", "headers", "=", "hdr", ";", "this", ".", "error", "=", "err", ";", "this", ".", "response", "=", "res", ";...
Enhanced response, used inside forward middleware functions.
[ "Enhanced", "response", "used", "inside", "forward", "middleware", "functions", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1785-L1790
train
mtth/avsc
lib/services.js
CallContext
function CallContext(msg, channel) { this.channel = channel; this.locals = {}; this.message = msg; Object.freeze(this); }
javascript
function CallContext(msg, channel) { this.channel = channel; this.locals = {}; this.message = msg; Object.freeze(this); }
[ "function", "CallContext", "(", "msg", ",", "channel", ")", "{", "this", ".", "channel", "=", "channel", ";", "this", ".", "locals", "=", "{", "}", ";", "this", ".", "message", "=", "msg", ";", "Object", ".", "freeze", "(", "this", ")", ";", "}" ]
Context for all middleware and handlers. It exposes a `locals` object which can be used to pass information between each other during a given call.
[ "Context", "for", "all", "middleware", "and", "handlers", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1810-L1815
train
mtth/avsc
lib/services.js
Registry
function Registry(ctx, prefixLength) { this._ctx = ctx; // Context for all callbacks. this._mask = ~0 >>> (prefixLength | 0); // 16 bits by default. this._id = 0; // Unique integer ID for each call. this._n = 0; // Number of pending calls. this._cbs = {}; }
javascript
function Registry(ctx, prefixLength) { this._ctx = ctx; // Context for all callbacks. this._mask = ~0 >>> (prefixLength | 0); // 16 bits by default. this._id = 0; // Unique integer ID for each call. this._n = 0; // Number of pending calls. this._cbs = {}; }
[ "function", "Registry", "(", "ctx", ",", "prefixLength", ")", "{", "this", ".", "_ctx", "=", "ctx", ";", "// Context for all callbacks.", "this", ".", "_mask", "=", "~", "0", ">>>", "(", "prefixLength", "|", "0", ")", ";", "// 16 bits by default.", "this", ...
Callback registry. Callbacks added must accept an error as first argument. This is used by client channels to store pending calls. This class isn't exposed by the public API.
[ "Callback", "registry", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1824-L1830
train
mtth/avsc
lib/services.js
Adapter
function Adapter(clientSvc, serverSvc, hash, isRemote) { this._clientSvc = clientSvc; this._serverSvc = serverSvc; this._hash = hash; // Convenience to access it when creating handshakes. this._isRemote = !!isRemote; this._readers = createReaders(clientSvc, serverSvc); }
javascript
function Adapter(clientSvc, serverSvc, hash, isRemote) { this._clientSvc = clientSvc; this._serverSvc = serverSvc; this._hash = hash; // Convenience to access it when creating handshakes. this._isRemote = !!isRemote; this._readers = createReaders(clientSvc, serverSvc); }
[ "function", "Adapter", "(", "clientSvc", ",", "serverSvc", ",", "hash", ",", "isRemote", ")", "{", "this", ".", "_clientSvc", "=", "clientSvc", ";", "this", ".", "_serverSvc", "=", "serverSvc", ";", "this", ".", "_hash", "=", "hash", ";", "// Convenience t...
Service resolution helper. It is used both by client and server channels, to respectively decode errors and responses, or requests.
[ "Service", "resolution", "helper", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1874-L1880
train
mtth/avsc
lib/services.js
FrameDecoder
function FrameDecoder() { stream.Transform.call(this, {readableObjectMode: true}); this._id = undefined; this._buf = utils.newBuffer(0); this._bufs = []; this.on('finish', function () { this.push(null); }); }
javascript
function FrameDecoder() { stream.Transform.call(this, {readableObjectMode: true}); this._id = undefined; this._buf = utils.newBuffer(0); this._bufs = []; this.on('finish', function () { this.push(null); }); }
[ "function", "FrameDecoder", "(", ")", "{", "stream", ".", "Transform", ".", "call", "(", "this", ",", "{", "readableObjectMode", ":", "true", "}", ")", ";", "this", ".", "_id", "=", "undefined", ";", "this", ".", "_buf", "=", "utils", ".", "newBuffer",...
Standard "un-framing" stream.
[ "Standard", "un", "-", "framing", "stream", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L1921-L1928
train
mtth/avsc
lib/services.js
readHead
function readHead(type, buf) { var tap = new Tap(buf); var head = type._read(tap); if (!tap.isValid()) { throw new Error(f('truncated %j', type.schema())); } return {head: head, tail: tap.buf.slice(tap.pos)}; }
javascript
function readHead(type, buf) { var tap = new Tap(buf); var head = type._read(tap); if (!tap.isValid()) { throw new Error(f('truncated %j', type.schema())); } return {head: head, tail: tap.buf.slice(tap.pos)}; }
[ "function", "readHead", "(", "type", ",", "buf", ")", "{", "var", "tap", "=", "new", "Tap", "(", "buf", ")", ";", "var", "head", "=", "type", ".", "_read", "(", "tap", ")", ";", "if", "(", "!", "tap", ".", "isValid", "(", ")", ")", "{", "thro...
Decode a type used as prefix inside a buffer. @param type {Type} The type of the prefix. @param buf {Buffer} Encoded bytes. This function will return an object `{head, tail}` where head contains the decoded value and tail the rest of the buffer. An error will be thrown if the prefix cannot be decoded.
[ "Decode", "a", "type", "used", "as", "prefix", "inside", "a", "buffer", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2082-L2089
train
mtth/avsc
lib/services.js
createReader
function createReader(rtype, wtype) { return rtype.equals(wtype) ? rtype : rtype.createResolver(wtype); }
javascript
function createReader(rtype, wtype) { return rtype.equals(wtype) ? rtype : rtype.createResolver(wtype); }
[ "function", "createReader", "(", "rtype", ",", "wtype", ")", "{", "return", "rtype", ".", "equals", "(", "wtype", ")", "?", "rtype", ":", "rtype", ".", "createResolver", "(", "wtype", ")", ";", "}" ]
Generate a decoder, optimizing the case where reader and writer are equal. @param rtype {Type} Reader's type. @param wtype {Type} Writer's type.
[ "Generate", "a", "decoder", "optimizing", "the", "case", "where", "reader", "and", "writer", "are", "equal", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2097-L2099
train
mtth/avsc
lib/services.js
createReaders
function createReaders(clientSvc, serverSvc) { var obj = {}; clientSvc.messages.forEach(function (c) { var n = c.name; var s = serverSvc.message(n); try { if (!s) { throw new Error(f('missing server message: %s', n)); } if (s.oneWay !== c.oneWay) { throw new Error(f('in...
javascript
function createReaders(clientSvc, serverSvc) { var obj = {}; clientSvc.messages.forEach(function (c) { var n = c.name; var s = serverSvc.message(n); try { if (!s) { throw new Error(f('missing server message: %s', n)); } if (s.oneWay !== c.oneWay) { throw new Error(f('in...
[ "function", "createReaders", "(", "clientSvc", ",", "serverSvc", ")", "{", "var", "obj", "=", "{", "}", ";", "clientSvc", ".", "messages", ".", "forEach", "(", "function", "(", "c", ")", "{", "var", "n", "=", "c", ".", "name", ";", "var", "s", "=",...
Generate all readers for a given protocol combination. @param clientSvc {Service} Client service. @param serverSvc {Service} Client service.
[ "Generate", "all", "readers", "for", "a", "given", "protocol", "combination", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2107-L2127
train
mtth/avsc
lib/services.js
insertRemoteProtocols
function insertRemoteProtocols(cache, ptcls, svc, isClient) { Object.keys(ptcls).forEach(function (hash) { var ptcl = ptcls[hash]; var clientSvc, serverSvc; if (isClient) { clientSvc = svc; serverSvc = Service.forProtocol(ptcl); } else { clientSvc = Service.forProtocol(ptcl); s...
javascript
function insertRemoteProtocols(cache, ptcls, svc, isClient) { Object.keys(ptcls).forEach(function (hash) { var ptcl = ptcls[hash]; var clientSvc, serverSvc; if (isClient) { clientSvc = svc; serverSvc = Service.forProtocol(ptcl); } else { clientSvc = Service.forProtocol(ptcl); s...
[ "function", "insertRemoteProtocols", "(", "cache", ",", "ptcls", ",", "svc", ",", "isClient", ")", "{", "Object", ".", "keys", "(", "ptcls", ")", ".", "forEach", "(", "function", "(", "hash", ")", "{", "var", "ptcl", "=", "ptcls", "[", "hash", "]", "...
Populate a cache from a list of protocols. @param cache {Object} Cache of adapters. @param svc {Service} The local service (either client or server). @param ptcls {Array} Array of protocols to insert. @param isClient {Boolean} Whether the local service is a client's or server's.
[ "Populate", "a", "cache", "from", "a", "list", "of", "protocols", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2138-L2151
train
mtth/avsc
lib/services.js
getRemoteProtocols
function getRemoteProtocols(cache, isClient) { var ptcls = {}; Object.keys(cache).forEach(function (hs) { var adapter = cache[hs]; if (adapter._isRemote) { var svc = isClient ? adapter._serverSvc : adapter._clientSvc; ptcls[hs] = svc.protocol; } }); return ptcls; }
javascript
function getRemoteProtocols(cache, isClient) { var ptcls = {}; Object.keys(cache).forEach(function (hs) { var adapter = cache[hs]; if (adapter._isRemote) { var svc = isClient ? adapter._serverSvc : adapter._clientSvc; ptcls[hs] = svc.protocol; } }); return ptcls; }
[ "function", "getRemoteProtocols", "(", "cache", ",", "isClient", ")", "{", "var", "ptcls", "=", "{", "}", ";", "Object", ".", "keys", "(", "cache", ")", ".", "forEach", "(", "function", "(", "hs", ")", "{", "var", "adapter", "=", "cache", "[", "hs", ...
Extract remote protocols from a cache @param cache {Object} Cache of adapters. @param isClient {Boolean} Whether the remote protocols extracted should be the servers' or clients'.
[ "Extract", "remote", "protocols", "from", "a", "cache" ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2160-L2170
train
mtth/avsc
lib/services.js
forwardErrors
function forwardErrors(src, dst) { return src.on('error', function (err) { dst.emit('error', err, src); }); }
javascript
function forwardErrors(src, dst) { return src.on('error', function (err) { dst.emit('error', err, src); }); }
[ "function", "forwardErrors", "(", "src", ",", "dst", ")", "{", "return", "src", ".", "on", "(", "'error'", ",", "function", "(", "err", ")", "{", "dst", ".", "emit", "(", "'error'", ",", "err", ",", "src", ")", ";", "}", ")", ";", "}" ]
Forward any errors emitted on the source to the destination. @param src {EventEmitter} The initial source of error events. @param dst {EventEmitter} The new target of the source's error events. The original source will be provided as second argument (the error being the first). As a convenience, the source will be re...
[ "Forward", "any", "errors", "emitted", "on", "the", "source", "to", "the", "destination", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2192-L2196
train
mtth/avsc
lib/services.js
toError
function toError(msg, cause) { var err = new Error(msg); err.cause = cause; return err; }
javascript
function toError(msg, cause) { var err = new Error(msg); err.cause = cause; return err; }
[ "function", "toError", "(", "msg", ",", "cause", ")", "{", "var", "err", "=", "new", "Error", "(", "msg", ")", ";", "err", ".", "cause", "=", "cause", ";", "return", "err", ";", "}" ]
Create an error. @param msg {String} Error message. @param cause {Error} The cause of the error. It is available as `cause` field on the outer error.
[ "Create", "an", "error", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2205-L2209
train
mtth/avsc
lib/services.js
toRpcError
function toRpcError(rpcCode, cause) { var err = toError(rpcCode.toLowerCase().replace(/_/g, ' '), cause); err.rpcCode = (cause && cause.rpcCode) ? cause.rpcCode : rpcCode; return err; }
javascript
function toRpcError(rpcCode, cause) { var err = toError(rpcCode.toLowerCase().replace(/_/g, ' '), cause); err.rpcCode = (cause && cause.rpcCode) ? cause.rpcCode : rpcCode; return err; }
[ "function", "toRpcError", "(", "rpcCode", ",", "cause", ")", "{", "var", "err", "=", "toError", "(", "rpcCode", ".", "toLowerCase", "(", ")", ".", "replace", "(", "/", "_", "/", "g", ",", "' '", ")", ",", "cause", ")", ";", "err", ".", "rpcCode", ...
Mark an error. @param rpcCode {String} Code representing the failure. @param cause {Error} The cause of the error. It is available as `cause` field on the outer error. This is used to keep the argument of channels' `'error'` event errors.
[ "Mark", "an", "error", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2220-L2224
train
mtth/avsc
lib/services.js
serializationError
function serializationError(msg, obj, fields) { var details = []; var i, l, field; for (i = 0, l = fields.length; i < l; i++) { field = fields[i]; field.type.isValid(obj[field.name], {errorHook: errorHook}); } var detailsStr = details .map(function (obj) { return f('%s = %j but expected %s',...
javascript
function serializationError(msg, obj, fields) { var details = []; var i, l, field; for (i = 0, l = fields.length; i < l; i++) { field = fields[i]; field.type.isValid(obj[field.name], {errorHook: errorHook}); } var detailsStr = details .map(function (obj) { return f('%s = %j but expected %s',...
[ "function", "serializationError", "(", "msg", ",", "obj", ",", "fields", ")", "{", "var", "details", "=", "[", "]", ";", "var", "i", ",", "l", ",", "field", ";", "for", "(", "i", "=", "0", ",", "l", "=", "fields", ".", "length", ";", "i", "<", ...
Provide a helpful error to identify why serialization failed. @param err {Error} The error to decorate. @param obj {...} The object containing fields to validated. @param fields {Array} Information about the fields to validate.
[ "Provide", "a", "helpful", "error", "to", "identify", "why", "serialization", "failed", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2233-L2266
train
mtth/avsc
lib/services.js
getExistingMessage
function getExistingMessage(svc, name) { var msg = svc.message(name); if (!msg) { throw new Error(f('unknown message: %s', name)); } return msg; }
javascript
function getExistingMessage(svc, name) { var msg = svc.message(name); if (!msg) { throw new Error(f('unknown message: %s', name)); } return msg; }
[ "function", "getExistingMessage", "(", "svc", ",", "name", ")", "{", "var", "msg", "=", "svc", ".", "message", "(", "name", ")", ";", "if", "(", "!", "msg", ")", "{", "throw", "new", "Error", "(", "f", "(", "'unknown message: %s'", ",", "name", ")", ...
Get a message, asserting that it exists. @param svc {Service} The protocol to look into. @param name {String} The message's name.
[ "Get", "a", "message", "asserting", "that", "it", "exists", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2308-L2314
train
mtth/avsc
lib/services.js
chainMiddleware
function chainMiddleware(params) { var args = [params.wreq, params.wres]; var cbs = []; var cause; // Backpropagated error. forward(0); function forward(pos) { var isDone = false; if (pos < params.fns.length) { params.fns[pos].apply(params.ctx, args.concat(function (err, cb) { if (isDon...
javascript
function chainMiddleware(params) { var args = [params.wreq, params.wres]; var cbs = []; var cause; // Backpropagated error. forward(0); function forward(pos) { var isDone = false; if (pos < params.fns.length) { params.fns[pos].apply(params.ctx, args.concat(function (err, cb) { if (isDon...
[ "function", "chainMiddleware", "(", "params", ")", "{", "var", "args", "=", "[", "params", ".", "wreq", ",", "params", ".", "wres", "]", ";", "var", "cbs", "=", "[", "]", ";", "var", "cause", ";", "// Backpropagated error.", "forward", "(", "0", ")", ...
Middleware logic. This is used both in clients and servers to intercept call handling (e.g. to populate headers, do access control). @param params {Object} The following parameters: + fns {Array} Array of middleware functions. + ctx {Object} Context used to call the middleware functions, onTransition, and onCompletio...
[ "Middleware", "logic", "." ]
d4e62f360b8f27c4b95372cac58c95157f87865a
https://github.com/mtth/avsc/blob/d4e62f360b8f27c4b95372cac58c95157f87865a/lib/services.js#L2336-L2403
train
joshswan/react-native-globalize
lib/globalize.js
getAvailableLocales
function getAvailableLocales() { if (Cldr._raw && Cldr._raw.main) { return Object.keys(Cldr._raw.main); } return []; }
javascript
function getAvailableLocales() { if (Cldr._raw && Cldr._raw.main) { return Object.keys(Cldr._raw.main); } return []; }
[ "function", "getAvailableLocales", "(", ")", "{", "if", "(", "Cldr", ".", "_raw", "&&", "Cldr", ".", "_raw", ".", "main", ")", "{", "return", "Object", ".", "keys", "(", "Cldr", ".", "_raw", ".", "main", ")", ";", "}", "return", "[", "]", ";", "}...
Get array of available locales
[ "Get", "array", "of", "available", "locales" ]
a753910a0b0c498085ba9c3f71db8f21fa9dc81b
https://github.com/joshswan/react-native-globalize/blob/a753910a0b0c498085ba9c3f71db8f21fa9dc81b/lib/globalize.js#L29-L35
train
joshswan/react-native-globalize
lib/globalize.js
findFallbackLocale
function findFallbackLocale(locale) { const locales = getAvailableLocales(); for (let i = locale.length - 1; i > 1; i -= 1) { const key = locale.substring(0, i); if (locales.includes(key)) { return key; } } return null; }
javascript
function findFallbackLocale(locale) { const locales = getAvailableLocales(); for (let i = locale.length - 1; i > 1; i -= 1) { const key = locale.substring(0, i); if (locales.includes(key)) { return key; } } return null; }
[ "function", "findFallbackLocale", "(", "locale", ")", "{", "const", "locales", "=", "getAvailableLocales", "(", ")", ";", "for", "(", "let", "i", "=", "locale", ".", "length", "-", "1", ";", "i", ">", "1", ";", "i", "-=", "1", ")", "{", "const", "k...
Find a fallback locale
[ "Find", "a", "fallback", "locale" ]
a753910a0b0c498085ba9c3f71db8f21fa9dc81b
https://github.com/joshswan/react-native-globalize/blob/a753910a0b0c498085ba9c3f71db8f21fa9dc81b/lib/globalize.js#L38-L50
train
joshswan/react-native-globalize
lib/globalize.js
localeIsLoaded
function localeIsLoaded(locale) { return !!(Cldr._raw && Cldr._raw.main && Cldr._raw.main[getLocaleKey(locale)]); }
javascript
function localeIsLoaded(locale) { return !!(Cldr._raw && Cldr._raw.main && Cldr._raw.main[getLocaleKey(locale)]); }
[ "function", "localeIsLoaded", "(", "locale", ")", "{", "return", "!", "!", "(", "Cldr", ".", "_raw", "&&", "Cldr", ".", "_raw", ".", "main", "&&", "Cldr", ".", "_raw", ".", "main", "[", "getLocaleKey", "(", "locale", ")", "]", ")", ";", "}" ]
Check if CLDR data loaded for a given locale
[ "Check", "if", "CLDR", "data", "loaded", "for", "a", "given", "locale" ]
a753910a0b0c498085ba9c3f71db8f21fa9dc81b
https://github.com/joshswan/react-native-globalize/blob/a753910a0b0c498085ba9c3f71db8f21fa9dc81b/lib/globalize.js#L59-L61
train
joshswan/react-native-globalize
lib/globalize.js
getCurrencySymbol
function getCurrencySymbol(locale, currencyCode, altNarrow) { // Check whether the locale has been loaded if (!localeIsLoaded(locale)) { return null; } const { currencies } = Cldr._raw.main[locale].numbers; // Check whether the given currency code exists within the CLDR file for the given locale if (!...
javascript
function getCurrencySymbol(locale, currencyCode, altNarrow) { // Check whether the locale has been loaded if (!localeIsLoaded(locale)) { return null; } const { currencies } = Cldr._raw.main[locale].numbers; // Check whether the given currency code exists within the CLDR file for the given locale if (!...
[ "function", "getCurrencySymbol", "(", "locale", ",", "currencyCode", ",", "altNarrow", ")", "{", "// Check whether the locale has been loaded", "if", "(", "!", "localeIsLoaded", "(", "locale", ")", ")", "{", "return", "null", ";", "}", "const", "{", "currencies", ...
Returns only the currency symbol from the CLDR file
[ "Returns", "only", "the", "currency", "symbol", "from", "the", "CLDR", "file" ]
a753910a0b0c498085ba9c3f71db8f21fa9dc81b
https://github.com/joshswan/react-native-globalize/blob/a753910a0b0c498085ba9c3f71db8f21fa9dc81b/lib/globalize.js#L64-L79
train
troybetz/react-youtube
src/YouTube.js
shouldUpdateVideo
function shouldUpdateVideo(prevProps, props) { // A changing video should always trigger an update if (prevProps.videoId !== props.videoId) { return true; } // Otherwise, a change in the start/end time playerVars also requires a player // update. const prevVars = prevProps.opts.playerVars || {}; cons...
javascript
function shouldUpdateVideo(prevProps, props) { // A changing video should always trigger an update if (prevProps.videoId !== props.videoId) { return true; } // Otherwise, a change in the start/end time playerVars also requires a player // update. const prevVars = prevProps.opts.playerVars || {}; cons...
[ "function", "shouldUpdateVideo", "(", "prevProps", ",", "props", ")", "{", "// A changing video should always trigger an update", "if", "(", "prevProps", ".", "videoId", "!==", "props", ".", "videoId", ")", "{", "return", "true", ";", "}", "// Otherwise, a change in t...
Check whether a `props` change should result in the video being updated. @param {Object} prevProps @param {Object} props
[ "Check", "whether", "a", "props", "change", "should", "result", "in", "the", "video", "being", "updated", "." ]
7062aefc145c04d9eea100ebe5b03c1f2c30ed62
https://github.com/troybetz/react-youtube/blob/7062aefc145c04d9eea100ebe5b03c1f2c30ed62/src/YouTube.js#L12-L24
train
troybetz/react-youtube
src/YouTube.js
shouldResetPlayer
function shouldResetPlayer(prevProps, props) { return !isEqual( filterResetOptions(prevProps.opts), filterResetOptions(props.opts), ); }
javascript
function shouldResetPlayer(prevProps, props) { return !isEqual( filterResetOptions(prevProps.opts), filterResetOptions(props.opts), ); }
[ "function", "shouldResetPlayer", "(", "prevProps", ",", "props", ")", "{", "return", "!", "isEqual", "(", "filterResetOptions", "(", "prevProps", ".", "opts", ")", ",", "filterResetOptions", "(", "props", ".", "opts", ")", ",", ")", ";", "}" ]
Check whether a `props` change should result in the player being reset. The player is reset when the `props.opts` change, except if the only change is in the `start` and `end` playerVars, because a video update can deal with those. @param {Object} prevProps @param {Object} props
[ "Check", "whether", "a", "props", "change", "should", "result", "in", "the", "player", "being", "reset", ".", "The", "player", "is", "reset", "when", "the", "props", ".", "opts", "change", "except", "if", "the", "only", "change", "is", "in", "the", "star...
7062aefc145c04d9eea100ebe5b03c1f2c30ed62
https://github.com/troybetz/react-youtube/blob/7062aefc145c04d9eea100ebe5b03c1f2c30ed62/src/YouTube.js#L54-L59
train
troybetz/react-youtube
src/YouTube.js
shouldUpdatePlayer
function shouldUpdatePlayer(prevProps, props) { return ( prevProps.id !== props.id || prevProps.className !== props.className ); }
javascript
function shouldUpdatePlayer(prevProps, props) { return ( prevProps.id !== props.id || prevProps.className !== props.className ); }
[ "function", "shouldUpdatePlayer", "(", "prevProps", ",", "props", ")", "{", "return", "(", "prevProps", ".", "id", "!==", "props", ".", "id", "||", "prevProps", ".", "className", "!==", "props", ".", "className", ")", ";", "}" ]
Check whether a props change should result in an id or className update. @param {Object} prevProps @param {Object} props
[ "Check", "whether", "a", "props", "change", "should", "result", "in", "an", "id", "or", "className", "update", "." ]
7062aefc145c04d9eea100ebe5b03c1f2c30ed62
https://github.com/troybetz/react-youtube/blob/7062aefc145c04d9eea100ebe5b03c1f2c30ed62/src/YouTube.js#L67-L71
train
eggjs/egg-sequelize
lib/loader.js
loadDatabase
function loadDatabase(config = {}) { if (typeof config.ignore === 'string' || Array.isArray(config.ignore)) { app.deprecate(`[egg-sequelize] if you want to exclude ${config.ignore} when load models, please set to config.sequelize.exclude instead of config.sequelize.ignore`); config.exclude = config.igno...
javascript
function loadDatabase(config = {}) { if (typeof config.ignore === 'string' || Array.isArray(config.ignore)) { app.deprecate(`[egg-sequelize] if you want to exclude ${config.ignore} when load models, please set to config.sequelize.exclude instead of config.sequelize.ignore`); config.exclude = config.igno...
[ "function", "loadDatabase", "(", "config", "=", "{", "}", ")", "{", "if", "(", "typeof", "config", ".", "ignore", "===", "'string'", "||", "Array", ".", "isArray", "(", "config", ".", "ignore", ")", ")", "{", "app", ".", "deprecate", "(", "`", "${", ...
load databse to app[config.delegate @param {Object} config config for load - delegate: load model to app[delegate] - baeDir: where model located - other sequelize configures(databasem username, password, etc...) @return {Object} sequelize instance
[ "load", "databse", "to", "app", "[", "config", ".", "delegate" ]
04c9e72ffb1b19dbfcc42275e68fe5113eb5e2fc
https://github.com/eggjs/egg-sequelize/blob/04c9e72ffb1b19dbfcc42275e68fe5113eb5e2fc/lib/loader.js#L51-L117
train
eggjs/egg-sequelize
lib/loader.js
authenticate
async function authenticate(database) { database[AUTH_RETRIES] = database[AUTH_RETRIES] || 0; try { await database.authenticate(); } catch (e) { if (e.name !== 'SequelizeConnectionRefusedError') throw e; if (app.model[AUTH_RETRIES] >= 3) throw e; // sleep 2s to retry, max 3 times ...
javascript
async function authenticate(database) { database[AUTH_RETRIES] = database[AUTH_RETRIES] || 0; try { await database.authenticate(); } catch (e) { if (e.name !== 'SequelizeConnectionRefusedError') throw e; if (app.model[AUTH_RETRIES] >= 3) throw e; // sleep 2s to retry, max 3 times ...
[ "async", "function", "authenticate", "(", "database", ")", "{", "database", "[", "AUTH_RETRIES", "]", "=", "database", "[", "AUTH_RETRIES", "]", "||", "0", ";", "try", "{", "await", "database", ".", "authenticate", "(", ")", ";", "}", "catch", "(", "e", ...
Authenticate to test Database connection. This method will retry 3 times when database connect fail in temporary, to avoid Egg start failed. @param {Application} database instance of sequelize
[ "Authenticate", "to", "test", "Database", "connection", "." ]
04c9e72ffb1b19dbfcc42275e68fe5113eb5e2fc
https://github.com/eggjs/egg-sequelize/blob/04c9e72ffb1b19dbfcc42275e68fe5113eb5e2fc/lib/loader.js#L125-L140
train
elix/elix
src/calendar.js
copyTimeFromDateToDate
function copyTimeFromDateToDate(date1, date2) { date2.setHours(date1.getHours()); date2.setMinutes(date1.getMinutes()); date2.setSeconds(date1.getSeconds()); date2.setMilliseconds(date1.getMilliseconds()); }
javascript
function copyTimeFromDateToDate(date1, date2) { date2.setHours(date1.getHours()); date2.setMinutes(date1.getMinutes()); date2.setSeconds(date1.getSeconds()); date2.setMilliseconds(date1.getMilliseconds()); }
[ "function", "copyTimeFromDateToDate", "(", "date1", ",", "date2", ")", "{", "date2", ".", "setHours", "(", "date1", ".", "getHours", "(", ")", ")", ";", "date2", ".", "setMinutes", "(", "date1", ".", "getMinutes", "(", ")", ")", ";", "date2", ".", "set...
Update the time on date2 to match date1.
[ "Update", "the", "time", "on", "date2", "to", "match", "date1", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/calendar.js#L403-L408
train
elix/elix
src/CalendarDays.js
updateDays
function updateDays(state, forceCreation) { const { dayCount, dayRole, locale, showCompleteWeeks, startDate } = state; const workingStartDate = showCompleteWeeks ? calendar.firstDateOfWeek(startDate, locale) : calendar.midnightOnDate(startDate); let workingDayCount; if (showCompleteWeeks) { const en...
javascript
function updateDays(state, forceCreation) { const { dayCount, dayRole, locale, showCompleteWeeks, startDate } = state; const workingStartDate = showCompleteWeeks ? calendar.firstDateOfWeek(startDate, locale) : calendar.midnightOnDate(startDate); let workingDayCount; if (showCompleteWeeks) { const en...
[ "function", "updateDays", "(", "state", ",", "forceCreation", ")", "{", "const", "{", "dayCount", ",", "dayRole", ",", "locale", ",", "showCompleteWeeks", ",", "startDate", "}", "=", "state", ";", "const", "workingStartDate", "=", "showCompleteWeeks", "?", "ca...
Create days as necessary for the given state. Reuse existing day elements to the degree possible.
[ "Create", "days", "as", "necessary", "for", "the", "given", "state", ".", "Reuse", "existing", "day", "elements", "to", "the", "degree", "possible", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/CalendarDays.js#L188-L234
train
elix/elix
src/ShadowTemplateMixin.js
prepareTemplate
function prepareTemplate(element) { let template = element[symbols.template]; if (!template) { /* eslint-disable no-console */ console.warn(`ShadowTemplateMixin expects ${element.constructor.name} to define a property called [symbols.template].\nSee https://elix.org/documentation/ShadowTemplateMixin.`); ...
javascript
function prepareTemplate(element) { let template = element[symbols.template]; if (!template) { /* eslint-disable no-console */ console.warn(`ShadowTemplateMixin expects ${element.constructor.name} to define a property called [symbols.template].\nSee https://elix.org/documentation/ShadowTemplateMixin.`); ...
[ "function", "prepareTemplate", "(", "element", ")", "{", "let", "template", "=", "element", "[", "symbols", ".", "template", "]", ";", "if", "(", "!", "template", ")", "{", "/* eslint-disable no-console */", "console", ".", "warn", "(", "`", "${", "element",...
Retrieve an element's template and prepare it for use.
[ "Retrieve", "an", "element", "s", "template", "and", "prepare", "it", "for", "use", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/ShadowTemplateMixin.js#L129-L152
train
elix/elix
src/PopupSource.js
measurePopup
function measurePopup(element) { const windowHeight = window.innerHeight; const windowWidth = window.innerWidth; const popupRect = element.$.popup.getBoundingClientRect(); const popupHeight = popupRect.height; const popupWidth = popupRect.width; const sourceRect = element.getBoundingClientRect(); con...
javascript
function measurePopup(element) { const windowHeight = window.innerHeight; const windowWidth = window.innerWidth; const popupRect = element.$.popup.getBoundingClientRect(); const popupHeight = popupRect.height; const popupWidth = popupRect.width; const sourceRect = element.getBoundingClientRect(); con...
[ "function", "measurePopup", "(", "element", ")", "{", "const", "windowHeight", "=", "window", ".", "innerHeight", ";", "const", "windowWidth", "=", "window", ".", "innerWidth", ";", "const", "popupRect", "=", "element", ".", "$", ".", "popup", ".", "getBound...
If we haven't already measured the popup since it was opened, measure its dimensions and the relevant distances in which the popup might be opened.
[ "If", "we", "haven", "t", "already", "measured", "the", "popup", "since", "it", "was", "opened", "measure", "its", "dimensions", "and", "the", "relevant", "distances", "in", "which", "the", "popup", "might", "be", "opened", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/PopupSource.js#L454-L482
train
elix/elix
demos/src/LocaleSelector.js
getLocaleOptions
function getLocaleOptions() { if (!localeOptions) { localeOptions = Object.keys(locales).map(locale => { const option = document.createElement('option'); option.value = locale; option.disabled = !localeSupported(locale); option.textContent = locales[locale]; return option; }); ...
javascript
function getLocaleOptions() { if (!localeOptions) { localeOptions = Object.keys(locales).map(locale => { const option = document.createElement('option'); option.value = locale; option.disabled = !localeSupported(locale); option.textContent = locales[locale]; return option; }); ...
[ "function", "getLocaleOptions", "(", ")", "{", "if", "(", "!", "localeOptions", ")", "{", "localeOptions", "=", "Object", ".", "keys", "(", "locales", ")", ".", "map", "(", "locale", "=>", "{", "const", "option", "=", "document", ".", "createElement", "(...
Create options for all locales and cache the result.
[ "Create", "options", "for", "all", "locales", "and", "cache", "the", "result", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/demos/src/LocaleSelector.js#L361-L373
train
elix/elix
demos/src/LocaleSelector.js
localeSupported
function localeSupported(locale) { const language = locale.split('-')[0]; if (language === 'en') { // Assume all flavors of English are supported. return true; } // Try formatting a Tuesday date, and if we get the English result "Tue", // the browser probably doesn't support the locale, and used the d...
javascript
function localeSupported(locale) { const language = locale.split('-')[0]; if (language === 'en') { // Assume all flavors of English are supported. return true; } // Try formatting a Tuesday date, and if we get the English result "Tue", // the browser probably doesn't support the locale, and used the d...
[ "function", "localeSupported", "(", "locale", ")", "{", "const", "language", "=", "locale", ".", "split", "(", "'-'", ")", "[", "0", "]", ";", "if", "(", "language", "===", "'en'", ")", "{", "// Assume all flavors of English are supported.", "return", "true", ...
Heuristic that returns true if the given locale is supported.
[ "Heuristic", "that", "returns", "true", "if", "the", "given", "locale", "is", "supported", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/demos/src/LocaleSelector.js#L377-L390
train
elix/elix
src/DialogModalityMixin.js
disableDocumentScrolling
function disableDocumentScrolling(element) { if (!document.documentElement) { return; } const documentWidth = document.documentElement.clientWidth; const scrollBarWidth = window.innerWidth - documentWidth; element[previousBodyOverflowKey] = document.body.style.overflow; element[previousDocumentMarginRig...
javascript
function disableDocumentScrolling(element) { if (!document.documentElement) { return; } const documentWidth = document.documentElement.clientWidth; const scrollBarWidth = window.innerWidth - documentWidth; element[previousBodyOverflowKey] = document.body.style.overflow; element[previousDocumentMarginRig...
[ "function", "disableDocumentScrolling", "(", "element", ")", "{", "if", "(", "!", "document", ".", "documentElement", ")", "{", "return", ";", "}", "const", "documentWidth", "=", "document", ".", "documentElement", ".", "clientWidth", ";", "const", "scrollBarWid...
Mark body as non-scrollable, to absorb space bar keypresses and other means of scrolling the top-level document.
[ "Mark", "body", "as", "non", "-", "scrollable", "to", "absorb", "space", "bar", "keypresses", "and", "other", "means", "of", "scrolling", "the", "top", "-", "level", "document", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/DialogModalityMixin.js#L88-L102
train
elix/elix
src/OverlayMixin.js
openedChanged
function openedChanged(element) { if (element.state.autoFocus) { if (element.state.opened) { // Opened if (!element[restoreFocusToElementKey] && document.activeElement !== document.body) { // Remember which element had the focus before we were opened. element[restoreFocusToElementKey] ...
javascript
function openedChanged(element) { if (element.state.autoFocus) { if (element.state.opened) { // Opened if (!element[restoreFocusToElementKey] && document.activeElement !== document.body) { // Remember which element had the focus before we were opened. element[restoreFocusToElementKey] ...
[ "function", "openedChanged", "(", "element", ")", "{", "if", "(", "element", ".", "state", ".", "autoFocus", ")", "{", "if", "(", "element", ".", "state", ".", "opened", ")", "{", "// Opened", "if", "(", "!", "element", "[", "restoreFocusToElementKey", "...
Update the overlay following a change in opened state.
[ "Update", "the", "overlay", "following", "a", "change", "in", "opened", "state", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/OverlayMixin.js#L151-L181
train
elix/elix
tasks/buildWeekData.js
formatWeekDataAsModule
function formatWeekDataAsModule(weekData) { const date = new Date(); const { firstDay, weekendEnd, weekendStart } = weekData; const transformed = { firstDay: transformWeekDays(firstDay), weekendEnd: transformWeekDays(weekendEnd), weekendStart: transformWeekDays(weekendStart) }; const formatted = J...
javascript
function formatWeekDataAsModule(weekData) { const date = new Date(); const { firstDay, weekendEnd, weekendStart } = weekData; const transformed = { firstDay: transformWeekDays(firstDay), weekendEnd: transformWeekDays(weekendEnd), weekendStart: transformWeekDays(weekendStart) }; const formatted = J...
[ "function", "formatWeekDataAsModule", "(", "weekData", ")", "{", "const", "date", "=", "new", "Date", "(", ")", ";", "const", "{", "firstDay", ",", "weekendEnd", ",", "weekendStart", "}", "=", "weekData", ";", "const", "transformed", "=", "{", "firstDay", ...
Extract the week data we care about and format it as an ES6 module.
[ "Extract", "the", "week", "data", "we", "care", "about", "and", "format", "it", "as", "an", "ES6", "module", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/tasks/buildWeekData.js#L33-L49
train
elix/elix
src/AutoSizeTextarea.js
getTextFromContent
function getTextFromContent(contentNodes) { if (contentNodes === null) { return ''; } const texts = [...contentNodes].map(node => node.textContent); const text = texts.join('').trim(); return unescapeHtml(text); }
javascript
function getTextFromContent(contentNodes) { if (contentNodes === null) { return ''; } const texts = [...contentNodes].map(node => node.textContent); const text = texts.join('').trim(); return unescapeHtml(text); }
[ "function", "getTextFromContent", "(", "contentNodes", ")", "{", "if", "(", "contentNodes", "===", "null", ")", "{", "return", "''", ";", "}", "const", "texts", "=", "[", "...", "contentNodes", "]", ".", "map", "(", "node", "=>", "node", ".", "textConten...
Return the text represented by the given content nodes.
[ "Return", "the", "text", "represented", "by", "the", "given", "content", "nodes", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/AutoSizeTextarea.js#L255-L262
train
elix/elix
src/State.js
isEmpty
function isEmpty(o) { for (var key in o) { if (o.hasOwnProperty(key)) { return false; } } return Object.getOwnPropertySymbols(o).length === 0; }
javascript
function isEmpty(o) { for (var key in o) { if (o.hasOwnProperty(key)) { return false; } } return Object.getOwnPropertySymbols(o).length === 0; }
[ "function", "isEmpty", "(", "o", ")", "{", "for", "(", "var", "key", "in", "o", ")", "{", "if", "(", "o", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "return", "false", ";", "}", "}", "return", "Object", ".", "getOwnPropertySymbols", "(", "o"...
Return true if o is an empty object.
[ "Return", "true", "if", "o", "is", "an", "empty", "object", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/State.js#L93-L100
train
elix/elix
src/PageNumbersMixin.js
PageNumbersMixin
function PageNumbersMixin(Base) { class PageNumbers extends Base { /** * Destructively wrap a node with elements to show page numbers. * * @param {Node} original - the element that should be wrapped by page numbers */ [wrap](original) { const pageNumbersTemplate = template.html` ...
javascript
function PageNumbersMixin(Base) { class PageNumbers extends Base { /** * Destructively wrap a node with elements to show page numbers. * * @param {Node} original - the element that should be wrapped by page numbers */ [wrap](original) { const pageNumbersTemplate = template.html` ...
[ "function", "PageNumbersMixin", "(", "Base", ")", "{", "class", "PageNumbers", "extends", "Base", "{", "/**\n * Destructively wrap a node with elements to show page numbers.\n * \n * @param {Node} original - the element that should be wrapped by page numbers\n */", "[", "wr...
Adds a page number and total page count to a carousel-like element. This can be applied to components like [Carousel](Carousel) that renders their content as pages. @module PageNumbersMixin
[ "Adds", "a", "page", "number", "and", "total", "page", "count", "to", "a", "carousel", "-", "like", "element", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/PageNumbersMixin.js#L16-L61
train
elix/elix
src/AttributeMarshallingMixin.js
attributeToPropertyName
function attributeToPropertyName(attributeName) { let propertyName = attributeToPropertyNames[attributeName]; if (!propertyName) { // Convert and memoize. const hyphenRegEx = /-([a-z])/g; propertyName = attributeName.replace(hyphenRegEx, match => match[1].toUpperCase()); attributeToPropertyN...
javascript
function attributeToPropertyName(attributeName) { let propertyName = attributeToPropertyNames[attributeName]; if (!propertyName) { // Convert and memoize. const hyphenRegEx = /-([a-z])/g; propertyName = attributeName.replace(hyphenRegEx, match => match[1].toUpperCase()); attributeToPropertyN...
[ "function", "attributeToPropertyName", "(", "attributeName", ")", "{", "let", "propertyName", "=", "attributeToPropertyNames", "[", "attributeName", "]", ";", "if", "(", "!", "propertyName", ")", "{", "// Convert and memoize.", "const", "hyphenRegEx", "=", "/", "-([...
Convert hyphenated foo-bar attribute name to camel case fooBar property name.
[ "Convert", "hyphenated", "foo", "-", "bar", "attribute", "name", "to", "camel", "case", "fooBar", "property", "name", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/AttributeMarshallingMixin.js#L126-L136
train
elix/elix
src/AttributeMarshallingMixin.js
propertyNameToAttribute
function propertyNameToAttribute(propertyName) { let attribute = propertyNamesToAttributes[propertyName]; if (!attribute) { // Convert and memoize. const uppercaseRegEx = /([A-Z])/g; attribute = propertyName.replace(uppercaseRegEx, '-$1').toLowerCase(); } return attribute; }
javascript
function propertyNameToAttribute(propertyName) { let attribute = propertyNamesToAttributes[propertyName]; if (!attribute) { // Convert and memoize. const uppercaseRegEx = /([A-Z])/g; attribute = propertyName.replace(uppercaseRegEx, '-$1').toLowerCase(); } return attribute; }
[ "function", "propertyNameToAttribute", "(", "propertyName", ")", "{", "let", "attribute", "=", "propertyNamesToAttributes", "[", "propertyName", "]", ";", "if", "(", "!", "attribute", ")", "{", "// Convert and memoize.", "const", "uppercaseRegEx", "=", "/", "([A-Z])...
Convert a camel case fooBar property name to a hyphenated foo-bar attribute.
[ "Convert", "a", "camel", "case", "fooBar", "property", "name", "to", "a", "hyphenated", "foo", "-", "bar", "attribute", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/AttributeMarshallingMixin.js#L154-L162
train
elix/elix
src/SlotContentMixin.js
assignedNodesChanged
function assignedNodesChanged(component) { const slot = component[symbols.contentSlot]; const content = slot ? slot.assignedNodes({ flatten: true }) : null; // Make immutable. Object.freeze(content); component.setState({ content }); }
javascript
function assignedNodesChanged(component) { const slot = component[symbols.contentSlot]; const content = slot ? slot.assignedNodes({ flatten: true }) : null; // Make immutable. Object.freeze(content); component.setState({ content }); }
[ "function", "assignedNodesChanged", "(", "component", ")", "{", "const", "slot", "=", "component", "[", "symbols", ".", "contentSlot", "]", ";", "const", "content", "=", "slot", "?", "slot", ".", "assignedNodes", "(", "{", "flatten", ":", "true", "}", ")",...
The nodes assigned to the given component have changed. Update the component's state to reflect the new content.
[ "The", "nodes", "assigned", "to", "the", "given", "component", "have", "changed", ".", "Update", "the", "component", "s", "state", "to", "reflect", "the", "new", "content", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/SlotContentMixin.js#L147-L158
train
elix/elix
src/FocusCaptureMixin.js
FocusCaptureMixin
function FocusCaptureMixin(base) { class FocusCapture extends base { componentDidMount() { if (super.componentDidMount) { super.componentDidMount(); } this.$.focusCatcher.addEventListener('focus', () => { if (!this[wrappingFocusKey]) { // Wrap focus back to the first focusable elem...
javascript
function FocusCaptureMixin(base) { class FocusCapture extends base { componentDidMount() { if (super.componentDidMount) { super.componentDidMount(); } this.$.focusCatcher.addEventListener('focus', () => { if (!this[wrappingFocusKey]) { // Wrap focus back to the first focusable elem...
[ "function", "FocusCaptureMixin", "(", "base", ")", "{", "class", "FocusCapture", "extends", "base", "{", "componentDidMount", "(", ")", "{", "if", "(", "super", ".", "componentDidMount", ")", "{", "super", ".", "componentDidMount", "(", ")", ";", "}", "this"...
Allows Tab and Shift+Tab operations to cycle the focus within the component. This mixin expects the component to provide: * A template-stamping mechanism compatible with `ShadowTemplateMixin`. The mixin provides these features to the component: * Template elements and event handlers that will cause the keyboard foc...
[ "Allows", "Tab", "and", "Shift", "+", "Tab", "operations", "to", "cycle", "the", "focus", "within", "the", "component", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/FocusCaptureMixin.js#L28-L84
train
elix/elix
src/PullToRefresh.js
handleScrollPull
async function handleScrollPull(element, scrollTarget) { const scrollTop = scrollTarget === window ? document.body.scrollTop : scrollTarget.scrollTop; if (scrollTop < 0) { // Negative scroll top means we're probably in WebKit. // Start a scroll pull operation. let scrollPullDistance = -scrollTop...
javascript
async function handleScrollPull(element, scrollTarget) { const scrollTop = scrollTarget === window ? document.body.scrollTop : scrollTarget.scrollTop; if (scrollTop < 0) { // Negative scroll top means we're probably in WebKit. // Start a scroll pull operation. let scrollPullDistance = -scrollTop...
[ "async", "function", "handleScrollPull", "(", "element", ",", "scrollTarget", ")", "{", "const", "scrollTop", "=", "scrollTarget", "===", "window", "?", "document", ".", "body", ".", "scrollTop", ":", "scrollTarget", ".", "scrollTop", ";", "if", "(", "scrollTo...
If a user flicks down to quickly scroll up, and scrolls past the top of the page, the area above the page may be shown briefly. We use that opportunity to show the user the refresh header so they'll realize they can pull to refresh. We call this operation a "scroll pull". It works a little like a real touch drag, but c...
[ "If", "a", "user", "flicks", "down", "to", "quickly", "scroll", "up", "and", "scrolls", "past", "the", "top", "of", "the", "page", "the", "area", "above", "the", "page", "may", "be", "shown", "briefly", ".", "We", "use", "that", "opportunity", "to", "s...
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/PullToRefresh.js#L303-L331
train
elix/elix
src/TimerSelectionMixin.js
updateTimer
function updateTimer(element) { // If the element is playing and we haven't started a timer yet, do so now. // Also, if the element's selectedIndex changed for any reason, restart the // timer. This ensures that the timer restarts no matter why the selection // changes: it could have been us moving to the next ...
javascript
function updateTimer(element) { // If the element is playing and we haven't started a timer yet, do so now. // Also, if the element's selectedIndex changed for any reason, restart the // timer. This ensures that the timer restarts no matter why the selection // changes: it could have been us moving to the next ...
[ "function", "updateTimer", "(", "element", ")", "{", "// If the element is playing and we haven't started a timer yet, do so now.", "// Also, if the element's selectedIndex changed for any reason, restart the", "// timer. This ensures that the timer restarts no matter why the selection", "// chang...
Update the timer to match the element's `playing` state.
[ "Update", "the", "timer", "to", "match", "the", "element", "s", "playing", "state", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/TimerSelectionMixin.js#L134-L146
train
elix/elix
src/TrackpadSwipeMixin.js
resetWheelTracking
function resetWheelTracking(element) { element[wheelDistanceSymbol] = 0; element[lastDeltaXSymbol] = 0; element[absorbDecelerationSymbol] = false; element[postNavigateDelayCompleteSymbol] = false; if (element[lastWheelTimeoutSymbol]) { clearTimeout(element[lastWheelTimeoutSymbol]); element[lastWheelTi...
javascript
function resetWheelTracking(element) { element[wheelDistanceSymbol] = 0; element[lastDeltaXSymbol] = 0; element[absorbDecelerationSymbol] = false; element[postNavigateDelayCompleteSymbol] = false; if (element[lastWheelTimeoutSymbol]) { clearTimeout(element[lastWheelTimeoutSymbol]); element[lastWheelTi...
[ "function", "resetWheelTracking", "(", "element", ")", "{", "element", "[", "wheelDistanceSymbol", "]", "=", "0", ";", "element", "[", "lastDeltaXSymbol", "]", "=", "0", ";", "element", "[", "absorbDecelerationSymbol", "]", "=", "false", ";", "element", "[", ...
Reset all state related to the tracking of the wheel.
[ "Reset", "all", "state", "related", "to", "the", "tracking", "of", "the", "wheel", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/TrackpadSwipeMixin.js#L171-L180
train
elix/elix
src/KeyboardPrefixSelectionMixin.js
handlePlainCharacter
function handlePlainCharacter(element, char) { const prefix = element[typedPrefixKey] || ''; element[typedPrefixKey] = prefix + char; element.selectItemWithTextPrefix(element[typedPrefixKey]); setPrefixTimeout(element); }
javascript
function handlePlainCharacter(element, char) { const prefix = element[typedPrefixKey] || ''; element[typedPrefixKey] = prefix + char; element.selectItemWithTextPrefix(element[typedPrefixKey]); setPrefixTimeout(element); }
[ "function", "handlePlainCharacter", "(", "element", ",", "char", ")", "{", "const", "prefix", "=", "element", "[", "typedPrefixKey", "]", "||", "''", ";", "element", "[", "typedPrefixKey", "]", "=", "prefix", "+", "char", ";", "element", ".", "selectItemWith...
Add a plain character to the prefix.
[ "Add", "a", "plain", "character", "to", "the", "prefix", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/KeyboardPrefixSelectionMixin.js#L122-L127
train
elix/elix
src/KeyboardPrefixSelectionMixin.js
resetPrefixTimeout
function resetPrefixTimeout(element) { if (element[prefixTimeoutKey]) { clearTimeout(element[prefixTimeoutKey]); element[prefixTimeoutKey] = false; } }
javascript
function resetPrefixTimeout(element) { if (element[prefixTimeoutKey]) { clearTimeout(element[prefixTimeoutKey]); element[prefixTimeoutKey] = false; } }
[ "function", "resetPrefixTimeout", "(", "element", ")", "{", "if", "(", "element", "[", "prefixTimeoutKey", "]", ")", "{", "clearTimeout", "(", "element", "[", "prefixTimeoutKey", "]", ")", ";", "element", "[", "prefixTimeoutKey", "]", "=", "false", ";", "}",...
Stop listening for typing.
[ "Stop", "listening", "for", "typing", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/KeyboardPrefixSelectionMixin.js#L130-L135
train
elix/elix
src/KeyboardPrefixSelectionMixin.js
setPrefixTimeout
function setPrefixTimeout(element) { resetPrefixTimeout(element); element[prefixTimeoutKey] = setTimeout(() => { resetTypedPrefix(element); }, TYPING_TIMEOUT_DURATION); }
javascript
function setPrefixTimeout(element) { resetPrefixTimeout(element); element[prefixTimeoutKey] = setTimeout(() => { resetTypedPrefix(element); }, TYPING_TIMEOUT_DURATION); }
[ "function", "setPrefixTimeout", "(", "element", ")", "{", "resetPrefixTimeout", "(", "element", ")", ";", "element", "[", "prefixTimeoutKey", "]", "=", "setTimeout", "(", "(", ")", "=>", "{", "resetTypedPrefix", "(", "element", ")", ";", "}", ",", "TYPING_TI...
Wait for the user to stop typing.
[ "Wait", "for", "the", "user", "to", "stop", "typing", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/KeyboardPrefixSelectionMixin.js#L144-L149
train
elix/elix
demos/src/CalendarDayMoonPhase.js
jd0
function jd0(year, month, day) { let y = year; let m = month; if (m < 3) { m += 12; y -= 1 }; const a = Math.floor(y/100); const b = 2-a+Math.floor(a/4); const j = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524.5; return j; }
javascript
function jd0(year, month, day) { let y = year; let m = month; if (m < 3) { m += 12; y -= 1 }; const a = Math.floor(y/100); const b = 2-a+Math.floor(a/4); const j = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524.5; return j; }
[ "function", "jd0", "(", "year", ",", "month", ",", "day", ")", "{", "let", "y", "=", "year", ";", "let", "m", "=", "month", ";", "if", "(", "m", "<", "3", ")", "{", "m", "+=", "12", ";", "y", "-=", "1", "}", ";", "const", "a", "=", "Math"...
The Julian date at 0 hours UT at Greenwich
[ "The", "Julian", "date", "at", "0", "hours", "UT", "at", "Greenwich" ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/demos/src/CalendarDayMoonPhase.js#L102-L113
train
elix/elix
src/Explorer.js
createDefaultProxies
function createDefaultProxies(items, proxyRole) { const proxies = items ? items.map(() => template.createElement(proxyRole)) : []; // Make the array immutable to help update performance. Object.freeze(proxies); return proxies; }
javascript
function createDefaultProxies(items, proxyRole) { const proxies = items ? items.map(() => template.createElement(proxyRole)) : []; // Make the array immutable to help update performance. Object.freeze(proxies); return proxies; }
[ "function", "createDefaultProxies", "(", "items", ",", "proxyRole", ")", "{", "const", "proxies", "=", "items", "?", "items", ".", "map", "(", "(", ")", "=>", "template", ".", "createElement", "(", "proxyRole", ")", ")", ":", "[", "]", ";", "// Make the ...
Return the default list generated for the given items.
[ "Return", "the", "default", "list", "generated", "for", "the", "given", "items", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/Explorer.js#L393-L400
train
elix/elix
src/Explorer.js
findChildContainingNode
function findChildContainingNode(root, node) { const parentNode = node.parentNode; return parentNode === root ? node : findChildContainingNode(root, parentNode); }
javascript
function findChildContainingNode(root, node) { const parentNode = node.parentNode; return parentNode === root ? node : findChildContainingNode(root, parentNode); }
[ "function", "findChildContainingNode", "(", "root", ",", "node", ")", "{", "const", "parentNode", "=", "node", ".", "parentNode", ";", "return", "parentNode", "===", "root", "?", "node", ":", "findChildContainingNode", "(", "root", ",", "parentNode", ")", ";",...
Find the child of root that is or contains the given node.
[ "Find", "the", "child", "of", "root", "that", "is", "or", "contains", "the", "given", "node", "." ]
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/Explorer.js#L404-L409
train
elix/elix
src/Explorer.js
setListAndStageOrder
function setListAndStageOrder(element) { const proxyListPosition = element.state.proxyListPosition; const rightToLeft = element[symbols.rightToLeft]; const listInInitialPosition = proxyListPosition === 'top' || proxyListPosition === 'start' || proxyListPosition === 'left' && !rightToLeft || ...
javascript
function setListAndStageOrder(element) { const proxyListPosition = element.state.proxyListPosition; const rightToLeft = element[symbols.rightToLeft]; const listInInitialPosition = proxyListPosition === 'top' || proxyListPosition === 'start' || proxyListPosition === 'left' && !rightToLeft || ...
[ "function", "setListAndStageOrder", "(", "element", ")", "{", "const", "proxyListPosition", "=", "element", ".", "state", ".", "proxyListPosition", ";", "const", "rightToLeft", "=", "element", "[", "symbols", ".", "rightToLeft", "]", ";", "const", "listInInitialPo...
Physically reorder the list and stage to reflect the desired arrangement. We could change the visual appearance by reversing the order of the flex box, but then the visual order wouldn't reflect the document order, which determines focus order. That would surprise a user trying to tab through the controls.
[ "Physically", "reorder", "the", "list", "and", "stage", "to", "reflect", "the", "desired", "arrangement", ".", "We", "could", "change", "the", "visual", "appearance", "by", "reversing", "the", "order", "of", "the", "flex", "box", "but", "then", "the", "visua...
2e5fde9777b2e6e4b9453c32d7b7007948d5892d
https://github.com/elix/elix/blob/2e5fde9777b2e6e4b9453c32d7b7007948d5892d/src/Explorer.js#L417-L433
train
adonisjs/adonis-lucid
src/Database/MonkeyPatch.js
generateAggregate
function generateAggregate (aggregateOp, defaultColumnName = undefined) { let funcName = `get${_.upperFirst(aggregateOp)}` /** * Do not re-add the method if exists */ if (KnexQueryBuilder.prototype[funcName]) { return } KnexQueryBuilder.prototype[funcName] = async function (columnName = defaultCol...
javascript
function generateAggregate (aggregateOp, defaultColumnName = undefined) { let funcName = `get${_.upperFirst(aggregateOp)}` /** * Do not re-add the method if exists */ if (KnexQueryBuilder.prototype[funcName]) { return } KnexQueryBuilder.prototype[funcName] = async function (columnName = defaultCol...
[ "function", "generateAggregate", "(", "aggregateOp", ",", "defaultColumnName", "=", "undefined", ")", "{", "let", "funcName", "=", "`", "${", "_", ".", "upperFirst", "(", "aggregateOp", ")", "}", "`", "/**\n * Do not re-add the method if exists\n */", "if", "(",...
Generates an aggregate function, that returns the aggregated result as a number. @method generateAggregate @param {String} aggregateOp @param {String} defaultColumnName @return {Number} @example ```js generateAggregate('count') ```
[ "Generates", "an", "aggregate", "function", "that", "returns", "the", "aggregated", "result", "as", "a", "number", "." ]
6cd666df9534a981f4bd99ac0812a44d1685728a
https://github.com/adonisjs/adonis-lucid/blob/6cd666df9534a981f4bd99ac0812a44d1685728a/src/Database/MonkeyPatch.js#L182-L212
train