repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
instructure/instructure-ui
packages/babel-plugin-transform-class-display-name/lib/index.js
insertDisplayName
function insertDisplayName(path, id) { const assignment = t.assignmentExpression( '=', t.memberExpression( t.identifier(id), t.identifier('displayName') ), t.stringLiteral(id) ) // Put in the assignment expression and a semicolon path.insertAfter([assignment, t.em...
javascript
function insertDisplayName(path, id) { const assignment = t.assignmentExpression( '=', t.memberExpression( t.identifier(id), t.identifier('displayName') ), t.stringLiteral(id) ) // Put in the assignment expression and a semicolon path.insertAfter([assignment, t.em...
[ "function", "insertDisplayName", "(", "path", ",", "id", ")", "{", "const", "assignment", "=", "t", ".", "assignmentExpression", "(", "'='", ",", "t", ".", "memberExpression", "(", "t", ".", "identifier", "(", "id", ")", ",", "t", ".", "identifier", "(",...
Insert a static displayName for the identifier
[ "Insert", "a", "static", "displayName", "for", "the", "identifier" ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/babel-plugin-transform-class-display-name/lib/index.js#L63-L74
train
instructure/instructure-ui
packages/ui-i18n/src/DateTime.js
parse
function parse (dateString, locale, timezone) { _checkParams(locale, timezone) // list all available localized formats, from most specific to least return moment.tz(dateString, [moment.ISO_8601, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], locale, timezone) }
javascript
function parse (dateString, locale, timezone) { _checkParams(locale, timezone) // list all available localized formats, from most specific to least return moment.tz(dateString, [moment.ISO_8601, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], locale, timezone) }
[ "function", "parse", "(", "dateString", ",", "locale", ",", "timezone", ")", "{", "_checkParams", "(", "locale", ",", "timezone", ")", "// list all available localized formats, from most specific to least", "return", "moment", ".", "tz", "(", "dateString", ",", "[", ...
Parses a string into a localized ISO 8601 string with timezone @param {String} dateString @param {String} locale @param {String} timezone @returns {String} ISO 8601 string
[ "Parses", "a", "string", "into", "a", "localized", "ISO", "8601", "string", "with", "timezone" ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-i18n/src/DateTime.js#L53-L57
train
instructure/instructure-ui
packages/ui-themeable/src/mirrorShorthand.js
mirrorShorthandCorners
function mirrorShorthandCorners (values) { if (typeof values !== 'string') { return } const valuesArr = values.split(' ') if (valuesArr.length === 2) { // swap the 1st and 2nd values [ valuesArr[0], valuesArr[1] ] = [ valuesArr[1], valuesArr[0] ] } if (valuesArr.length === 3) { // conv...
javascript
function mirrorShorthandCorners (values) { if (typeof values !== 'string') { return } const valuesArr = values.split(' ') if (valuesArr.length === 2) { // swap the 1st and 2nd values [ valuesArr[0], valuesArr[1] ] = [ valuesArr[1], valuesArr[0] ] } if (valuesArr.length === 3) { // conv...
[ "function", "mirrorShorthandCorners", "(", "values", ")", "{", "if", "(", "typeof", "values", "!==", "'string'", ")", "{", "return", "}", "const", "valuesArr", "=", "values", ".", "split", "(", "' '", ")", "if", "(", "valuesArr", ".", "length", "===", "2...
Convert shorthand CSS properties for corners to rtl Given a string representing a CSS shorthand for corners, swaps the values such that 2,3 and 4 value syntax is rtl instead of ltr. See the following for further reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties @param {String} values -...
[ "Convert", "shorthand", "CSS", "properties", "for", "corners", "to", "rtl" ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-themeable/src/mirrorShorthand.js#L73-L96
train
instructure/instructure-ui
packages/ui-layout/src/mirrorPlacement.js
mirrorHorizontalPlacement
function mirrorHorizontalPlacement (placement, delimiter) { return executeMirrorFunction(placement, (first, second) => { return [first, second].map(value => { return (value === 'start' || value === 'end') ? mirror[value] : value }) }, delimiter) }
javascript
function mirrorHorizontalPlacement (placement, delimiter) { return executeMirrorFunction(placement, (first, second) => { return [first, second].map(value => { return (value === 'start' || value === 'end') ? mirror[value] : value }) }, delimiter) }
[ "function", "mirrorHorizontalPlacement", "(", "placement", ",", "delimiter", ")", "{", "return", "executeMirrorFunction", "(", "placement", ",", "(", "first", ",", "second", ")", "=>", "{", "return", "[", "first", ",", "second", "]", ".", "map", "(", "value"...
Given a string or array of one or two placement values, mirrors the placement horizontally. Examples ```js mirrorHorizontalPlacement('top start') // input ['top', 'end'] // output mirrorPlacement('top start', ' ') // input 'top end' //output ``` @param {string|Array} placement - a string of the form '<value> <value>...
[ "Given", "a", "string", "or", "array", "of", "one", "or", "two", "placement", "values", "mirrors", "the", "placement", "horizontally", "." ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-layout/src/mirrorPlacement.js#L80-L86
train
instructure/instructure-ui
packages/ui-react-utils/src/windowMessageListener.js
origin
function origin (node) { const ownWindow = ownerWindow(node) const { location } = ownWindow if (location.protocol === 'file:') { return '*' } else if (location.origin) { return location.origin } else if (location.port) { return `${location.protocol}//${location.hostname}:${location.port}` } e...
javascript
function origin (node) { const ownWindow = ownerWindow(node) const { location } = ownWindow if (location.protocol === 'file:') { return '*' } else if (location.origin) { return location.origin } else if (location.port) { return `${location.protocol}//${location.hostname}:${location.port}` } e...
[ "function", "origin", "(", "node", ")", "{", "const", "ownWindow", "=", "ownerWindow", "(", "node", ")", "const", "{", "location", "}", "=", "ownWindow", "if", "(", "location", ".", "protocol", "===", "'file:'", ")", "{", "return", "'*'", "}", "else", ...
Return the origin of the owner window of the DOM element see https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage @param {DOMElement} node @returns {String} the origin
[ "Return", "the", "origin", "of", "the", "owner", "window", "of", "the", "DOM", "element" ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-react-utils/src/windowMessageListener.js#L94-L109
train
instructure/instructure-ui
packages/ui-i18n/src/Decimal.js
_format
function _format (input, locale) { locale = locale || Locale.browserLocale() // eslint-disable-line no-param-reassign let result = input const { thousands, decimal } = Decimal.getDelimiters(locale) const isNegative = (result[0] === '-') // remove all characters except for digits and decimal delimiters re...
javascript
function _format (input, locale) { locale = locale || Locale.browserLocale() // eslint-disable-line no-param-reassign let result = input const { thousands, decimal } = Decimal.getDelimiters(locale) const isNegative = (result[0] === '-') // remove all characters except for digits and decimal delimiters re...
[ "function", "_format", "(", "input", ",", "locale", ")", "{", "locale", "=", "locale", "||", "Locale", ".", "browserLocale", "(", ")", "// eslint-disable-line no-param-reassign", "let", "result", "=", "input", "const", "{", "thousands", ",", "decimal", "}", "=...
Cleans up the string given and applies the thousands delimiter Doesn't take into account chinese and indian locales with non-standard grouping This will be addressed in INSTUI-996
[ "Cleans", "up", "the", "string", "given", "and", "applies", "the", "thousands", "delimiter", "Doesn", "t", "take", "into", "account", "chinese", "and", "indian", "locales", "with", "non", "-", "standard", "grouping", "This", "will", "be", "addressed", "in", ...
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-i18n/src/Decimal.js#L138-L178
train
instructure/instructure-ui
packages/ui-themeable/src/scopeStylesToNode.js
scopeCssText
function scopeCssText (cssText, scope) { return transformCss(cssText, (rule) => { const transformed = {...rule} if (!rule.isScoped) { transformed.selector = scopeRule(rule, scope) transformed.isScoped = true } return transformed }) }
javascript
function scopeCssText (cssText, scope) { return transformCss(cssText, (rule) => { const transformed = {...rule} if (!rule.isScoped) { transformed.selector = scopeRule(rule, scope) transformed.isScoped = true } return transformed }) }
[ "function", "scopeCssText", "(", "cssText", ",", "scope", ")", "{", "return", "transformCss", "(", "cssText", ",", "(", "rule", ")", "=>", "{", "const", "transformed", "=", "{", "...", "rule", "}", "if", "(", "!", "rule", ".", "isScoped", ")", "{", "...
Transforms a CSS string to add a scoping selector to each rule @param {String} cssText @param {String} scope a unique identifier to use to scope the styles
[ "Transforms", "a", "CSS", "string", "to", "add", "a", "scoping", "selector", "to", "each", "rule" ]
7cee93b56f34679824b49d79e0d5821e4c9b5ea7
https://github.com/instructure/instructure-ui/blob/7cee93b56f34679824b49d79e0d5821e4c9b5ea7/packages/ui-themeable/src/scopeStylesToNode.js#L82-L91
train
saebekassebil/teoria
lib/note.js
function(oneaccidental) { var key = this.key(), limit = oneaccidental ? 2 : 3; return ['m3', 'm2', 'm-2', 'm-3'] .map(this.interval.bind(this)) .filter(function(note) { var acc = note.accidentalValue(); var diff = key - (note.key() - acc); if (diff < limit && diff > -limit) { ...
javascript
function(oneaccidental) { var key = this.key(), limit = oneaccidental ? 2 : 3; return ['m3', 'm2', 'm-2', 'm-3'] .map(this.interval.bind(this)) .filter(function(note) { var acc = note.accidentalValue(); var diff = key - (note.key() - acc); if (diff < limit && diff > -limit) { ...
[ "function", "(", "oneaccidental", ")", "{", "var", "key", "=", "this", ".", "key", "(", ")", ",", "limit", "=", "oneaccidental", "?", "2", ":", "3", ";", "return", "[", "'m3'", ",", "'m2'", ",", "'m-2'", ",", "'m-3'", "]", ".", "map", "(", "this"...
Returns notes that are enharmonic with this note.
[ "Returns", "notes", "that", "are", "enharmonic", "with", "this", "note", "." ]
0f4bbe8fb0d6a43fd9c96a309ce781c3841114d2
https://github.com/saebekassebil/teoria/blob/0f4bbe8fb0d6a43fd9c96a309ce781c3841114d2/lib/note.js#L116-L131
train
aliyun/aliyun-tablestore-nodejs-sdk
lib/config.js
set
function set(property, value, defaultValue) { if (value === undefined) { if (defaultValue === undefined) { defaultValue = this.keys[property]; } if (typeof defaultValue === 'function') { this[property] = defaultValue.call(this); } else { this[property] = defaultValue;...
javascript
function set(property, value, defaultValue) { if (value === undefined) { if (defaultValue === undefined) { defaultValue = this.keys[property]; } if (typeof defaultValue === 'function') { this[property] = defaultValue.call(this); } else { this[property] = defaultValue;...
[ "function", "set", "(", "property", ",", "value", ",", "defaultValue", ")", "{", "if", "(", "value", "===", "undefined", ")", "{", "if", "(", "defaultValue", "===", "undefined", ")", "{", "defaultValue", "=", "this", ".", "keys", "[", "property", "]", ...
Sets a property on the configuration object, allowing for a default value @api private
[ "Sets", "a", "property", "on", "the", "configuration", "object", "allowing", "for", "a", "default", "value" ]
33cb123d8e5b3e79fbad3cb13f7bed7b2361b620
https://github.com/aliyun/aliyun-tablestore-nodejs-sdk/blob/33cb123d8e5b3e79fbad3cb13f7bed7b2361b620/lib/config.js#L41-L54
train
aliyun/aliyun-tablestore-nodejs-sdk
lib/util-browser.js
function (buffers) { var length = 0, offset = 0, buffer = null, i; for (i = 0; i < buffers.length; i++) { length += buffers[i].length; } buffer = new TableStore.util.Buffer(length); for (i = 0; i < buffers.len...
javascript
function (buffers) { var length = 0, offset = 0, buffer = null, i; for (i = 0; i < buffers.length; i++) { length += buffers[i].length; } buffer = new TableStore.util.Buffer(length); for (i = 0; i < buffers.len...
[ "function", "(", "buffers", ")", "{", "var", "length", "=", "0", ",", "offset", "=", "0", ",", "buffer", "=", "null", ",", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "buffers", ".", "length", ";", "i", "++", ")", "{", "length", "+=",...
Concatenates a list of Buffer objects.
[ "Concatenates", "a", "list", "of", "Buffer", "objects", "." ]
33cb123d8e5b3e79fbad3cb13f7bed7b2361b620
https://github.com/aliyun/aliyun-tablestore-nodejs-sdk/blob/33cb123d8e5b3e79fbad3cb13f7bed7b2361b620/lib/util-browser.js#L199-L216
train
aliyun/aliyun-tablestore-nodejs-sdk
lib/util-browser.js
top
function top(date, fmt) { fmt = fmt || '%Y-%M-%dT%H:%m:%sZ'; function pad(value) { return (value.toString().length < 2) ? '0' + value : value; }; return fmt.replace(/%([a-zA-Z])/g, function (_, fmtCode) { switch (fmtCode) { ...
javascript
function top(date, fmt) { fmt = fmt || '%Y-%M-%dT%H:%m:%sZ'; function pad(value) { return (value.toString().length < 2) ? '0' + value : value; }; return fmt.replace(/%([a-zA-Z])/g, function (_, fmtCode) { switch (fmtCode) { ...
[ "function", "top", "(", "date", ",", "fmt", ")", "{", "fmt", "=", "fmt", "||", "'%Y-%M-%dT%H:%m:%sZ'", ";", "function", "pad", "(", "value", ")", "{", "return", "(", "value", ".", "toString", "(", ")", ".", "length", "<", "2", ")", "?", "'0'", "+",...
for taobao open platform
[ "for", "taobao", "open", "platform" ]
33cb123d8e5b3e79fbad3cb13f7bed7b2361b620
https://github.com/aliyun/aliyun-tablestore-nodejs-sdk/blob/33cb123d8e5b3e79fbad3cb13f7bed7b2361b620/lib/util-browser.js#L329-L354
train
aliyun/aliyun-tablestore-nodejs-sdk
lib/util-browser.js
format
function format(date, formatter) { if (!formatter) formatter = 'unixSeconds'; return TableStore.util.date[formatter](TableStore.util.date.from(date)); }
javascript
function format(date, formatter) { if (!formatter) formatter = 'unixSeconds'; return TableStore.util.date[formatter](TableStore.util.date.from(date)); }
[ "function", "format", "(", "date", ",", "formatter", ")", "{", "if", "(", "!", "formatter", ")", "formatter", "=", "'unixSeconds'", ";", "return", "TableStore", ".", "util", ".", "date", "[", "formatter", "]", "(", "TableStore", ".", "util", ".", "date",...
Given a Date or date-like value, this function formats the date into a string of the requested value. @param [String,number,Date] date @param [String] formatter Valid formats are: # * 'iso8601' # * 'rfc822' # * 'unixSeconds' # * 'unixMilliseconds' @return [String]
[ "Given", "a", "Date", "or", "date", "-", "like", "value", "this", "function", "formats", "the", "date", "into", "a", "string", "of", "the", "requested", "value", "." ]
33cb123d8e5b3e79fbad3cb13f7bed7b2361b620
https://github.com/aliyun/aliyun-tablestore-nodejs-sdk/blob/33cb123d8e5b3e79fbad3cb13f7bed7b2361b620/lib/util-browser.js#L412-L415
train
aliyun/aliyun-tablestore-nodejs-sdk
lib/request.js
Request
function Request(config, operation, params) { var endpoint = new TableStore.Endpoint(config.endpoint); var region = config.region; this.config = config; if (config.maxRetries !== undefined) { TableStore.DefaultRetryPolicy.maxRetryTimes = config.maxRetries; } //如果在sdk外部包装了一层domain,就把它传到this...
javascript
function Request(config, operation, params) { var endpoint = new TableStore.Endpoint(config.endpoint); var region = config.region; this.config = config; if (config.maxRetries !== undefined) { TableStore.DefaultRetryPolicy.maxRetryTimes = config.maxRetries; } //如果在sdk外部包装了一层domain,就把它传到this...
[ "function", "Request", "(", "config", ",", "operation", ",", "params", ")", "{", "var", "endpoint", "=", "new", "TableStore", ".", "Endpoint", "(", "config", ".", "endpoint", ")", ";", "var", "region", "=", "config", ".", "region", ";", "this", ".", "c...
Creates a request for an operation on a given service with a set of input parameters. @param config [TableStore.Config] the config to perform the operation on @param operation [String] the operation to perform on the service @param params [Object] parameters to send to the operation. See the operation's documentation ...
[ "Creates", "a", "request", "for", "an", "operation", "on", "a", "given", "service", "with", "a", "set", "of", "input", "parameters", "." ]
33cb123d8e5b3e79fbad3cb13f7bed7b2361b620
https://github.com/aliyun/aliyun-tablestore-nodejs-sdk/blob/33cb123d8e5b3e79fbad3cb13f7bed7b2361b620/lib/request.js#L118-L138
train
keeweb/kdbxweb
lib/format/kdbx-uuid.js
KdbxUuid
function KdbxUuid(ab) { if (ab === undefined) { ab = new ArrayBuffer(UuidLength); } if (typeof ab === 'string') { ab = ByteUtils.base64ToBytes(ab); } this.id = ab.byteLength === 16 ? ByteUtils.bytesToBase64(ab) : undefined; this.empty = true; if (ab) { var bytes = new...
javascript
function KdbxUuid(ab) { if (ab === undefined) { ab = new ArrayBuffer(UuidLength); } if (typeof ab === 'string') { ab = ByteUtils.base64ToBytes(ab); } this.id = ab.byteLength === 16 ? ByteUtils.bytesToBase64(ab) : undefined; this.empty = true; if (ab) { var bytes = new...
[ "function", "KdbxUuid", "(", "ab", ")", "{", "if", "(", "ab", "===", "undefined", ")", "{", "ab", "=", "new", "ArrayBuffer", "(", "UuidLength", ")", ";", "}", "if", "(", "typeof", "ab", "===", "'string'", ")", "{", "ab", "=", "ByteUtils", ".", "bas...
Uuid for passwords @param {ArrayBuffer|string} ab - ArrayBuffer with data @constructor
[ "Uuid", "for", "passwords" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/format/kdbx-uuid.js#L13-L31
train
keeweb/kdbxweb
lib/utils/binary-stream.js
BinaryStream
function BinaryStream(arrayBuffer) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(1024); this._dataView = new DataView(this._arrayBuffer); this._pos = 0; this._canExpand = !arrayBuffer; }
javascript
function BinaryStream(arrayBuffer) { this._arrayBuffer = arrayBuffer || new ArrayBuffer(1024); this._dataView = new DataView(this._arrayBuffer); this._pos = 0; this._canExpand = !arrayBuffer; }
[ "function", "BinaryStream", "(", "arrayBuffer", ")", "{", "this", ".", "_arrayBuffer", "=", "arrayBuffer", "||", "new", "ArrayBuffer", "(", "1024", ")", ";", "this", ".", "_dataView", "=", "new", "DataView", "(", "this", ".", "_arrayBuffer", ")", ";", "thi...
Stream for accessing array buffer with auto-advanced position @param {ArrayBuffer} [arrayBuffer] @constructor
[ "Stream", "for", "accessing", "array", "buffer", "with", "auto", "-", "advanced", "position" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/binary-stream.js#L8-L13
train
keeweb/kdbxweb
lib/crypto/random.js
getBytes
function getBytes(len) { if (!len) { return new Uint8Array(0); } algo.getBytes(Math.round(Math.random() * len) + 1); var result = algo.getBytes(len); var cryptoBytes = CryptoEngine.random(len); for (var i = cryptoBytes.length - 1; i >= 0; --i) { result[i] ^= cryptoBytes[i]; }...
javascript
function getBytes(len) { if (!len) { return new Uint8Array(0); } algo.getBytes(Math.round(Math.random() * len) + 1); var result = algo.getBytes(len); var cryptoBytes = CryptoEngine.random(len); for (var i = cryptoBytes.length - 1; i >= 0; --i) { result[i] ^= cryptoBytes[i]; }...
[ "function", "getBytes", "(", "len", ")", "{", "if", "(", "!", "len", ")", "{", "return", "new", "Uint8Array", "(", "0", ")", ";", "}", "algo", ".", "getBytes", "(", "Math", ".", "round", "(", "Math", ".", "random", "(", ")", "*", "len", ")", "+...
Gets random bytes @param {number} len - bytes count @return {Uint8Array} - random bytes
[ "Gets", "random", "bytes" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/random.js#L20-L31
train
keeweb/kdbxweb
lib/crypto/key-encryptor-kdf.js
encrypt
function encrypt(key, kdfParams) { var uuid = kdfParams.get('$UUID'); if (!uuid || !(uuid instanceof ArrayBuffer)) { return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf uuid')); } var kdfUuid = ByteUtils.bytesToBase64(uuid); switch (kdfUuid) { case Consts.KdfId...
javascript
function encrypt(key, kdfParams) { var uuid = kdfParams.get('$UUID'); if (!uuid || !(uuid instanceof ArrayBuffer)) { return Promise.reject(new KdbxError(Consts.ErrorCodes.FileCorrupt, 'no kdf uuid')); } var kdfUuid = ByteUtils.bytesToBase64(uuid); switch (kdfUuid) { case Consts.KdfId...
[ "function", "encrypt", "(", "key", ",", "kdfParams", ")", "{", "var", "uuid", "=", "kdfParams", ".", "get", "(", "'$UUID'", ")", ";", "if", "(", "!", "uuid", "||", "!", "(", "uuid", "instanceof", "ArrayBuffer", ")", ")", "{", "return", "Promise", "."...
Derives key from seed using KDF parameters @param {ArrayBuffer} key @param {VarDictionary} kdfParams
[ "Derives", "key", "from", "seed", "using", "KDF", "parameters" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/key-encryptor-kdf.js#L27-L41
train
keeweb/kdbxweb
lib/utils/byte-utils.js
arrayBufferEquals
function arrayBufferEquals(ab1, ab2) { if (ab1.byteLength !== ab2.byteLength) { return false; } var arr1 = new Uint8Array(ab1); var arr2 = new Uint8Array(ab2); for (var i = 0, len = arr1.length; i < len; i++) { if (arr1[i] !== arr2[i]) { return false; } } ...
javascript
function arrayBufferEquals(ab1, ab2) { if (ab1.byteLength !== ab2.byteLength) { return false; } var arr1 = new Uint8Array(ab1); var arr2 = new Uint8Array(ab2); for (var i = 0, len = arr1.length; i < len; i++) { if (arr1[i] !== arr2[i]) { return false; } } ...
[ "function", "arrayBufferEquals", "(", "ab1", ",", "ab2", ")", "{", "if", "(", "ab1", ".", "byteLength", "!==", "ab2", ".", "byteLength", ")", "{", "return", "false", ";", "}", "var", "arr1", "=", "new", "Uint8Array", "(", "ab1", ")", ";", "var", "arr...
Checks if two ArrayBuffers are equal @param {ArrayBuffer} ab1 @param {ArrayBuffer} ab2 @returns {boolean}
[ "Checks", "if", "two", "ArrayBuffers", "are", "equal" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/byte-utils.js#L21-L33
train
keeweb/kdbxweb
lib/utils/byte-utils.js
bytesToString
function bytesToString(arr) { if (arr instanceof ArrayBuffer) { arr = new Uint8Array(arr); } return textDecoder.decode(arr); }
javascript
function bytesToString(arr) { if (arr instanceof ArrayBuffer) { arr = new Uint8Array(arr); } return textDecoder.decode(arr); }
[ "function", "bytesToString", "(", "arr", ")", "{", "if", "(", "arr", "instanceof", "ArrayBuffer", ")", "{", "arr", "=", "new", "Uint8Array", "(", "arr", ")", ";", "}", "return", "textDecoder", ".", "decode", "(", "arr", ")", ";", "}" ]
Converts Array or ArrayBuffer to string @param {Array|Uint8Array|ArrayBuffer} arr @return {string}
[ "Converts", "Array", "or", "ArrayBuffer", "to", "string" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/byte-utils.js#L40-L45
train
keeweb/kdbxweb
lib/utils/byte-utils.js
base64ToBytes
function base64ToBytes(str) { if (typeof atob === 'undefined' && typeof Buffer === 'function') { // node.js doesn't have atob var buffer = Buffer.from(str, 'base64'); return new Uint8Array(buffer); } var byteStr = atob(str); var arr = new Uint8Array(byteStr.length); for (var ...
javascript
function base64ToBytes(str) { if (typeof atob === 'undefined' && typeof Buffer === 'function') { // node.js doesn't have atob var buffer = Buffer.from(str, 'base64'); return new Uint8Array(buffer); } var byteStr = atob(str); var arr = new Uint8Array(byteStr.length); for (var ...
[ "function", "base64ToBytes", "(", "str", ")", "{", "if", "(", "typeof", "atob", "===", "'undefined'", "&&", "typeof", "Buffer", "===", "'function'", ")", "{", "// node.js doesn't have atob", "var", "buffer", "=", "Buffer", ".", "from", "(", "str", ",", "'bas...
Converts base64 string to array @param {string} str @return {Uint8Array}
[ "Converts", "base64", "string", "to", "array" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/byte-utils.js#L61-L73
train
keeweb/kdbxweb
lib/utils/byte-utils.js
bytesToBase64
function bytesToBase64(arr) { if (arr instanceof ArrayBuffer) { arr = new Uint8Array(arr); } if (typeof btoa === 'undefined' && typeof Buffer === 'function') { // node.js doesn't have btoa var buffer = Buffer.from(arr); return buffer.toString('base64'); } var str = ''...
javascript
function bytesToBase64(arr) { if (arr instanceof ArrayBuffer) { arr = new Uint8Array(arr); } if (typeof btoa === 'undefined' && typeof Buffer === 'function') { // node.js doesn't have btoa var buffer = Buffer.from(arr); return buffer.toString('base64'); } var str = ''...
[ "function", "bytesToBase64", "(", "arr", ")", "{", "if", "(", "arr", "instanceof", "ArrayBuffer", ")", "{", "arr", "=", "new", "Uint8Array", "(", "arr", ")", ";", "}", "if", "(", "typeof", "btoa", "===", "'undefined'", "&&", "typeof", "Buffer", "===", ...
Converts Array or ArrayBuffer to base64-string @param {Array|Uint8Array|ArrayBuffer} arr @return {string}
[ "Converts", "Array", "or", "ArrayBuffer", "to", "base64", "-", "string" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/byte-utils.js#L80-L94
train
keeweb/kdbxweb
lib/utils/byte-utils.js
arrayToBuffer
function arrayToBuffer(arr) { if (arr instanceof ArrayBuffer) { return arr; } var ab = arr.buffer; if (arr.byteOffset === 0 && arr.byteLength === ab.byteLength) { return ab; } return arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength); }
javascript
function arrayToBuffer(arr) { if (arr instanceof ArrayBuffer) { return arr; } var ab = arr.buffer; if (arr.byteOffset === 0 && arr.byteLength === ab.byteLength) { return ab; } return arr.buffer.slice(arr.byteOffset, arr.byteOffset + arr.byteLength); }
[ "function", "arrayToBuffer", "(", "arr", ")", "{", "if", "(", "arr", "instanceof", "ArrayBuffer", ")", "{", "return", "arr", ";", "}", "var", "ab", "=", "arr", ".", "buffer", ";", "if", "(", "arr", ".", "byteOffset", "===", "0", "&&", "arr", ".", "...
Converts byte array to array buffer @param {Uint8Array|ArrayBuffer} arr @returns {ArrayBuffer}
[ "Converts", "byte", "array", "to", "array", "buffer" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/byte-utils.js#L134-L143
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
sha256
function sha256(data) { if (!data.byteLength) { return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256))); } if (subtle) { return subtle.digest({ name: 'SHA-256' }, data); } else if (nodeCrypto) { return new Promise(function(resolve) { var sha...
javascript
function sha256(data) { if (!data.byteLength) { return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256))); } if (subtle) { return subtle.digest({ name: 'SHA-256' }, data); } else if (nodeCrypto) { return new Promise(function(resolve) { var sha...
[ "function", "sha256", "(", "data", ")", "{", "if", "(", "!", "data", ".", "byteLength", ")", "{", "return", "Promise", ".", "resolve", "(", "ByteUtils", ".", "arrayToBuffer", "(", "ByteUtils", ".", "hexToBytes", "(", "EmptySha256", ")", ")", ")", ";", ...
SHA-256 hash @param {ArrayBuffer} data @returns {Promise.<ArrayBuffer>}
[ "SHA", "-", "256", "hash" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L25-L40
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
hmacSha256
function hmacSha256(key, data) { if (subtle) { var algo = { name: 'HMAC', hash: { name: 'SHA-256' } }; return subtle.importKey('raw', key, algo, false, ['sign']) .then(function(subtleKey) { return subtle.sign(algo, subtleKey, data); }); } else if (nodeCryp...
javascript
function hmacSha256(key, data) { if (subtle) { var algo = { name: 'HMAC', hash: { name: 'SHA-256' } }; return subtle.importKey('raw', key, algo, false, ['sign']) .then(function(subtleKey) { return subtle.sign(algo, subtleKey, data); }); } else if (nodeCryp...
[ "function", "hmacSha256", "(", "key", ",", "data", ")", "{", "if", "(", "subtle", ")", "{", "var", "algo", "=", "{", "name", ":", "'HMAC'", ",", "hash", ":", "{", "name", ":", "'SHA-256'", "}", "}", ";", "return", "subtle", ".", "importKey", "(", ...
HMAC-SHA-256 hash @param {ArrayBuffer} key @param {ArrayBuffer} data @returns {Promise.<ArrayBuffer>}
[ "HMAC", "-", "SHA", "-", "256", "hash" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L70-L86
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
safeRandom
function safeRandom(len) { var randomBytes = new Uint8Array(len); while (len > 0) { var segmentSize = len % maxRandomQuota; segmentSize = segmentSize > 0 ? segmentSize : maxRandomQuota; var randomBytesSegment = new Uint8Array(segmentSize); webCrypto.getRandomValues(randomBytesSeg...
javascript
function safeRandom(len) { var randomBytes = new Uint8Array(len); while (len > 0) { var segmentSize = len % maxRandomQuota; segmentSize = segmentSize > 0 ? segmentSize : maxRandomQuota; var randomBytesSegment = new Uint8Array(segmentSize); webCrypto.getRandomValues(randomBytesSeg...
[ "function", "safeRandom", "(", "len", ")", "{", "var", "randomBytes", "=", "new", "Uint8Array", "(", "len", ")", ";", "while", "(", "len", ">", "0", ")", "{", "var", "segmentSize", "=", "len", "%", "maxRandomQuota", ";", "segmentSize", "=", "segmentSize"...
Gets random bytes from the CryptoEngine @param {number} len - bytes count @return {Uint8Array} - random bytes
[ "Gets", "random", "bytes", "from", "the", "CryptoEngine" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L159-L170
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
random
function random(len) { if (subtle) { return safeRandom(len); } else if (nodeCrypto) { return new Uint8Array(nodeCrypto.randomBytes(len)); } else { throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'Random not implemented'); } }
javascript
function random(len) { if (subtle) { return safeRandom(len); } else if (nodeCrypto) { return new Uint8Array(nodeCrypto.randomBytes(len)); } else { throw new KdbxError(Consts.ErrorCodes.NotImplemented, 'Random not implemented'); } }
[ "function", "random", "(", "len", ")", "{", "if", "(", "subtle", ")", "{", "return", "safeRandom", "(", "len", ")", ";", "}", "else", "if", "(", "nodeCrypto", ")", "{", "return", "new", "Uint8Array", "(", "nodeCrypto", ".", "randomBytes", "(", "len", ...
Generates random bytes of specified length @param {Number} len @returns {Uint8Array}
[ "Generates", "random", "bytes", "of", "specified", "length" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L177-L185
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
chacha20
function chacha20(data, key, iv) { return Promise.resolve().then(function() { var algo = new ChaCha20(new Uint8Array(key), new Uint8Array(iv)); return ByteUtils.arrayToBuffer(algo.encrypt(new Uint8Array(data))); }); }
javascript
function chacha20(data, key, iv) { return Promise.resolve().then(function() { var algo = new ChaCha20(new Uint8Array(key), new Uint8Array(iv)); return ByteUtils.arrayToBuffer(algo.encrypt(new Uint8Array(data))); }); }
[ "function", "chacha20", "(", "data", ",", "key", ",", "iv", ")", "{", "return", "Promise", ".", "resolve", "(", ")", ".", "then", "(", "function", "(", ")", "{", "var", "algo", "=", "new", "ChaCha20", "(", "new", "Uint8Array", "(", "key", ")", ",",...
Encrypts with ChaCha20 @param {ArrayBuffer} data @param {ArrayBuffer} key @param {ArrayBuffer} iv @returns {Promise.<ArrayBuffer>}
[ "Encrypts", "with", "ChaCha20" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L194-L199
train
keeweb/kdbxweb
lib/crypto/crypto-engine.js
configure
function configure(newSubtle, newWebCrypto, newNodeCrypto) { subtle = newSubtle; webCrypto = newWebCrypto; nodeCrypto = newNodeCrypto; }
javascript
function configure(newSubtle, newWebCrypto, newNodeCrypto) { subtle = newSubtle; webCrypto = newWebCrypto; nodeCrypto = newNodeCrypto; }
[ "function", "configure", "(", "newSubtle", ",", "newWebCrypto", ",", "newNodeCrypto", ")", "{", "subtle", "=", "newSubtle", ";", "webCrypto", "=", "newWebCrypto", ";", "nodeCrypto", "=", "newNodeCrypto", ";", "}" ]
Configures globals, for tests
[ "Configures", "globals", "for", "tests" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/crypto-engine.js#L220-L224
train
keeweb/kdbxweb
lib/crypto/protected-value.js
function(value, salt) { Object.defineProperty(this, '_value', { value: new Uint8Array(value) }); Object.defineProperty(this, '_salt', { value: new Uint8Array(salt) }); }
javascript
function(value, salt) { Object.defineProperty(this, '_value', { value: new Uint8Array(value) }); Object.defineProperty(this, '_salt', { value: new Uint8Array(salt) }); }
[ "function", "(", "value", ",", "salt", ")", "{", "Object", ".", "defineProperty", "(", "this", ",", "'_value'", ",", "{", "value", ":", "new", "Uint8Array", "(", "value", ")", "}", ")", ";", "Object", ".", "defineProperty", "(", "this", ",", "'_salt'",...
Protected value, used for protected entry fields @param {ArrayBuffer} value - encrypted value @param {ArrayBuffer} salt - salt bytes @constructor
[ "Protected", "value", "used", "for", "protected", "entry", "fields" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/protected-value.js#L13-L16
train
keeweb/kdbxweb
lib/crypto/hmac-block-transform.js
getHmacKey
function getHmacKey(key, blockIndex) { var shaSrc = new Uint8Array(8 + key.byteLength); shaSrc.set(new Uint8Array(key), 8); var view = new DataView(shaSrc.buffer); view.setUint32(0, blockIndex.lo, true); view.setUint32(4, blockIndex.hi, true); return CryptoEngine.sha512(ByteUtils.arrayToBuffer(s...
javascript
function getHmacKey(key, blockIndex) { var shaSrc = new Uint8Array(8 + key.byteLength); shaSrc.set(new Uint8Array(key), 8); var view = new DataView(shaSrc.buffer); view.setUint32(0, blockIndex.lo, true); view.setUint32(4, blockIndex.hi, true); return CryptoEngine.sha512(ByteUtils.arrayToBuffer(s...
[ "function", "getHmacKey", "(", "key", ",", "blockIndex", ")", "{", "var", "shaSrc", "=", "new", "Uint8Array", "(", "8", "+", "key", ".", "byteLength", ")", ";", "shaSrc", ".", "set", "(", "new", "Uint8Array", "(", "key", ")", ",", "8", ")", ";", "v...
Computes HMAC-SHA key @param {ArrayBuffer} key @param {Int64} blockIndex @returns {Promise.<ArrayBuffer>}
[ "Computes", "HMAC", "-", "SHA", "key" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/hmac-block-transform.js#L19-L29
train
keeweb/kdbxweb
lib/crypto/hmac-block-transform.js
getBlockHmac
function getBlockHmac(key, blockIndex, blockLength, blockData) { return getHmacKey(key, new Int64(blockIndex)).then(function(blockKey) { var blockDataForHash = new Uint8Array(blockData.byteLength + 4 + 8); var blockDataForHashView = new DataView(blockDataForHash.buffer); blockDataForHash.set...
javascript
function getBlockHmac(key, blockIndex, blockLength, blockData) { return getHmacKey(key, new Int64(blockIndex)).then(function(blockKey) { var blockDataForHash = new Uint8Array(blockData.byteLength + 4 + 8); var blockDataForHashView = new DataView(blockDataForHash.buffer); blockDataForHash.set...
[ "function", "getBlockHmac", "(", "key", ",", "blockIndex", ",", "blockLength", ",", "blockData", ")", "{", "return", "getHmacKey", "(", "key", ",", "new", "Int64", "(", "blockIndex", ")", ")", ".", "then", "(", "function", "(", "blockKey", ")", "{", "var...
Gets block HMAC @param {ArrayBuffer} key @param {number} blockIndex @param {number} blockLength @param {ArrayBuffer} blockData @returns {Promise.<ArrayBuffer>}
[ "Gets", "block", "HMAC" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/crypto/hmac-block-transform.js#L39-L48
train
keeweb/kdbxweb
lib/utils/xml-utils.js
parse
function parse(xml) { var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser(); var doc; try { doc = parser.parseFromString(xml, 'application/xml'); } catch (e) { throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message); } if (!doc.docu...
javascript
function parse(xml) { var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser(); var doc; try { doc = parser.parseFromString(xml, 'application/xml'); } catch (e) { throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message); } if (!doc.docu...
[ "function", "parse", "(", "xml", ")", "{", "var", "parser", "=", "domParserArg", "?", "new", "dom", ".", "DOMParser", "(", "domParserArg", ")", ":", "new", "dom", ".", "DOMParser", "(", ")", ";", "var", "doc", ";", "try", "{", "doc", "=", "parser", ...
Parses XML document Throws an error in case of invalid XML @param {string} xml - xml document @returns {Document}
[ "Parses", "XML", "document", "Throws", "an", "error", "in", "case", "of", "invalid", "XML" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L30-L46
train
keeweb/kdbxweb
lib/utils/xml-utils.js
getChildNode
function getChildNode(node, tagName, errorMsgIfAbsent) { if (node && node.childNodes) { for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) { if (cn[i].tagName === tagName) { return cn[i]; } } } if (errorMsgIfAbsent) { throw ne...
javascript
function getChildNode(node, tagName, errorMsgIfAbsent) { if (node && node.childNodes) { for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) { if (cn[i].tagName === tagName) { return cn[i]; } } } if (errorMsgIfAbsent) { throw ne...
[ "function", "getChildNode", "(", "node", ",", "tagName", ",", "errorMsgIfAbsent", ")", "{", "if", "(", "node", "&&", "node", ".", "childNodes", ")", "{", "for", "(", "var", "i", "=", "0", ",", "cn", "=", "node", ".", "childNodes", ",", "len", "=", ...
Gets first child node from xml @param {Node} node - parent node for search @param {string} tagName - child node tag name @param {string} [errorMsgIfAbsent] - if set, error will be thrown if node is absent @returns {Node} - first found node, or null, if there's no such node
[ "Gets", "first", "child", "node", "from", "xml" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L73-L86
train
keeweb/kdbxweb
lib/utils/xml-utils.js
addChildNode
function addChildNode(node, tagName) { return node.appendChild((node.ownerDocument || node).createElement(tagName)); }
javascript
function addChildNode(node, tagName) { return node.appendChild((node.ownerDocument || node).createElement(tagName)); }
[ "function", "addChildNode", "(", "node", ",", "tagName", ")", "{", "return", "node", ".", "appendChild", "(", "(", "node", ".", "ownerDocument", "||", "node", ")", ".", "createElement", "(", "tagName", ")", ")", ";", "}" ]
Adds child node to xml @param {Node} node - parent node @param {string} tagName - child node tag name @returns {Node} - created node
[ "Adds", "child", "node", "to", "xml" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L94-L96
train
keeweb/kdbxweb
lib/utils/xml-utils.js
getText
function getText(node) { if (!node || !node.childNodes) { return undefined; } return node.protectedValue ? node.protectedValue.text : node.textContent; }
javascript
function getText(node) { if (!node || !node.childNodes) { return undefined; } return node.protectedValue ? node.protectedValue.text : node.textContent; }
[ "function", "getText", "(", "node", ")", "{", "if", "(", "!", "node", "||", "!", "node", ".", "childNodes", ")", "{", "return", "undefined", ";", "}", "return", "node", ".", "protectedValue", "?", "node", ".", "protectedValue", ".", "text", ":", "node"...
Gets node inner text @param {Node} node - xml node @return {string|undefined} - node inner text or undefined, if the node is empty
[ "Gets", "node", "inner", "text" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L103-L108
train
keeweb/kdbxweb
lib/utils/xml-utils.js
getBytes
function getBytes(node) { var text = getText(node); return text ? ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)) : undefined; }
javascript
function getBytes(node) { var text = getText(node); return text ? ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text)) : undefined; }
[ "function", "getBytes", "(", "node", ")", "{", "var", "text", "=", "getText", "(", "node", ")", ";", "return", "text", "?", "ByteUtils", ".", "arrayToBuffer", "(", "ByteUtils", ".", "base64ToBytes", "(", "text", ")", ")", ":", "undefined", ";", "}" ]
Parses bytes saved by KeePass from XML @param {Node} node - xml node with bytes saved by KeePass (base64 format) @return {ArrayBuffer} - ArrayBuffer or undefined, if the tag is empty
[ "Parses", "bytes", "saved", "by", "KeePass", "from", "XML" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L124-L127
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setBytes
function setBytes(node, bytes) { if (typeof bytes === 'string') { bytes = ByteUtils.base64ToBytes(bytes); } setText(node, bytes ? ByteUtils.bytesToBase64(ByteUtils.arrayToBuffer(bytes)) : undefined); }
javascript
function setBytes(node, bytes) { if (typeof bytes === 'string') { bytes = ByteUtils.base64ToBytes(bytes); } setText(node, bytes ? ByteUtils.bytesToBase64(ByteUtils.arrayToBuffer(bytes)) : undefined); }
[ "function", "setBytes", "(", "node", ",", "bytes", ")", "{", "if", "(", "typeof", "bytes", "===", "'string'", ")", "{", "bytes", "=", "ByteUtils", ".", "base64ToBytes", "(", "bytes", ")", ";", "}", "setText", "(", "node", ",", "bytes", "?", "ByteUtils"...
Sets bytes for node @param {Node} node @param {ArrayBuffer|Uint8Array|string|undefined} bytes
[ "Sets", "bytes", "for", "node" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L134-L139
train
keeweb/kdbxweb
lib/utils/xml-utils.js
getDate
function getDate(node) { var text = getText(node); if (!text) { return undefined; } if (text.indexOf(':') > 0) { return new Date(text); } var bytes = new DataView(ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text))); var secondsFrom00 = new Int64(bytes.getUint32(0, true), ...
javascript
function getDate(node) { var text = getText(node); if (!text) { return undefined; } if (text.indexOf(':') > 0) { return new Date(text); } var bytes = new DataView(ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(text))); var secondsFrom00 = new Int64(bytes.getUint32(0, true), ...
[ "function", "getDate", "(", "node", ")", "{", "var", "text", "=", "getText", "(", "node", ")", ";", "if", "(", "!", "text", ")", "{", "return", "undefined", ";", "}", "if", "(", "text", ".", "indexOf", "(", "':'", ")", ">", "0", ")", "{", "retu...
Parses date saved by KeePass from XML @param {Node} node - xml node with date saved by KeePass (ISO format or base64-uint64) format @return {Date} - date or undefined, if the tag is empty
[ "Parses", "date", "saved", "by", "KeePass", "from", "XML" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L146-L158
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setDate
function setDate(node, date, binary) { if (date) { if (binary) { var secondsFrom00 = Math.floor(date.getTime() / 1000) + EpochSeconds; var bytes = new DataView(new ArrayBuffer(8)); var val64 = Int64.from(secondsFrom00); bytes.setUint32(0, val64.lo, true); ...
javascript
function setDate(node, date, binary) { if (date) { if (binary) { var secondsFrom00 = Math.floor(date.getTime() / 1000) + EpochSeconds; var bytes = new DataView(new ArrayBuffer(8)); var val64 = Int64.from(secondsFrom00); bytes.setUint32(0, val64.lo, true); ...
[ "function", "setDate", "(", "node", ",", "date", ",", "binary", ")", "{", "if", "(", "date", ")", "{", "if", "(", "binary", ")", "{", "var", "secondsFrom00", "=", "Math", ".", "floor", "(", "date", ".", "getTime", "(", ")", "/", "1000", ")", "+",...
Sets node date as string or binary @param {Node} node @param {Date|undefined} date @param {boolean} [binary=false]
[ "Sets", "node", "date", "as", "string", "or", "binary" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L166-L181
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setNumber
function setNumber(node, number) { setText(node, typeof number === 'number' && !isNaN(number) ? number.toString() : undefined); }
javascript
function setNumber(node, number) { setText(node, typeof number === 'number' && !isNaN(number) ? number.toString() : undefined); }
[ "function", "setNumber", "(", "node", ",", "number", ")", "{", "setText", "(", "node", ",", "typeof", "number", "===", "'number'", "&&", "!", "isNaN", "(", "number", ")", "?", "number", ".", "toString", "(", ")", ":", "undefined", ")", ";", "}" ]
Sets node number @param {Node} node @return {Number|undefined} number
[ "Sets", "node", "number" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L198-L200
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setBoolean
function setBoolean(node, boolean) { setText(node, boolean === undefined ? '' : boolean === null ? 'null' : boolean ? 'True' : 'False'); }
javascript
function setBoolean(node, boolean) { setText(node, boolean === undefined ? '' : boolean === null ? 'null' : boolean ? 'True' : 'False'); }
[ "function", "setBoolean", "(", "node", ",", "boolean", ")", "{", "setText", "(", "node", ",", "boolean", "===", "undefined", "?", "''", ":", "boolean", "===", "null", "?", "'null'", ":", "boolean", "?", "'True'", ":", "'False'", ")", ";", "}" ]
Sets node boolean @param {Node} node @param {boolean|undefined} boolean
[ "Sets", "node", "boolean" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L217-L219
train
keeweb/kdbxweb
lib/utils/xml-utils.js
strToBoolean
function strToBoolean(str) { switch (str && str.toLowerCase && str.toLowerCase()) { case 'true': return true; case 'false': return false; case 'null': return null; } return undefined; }
javascript
function strToBoolean(str) { switch (str && str.toLowerCase && str.toLowerCase()) { case 'true': return true; case 'false': return false; case 'null': return null; } return undefined; }
[ "function", "strToBoolean", "(", "str", ")", "{", "switch", "(", "str", "&&", "str", ".", "toLowerCase", "&&", "str", ".", "toLowerCase", "(", ")", ")", "{", "case", "'true'", ":", "return", "true", ";", "case", "'false'", ":", "return", "false", ";", ...
Converts saved string to boolean @param {string} str @returns {boolean}
[ "Converts", "saved", "string", "to", "boolean" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L226-L236
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setUuid
function setUuid(node, uuid) { var uuidBytes = uuid instanceof KdbxUuid ? uuid.toBytes() : uuid; setBytes(node, uuidBytes); }
javascript
function setUuid(node, uuid) { var uuidBytes = uuid instanceof KdbxUuid ? uuid.toBytes() : uuid; setBytes(node, uuidBytes); }
[ "function", "setUuid", "(", "node", ",", "uuid", ")", "{", "var", "uuidBytes", "=", "uuid", "instanceof", "KdbxUuid", "?", "uuid", ".", "toBytes", "(", ")", ":", "uuid", ";", "setBytes", "(", "node", ",", "uuidBytes", ")", ";", "}" ]
Sets node uuid @param {Node} node @param {KdbxUuid} uuid
[ "Sets", "node", "uuid" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L253-L256
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setProtectedText
function setProtectedText(node, text) { if (text instanceof ProtectedValue) { node.protectedValue = text; node.setAttribute(XmlNames.Attr.Protected, 'True'); } else { setText(node, text); } }
javascript
function setProtectedText(node, text) { if (text instanceof ProtectedValue) { node.protectedValue = text; node.setAttribute(XmlNames.Attr.Protected, 'True'); } else { setText(node, text); } }
[ "function", "setProtectedText", "(", "node", ",", "text", ")", "{", "if", "(", "text", "instanceof", "ProtectedValue", ")", "{", "node", ".", "protectedValue", "=", "text", ";", "node", ".", "setAttribute", "(", "XmlNames", ".", "Attr", ".", "Protected", "...
Sets node protected text @param {Node} node @param {ProtectedValue|string} text
[ "Sets", "node", "protected", "text" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L272-L279
train
keeweb/kdbxweb
lib/utils/xml-utils.js
getProtectedBinary
function getProtectedBinary(node) { if (node.protectedValue) { return node.protectedValue; } var text = node.textContent; var ref = node.getAttribute(XmlNames.Attr.Ref); if (ref) { return { ref: ref }; } if (!text) { return undefined; } var compressed = strToB...
javascript
function getProtectedBinary(node) { if (node.protectedValue) { return node.protectedValue; } var text = node.textContent; var ref = node.getAttribute(XmlNames.Attr.Ref); if (ref) { return { ref: ref }; } if (!text) { return undefined; } var compressed = strToB...
[ "function", "getProtectedBinary", "(", "node", ")", "{", "if", "(", "node", ".", "protectedValue", ")", "{", "return", "node", ".", "protectedValue", ";", "}", "var", "text", "=", "node", ".", "textContent", ";", "var", "ref", "=", "node", ".", "getAttri...
Gets node protected text from inner text @param {Node} node @return {ProtectedValue|ArrayBuffer|{ref: string}} - protected value, or array buffer, or reference to binary
[ "Gets", "node", "protected", "text", "from", "inner", "text" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L286-L304
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setProtectedBinary
function setProtectedBinary(node, binary) { if (binary instanceof ProtectedValue) { node.protectedValue = binary; node.setAttribute(XmlNames.Attr.Protected, 'True'); } else if (binary && binary.ref) { node.setAttribute(XmlNames.Attr.Ref, binary.ref); } else { setBytes(node, b...
javascript
function setProtectedBinary(node, binary) { if (binary instanceof ProtectedValue) { node.protectedValue = binary; node.setAttribute(XmlNames.Attr.Protected, 'True'); } else if (binary && binary.ref) { node.setAttribute(XmlNames.Attr.Ref, binary.ref); } else { setBytes(node, b...
[ "function", "setProtectedBinary", "(", "node", ",", "binary", ")", "{", "if", "(", "binary", "instanceof", "ProtectedValue", ")", "{", "node", ".", "protectedValue", "=", "binary", ";", "node", ".", "setAttribute", "(", "XmlNames", ".", "Attr", ".", "Protect...
Sets node protected binary @param {Node} node @param {ProtectedValue|ArrayBuffer|{ref: string}|string} binary
[ "Sets", "node", "protected", "binary" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L311-L320
train
keeweb/kdbxweb
lib/utils/xml-utils.js
traverse
function traverse(node, callback) { callback(node); for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) { var childNode = cn[i]; if (childNode.tagName) { traverse(childNode, callback); } } }
javascript
function traverse(node, callback) { callback(node); for (var i = 0, cn = node.childNodes, len = cn.length; i < len; i++) { var childNode = cn[i]; if (childNode.tagName) { traverse(childNode, callback); } } }
[ "function", "traverse", "(", "node", ",", "callback", ")", "{", "callback", "(", "node", ")", ";", "for", "(", "var", "i", "=", "0", ",", "cn", "=", "node", ".", "childNodes", ",", "len", "=", "cn", ".", "length", ";", "i", "<", "len", ";", "i"...
Traversed XML tree with depth-first preorder search @param {Node} node @param {function} callback
[ "Traversed", "XML", "tree", "with", "depth", "-", "first", "preorder", "search" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L327-L335
train
keeweb/kdbxweb
lib/utils/xml-utils.js
setProtectedValues
function setProtectedValues(node, protectSaltGenerator) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected))) { try { var value = ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(node.textContent)); if (value.byteLength) { ...
javascript
function setProtectedValues(node, protectSaltGenerator) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected))) { try { var value = ByteUtils.arrayToBuffer(ByteUtils.base64ToBytes(node.textContent)); if (value.byteLength) { ...
[ "function", "setProtectedValues", "(", "node", ",", "protectSaltGenerator", ")", "{", "traverse", "(", "node", ",", "function", "(", "node", ")", "{", "if", "(", "strToBoolean", "(", "node", ".", "getAttribute", "(", "XmlNames", ".", "Attr", ".", "Protected"...
Reads protected values for all nodes in tree @param {Node} node @param {ProtectSaltGenerator} protectSaltGenerator
[ "Reads", "protected", "values", "for", "all", "nodes", "in", "tree" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L342-L357
train
keeweb/kdbxweb
lib/utils/xml-utils.js
updateProtectedValuesSalt
function updateProtectedValuesSalt(node, protectSaltGenerator) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) { var newSalt = protectSaltGenerator.getSalt(node.protectedValue.byteLength); node.protectedValue.setS...
javascript
function updateProtectedValuesSalt(node, protectSaltGenerator) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) { var newSalt = protectSaltGenerator.getSalt(node.protectedValue.byteLength); node.protectedValue.setS...
[ "function", "updateProtectedValuesSalt", "(", "node", ",", "protectSaltGenerator", ")", "{", "traverse", "(", "node", ",", "function", "(", "node", ")", "{", "if", "(", "strToBoolean", "(", "node", ".", "getAttribute", "(", "XmlNames", ".", "Attr", ".", "Pro...
Updates protected values salt for all nodes in tree which have protected values assigned @param {Node} node @param {ProtectSaltGenerator} protectSaltGenerator
[ "Updates", "protected", "values", "salt", "for", "all", "nodes", "in", "tree", "which", "have", "protected", "values", "assigned" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L364-L372
train
keeweb/kdbxweb
lib/utils/xml-utils.js
unprotectValues
function unprotectValues(node) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) { node.removeAttribute(XmlNames.Attr.Protected); node.setAttribute(XmlNames.Attr.ProtectedInMemPlainXml, 'True'); node.tex...
javascript
function unprotectValues(node) { traverse(node, function(node) { if (strToBoolean(node.getAttribute(XmlNames.Attr.Protected)) && node.protectedValue) { node.removeAttribute(XmlNames.Attr.Protected); node.setAttribute(XmlNames.Attr.ProtectedInMemPlainXml, 'True'); node.tex...
[ "function", "unprotectValues", "(", "node", ")", "{", "traverse", "(", "node", ",", "function", "(", "node", ")", "{", "if", "(", "strToBoolean", "(", "node", ".", "getAttribute", "(", "XmlNames", ".", "Attr", ".", "Protected", ")", ")", "&&", "node", ...
Unprotect protected values for all nodes in tree which have protected values assigned @param {Node} node
[ "Unprotect", "protected", "values", "for", "all", "nodes", "in", "tree", "which", "have", "protected", "values", "assigned" ]
43ada2ed06f0608b8cb88278fb309351a6eaad82
https://github.com/keeweb/kdbxweb/blob/43ada2ed06f0608b8cb88278fb309351a6eaad82/lib/utils/xml-utils.js#L378-L386
train
square/connect-javascript-sdk
src/model/Customer.js
function(id, createdAt, updatedAt) { var _this = this; _this['id'] = id; _this['created_at'] = createdAt; _this['updated_at'] = updatedAt; }
javascript
function(id, createdAt, updatedAt) { var _this = this; _this['id'] = id; _this['created_at'] = createdAt; _this['updated_at'] = updatedAt; }
[ "function", "(", "id", ",", "createdAt", ",", "updatedAt", ")", "{", "var", "_this", "=", "this", ";", "_this", "[", "'id'", "]", "=", "id", ";", "_this", "[", "'created_at'", "]", "=", "createdAt", ";", "_this", "[", "'updated_at'", "]", "=", "updat...
The Customer model module. @module model/Customer Constructs a new <code>Customer</code>. Represents one of a business&#39;s customers, which can have one or more cards on file associated with it. @alias module:model/Customer @class @param id {String} The customer's unique ID. @param createdAt {String} The time when ...
[ "The", "Customer", "model", "module", "." ]
5c69a3054e112ab10a0b651f33d8371a7485c13e
https://github.com/square/connect-javascript-sdk/blob/5c69a3054e112ab10a0b651f33d8371a7485c13e/src/model/Customer.js#L37-L57
train
hprose/hprose-nodejs
example/future.js
function(resolve, reject) { console.log(thisPromiseCount + ') Promise started (Async code started)'); // This only is an example to create asynchronism global.setTimeout( function() { // We fulfill the promis...
javascript
function(resolve, reject) { console.log(thisPromiseCount + ') Promise started (Async code started)'); // This only is an example to create asynchronism global.setTimeout( function() { // We fulfill the promis...
[ "function", "(", "resolve", ",", "reject", ")", "{", "console", ".", "log", "(", "thisPromiseCount", "+", "') Promise started (Async code started)'", ")", ";", "// This only is an example to create asynchronism", "global", ".", "setTimeout", "(", "function", "(", ")", ...
The resolver function is called with the ability to resolve or reject the promise
[ "The", "resolver", "function", "is", "called", "with", "the", "ability", "to", "resolve", "or", "reject", "the", "promise" ]
04da8ca371d4696c19a4ca189733aac6afbc05ad
https://github.com/hprose/hprose-nodejs/blob/04da8ca371d4696c19a4ca189733aac6afbc05ad/example/future.js#L178-L187
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentId) { var experiment = projectConfig.experimentIdMap[experimentId]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_ID, MODULE_NAME, experimentId)); } return experiment.layerId; }
javascript
function(projectConfig, experimentId) { var experiment = projectConfig.experimentIdMap[experimentId]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_ID, MODULE_NAME, experimentId)); } return experiment.layerId; }
[ "function", "(", "projectConfig", ",", "experimentId", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentIdMap", "[", "experimentId", "]", ";", "if", "(", "fns", ".", "isEmpty", "(", "experiment", ")", ")", "{", "throw", "new", "Error", ...
Get layer ID for the provided experiment key @param {Object} projectConfig Object representing project configuration @param {string} experimentId Experiment ID for which layer ID is to be determined @return {string} Layer ID corresponding to the provided experiment key @throws If experiment key is not in datafile
[ "Get", "layer", "ID", "for", "the", "provided", "experiment", "key" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L140-L146
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, attributeKey, logger) { var attribute = projectConfig.attributeKeyMap[attributeKey]; var hasReservedPrefix = attributeKey.indexOf(RESERVED_ATTRIBUTE_PREFIX) === 0; if (attribute) { if (hasReservedPrefix) { logger.log(LOG_LEVEL.WARN, sprintf('Attribute...
javascript
function(projectConfig, attributeKey, logger) { var attribute = projectConfig.attributeKeyMap[attributeKey]; var hasReservedPrefix = attributeKey.indexOf(RESERVED_ATTRIBUTE_PREFIX) === 0; if (attribute) { if (hasReservedPrefix) { logger.log(LOG_LEVEL.WARN, sprintf('Attribute...
[ "function", "(", "projectConfig", ",", "attributeKey", ",", "logger", ")", "{", "var", "attribute", "=", "projectConfig", ".", "attributeKeyMap", "[", "attributeKey", "]", ";", "var", "hasReservedPrefix", "=", "attributeKey", ".", "indexOf", "(", "RESERVED_ATTRIBU...
Get attribute ID for the provided attribute key @param {Object} projectConfig Object representing project configuration @param {string} attributeKey Attribute key for which ID is to be determined @param {Object} logger @return {string|null} Attribute ID corresponding to the provided attribute key. At...
[ "Get", "attribute", "ID", "for", "the", "provided", "attribute", "key" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L155-L170
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, eventKey) { var event = projectConfig.eventKeyMap[eventKey]; if (event) { return event.id; } return null; }
javascript
function(projectConfig, eventKey) { var event = projectConfig.eventKeyMap[eventKey]; if (event) { return event.id; } return null; }
[ "function", "(", "projectConfig", ",", "eventKey", ")", "{", "var", "event", "=", "projectConfig", ".", "eventKeyMap", "[", "eventKey", "]", ";", "if", "(", "event", ")", "{", "return", "event", ".", "id", ";", "}", "return", "null", ";", "}" ]
Get event ID for the provided @param {Object} projectConfig Object representing project configuration @param {string} eventKey Event key for which ID is to be determined @return {string|null} Event ID corresponding to the provided event key
[ "Get", "event", "ID", "for", "the", "provided" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L178-L184
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentKey) { return module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_RUNNING_STATUS || module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_LAUNCHED_STATUS; }
javascript
function(projectConfig, experimentKey) { return module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_RUNNING_STATUS || module.exports.getExperimentStatus(projectConfig, experimentKey) === EXPERIMENT_LAUNCHED_STATUS; }
[ "function", "(", "projectConfig", ",", "experimentKey", ")", "{", "return", "module", ".", "exports", ".", "getExperimentStatus", "(", "projectConfig", ",", "experimentKey", ")", "===", "EXPERIMENT_RUNNING_STATUS", "||", "module", ".", "exports", ".", "getExperiment...
Returns whether experiment has a status of 'Running' or 'Launched' @param {Object} projectConfig Object representing project configuration @param {string} experimentKey Experiment key for which status is to be compared with 'Running' @return {Boolean} true if experiment status is set to 'Running', fal...
[ "Returns", "whether", "experiment", "has", "a", "status", "of", "Running", "or", "Launched" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L207-L210
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey)); } return experiment.audienceConditions || experiment.audienceIds; ...
javascript
function(projectConfig, experimentKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey)); } return experiment.audienceConditions || experiment.audienceIds; ...
[ "function", "(", "projectConfig", ",", "experimentKey", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentKeyMap", "[", "experimentKey", "]", ";", "if", "(", "fns", ".", "isEmpty", "(", "experiment", ")", ")", "{", "throw", "new", "Error",...
Get audience conditions for the experiment @param {Object} projectConfig Object representing project configuration @param {string} experimentKey Experiment key for which audience conditions are to be determined @return {Array} Audience conditions for the experiment - can be an array of audien...
[ "Get", "audience", "conditions", "for", "the", "experiment" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L228-L235
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, variationId) { if (projectConfig.variationIdMap.hasOwnProperty(variationId)) { return projectConfig.variationIdMap[variationId].key; } return null; }
javascript
function(projectConfig, variationId) { if (projectConfig.variationIdMap.hasOwnProperty(variationId)) { return projectConfig.variationIdMap[variationId].key; } return null; }
[ "function", "(", "projectConfig", ",", "variationId", ")", "{", "if", "(", "projectConfig", ".", "variationIdMap", ".", "hasOwnProperty", "(", "variationId", ")", ")", "{", "return", "projectConfig", ".", "variationIdMap", "[", "variationId", "]", ".", "key", ...
Get variation key given experiment key and variation ID @param {Object} projectConfig Object representing project configuration @param {string} variationId ID of the variation @return {string} Variation key or null if the variation ID is not found
[ "Get", "variation", "key", "given", "experiment", "key", "and", "variation", "ID" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L243-L248
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentKey, variationKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (experiment.variationKeyMap.hasOwnProperty(variationKey)) { return experiment.variationKeyMap[variationKey].id; } return null; }
javascript
function(projectConfig, experimentKey, variationKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (experiment.variationKeyMap.hasOwnProperty(variationKey)) { return experiment.variationKeyMap[variationKey].id; } return null; }
[ "function", "(", "projectConfig", ",", "experimentKey", ",", "variationKey", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentKeyMap", "[", "experimentKey", "]", ";", "if", "(", "experiment", ".", "variationKeyMap", ".", "hasOwnProperty", "(", ...
Get the variation ID given the experiment key and variation key @param {Object} projectConfig Object representing project configuration @param {string} experimentKey Key of the experiment the variation belongs to @param {string} variationKey The variation key @return {string} the variation ID
[ "Get", "the", "variation", "ID", "given", "the", "experiment", "key", "and", "variation", "key" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L257-L263
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentKey) { if (projectConfig.experimentKeyMap.hasOwnProperty(experimentKey)) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (!!experiment) { return experiment; } } throw new Error(sprintf(ERROR_MESSAGES.EXPERIMENT_KEY_NOT_IN_DATA...
javascript
function(projectConfig, experimentKey) { if (projectConfig.experimentKeyMap.hasOwnProperty(experimentKey)) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (!!experiment) { return experiment; } } throw new Error(sprintf(ERROR_MESSAGES.EXPERIMENT_KEY_NOT_IN_DATA...
[ "function", "(", "projectConfig", ",", "experimentKey", ")", "{", "if", "(", "projectConfig", ".", "experimentKeyMap", ".", "hasOwnProperty", "(", "experimentKey", ")", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentKeyMap", "[", "experimentK...
Get experiment from provided experiment key @param {Object} projectConfig Object representing project configuration @param {string} experimentKey Event key for which experiment IDs are to be retrieved @return {Object} experiment @throws If experiment key is not in datafile
[ "Get", "experiment", "from", "provided", "experiment", "key" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L272-L281
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey)); } return experiment.trafficAllocation; }
javascript
function(projectConfig, experimentKey) { var experiment = projectConfig.experimentKeyMap[experimentKey]; if (fns.isEmpty(experiment)) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey)); } return experiment.trafficAllocation; }
[ "function", "(", "projectConfig", ",", "experimentKey", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentKeyMap", "[", "experimentKey", "]", ";", "if", "(", "fns", ".", "isEmpty", "(", "experiment", ")", ")", "{", "throw", "new", "Error",...
Given an experiment key, returns the traffic allocation within that experiment @param {Object} projectConfig Object representing project configuration @param {string} experimentKey Key representing the experiment @return {Array<Object>} Traffic allocation for the experiment @throws If experiment key is not in ...
[ "Given", "an", "experiment", "key", "returns", "the", "traffic", "allocation", "within", "that", "experiment" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L290-L296
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, experimentId, logger) { if (projectConfig.experimentIdMap.hasOwnProperty(experimentId)) { var experiment = projectConfig.experimentIdMap[experimentId]; if (!!experiment) { return experiment; } } logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.INVALID_EXP...
javascript
function(projectConfig, experimentId, logger) { if (projectConfig.experimentIdMap.hasOwnProperty(experimentId)) { var experiment = projectConfig.experimentIdMap[experimentId]; if (!!experiment) { return experiment; } } logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.INVALID_EXP...
[ "function", "(", "projectConfig", ",", "experimentId", ",", "logger", ")", "{", "if", "(", "projectConfig", ".", "experimentIdMap", ".", "hasOwnProperty", "(", "experimentId", ")", ")", "{", "var", "experiment", "=", "projectConfig", ".", "experimentIdMap", "[",...
Get experiment from provided experiment id. Log an error if no experiment exists in the project config with the given ID. @param {Object} projectConfig Object representing project configuration @param {string} experimentId ID of desired experiment object @return {Object} Experiment object
[ "Get", "experiment", "from", "provided", "experiment", "id", ".", "Log", "an", "error", "if", "no", "experiment", "exists", "in", "the", "project", "config", "with", "the", "given", "ID", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L305-L315
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, featureKey, logger) { if (projectConfig.featureKeyMap.hasOwnProperty(featureKey)) { var feature = projectConfig.featureKeyMap[featureKey]; if (!!feature) { return feature; } } logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.FEATURE_NOT_IN_DATAFILE, MODUL...
javascript
function(projectConfig, featureKey, logger) { if (projectConfig.featureKeyMap.hasOwnProperty(featureKey)) { var feature = projectConfig.featureKeyMap[featureKey]; if (!!feature) { return feature; } } logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.FEATURE_NOT_IN_DATAFILE, MODUL...
[ "function", "(", "projectConfig", ",", "featureKey", ",", "logger", ")", "{", "if", "(", "projectConfig", ".", "featureKeyMap", ".", "hasOwnProperty", "(", "featureKey", ")", ")", "{", "var", "feature", "=", "projectConfig", ".", "featureKeyMap", "[", "feature...
Get feature from provided feature key. Log an error if no feature exists in the project config with the given key. @param {Object} projectConfig @param {string} featureKey @param {Object} logger @return {Object|null} Feature object, or null if no feature with the given key exists
[ "Get", "feature", "from", "provided", "feature", "key", ".", "Log", "an", "error", "if", "no", "feature", "exists", "in", "the", "project", "config", "with", "the", "given", "key", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L326-L336
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, featureKey, variableKey, logger) { var feature = projectConfig.featureKeyMap[featureKey]; if (!feature) { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.FEATURE_NOT_IN_DATAFILE, MODULE_NAME, featureKey)); return null; } var variable = feature.variableKeyMap[varia...
javascript
function(projectConfig, featureKey, variableKey, logger) { var feature = projectConfig.featureKeyMap[featureKey]; if (!feature) { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.FEATURE_NOT_IN_DATAFILE, MODULE_NAME, featureKey)); return null; } var variable = feature.variableKeyMap[varia...
[ "function", "(", "projectConfig", ",", "featureKey", ",", "variableKey", ",", "logger", ")", "{", "var", "feature", "=", "projectConfig", ".", "featureKeyMap", "[", "featureKey", "]", ";", "if", "(", "!", "feature", ")", "{", "logger", ".", "log", "(", "...
Get the variable with the given key associated with the feature with the given key. If the feature key or the variable key are invalid, log an error message. @param {Object} projectConfig @param {string} featureKey @param {string} variableKey @param {Object} logger @return {Object|null} Variable object, or null one or ...
[ "Get", "the", "variable", "with", "the", "given", "key", "associated", "with", "the", "feature", "with", "the", "given", "key", ".", "If", "the", "feature", "key", "or", "the", "variable", "key", "are", "invalid", "log", "an", "error", "message", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L349-L363
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(projectConfig, variable, variation, logger) { if (!variable || !variation) { return null; } if (!projectConfig.variationVariableUsageMap.hasOwnProperty(variation.id)) { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT, MODULE_NAME, variation...
javascript
function(projectConfig, variable, variation, logger) { if (!variable || !variation) { return null; } if (!projectConfig.variationVariableUsageMap.hasOwnProperty(variation.id)) { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.VARIATION_ID_NOT_IN_DATAFILE_NO_EXPERIMENT, MODULE_NAME, variation...
[ "function", "(", "projectConfig", ",", "variable", ",", "variation", ",", "logger", ")", "{", "if", "(", "!", "variable", "||", "!", "variation", ")", "{", "return", "null", ";", "}", "if", "(", "!", "projectConfig", ".", "variationVariableUsageMap", ".", ...
Get the value of the given variable for the given variation. If the given variable has no value for the given variation, return null. Log an error message if the variation is invalid. If the variable or variation are invalid, return null. @param {Object} projectConfig @param {Object} variable @param {Object} variation ...
[ "Get", "the", "value", "of", "the", "given", "variable", "for", "the", "given", "variation", ".", "If", "the", "given", "variable", "has", "no", "value", "for", "the", "given", "variation", "return", "null", ".", "Log", "an", "error", "message", "if", "t...
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L377-L391
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(variableValue, variableType, logger) { var castValue; switch (variableType) { case FEATURE_VARIABLE_TYPES.BOOLEAN: if (variableValue !== 'true' && variableValue !== 'false') { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.UNABLE_TO_CAST_VALUE, MODULE_NAME, variableValue, v...
javascript
function(variableValue, variableType, logger) { var castValue; switch (variableType) { case FEATURE_VARIABLE_TYPES.BOOLEAN: if (variableValue !== 'true' && variableValue !== 'false') { logger.log(LOG_LEVEL.ERROR, sprintf(ERROR_MESSAGES.UNABLE_TO_CAST_VALUE, MODULE_NAME, variableValue, v...
[ "function", "(", "variableValue", ",", "variableType", ",", "logger", ")", "{", "var", "castValue", ";", "switch", "(", "variableType", ")", "{", "case", "FEATURE_VARIABLE_TYPES", ".", "BOOLEAN", ":", "if", "(", "variableValue", "!==", "'true'", "&&", "variabl...
Given a variable value in string form, try to cast it to the argument type. If the type cast succeeds, return the type casted value, otherwise log an error and return null. @param {string} variableValue Variable value in string form @param {string} variableType Type of the variable whose value was passed in the firs...
[ "Given", "a", "variable", "value", "in", "string", "form", "try", "to", "cast", "it", "to", "the", "argument", "type", ".", "If", "the", "type", "cast", "succeeds", "return", "the", "type", "casted", "value", "otherwise", "log", "an", "error", "and", "re...
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L409-L444
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/index.js
function(config) { configValidator.validateDatafile(config.datafile); if (config.skipJSONValidation === true) { config.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SKIPPING_JSON_VALIDATION, MODULE_NAME)); } else if (config.jsonSchemaValidator) { config.jsonSchemaValidator.validate(projectConf...
javascript
function(config) { configValidator.validateDatafile(config.datafile); if (config.skipJSONValidation === true) { config.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.SKIPPING_JSON_VALIDATION, MODULE_NAME)); } else if (config.jsonSchemaValidator) { config.jsonSchemaValidator.validate(projectConf...
[ "function", "(", "config", ")", "{", "configValidator", ".", "validateDatafile", "(", "config", ".", "datafile", ")", ";", "if", "(", "config", ".", "skipJSONValidation", "===", "true", ")", "{", "config", ".", "logger", ".", "log", "(", "LOG_LEVEL", ".", ...
Try to create a project config object from the given datafile and configuration properties. If successful, return the project config object, otherwise throws an error @param {Object} config @param {Object} config.datafile @param {Object} config.jsonSchemaValidator @param {Object} config.logger @param {Object} conf...
[ "Try", "to", "create", "a", "project", "config", "object", "from", "the", "given", "datafile", "and", "configuration", "properties", ".", "If", "successful", "return", "the", "project", "config", "object", "otherwise", "throws", "an", "error" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/index.js#L488-L497
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/audience_evaluator/index.js
function(audienceConditions, audiencesById, userAttributes, logger) { // if there are no audiences, return true because that means ALL users are included in the experiment if (!audienceConditions || audienceConditions.length === 0) { return true; } if (!userAttributes) { userAttributes = {}...
javascript
function(audienceConditions, audiencesById, userAttributes, logger) { // if there are no audiences, return true because that means ALL users are included in the experiment if (!audienceConditions || audienceConditions.length === 0) { return true; } if (!userAttributes) { userAttributes = {}...
[ "function", "(", "audienceConditions", ",", "audiencesById", ",", "userAttributes", ",", "logger", ")", "{", "// if there are no audiences, return true because that means ALL users are included in the experiment", "if", "(", "!", "audienceConditions", "||", "audienceConditions", ...
Determine if the given user attributes satisfy the given audience conditions @param {Array|String|null|undefined} audienceConditions Audience conditions to match the user attributes against - can be an array of audience IDs, a nested array of conditions, or a single leaf condition. Examples: ["5", "6"], ["and", ["...
[ "Determine", "if", "the", "given", "user", "attributes", "satisfy", "the", "given", "audience", "conditions" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/audience_evaluator/index.js#L40-L68
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/event_tags_validator/index.js
function(eventTags) { if (typeof eventTags === 'object' && !Array.isArray(eventTags) && eventTags !== null) { return true; } else { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, MODULE_NAME)); } }
javascript
function(eventTags) { if (typeof eventTags === 'object' && !Array.isArray(eventTags) && eventTags !== null) { return true; } else { throw new Error(sprintf(ERROR_MESSAGES.INVALID_EVENT_TAGS, MODULE_NAME)); } }
[ "function", "(", "eventTags", ")", "{", "if", "(", "typeof", "eventTags", "===", "'object'", "&&", "!", "Array", ".", "isArray", "(", "eventTags", ")", "&&", "eventTags", "!==", "null", ")", "{", "return", "true", ";", "}", "else", "{", "throw", "new",...
Validates user's provided event tags @param {Object} event tags @return {boolean} True if event tags are valid @throws If event tags are not valid
[ "Validates", "user", "s", "provided", "event", "tags" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/event_tags_validator/index.js#L33-L39
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/decision_service/index.js
DecisionService
function DecisionService(options) { this.userProfileService = options.userProfileService || null; this.logger = options.logger; this.forcedVariationMap = {}; }
javascript
function DecisionService(options) { this.userProfileService = options.userProfileService || null; this.logger = options.logger; this.forcedVariationMap = {}; }
[ "function", "DecisionService", "(", "options", ")", "{", "this", ".", "userProfileService", "=", "options", ".", "userProfileService", "||", "null", ";", "this", ".", "logger", "=", "options", ".", "logger", ";", "this", ".", "forcedVariationMap", "=", "{", ...
Optimizely's decision service that determines which variation of an experiment the user will be allocated to. The decision service contains all logic around how a user decision is made. This includes all of the following (in order): 1. Checking experiment status 2. Checking forced bucketing 3. Checking whitelisting 4....
[ "Optimizely", "s", "decision", "service", "that", "determines", "which", "variation", "of", "an", "experiment", "the", "user", "will", "be", "allocated", "to", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/decision_service/index.js#L51-L55
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/config_validator/index.js
function(config) { if (config.errorHandler && (typeof config.errorHandler.handleError !== 'function')) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_ERROR_HANDLER, MODULE_NAME)); } if (config.eventDispatcher && (typeof config.eventDispatcher.dispatchEvent !== 'function')) { throw new Error(s...
javascript
function(config) { if (config.errorHandler && (typeof config.errorHandler.handleError !== 'function')) { throw new Error(sprintf(ERROR_MESSAGES.INVALID_ERROR_HANDLER, MODULE_NAME)); } if (config.eventDispatcher && (typeof config.eventDispatcher.dispatchEvent !== 'function')) { throw new Error(s...
[ "function", "(", "config", ")", "{", "if", "(", "config", ".", "errorHandler", "&&", "(", "typeof", "config", ".", "errorHandler", ".", "handleError", "!==", "'function'", ")", ")", "{", "throw", "new", "Error", "(", "sprintf", "(", "ERROR_MESSAGES", ".", ...
Validates the given config options @param {Object} config @param {Object} config.errorHandler @param {Object} config.eventDispatcher @param {Object} config.logger @return {Boolean} True if the config options are valid @throws If any of the config options are not valid
[ "Validates", "the", "given", "config", "options" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/config_validator/index.js#L41-L55
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/config_validator/index.js
function(datafile) { if (!datafile) { throw new Error(sprintf(ERROR_MESSAGES.NO_DATAFILE_SPECIFIED, MODULE_NAME)); } if (typeof datafile === 'string' || datafile instanceof String) { // Attempt to parse the datafile string try { datafile = JSON.parse(datafile); } catch (ex) ...
javascript
function(datafile) { if (!datafile) { throw new Error(sprintf(ERROR_MESSAGES.NO_DATAFILE_SPECIFIED, MODULE_NAME)); } if (typeof datafile === 'string' || datafile instanceof String) { // Attempt to parse the datafile string try { datafile = JSON.parse(datafile); } catch (ex) ...
[ "function", "(", "datafile", ")", "{", "if", "(", "!", "datafile", ")", "{", "throw", "new", "Error", "(", "sprintf", "(", "ERROR_MESSAGES", ".", "NO_DATAFILE_SPECIFIED", ",", "MODULE_NAME", ")", ")", ";", "}", "if", "(", "typeof", "datafile", "===", "'s...
Validates the datafile @param {string} datafile @return {Boolean} True if the datafile is valid @throws If the datafile is not valid for any of the following reasons: - The datafile string is undefined - The datafile string cannot be parsed as a JSON object - The datafile version is not supported
[ "Validates", "the", "datafile" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/config_validator/index.js#L66-L85
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/plugins/event_dispatcher/index.node.js
function(eventObj, callback) { // Non-POST requests not supported if (eventObj.httpVerb !== 'POST') { return; } var parsedUrl = url.parse(eventObj.url); var path = parsedUrl.path; if (parsedUrl.query) { path += '?' + parsedUrl.query; } var dataString = JSON.stringify(eventO...
javascript
function(eventObj, callback) { // Non-POST requests not supported if (eventObj.httpVerb !== 'POST') { return; } var parsedUrl = url.parse(eventObj.url); var path = parsedUrl.path; if (parsedUrl.query) { path += '?' + parsedUrl.query; } var dataString = JSON.stringify(eventO...
[ "function", "(", "eventObj", ",", "callback", ")", "{", "// Non-POST requests not supported", "if", "(", "eventObj", ".", "httpVerb", "!==", "'POST'", ")", "{", "return", ";", "}", "var", "parsedUrl", "=", "url", ".", "parse", "(", "eventObj", ".", "url", ...
Dispatch an HTTP request to the given url and the specified options @param {Object} eventObj Event object containing @param {string} eventObj.url the url to make the request to @param {Object} eventObj.params parameters to pass to the request (i.e. in the POST body) @param {string} eventObj.httpVerb...
[ "Dispatch", "an", "HTTP", "request", "to", "the", "given", "url", "and", "the", "specified", "options" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/plugins/event_dispatcher/index.node.js#L30-L66
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/bucketer/index.js
function(bucketerParams) { // Check if user is in a random group; if so, check if user is bucketed into a specific experiment var experiment = bucketerParams.experimentKeyMap[bucketerParams.experimentKey]; var groupId = experiment['groupId']; if (groupId) { var group = bucketerParams.groupIdMap[gr...
javascript
function(bucketerParams) { // Check if user is in a random group; if so, check if user is bucketed into a specific experiment var experiment = bucketerParams.experimentKeyMap[bucketerParams.experimentKey]; var groupId = experiment['groupId']; if (groupId) { var group = bucketerParams.groupIdMap[gr...
[ "function", "(", "bucketerParams", ")", "{", "// Check if user is in a random group; if so, check if user is bucketed into a specific experiment", "var", "experiment", "=", "bucketerParams", ".", "experimentKeyMap", "[", "bucketerParams", ".", "experimentKey", "]", ";", "var", ...
Determines ID of variation to be shown for the given input params @param {Object} bucketerParams @param {string} bucketerParams.experimentId @param {string} bucketerParams.experimentKey @param {string} bucketerParams.userId @param {Object[]} bucketerParams.trafficAllocationCon...
[ "Determines", "ID", "of", "variation", "to", "be", "shown", "for", "the", "given", "input", "params" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/bucketer/index.js#L49-L104
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/bucketer/index.js
function(group, bucketingId, userId, logger) { var bucketingKey = sprintf('%s%s', bucketingId, group.id); var bucketValue = module.exports._generateBucketValue(bucketingKey); logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_EXPERIMENT_BUCKET, MODULE_NAME, bucketValue, userId)); var traf...
javascript
function(group, bucketingId, userId, logger) { var bucketingKey = sprintf('%s%s', bucketingId, group.id); var bucketValue = module.exports._generateBucketValue(bucketingKey); logger.log(LOG_LEVEL.DEBUG, sprintf(LOG_MESSAGES.USER_ASSIGNED_TO_EXPERIMENT_BUCKET, MODULE_NAME, bucketValue, userId)); var traf...
[ "function", "(", "group", ",", "bucketingId", ",", "userId", ",", "logger", ")", "{", "var", "bucketingKey", "=", "sprintf", "(", "'%s%s'", ",", "bucketingId", ",", "group", ".", "id", ")", ";", "var", "bucketValue", "=", "module", ".", "exports", ".", ...
Returns bucketed experiment ID to compare against experiment user is being called into @param {Object} group Group that experiment is in @param {string} bucketingId Bucketing ID @param {string} userId ID of user to be bucketed into experiment @param {Object} logger Logger implementation @return {str...
[ "Returns", "bucketed", "experiment", "ID", "to", "compare", "against", "experiment", "user", "is", "being", "called", "into" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/bucketer/index.js#L114-L121
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/bucketer/index.js
function(bucketValue, trafficAllocationConfig) { for (var i = 0; i < trafficAllocationConfig.length; i++) { if (bucketValue < trafficAllocationConfig[i].endOfRange) { return trafficAllocationConfig[i].entityId; } } return null; }
javascript
function(bucketValue, trafficAllocationConfig) { for (var i = 0; i < trafficAllocationConfig.length; i++) { if (bucketValue < trafficAllocationConfig[i].endOfRange) { return trafficAllocationConfig[i].entityId; } } return null; }
[ "function", "(", "bucketValue", ",", "trafficAllocationConfig", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "trafficAllocationConfig", ".", "length", ";", "i", "++", ")", "{", "if", "(", "bucketValue", "<", "trafficAllocationConfig", "[", "i...
Returns entity ID associated with bucket value @param {string} bucketValue @param {Object[]} trafficAllocationConfig @param {number} trafficAllocationConfig[].endOfRange @param {number} trafficAllocationConfig[].entityId @return {string} Entity ID for bucketing if bucket value is within traffic allocation b...
[ "Returns", "entity", "ID", "associated", "with", "bucket", "value" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/bucketer/index.js#L131-L138
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/bucketer/index.js
function(bucketingKey) { try { // NOTE: the mmh library already does cast the hash value as an unsigned 32bit int // https://github.com/perezd/node-murmurhash/blob/master/murmurhash.js#L115 var hashValue = murmurhash.v3(bucketingKey, HASH_SEED); var ratio = hashValue / MAX_HASH_VALUE; ...
javascript
function(bucketingKey) { try { // NOTE: the mmh library already does cast the hash value as an unsigned 32bit int // https://github.com/perezd/node-murmurhash/blob/master/murmurhash.js#L115 var hashValue = murmurhash.v3(bucketingKey, HASH_SEED); var ratio = hashValue / MAX_HASH_VALUE; ...
[ "function", "(", "bucketingKey", ")", "{", "try", "{", "// NOTE: the mmh library already does cast the hash value as an unsigned 32bit int", "// https://github.com/perezd/node-murmurhash/blob/master/murmurhash.js#L115", "var", "hashValue", "=", "murmurhash", ".", "v3", "(", "bucketin...
Helper function to generate bucket value in half-closed interval [0, MAX_TRAFFIC_VALUE) @param {string} bucketingKey String value for bucketing @return {string} the generated bucket value @throws If bucketing value is not a valid string
[ "Helper", "function", "to", "generate", "bucket", "value", "in", "half", "-", "closed", "interval", "[", "0", "MAX_TRAFFIC_VALUE", ")" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/bucketer/index.js#L146-L156
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/plugins/event_dispatcher/index.browser.js
function(eventObj, callback) { var url = eventObj.url; var params = eventObj.params; if (eventObj.httpVerb === POST_METHOD) { var req = new XMLHttpRequest(); req.open(POST_METHOD, url, true); req.setRequestHeader('Content-Type', 'application/json'); req.onreadystatechange = function(...
javascript
function(eventObj, callback) { var url = eventObj.url; var params = eventObj.params; if (eventObj.httpVerb === POST_METHOD) { var req = new XMLHttpRequest(); req.open(POST_METHOD, url, true); req.setRequestHeader('Content-Type', 'application/json'); req.onreadystatechange = function(...
[ "function", "(", "eventObj", ",", "callback", ")", "{", "var", "url", "=", "eventObj", ".", "url", ";", "var", "params", "=", "eventObj", ".", "params", ";", "if", "(", "eventObj", ".", "httpVerb", "===", "POST_METHOD", ")", "{", "var", "req", "=", "...
Sample event dispatcher implementation for tracking impression and conversions Users of the SDK can provide their own implementation @param {Object} eventObj @param {Function} callback
[ "Sample", "event", "dispatcher", "implementation", "for", "tracking", "impression", "and", "conversions", "Users", "of", "the", "SDK", "can", "provide", "their", "own", "implementation" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/plugins/event_dispatcher/index.browser.js#L29-L66
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/event_builder/index.js
getCommonEventParams
function getCommonEventParams(options) { var attributes = options.attributes; var configObj = options.configObj; var anonymize_ip = configObj.anonymizeIP; var botFiltering = configObj.botFiltering; if (anonymize_ip === null || anonymize_ip === undefined) { anonymize_ip = false; } var visitor = { ...
javascript
function getCommonEventParams(options) { var attributes = options.attributes; var configObj = options.configObj; var anonymize_ip = configObj.anonymizeIP; var botFiltering = configObj.botFiltering; if (anonymize_ip === null || anonymize_ip === undefined) { anonymize_ip = false; } var visitor = { ...
[ "function", "getCommonEventParams", "(", "options", ")", "{", "var", "attributes", "=", "options", ".", "attributes", ";", "var", "configObj", "=", "options", ".", "configObj", ";", "var", "anonymize_ip", "=", "configObj", ".", "anonymizeIP", ";", "var", "botF...
Get params which are used same in both conversion and impression events @param {Object} options.attributes Object representing user attributes and values which need to be recorded @param {string} options.clientEngine The client we are using: node or javascript @param {string} options.clientVersion The version of...
[ "Get", "params", "which", "are", "used", "same", "in", "both", "conversion", "and", "impression", "events" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/event_builder/index.js#L37-L87
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/event_builder/index.js
getImpressionEventParams
function getImpressionEventParams(configObj, experimentId, variationId) { var impressionEventParams = { decisions: [{ campaign_id: projectConfig.getLayerId(configObj, experimentId), experiment_id: experimentId, variation_id: variationId, }], events: [{ entity_id: proj...
javascript
function getImpressionEventParams(configObj, experimentId, variationId) { var impressionEventParams = { decisions: [{ campaign_id: projectConfig.getLayerId(configObj, experimentId), experiment_id: experimentId, variation_id: variationId, }], events: [{ entity_id: proj...
[ "function", "getImpressionEventParams", "(", "configObj", ",", "experimentId", ",", "variationId", ")", "{", "var", "impressionEventParams", "=", "{", "decisions", ":", "[", "{", "campaign_id", ":", "projectConfig", ".", "getLayerId", "(", "configObj", ",", "exper...
Creates object of params specific to impression events @param {Object} configObj Object representing project configuration @param {string} experimentId ID of experiment for which impression needs to be recorded @param {string} variationId ID for variation which would be presented to user @return {Object} ...
[ "Creates", "object", "of", "params", "specific", "to", "impression", "events" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/event_builder/index.js#L96-L112
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/event_builder/index.js
getVisitorSnapshot
function getVisitorSnapshot(configObj, eventKey, eventTags, logger) { var snapshot = { events: [] }; var eventDict = { entity_id: projectConfig.getEventId(configObj, eventKey), timestamp: fns.currentTimestamp(), uuid: fns.uuid(), key: eventKey, }; if (eventTags) { var revenue = event...
javascript
function getVisitorSnapshot(configObj, eventKey, eventTags, logger) { var snapshot = { events: [] }; var eventDict = { entity_id: projectConfig.getEventId(configObj, eventKey), timestamp: fns.currentTimestamp(), uuid: fns.uuid(), key: eventKey, }; if (eventTags) { var revenue = event...
[ "function", "getVisitorSnapshot", "(", "configObj", ",", "eventKey", ",", "eventTags", ",", "logger", ")", "{", "var", "snapshot", "=", "{", "events", ":", "[", "]", "}", ";", "var", "eventDict", "=", "{", "entity_id", ":", "projectConfig", ".", "getEventI...
Creates object of params specific to conversion events @param {Object} configObj Object representing project configuration @param {string} eventKey Event key representing the event which needs to be recorded @param {Object} eventTags Values associated with the event. ...
[ "Creates", "object", "of", "params", "specific", "to", "conversion", "events" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/event_builder/index.js#L122-L150
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/event_builder/index.js
function(options) { var impressionEvent = { httpVerb: HTTP_VERB }; var commonParams = getCommonEventParams(options); impressionEvent.url = ENDPOINT; var impressionEventParams = getImpressionEventParams(options.configObj, options.experimentId, options.variationId); // combine Event params...
javascript
function(options) { var impressionEvent = { httpVerb: HTTP_VERB }; var commonParams = getCommonEventParams(options); impressionEvent.url = ENDPOINT; var impressionEventParams = getImpressionEventParams(options.configObj, options.experimentId, options.variationId); // combine Event params...
[ "function", "(", "options", ")", "{", "var", "impressionEvent", "=", "{", "httpVerb", ":", "HTTP_VERB", "}", ";", "var", "commonParams", "=", "getCommonEventParams", "(", "options", ")", ";", "impressionEvent", ".", "url", "=", "ENDPOINT", ";", "var", "impre...
Create impression event params to be sent to the logging endpoint @param {Object} options Object containing values needed to build impression event @param {Object} options.attributes Object representing user attributes and values which need to be recorded @param {string} options.clientEngine The cl...
[ "Create", "impression", "event", "params", "to", "be", "sent", "to", "the", "logging", "endpoint" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/event_builder/index.js#L165-L180
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/event_builder/index.js
function(options) { var conversionEvent = { httpVerb: HTTP_VERB, }; var commonParams = getCommonEventParams(options); conversionEvent.url = ENDPOINT; var snapshot = getVisitorSnapshot(options.configObj, options.eventKey, ...
javascript
function(options) { var conversionEvent = { httpVerb: HTTP_VERB, }; var commonParams = getCommonEventParams(options); conversionEvent.url = ENDPOINT; var snapshot = getVisitorSnapshot(options.configObj, options.eventKey, ...
[ "function", "(", "options", ")", "{", "var", "conversionEvent", "=", "{", "httpVerb", ":", "HTTP_VERB", ",", "}", ";", "var", "commonParams", "=", "getCommonEventParams", "(", "options", ")", ";", "conversionEvent", ".", "url", "=", "ENDPOINT", ";", "var", ...
Create conversion event params to be sent to the logging endpoint @param {Object} options Object containing values needed to build conversion event @param {Object} options.attributes Object representing user attributes and values which need to be recorded @param {string} opti...
[ "Create", "conversion", "event", "params", "to", "be", "sent", "to", "the", "logging", "endpoint" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/event_builder/index.js#L195-L212
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js
evaluate
function evaluate(condition, userAttributes, logger) { if (condition.type !== CUSTOM_ATTRIBUTE_CONDITION_TYPE) { logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNKNOWN_CONDITION_TYPE, MODULE_NAME, JSON.stringify(condition))); return null; } var conditionMatch = condition.match; if (typeof condition...
javascript
function evaluate(condition, userAttributes, logger) { if (condition.type !== CUSTOM_ATTRIBUTE_CONDITION_TYPE) { logger.log(LOG_LEVEL.WARNING, sprintf(LOG_MESSAGES.UNKNOWN_CONDITION_TYPE, MODULE_NAME, JSON.stringify(condition))); return null; } var conditionMatch = condition.match; if (typeof condition...
[ "function", "evaluate", "(", "condition", ",", "userAttributes", ",", "logger", ")", "{", "if", "(", "condition", ".", "type", "!==", "CUSTOM_ATTRIBUTE_CONDITION_TYPE", ")", "{", "logger", ".", "log", "(", "LOG_LEVEL", ".", "WARNING", ",", "sprintf", "(", "L...
Given a custom attribute audience condition and user attributes, evaluate the condition against the attributes. @param {Object} condition @param {Object} userAttributes @param {Object} logger @return {?Boolean} true/false if the given user attributes match/don't match the given condition, null if the g...
[ "Given", "a", "custom", "attribute", "audience", "condition", "and", "user", "attributes", "evaluate", "the", "condition", "against", "the", "attributes", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js#L57-L77
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js
existsEvaluator
function existsEvaluator(condition, userAttributes) { var userValue = userAttributes[condition.name]; return typeof userValue !== 'undefined' && userValue !== null; }
javascript
function existsEvaluator(condition, userAttributes) { var userValue = userAttributes[condition.name]; return typeof userValue !== 'undefined' && userValue !== null; }
[ "function", "existsEvaluator", "(", "condition", ",", "userAttributes", ")", "{", "var", "userValue", "=", "userAttributes", "[", "condition", ".", "name", "]", ";", "return", "typeof", "userValue", "!==", "'undefined'", "&&", "userValue", "!==", "null", ";", ...
Evaluate the given exists match condition for the given user attributes @param {Object} condition @param {Object} userAttributes @returns {Boolean} true if both: 1) the user attributes have a value for the given condition, and 2) the user attribute value is neither null nor undefined Returns false otherwise
[ "Evaluate", "the", "given", "exists", "match", "condition", "for", "the", "given", "user", "attributes" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js#L140-L143
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js
greaterThanEvaluator
function greaterThanEvaluator(condition, userAttributes, logger) { var conditionName = condition.name; var userValue = userAttributes[conditionName]; var userValueType = typeof userValue; var conditionValue = condition.value; if (!fns.isFinite(conditionValue)) { logger.log(LOG_LEVEL.WARNING, sprintf(LOG_...
javascript
function greaterThanEvaluator(condition, userAttributes, logger) { var conditionName = condition.name; var userValue = userAttributes[conditionName]; var userValueType = typeof userValue; var conditionValue = condition.value; if (!fns.isFinite(conditionValue)) { logger.log(LOG_LEVEL.WARNING, sprintf(LOG_...
[ "function", "greaterThanEvaluator", "(", "condition", ",", "userAttributes", ",", "logger", ")", "{", "var", "conditionName", "=", "condition", ".", "name", ";", "var", "userValue", "=", "userAttributes", "[", "conditionName", "]", ";", "var", "userValueType", "...
Evaluate the given greater than match condition for the given user attributes @param {Object} condition @param {Object} userAttributes @param {Object} logger @returns {?Boolean} true if the user attribute value is greater than the condition value, false if the user attribute value is less than or equal ...
[ "Evaluate", "the", "given", "greater", "than", "match", "condition", "for", "the", "given", "user", "attributes" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js#L155-L182
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js
substringEvaluator
function substringEvaluator(condition, userAttributes, logger) { var conditionName = condition.name; var userValue = userAttributes[condition.name]; var userValueType = typeof userValue; var conditionValue = condition.value; if (typeof conditionValue !== 'string') { logger.log(LOG_LEVEL.WARNING, sprintf(...
javascript
function substringEvaluator(condition, userAttributes, logger) { var conditionName = condition.name; var userValue = userAttributes[condition.name]; var userValueType = typeof userValue; var conditionValue = condition.value; if (typeof conditionValue !== 'string') { logger.log(LOG_LEVEL.WARNING, sprintf(...
[ "function", "substringEvaluator", "(", "condition", ",", "userAttributes", ",", "logger", ")", "{", "var", "conditionName", "=", "condition", ".", "name", ";", "var", "userValue", "=", "userAttributes", "[", "condition", ".", "name", "]", ";", "var", "userValu...
Evaluate the given substring match condition for the given user attributes @param {Object} condition @param {Object} userAttributes @param {Object} logger @returns {?Boolean} true if the condition value is a substring of the user attribute value, false if the condition value is not a substring of the us...
[ "Evaluate", "the", "given", "substring", "match", "condition", "for", "the", "given", "user", "attributes" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.js#L233-L255
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js
evaluate
function evaluate(conditions, leafEvaluator) { if (Array.isArray(conditions)) { var firstOperator = conditions[0]; var restOfConditions = conditions.slice(1); if (DEFAULT_OPERATOR_TYPES.indexOf(firstOperator) === -1) { // Operator to apply is not explicit - assume 'or' firstOperator = OR_COND...
javascript
function evaluate(conditions, leafEvaluator) { if (Array.isArray(conditions)) { var firstOperator = conditions[0]; var restOfConditions = conditions.slice(1); if (DEFAULT_OPERATOR_TYPES.indexOf(firstOperator) === -1) { // Operator to apply is not explicit - assume 'or' firstOperator = OR_COND...
[ "function", "evaluate", "(", "conditions", ",", "leafEvaluator", ")", "{", "if", "(", "Array", ".", "isArray", "(", "conditions", ")", ")", "{", "var", "firstOperator", "=", "conditions", "[", "0", "]", ";", "var", "restOfConditions", "=", "conditions", "....
Top level method to evaluate conditions @param {Array|*} conditions Nested array of and/or conditions, or a single leaf condition value of any type Example: ['and', '0', ['or', '1', '2']] @param {Function} leafEvaluator Function which will be called to evaluate leaf condition values @return {?Boolean} ...
[ "Top", "level", "method", "to", "evaluate", "conditions" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js#L35-L58
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js
andEvaluator
function andEvaluator(conditions, leafEvaluator) { var sawNullResult = false; for (var i = 0; i < conditions.length; i++) { var conditionResult = evaluate(conditions[i], leafEvaluator); if (conditionResult === false) { return false; } if (conditionResult === null) { sawNullResult = true;...
javascript
function andEvaluator(conditions, leafEvaluator) { var sawNullResult = false; for (var i = 0; i < conditions.length; i++) { var conditionResult = evaluate(conditions[i], leafEvaluator); if (conditionResult === false) { return false; } if (conditionResult === null) { sawNullResult = true;...
[ "function", "andEvaluator", "(", "conditions", ",", "leafEvaluator", ")", "{", "var", "sawNullResult", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "conditions", ".", "length", ";", "i", "++", ")", "{", "var", "conditionResult", ...
Evaluates an array of conditions as if the evaluator had been applied to each entry and the results AND-ed together. @param {Array} conditions Array of conditions ex: [operand_1, operand_2] @param {Function} leafEvaluator Function which will be called to evaluate leaf condition values @return {?Boolean}...
[ "Evaluates", "an", "array", "of", "conditions", "as", "if", "the", "evaluator", "had", "been", "applied", "to", "each", "entry", "and", "the", "results", "AND", "-", "ed", "together", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js#L69-L81
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js
notEvaluator
function notEvaluator(conditions, leafEvaluator) { if (conditions.length > 0) { var result = evaluate(conditions[0], leafEvaluator); return result === null ? null : !result; } return null; }
javascript
function notEvaluator(conditions, leafEvaluator) { if (conditions.length > 0) { var result = evaluate(conditions[0], leafEvaluator); return result === null ? null : !result; } return null; }
[ "function", "notEvaluator", "(", "conditions", ",", "leafEvaluator", ")", "{", "if", "(", "conditions", ".", "length", ">", "0", ")", "{", "var", "result", "=", "evaluate", "(", "conditions", "[", "0", "]", ",", "leafEvaluator", ")", ";", "return", "resu...
Evaluates an array of conditions as if the evaluator had been applied to a single entry and NOT was applied to the result. @param {Array} conditions Array of conditions ex: [operand_1] @param {Function} leafEvaluator Function which will be called to evaluate leaf condition values @return {?Boolean} ...
[ "Evaluates", "an", "array", "of", "conditions", "as", "if", "the", "evaluator", "had", "been", "applied", "to", "a", "single", "entry", "and", "NOT", "was", "applied", "to", "the", "result", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/condition_tree_evaluator/index.js#L92-L98
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/optimizely/index.js
Optimizely
function Optimizely(config) { var clientEngine = config.clientEngine; if (clientEngine !== enums.NODE_CLIENT_ENGINE && clientEngine !== enums.JAVASCRIPT_CLIENT_ENGINE) { config.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.INVALID_CLIENT_ENGINE, MODULE_NAME, clientEngine)); clientEngine = enums.NODE_CLIEN...
javascript
function Optimizely(config) { var clientEngine = config.clientEngine; if (clientEngine !== enums.NODE_CLIENT_ENGINE && clientEngine !== enums.JAVASCRIPT_CLIENT_ENGINE) { config.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.INVALID_CLIENT_ENGINE, MODULE_NAME, clientEngine)); clientEngine = enums.NODE_CLIEN...
[ "function", "Optimizely", "(", "config", ")", "{", "var", "clientEngine", "=", "config", ".", "clientEngine", ";", "if", "(", "clientEngine", "!==", "enums", ".", "NODE_CLIENT_ENGINE", "&&", "clientEngine", "!==", "enums", ".", "JAVASCRIPT_CLIENT_ENGINE", ")", "...
The Optimizely class @param {Object} config @param {string} config.clientEngine @param {string} config.clientVersion @param {Object} config.datafile @param {Object} config.errorHandler @param {Object} config.eventDispatcher @param {Object} config.logger @param {Object} config.skipJSONValidation @param {Object} config.u...
[ "The", "Optimizely", "class" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/optimizely/index.js#L59-L119
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/user_profile_service_validator/index.js
function(userProfileServiceInstance) { if (typeof userProfileServiceInstance.lookup !== 'function') { throw new Error(sprintf(ERROR_MESSAGES.INVALID_USER_PROFILE_SERVICE, MODULE_NAME, 'Missing function \'lookup\'')); } else if (typeof userProfileServiceInstance.save !== 'function') { throw new Error...
javascript
function(userProfileServiceInstance) { if (typeof userProfileServiceInstance.lookup !== 'function') { throw new Error(sprintf(ERROR_MESSAGES.INVALID_USER_PROFILE_SERVICE, MODULE_NAME, 'Missing function \'lookup\'')); } else if (typeof userProfileServiceInstance.save !== 'function') { throw new Error...
[ "function", "(", "userProfileServiceInstance", ")", "{", "if", "(", "typeof", "userProfileServiceInstance", ".", "lookup", "!==", "'function'", ")", "{", "throw", "new", "Error", "(", "sprintf", "(", "ERROR_MESSAGES", ".", "INVALID_USER_PROFILE_SERVICE", ",", "MODUL...
Validates user's provided user profile service instance @param {Object} userProfileServiceInstance @return {boolean} True if the instance is valid @throws If the instance is not valid
[ "Validates", "user", "s", "provided", "user", "profile", "service", "instance" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/user_profile_service_validator/index.js#L33-L40
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/core/project_config/project_config_manager.js
ProjectConfigManager
function ProjectConfigManager(config) { try { this.__initialize(config); } catch (ex) { logger.error(ex); this.__updateListeners = []; this.__configObj = null; this.__readyPromise = Promise.resolve({ success: false, reason: getErrorMessage(ex, 'Error in initialize'), }); } }
javascript
function ProjectConfigManager(config) { try { this.__initialize(config); } catch (ex) { logger.error(ex); this.__updateListeners = []; this.__configObj = null; this.__readyPromise = Promise.resolve({ success: false, reason: getErrorMessage(ex, 'Error in initialize'), }); } }
[ "function", "ProjectConfigManager", "(", "config", ")", "{", "try", "{", "this", ".", "__initialize", "(", "config", ")", ";", "}", "catch", "(", "ex", ")", "{", "logger", ".", "error", "(", "ex", ")", ";", "this", ".", "__updateListeners", "=", "[", ...
ProjectConfigManager provides project config objects via its methods getConfig and onUpdate. It uses a DatafileManager to fetch datafiles. It is responsible for parsing and validating datafiles, and converting datafile JSON objects into project config objects. @param {Object} config @param {Object|string=} conf...
[ "ProjectConfigManager", "provides", "project", "config", "objects", "via", "its", "methods", "getConfig", "and", "onUpdate", ".", "It", "uses", "a", "DatafileManager", "to", "fetch", "datafiles", ".", "It", "is", "responsible", "for", "parsing", "and", "validating...
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/core/project_config/project_config_manager.js#L58-L70
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/json_schema_validator/index.js
function(jsonSchema, jsonObject) { if (!jsonSchema) { throw new Error(sprintf(ERROR_MESSAGES.JSON_SCHEMA_EXPECTED, MODULE_NAME)); } if (!jsonObject) { throw new Error(sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, MODULE_NAME)); } var result = validate(jsonObject, jsonSchema); if (result...
javascript
function(jsonSchema, jsonObject) { if (!jsonSchema) { throw new Error(sprintf(ERROR_MESSAGES.JSON_SCHEMA_EXPECTED, MODULE_NAME)); } if (!jsonObject) { throw new Error(sprintf(ERROR_MESSAGES.NO_JSON_PROVIDED, MODULE_NAME)); } var result = validate(jsonObject, jsonSchema); if (result...
[ "function", "(", "jsonSchema", ",", "jsonObject", ")", "{", "if", "(", "!", "jsonSchema", ")", "{", "throw", "new", "Error", "(", "sprintf", "(", "ERROR_MESSAGES", ".", "JSON_SCHEMA_EXPECTED", ",", "MODULE_NAME", ")", ")", ";", "}", "if", "(", "!", "json...
Validate the given json object against the specified schema @param {Object} jsonSchema The json schema to validate against @param {Object} jsonObject The object to validate against the schema @return {Boolean} True if the given object is valid
[ "Validate", "the", "given", "json", "object", "against", "the", "specified", "schema" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/json_schema_validator/index.js#L30-L48
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/event_tag_utils/index.js
function(eventTags, logger) { if (eventTags && eventTags.hasOwnProperty(REVENUE_EVENT_METRIC_NAME)) { var rawValue = eventTags[REVENUE_EVENT_METRIC_NAME]; var parsedRevenueValue = parseInt(rawValue, 10); if (isNaN(parsedRevenueValue)) { logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILE...
javascript
function(eventTags, logger) { if (eventTags && eventTags.hasOwnProperty(REVENUE_EVENT_METRIC_NAME)) { var rawValue = eventTags[REVENUE_EVENT_METRIC_NAME]; var parsedRevenueValue = parseInt(rawValue, 10); if (isNaN(parsedRevenueValue)) { logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILE...
[ "function", "(", "eventTags", ",", "logger", ")", "{", "if", "(", "eventTags", "&&", "eventTags", ".", "hasOwnProperty", "(", "REVENUE_EVENT_METRIC_NAME", ")", ")", "{", "var", "rawValue", "=", "eventTags", "[", "REVENUE_EVENT_METRIC_NAME", "]", ";", "var", "p...
Grab the revenue value from the event tags. "revenue" is a reserved keyword. @param {Object} eventTags @param {Object} logger @return {Integer|null}
[ "Grab", "the", "revenue", "value", "from", "the", "event", "tags", ".", "revenue", "is", "a", "reserved", "keyword", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js#L36-L48
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/event_tag_utils/index.js
function(eventTags, logger) { if (eventTags && eventTags.hasOwnProperty(VALUE_EVENT_METRIC_NAME)) { var rawValue = eventTags[VALUE_EVENT_METRIC_NAME]; var parsedEventValue = parseFloat(rawValue); if (isNaN(parsedEventValue)) { logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE...
javascript
function(eventTags, logger) { if (eventTags && eventTags.hasOwnProperty(VALUE_EVENT_METRIC_NAME)) { var rawValue = eventTags[VALUE_EVENT_METRIC_NAME]; var parsedEventValue = parseFloat(rawValue); if (isNaN(parsedEventValue)) { logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FAILED_TO_PARSE...
[ "function", "(", "eventTags", ",", "logger", ")", "{", "if", "(", "eventTags", "&&", "eventTags", ".", "hasOwnProperty", "(", "VALUE_EVENT_METRIC_NAME", ")", ")", "{", "var", "rawValue", "=", "eventTags", "[", "VALUE_EVENT_METRIC_NAME", "]", ";", "var", "parse...
Grab the event value from the event tags. "value" is a reserved keyword. @param {Object} eventTags @param {Object} logger @return {Number|null}
[ "Grab", "the", "event", "value", "from", "the", "event", "tags", ".", "value", "is", "a", "reserved", "keyword", "." ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/event_tag_utils/index.js#L56-L68
train
optimizely/javascript-sdk
packages/optimizely-sdk/lib/utils/attributes_validator/index.js
function(attributes) { if (typeof attributes === 'object' && !Array.isArray(attributes) && attributes !== null) { lodashForOwn(attributes, function(value, key) { if (typeof value === 'undefined') { throw new Error(sprintf(ERROR_MESSAGES.UNDEFINED_ATTRIBUTE, MODULE_NAME, key)); } ...
javascript
function(attributes) { if (typeof attributes === 'object' && !Array.isArray(attributes) && attributes !== null) { lodashForOwn(attributes, function(value, key) { if (typeof value === 'undefined') { throw new Error(sprintf(ERROR_MESSAGES.UNDEFINED_ATTRIBUTE, MODULE_NAME, key)); } ...
[ "function", "(", "attributes", ")", "{", "if", "(", "typeof", "attributes", "===", "'object'", "&&", "!", "Array", ".", "isArray", "(", "attributes", ")", "&&", "attributes", "!==", "null", ")", "{", "lodashForOwn", "(", "attributes", ",", "function", "(",...
Validates user's provided attributes @param {Object} attributes @return {boolean} True if the attributes are valid @throws If the attributes are not valid
[ "Validates", "user", "s", "provided", "attributes" ]
39c3b2d97388100abd1c25d355a71c72b17363be
https://github.com/optimizely/javascript-sdk/blob/39c3b2d97388100abd1c25d355a71c72b17363be/packages/optimizely-sdk/lib/utils/attributes_validator/index.js#L35-L46
train
qTip2/qTip2
src/tips/tips.js
function(corner, size, scale) { scale = scale || 1; size = size || this.size; var width = size[0] * scale, height = size[1] * scale, width2 = Math.ceil(width / 2), height2 = Math.ceil(height / 2), // Define tip coordinates in terms of height and width values tips = { br: [0,0, width,height, width,...
javascript
function(corner, size, scale) { scale = scale || 1; size = size || this.size; var width = size[0] * scale, height = size[1] * scale, width2 = Math.ceil(width / 2), height2 = Math.ceil(height / 2), // Define tip coordinates in terms of height and width values tips = { br: [0,0, width,height, width,...
[ "function", "(", "corner", ",", "size", ",", "scale", ")", "{", "scale", "=", "scale", "||", "1", ";", "size", "=", "size", "||", "this", ".", "size", ";", "var", "width", "=", "size", "[", "0", "]", "*", "scale", ",", "height", "=", "size", "[...
Tip coordinates calculator
[ "Tip", "coordinates", "calculator" ]
eeffdbaa2340de54f8fb9f0dd0d17532f907be55
https://github.com/qTip2/qTip2/blob/eeffdbaa2340de54f8fb9f0dd0d17532f907be55/src/tips/tips.js#L222-L247
train
qTip2/qTip2
dist/jquery.qtip.js
function() { if(!this.rendered) { return; } // Set tracking flag var posOptions = this.options.position; this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); // Reassign events this._unassignEvents(); this._assignEvents(); }
javascript
function() { if(!this.rendered) { return; } // Set tracking flag var posOptions = this.options.position; this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); // Reassign events this._unassignEvents(); this._assignEvents(); }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "rendered", ")", "{", "return", ";", "}", "// Set tracking flag", "var", "posOptions", "=", "this", ".", "options", ".", "position", ";", "this", ".", "tooltip", ".", "attr", "(", "'tracking'", ",...
Properties which require event reassignment
[ "Properties", "which", "require", "event", "reassignment" ]
eeffdbaa2340de54f8fb9f0dd0d17532f907be55
https://github.com/qTip2/qTip2/blob/eeffdbaa2340de54f8fb9f0dd0d17532f907be55/dist/jquery.qtip.js#L483-L493
train
qTip2/qTip2
dist/jquery.qtip.js
convertNotation
function convertNotation(options, notation) { var i = 0, obj, option = options, // Split notation into array levels = notation.split('.'); // Loop through while(option = option[ levels[i++] ]) { if(i < levels.length) { obj = option; } } return [obj || options, levels.pop()]; }
javascript
function convertNotation(options, notation) { var i = 0, obj, option = options, // Split notation into array levels = notation.split('.'); // Loop through while(option = option[ levels[i++] ]) { if(i < levels.length) { obj = option; } } return [obj || options, levels.pop()]; }
[ "function", "convertNotation", "(", "options", ",", "notation", ")", "{", "var", "i", "=", "0", ",", "obj", ",", "option", "=", "options", ",", "// Split notation into array", "levels", "=", "notation", ".", "split", "(", "'.'", ")", ";", "// Loop through", ...
Dot notation converter
[ "Dot", "notation", "converter" ]
eeffdbaa2340de54f8fb9f0dd0d17532f907be55
https://github.com/qTip2/qTip2/blob/eeffdbaa2340de54f8fb9f0dd0d17532f907be55/dist/jquery.qtip.js#L498-L510
train