id
int32
0
58k
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
7,600
segmentio/analytics.js
analytics.js
toCamelCase
function toCamelCase (string) { return toSpace(string).replace(/\s(\w)/g, function (matches, letter) { return letter.toUpperCase(); }); }
javascript
function toCamelCase (string) { return toSpace(string).replace(/\s(\w)/g, function (matches, letter) { return letter.toUpperCase(); }); }
[ "function", "toCamelCase", "(", "string", ")", "{", "return", "toSpace", "(", "string", ")", ".", "replace", "(", "/", "\\s(\\w)", "/", "g", ",", "function", "(", "matches", ",", "letter", ")", "{", "return", "letter", ".", "toUpperCase", "(", ")", ";"...
Convert a `string` to camel case. @param {String} string @return {String}
[ "Convert", "a", "string", "to", "camel", "case", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12734-L12738
7,601
segmentio/analytics.js
analytics.js
path
function path(properties, options) { if (!properties) return; var str = properties.path; if (options.includeSearch && properties.search) str += properties.search; return str; }
javascript
function path(properties, options) { if (!properties) return; var str = properties.path; if (options.includeSearch && properties.search) str += properties.search; return str; }
[ "function", "path", "(", "properties", ",", "options", ")", "{", "if", "(", "!", "properties", ")", "return", ";", "var", "str", "=", "properties", ".", "path", ";", "if", "(", "options", ".", "includeSearch", "&&", "properties", ".", "search", ")", "s...
Return the path based on `properties` and `options`. @param {Object} properties @param {Object} options @return {string|undefined}
[ "Return", "the", "path", "based", "on", "properties", "and", "options", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13320-L13325
7,602
segmentio/analytics.js
analytics.js
metrics
function metrics(obj, data) { var dimensions = data.dimensions; var metrics = data.metrics; var names = keys(metrics).concat(keys(dimensions)); var ret = {}; for (var i = 0; i < names.length; ++i) { var name = names[i]; var key = metrics[name] || dimensions[name]; var value = dot(obj, name) || ob...
javascript
function metrics(obj, data) { var dimensions = data.dimensions; var metrics = data.metrics; var names = keys(metrics).concat(keys(dimensions)); var ret = {}; for (var i = 0; i < names.length; ++i) { var name = names[i]; var key = metrics[name] || dimensions[name]; var value = dot(obj, name) || ob...
[ "function", "metrics", "(", "obj", ",", "data", ")", "{", "var", "dimensions", "=", "data", ".", "dimensions", ";", "var", "metrics", "=", "data", ".", "metrics", ";", "var", "names", "=", "keys", "(", "metrics", ")", ".", "concat", "(", "keys", "(",...
Map google's custom dimensions & metrics with `obj`. Example: metrics({ revenue: 1.9 }, { { metrics : { revenue: 'metric8' } }); // => { metric8: 1.9 } metrics({ revenue: 1.9 }, {}); // => {} @param {Object} obj @param {Object} data @return {Object|null} @api private
[ "Map", "google", "s", "custom", "dimensions", "&", "metrics", "with", "obj", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13356-L13371
7,603
segmentio/analytics.js
analytics.js
enhancedEcommerceTrackProduct
function enhancedEcommerceTrackProduct(track) { var props = track.properties(); window.ga('ec:addProduct', { id: track.id() || track.sku(), name: track.name(), category: track.category(), quantity: track.quantity(), price: track.price(), brand: props.brand, variant: props.variant, c...
javascript
function enhancedEcommerceTrackProduct(track) { var props = track.properties(); window.ga('ec:addProduct', { id: track.id() || track.sku(), name: track.name(), category: track.category(), quantity: track.quantity(), price: track.price(), brand: props.brand, variant: props.variant, c...
[ "function", "enhancedEcommerceTrackProduct", "(", "track", ")", "{", "var", "props", "=", "track", ".", "properties", "(", ")", ";", "window", ".", "ga", "(", "'ec:addProduct'", ",", "{", "id", ":", "track", ".", "id", "(", ")", "||", "track", ".", "sk...
Enhanced ecommerce track product. Simple helper so that we don't repeat `ec:addProduct` everywhere. @api private @param {Track} track
[ "Enhanced", "ecommerce", "track", "product", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13674-L13687
7,604
segmentio/analytics.js
analytics.js
enhancedEcommerceProductAction
function enhancedEcommerceProductAction(track, action, data) { enhancedEcommerceTrackProduct(track); window.ga('ec:setAction', action, data || {}); }
javascript
function enhancedEcommerceProductAction(track, action, data) { enhancedEcommerceTrackProduct(track); window.ga('ec:setAction', action, data || {}); }
[ "function", "enhancedEcommerceProductAction", "(", "track", ",", "action", ",", "data", ")", "{", "enhancedEcommerceTrackProduct", "(", "track", ")", ";", "window", ".", "ga", "(", "'ec:setAction'", ",", "action", ",", "data", "||", "{", "}", ")", ";", "}" ]
Set `action` on `track` with `data`. @api private @param {Track} track @param {String} action @param {Object} data
[ "Set", "action", "on", "track", "with", "data", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13698-L13701
7,605
segmentio/analytics.js
analytics.js
extractCheckoutOptions
function extractCheckoutOptions(props) { var options = [ props.paymentMethod, props.shippingMethod ]; // Remove all nulls, empty strings, zeroes, and join with commas. var valid = select(options, function(e) {return e; }); return valid.length > 0 ? valid.join(', ') : null; }
javascript
function extractCheckoutOptions(props) { var options = [ props.paymentMethod, props.shippingMethod ]; // Remove all nulls, empty strings, zeroes, and join with commas. var valid = select(options, function(e) {return e; }); return valid.length > 0 ? valid.join(', ') : null; }
[ "function", "extractCheckoutOptions", "(", "props", ")", "{", "var", "options", "=", "[", "props", ".", "paymentMethod", ",", "props", ".", "shippingMethod", "]", ";", "// Remove all nulls, empty strings, zeroes, and join with commas.", "var", "valid", "=", "select", ...
Extracts checkout options. @api private @param {Object} props @return {string|null}
[ "Extracts", "checkout", "options", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13711-L13720
7,606
segmentio/analytics.js
analytics.js
createProductTrack
function createProductTrack(track, properties) { properties.currency = properties.currency || track.currency(); return new Track({ properties: properties }); }
javascript
function createProductTrack(track, properties) { properties.currency = properties.currency || track.currency(); return new Track({ properties: properties }); }
[ "function", "createProductTrack", "(", "track", ",", "properties", ")", "{", "properties", ".", "currency", "=", "properties", ".", "currency", "||", "track", ".", "currency", "(", ")", ";", "return", "new", "Track", "(", "{", "properties", ":", "properties"...
Creates a track out of product properties. @api private @param {Track} track @param {Object} properties @return {Track}
[ "Creates", "a", "track", "out", "of", "product", "properties", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13731-L13734
7,607
segmentio/analytics.js
analytics.js
push
function push() { window._gs = window._gs || function() { window._gs.q.push(arguments); }; window._gs.q = window._gs.q || []; window._gs.apply(null, arguments); }
javascript
function push() { window._gs = window._gs || function() { window._gs.q.push(arguments); }; window._gs.q = window._gs.q || []; window._gs.apply(null, arguments); }
[ "function", "push", "(", ")", "{", "window", ".", "_gs", "=", "window", ".", "_gs", "||", "function", "(", ")", "{", "window", ".", "_gs", ".", "q", ".", "push", "(", "arguments", ")", ";", "}", ";", "window", ".", "_gs", ".", "q", "=", "window...
Push to `_gs.q`. @api private @param {...*} args
[ "Push", "to", "_gs", ".", "q", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14041-L14047
7,608
segmentio/analytics.js
analytics.js
omit
function omit(keys, object){ var ret = {}; for (var item in object) { ret[item] = object[item]; } for (var i = 0; i < keys.length; i++) { delete ret[keys[i]]; } return ret; }
javascript
function omit(keys, object){ var ret = {}; for (var item in object) { ret[item] = object[item]; } for (var i = 0; i < keys.length; i++) { delete ret[keys[i]]; } return ret; }
[ "function", "omit", "(", "keys", ",", "object", ")", "{", "var", "ret", "=", "{", "}", ";", "for", "(", "var", "item", "in", "object", ")", "{", "ret", "[", "item", "]", "=", "object", "[", "item", "]", ";", "}", "for", "(", "var", "i", "=", ...
Return a copy of the object without the specified keys. @param {Array} keys @param {Object} object @return {Object}
[ "Return", "a", "copy", "of", "the", "object", "without", "the", "specified", "keys", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14065-L14076
7,609
segmentio/analytics.js
analytics.js
pick
function pick(obj){ var keys = [].slice.call(arguments, 1); var ret = {}; for (var i = 0, key; key = keys[i]; i++) { if (key in obj) ret[key] = obj[key]; } return ret; }
javascript
function pick(obj){ var keys = [].slice.call(arguments, 1); var ret = {}; for (var i = 0, key; key = keys[i]; i++) { if (key in obj) ret[key] = obj[key]; } return ret; }
[ "function", "pick", "(", "obj", ")", "{", "var", "keys", "=", "[", "]", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "var", "ret", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "key", ";", "key", "=", "keys"...
Pick keys from an `obj`. @param {Object} obj @param {Strings} keys... @return {Object}
[ "Pick", "keys", "from", "an", "obj", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14094-L14103
7,610
segmentio/analytics.js
analytics.js
prefix
function prefix(event, properties) { var prefixed = {}; each(properties, function(key, val) { if (key === 'Billing Amount') { prefixed[key] = val; } else { prefixed[event + ' - ' + key] = val; } }); return prefixed; }
javascript
function prefix(event, properties) { var prefixed = {}; each(properties, function(key, val) { if (key === 'Billing Amount') { prefixed[key] = val; } else { prefixed[event + ' - ' + key] = val; } }); return prefixed; }
[ "function", "prefix", "(", "event", ",", "properties", ")", "{", "var", "prefixed", "=", "{", "}", ";", "each", "(", "properties", ",", "function", "(", "key", ",", "val", ")", "{", "if", "(", "key", "===", "'Billing Amount'", ")", "{", "prefixed", "...
Prefix properties with the event name. @param {String} event @param {Object} properties @return {Object} prefixed @api private
[ "Prefix", "properties", "with", "the", "event", "name", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15282-L15292
7,611
segmentio/analytics.js
analytics.js
convert
function convert(traits) { var arr = []; each(traits, function(key, value) { arr.push({ name: key, value: value }); }); return arr; }
javascript
function convert(traits) { var arr = []; each(traits, function(key, value) { arr.push({ name: key, value: value }); }); return arr; }
[ "function", "convert", "(", "traits", ")", "{", "var", "arr", "=", "[", "]", ";", "each", "(", "traits", ",", "function", "(", "key", ",", "value", ")", "{", "arr", ".", "push", "(", "{", "name", ":", "key", ",", "value", ":", "value", "}", ")"...
Convert a traits object into the format LiveChat requires. @param {Object} traits @return {Array}
[ "Convert", "a", "traits", "object", "into", "the", "format", "LiveChat", "requires", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15533-L15539
7,612
segmentio/analytics.js
analytics.js
lowercase
function lowercase(arr) { var ret = new Array(arr.length); for (var i = 0; i < arr.length; ++i) { ret[i] = String(arr[i]).toLowerCase(); } return ret; }
javascript
function lowercase(arr) { var ret = new Array(arr.length); for (var i = 0; i < arr.length; ++i) { ret[i] = String(arr[i]).toLowerCase(); } return ret; }
[ "function", "lowercase", "(", "arr", ")", "{", "var", "ret", "=", "new", "Array", "(", "arr", ".", "length", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "++", "i", ")", "{", "ret", "[", "i", "]", "=...
Lowercase the given `arr`. @api private @param {Array} arr @return {Array}
[ "Lowercase", "the", "given", "arr", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15932-L15940
7,613
segmentio/analytics.js
analytics.js
ads
function ads(query){ var params = parse(query); for (var key in params) { for (var id in QUERYIDS) { if (key === id) { return { id : params[key], type : QUERYIDS[id] }; } } } }
javascript
function ads(query){ var params = parse(query); for (var key in params) { for (var id in QUERYIDS) { if (key === id) { return { id : params[key], type : QUERYIDS[id] }; } } } }
[ "function", "ads", "(", "query", ")", "{", "var", "params", "=", "parse", "(", "query", ")", ";", "for", "(", "var", "key", "in", "params", ")", "{", "for", "(", "var", "id", "in", "QUERYIDS", ")", "{", "if", "(", "key", "===", "id", ")", "{", ...
Get all ads info from the given `querystring` @param {String} query @return {Object} @api private
[ "Get", "all", "ads", "info", "from", "the", "given", "querystring" ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18200-L18212
7,614
segmentio/analytics.js
analytics.js
store
function store(key, value){ var length = arguments.length; if (0 == length) return all(); if (2 <= length) return set(key, value); if (1 != length) return; if (null == key) return storage.clear(); if ('string' == typeof key) return get(key); if ('object' == typeof key) return each(key, set); }
javascript
function store(key, value){ var length = arguments.length; if (0 == length) return all(); if (2 <= length) return set(key, value); if (1 != length) return; if (null == key) return storage.clear(); if ('string' == typeof key) return get(key); if ('object' == typeof key) return each(key, set); }
[ "function", "store", "(", "key", ",", "value", ")", "{", "var", "length", "=", "arguments", ".", "length", ";", "if", "(", "0", "==", "length", ")", "return", "all", "(", ")", ";", "if", "(", "2", "<=", "length", ")", "return", "set", "(", "key",...
Store the given `key`, `val`. @param {String|Object} key @param {Mixed} value @return {Mixed} @api public
[ "Store", "the", "given", "key", "val", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18250-L18258
7,615
segmentio/analytics.js
analytics.js
set
function set(key, val){ return null == val ? storage.removeItem(key) : storage.setItem(key, JSON.stringify(val)); }
javascript
function set(key, val){ return null == val ? storage.removeItem(key) : storage.setItem(key, JSON.stringify(val)); }
[ "function", "set", "(", "key", ",", "val", ")", "{", "return", "null", "==", "val", "?", "storage", ".", "removeItem", "(", "key", ")", ":", "storage", ".", "setItem", "(", "key", ",", "JSON", ".", "stringify", "(", "val", ")", ")", ";", "}" ]
Set `key` to `val`. @param {String} key @param {Mixed} val
[ "Set", "key", "to", "val", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18273-L18277
7,616
segmentio/analytics.js
analytics.js
all
function all(){ var len = storage.length; var ret = {}; var key; while (0 <= --len) { key = storage.key(len); ret[key] = get(key); } return ret; }
javascript
function all(){ var len = storage.length; var ret = {}; var key; while (0 <= --len) { key = storage.key(len); ret[key] = get(key); } return ret; }
[ "function", "all", "(", ")", "{", "var", "len", "=", "storage", ".", "length", ";", "var", "ret", "=", "{", "}", ";", "var", "key", ";", "while", "(", "0", "<=", "--", "len", ")", "{", "key", "=", "storage", ".", "key", "(", "len", ")", ";", ...
Get all. @return {Object}
[ "Get", "all", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18296-L18307
7,617
segmentio/analytics.js
analytics.js
set
function set (protocol) { try { define(window.location, 'protocol', { get: function () { return protocol; } }); } catch (err) { mockedProtocol = protocol; } }
javascript
function set (protocol) { try { define(window.location, 'protocol', { get: function () { return protocol; } }); } catch (err) { mockedProtocol = protocol; } }
[ "function", "set", "(", "protocol", ")", "{", "try", "{", "define", "(", "window", ".", "location", ",", "'protocol'", ",", "{", "get", ":", "function", "(", ")", "{", "return", "protocol", ";", "}", "}", ")", ";", "}", "catch", "(", "err", ")", ...
Sets the protocol @param {String} protocol
[ "Sets", "the", "protocol" ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18400-L18408
7,618
segmentio/analytics.js
analytics.js
formatOptions
function formatOptions(options) { return alias(options, { forumId: 'forum_id', accentColor: 'accent_color', smartvote: 'smartvote_enabled', triggerColor: 'trigger_color', triggerBackgroundColor: 'trigger_background_color', triggerPosition: 'trigger_position', screenshotEnabled: 'screenshot...
javascript
function formatOptions(options) { return alias(options, { forumId: 'forum_id', accentColor: 'accent_color', smartvote: 'smartvote_enabled', triggerColor: 'trigger_color', triggerBackgroundColor: 'trigger_background_color', triggerPosition: 'trigger_position', screenshotEnabled: 'screenshot...
[ "function", "formatOptions", "(", "options", ")", "{", "return", "alias", "(", "options", ",", "{", "forumId", ":", "'forum_id'", ",", "accentColor", ":", "'accent_color'", ",", "smartvote", ":", "'smartvote_enabled'", ",", "triggerColor", ":", "'trigger_color'", ...
Format the options for UserVoice. @api private @param {Object} options @return {Object}
[ "Format", "the", "options", "for", "UserVoice", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L19716-L19727
7,619
segmentio/analytics.js
analytics.js
formatClassicOptions
function formatClassicOptions(options) { return alias(options, { forumId: 'forum_id', classicMode: 'mode', primaryColor: 'primary_color', tabPosition: 'tab_position', tabColor: 'tab_color', linkColor: 'link_color', defaultMode: 'default_mode', tabLabel: 'tab_label', tabInverted: 't...
javascript
function formatClassicOptions(options) { return alias(options, { forumId: 'forum_id', classicMode: 'mode', primaryColor: 'primary_color', tabPosition: 'tab_position', tabColor: 'tab_color', linkColor: 'link_color', defaultMode: 'default_mode', tabLabel: 'tab_label', tabInverted: 't...
[ "function", "formatClassicOptions", "(", "options", ")", "{", "return", "alias", "(", "options", ",", "{", "forumId", ":", "'forum_id'", ",", "classicMode", ":", "'mode'", ",", "primaryColor", ":", "'primary_color'", ",", "tabPosition", ":", "'tab_position'", ",...
Format the classic options for UserVoice. @api private @param {Object} options @return {Object}
[ "Format", "the", "classic", "options", "for", "UserVoice", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L19737-L19749
7,620
segmentio/analytics.js
analytics.js
enqueue
function enqueue(fn) { window._vis_opt_queue = window._vis_opt_queue || []; window._vis_opt_queue.push(fn); }
javascript
function enqueue(fn) { window._vis_opt_queue = window._vis_opt_queue || []; window._vis_opt_queue.push(fn); }
[ "function", "enqueue", "(", "fn", ")", "{", "window", ".", "_vis_opt_queue", "=", "window", ".", "_vis_opt_queue", "||", "[", "]", ";", "window", ".", "_vis_opt_queue", ".", "push", "(", "fn", ")", ";", "}" ]
Add a `fn` to the VWO queue, creating one if it doesn't exist. @param {Function} fn
[ "Add", "a", "fn", "to", "the", "VWO", "queue", "creating", "one", "if", "it", "doesn", "t", "exist", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20060-L20063
7,621
segmentio/analytics.js
analytics.js
variation
function variation(id) { var experiments = window._vwo_exp; if (!experiments) return null; var experiment = experiments[id]; var variationId = experiment.combination_chosen; return variationId ? experiment.comb_n[variationId] : null; }
javascript
function variation(id) { var experiments = window._vwo_exp; if (!experiments) return null; var experiment = experiments[id]; var variationId = experiment.combination_chosen; return variationId ? experiment.comb_n[variationId] : null; }
[ "function", "variation", "(", "id", ")", "{", "var", "experiments", "=", "window", ".", "_vwo_exp", ";", "if", "(", "!", "experiments", ")", "return", "null", ";", "var", "experiment", "=", "experiments", "[", "id", "]", ";", "var", "variationId", "=", ...
Get the chosen variation's name from an experiment `id`. http://visualwebsiteoptimizer.com/knowledge/integration-of-vwo-with-kissmetrics/ @param {String} id @return {String}
[ "Get", "the", "chosen", "variation", "s", "name", "from", "an", "experiment", "id", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20074-L20080
7,622
segmentio/analytics.js
analytics.js
push
function push(callback) { window.yandex_metrika_callbacks = window.yandex_metrika_callbacks || []; window.yandex_metrika_callbacks.push(callback); }
javascript
function push(callback) { window.yandex_metrika_callbacks = window.yandex_metrika_callbacks || []; window.yandex_metrika_callbacks.push(callback); }
[ "function", "push", "(", "callback", ")", "{", "window", ".", "yandex_metrika_callbacks", "=", "window", ".", "yandex_metrika_callbacks", "||", "[", "]", ";", "window", ".", "yandex_metrika_callbacks", ".", "push", "(", "callback", ")", ";", "}" ]
Push a new callback on the global Yandex queue. @api private @param {Function} callback
[ "Push", "a", "new", "callback", "on", "the", "global", "Yandex", "queue", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20405-L20408
7,623
expressjs/compression
index.js
chunkLength
function chunkLength (chunk, encoding) { if (!chunk) { return 0 } return !Buffer.isBuffer(chunk) ? Buffer.byteLength(chunk, encoding) : chunk.length }
javascript
function chunkLength (chunk, encoding) { if (!chunk) { return 0 } return !Buffer.isBuffer(chunk) ? Buffer.byteLength(chunk, encoding) : chunk.length }
[ "function", "chunkLength", "(", "chunk", ",", "encoding", ")", "{", "if", "(", "!", "chunk", ")", "{", "return", "0", "}", "return", "!", "Buffer", ".", "isBuffer", "(", "chunk", ")", "?", "Buffer", ".", "byteLength", "(", "chunk", ",", "encoding", "...
Get the length of a given chunk
[ "Get", "the", "length", "of", "a", "given", "chunk" ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L239-L247
7,624
expressjs/compression
index.js
shouldCompress
function shouldCompress (req, res) { var type = res.getHeader('Content-Type') if (type === undefined || !compressible(type)) { debug('%s not compressible', type) return false } return true }
javascript
function shouldCompress (req, res) { var type = res.getHeader('Content-Type') if (type === undefined || !compressible(type)) { debug('%s not compressible', type) return false } return true }
[ "function", "shouldCompress", "(", "req", ",", "res", ")", "{", "var", "type", "=", "res", ".", "getHeader", "(", "'Content-Type'", ")", "if", "(", "type", "===", "undefined", "||", "!", "compressible", "(", "type", ")", ")", "{", "debug", "(", "'%s no...
Default filter function. @private
[ "Default", "filter", "function", "." ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L254-L263
7,625
expressjs/compression
index.js
shouldTransform
function shouldTransform (req, res) { var cacheControl = res.getHeader('Cache-Control') // Don't compress for Cache-Control: no-transform // https://tools.ietf.org/html/rfc7234#section-5.2.2.4 return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl) }
javascript
function shouldTransform (req, res) { var cacheControl = res.getHeader('Cache-Control') // Don't compress for Cache-Control: no-transform // https://tools.ietf.org/html/rfc7234#section-5.2.2.4 return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl) }
[ "function", "shouldTransform", "(", "req", ",", "res", ")", "{", "var", "cacheControl", "=", "res", ".", "getHeader", "(", "'Cache-Control'", ")", "// Don't compress for Cache-Control: no-transform", "// https://tools.ietf.org/html/rfc7234#section-5.2.2.4", "return", "!", "...
Determine if the entity should be transformed. @private
[ "Determine", "if", "the", "entity", "should", "be", "transformed", "." ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L270-L277
7,626
expressjs/compression
index.js
toBuffer
function toBuffer (chunk, encoding) { return !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk }
javascript
function toBuffer (chunk, encoding) { return !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk }
[ "function", "toBuffer", "(", "chunk", ",", "encoding", ")", "{", "return", "!", "Buffer", ".", "isBuffer", "(", "chunk", ")", "?", "Buffer", ".", "from", "(", "chunk", ",", "encoding", ")", ":", "chunk", "}" ]
Coerce arguments to Buffer @private
[ "Coerce", "arguments", "to", "Buffer" ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L284-L288
7,627
zeit/styled-jsx
src/lib/style-transform.js
transform
function transform(hash, styles, settings = {}) { generator = settings.generator offset = settings.offset filename = settings.filename splitRules = [] stylis.set({ prefix: typeof settings.vendorPrefixes === 'boolean' ? settings.vendorPrefixes : true }) stylis(hash, styles) i...
javascript
function transform(hash, styles, settings = {}) { generator = settings.generator offset = settings.offset filename = settings.filename splitRules = [] stylis.set({ prefix: typeof settings.vendorPrefixes === 'boolean' ? settings.vendorPrefixes : true }) stylis(hash, styles) i...
[ "function", "transform", "(", "hash", ",", "styles", ",", "settings", "=", "{", "}", ")", "{", "generator", "=", "settings", ".", "generator", "offset", "=", "settings", ".", "offset", "filename", "=", "settings", ".", "filename", "splitRules", "=", "[", ...
Public transform function @param {String} hash @param {String} styles @param {Object} settings @return {string}
[ "Public", "transform", "function" ]
00fcb7bcad9c8af91167056f93c63858d24769ba
https://github.com/zeit/styled-jsx/blob/00fcb7bcad9c8af91167056f93c63858d24769ba/src/lib/style-transform.js#L96-L116
7,628
HubSpot/vex
src/vex.js
addClasses
function addClasses (el, classStr) { if (typeof classStr !== 'string' || classStr.length === 0) { return } var classes = classStr.split(' ') for (var i = 0; i < classes.length; i++) { var className = classes[i] if (className.length) { el.classList.add(className) } } }
javascript
function addClasses (el, classStr) { if (typeof classStr !== 'string' || classStr.length === 0) { return } var classes = classStr.split(' ') for (var i = 0; i < classes.length; i++) { var className = classes[i] if (className.length) { el.classList.add(className) } } }
[ "function", "addClasses", "(", "el", ",", "classStr", ")", "{", "if", "(", "typeof", "classStr", "!==", "'string'", "||", "classStr", ".", "length", "===", "0", ")", "{", "return", "}", "var", "classes", "=", "classStr", ".", "split", "(", "' '", ")", ...
Utility function to add space-delimited class strings to a DOM element's classList
[ "Utility", "function", "to", "add", "space", "-", "delimited", "class", "strings", "to", "a", "DOM", "element", "s", "classList" ]
0df3f63db5eebee09d284feec0895dc723e95514
https://github.com/HubSpot/vex/blob/0df3f63db5eebee09d284feec0895dc723e95514/src/vex.js#L21-L32
7,629
HubSpot/vex
src/vex.js
close
function close (vexOrId) { var id if (vexOrId.id) { id = vexOrId.id } else if (typeof vexOrId === 'string') { id = vexOrId } else { throw new TypeError('close requires a vex object or id string') } if (!vexes[id]) { return false } return vexes[id].close() }
javascript
function close (vexOrId) { var id if (vexOrId.id) { id = vexOrId.id } else if (typeof vexOrId === 'string') { id = vexOrId } else { throw new TypeError('close requires a vex object or id string') } if (!vexes[id]) { return false } return vexes[id].close() }
[ "function", "close", "(", "vexOrId", ")", "{", "var", "id", "if", "(", "vexOrId", ".", "id", ")", "{", "id", "=", "vexOrId", ".", "id", "}", "else", "if", "(", "typeof", "vexOrId", "===", "'string'", ")", "{", "id", "=", "vexOrId", "}", "else", "...
A top-level vex.close function to close dialogs by reference or id
[ "A", "top", "-", "level", "vex", ".", "close", "function", "to", "close", "dialogs", "by", "reference", "or", "id" ]
0df3f63db5eebee09d284feec0895dc723e95514
https://github.com/HubSpot/vex/blob/0df3f63db5eebee09d284feec0895dc723e95514/src/vex.js#L253-L266
7,630
algolia/instantsearch.js
scripts/release/publish.js
rollback
function rollback(newVersion) { if (strategy === 'stable') { // reset master shell.exec('git reset --hard origin/master'); shell.exec('git checkout develop'); } else { // remove last commit shell.exec('git reset --hard HEAD~1'); } // remove local created tag shell.exec(`git tag -d v${newV...
javascript
function rollback(newVersion) { if (strategy === 'stable') { // reset master shell.exec('git reset --hard origin/master'); shell.exec('git checkout develop'); } else { // remove last commit shell.exec('git reset --hard HEAD~1'); } // remove local created tag shell.exec(`git tag -d v${newV...
[ "function", "rollback", "(", "newVersion", ")", "{", "if", "(", "strategy", "===", "'stable'", ")", "{", "// reset master", "shell", ".", "exec", "(", "'git reset --hard origin/master'", ")", ";", "shell", ".", "exec", "(", "'git checkout develop'", ")", ";", ...
called if process aborted before publish, nothing is pushed nor published remove local changes
[ "called", "if", "process", "aborted", "before", "publish", "nothing", "is", "pushed", "nor", "published", "remove", "local", "changes" ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/scripts/release/publish.js#L78-L91
7,631
algolia/instantsearch.js
src/widgets/refinement-list/refinement-list.js
transformTemplates
function transformTemplates(templates) { const allTemplates = { ...templates, submit: templates.searchableSubmit, reset: templates.searchableReset, loadingIndicator: templates.searchableLoadingIndicator, }; const { searchableReset, searchableSubmit, searchableLoadingIndicator, ......
javascript
function transformTemplates(templates) { const allTemplates = { ...templates, submit: templates.searchableSubmit, reset: templates.searchableReset, loadingIndicator: templates.searchableLoadingIndicator, }; const { searchableReset, searchableSubmit, searchableLoadingIndicator, ......
[ "function", "transformTemplates", "(", "templates", ")", "{", "const", "allTemplates", "=", "{", "...", "templates", ",", "submit", ":", "templates", ".", "searchableSubmit", ",", "reset", ":", "templates", ".", "searchableReset", ",", "loadingIndicator", ":", "...
Transforms the searchable templates by removing the `searchable` prefix. This makes them usable in the `SearchBox` component. @param {object} templates The widget templates @returns {object} the formatted templates
[ "Transforms", "the", "searchable", "templates", "by", "removing", "the", "searchable", "prefix", "." ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/widgets/refinement-list/refinement-list.js#L27-L43
7,632
algolia/instantsearch.js
src/lib/utils/clearRefinements.js
clearRefinements
function clearRefinements({ helper, attributesToClear = [] }) { let finalState = helper.state; attributesToClear.forEach(attribute => { if (attribute === '_tags') { finalState = finalState.clearTags(); } else { finalState = finalState.clearRefinements(attribute); } }); if (attributesTo...
javascript
function clearRefinements({ helper, attributesToClear = [] }) { let finalState = helper.state; attributesToClear.forEach(attribute => { if (attribute === '_tags') { finalState = finalState.clearTags(); } else { finalState = finalState.clearRefinements(attribute); } }); if (attributesTo...
[ "function", "clearRefinements", "(", "{", "helper", ",", "attributesToClear", "=", "[", "]", "}", ")", "{", "let", "finalState", "=", "helper", ".", "state", ";", "attributesToClear", ".", "forEach", "(", "attribute", "=>", "{", "if", "(", "attribute", "==...
Clears the refinements of a SearchParameters object based on rules provided. The included attributes list is applied before the excluded attributes list. If the list is not provided, this list of all the currently refined attributes is used as included attributes. @param {object} $0 parameters @param {Helper} $0.helper...
[ "Clears", "the", "refinements", "of", "a", "SearchParameters", "object", "based", "on", "rules", "provided", ".", "The", "included", "attributes", "list", "is", "applied", "before", "the", "excluded", "attributes", "list", ".", "If", "the", "list", "is", "not"...
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/lib/utils/clearRefinements.js#L10-L26
7,633
algolia/instantsearch.js
src/lib/utils/prepareTemplateProps.js
prepareTemplateProps
function prepareTemplateProps({ defaultTemplates, templates, templatesConfig, }) { const preparedTemplates = prepareTemplates(defaultTemplates, templates); return { templatesConfig, ...preparedTemplates, }; }
javascript
function prepareTemplateProps({ defaultTemplates, templates, templatesConfig, }) { const preparedTemplates = prepareTemplates(defaultTemplates, templates); return { templatesConfig, ...preparedTemplates, }; }
[ "function", "prepareTemplateProps", "(", "{", "defaultTemplates", ",", "templates", ",", "templatesConfig", ",", "}", ")", "{", "const", "preparedTemplates", "=", "prepareTemplates", "(", "defaultTemplates", ",", "templates", ")", ";", "return", "{", "templatesConfi...
Prepares an object to be passed to the Template widget @param {object} unknownBecauseES6 an object with the following attributes: - defaultTemplate - templates - templatesConfig @return {object} the configuration with the attributes: - defaultTemplate - templates - useCustomCompileOptions
[ "Prepares", "an", "object", "to", "be", "passed", "to", "the", "Template", "widget" ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/lib/utils/prepareTemplateProps.js#L38-L49
7,634
lingui/js-lingui
scripts/build/modules.js
getDependencies
function getDependencies(bundleType, entry) { const packageJson = require(path.dirname(require.resolve(entry)) + "/package.json") // Both deps and peerDeps are assumed as accessible. return Array.from( new Set([ ...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.peerDep...
javascript
function getDependencies(bundleType, entry) { const packageJson = require(path.dirname(require.resolve(entry)) + "/package.json") // Both deps and peerDeps are assumed as accessible. return Array.from( new Set([ ...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.peerDep...
[ "function", "getDependencies", "(", "bundleType", ",", "entry", ")", "{", "const", "packageJson", "=", "require", "(", "path", ".", "dirname", "(", "require", ".", "resolve", "(", "entry", ")", ")", "+", "\"/package.json\"", ")", "// Both deps and peerDeps are a...
Determines node_modules packages that are safe to assume will exist.
[ "Determines", "node_modules", "packages", "that", "are", "safe", "to", "assume", "will", "exist", "." ]
c9a4b151f621502349d3ee7ce1fc3e10d88f4a73
https://github.com/lingui/js-lingui/blob/c9a4b151f621502349d3ee7ce1fc3e10d88f4a73/scripts/build/modules.js#L37-L47
7,635
PolymathNetwork/polymath-core
CLI/commands/investor_portal.js
inputSymbol
async function inputSymbol(symbol) { if (typeof symbol === 'undefined') { STSymbol = readlineSync.question(chalk.yellow(`Enter the symbol of a registered security token or press 'Enter' to exit: `)); } else { STSymbol = symbol; } if (STSymbol == "") process.exit(); STAddress = awai...
javascript
async function inputSymbol(symbol) { if (typeof symbol === 'undefined') { STSymbol = readlineSync.question(chalk.yellow(`Enter the symbol of a registered security token or press 'Enter' to exit: `)); } else { STSymbol = symbol; } if (STSymbol == "") process.exit(); STAddress = awai...
[ "async", "function", "inputSymbol", "(", "symbol", ")", "{", "if", "(", "typeof", "symbol", "===", "'undefined'", ")", "{", "STSymbol", "=", "readlineSync", ".", "question", "(", "chalk", ".", "yellow", "(", "`", "`", ")", ")", ";", "}", "else", "{", ...
Input security token symbol or exit
[ "Input", "security", "token", "symbol", "or", "exit" ]
aa635df01588f733ce95bc13fe319c7d3c858a24
https://github.com/PolymathNetwork/polymath-core/blob/aa635df01588f733ce95bc13fe319c7d3c858a24/CLI/commands/investor_portal.js#L102-L136
7,636
PolymathNetwork/polymath-core
CLI/commands/token_manager.js
addModule
async function addModule() { let options = ['Permission Manager', 'Transfer Manager', 'Security Token Offering', 'Dividends', 'Burn']; let index = readlineSync.keyInSelect(options, 'What type of module would you like to add?', { cancel: 'Return' }); switch (options[index]) { case 'Permission Manager': c...
javascript
async function addModule() { let options = ['Permission Manager', 'Transfer Manager', 'Security Token Offering', 'Dividends', 'Burn']; let index = readlineSync.keyInSelect(options, 'What type of module would you like to add?', { cancel: 'Return' }); switch (options[index]) { case 'Permission Manager': c...
[ "async", "function", "addModule", "(", ")", "{", "let", "options", "=", "[", "'Permission Manager'", ",", "'Transfer Manager'", ",", "'Security Token Offering'", ",", "'Dividends'", ",", "'Burn'", "]", ";", "let", "index", "=", "readlineSync", ".", "keyInSelect", ...
Modules a actions
[ "Modules", "a", "actions" ]
aa635df01588f733ce95bc13fe319c7d3c858a24
https://github.com/PolymathNetwork/polymath-core/blob/aa635df01588f733ce95bc13fe319c7d3c858a24/CLI/commands/token_manager.js#L456-L485
7,637
bestiejs/platform.js
platform.js
cleanupOS
function cleanupOS(os, pattern, label) { // Platform tokens are defined at: // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx var data = { '10.0': '10', '6.4': '10 Technic...
javascript
function cleanupOS(os, pattern, label) { // Platform tokens are defined at: // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx var data = { '10.0': '10', '6.4': '10 Technic...
[ "function", "cleanupOS", "(", "os", ",", "pattern", ",", "label", ")", "{", "// Platform tokens are defined at:", "// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx", "// http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx", ...
A utility function to clean up the OS name. @private @param {string} os The OS name to clean up. @param {string} [pattern] A `RegExp` pattern matching the OS name. @param {string} [label] A label for the OS.
[ "A", "utility", "function", "to", "clean", "up", "the", "OS", "name", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L78-L125
7,638
bestiejs/platform.js
platform.js
each
function each(object, callback) { var index = -1, length = object ? object.length : 0; if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) { while (++index < length) { callback(object[index], index, object); } } else { forOwn(object, callback); } ...
javascript
function each(object, callback) { var index = -1, length = object ? object.length : 0; if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) { while (++index < length) { callback(object[index], index, object); } } else { forOwn(object, callback); } ...
[ "function", "each", "(", "object", ",", "callback", ")", "{", "var", "index", "=", "-", "1", ",", "length", "=", "object", "?", "object", ".", "length", ":", "0", ";", "if", "(", "typeof", "length", "==", "'number'", "&&", "length", ">", "-", "1", ...
An iteration utility for arrays and objects. @private @param {Array|Object} object The object to iterate over. @param {Function} callback The function called per iteration.
[ "An", "iteration", "utility", "for", "arrays", "and", "objects", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L134-L145
7,639
bestiejs/platform.js
platform.js
format
function format(string) { string = trim(string); return /^(?:webOS|i(?:OS|P))/.test(string) ? string : capitalize(string); }
javascript
function format(string) { string = trim(string); return /^(?:webOS|i(?:OS|P))/.test(string) ? string : capitalize(string); }
[ "function", "format", "(", "string", ")", "{", "string", "=", "trim", "(", "string", ")", ";", "return", "/", "^(?:webOS|i(?:OS|P))", "/", ".", "test", "(", "string", ")", "?", "string", ":", "capitalize", "(", "string", ")", ";", "}" ]
Trim and conditionally capitalize string values. @private @param {string} string The string to format. @returns {string} The formatted string.
[ "Trim", "and", "conditionally", "capitalize", "string", "values", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L154-L159
7,640
bestiejs/platform.js
platform.js
forOwn
function forOwn(object, callback) { for (var key in object) { if (hasOwnProperty.call(object, key)) { callback(object[key], key, object); } } }
javascript
function forOwn(object, callback) { for (var key in object) { if (hasOwnProperty.call(object, key)) { callback(object[key], key, object); } } }
[ "function", "forOwn", "(", "object", ",", "callback", ")", "{", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "hasOwnProperty", ".", "call", "(", "object", ",", "key", ")", ")", "{", "callback", "(", "object", "[", "key", "]", ",",...
Iterates over an object's own properties, executing the `callback` for each. @private @param {Object} object The object to iterate over. @param {Function} callback The function executed per own property.
[ "Iterates", "over", "an", "object", "s", "own", "properties", "executing", "the", "callback", "for", "each", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L168-L174
7,641
bestiejs/platform.js
platform.js
getManufacturer
function getManufacturer(guesses) { return reduce(guesses, function(result, value, key) { // Lookup the manufacturer by product or scan the UA for the manufacturer. return result || ( value[product] || value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || RegExp('\\b' + q...
javascript
function getManufacturer(guesses) { return reduce(guesses, function(result, value, key) { // Lookup the manufacturer by product or scan the UA for the manufacturer. return result || ( value[product] || value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || RegExp('\\b' + q...
[ "function", "getManufacturer", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "value", ",", "key", ")", "{", "// Lookup the manufacturer by product or scan the UA for the manufacturer.", "return", "result", "||", "("...
Picks the manufacturer from an array of guesses. @private @param {Array} guesses An object of guesses. @returns {null|string} The detected manufacturer.
[ "Picks", "the", "manufacturer", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L514-L523
7,642
bestiejs/platform.js
platform.js
getOS
function getOS(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua) )) { result = cleanupOS(result, pattern, guess.labe...
javascript
function getOS(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua) )) { result = cleanupOS(result, pattern, guess.labe...
[ "function", "getOS", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "guess", ")", "{", "var", "pattern", "=", "guess", ".", "pattern", "||", "qualify", "(", "guess", ")", ";", "if", "(", "!", "resul...
Picks the OS name from an array of guesses. @private @param {Array} guesses An array of guesses. @returns {null|string} The detected OS name.
[ "Picks", "the", "OS", "name", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L547-L557
7,643
bestiejs/platform.js
platform.js
getProduct
function getProduct(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||...
javascript
function getProduct(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||...
[ "function", "getProduct", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "guess", ")", "{", "var", "pattern", "=", "guess", ".", "pattern", "||", "qualify", "(", "guess", ")", ";", "if", "(", "!", "...
Picks the product name from an array of guesses. @private @param {Array} guesses An array of guesses. @returns {null|string} The detected product name.
[ "Picks", "the", "product", "name", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L566-L587
7,644
bestiejs/platform.js
platform.js
getVersion
function getVersion(patterns) { return reduce(patterns, function(result, pattern) { return result || (RegExp(pattern + '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null; }); }
javascript
function getVersion(patterns) { return reduce(patterns, function(result, pattern) { return result || (RegExp(pattern + '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null; }); }
[ "function", "getVersion", "(", "patterns", ")", "{", "return", "reduce", "(", "patterns", ",", "function", "(", "result", ",", "pattern", ")", "{", "return", "result", "||", "(", "RegExp", "(", "pattern", "+", "'(?:-[\\\\d.]+/|(?: for [\\\\w-]+)?[ /-])([\\\\d.]+[^...
Resolves the version using an array of UA patterns. @private @param {Array} patterns An array of UA patterns. @returns {null|string} The detected version.
[ "Resolves", "the", "version", "using", "an", "array", "of", "UA", "patterns", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L596-L601
7,645
KhaosT/HAP-NodeJS
lib/Characteristic.js
Characteristic
function Characteristic(displayName, UUID, props) { this.displayName = displayName; this.UUID = UUID; this.iid = null; // assigned by our containing Service this.value = null; this.status = null; this.eventOnlyCharacteristic = false; this.props = props || { format: null, unit: null, minValue: ...
javascript
function Characteristic(displayName, UUID, props) { this.displayName = displayName; this.UUID = UUID; this.iid = null; // assigned by our containing Service this.value = null; this.status = null; this.eventOnlyCharacteristic = false; this.props = props || { format: null, unit: null, minValue: ...
[ "function", "Characteristic", "(", "displayName", ",", "UUID", ",", "props", ")", "{", "this", ".", "displayName", "=", "displayName", ";", "this", ".", "UUID", "=", "UUID", ";", "this", ".", "iid", "=", "null", ";", "// assigned by our containing Service", ...
Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic to a Service in order to store that value. A particular Characteristic is distinguished from others by its ...
[ "Characteristic", "represents", "a", "particular", "typed", "variable", "that", "can", "be", "assigned", "to", "a", "Service", ".", "For", "instance", "a", "Hue", "Characteristic", "might", "store", "a", "float", "value", "of", "type", "arcdegrees", ".", "You"...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Characteristic.js#L46-L63
7,646
KhaosT/HAP-NodeJS
lib/model/AccessoryInfo.js
AccessoryInfo
function AccessoryInfo(username) { this.username = username; this.displayName = ""; this.category = ""; this.pincode = ""; this.signSk = bufferShim.alloc(0); this.signPk = bufferShim.alloc(0); this.pairedClients = {}; // pairedClients[clientUsername:string] = clientPublicKey:Buffer this.configVersion = ...
javascript
function AccessoryInfo(username) { this.username = username; this.displayName = ""; this.category = ""; this.pincode = ""; this.signSk = bufferShim.alloc(0); this.signPk = bufferShim.alloc(0); this.pairedClients = {}; // pairedClients[clientUsername:string] = clientPublicKey:Buffer this.configVersion = ...
[ "function", "AccessoryInfo", "(", "username", ")", "{", "this", ".", "username", "=", "username", ";", "this", ".", "displayName", "=", "\"\"", ";", "this", ".", "category", "=", "\"\"", ";", "this", ".", "pincode", "=", "\"\"", ";", "this", ".", "sign...
AccessoryInfo is a model class containing a subset of Accessory data relevant to the internal HAP server, such as encryption keys and username. It is persisted to disk.
[ "AccessoryInfo", "is", "a", "model", "class", "containing", "a", "subset", "of", "Accessory", "data", "relevant", "to", "the", "internal", "HAP", "server", "such", "as", "encryption", "keys", "and", "username", ".", "It", "is", "persisted", "to", "disk", "."...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/model/AccessoryInfo.js#L17-L36
7,647
KhaosT/HAP-NodeJS
lib/util/eventedhttp.js
EventedHTTPServerConnection
function EventedHTTPServerConnection(clientSocket) { this.sessionID = uuid.generate(clientSocket.remoteAddress + ':' + clientSocket.remotePort); this._remoteAddress = clientSocket.remoteAddress; // cache because it becomes undefined in 'onClientSocketClose' this._pendingClientSocketData = bufferShim.alloc(0); //...
javascript
function EventedHTTPServerConnection(clientSocket) { this.sessionID = uuid.generate(clientSocket.remoteAddress + ':' + clientSocket.remotePort); this._remoteAddress = clientSocket.remoteAddress; // cache because it becomes undefined in 'onClientSocketClose' this._pendingClientSocketData = bufferShim.alloc(0); //...
[ "function", "EventedHTTPServerConnection", "(", "clientSocket", ")", "{", "this", ".", "sessionID", "=", "uuid", ".", "generate", "(", "clientSocket", ".", "remoteAddress", "+", "':'", "+", "clientSocket", ".", "remotePort", ")", ";", "this", ".", "_remoteAddres...
Manages a single iOS-initiated HTTP connection during its lifetime. @event 'request' => function(request, response) { } @event 'decrypt' => function(data, {decrypted.data}, session) { } @event 'encrypt' => function(data, {encrypted.data}, session) { } @event 'close' => function() { }
[ "Manages", "a", "single", "iOS", "-", "initiated", "HTTP", "connection", "during", "its", "lifetime", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/util/eventedhttp.js#L113-L150
7,648
KhaosT/HAP-NodeJS
lib/Service.js
Service
function Service(displayName, UUID, subtype) { if (!UUID) throw new Error("Services must be created with a valid UUID."); this.displayName = displayName; this.UUID = UUID; this.subtype = subtype; this.iid = null; // assigned later by our containing Accessory this.characteristics = []; this.optionalChara...
javascript
function Service(displayName, UUID, subtype) { if (!UUID) throw new Error("Services must be created with a valid UUID."); this.displayName = displayName; this.UUID = UUID; this.subtype = subtype; this.iid = null; // assigned later by our containing Accessory this.characteristics = []; this.optionalChara...
[ "function", "Service", "(", "displayName", ",", "UUID", ",", "subtype", ")", "{", "if", "(", "!", "UUID", ")", "throw", "new", "Error", "(", "\"Services must be created with a valid UUID.\"", ")", ";", "this", ".", "displayName", "=", "displayName", ";", "this...
Service represents a set of grouped values necessary to provide a logical function. For instance, a "Door Lock Mechanism" service might contain two values, one for the "desired lock state" and one for the "current lock state". A particular Service is distinguished from others by its "type", which is a UUID. HomeKit pro...
[ "Service", "represents", "a", "set", "of", "grouped", "values", "necessary", "to", "provide", "a", "logical", "function", ".", "For", "instance", "a", "Door", "Lock", "Mechanism", "service", "might", "contain", "two", "values", "one", "for", "the", "desired", ...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Service.js#L36-L62
7,649
KhaosT/HAP-NodeJS
lib/util/clone.js
clone
function clone(object, extend) { var cloned = {}; for (var key in object) { cloned[key] = object[key]; } for (var key in extend) { cloned[key] = extend[key]; } return cloned; }
javascript
function clone(object, extend) { var cloned = {}; for (var key in object) { cloned[key] = object[key]; } for (var key in extend) { cloned[key] = extend[key]; } return cloned; }
[ "function", "clone", "(", "object", ",", "extend", ")", "{", "var", "cloned", "=", "{", "}", ";", "for", "(", "var", "key", "in", "object", ")", "{", "cloned", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "for", "(", "var", "key",...
A simple clone function that also allows you to pass an "extend" object whose properties will be added to the cloned copy of the original object passed.
[ "A", "simple", "clone", "function", "that", "also", "allows", "you", "to", "pass", "an", "extend", "object", "whose", "properties", "will", "be", "added", "to", "the", "cloned", "copy", "of", "the", "original", "object", "passed", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/util/clone.js#L12-L25
7,650
KhaosT/HAP-NodeJS
lib/Accessory.js
Accessory
function Accessory(displayName, UUID) { if (!displayName) throw new Error("Accessories must be created with a non-empty displayName."); if (!UUID) throw new Error("Accessories must be created with a valid UUID."); if (!uuid.isValid(UUID)) throw new Error("UUID '" + UUID + "' is not a valid UUID. Try using the pr...
javascript
function Accessory(displayName, UUID) { if (!displayName) throw new Error("Accessories must be created with a non-empty displayName."); if (!UUID) throw new Error("Accessories must be created with a valid UUID."); if (!uuid.isValid(UUID)) throw new Error("UUID '" + UUID + "' is not a valid UUID. Try using the pr...
[ "function", "Accessory", "(", "displayName", ",", "UUID", ")", "{", "if", "(", "!", "displayName", ")", "throw", "new", "Error", "(", "\"Accessories must be created with a non-empty displayName.\"", ")", ";", "if", "(", "!", "UUID", ")", "throw", "new", "Error",...
Accessory is a virtual HomeKit device. It can publish an associated HAP server for iOS devices to communicate with - or it can run behind another "Bridge" Accessory server. Bridged Accessories in this implementation must have a UUID that is unique among all other Accessories that are hosted by the Bridge. This UUID mu...
[ "Accessory", "is", "a", "virtual", "HomeKit", "device", ".", "It", "can", "publish", "an", "associated", "HAP", "server", "for", "iOS", "devices", "to", "communicate", "with", "-", "or", "it", "can", "run", "behind", "another", "Bridge", "Accessory", "server...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Accessory.js#L47-L85
7,651
KhaosT/HAP-NodeJS
lib/HAPServer.js
HAPServer
function HAPServer(accessoryInfo, relayServer) { this.accessoryInfo = accessoryInfo; this.allowInsecureRequest = false; // internal server that does all the actual communication this._httpServer = new EventedHTTPServer(); this._httpServer.on('listening', this._onListening.bind(this)); this._httpServer.on('...
javascript
function HAPServer(accessoryInfo, relayServer) { this.accessoryInfo = accessoryInfo; this.allowInsecureRequest = false; // internal server that does all the actual communication this._httpServer = new EventedHTTPServer(); this._httpServer.on('listening', this._onListening.bind(this)); this._httpServer.on('...
[ "function", "HAPServer", "(", "accessoryInfo", ",", "relayServer", ")", "{", "this", ".", "accessoryInfo", "=", "accessoryInfo", ";", "this", ".", "allowInsecureRequest", "=", "false", ";", "// internal server that does all the actual communication", "this", ".", "_http...
The actual HAP server that iOS devices talk to. Notes ----- It turns out that the IP-based version of HomeKit's HAP protocol operates over a sort of pseudo-HTTP. Accessories are meant to host a TCP socket server that initially behaves exactly as an HTTP/1.1 server. So iOS devices will open up a long-lived connection t...
[ "The", "actual", "HAP", "server", "that", "iOS", "devices", "talk", "to", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/HAPServer.js#L81-L109
7,652
KhaosT/HAP-NodeJS
lib/HAPServer.js
HAPEncryption
function HAPEncryption() { // initialize member vars with null-object values this.clientPublicKey = bufferShim.alloc(0); this.secretKey = bufferShim.alloc(0); this.publicKey = bufferShim.alloc(0); this.sharedSec = bufferShim.alloc(0); this.hkdfPairEncKey = bufferShim.alloc(0); this.accessoryToControllerCo...
javascript
function HAPEncryption() { // initialize member vars with null-object values this.clientPublicKey = bufferShim.alloc(0); this.secretKey = bufferShim.alloc(0); this.publicKey = bufferShim.alloc(0); this.sharedSec = bufferShim.alloc(0); this.hkdfPairEncKey = bufferShim.alloc(0); this.accessoryToControllerCo...
[ "function", "HAPEncryption", "(", ")", "{", "// initialize member vars with null-object values", "this", ".", "clientPublicKey", "=", "bufferShim", ".", "alloc", "(", "0", ")", ";", "this", ".", "secretKey", "=", "bufferShim", ".", "alloc", "(", "0", ")", ";", ...
Simple struct to hold vars needed to support HAP encryption.
[ "Simple", "struct", "to", "hold", "vars", "needed", "to", "support", "HAP", "encryption", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/HAPServer.js#L1107-L1119
7,653
KhaosT/HAP-NodeJS
lib/Advertiser.js
Advertiser
function Advertiser(accessoryInfo, mdnsConfig) { this.accessoryInfo = accessoryInfo; this._bonjourService = bonjour(mdnsConfig); this._advertisement = null; this._setupHash = this._computeSetupHash(); }
javascript
function Advertiser(accessoryInfo, mdnsConfig) { this.accessoryInfo = accessoryInfo; this._bonjourService = bonjour(mdnsConfig); this._advertisement = null; this._setupHash = this._computeSetupHash(); }
[ "function", "Advertiser", "(", "accessoryInfo", ",", "mdnsConfig", ")", "{", "this", ".", "accessoryInfo", "=", "accessoryInfo", ";", "this", ".", "_bonjourService", "=", "bonjour", "(", "mdnsConfig", ")", ";", "this", ".", "_advertisement", "=", "null", ";", ...
Advertiser uses mdns to broadcast the presence of an Accessory to the local network. Note that as of iOS 9, an accessory can only pair with a single client. Instead of pairing your accessories with multiple iOS devices in your home, Apple intends for you to use Home Sharing. To support this requirement, we provide the...
[ "Advertiser", "uses", "mdns", "to", "broadcast", "the", "presence", "of", "an", "Accessory", "to", "the", "local", "network", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Advertiser.js#L21-L27
7,654
KhaosT/HAP-NodeJS
lib/AccessoryLoader.js
loadDirectory
function loadDirectory(dir) { // exported accessory objects loaded from this dir var accessories = []; fs.readdirSync(dir).forEach(function(file) { // "Accessories" are modules that export a single accessory. if (file.split('_').pop() === 'accessory.js') { debug('Parsing accessory: %s', file); ...
javascript
function loadDirectory(dir) { // exported accessory objects loaded from this dir var accessories = []; fs.readdirSync(dir).forEach(function(file) { // "Accessories" are modules that export a single accessory. if (file.split('_').pop() === 'accessory.js') { debug('Parsing accessory: %s', file); ...
[ "function", "loadDirectory", "(", "dir", ")", "{", "// exported accessory objects loaded from this dir", "var", "accessories", "=", "[", "]", ";", "fs", ".", "readdirSync", "(", "dir", ")", ".", "forEach", "(", "function", "(", "file", ")", "{", "// \"Accessorie...
Loads all accessories from the given folder. Handles object-literal-style accessories, "accessory factories", and new-API style modules.
[ "Loads", "all", "accessories", "from", "the", "given", "folder", ".", "Handles", "object", "-", "literal", "-", "style", "accessories", "accessory", "factories", "and", "new", "-", "API", "style", "modules", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/AccessoryLoader.js#L23-L56
7,655
matrix-org/matrix-js-sdk
src/timeline-window.js
TimelineWindow
function TimelineWindow(client, timelineSet, opts) { opts = opts || {}; this._client = client; this._timelineSet = timelineSet; // these will be TimelineIndex objects; they delineate the 'start' and // 'end' of the window. // // _start.index is inclusive; _end.index is exclusive. this._...
javascript
function TimelineWindow(client, timelineSet, opts) { opts = opts || {}; this._client = client; this._timelineSet = timelineSet; // these will be TimelineIndex objects; they delineate the 'start' and // 'end' of the window. // // _start.index is inclusive; _end.index is exclusive. this._...
[ "function", "TimelineWindow", "(", "client", ",", "timelineSet", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "_client", "=", "client", ";", "this", ".", "_timelineSet", "=", "timelineSet", ";", "// these will be TimelineInde...
Construct a TimelineWindow. <p>This abstracts the separate timelines in a Matrix {@link module:models/room|Room} into a single iterable thing. It keeps track of the start and endpoints of the window, which can be advanced with the help of pagination requests. <p>Before the window is useful, it must be initialised by ...
[ "Construct", "a", "TimelineWindow", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/timeline-window.js#L69-L83
7,656
matrix-org/matrix-js-sdk
src/timeline-window.js
function(timeline) { let eventIndex; const events = timeline.getEvents(); if (!initialEventId) { // we were looking for the live timeline: initialise to the end eventIndex = events.length; } else { for (let i = 0; i < events.length; i++) { ...
javascript
function(timeline) { let eventIndex; const events = timeline.getEvents(); if (!initialEventId) { // we were looking for the live timeline: initialise to the end eventIndex = events.length; } else { for (let i = 0; i < events.length; i++) { ...
[ "function", "(", "timeline", ")", "{", "let", "eventIndex", ";", "const", "events", "=", "timeline", ".", "getEvents", "(", ")", ";", "if", "(", "!", "initialEventId", ")", "{", "// we were looking for the live timeline: initialise to the end", "eventIndex", "=", ...
given an EventTimeline, find the event we were looking for, and initialise our fields so that the event in question is in the middle of the window.
[ "given", "an", "EventTimeline", "find", "the", "event", "we", "were", "looking", "for", "and", "initialise", "our", "fields", "so", "that", "the", "event", "in", "question", "is", "in", "the", "middle", "of", "the", "window", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/timeline-window.js#L100-L127
7,657
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
createOlmSession
function createOlmSession(olmAccount, recipientTestClient) { return recipientTestClient.awaitOneTimeKeyUpload().then((keys) => { const otkId = utils.keys(keys)[0]; const otk = keys[otkId]; const session = new global.Olm.Session(); session.create_outbound( olmAccount, rec...
javascript
function createOlmSession(olmAccount, recipientTestClient) { return recipientTestClient.awaitOneTimeKeyUpload().then((keys) => { const otkId = utils.keys(keys)[0]; const otk = keys[otkId]; const session = new global.Olm.Session(); session.create_outbound( olmAccount, rec...
[ "function", "createOlmSession", "(", "olmAccount", ",", "recipientTestClient", ")", "{", "return", "recipientTestClient", ".", "awaitOneTimeKeyUpload", "(", ")", ".", "then", "(", "(", "keys", ")", "=>", "{", "const", "otkId", "=", "utils", ".", "keys", "(", ...
start an Olm session with a given recipient @param {Olm.Account} olmAccount @param {TestClient} recipientTestClient @return {Promise} promise for Olm.Session
[ "start", "an", "Olm", "session", "with", "a", "given", "recipient" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L36-L47
7,658
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptOlmEvent
function encryptOlmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.p2pSession).toBeTruthy(); expect(opts.recipient).toBeTruthy(); const plaintext = { content: opts.plaincontent || {}, recipient: opts.recipient.userId, recipient_keys: { ed25519: opts.re...
javascript
function encryptOlmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.p2pSession).toBeTruthy(); expect(opts.recipient).toBeTruthy(); const plaintext = { content: opts.plaincontent || {}, recipient: opts.recipient.userId, recipient_keys: { ed25519: opts.re...
[ "function", "encryptOlmEvent", "(", "opts", ")", "{", "expect", "(", "opts", ".", "senderKey", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "p2pSession", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "recipien...
encrypt an event with olm @param {object} opts @param {string=} opts.sender @param {string} opts.senderKey @param {Olm.Session} opts.p2pSession @param {TestClient} opts.recipient @param {object=} opts.plaincontent @param {string=} opts.plaintype @return {object} event
[ "encrypt", "an", "event", "with", "olm" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L62-L89
7,659
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptMegolmEvent
function encryptMegolmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.groupSession).toBeTruthy(); const plaintext = opts.plaintext || {}; if (!plaintext.content) { plaintext.content = { body: '42', msgtype: "m.text", }; } if (!plaintext.typ...
javascript
function encryptMegolmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.groupSession).toBeTruthy(); const plaintext = opts.plaintext || {}; if (!plaintext.content) { plaintext.content = { body: '42', msgtype: "m.text", }; } if (!plaintext.typ...
[ "function", "encryptMegolmEvent", "(", "opts", ")", "{", "expect", "(", "opts", ".", "senderKey", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "groupSession", ")", ".", "toBeTruthy", "(", ")", ";", "const", "plaintext", "=", "opts",...
encrypt an event with megolm @param {object} opts @param {string} opts.senderKey @param {Olm.OutboundGroupSession} opts.groupSession @param {object=} opts.plaintext @param {string=} opts.room_id @return {object} event
[ "encrypt", "an", "event", "with", "megolm" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L102-L132
7,660
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptGroupSessionKey
function encryptGroupSessionKey(opts) { return encryptOlmEvent({ senderKey: opts.senderKey, recipient: opts.recipient, p2pSession: opts.p2pSession, plaincontent: { algorithm: 'm.megolm.v1.aes-sha2', room_id: opts.room_id, session_id: opts.groupSess...
javascript
function encryptGroupSessionKey(opts) { return encryptOlmEvent({ senderKey: opts.senderKey, recipient: opts.recipient, p2pSession: opts.p2pSession, plaincontent: { algorithm: 'm.megolm.v1.aes-sha2', room_id: opts.room_id, session_id: opts.groupSess...
[ "function", "encryptGroupSessionKey", "(", "opts", ")", "{", "return", "encryptOlmEvent", "(", "{", "senderKey", ":", "opts", ".", "senderKey", ",", "recipient", ":", "opts", ".", "recipient", ",", "p2pSession", ":", "opts", ".", "p2pSession", ",", "plainconte...
build an encrypted room_key event to share a group session @param {object} opts @param {string} opts.senderKey @param {TestClient} opts.recipient @param {Olm.Session} opts.p2pSession @param {Olm.OutboundGroupSession} opts.groupSession @param {string=} opts.room_id @return {object} event
[ "build", "an", "encrypted", "room_key", "event", "to", "share", "a", "group", "session" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L146-L159
7,661
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
WebStorageSessionStore
function WebStorageSessionStore(webStore) { this.store = webStore; if (!utils.isFunction(webStore.getItem) || !utils.isFunction(webStore.setItem) || !utils.isFunction(webStore.removeItem) || !utils.isFunction(webStore.key) || typeof(webStore.length) !== 'number' ) { ...
javascript
function WebStorageSessionStore(webStore) { this.store = webStore; if (!utils.isFunction(webStore.getItem) || !utils.isFunction(webStore.setItem) || !utils.isFunction(webStore.removeItem) || !utils.isFunction(webStore.key) || typeof(webStore.length) !== 'number' ) { ...
[ "function", "WebStorageSessionStore", "(", "webStore", ")", "{", "this", ".", "store", "=", "webStore", ";", "if", "(", "!", "utils", ".", "isFunction", "(", "webStore", ".", "getItem", ")", "||", "!", "utils", ".", "isFunction", "(", "webStore", ".", "s...
Construct a web storage session store, capable of storing account keys, session keys and access tokens. @constructor @param {WebStorage} webStore A web storage implementation, e.g. 'window.localStorage' or 'window.sessionStorage' or a custom implementation. @throws if the supplied 'store' does not meet the Storage inte...
[ "Construct", "a", "web", "storage", "session", "store", "capable", "of", "storing", "account", "keys", "session", "keys", "and", "access", "tokens", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L38-L50
7,662
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const prefix = keyEndToEndDevicesForUser(''); const devices = {}; for (let i = 0; i < this.store.length; ++i) { const key = this.store.key(i); const userId = key.substr(prefix.length); if (key.startsWith(prefix)) devices[userId] = getJsonItem(this...
javascript
function() { const prefix = keyEndToEndDevicesForUser(''); const devices = {}; for (let i = 0; i < this.store.length; ++i) { const key = this.store.key(i); const userId = key.substr(prefix.length); if (key.startsWith(prefix)) devices[userId] = getJsonItem(this...
[ "function", "(", ")", "{", "const", "prefix", "=", "keyEndToEndDevicesForUser", "(", "''", ")", ";", "const", "devices", "=", "{", "}", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "this", ".", "store", ".", "length", ";", "++", "i", ")"...
Retrieves the known devices for all users. @return {object} A map from user ID to map of device ID to keys for the device.
[ "Retrieves", "the", "known", "devices", "for", "all", "users", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L75-L84
7,663
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const deviceKeys = getKeysWithPrefix(this.store, keyEndToEndSessions('')); const results = {}; for (const k of deviceKeys) { const unprefixedKey = k.substr(keyEndToEndSessions('').length); results[unprefixedKey] = getJsonItem(this.store, k); } ...
javascript
function() { const deviceKeys = getKeysWithPrefix(this.store, keyEndToEndSessions('')); const results = {}; for (const k of deviceKeys) { const unprefixedKey = k.substr(keyEndToEndSessions('').length); results[unprefixedKey] = getJsonItem(this.store, k); } ...
[ "function", "(", ")", "{", "const", "deviceKeys", "=", "getKeysWithPrefix", "(", "this", ".", "store", ",", "keyEndToEndSessions", "(", "''", ")", ")", ";", "const", "results", "=", "{", "}", ";", "for", "(", "const", "k", "of", "deviceKeys", ")", "{",...
Retrieve all end-to-end sessions between the logged-in user and other devices. @return {object} A map of {deviceKey -> {sessionId -> session pickle}}
[ "Retrieve", "all", "end", "-", "to", "-", "end", "sessions", "between", "the", "logged", "-", "in", "user", "and", "other", "devices", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L123-L131
7,664
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const prefix = E2E_PREFIX + 'inboundgroupsessions/'; const result = []; for (let i = 0; i < this.store.length; i++) { const key = this.store.key(i); if (!key.startsWith(prefix)) { continue; } // we can't use split, as t...
javascript
function() { const prefix = E2E_PREFIX + 'inboundgroupsessions/'; const result = []; for (let i = 0; i < this.store.length; i++) { const key = this.store.key(i); if (!key.startsWith(prefix)) { continue; } // we can't use split, as t...
[ "function", "(", ")", "{", "const", "prefix", "=", "E2E_PREFIX", "+", "'inboundgroupsessions/'", ";", "const", "result", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "this", ".", "store", ".", "length", ";", "i", "++", ")", ...
Retrieve a list of all known inbound group sessions @return {{senderKey: string, sessionId: string}}
[ "Retrieve", "a", "list", "of", "all", "known", "inbound", "group", "sessions" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L146-L165
7,665
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const roomKeys = getKeysWithPrefix(this.store, keyEndToEndRoom('')); const results = {}; for (const k of roomKeys) { const unprefixedKey = k.substr(keyEndToEndRoom('').length); results[unprefixedKey] = getJsonItem(this.store, k); } return resu...
javascript
function() { const roomKeys = getKeysWithPrefix(this.store, keyEndToEndRoom('')); const results = {}; for (const k of roomKeys) { const unprefixedKey = k.substr(keyEndToEndRoom('').length); results[unprefixedKey] = getJsonItem(this.store, k); } return resu...
[ "function", "(", ")", "{", "const", "roomKeys", "=", "getKeysWithPrefix", "(", "this", ".", "store", ",", "keyEndToEndRoom", "(", "''", ")", ")", ";", "const", "results", "=", "{", "}", ";", "for", "(", "const", "k", "of", "roomKeys", ")", "{", "cons...
Get the end-to-end state for all rooms @return {object} roomId -> object with the end-to-end info for the room.
[ "Get", "the", "end", "-", "to", "-", "end", "state", "for", "all", "rooms" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L180-L188
7,666
matrix-org/matrix-js-sdk
src/store/indexeddb.js
IndexedDBStore
function IndexedDBStore(opts) { MemoryStore.call(this, opts); if (!opts.indexedDB) { throw new Error('Missing required option: indexedDB'); } if (opts.workerScript) { // try & find a webworker-compatible API let workerApi = opts.workerApi; if (!workerApi) { ...
javascript
function IndexedDBStore(opts) { MemoryStore.call(this, opts); if (!opts.indexedDB) { throw new Error('Missing required option: indexedDB'); } if (opts.workerScript) { // try & find a webworker-compatible API let workerApi = opts.workerApi; if (!workerApi) { ...
[ "function", "IndexedDBStore", "(", "opts", ")", "{", "MemoryStore", ".", "call", "(", "this", ",", "opts", ")", ";", "if", "(", "!", "opts", ".", "indexedDB", ")", "{", "throw", "new", "Error", "(", "'Missing required option: indexedDB'", ")", ";", "}", ...
once every 5 minutes Construct a new Indexed Database store, which extends MemoryStore. This store functions like a MemoryStore except it periodically persists the contents of the store to an IndexedDB backend. All data is still kept in-memory but can be loaded from disk by calling <code>startup()</code>. This can m...
[ "once", "every", "5", "minutes", "Construct", "a", "new", "Indexed", "Database", "store", "which", "extends", "MemoryStore", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb.js#L84-L114
7,667
matrix-org/matrix-js-sdk
src/store/indexeddb.js
degradable
function degradable(func, fallback) { return async function(...args) { try { return await func.call(this, ...args); } catch (e) { console.error("IndexedDBStore failure, degrading to MemoryStore", e); this.emit("degraded", e); try { // W...
javascript
function degradable(func, fallback) { return async function(...args) { try { return await func.call(this, ...args); } catch (e) { console.error("IndexedDBStore failure, degrading to MemoryStore", e); this.emit("degraded", e); try { // W...
[ "function", "degradable", "(", "func", ",", "fallback", ")", "{", "return", "async", "function", "(", "...", "args", ")", "{", "try", "{", "return", "await", "func", ".", "call", "(", "this", ",", "...", "args", ")", ";", "}", "catch", "(", "e", ")...
All member functions of `IndexedDBStore` that access the backend use this wrapper to watch for failures after initial store startup, including `QuotaExceededError` as free disk space changes, etc. When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore` in place so that the current operatio...
[ "All", "member", "functions", "of", "IndexedDBStore", "that", "access", "the", "backend", "use", "this", "wrapper", "to", "watch", "for", "failures", "after", "initial", "store", "startup", "including", "QuotaExceededError", "as", "free", "disk", "space", "changes...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb.js#L288-L319
7,668
matrix-org/matrix-js-sdk
src/base-apis.js
MatrixBaseApis
function MatrixBaseApis(opts) { utils.checkObjectHasKeys(opts, ["baseUrl", "request"]); this.baseUrl = opts.baseUrl; this.idBaseUrl = opts.idBaseUrl; const httpOpts = { baseUrl: opts.baseUrl, idBaseUrl: opts.idBaseUrl, accessToken: opts.accessToken, request: opts.reques...
javascript
function MatrixBaseApis(opts) { utils.checkObjectHasKeys(opts, ["baseUrl", "request"]); this.baseUrl = opts.baseUrl; this.idBaseUrl = opts.idBaseUrl; const httpOpts = { baseUrl: opts.baseUrl, idBaseUrl: opts.idBaseUrl, accessToken: opts.accessToken, request: opts.reques...
[ "function", "MatrixBaseApis", "(", "opts", ")", "{", "utils", ".", "checkObjectHasKeys", "(", "opts", ",", "[", "\"baseUrl\"", ",", "\"request\"", "]", ")", ";", "this", ".", "baseUrl", "=", "opts", ".", "baseUrl", ";", "this", ".", "idBaseUrl", "=", "op...
Low-level wrappers for the Matrix APIs @constructor @param {Object} opts Configuration options @param {string} opts.baseUrl Required. The base URL to the client-server HTTP API. @param {string} opts.idBaseUrl Optional. The base identity server URL for identity server requests. @param {Function} opts.request Requir...
[ "Low", "-", "level", "wrappers", "for", "the", "Matrix", "APIs" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/base-apis.js#L60-L80
7,669
matrix-org/matrix-js-sdk
src/realtime-callbacks.js
_scheduleRealCallback
function _scheduleRealCallback() { if (_realCallbackKey) { global.clearTimeout(_realCallbackKey); } const first = _callbackList[0]; if (!first) { debuglog("_scheduleRealCallback: no more callbacks, not rescheduling"); return; } const now = _now(); const delayMs = M...
javascript
function _scheduleRealCallback() { if (_realCallbackKey) { global.clearTimeout(_realCallbackKey); } const first = _callbackList[0]; if (!first) { debuglog("_scheduleRealCallback: no more callbacks, not rescheduling"); return; } const now = _now(); const delayMs = M...
[ "function", "_scheduleRealCallback", "(", ")", "{", "if", "(", "_realCallbackKey", ")", "{", "global", ".", "clearTimeout", "(", "_realCallbackKey", ")", ";", "}", "const", "first", "=", "_callbackList", "[", "0", "]", ";", "if", "(", "!", "first", ")", ...
use the real global.setTimeout to schedule a callback to _runCallbacks.
[ "use", "the", "real", "global", ".", "setTimeout", "to", "schedule", "a", "callback", "to", "_runCallbacks", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/realtime-callbacks.js#L127-L144
7,670
matrix-org/matrix-js-sdk
src/models/room.js
Room
function Room(roomId, client, myUserId, opts) { opts = opts || {}; opts.pendingEventOrdering = opts.pendingEventOrdering || "chronological"; this.reEmitter = new ReEmitter(this); if (["chronological", "detached"].indexOf(opts.pendingEventOrdering) === -1) { throw new Error( "opts.p...
javascript
function Room(roomId, client, myUserId, opts) { opts = opts || {}; opts.pendingEventOrdering = opts.pendingEventOrdering || "chronological"; this.reEmitter = new ReEmitter(this); if (["chronological", "detached"].indexOf(opts.pendingEventOrdering) === -1) { throw new Error( "opts.p...
[ "function", "Room", "(", "roomId", ",", "client", ",", "myUserId", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "opts", ".", "pendingEventOrdering", "=", "opts", ".", "pendingEventOrdering", "||", "\"chronological\"", ";", "this", ".", ...
Construct a new Room. <p>For a room, we store an ordered sequence of timelines, which may or may not be continuous. Each timeline lists a series of events, as well as tracking the room state at the start and the end of the timeline. It also tracks forward and backward pagination tokens, as well as containing links to ...
[ "Construct", "a", "new", "Room", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room.js#L118-L198
7,671
matrix-org/matrix-js-sdk
src/models/room.js
calculateRoomName
function calculateRoomName(room, userId, ignoreRoomNameEvent) { if (!ignoreRoomNameEvent) { // check for an alias, if any. for now, assume first alias is the // official one. const mRoomName = room.currentState.getStateEvents("m.room.name", ""); if (mRoomName && mRoomName.getContent(...
javascript
function calculateRoomName(room, userId, ignoreRoomNameEvent) { if (!ignoreRoomNameEvent) { // check for an alias, if any. for now, assume first alias is the // official one. const mRoomName = room.currentState.getStateEvents("m.room.name", ""); if (mRoomName && mRoomName.getContent(...
[ "function", "calculateRoomName", "(", "room", ",", "userId", ",", "ignoreRoomNameEvent", ")", "{", "if", "(", "!", "ignoreRoomNameEvent", ")", "{", "// check for an alias, if any. for now, assume first alias is the", "// official one.", "const", "mRoomName", "=", "room", ...
This is an internal method. Calculates the name of the room from the current room state. @param {Room} room The matrix room. @param {string} userId The client's user ID. Used to filter room members correctly. @param {bool} ignoreRoomNameEvent Return the implicit room name that we'd see if there was no m.room.name event...
[ "This", "is", "an", "internal", "method", ".", "Calculates", "the", "name", "of", "the", "room", "from", "the", "current", "room", "state", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room.js#L1658-L1741
7,672
matrix-org/matrix-js-sdk
src/interactive-auth.js
InteractiveAuth
function InteractiveAuth(opts) { this._matrixClient = opts.matrixClient; this._data = opts.authData || {}; this._requestCallback = opts.doRequest; // startAuthStage included for backwards compat this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this._completionDeferred = nul...
javascript
function InteractiveAuth(opts) { this._matrixClient = opts.matrixClient; this._data = opts.authData || {}; this._requestCallback = opts.doRequest; // startAuthStage included for backwards compat this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this._completionDeferred = nul...
[ "function", "InteractiveAuth", "(", "opts", ")", "{", "this", ".", "_matrixClient", "=", "opts", ".", "matrixClient", ";", "this", ".", "_data", "=", "opts", ".", "authData", "||", "{", "}", ";", "this", ".", "_requestCallback", "=", "opts", ".", "doRequ...
Abstracts the logic used to drive the interactive auth process. <p>Components implementing an interactive auth flow should instantiate one of these, passing in the necessary callbacks to the constructor. They should then call attemptAuth, which will return a promise which will resolve or reject when the interactive-au...
[ "Abstracts", "the", "logic", "used", "to", "drive", "the", "interactive", "auth", "process", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L92-L107
7,673
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { this._completionDeferred = Promise.defer(); // wrap in a promise so that if _startNextAuthStage // throws, it rejects the promise in a consistent way return Promise.resolve().then(() => { // if we have no flows, try a request (we'll have // just a se...
javascript
function() { this._completionDeferred = Promise.defer(); // wrap in a promise so that if _startNextAuthStage // throws, it rejects the promise in a consistent way return Promise.resolve().then(() => { // if we have no flows, try a request (we'll have // just a se...
[ "function", "(", ")", "{", "this", ".", "_completionDeferred", "=", "Promise", ".", "defer", "(", ")", ";", "// wrap in a promise so that if _startNextAuthStage", "// throws, it rejects the promise in a consistent way", "return", "Promise", ".", "resolve", "(", ")", ".", ...
begin the authentication process. @return {module:client.Promise} which resolves to the response on success, or rejects with the error on failure. Rejects with NoAuthFlowFoundError if no suitable authentication flow can be found
[ "begin", "the", "authentication", "process", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L117-L132
7,674
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { if (!this._data.session) return; let authDict = {}; if (this._currentStage == EMAIL_STAGE_TYPE) { // The email can be validated out-of-band, but we need to provide the // creds so the HS can go & check it. if (this._emailSid) { co...
javascript
function() { if (!this._data.session) return; let authDict = {}; if (this._currentStage == EMAIL_STAGE_TYPE) { // The email can be validated out-of-band, but we need to provide the // creds so the HS can go & check it. if (this._emailSid) { co...
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "_data", ".", "session", ")", "return", ";", "let", "authDict", "=", "{", "}", ";", "if", "(", "this", ".", "_currentStage", "==", "EMAIL_STAGE_TYPE", ")", "{", "// The email can be validated out-of-b...
Poll to check if the auth session or current stage has been completed out-of-band. If so, the attemptAuth promise will be resolved.
[ "Poll", "to", "check", "if", "the", "auth", "session", "or", "current", "stage", "has", "been", "completed", "out", "-", "of", "-", "band", ".", "If", "so", "the", "attemptAuth", "promise", "will", "be", "resolved", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L139-L162
7,675
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(loginType) { let params = {}; if (this._data && this._data.params) { params = this._data.params; } return params[loginType]; }
javascript
function(loginType) { let params = {}; if (this._data && this._data.params) { params = this._data.params; } return params[loginType]; }
[ "function", "(", "loginType", ")", "{", "let", "params", "=", "{", "}", ";", "if", "(", "this", ".", "_data", "&&", "this", ".", "_data", ".", "params", ")", "{", "params", "=", "this", ".", "_data", ".", "params", ";", "}", "return", "params", "...
get the server params for a given stage @param {string} loginType login type for the stage @return {object?} any parameters from the server for this stage
[ "get", "the", "server", "params", "for", "a", "given", "stage" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L189-L195
7,676
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(auth, background) { const self = this; // hackery to make sure that synchronous exceptions end up in the catch // handler (without the additional event loop entailed by q.fcall or an // extra Promise.resolve().then) let prom; try { prom = this._reque...
javascript
function(auth, background) { const self = this; // hackery to make sure that synchronous exceptions end up in the catch // handler (without the additional event loop entailed by q.fcall or an // extra Promise.resolve().then) let prom; try { prom = this._reque...
[ "function", "(", "auth", ",", "background", ")", "{", "const", "self", "=", "this", ";", "// hackery to make sure that synchronous exceptions end up in the catch", "// handler (without the additional event loop entailed by q.fcall or an", "// extra Promise.resolve().then)", "let", "p...
Fire off a request, and either resolve the promise, or call startAuthStage. @private @param {object?} auth new auth dict, including session id @param {bool?} background If true, this request is a background poll, so it failing will not result in the attemptAuth promise being rejected. This can be set to true for reque...
[ "Fire", "off", "a", "request", "and", "either", "resolve", "the", "promise", "or", "call", "startAuthStage", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L256-L308
7,677
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const nextStage = this._chooseStage(); if (!nextStage) { throw new Error("No incomplete flows from the server"); } this._currentStage = nextStage; if (nextStage == 'm.login.dummy') { this.submitAuthDict({ type: 'm.login.dummy'...
javascript
function() { const nextStage = this._chooseStage(); if (!nextStage) { throw new Error("No incomplete flows from the server"); } this._currentStage = nextStage; if (nextStage == 'm.login.dummy') { this.submitAuthDict({ type: 'm.login.dummy'...
[ "function", "(", ")", "{", "const", "nextStage", "=", "this", ".", "_chooseStage", "(", ")", ";", "if", "(", "!", "nextStage", ")", "{", "throw", "new", "Error", "(", "\"No incomplete flows from the server\"", ")", ";", "}", "this", ".", "_currentStage", "...
Pick the next stage and call the callback @private @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found
[ "Pick", "the", "next", "stage", "and", "call", "the", "callback" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L316-L343
7,678
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const flow = this._chooseFlow(); console.log("Active flow => %s", JSON.stringify(flow)); const nextStage = this._firstUncompletedStage(flow); console.log("Next stage: %s", nextStage); return nextStage; }
javascript
function() { const flow = this._chooseFlow(); console.log("Active flow => %s", JSON.stringify(flow)); const nextStage = this._firstUncompletedStage(flow); console.log("Next stage: %s", nextStage); return nextStage; }
[ "function", "(", ")", "{", "const", "flow", "=", "this", ".", "_chooseFlow", "(", ")", ";", "console", ".", "log", "(", "\"Active flow => %s\"", ",", "JSON", ".", "stringify", "(", "flow", ")", ")", ";", "const", "nextStage", "=", "this", ".", "_firstU...
Pick the next auth stage @private @return {string?} login type @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found
[ "Pick", "the", "next", "auth", "stage" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L352-L358
7,679
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const flows = this._data.flows || []; // we've been given an email or we've already done an email part const haveEmail = Boolean(this._inputs.emailAddress) || Boolean(this._emailSid); const haveMsisdn = ( Boolean(this._inputs.phoneCountry) && Boolean...
javascript
function() { const flows = this._data.flows || []; // we've been given an email or we've already done an email part const haveEmail = Boolean(this._inputs.emailAddress) || Boolean(this._emailSid); const haveMsisdn = ( Boolean(this._inputs.phoneCountry) && Boolean...
[ "function", "(", ")", "{", "const", "flows", "=", "this", ".", "_data", ".", "flows", "||", "[", "]", ";", "// we've been given an email or we've already done an email part", "const", "haveEmail", "=", "Boolean", "(", "this", ".", "_inputs", ".", "emailAddress", ...
Pick one of the flows from the returned list If a flow using all of the inputs is found, it will be returned, otherwise, null will be returned. Only flows using all given inputs are chosen because it is likley to be surprising if the user provides a credential and it is not used. For example, for registration, this co...
[ "Pick", "one", "of", "the", "flows", "from", "the", "returned", "list", "If", "a", "flow", "using", "all", "of", "the", "inputs", "is", "found", "it", "will", "be", "returned", "otherwise", "null", "will", "be", "returned", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L375-L409
7,680
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(flow) { const completed = (this._data || {}).completed || []; for (let i = 0; i < flow.stages.length; ++i) { const stageType = flow.stages[i]; if (completed.indexOf(stageType) === -1) { return stageType; } } }
javascript
function(flow) { const completed = (this._data || {}).completed || []; for (let i = 0; i < flow.stages.length; ++i) { const stageType = flow.stages[i]; if (completed.indexOf(stageType) === -1) { return stageType; } } }
[ "function", "(", "flow", ")", "{", "const", "completed", "=", "(", "this", ".", "_data", "||", "{", "}", ")", ".", "completed", "||", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "flow", ".", "stages", ".", "length", ";", "...
Get the first uncompleted stage in the given flow @private @param {object} flow @return {string} login type
[ "Get", "the", "first", "uncompleted", "stage", "in", "the", "given", "flow" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L418-L426
7,681
matrix-org/matrix-js-sdk
src/models/room-member.js
RoomMember
function RoomMember(roomId, userId) { this.roomId = roomId; this.userId = userId; this.typing = false; this.name = userId; this.rawDisplayName = userId; this.powerLevel = 0; this.powerLevelNorm = 0; this.user = null; this.membership = null; this.events = { member: null, ...
javascript
function RoomMember(roomId, userId) { this.roomId = roomId; this.userId = userId; this.typing = false; this.name = userId; this.rawDisplayName = userId; this.powerLevel = 0; this.powerLevelNorm = 0; this.user = null; this.membership = null; this.events = { member: null, ...
[ "function", "RoomMember", "(", "roomId", ",", "userId", ")", "{", "this", ".", "roomId", "=", "roomId", ";", "this", ".", "userId", "=", "userId", ";", "this", ".", "typing", "=", "false", ";", "this", ".", "name", "=", "userId", ";", "this", ".", ...
Construct a new room member. @constructor @alias module:models/room-member @param {string} roomId The room ID of the member. @param {string} userId The user ID of the member. @prop {string} roomId The room ID for this member. @prop {string} userId The user ID of this member. @prop {boolean} typing True if the room me...
[ "Construct", "a", "new", "room", "member", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room-member.js#L48-L63
7,682
matrix-org/matrix-js-sdk
src/models/room-state.js
RoomState
function RoomState(roomId, oobMemberFlags = undefined) { this.roomId = roomId; this.members = { // userId: RoomMember }; this.events = { // eventType: { stateKey: MatrixEvent } }; this.paginationToken = null; this._sentinels = { // userId: RoomMember }; this....
javascript
function RoomState(roomId, oobMemberFlags = undefined) { this.roomId = roomId; this.members = { // userId: RoomMember }; this.events = { // eventType: { stateKey: MatrixEvent } }; this.paginationToken = null; this._sentinels = { // userId: RoomMember }; this....
[ "function", "RoomState", "(", "roomId", ",", "oobMemberFlags", "=", "undefined", ")", "{", "this", ".", "roomId", "=", "roomId", ";", "this", ".", "members", "=", "{", "// userId: RoomMember", "}", ";", "this", ".", "events", "=", "{", "// eventType: { state...
Construct room state. Room State represents the state of the room at a given point. It can be mutated by adding state events to it. There are two types of room member associated with a state event: normal member objects (accessed via getMember/getMembers) which mutate with the state to represent the current state of t...
[ "Construct", "room", "state", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room-state.js#L64-L100
7,683
matrix-org/matrix-js-sdk
src/crypto/algorithms/olm.js
OlmEncryption
function OlmEncryption(params) { base.EncryptionAlgorithm.call(this, params); this._sessionPrepared = false; this._prepPromise = null; }
javascript
function OlmEncryption(params) { base.EncryptionAlgorithm.call(this, params); this._sessionPrepared = false; this._prepPromise = null; }
[ "function", "OlmEncryption", "(", "params", ")", "{", "base", ".", "EncryptionAlgorithm", ".", "call", "(", "this", ",", "params", ")", ";", "this", ".", "_sessionPrepared", "=", "false", ";", "this", ".", "_prepPromise", "=", "null", ";", "}" ]
Olm encryption implementation @constructor @extends {module:crypto/algorithms/base.EncryptionAlgorithm} @param {object} params parameters, as per {@link module:crypto/algorithms/base.EncryptionAlgorithm}
[ "Olm", "encryption", "implementation" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/algorithms/olm.js#L43-L47
7,684
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliQueryKeys
function expectAliQueryKeys() { // can't query keys before bob has uploaded them expect(bobTestClient.deviceKeys).toBeTruthy(); const bobKeys = {}; bobKeys[bobDeviceId] = bobTestClient.deviceKeys; aliTestClient.httpBackend.when("POST", "/keys/query") .respond(200, function(path, content...
javascript
function expectAliQueryKeys() { // can't query keys before bob has uploaded them expect(bobTestClient.deviceKeys).toBeTruthy(); const bobKeys = {}; bobKeys[bobDeviceId] = bobTestClient.deviceKeys; aliTestClient.httpBackend.when("POST", "/keys/query") .respond(200, function(path, content...
[ "function", "expectAliQueryKeys", "(", ")", "{", "// can't query keys before bob has uploaded them", "expect", "(", "bobTestClient", ".", "deviceKeys", ")", ".", "toBeTruthy", "(", ")", ";", "const", "bobKeys", "=", "{", "}", ";", "bobKeys", "[", "bobDeviceId", "]...
Set an expectation that ali will query bobs keys; then flush the http request. @return {promise} resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "ali", "will", "query", "bobs", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L67-L85
7,685
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectBobQueryKeys
function expectBobQueryKeys() { // can't query keys before ali has uploaded them expect(aliTestClient.deviceKeys).toBeTruthy(); const aliKeys = {}; aliKeys[aliDeviceId] = aliTestClient.deviceKeys; console.log("query result will be", aliKeys); bobTestClient.httpBackend.when( "POST", "/k...
javascript
function expectBobQueryKeys() { // can't query keys before ali has uploaded them expect(aliTestClient.deviceKeys).toBeTruthy(); const aliKeys = {}; aliKeys[aliDeviceId] = aliTestClient.deviceKeys; console.log("query result will be", aliKeys); bobTestClient.httpBackend.when( "POST", "/k...
[ "function", "expectBobQueryKeys", "(", ")", "{", "// can't query keys before ali has uploaded them", "expect", "(", "aliTestClient", ".", "deviceKeys", ")", ".", "toBeTruthy", "(", ")", ";", "const", "aliKeys", "=", "{", "}", ";", "aliKeys", "[", "aliDeviceId", "]...
Set an expectation that bob will query alis keys; then flush the http request. @return {promise} which resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "bob", "will", "query", "alis", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L92-L113
7,686
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliClaimKeys
function expectAliClaimKeys() { return bobTestClient.awaitOneTimeKeyUpload().then((keys) => { aliTestClient.httpBackend.when( "POST", "/keys/claim", ).respond(200, function(path, content) { const claimType = content.one_time_keys[bobUserId][bobDeviceId]; expect(cl...
javascript
function expectAliClaimKeys() { return bobTestClient.awaitOneTimeKeyUpload().then((keys) => { aliTestClient.httpBackend.when( "POST", "/keys/claim", ).respond(200, function(path, content) { const claimType = content.one_time_keys[bobUserId][bobDeviceId]; expect(cl...
[ "function", "expectAliClaimKeys", "(", ")", "{", "return", "bobTestClient", ".", "awaitOneTimeKeyUpload", "(", ")", ".", "then", "(", "(", "keys", ")", "=>", "{", "aliTestClient", ".", "httpBackend", ".", "when", "(", "\"POST\"", ",", "\"/keys/claim\"", ",", ...
Set an expectation that ali will claim one of bob's keys; then flush the http request. @return {promise} resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "ali", "will", "claim", "one", "of", "bob", "s", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L120-L149
7,687
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
aliSendsFirstMessage
function aliSendsFirstMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliQueryKeys() .then(expectAliClaimKeys) .then(expectAliSendMessageRequest), ]).spread(function(_, ciphertext) { return ciphertext; }); }
javascript
function aliSendsFirstMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliQueryKeys() .then(expectAliClaimKeys) .then(expectAliSendMessageRequest), ]).spread(function(_, ciphertext) { return ciphertext; }); }
[ "function", "aliSendsFirstMessage", "(", ")", "{", "return", "Promise", ".", "all", "(", "[", "sendMessage", "(", "aliTestClient", ".", "client", ")", ",", "expectAliQueryKeys", "(", ")", ".", "then", "(", "expectAliClaimKeys", ")", ".", "then", "(", "expect...
Ali sends a message, first claiming e2e keys. Set the expectations and check the results. @return {promise} which resolves to the ciphertext for Bob's device.
[ "Ali", "sends", "a", "message", "first", "claiming", "e2e", "keys", ".", "Set", "the", "expectations", "and", "check", "the", "results", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L200-L209
7,688
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
aliSendsMessage
function aliSendsMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliSendMessageRequest(), ]).spread(function(_, ciphertext) { return ciphertext; }); }
javascript
function aliSendsMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliSendMessageRequest(), ]).spread(function(_, ciphertext) { return ciphertext; }); }
[ "function", "aliSendsMessage", "(", ")", "{", "return", "Promise", ".", "all", "(", "[", "sendMessage", "(", "aliTestClient", ".", "client", ")", ",", "expectAliSendMessageRequest", "(", ")", ",", "]", ")", ".", "spread", "(", "function", "(", "_", ",", ...
Ali sends a message without first claiming e2e keys. Set the expectations and check the results. @return {promise} which resolves to the ciphertext for Bob's device.
[ "Ali", "sends", "a", "message", "without", "first", "claiming", "e2e", "keys", ".", "Set", "the", "expectations", "and", "check", "the", "results", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L217-L224
7,689
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliSendMessageRequest
function expectAliSendMessageRequest() { return expectSendMessageRequest(aliTestClient.httpBackend).then(function(content) { aliMessages.push(content); expect(utils.keys(content.ciphertext)).toEqual([bobTestClient.getDeviceKey()]); const ciphertext = content.ciphertext[bobTestClient.getDevic...
javascript
function expectAliSendMessageRequest() { return expectSendMessageRequest(aliTestClient.httpBackend).then(function(content) { aliMessages.push(content); expect(utils.keys(content.ciphertext)).toEqual([bobTestClient.getDeviceKey()]); const ciphertext = content.ciphertext[bobTestClient.getDevic...
[ "function", "expectAliSendMessageRequest", "(", ")", "{", "return", "expectSendMessageRequest", "(", "aliTestClient", ".", "httpBackend", ")", ".", "then", "(", "function", "(", "content", ")", "{", "aliMessages", ".", "push", "(", "content", ")", ";", "expect",...
Set an expectation that Ali will send a message, and flush the request @return {promise} which resolves to the ciphertext for Bob's device.
[ "Set", "an", "expectation", "that", "Ali", "will", "send", "a", "message", "and", "flush", "the", "request" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L247-L255
7,690
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectBobSendMessageRequest
function expectBobSendMessageRequest() { return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) { bobMessages.push(content); const aliKeyId = "curve25519:" + aliDeviceId; const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId]; expect(utils.k...
javascript
function expectBobSendMessageRequest() { return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) { bobMessages.push(content); const aliKeyId = "curve25519:" + aliDeviceId; const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId]; expect(utils.k...
[ "function", "expectBobSendMessageRequest", "(", ")", "{", "return", "expectSendMessageRequest", "(", "bobTestClient", ".", "httpBackend", ")", ".", "then", "(", "function", "(", "content", ")", "{", "bobMessages", ".", "push", "(", "content", ")", ";", "const", ...
Set an expectation that Bob will send a message, and flush the request @return {promise} which resolves to the ciphertext for Bob's device.
[ "Set", "an", "expectation", "that", "Bob", "will", "send", "a", "message", "and", "flush", "the", "request" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L262-L272
7,691
matrix-org/matrix-js-sdk
src/crypto/OlmDevice.js
OlmDevice
function OlmDevice(cryptoStore) { this._cryptoStore = cryptoStore; this._pickleKey = "DEFAULT_KEY"; // don't know these until we load the account from storage in init() this.deviceCurve25519Key = null; this.deviceEd25519Key = null; this._maxOneTimeKeys = null; // we don't bother stashing o...
javascript
function OlmDevice(cryptoStore) { this._cryptoStore = cryptoStore; this._pickleKey = "DEFAULT_KEY"; // don't know these until we load the account from storage in init() this.deviceCurve25519Key = null; this.deviceEd25519Key = null; this._maxOneTimeKeys = null; // we don't bother stashing o...
[ "function", "OlmDevice", "(", "cryptoStore", ")", "{", "this", ".", "_cryptoStore", "=", "cryptoStore", ";", "this", ".", "_pickleKey", "=", "\"DEFAULT_KEY\"", ";", "// don't know these until we load the account from storage in init()", "this", ".", "deviceCurve25519Key", ...
The type of object we use for importing and exporting megolm session data. @typedef {Object} module:crypto/OlmDevice.MegolmSessionData @property {String} sender_key Sender's Curve25519 device key @property {String[]} forwarding_curve25519_key_chain Devices which forwarded this session to us (normally empty). @propert...
[ "The", "type", "of", "object", "we", "use", "for", "importing", "and", "exporting", "megolm", "session", "data", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/OlmDevice.js#L72-L106
7,692
matrix-org/matrix-js-sdk
src/crypto/algorithms/megolm.js
MegolmEncryption
function MegolmEncryption(params) { base.EncryptionAlgorithm.call(this, params); // the most recent attempt to set up a session. This is used to serialise // the session setups, so that we have a race-free view of which session we // are using, and which devices we have shared the keys with. It resolve...
javascript
function MegolmEncryption(params) { base.EncryptionAlgorithm.call(this, params); // the most recent attempt to set up a session. This is used to serialise // the session setups, so that we have a race-free view of which session we // are using, and which devices we have shared the keys with. It resolve...
[ "function", "MegolmEncryption", "(", "params", ")", "{", "base", ".", "EncryptionAlgorithm", ".", "call", "(", "this", ",", "params", ")", ";", "// the most recent attempt to set up a session. This is used to serialise", "// the session setups, so that we have a race-free view of...
Megolm encryption implementation @constructor @extends {module:crypto/algorithms/base.EncryptionAlgorithm} @param {object} params parameters, as per {@link module:crypto/algorithms/base.EncryptionAlgorithm}
[ "Megolm", "encryption", "implementation" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/algorithms/megolm.js#L137-L163
7,693
matrix-org/matrix-js-sdk
src/models/group.js
Group
function Group(groupId) { this.groupId = groupId; this.name = null; this.avatarUrl = null; this.myMembership = null; this.inviter = null; }
javascript
function Group(groupId) { this.groupId = groupId; this.name = null; this.avatarUrl = null; this.myMembership = null; this.inviter = null; }
[ "function", "Group", "(", "groupId", ")", "{", "this", ".", "groupId", "=", "groupId", ";", "this", ".", "name", "=", "null", ";", "this", ".", "avatarUrl", "=", "null", ";", "this", ".", "myMembership", "=", "null", ";", "this", ".", "inviter", "=",...
Construct a new Group. @param {string} groupId The ID of this group. @prop {string} groupId The ID of this group. @prop {string} name The human-readable display name for this group. @prop {string} avatarUrl The mxc URL for this group's avatar. @prop {string} myMembership The logged in user's membership of this group ...
[ "Construct", "a", "new", "Group", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/group.js#L37-L43
7,694
matrix-org/matrix-js-sdk
src/models/user.js
User
function User(userId) { this.userId = userId; this.presence = "offline"; this.presenceStatusMsg = null; this._unstable_statusMessage = ""; this.displayName = userId; this.rawDisplayName = userId; this.avatarUrl = null; this.lastActiveAgo = 0; this.lastPresenceTs = 0; this.current...
javascript
function User(userId) { this.userId = userId; this.presence = "offline"; this.presenceStatusMsg = null; this._unstable_statusMessage = ""; this.displayName = userId; this.rawDisplayName = userId; this.avatarUrl = null; this.lastActiveAgo = 0; this.lastPresenceTs = 0; this.current...
[ "function", "User", "(", "userId", ")", "{", "this", ".", "userId", "=", "userId", ";", "this", ".", "presence", "=", "\"offline\"", ";", "this", ".", "presenceStatusMsg", "=", "null", ";", "this", ".", "_unstable_statusMessage", "=", "\"\"", ";", "this", ...
Construct a new User. A User must have an ID and can optionally have extra information associated with it. @constructor @param {string} userId Required. The ID of this user. @prop {string} userId The ID of the user. @prop {Object} info The info object supplied in the constructor. @prop {string} displayName The 'display...
[ "Construct", "a", "new", "User", ".", "A", "User", "must", "have", "an", "ID", "and", "can", "optionally", "have", "extra", "information", "associated", "with", "it", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/user.js#L48-L64
7,695
matrix-org/matrix-js-sdk
src/filter-component.js
FilterComponent
function FilterComponent(filter_json) { this.filter_json = filter_json; this.types = filter_json.types || null; this.not_types = filter_json.not_types || []; this.rooms = filter_json.rooms || null; this.not_rooms = filter_json.not_rooms || []; this.senders = filter_json.senders || null; t...
javascript
function FilterComponent(filter_json) { this.filter_json = filter_json; this.types = filter_json.types || null; this.not_types = filter_json.not_types || []; this.rooms = filter_json.rooms || null; this.not_rooms = filter_json.not_rooms || []; this.senders = filter_json.senders || null; t...
[ "function", "FilterComponent", "(", "filter_json", ")", "{", "this", ".", "filter_json", "=", "filter_json", ";", "this", ".", "types", "=", "filter_json", ".", "types", "||", "null", ";", "this", ".", "not_types", "=", "filter_json", ".", "not_types", "||",...
FilterComponent is a section of a Filter definition which defines the types, rooms, senders filters etc to be applied to a particular type of resource. This is all ported over from synapse's Filter object. N.B. that synapse refers to these as 'Filters', and what js-sdk refers to as 'Filters' are referred to as 'Filter...
[ "FilterComponent", "is", "a", "section", "of", "a", "Filter", "definition", "which", "defines", "the", "types", "rooms", "senders", "filters", "etc", "to", "be", "applied", "to", "a", "particular", "type", "of", "resource", ".", "This", "is", "all", "ported"...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/filter-component.js#L48-L61
7,696
matrix-org/matrix-js-sdk
src/http-api.js
function() { const params = { access_token: this.opts.accessToken, }; return { base: this.opts.baseUrl, path: "/_matrix/media/v1/upload", params: params, }; }
javascript
function() { const params = { access_token: this.opts.accessToken, }; return { base: this.opts.baseUrl, path: "/_matrix/media/v1/upload", params: params, }; }
[ "function", "(", ")", "{", "const", "params", "=", "{", "access_token", ":", "this", ".", "opts", ".", "accessToken", ",", "}", ";", "return", "{", "base", ":", "this", ".", "opts", ".", "baseUrl", ",", "path", ":", "\"/_matrix/media/v1/upload\"", ",", ...
Get the content repository url with query parameters. @return {Object} An object with a 'base', 'path' and 'params' for base URL, path and query parameters respectively.
[ "Get", "the", "content", "repository", "url", "with", "query", "parameters", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L98-L107
7,697
matrix-org/matrix-js-sdk
src/http-api.js
function(path, queryParams, prefix) { let queryString = ""; if (queryParams) { queryString = "?" + utils.encodeParams(queryParams); } return this.opts.baseUrl + prefix + path + queryString; }
javascript
function(path, queryParams, prefix) { let queryString = ""; if (queryParams) { queryString = "?" + utils.encodeParams(queryParams); } return this.opts.baseUrl + prefix + path + queryString; }
[ "function", "(", "path", ",", "queryParams", ",", "prefix", ")", "{", "let", "queryString", "=", "\"\"", ";", "if", "(", "queryParams", ")", "{", "queryString", "=", "\"?\"", "+", "utils", ".", "encodeParams", "(", "queryParams", ")", ";", "}", "return",...
Form and return a homeserver request URL based on the given path params and prefix. @param {string} path The HTTP path <b>after</b> the supplied prefix e.g. "/createRoom". @param {Object} queryParams A dict of query params (these will NOT be urlencoded). @param {string} prefix The full prefix to use e.g. "/_matrix/clie...
[ "Form", "and", "return", "a", "homeserver", "request", "URL", "based", "on", "the", "given", "path", "params", "and", "prefix", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L641-L647
7,698
matrix-org/matrix-js-sdk
src/http-api.js
parseErrorResponse
function parseErrorResponse(response, body) { const httpStatus = response.statusCode; const contentType = getResponseContentType(response); let err; if (contentType) { if (contentType.type === 'application/json') { err = new module.exports.MatrixError(JSON.parse(body)); } el...
javascript
function parseErrorResponse(response, body) { const httpStatus = response.statusCode; const contentType = getResponseContentType(response); let err; if (contentType) { if (contentType.type === 'application/json') { err = new module.exports.MatrixError(JSON.parse(body)); } el...
[ "function", "parseErrorResponse", "(", "response", ",", "body", ")", "{", "const", "httpStatus", "=", "response", ".", "statusCode", ";", "const", "contentType", "=", "getResponseContentType", "(", "response", ")", ";", "let", "err", ";", "if", "(", "contentTy...
Attempt to turn an HTTP error response into a Javascript Error. If it is a JSON response, we will parse it into a MatrixError. Otherwise we return a generic Error. @param {XMLHttpRequest|http.IncomingMessage} response response object @param {String} body raw body of the response @returns {Error}
[ "Attempt", "to", "turn", "an", "HTTP", "error", "response", "into", "a", "Javascript", "Error", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L866-L884
7,699
matrix-org/matrix-js-sdk
src/client.js
keysFromRecoverySession
function keysFromRecoverySession(sessions, decryptionKey, roomId) { const keys = []; for (const [sessionId, sessionData] of Object.entries(sessions)) { try { const decrypted = keyFromRecoverySession(sessionData, decryptionKey); decrypted.session_id = sessionId; decryp...
javascript
function keysFromRecoverySession(sessions, decryptionKey, roomId) { const keys = []; for (const [sessionId, sessionData] of Object.entries(sessions)) { try { const decrypted = keyFromRecoverySession(sessionData, decryptionKey); decrypted.session_id = sessionId; decryp...
[ "function", "keysFromRecoverySession", "(", "sessions", ",", "decryptionKey", ",", "roomId", ")", "{", "const", "keys", "=", "[", "]", ";", "for", "(", "const", "[", "sessionId", ",", "sessionData", "]", "of", "Object", ".", "entries", "(", "sessions", ")"...
6 hours - an arbitrary value
[ "6", "hours", "-", "an", "arbitrary", "value" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/client.js#L64-L77