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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
node-pinus/pinus | tools/pinus-admin-web/public/js/socket.io.js | JSONPPolling | function JSONPPolling (socket) {
io.Transport['xhr-polling'].apply(this, arguments);
this.index = io.j.length;
var self = this;
io.j.push(function (msg) {
self._(msg);
});
} | javascript | function JSONPPolling (socket) {
io.Transport['xhr-polling'].apply(this, arguments);
this.index = io.j.length;
var self = this;
io.j.push(function (msg) {
self._(msg);
});
} | [
"function",
"JSONPPolling",
"(",
"socket",
")",
"{",
"io",
".",
"Transport",
"[",
"'xhr-polling'",
"]",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"index",
"=",
"io",
".",
"j",
".",
"length",
";",
"var",
"self",
"=",
"this",
... | The JSONP transport creates an persistent connection by dynamically
inserting a script tag in the page. This script tag will receive the
information of the Socket.IO server. When new information is received
it creates a new script tag for the new data stream.
@constructor
@extends {io.Transport.xhr-polling}
@api publi... | [
"The",
"JSONP",
"transport",
"creates",
"an",
"persistent",
"connection",
"by",
"dynamically",
"inserting",
"a",
"script",
"tag",
"in",
"the",
"page",
".",
"This",
"script",
"tag",
"will",
"receive",
"the",
"information",
"of",
"the",
"Socket",
".",
"IO",
"s... | 985ba74bc4ef4bab12d4b0cc677c8c07c557d8de | https://github.com/node-pinus/pinus/blob/985ba74bc4ef4bab12d4b0cc677c8c07c557d8de/tools/pinus-admin-web/public/js/socket.io.js#L3532-L3542 | train |
ethereum/remix | remix-debug/src/solidity-decoder/astHelper.js | extractStateDefinitions | function extractStateDefinitions (contractName, sourcesList, contracts) {
if (!contracts) {
contracts = extractContractDefinitions(sourcesList)
}
var node = contracts.contractsByName[contractName]
if (node) {
var stateItems = []
var stateVar = []
var baseContracts = getLinearizedBaseContracts(no... | javascript | function extractStateDefinitions (contractName, sourcesList, contracts) {
if (!contracts) {
contracts = extractContractDefinitions(sourcesList)
}
var node = contracts.contractsByName[contractName]
if (node) {
var stateItems = []
var stateVar = []
var baseContracts = getLinearizedBaseContracts(no... | [
"function",
"extractStateDefinitions",
"(",
"contractName",
",",
"sourcesList",
",",
"contracts",
")",
"{",
"if",
"(",
"!",
"contracts",
")",
"{",
"contracts",
"=",
"extractContractDefinitions",
"(",
"sourcesList",
")",
"}",
"var",
"node",
"=",
"contracts",
".",... | return state var and type definition of the given contract
@param {String} contractName - contract for which state var should be resolved
@param {Object} sourcesList - sources list (containing root AST node)
@param {Object} [contracts] - map of contract definitions (contains contractsById, contractsByName)
@return {Ob... | [
"return",
"state",
"var",
"and",
"type",
"definition",
"of",
"the",
"given",
"contract"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/solidity-decoder/astHelper.js#L49-L75 | train |
ethereum/remix | remix-lib/src/util.js | function (hexString) {
if (hexString.slice(0, 2) === '0x') {
hexString = hexString.slice(2)
}
var integers = []
for (var i = 0; i < hexString.length; i += 2) {
integers.push(parseInt(hexString.slice(i, i + 2), 16))
}
return integers
} | javascript | function (hexString) {
if (hexString.slice(0, 2) === '0x') {
hexString = hexString.slice(2)
}
var integers = []
for (var i = 0; i < hexString.length; i += 2) {
integers.push(parseInt(hexString.slice(i, i + 2), 16))
}
return integers
} | [
"function",
"(",
"hexString",
")",
"{",
"if",
"(",
"hexString",
".",
"slice",
"(",
"0",
",",
"2",
")",
"===",
"'0x'",
")",
"{",
"hexString",
"=",
"hexString",
".",
"slice",
"(",
"2",
")",
"}",
"var",
"integers",
"=",
"[",
"]",
"for",
"(",
"var",
... | Converts a hex string to an array of integers. | [
"Converts",
"a",
"hex",
"string",
"to",
"an",
"array",
"of",
"integers",
"."
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/util.js#L33-L42 | train | |
ethereum/remix | remix-debug/src/storage/mappingPreimages.js | getPreimage | function getPreimage (web3, key) {
return new Promise((resolve, reject) => {
web3.debug.preimage(key.indexOf('0x') === 0 ? key : '0x' + key, function (error, preimage) {
if (error) {
resolve(null)
} else {
resolve(preimage)
}
})
})
} | javascript | function getPreimage (web3, key) {
return new Promise((resolve, reject) => {
web3.debug.preimage(key.indexOf('0x') === 0 ? key : '0x' + key, function (error, preimage) {
if (error) {
resolve(null)
} else {
resolve(preimage)
}
})
})
} | [
"function",
"getPreimage",
"(",
"web3",
",",
"key",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"web3",
".",
"debug",
".",
"preimage",
"(",
"key",
".",
"indexOf",
"(",
"'0x'",
")",
"===",
"0",
"?",
"key... | Uses web3 to return preimage of a key
@param {String} key - key to retrieve the preimage of
@return {String} - preimage of the given key | [
"Uses",
"web3",
"to",
"return",
"preimage",
"of",
"a",
"key"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/storage/mappingPreimages.js#L51-L61 | train |
ethereum/remix | remix-debug/src/solidity-decoder/stateDecoder.js | decodeState | async function decodeState (stateVars, storageResolver) {
var ret = {}
for (var k in stateVars) {
var stateVar = stateVars[k]
try {
var decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver)
decoded.constant = stateVar.constant
if (decoded.constant) {
... | javascript | async function decodeState (stateVars, storageResolver) {
var ret = {}
for (var k in stateVars) {
var stateVar = stateVars[k]
try {
var decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver)
decoded.constant = stateVar.constant
if (decoded.constant) {
... | [
"async",
"function",
"decodeState",
"(",
"stateVars",
",",
"storageResolver",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
"for",
"(",
"var",
"k",
"in",
"stateVars",
")",
"{",
"var",
"stateVar",
"=",
"stateVars",
"[",
"k",
"]",
"try",
"{",
"var",
"decoded",
... | decode the contract state storage
@param {Array} storage location - location of all state variables
@param {Object} storageResolver - resolve storage queries
@return {Map} - decoded state variable | [
"decode",
"the",
"contract",
"state",
"storage"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/solidity-decoder/stateDecoder.js#L11-L28 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isDynamicArrayAccess | function isDynamicArrayAccess (node) {
return node && nodeType(node, exactMatch(nodeTypes.IDENTIFIER)) && (node.attributes.type.endsWith('[] storage ref') || node.attributes.type === 'bytes storage ref' || node.attributes.type === 'string storage ref')
} | javascript | function isDynamicArrayAccess (node) {
return node && nodeType(node, exactMatch(nodeTypes.IDENTIFIER)) && (node.attributes.type.endsWith('[] storage ref') || node.attributes.type === 'bytes storage ref' || node.attributes.type === 'string storage ref')
} | [
"function",
"isDynamicArrayAccess",
"(",
"node",
")",
"{",
"return",
"node",
"&&",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"IDENTIFIER",
")",
")",
"&&",
"(",
"node",
".",
"attributes",
".",
"type",
".",
"endsWith",
"(",
"'[] stor... | True if node is node is a ref to a dynamic array
@node {ASTNode} node to check for
@return {bool} | [
"True",
"if",
"node",
"is",
"node",
"is",
"a",
"ref",
"to",
"a",
"dynamic",
"array"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L506-L508 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isConstantFunction | function isConstantFunction (node) {
return isFunctionDefinition(node) && (
node.attributes.constant === true ||
node.attributes.stateMutability === 'view' ||
node.attributes.stateMutability === 'pure'
)
} | javascript | function isConstantFunction (node) {
return isFunctionDefinition(node) && (
node.attributes.constant === true ||
node.attributes.stateMutability === 'view' ||
node.attributes.stateMutability === 'pure'
)
} | [
"function",
"isConstantFunction",
"(",
"node",
")",
"{",
"return",
"isFunctionDefinition",
"(",
"node",
")",
"&&",
"(",
"node",
".",
"attributes",
".",
"constant",
"===",
"true",
"||",
"node",
".",
"attributes",
".",
"stateMutability",
"===",
"'view'",
"||",
... | True if is function defintion that is flaged as constant
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"is",
"function",
"defintion",
"that",
"is",
"flaged",
"as",
"constant"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L634-L640 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isPlusPlusUnaryOperation | function isPlusPlusUnaryOperation (node) {
return nodeType(node, exactMatch(nodeTypes.UNARYOPERATION)) && operator(node, exactMatch(util.escapeRegExp('++')))
} | javascript | function isPlusPlusUnaryOperation (node) {
return nodeType(node, exactMatch(nodeTypes.UNARYOPERATION)) && operator(node, exactMatch(util.escapeRegExp('++')))
} | [
"function",
"isPlusPlusUnaryOperation",
"(",
"node",
")",
"{",
"return",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"UNARYOPERATION",
")",
")",
"&&",
"operator",
"(",
"node",
",",
"exactMatch",
"(",
"util",
".",
"escapeRegExp",
"(",
"... | True if unary increment operation
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"unary",
"increment",
"operation"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L705-L707 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isFullyImplementedContract | function isFullyImplementedContract (node) {
return nodeType(node, exactMatch(nodeTypes.CONTRACTDEFINITION)) && node.attributes.fullyImplemented === true
} | javascript | function isFullyImplementedContract (node) {
return nodeType(node, exactMatch(nodeTypes.CONTRACTDEFINITION)) && node.attributes.fullyImplemented === true
} | [
"function",
"isFullyImplementedContract",
"(",
"node",
")",
"{",
"return",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"CONTRACTDEFINITION",
")",
")",
"&&",
"node",
".",
"attributes",
".",
"fullyImplemented",
"===",
"true",
"}"
] | True if all functions on a contract are implemented
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"all",
"functions",
"on",
"a",
"contract",
"are",
"implemented"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L732-L734 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLibrary | function isLibrary (node) {
return nodeType(node, exactMatch(nodeTypes.CONTRACTDEFINITION)) && node.attributes.isLibrary === true
} | javascript | function isLibrary (node) {
return nodeType(node, exactMatch(nodeTypes.CONTRACTDEFINITION)) && node.attributes.isLibrary === true
} | [
"function",
"isLibrary",
"(",
"node",
")",
"{",
"return",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"CONTRACTDEFINITION",
")",
")",
"&&",
"node",
".",
"attributes",
".",
"isLibrary",
"===",
"true",
"}"
] | True if it is a library contract defintion
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"it",
"is",
"a",
"library",
"contract",
"defintion"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L741-L743 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLibraryCall | function isLibraryCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, undefined, basicRegex.LIBRARYTYPE, undefined)
} | javascript | function isLibraryCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, undefined, basicRegex.LIBRARYTYPE, undefined)
} | [
"function",
"isLibraryCall",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"basicRegex",
".",
"FUNCTIONTYPE",
",",
"undefined",
",",
"basicRegex",
".",
"LIBRARYTYPE",
",",
"undefined",
")",
"}"
] | True if it is a call to a library
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"it",
"is",
"a",
"call",
"to",
"a",
"library"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L759-L761 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isNowAccess | function isNowAccess (node) {
return nodeType(node, exactMatch(nodeTypes.IDENTIFIER)) &&
expressionType(node, exactMatch(basicTypes.UINT)) &&
name(node, exactMatch('now'))
} | javascript | function isNowAccess (node) {
return nodeType(node, exactMatch(nodeTypes.IDENTIFIER)) &&
expressionType(node, exactMatch(basicTypes.UINT)) &&
name(node, exactMatch('now'))
} | [
"function",
"isNowAccess",
"(",
"node",
")",
"{",
"return",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"IDENTIFIER",
")",
")",
"&&",
"expressionType",
"(",
"node",
",",
"exactMatch",
"(",
"basicTypes",
".",
"UINT",
")",
")",
"&&",
... | True if access to block.timestamp via now alias
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"access",
"to",
"block",
".",
"timestamp",
"via",
"now",
"alias"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L777-L781 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isBlockBlockHashAccess | function isBlockBlockHashAccess (node) {
return isSpecialVariableAccess(node, specialVariables.BLOCKHASH) || isBuiltinFunctionCall(node) && getLocalCallName(node) === 'blockhash'
} | javascript | function isBlockBlockHashAccess (node) {
return isSpecialVariableAccess(node, specialVariables.BLOCKHASH) || isBuiltinFunctionCall(node) && getLocalCallName(node) === 'blockhash'
} | [
"function",
"isBlockBlockHashAccess",
"(",
"node",
")",
"{",
"return",
"isSpecialVariableAccess",
"(",
"node",
",",
"specialVariables",
".",
"BLOCKHASH",
")",
"||",
"isBuiltinFunctionCall",
"(",
"node",
")",
"&&",
"getLocalCallName",
"(",
"node",
")",
"===",
"'blo... | True if access to block.blockhash
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"access",
"to",
"block",
".",
"blockhash"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L797-L799 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isThisLocalCall | function isThisLocalCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, exactMatch('this'), basicRegex.CONTRACTTYPE, undefined)
} | javascript | function isThisLocalCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, exactMatch('this'), basicRegex.CONTRACTTYPE, undefined)
} | [
"function",
"isThisLocalCall",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"basicRegex",
".",
"FUNCTIONTYPE",
",",
"exactMatch",
"(",
"'this'",
")",
",",
"basicRegex",
".",
"CONTRACTTYPE",
",",
"undefined",
")",
"}"
] | True if call to local function via this keyword
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"call",
"to",
"local",
"function",
"via",
"this",
"keyword"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L806-L808 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isSuperLocalCall | function isSuperLocalCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, exactMatch('super'), basicRegex.CONTRACTTYPE, undefined)
} | javascript | function isSuperLocalCall (node) {
return isMemberAccess(node, basicRegex.FUNCTIONTYPE, exactMatch('super'), basicRegex.CONTRACTTYPE, undefined)
} | [
"function",
"isSuperLocalCall",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"basicRegex",
".",
"FUNCTIONTYPE",
",",
"exactMatch",
"(",
"'super'",
")",
",",
"basicRegex",
".",
"CONTRACTTYPE",
",",
"undefined",
")",
"}"
] | True if access to local function via super keyword
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"access",
"to",
"local",
"function",
"via",
"super",
"keyword"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L815-L817 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLocalCall | function isLocalCall (node) {
return nodeType(node, exactMatch(nodeTypes.FUNCTIONCALL)) &&
minNrOfChildren(node, 1) &&
nodeType(node.children[0], exactMatch(nodeTypes.IDENTIFIER)) &&
expressionType(node.children[0], basicRegex.FUNCTIONTYPE) &&
!expressionType(node.children[0], basicReg... | javascript | function isLocalCall (node) {
return nodeType(node, exactMatch(nodeTypes.FUNCTIONCALL)) &&
minNrOfChildren(node, 1) &&
nodeType(node.children[0], exactMatch(nodeTypes.IDENTIFIER)) &&
expressionType(node.children[0], basicRegex.FUNCTIONTYPE) &&
!expressionType(node.children[0], basicReg... | [
"function",
"isLocalCall",
"(",
"node",
")",
"{",
"return",
"nodeType",
"(",
"node",
",",
"exactMatch",
"(",
"nodeTypes",
".",
"FUNCTIONCALL",
")",
")",
"&&",
"minNrOfChildren",
"(",
"node",
",",
"1",
")",
"&&",
"nodeType",
"(",
"node",
".",
"children",
... | True if call to local function
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"call",
"to",
"local",
"function"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L824-L831 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLLCall | function isLLCall (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.CALL.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.CALL.ident))
} | javascript | function isLLCall (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.CALL.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.CALL.ident))
} | [
"function",
"isLLCall",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"exactMatch",
"(",
"util",
".",
"escapeRegExp",
"(",
"lowLevelCallTypes",
".",
"CALL",
".",
"type",
")",
")",
",",
"undefined",
",",
"exactMatch",
"(",
"basicTypes",... | True if low level call
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"low",
"level",
"call"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L875-L879 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLLCallcode | function isLLCallcode (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.CALLCODE.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.CALLCODE.ident))
} | javascript | function isLLCallcode (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.CALLCODE.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.CALLCODE.ident))
} | [
"function",
"isLLCallcode",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"exactMatch",
"(",
"util",
".",
"escapeRegExp",
"(",
"lowLevelCallTypes",
".",
"CALLCODE",
".",
"type",
")",
")",
",",
"undefined",
",",
"exactMatch",
"(",
"basi... | True if low level callcode
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"low",
"level",
"callcode"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L897-L901 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | isLLDelegatecall | function isLLDelegatecall (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.DELEGATECALL.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.DELEGATECALL.ident))
} | javascript | function isLLDelegatecall (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.DELEGATECALL.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.DELEGATECALL.ident))
} | [
"function",
"isLLDelegatecall",
"(",
"node",
")",
"{",
"return",
"isMemberAccess",
"(",
"node",
",",
"exactMatch",
"(",
"util",
".",
"escapeRegExp",
"(",
"lowLevelCallTypes",
".",
"DELEGATECALL",
".",
"type",
")",
")",
",",
"undefined",
",",
"exactMatch",
"(",... | True if low level delegatecall
@node {ASTNode} some AstNode
@return {bool} | [
"True",
"if",
"low",
"level",
"delegatecall"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L908-L912 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | buildFunctionSignature | function buildFunctionSignature (paramTypes, returnTypes, isPayable, additionalMods) {
return 'function (' + util.concatWithSeperator(paramTypes, ',') + ')' + ((isPayable) ? ' payable' : '') + ((additionalMods) ? ' ' + additionalMods : '') + ((returnTypes.length) ? ' returns (' + util.concatWithSeperator(returnTypes,... | javascript | function buildFunctionSignature (paramTypes, returnTypes, isPayable, additionalMods) {
return 'function (' + util.concatWithSeperator(paramTypes, ',') + ')' + ((isPayable) ? ' payable' : '') + ((additionalMods) ? ' ' + additionalMods : '') + ((returnTypes.length) ? ' returns (' + util.concatWithSeperator(returnTypes,... | [
"function",
"buildFunctionSignature",
"(",
"paramTypes",
",",
"returnTypes",
",",
"isPayable",
",",
"additionalMods",
")",
"{",
"return",
"'function ('",
"+",
"util",
".",
"concatWithSeperator",
"(",
"paramTypes",
",",
"','",
")",
"+",
"')'",
"+",
"(",
"(",
"i... | Builds an function signature as used in the AST of the solc-json AST
@param {Array} paramTypes
list of parameter type names
@param {Array} returnTypes
list of return type names
@return {Boolean} isPayable | [
"Builds",
"an",
"function",
"signature",
"as",
"used",
"in",
"the",
"AST",
"of",
"the",
"solc",
"-",
"json",
"AST"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L1023-L1025 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js | findFirstSubNodeLTR | function findFirstSubNodeLTR (node, type) {
if (!node || !node.children) return null
for (let i = 0; i < node.children.length; ++i) {
var item = node.children[i]
if (nodeType(item, type)) return item
else {
var res = findFirstSubNodeLTR(item, type)
if (res) return res
}
}
return null... | javascript | function findFirstSubNodeLTR (node, type) {
if (!node || !node.children) return null
for (let i = 0; i < node.children.length; ++i) {
var item = node.children[i]
if (nodeType(item, type)) return item
else {
var res = findFirstSubNodeLTR(item, type)
if (res) return res
}
}
return null... | [
"function",
"findFirstSubNodeLTR",
"(",
"node",
",",
"type",
")",
"{",
"if",
"(",
"!",
"node",
"||",
"!",
"node",
".",
"children",
")",
"return",
"null",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"children",
".",
"length",
";",
... | Finds first node of a certain type under a specific node.
@node {AstNode} node to start form
@type {String} Type the ast node should have
@return {AstNode} null or node found | [
"Finds",
"first",
"node",
"of",
"a",
"certain",
"type",
"under",
"a",
"specific",
"node",
"."
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/staticAnalysisCommon.js#L1037-L1048 | train |
ethereum/remix | remix-debug/src/Ethdebugger.js | Ethdebugger | function Ethdebugger (opts) {
this.opts = opts || {}
if (!this.opts.compilationResult) this.opts.compilationResult = () => { return null }
this.web3 = opts.web3
this.event = new EventManager()
this.tx
this.traceManager = new TraceManager({web3: this.web3})
this.codeManager = new CodeManager(this.trace... | javascript | function Ethdebugger (opts) {
this.opts = opts || {}
if (!this.opts.compilationResult) this.opts.compilationResult = () => { return null }
this.web3 = opts.web3
this.event = new EventManager()
this.tx
this.traceManager = new TraceManager({web3: this.web3})
this.codeManager = new CodeManager(this.trace... | [
"function",
"Ethdebugger",
"(",
"opts",
")",
"{",
"this",
".",
"opts",
"=",
"opts",
"||",
"{",
"}",
"if",
"(",
"!",
"this",
".",
"opts",
".",
"compilationResult",
")",
"this",
".",
"opts",
".",
"compilationResult",
"=",
"(",
")",
"=>",
"{",
"return",... | Ethdebugger is a wrapper around a few classes that helps debugging a transaction
- Web3Providers - define which environment (web3) the transaction will be retrieved from
- TraceManager - Load / Analyze the trace and retrieve details of specific test
- CodeManager - Retrieve loaded byte code and help to resolve AST ite... | [
"Ethdebugger",
"is",
"a",
"wrapper",
"around",
"a",
"few",
"classes",
"that",
"helps",
"debugging",
"a",
"transaction"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/Ethdebugger.js#L31-L47 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/gasCosts.js | visitContracts | function visitContracts (contracts, cb) {
for (var file in contracts) {
for (var name in contracts[file]) {
if (cb({ name: name, object: contracts[file][name], file: file })) return
}
}
} | javascript | function visitContracts (contracts, cb) {
for (var file in contracts) {
for (var name in contracts[file]) {
if (cb({ name: name, object: contracts[file][name], file: file })) return
}
}
} | [
"function",
"visitContracts",
"(",
"contracts",
",",
"cb",
")",
"{",
"for",
"(",
"var",
"file",
"in",
"contracts",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"contracts",
"[",
"file",
"]",
")",
"{",
"if",
"(",
"cb",
"(",
"{",
"name",
":",
"name",
... | call the given @arg cb (function) for all the contracts. Uses last compilation result
stop visiting when cb return true
@param {Function} cb - callback
@TODO has been copied from remix-ide repo ! should fix that soon ! | [
"call",
"the",
"given"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/gasCosts.js#L15-L21 | train |
ethereum/remix | remix-lib/src/code/codeUtils.js | function (raw) {
var code = []
for (var i = 0; i < raw.length; i++) {
var opcode = opcodes(raw[i], true)
if (opcode.name.slice(0, 4) === 'PUSH') {
var length = raw[i] - 0x5f
opcode.pushData = raw.slice(i + 1, i + length + 1)
// in case pushdata extends beyond code
if ... | javascript | function (raw) {
var code = []
for (var i = 0; i < raw.length; i++) {
var opcode = opcodes(raw[i], true)
if (opcode.name.slice(0, 4) === 'PUSH') {
var length = raw[i] - 0x5f
opcode.pushData = raw.slice(i + 1, i + length + 1)
// in case pushdata extends beyond code
if ... | [
"function",
"(",
"raw",
")",
"{",
"var",
"code",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"raw",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"opcode",
"=",
"opcodes",
"(",
"raw",
"[",
"i",
"]",
",",
"true",
")",
... | Parses code as a list of integers into a list of objects containing
information about the opcode. | [
"Parses",
"code",
"as",
"a",
"list",
"of",
"integers",
"into",
"a",
"list",
"of",
"objects",
"containing",
"information",
"about",
"the",
"opcode",
"."
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/code/codeUtils.js#L33-L51 | train | |
ethereum/remix | remix-lib/src/execution/txFormat.js | function (funABI, values, contractbyteCode) {
var encoded
var encodedHex
try {
encoded = helper.encodeParams(funABI, values)
encodedHex = encoded.toString('hex')
} catch (e) {
return { error: 'cannot encode arguments' }
}
if (contractbyteCode) {
return { data: '0x' + cont... | javascript | function (funABI, values, contractbyteCode) {
var encoded
var encodedHex
try {
encoded = helper.encodeParams(funABI, values)
encodedHex = encoded.toString('hex')
} catch (e) {
return { error: 'cannot encode arguments' }
}
if (contractbyteCode) {
return { data: '0x' + cont... | [
"function",
"(",
"funABI",
",",
"values",
",",
"contractbyteCode",
")",
"{",
"var",
"encoded",
"var",
"encodedHex",
"try",
"{",
"encoded",
"=",
"helper",
".",
"encodeParams",
"(",
"funABI",
",",
"values",
")",
"encodedHex",
"=",
"encoded",
".",
"toString",
... | build the transaction data
@param {Object} function abi
@param {Object} values to encode
@param {String} contractbyteCode | [
"build",
"the",
"transaction",
"data"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/execution/txFormat.js#L17-L31 | train | |
ethereum/remix | remix-lib/src/execution/txFormat.js | function (contract, params, funAbi, linkLibraries, linkReferences, callback) {
this.encodeParams(params, funAbi, (error, encodedParam) => {
if (error) return callback(error)
var bytecodeToDeploy = contract.evm.bytecode.object
if (bytecodeToDeploy.indexOf('_') >= 0) {
if (linkLibraries && l... | javascript | function (contract, params, funAbi, linkLibraries, linkReferences, callback) {
this.encodeParams(params, funAbi, (error, encodedParam) => {
if (error) return callback(error)
var bytecodeToDeploy = contract.evm.bytecode.object
if (bytecodeToDeploy.indexOf('_') >= 0) {
if (linkLibraries && l... | [
"function",
"(",
"contract",
",",
"params",
",",
"funAbi",
",",
"linkLibraries",
",",
"linkReferences",
",",
"callback",
")",
"{",
"this",
".",
"encodeParams",
"(",
"params",
",",
"funAbi",
",",
"(",
"error",
",",
"encodedParam",
")",
"=>",
"{",
"if",
"(... | encode constructor creation and link with provided libraries if needed
@param {Object} contract - input paramater of the function to call
@param {Object} params - input paramater of the function to call
@param {Object} funAbi - abi definition of the function to call. null if building data for the ctor.
@param... | [
"encode",
"constructor",
"creation",
"and",
"link",
"with",
"provided",
"libraries",
"if",
"needed"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/execution/txFormat.js#L100-L120 | train | |
ethereum/remix | remix-lib/src/execution/txFormat.js | function (contractName, contract, contracts, params, funAbi, callback, callbackStep, callbackDeployLibrary) {
this.encodeParams(params, funAbi, (error, encodedParam) => {
if (error) return callback(error)
var dataHex = ''
var contractBytecode = contract.evm.bytecode.object
var bytecodeToDepl... | javascript | function (contractName, contract, contracts, params, funAbi, callback, callbackStep, callbackDeployLibrary) {
this.encodeParams(params, funAbi, (error, encodedParam) => {
if (error) return callback(error)
var dataHex = ''
var contractBytecode = contract.evm.bytecode.object
var bytecodeToDepl... | [
"function",
"(",
"contractName",
",",
"contract",
",",
"contracts",
",",
"params",
",",
"funAbi",
",",
"callback",
",",
"callbackStep",
",",
"callbackDeployLibrary",
")",
"{",
"this",
".",
"encodeParams",
"(",
"params",
",",
"funAbi",
",",
"(",
"error",
",",... | encode constructor creation and deploy librairies if needed
@param {String} contractName - current contract name
@param {Object} contract - input paramater of the function to call
@param {Object} contracts - map of all compiled contracts.
@param {Object} params - input paramater of the function to call
@pa... | [
"encode",
"constructor",
"creation",
"and",
"deploy",
"librairies",
"if",
"needed"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/execution/txFormat.js#L135-L156 | train | |
ethereum/remix | remix-lib/src/helpers/traceHelper.js | function (vmTraceIndex, trace) {
var step = trace[vmTraceIndex]
if (this.isCreateInstruction(step)) {
return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ...
return ui.normalizeHexAddress(stack[stack.l... | javascript | function (vmTraceIndex, trace) {
var step = trace[vmTraceIndex]
if (this.isCreateInstruction(step)) {
return this.contractCreationToken(vmTraceIndex)
} else if (this.isCallInstruction(step)) {
var stack = step.stack // callcode, delegatecall, ...
return ui.normalizeHexAddress(stack[stack.l... | [
"function",
"(",
"vmTraceIndex",
",",
"trace",
")",
"{",
"var",
"step",
"=",
"trace",
"[",
"vmTraceIndex",
"]",
"if",
"(",
"this",
".",
"isCreateInstruction",
"(",
"step",
")",
")",
"{",
"return",
"this",
".",
"contractCreationToken",
"(",
"vmTraceIndex",
... | vmTraceIndex has to point to a CALL, CODECALL, ... | [
"vmTraceIndex",
"has",
"to",
"point",
"to",
"a",
"CALL",
"CODECALL",
"..."
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/helpers/traceHelper.js#L5-L14 | train | |
ethereum/remix | remix-debug/src/solidity-decoder/decodeInfo.js | typeClass | function typeClass (fullType) {
fullType = util.removeLocation(fullType)
if (fullType.lastIndexOf(']') === fullType.length - 1) {
return 'array'
}
if (fullType.indexOf('mapping') === 0) {
return 'mapping'
}
if (fullType.indexOf(' ') !== -1) {
fullType = fullType.split(' ')[0]
}
var char = fu... | javascript | function typeClass (fullType) {
fullType = util.removeLocation(fullType)
if (fullType.lastIndexOf(']') === fullType.length - 1) {
return 'array'
}
if (fullType.indexOf('mapping') === 0) {
return 'mapping'
}
if (fullType.indexOf(' ') !== -1) {
fullType = fullType.split(' ')[0]
}
var char = fu... | [
"function",
"typeClass",
"(",
"fullType",
")",
"{",
"fullType",
"=",
"util",
".",
"removeLocation",
"(",
"fullType",
")",
"if",
"(",
"fullType",
".",
"lastIndexOf",
"(",
"']'",
")",
"===",
"fullType",
".",
"length",
"-",
"1",
")",
"{",
"return",
"'array'... | parse the full type
@param {String} fullType - type given by the AST (ex: uint[2] storage ref[2])
@return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX) | [
"parse",
"the",
"full",
"type"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/solidity-decoder/decodeInfo.js#L267-L280 | train |
ethereum/remix | remix-debug/src/solidity-decoder/decodeInfo.js | parseType | function parseType (type, stateDefinitions, contractName, location) {
var decodeInfos = {
'contract': address,
'address': address,
'array': array,
'bool': bool,
'bytes': dynamicByteArray,
'bytesX': fixedByteArray,
'enum': enumType,
'string': stringType,
'struct': struct,
'int':... | javascript | function parseType (type, stateDefinitions, contractName, location) {
var decodeInfos = {
'contract': address,
'address': address,
'array': array,
'bool': bool,
'bytes': dynamicByteArray,
'bytesX': fixedByteArray,
'enum': enumType,
'string': stringType,
'struct': struct,
'int':... | [
"function",
"parseType",
"(",
"type",
",",
"stateDefinitions",
",",
"contractName",
",",
"location",
")",
"{",
"var",
"decodeInfos",
"=",
"{",
"'contract'",
":",
"address",
",",
"'address'",
":",
"address",
",",
"'array'",
":",
"array",
",",
"'bool'",
":",
... | parse the type and return an object representing the type
@param {Object} type - type name given by the ast node
@param {Object} stateDefinitions - all state stateDefinitions given by the AST (including struct and enum type declaration) for all contracts
@param {String} contractName - contract the @args typeName belon... | [
"parse",
"the",
"type",
"and",
"return",
"an",
"object",
"representing",
"the",
"type"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-debug/src/solidity-decoder/decodeInfo.js#L291-L316 | train |
ethereum/remix | remix-analyzer/src/solidity-analyzer/modules/functionCallGraph.js | analyseCallGraph | function analyseCallGraph (callGraph, funcName, context, nodeCheck) {
return analyseCallGraphInternal(callGraph, funcName, context, (a, b) => a || b, nodeCheck, {})
} | javascript | function analyseCallGraph (callGraph, funcName, context, nodeCheck) {
return analyseCallGraphInternal(callGraph, funcName, context, (a, b) => a || b, nodeCheck, {})
} | [
"function",
"analyseCallGraph",
"(",
"callGraph",
",",
"funcName",
",",
"context",
",",
"nodeCheck",
")",
"{",
"return",
"analyseCallGraphInternal",
"(",
"callGraph",
",",
"funcName",
",",
"context",
",",
"(",
"a",
",",
"b",
")",
"=>",
"a",
"||",
"b",
",",... | Walks through the call graph from a defined starting function, true if nodeCheck holds for every relevant node in the callgraph
@callGraph {callGraph} As returned by buildGlobalFuncCallGraph
@funcName {string} full qualified name of the starting function
@context {Object} provides additional context information that ca... | [
"Walks",
"through",
"the",
"call",
"graph",
"from",
"a",
"defined",
"starting",
"function",
"true",
"if",
"nodeCheck",
"holds",
"for",
"every",
"relevant",
"node",
"in",
"the",
"callgraph"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-analyzer/src/solidity-analyzer/modules/functionCallGraph.js#L64-L66 | train |
ethereum/remix | remix-lib/src/execution/txExecution.js | function (from, data, value, gasLimit, txRunner, callbacks, finalCallback) {
if (!callbacks.confirmationCb || !callbacks.gasEstimationForceSend || !callbacks.promptCb) {
return finalCallback('all the callbacks must have been defined')
}
var tx = { from: from, to: null, data: data, useCall: false, valu... | javascript | function (from, data, value, gasLimit, txRunner, callbacks, finalCallback) {
if (!callbacks.confirmationCb || !callbacks.gasEstimationForceSend || !callbacks.promptCb) {
return finalCallback('all the callbacks must have been defined')
}
var tx = { from: from, to: null, data: data, useCall: false, valu... | [
"function",
"(",
"from",
",",
"data",
",",
"value",
",",
"gasLimit",
",",
"txRunner",
",",
"callbacks",
",",
"finalCallback",
")",
"{",
"if",
"(",
"!",
"callbacks",
".",
"confirmationCb",
"||",
"!",
"callbacks",
".",
"gasEstimationForceSend",
"||",
"!",
"c... | deploy the given contract
@param {String} from - sender address
@param {String} data - data to send with the transaction ( return of txFormat.buildData(...) ).
@param {String} value - decimal representation of value.
@param {String} gasLimit - decimal representation of gas limit.
@param {Object} txRunner ... | [
"deploy",
"the",
"given",
"contract"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/execution/txExecution.js#L19-L28 | train | |
ethereum/remix | remix-lib/src/execution/txExecution.js | function (txResult) {
var errorCode = {
OUT_OF_GAS: 'out of gas',
STACK_UNDERFLOW: 'stack underflow',
STACK_OVERFLOW: 'stack overflow',
INVALID_JUMP: 'invalid JUMP',
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
STATIC_STATE_CHANGE: 'static state change'
}
var... | javascript | function (txResult) {
var errorCode = {
OUT_OF_GAS: 'out of gas',
STACK_UNDERFLOW: 'stack underflow',
STACK_OVERFLOW: 'stack overflow',
INVALID_JUMP: 'invalid JUMP',
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
STATIC_STATE_CHANGE: 'static state change'
}
var... | [
"function",
"(",
"txResult",
")",
"{",
"var",
"errorCode",
"=",
"{",
"OUT_OF_GAS",
":",
"'out of gas'",
",",
"STACK_UNDERFLOW",
":",
"'stack underflow'",
",",
"STACK_OVERFLOW",
":",
"'stack overflow'",
",",
"INVALID_JUMP",
":",
"'invalid JUMP'",
",",
"INVALID_OPCODE... | check if the vm has errored
@param {Object} txResult - the value returned by the vm
@return {Object} - { error: true/false, message: DOMNode } | [
"check",
"if",
"the",
"vm",
"has",
"errored"
] | 09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e | https://github.com/ethereum/remix/blob/09acd177d52d3b6d1c4ef04f4d9bdbad6e526a6e/remix-lib/src/execution/txExecution.js#L59-L102 | train | |
livoras/simple-virtual-dom | lib/element.js | Element | function Element (tagName, props, children) {
if (!(this instanceof Element)) {
if (!_.isArray(children) && children != null) {
children = _.slice(arguments, 2).filter(_.truthy)
}
return new Element(tagName, props, children)
}
if (_.isArray(props)) {
children = props
props = {... | javascript | function Element (tagName, props, children) {
if (!(this instanceof Element)) {
if (!_.isArray(children) && children != null) {
children = _.slice(arguments, 2).filter(_.truthy)
}
return new Element(tagName, props, children)
}
if (_.isArray(props)) {
children = props
props = {... | [
"function",
"Element",
"(",
"tagName",
",",
"props",
",",
"children",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Element",
")",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"children",
")",
"&&",
"children",
"!=",
"null",
")",
"{"... | Virtual-dom Element.
@param {String} tagName
@param {Object} props - Element's properties,
- using object to store key-value pair
@param {Array<Element|String>} - This element's children elements.
- Can be Element instance or just a piece plain text. | [
"Virtual",
"-",
"dom",
"Element",
"."
] | 92856ae49bdb35d6c3aea7b3367eec47abb70f22 | https://github.com/livoras/simple-virtual-dom/blob/92856ae49bdb35d6c3aea7b3367eec47abb70f22/lib/element.js#L11-L43 | train |
segmentio/analytics.js | analytics.js | Facade | function Facade (obj) {
obj = clone(obj);
if (!obj.hasOwnProperty('timestamp')) obj.timestamp = new Date();
else obj.timestamp = newDate(obj.timestamp);
traverse(obj);
this.obj = obj;
} | javascript | function Facade (obj) {
obj = clone(obj);
if (!obj.hasOwnProperty('timestamp')) obj.timestamp = new Date();
else obj.timestamp = newDate(obj.timestamp);
traverse(obj);
this.obj = obj;
} | [
"function",
"Facade",
"(",
"obj",
")",
"{",
"obj",
"=",
"clone",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"obj",
".",
"hasOwnProperty",
"(",
"'timestamp'",
")",
")",
"obj",
".",
"timestamp",
"=",
"new",
"Date",
"(",
")",
";",
"else",
"obj",
".",
"ti... | Initialize a new `Facade` with an `obj` of arguments.
@param {Object} obj | [
"Initialize",
"a",
"new",
"Facade",
"with",
"an",
"obj",
"of",
"arguments",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1053-L1059 | train |
segmentio/analytics.js | analytics.js | traverse | function traverse (input, strict) {
if (strict === undefined) strict = true;
if (is.object(input)) return object(input, strict);
if (is.array(input)) return array(input, strict);
return input;
} | javascript | function traverse (input, strict) {
if (strict === undefined) strict = true;
if (is.object(input)) return object(input, strict);
if (is.array(input)) return array(input, strict);
return input;
} | [
"function",
"traverse",
"(",
"input",
",",
"strict",
")",
"{",
"if",
"(",
"strict",
"===",
"undefined",
")",
"strict",
"=",
"true",
";",
"if",
"(",
"is",
".",
"object",
"(",
"input",
")",
")",
"return",
"object",
"(",
"input",
",",
"strict",
")",
"... | Traverse an object or array, and return a clone with all ISO strings parsed
into Date objects.
@param {Object} obj
@return {Object} | [
"Traverse",
"an",
"object",
"or",
"array",
"and",
"return",
"a",
"clone",
"with",
"all",
"ISO",
"strings",
"parsed",
"into",
"Date",
"objects",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1369-L1375 | train |
segmentio/analytics.js | analytics.js | object | function object (obj, strict) {
each(obj, function (key, val) {
if (isodate.is(val, strict)) {
obj[key] = isodate.parse(val);
} else if (is.object(val) || is.array(val)) {
traverse(val, strict);
}
});
return obj;
} | javascript | function object (obj, strict) {
each(obj, function (key, val) {
if (isodate.is(val, strict)) {
obj[key] = isodate.parse(val);
} else if (is.object(val) || is.array(val)) {
traverse(val, strict);
}
});
return obj;
} | [
"function",
"object",
"(",
"obj",
",",
"strict",
")",
"{",
"each",
"(",
"obj",
",",
"function",
"(",
"key",
",",
"val",
")",
"{",
"if",
"(",
"isodate",
".",
"is",
"(",
"val",
",",
"strict",
")",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"isodate",... | Object traverser.
@param {Object} obj
@param {Boolean} strict
@return {Object} | [
"Object",
"traverser",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1385-L1394 | train |
segmentio/analytics.js | analytics.js | array | function array (arr, strict) {
each(arr, function (val, x) {
if (is.object(val)) {
traverse(val, strict);
} else if (isodate.is(val, strict)) {
arr[x] = isodate.parse(val);
}
});
return arr;
} | javascript | function array (arr, strict) {
each(arr, function (val, x) {
if (is.object(val)) {
traverse(val, strict);
} else if (isodate.is(val, strict)) {
arr[x] = isodate.parse(val);
}
});
return arr;
} | [
"function",
"array",
"(",
"arr",
",",
"strict",
")",
"{",
"each",
"(",
"arr",
",",
"function",
"(",
"val",
",",
"x",
")",
"{",
"if",
"(",
"is",
".",
"object",
"(",
"val",
")",
")",
"{",
"traverse",
"(",
"val",
",",
"strict",
")",
";",
"}",
"e... | Array traverser.
@param {Array} arr
@param {Boolean} strict
@return {Array} | [
"Array",
"traverser",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1404-L1413 | train |
segmentio/analytics.js | analytics.js | isEmpty | function isEmpty (val) {
if (null == val) return true;
if ('number' == typeof val) return 0 === val;
if (undefined !== val.length) return 0 === val.length;
for (var key in val) if (has.call(val, key)) return false;
return true;
} | javascript | function isEmpty (val) {
if (null == val) return true;
if ('number' == typeof val) return 0 === val;
if (undefined !== val.length) return 0 === val.length;
for (var key in val) if (has.call(val, key)) return false;
return true;
} | [
"function",
"isEmpty",
"(",
"val",
")",
"{",
"if",
"(",
"null",
"==",
"val",
")",
"return",
"true",
";",
"if",
"(",
"'number'",
"==",
"typeof",
"val",
")",
"return",
"0",
"===",
"val",
";",
"if",
"(",
"undefined",
"!==",
"val",
".",
"length",
")",
... | Test whether a value is "empty".
@param {Mixed} val
@return {Boolean} | [
"Test",
"whether",
"a",
"value",
"is",
"empty",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1516-L1522 | train |
segmentio/analytics.js | analytics.js | object | function object(obj, fn) {
for (var key in obj) {
if (has.call(obj, key)) {
fn(key, obj[key]);
}
}
} | javascript | function object(obj, fn) {
for (var key in obj) {
if (has.call(obj, key)) {
fn(key, obj[key]);
}
}
} | [
"function",
"object",
"(",
"obj",
",",
"fn",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"has",
".",
"call",
"(",
"obj",
",",
"key",
")",
")",
"{",
"fn",
"(",
"key",
",",
"obj",
"[",
"key",
"]",
")",
";",
"}",
"}... | Iterate object keys.
@param {Object} obj
@param {Function} fn
@api private | [
"Iterate",
"object",
"keys",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1689-L1695 | train |
segmentio/analytics.js | analytics.js | multiple | function multiple (fn) {
return function (obj, path, val, options) {
var normalize = options && isFunction(options.normalizer) ? options.normalizer : defaultNormalize;
path = normalize(path);
var key;
var finished = false;
while (!finished) loop();
function loop() {
for (key in obj) {... | javascript | function multiple (fn) {
return function (obj, path, val, options) {
var normalize = options && isFunction(options.normalizer) ? options.normalizer : defaultNormalize;
path = normalize(path);
var key;
var finished = false;
while (!finished) loop();
function loop() {
for (key in obj) {... | [
"function",
"multiple",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
"obj",
",",
"path",
",",
"val",
",",
"options",
")",
"{",
"var",
"normalize",
"=",
"options",
"&&",
"isFunction",
"(",
"options",
".",
"normalizer",
")",
"?",
"options",
".",
"norm... | Compose applying the function to a nested key | [
"Compose",
"applying",
"the",
"function",
"to",
"a",
"nested",
"key"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1895-L1951 | train |
segmentio/analytics.js | analytics.js | replace | function replace (obj, key, val) {
if (obj.hasOwnProperty(key)) obj[key] = val;
return obj;
} | javascript | function replace (obj, key, val) {
if (obj.hasOwnProperty(key)) obj[key] = val;
return obj;
} | [
"function",
"replace",
"(",
"obj",
",",
"key",
",",
"val",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"obj",
"[",
"key",
"]",
"=",
"val",
";",
"return",
"obj",
";",
"}"
] | Replace an objects existing value with a new one
replace({ a : 'b' }, 'a', 'c') -> { a : 'c' } | [
"Replace",
"an",
"objects",
"existing",
"value",
"with",
"a",
"new",
"one"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L1983-L1986 | train |
segmentio/analytics.js | analytics.js | currency | function currency(val) {
if (!val) return;
if (typeof val === 'number') return val;
if (typeof val !== 'string') return;
val = val.replace(/\$/g, '');
val = parseFloat(val);
if (!isNaN(val)) return val;
} | javascript | function currency(val) {
if (!val) return;
if (typeof val === 'number') return val;
if (typeof val !== 'string') return;
val = val.replace(/\$/g, '');
val = parseFloat(val);
if (!isNaN(val)) return val;
} | [
"function",
"currency",
"(",
"val",
")",
"{",
"if",
"(",
"!",
"val",
")",
"return",
";",
"if",
"(",
"typeof",
"val",
"===",
"'number'",
")",
"return",
"val",
";",
"if",
"(",
"typeof",
"val",
"!==",
"'string'",
")",
"return",
";",
"val",
"=",
"val",... | Get float from currency value.
@param {Mixed} val
@return {Number} | [
"Get",
"float",
"from",
"currency",
"value",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L2971-L2980 | train |
segmentio/analytics.js | analytics.js | bindMethods | function bindMethods (obj, methods) {
methods = [].slice.call(arguments, 1);
for (var i = 0, method; method = methods[i]; i++) {
obj[method] = bind(obj, obj[method]);
}
return obj;
} | javascript | function bindMethods (obj, methods) {
methods = [].slice.call(arguments, 1);
for (var i = 0, method; method = methods[i]; i++) {
obj[method] = bind(obj, obj[method]);
}
return obj;
} | [
"function",
"bindMethods",
"(",
"obj",
",",
"methods",
")",
"{",
"methods",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"method",
";",
"method",
"=",
"methods",
"[",
"i",
... | Bind `methods` on `obj` to always be called with the `obj` as context.
@param {Object} obj
@param {String} methods... | [
"Bind",
"methods",
"on",
"obj",
"to",
"always",
"be",
"called",
"with",
"the",
"obj",
"as",
"context",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L3239-L3245 | train |
segmentio/analytics.js | analytics.js | set | function set(name, value, options) {
options = options || {};
var str = encode(name) + '=' + encode(value);
if (null == value) options.maxage = -1;
if (options.maxage) {
options.expires = new Date(+new Date + options.maxage);
}
if (options.path) str += '; path=' + options.path;
if (options.domain) ... | javascript | function set(name, value, options) {
options = options || {};
var str = encode(name) + '=' + encode(value);
if (null == value) options.maxage = -1;
if (options.maxage) {
options.expires = new Date(+new Date + options.maxage);
}
if (options.path) str += '; path=' + options.path;
if (options.domain) ... | [
"function",
"set",
"(",
"name",
",",
"value",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"str",
"=",
"encode",
"(",
"name",
")",
"+",
"'='",
"+",
"encode",
"(",
"value",
")",
";",
"if",
"(",
"null",
"==",
"... | Set cookie `name` to `value`.
@param {String} name
@param {String} value
@param {Object} options
@api private | [
"Set",
"cookie",
"name",
"to",
"value",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L3607-L3623 | train |
segmentio/analytics.js | analytics.js | parse | function parse(str) {
var obj = {};
var pairs = str.split(/ *; */);
var pair;
if ('' == pairs[0]) return obj;
for (var i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
obj[decode(pair[0])] = decode(pair[1]);
}
return obj;
} | javascript | function parse(str) {
var obj = {};
var pairs = str.split(/ *; */);
var pair;
if ('' == pairs[0]) return obj;
for (var i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
obj[decode(pair[0])] = decode(pair[1]);
}
return obj;
} | [
"function",
"parse",
"(",
"str",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"var",
"pairs",
"=",
"str",
".",
"split",
"(",
"/",
" *; *",
"/",
")",
";",
"var",
"pair",
";",
"if",
"(",
"''",
"==",
"pairs",
"[",
"0",
"]",
")",
"return",
"obj",
... | Parse cookie `str`.
@param {String} str
@return {Object}
@api private | [
"Parse",
"cookie",
"str",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L3656-L3666 | train |
segmentio/analytics.js | analytics.js | function (dest, src, recursive) {
for (var prop in src) {
if (recursive && dest[prop] instanceof Object && src[prop] instanceof Object) {
dest[prop] = defaults(dest[prop], src[prop], true);
} else if (! (prop in dest)) {
dest[prop] = src[prop];
}
}
return dest;
} | javascript | function (dest, src, recursive) {
for (var prop in src) {
if (recursive && dest[prop] instanceof Object && src[prop] instanceof Object) {
dest[prop] = defaults(dest[prop], src[prop], true);
} else if (! (prop in dest)) {
dest[prop] = src[prop];
}
}
return dest;
} | [
"function",
"(",
"dest",
",",
"src",
",",
"recursive",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"src",
")",
"{",
"if",
"(",
"recursive",
"&&",
"dest",
"[",
"prop",
"]",
"instanceof",
"Object",
"&&",
"src",
"[",
"prop",
"]",
"instanceof",
"Object",
... | Merge default values.
@param {Object} dest
@param {Object} defaults
@return {Object}
@api public | [
"Merge",
"default",
"values",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L4002-L4012 | train | |
segmentio/analytics.js | analytics.js | all | function all() {
var str;
try {
str = document.cookie;
} catch (err) {
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(err.stack || err);
}
return {};
}
return parse(str);
} | javascript | function all() {
var str;
try {
str = document.cookie;
} catch (err) {
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(err.stack || err);
}
return {};
}
return parse(str);
} | [
"function",
"all",
"(",
")",
"{",
"var",
"str",
";",
"try",
"{",
"str",
"=",
"document",
".",
"cookie",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"typeof",
"console",
"!==",
"'undefined'",
"&&",
"typeof",
"console",
".",
"error",
"===",
"... | Return all cookies.
@return {Object}
@api private | [
"Return",
"all",
"cookies",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L4775-L4786 | train |
segmentio/analytics.js | analytics.js | Group | function Group(options) {
this.defaults = Group.defaults;
this.debug = debug;
Entity.call(this, options);
} | javascript | function Group(options) {
this.defaults = Group.defaults;
this.debug = debug;
Entity.call(this, options);
} | [
"function",
"Group",
"(",
"options",
")",
"{",
"this",
".",
"defaults",
"=",
"Group",
".",
"defaults",
";",
"this",
".",
"debug",
"=",
"debug",
";",
"Entity",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"}"
] | Initialize a new `Group` with `options`.
@param {Object} options | [
"Initialize",
"a",
"new",
"Group",
"with",
"options",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L4877-L4881 | train |
segmentio/analytics.js | analytics.js | includes | function includes(searchElement, collection) {
var found = false;
// Delegate to String.prototype.indexOf when `collection` is a string
if (typeof collection === 'string') {
return strIndexOf.call(collection, searchElement) !== -1;
}
// Iterate through enumerable/own array elements and object properties... | javascript | function includes(searchElement, collection) {
var found = false;
// Delegate to String.prototype.indexOf when `collection` is a string
if (typeof collection === 'string') {
return strIndexOf.call(collection, searchElement) !== -1;
}
// Iterate through enumerable/own array elements and object properties... | [
"function",
"includes",
"(",
"searchElement",
",",
"collection",
")",
"{",
"var",
"found",
"=",
"false",
";",
"// Delegate to String.prototype.indexOf when `collection` is a string",
"if",
"(",
"typeof",
"collection",
"===",
"'string'",
")",
"{",
"return",
"strIndexOf",... | Searches a given `collection` for a value, returning true if the collection
contains the value and false otherwise. Can search strings, arrays, and
objects.
@name includes
@api public
@param {*} searchElement The element to search for.
@param {Object|Array|string} collection The collection to search.
@return {boolean}... | [
"Searches",
"a",
"given",
"collection",
"for",
"a",
"value",
"returning",
"true",
"if",
"the",
"collection",
"contains",
"the",
"value",
"and",
"false",
"otherwise",
".",
"Can",
"search",
"strings",
"arrays",
"and",
"objects",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L5817-L5835 | train |
segmentio/analytics.js | analytics.js | isArrayLike | function isArrayLike(val) {
return val != null && (isArray(val) || (val !== 'function' && isNumber(val.length)));
} | javascript | function isArrayLike(val) {
return val != null && (isArray(val) || (val !== 'function' && isNumber(val.length)));
} | [
"function",
"isArrayLike",
"(",
"val",
")",
"{",
"return",
"val",
"!=",
"null",
"&&",
"(",
"isArray",
"(",
"val",
")",
"||",
"(",
"val",
"!==",
"'function'",
"&&",
"isNumber",
"(",
"val",
".",
"length",
")",
")",
")",
";",
"}"
] | Tests if a value is array-like. Array-like means the value is not a function and has a numeric
`.length` property.
@name isArrayLike
@api private
@param {*} val
@return {boolean}
TODO: Move to library | [
"Tests",
"if",
"a",
"value",
"is",
"array",
"-",
"like",
".",
"Array",
"-",
"like",
"means",
"the",
"value",
"is",
"not",
"a",
"function",
"and",
"has",
"a",
"numeric",
".",
"length",
"property",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L5900-L5902 | train |
segmentio/analytics.js | analytics.js | arrayEach | function arrayEach(iterator, array) {
for (var i = 0; i < array.length; i += 1) {
// Break iteration early if `iterator` returns `false`
if (iterator(array[i], i, array) === false) {
break;
}
}
} | javascript | function arrayEach(iterator, array) {
for (var i = 0; i < array.length; i += 1) {
// Break iteration early if `iterator` returns `false`
if (iterator(array[i], i, array) === false) {
break;
}
}
} | [
"function",
"arrayEach",
"(",
"iterator",
",",
"array",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"// Break iteration early if `iterator` returns `false`",
"if",
"(",
"iterator",
"(",
... | Internal implementation of `each`. Works on arrays and array-like data structures.
@name arrayEach
@api private
@param {Function(value, key, collection)} iterator The function to invoke per iteration.
@param {Array} array The array(-like) structure to iterate over.
@return {undefined} | [
"Internal",
"implementation",
"of",
"each",
".",
"Works",
"on",
"arrays",
"and",
"array",
"-",
"like",
"data",
"structures",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L5914-L5921 | train |
segmentio/analytics.js | analytics.js | baseEach | function baseEach(iterator, object) {
var ks = keys(object);
for (var i = 0; i < ks.length; i += 1) {
// Break iteration early if `iterator` returns `false`
if (iterator(object[ks[i]], ks[i], object) === false) {
break;
}
}
} | javascript | function baseEach(iterator, object) {
var ks = keys(object);
for (var i = 0; i < ks.length; i += 1) {
// Break iteration early if `iterator` returns `false`
if (iterator(object[ks[i]], ks[i], object) === false) {
break;
}
}
} | [
"function",
"baseEach",
"(",
"iterator",
",",
"object",
")",
"{",
"var",
"ks",
"=",
"keys",
"(",
"object",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ks",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"// Break iteration early if `... | Internal implementation of `each`. Works on objects.
@name baseEach
@api private
@param {Function(value, key, collection)} iterator The function to invoke per iteration.
@param {Object} object The object to iterate over.
@return {undefined} | [
"Internal",
"implementation",
"of",
"each",
".",
"Works",
"on",
"objects",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L5933-L5942 | train |
segmentio/analytics.js | analytics.js | objectKeys | function objectKeys(target, pred) {
pred = pred || has;
var results = [];
for (var key in target) {
if (pred(target, key)) {
results.push(String(key));
}
}
return results;
} | javascript | function objectKeys(target, pred) {
pred = pred || has;
var results = [];
for (var key in target) {
if (pred(target, key)) {
results.push(String(key));
}
}
return results;
} | [
"function",
"objectKeys",
"(",
"target",
",",
"pred",
")",
"{",
"pred",
"=",
"pred",
"||",
"has",
";",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"target",
")",
"{",
"if",
"(",
"pred",
"(",
"target",
",",
"key",
")",
... | Returns an array of all the owned
@name objectKeys
@api private
@param {*} target
@param {Function} pred Predicate function used to include/exclude values from
the resulting array.
@return {Array} | [
"Returns",
"an",
"array",
"of",
"all",
"the",
"owned"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6101-L6113 | train |
segmentio/analytics.js | analytics.js | toFunction | function toFunction(obj) {
switch ({}.toString.call(obj)) {
case '[object Object]':
return objectToFunction(obj);
case '[object Function]':
return obj;
case '[object String]':
return stringToFunction(obj);
case '[object RegExp]':
return regexpToFunction(obj);
default:
... | javascript | function toFunction(obj) {
switch ({}.toString.call(obj)) {
case '[object Object]':
return objectToFunction(obj);
case '[object Function]':
return obj;
case '[object String]':
return stringToFunction(obj);
case '[object RegExp]':
return regexpToFunction(obj);
default:
... | [
"function",
"toFunction",
"(",
"obj",
")",
"{",
"switch",
"(",
"{",
"}",
".",
"toString",
".",
"call",
"(",
"obj",
")",
")",
"{",
"case",
"'[object Object]'",
":",
"return",
"objectToFunction",
"(",
"obj",
")",
";",
"case",
"'[object Function]'",
":",
"r... | Convert `obj` to a `Function`.
@param {Mixed} obj
@return {Function}
@api private | [
"Convert",
"obj",
"to",
"a",
"Function",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6220-L6233 | train |
segmentio/analytics.js | analytics.js | objectToFunction | function objectToFunction(obj) {
var match = {};
for (var key in obj) {
match[key] = typeof obj[key] === 'string'
? defaultToFunction(obj[key])
: toFunction(obj[key]);
}
return function(val){
if (typeof val !== 'object') return false;
for (var key in match) {
if (!(key in val)) ret... | javascript | function objectToFunction(obj) {
var match = {};
for (var key in obj) {
match[key] = typeof obj[key] === 'string'
? defaultToFunction(obj[key])
: toFunction(obj[key]);
}
return function(val){
if (typeof val !== 'object') return false;
for (var key in match) {
if (!(key in val)) ret... | [
"function",
"objectToFunction",
"(",
"obj",
")",
"{",
"var",
"match",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"match",
"[",
"key",
"]",
"=",
"typeof",
"obj",
"[",
"key",
"]",
"===",
"'string'",
"?",
"defaultToFunction",
... | Convert `object` to a function.
@param {Object} object
@return {Function}
@api private | [
"Convert",
"object",
"to",
"a",
"function",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6287-L6302 | train |
segmentio/analytics.js | analytics.js | get | function get(str) {
var props = expr(str);
if (!props.length) return '_.' + str;
var val, i, prop;
for (i = 0; i < props.length; i++) {
prop = props[i];
val = '_.' + prop;
val = "('function' == typeof " + val + " ? " + val + "() : " + val + ")";
// mimic negative lookbehind to avoid problems w... | javascript | function get(str) {
var props = expr(str);
if (!props.length) return '_.' + str;
var val, i, prop;
for (i = 0; i < props.length; i++) {
prop = props[i];
val = '_.' + prop;
val = "('function' == typeof " + val + " ? " + val + "() : " + val + ")";
// mimic negative lookbehind to avoid problems w... | [
"function",
"get",
"(",
"str",
")",
"{",
"var",
"props",
"=",
"expr",
"(",
"str",
")",
";",
"if",
"(",
"!",
"props",
".",
"length",
")",
"return",
"'_.'",
"+",
"str",
";",
"var",
"val",
",",
"i",
",",
"prop",
";",
"for",
"(",
"i",
"=",
"0",
... | Built the getter function. Supports getter style functions
@param {String} str
@return {String}
@api private | [
"Built",
"the",
"getter",
"function",
".",
"Supports",
"getter",
"style",
"functions"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6312-L6327 | train |
segmentio/analytics.js | analytics.js | map | function map(str, props, fn) {
var re = /\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;
return str.replace(re, function(_){
if ('(' == _[_.length - 1]) return fn(_);
if (!~props.indexOf(_)) return _;
return fn(_);
});
} | javascript | function map(str, props, fn) {
var re = /\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;
return str.replace(re, function(_){
if ('(' == _[_.length - 1]) return fn(_);
if (!~props.indexOf(_)) return _;
return fn(_);
});
} | [
"function",
"map",
"(",
"str",
",",
"props",
",",
"fn",
")",
"{",
"var",
"re",
"=",
"/",
"\\.\\w+|\\w+ *\\(|\"[^\"]*\"|'[^']*'|\\/([^/]+)\\/|[a-zA-Z_]\\w*",
"/",
"g",
";",
"return",
"str",
".",
"replace",
"(",
"re",
",",
"function",
"(",
"_",
")",
"{",
"if... | Return `str` with `props` mapped with `fn`.
@param {String} str
@param {Array} props
@param {Function} fn
@return {String}
@api private | [
"Return",
"str",
"with",
"props",
"mapped",
"with",
"fn",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6397-L6404 | train |
segmentio/analytics.js | analytics.js | unique | function unique(arr) {
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (~ret.indexOf(arr[i])) continue;
ret.push(arr[i]);
}
return ret;
} | javascript | function unique(arr) {
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (~ret.indexOf(arr[i])) continue;
ret.push(arr[i]);
}
return ret;
} | [
"function",
"unique",
"(",
"arr",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"~",
"ret",
".",
"indexOf",
"(",
"arr",
"[",
"i",
"]... | Return unique array.
@param {Array} arr
@return {Array}
@api private | [
"Return",
"unique",
"array",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6414-L6423 | train |
segmentio/analytics.js | analytics.js | pageDefaults | function pageDefaults() {
return {
path: canonicalPath(),
referrer: document.referrer,
search: location.search,
title: document.title,
url: canonicalUrl(location.search)
};
} | javascript | function pageDefaults() {
return {
path: canonicalPath(),
referrer: document.referrer,
search: location.search,
title: document.title,
url: canonicalUrl(location.search)
};
} | [
"function",
"pageDefaults",
"(",
")",
"{",
"return",
"{",
"path",
":",
"canonicalPath",
"(",
")",
",",
"referrer",
":",
"document",
".",
"referrer",
",",
"search",
":",
"location",
".",
"search",
",",
"title",
":",
"document",
".",
"title",
",",
"url",
... | Return a default `options.context.page` object.
https://segment.com/docs/spec/page/#properties
@return {Object} | [
"Return",
"a",
"default",
"options",
".",
"context",
".",
"page",
"object",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6497-L6505 | train |
segmentio/analytics.js | analytics.js | canonicalPath | function canonicalPath() {
var canon = canonical();
if (!canon) return window.location.pathname;
var parsed = url.parse(canon);
return parsed.pathname;
} | javascript | function canonicalPath() {
var canon = canonical();
if (!canon) return window.location.pathname;
var parsed = url.parse(canon);
return parsed.pathname;
} | [
"function",
"canonicalPath",
"(",
")",
"{",
"var",
"canon",
"=",
"canonical",
"(",
")",
";",
"if",
"(",
"!",
"canon",
")",
"return",
"window",
".",
"location",
".",
"pathname",
";",
"var",
"parsed",
"=",
"url",
".",
"parse",
"(",
"canon",
")",
";",
... | Return the canonical path for the page.
@return {string} | [
"Return",
"the",
"canonical",
"path",
"for",
"the",
"page",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6513-L6518 | train |
segmentio/analytics.js | analytics.js | canonicalUrl | function canonicalUrl(search) {
var canon = canonical();
if (canon) return includes('?', canon) ? canon : canon + search;
var url = window.location.href;
var i = url.indexOf('#');
return i === -1 ? url : url.slice(0, i);
} | javascript | function canonicalUrl(search) {
var canon = canonical();
if (canon) return includes('?', canon) ? canon : canon + search;
var url = window.location.href;
var i = url.indexOf('#');
return i === -1 ? url : url.slice(0, i);
} | [
"function",
"canonicalUrl",
"(",
"search",
")",
"{",
"var",
"canon",
"=",
"canonical",
"(",
")",
";",
"if",
"(",
"canon",
")",
"return",
"includes",
"(",
"'?'",
",",
"canon",
")",
"?",
"canon",
":",
"canon",
"+",
"search",
";",
"var",
"url",
"=",
"... | Return the canonical URL for the page concat the given `search`
and strip the hash.
@param {string} search
@return {string} | [
"Return",
"the",
"canonical",
"URL",
"for",
"the",
"page",
"concat",
"the",
"given",
"search",
"and",
"strip",
"the",
"hash",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6528-L6534 | train |
segmentio/analytics.js | analytics.js | pick | function pick(props, object) {
if (!existy(object) || !isObject(object)) {
return {};
}
if (isString(props)) {
props = [props];
}
if (!isArray(props)) {
props = [];
}
var result = {};
for (var i = 0; i < props.length; i += 1) {
if (isString(props[i]) && props[i] in object) {
re... | javascript | function pick(props, object) {
if (!existy(object) || !isObject(object)) {
return {};
}
if (isString(props)) {
props = [props];
}
if (!isArray(props)) {
props = [];
}
var result = {};
for (var i = 0; i < props.length; i += 1) {
if (isString(props[i]) && props[i] in object) {
re... | [
"function",
"pick",
"(",
"props",
",",
"object",
")",
"{",
"if",
"(",
"!",
"existy",
"(",
"object",
")",
"||",
"!",
"isObject",
"(",
"object",
")",
")",
"{",
"return",
"{",
"}",
";",
"}",
"if",
"(",
"isString",
"(",
"props",
")",
")",
"{",
"pro... | Returns a copy of the new `object` containing only the specified properties.
@name pick
@api public
@category Object
@see {@link omit}
@param {Array.<string>|string} props The property or properties to keep.
@param {Object} object The object to iterate over.
@return {Object} A new object containing only the specified ... | [
"Returns",
"a",
"copy",
"of",
"the",
"new",
"object",
"containing",
"only",
"the",
"specified",
"properties",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6681-L6703 | train |
segmentio/analytics.js | analytics.js | User | function User(options) {
this.defaults = User.defaults;
this.debug = debug;
Entity.call(this, options);
} | javascript | function User(options) {
this.defaults = User.defaults;
this.debug = debug;
Entity.call(this, options);
} | [
"function",
"User",
"(",
"options",
")",
"{",
"this",
".",
"defaults",
"=",
"User",
".",
"defaults",
";",
"this",
".",
"debug",
"=",
"debug",
";",
"Entity",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"}"
] | Initialize a new `User` with `options`.
@param {Object} options | [
"Initialize",
"a",
"new",
"User",
"with",
"options",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L6880-L6884 | train |
segmentio/analytics.js | analytics.js | render | function render(template, locals){
return foldl(function(attrs, val, key) {
attrs[key] = val.replace(/\{\{\ *(\w+)\ *\}\}/g, function(_, $1){
return locals[$1];
});
return attrs;
}, {}, template.attrs);
} | javascript | function render(template, locals){
return foldl(function(attrs, val, key) {
attrs[key] = val.replace(/\{\{\ *(\w+)\ *\}\}/g, function(_, $1){
return locals[$1];
});
return attrs;
}, {}, template.attrs);
} | [
"function",
"render",
"(",
"template",
",",
"locals",
")",
"{",
"return",
"foldl",
"(",
"function",
"(",
"attrs",
",",
"val",
",",
"key",
")",
"{",
"attrs",
"[",
"key",
"]",
"=",
"val",
".",
"replace",
"(",
"/",
"\\{\\{\\ *(\\w+)\\ *\\}\\}",
"/",
"g",
... | Render template + locals into an `attrs` object.
@api private
@param {Object} template
@param {Object} locals
@return {Object} | [
"Render",
"template",
"+",
"locals",
"into",
"an",
"attrs",
"object",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8139-L8146 | train |
segmentio/analytics.js | analytics.js | fmt | function fmt(str){
var args = [].slice.call(arguments, 1);
var j = 0;
return str.replace(/%([a-z])/gi, function(_, f){
return fmt[f]
? fmt[f](args[j++])
: _ + f;
});
} | javascript | function fmt(str){
var args = [].slice.call(arguments, 1);
var j = 0;
return str.replace(/%([a-z])/gi, function(_, f){
return fmt[f]
? fmt[f](args[j++])
: _ + f;
});
} | [
"function",
"fmt",
"(",
"str",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"j",
"=",
"0",
";",
"return",
"str",
".",
"replace",
"(",
"/",
"%([a-z])",
"/",
"gi",
",",
"function"... | Format the given `str`.
@param {String} str
@param {...} args
@return {String}
@api public | [
"Format",
"the",
"given",
"str",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8329-L8338 | train |
segmentio/analytics.js | analytics.js | attach | function attach(el, fn){
el.attachEvent('onreadystatechange', function(e){
if (!/complete|loaded/.test(el.readyState)) return;
fn(null, e);
});
el.attachEvent('onerror', function(e){
var err = new Error('failed to load the script "' + el.src + '"');
err.event = e || window.event;
fn(err);
})... | javascript | function attach(el, fn){
el.attachEvent('onreadystatechange', function(e){
if (!/complete|loaded/.test(el.readyState)) return;
fn(null, e);
});
el.attachEvent('onerror', function(e){
var err = new Error('failed to load the script "' + el.src + '"');
err.event = e || window.event;
fn(err);
})... | [
"function",
"attach",
"(",
"el",
",",
"fn",
")",
"{",
"el",
".",
"attachEvent",
"(",
"'onreadystatechange'",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"/",
"complete|loaded",
"/",
".",
"test",
"(",
"el",
".",
"readyState",
")",
")",
"retur... | Attach event.
@param {Element} el
@param {Function} fn
@api private | [
"Attach",
"event",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8506-L8516 | train |
segmentio/analytics.js | analytics.js | uncamelize | function uncamelize (string) {
return string.replace(camelSplitter, function (m, previous, uppers) {
return previous + ' ' + uppers.toLowerCase().split('').join(' ');
});
} | javascript | function uncamelize (string) {
return string.replace(camelSplitter, function (m, previous, uppers) {
return previous + ' ' + uppers.toLowerCase().split('').join(' ');
});
} | [
"function",
"uncamelize",
"(",
"string",
")",
"{",
"return",
"string",
".",
"replace",
"(",
"camelSplitter",
",",
"function",
"(",
"m",
",",
"previous",
",",
"uppers",
")",
"{",
"return",
"previous",
"+",
"' '",
"+",
"uppers",
".",
"toLowerCase",
"(",
")... | Un-camelcase a `string`.
@param {String} string
@return {String} | [
"Un",
"-",
"camelcase",
"a",
"string",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8648-L8652 | train |
segmentio/analytics.js | analytics.js | objectify | function objectify(str) {
// replace `src` with `data-src` to prevent image loading
str = str.replace(' src="', ' data-src="');
var el = domify(str);
var attrs = {};
each(el.attributes, function(attr){
// then replace it back
var name = attr.name === 'data-src' ? 'src' : attr.name;
if (!includes... | javascript | function objectify(str) {
// replace `src` with `data-src` to prevent image loading
str = str.replace(' src="', ' data-src="');
var el = domify(str);
var attrs = {};
each(el.attributes, function(attr){
// then replace it back
var name = attr.name === 'data-src' ? 'src' : attr.name;
if (!includes... | [
"function",
"objectify",
"(",
"str",
")",
"{",
"// replace `src` with `data-src` to prevent image loading",
"str",
"=",
"str",
".",
"replace",
"(",
"' src=\"'",
",",
"' data-src=\"'",
")",
";",
"var",
"el",
"=",
"domify",
"(",
"str",
")",
";",
"var",
"attrs",
... | Given a string, give back DOM attributes.
Do it in a way where the browser doesn't load images or iframes. It turns
out domify will load images/iframes because whenever you construct those
DOM elements, the browser immediately loads them.
@api private
@param {string} str
@return {Object} | [
"Given",
"a",
"string",
"give",
"back",
"DOM",
"attributes",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8798-L8816 | train |
segmentio/analytics.js | analytics.js | toSpaceCase | function toSpaceCase (string) {
return clean(string).replace(/[\W_]+(.|$)/g, function (matches, match) {
return match ? ' ' + match : '';
});
} | javascript | function toSpaceCase (string) {
return clean(string).replace(/[\W_]+(.|$)/g, function (matches, match) {
return match ? ' ' + match : '';
});
} | [
"function",
"toSpaceCase",
"(",
"string",
")",
"{",
"return",
"clean",
"(",
"string",
")",
".",
"replace",
"(",
"/",
"[\\W_]+(.|$)",
"/",
"g",
",",
"function",
"(",
"matches",
",",
"match",
")",
"{",
"return",
"match",
"?",
"' '",
"+",
"match",
":",
... | Convert a `string` to space case.
@param {String} string
@return {String} | [
"Convert",
"a",
"string",
"to",
"space",
"case",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L8974-L8978 | train |
segmentio/analytics.js | analytics.js | toIsoString | function toIsoString (date) {
return date.getUTCFullYear()
+ '-' + pad(date.getUTCMonth() + 1)
+ '-' + pad(date.getUTCDate())
+ 'T' + pad(date.getUTCHours())
+ ':' + pad(date.getUTCMinutes())
+ ':' + pad(date.getUTCSeconds())
+ '.' + String((date.getUTCMilliseconds()/1000).toFixed(3)).slice(2,... | javascript | function toIsoString (date) {
return date.getUTCFullYear()
+ '-' + pad(date.getUTCMonth() + 1)
+ '-' + pad(date.getUTCDate())
+ 'T' + pad(date.getUTCHours())
+ ':' + pad(date.getUTCMinutes())
+ ':' + pad(date.getUTCSeconds())
+ '.' + String((date.getUTCMilliseconds()/1000).toFixed(3)).slice(2,... | [
"function",
"toIsoString",
"(",
"date",
")",
"{",
"return",
"date",
".",
"getUTCFullYear",
"(",
")",
"+",
"'-'",
"+",
"pad",
"(",
"date",
".",
"getUTCMonth",
"(",
")",
"+",
"1",
")",
"+",
"'-'",
"+",
"pad",
"(",
"date",
".",
"getUTCDate",
"(",
")",... | Turn a `date` into an ISO string.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
@param {Date} date
@return {String} | [
"Turn",
"a",
"date",
"into",
"an",
"ISO",
"string",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11107-L11116 | train |
segmentio/analytics.js | analytics.js | alias | function alias (obj, method) {
switch (type(method)) {
case 'object': return aliasByDictionary(clone(obj), method);
case 'function': return aliasByFunction(clone(obj), method);
}
} | javascript | function alias (obj, method) {
switch (type(method)) {
case 'object': return aliasByDictionary(clone(obj), method);
case 'function': return aliasByFunction(clone(obj), method);
}
} | [
"function",
"alias",
"(",
"obj",
",",
"method",
")",
"{",
"switch",
"(",
"type",
"(",
"method",
")",
")",
"{",
"case",
"'object'",
":",
"return",
"aliasByDictionary",
"(",
"clone",
"(",
"obj",
")",
",",
"method",
")",
";",
"case",
"'function'",
":",
... | Alias an `object`.
@param {Object} obj
@param {Mixed} method | [
"Alias",
"an",
"object",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11362-L11367 | train |
segmentio/analytics.js | analytics.js | aliasByDictionary | function aliasByDictionary (obj, aliases) {
for (var key in aliases) {
if (undefined === obj[key]) continue;
obj[aliases[key]] = obj[key];
delete obj[key];
}
return obj;
} | javascript | function aliasByDictionary (obj, aliases) {
for (var key in aliases) {
if (undefined === obj[key]) continue;
obj[aliases[key]] = obj[key];
delete obj[key];
}
return obj;
} | [
"function",
"aliasByDictionary",
"(",
"obj",
",",
"aliases",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"aliases",
")",
"{",
"if",
"(",
"undefined",
"===",
"obj",
"[",
"key",
"]",
")",
"continue",
";",
"obj",
"[",
"aliases",
"[",
"key",
"]",
"]",
"=... | Convert the keys in an `obj` using a dictionary of `aliases`.
@param {Object} obj
@param {Object} aliases | [
"Convert",
"the",
"keys",
"in",
"an",
"obj",
"using",
"a",
"dictionary",
"of",
"aliases",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11377-L11384 | train |
segmentio/analytics.js | analytics.js | aliasByFunction | function aliasByFunction (obj, convert) {
// have to create another object so that ie8 won't infinite loop on keys
var output = {};
for (var key in obj) output[convert(key)] = obj[key];
return output;
} | javascript | function aliasByFunction (obj, convert) {
// have to create another object so that ie8 won't infinite loop on keys
var output = {};
for (var key in obj) output[convert(key)] = obj[key];
return output;
} | [
"function",
"aliasByFunction",
"(",
"obj",
",",
"convert",
")",
"{",
"// have to create another object so that ie8 won't infinite loop on keys",
"var",
"output",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"output",
"[",
"convert",
"(",
"key",
... | Convert the keys in an `obj` using a `convert` function.
@param {Object} obj
@param {Function} convert | [
"Convert",
"the",
"keys",
"in",
"an",
"obj",
"using",
"a",
"convert",
"function",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11394-L11399 | train |
segmentio/analytics.js | analytics.js | convertDates | function convertDates (obj, convert) {
obj = clone(obj);
for (var key in obj) {
var val = obj[key];
if (is.date(val)) obj[key] = convert(val);
if (is.object(val)) obj[key] = convertDates(val, convert);
}
return obj;
} | javascript | function convertDates (obj, convert) {
obj = clone(obj);
for (var key in obj) {
var val = obj[key];
if (is.date(val)) obj[key] = convert(val);
if (is.object(val)) obj[key] = convertDates(val, convert);
}
return obj;
} | [
"function",
"convertDates",
"(",
"obj",
",",
"convert",
")",
"{",
"obj",
"=",
"clone",
"(",
"obj",
")",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"var",
"val",
"=",
"obj",
"[",
"key",
"]",
";",
"if",
"(",
"is",
".",
"date",
"(",
"... | Recursively convert an `obj`'s dates to new values.
@param {Object} obj
@param {Function} convert
@return {Object} | [
"Recursively",
"convert",
"an",
"obj",
"s",
"dates",
"to",
"new",
"values",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11427-L11435 | train |
segmentio/analytics.js | analytics.js | handler | function handler () {
for (var i = 0, fn; fn = callbacks[i]; i++) fn.apply(this, arguments);
} | javascript | function handler () {
for (var i = 0, fn; fn = callbacks[i]; i++) fn.apply(this, arguments);
} | [
"function",
"handler",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"fn",
";",
"fn",
"=",
"callbacks",
"[",
"i",
"]",
";",
"i",
"++",
")",
"fn",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}"
] | Error handler. | [
"Error",
"handler",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11669-L11671 | train |
segmentio/analytics.js | analytics.js | onError | function onError (fn) {
callbacks.push(fn);
if (window.onerror != handler) {
callbacks.push(window.onerror);
window.onerror = handler;
}
} | javascript | function onError (fn) {
callbacks.push(fn);
if (window.onerror != handler) {
callbacks.push(window.onerror);
window.onerror = handler;
}
} | [
"function",
"onError",
"(",
"fn",
")",
"{",
"callbacks",
".",
"push",
"(",
"fn",
")",
";",
"if",
"(",
"window",
".",
"onerror",
"!=",
"handler",
")",
"{",
"callbacks",
".",
"push",
"(",
"window",
".",
"onerror",
")",
";",
"window",
".",
"onerror",
... | Call a `fn` on `window.onerror`.
@param {Function} fn | [
"Call",
"a",
"fn",
"on",
"window",
".",
"onerror",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L11680-L11686 | train |
segmentio/analytics.js | analytics.js | ecommerce | function ecommerce(event, track, arr) {
push.apply(null, [
'_fxm.ecommerce.' + event,
track.id() || track.sku(),
track.name(),
track.category()
].concat(arr || []));
} | javascript | function ecommerce(event, track, arr) {
push.apply(null, [
'_fxm.ecommerce.' + event,
track.id() || track.sku(),
track.name(),
track.category()
].concat(arr || []));
} | [
"function",
"ecommerce",
"(",
"event",
",",
"track",
",",
"arr",
")",
"{",
"push",
".",
"apply",
"(",
"null",
",",
"[",
"'_fxm.ecommerce.'",
"+",
"event",
",",
"track",
".",
"id",
"(",
")",
"||",
"track",
".",
"sku",
"(",
")",
",",
"track",
".",
... | Track ecommerce `event` with `track`
with optional `arr` to append.
@api private
@param {string} event
@param {Track} track
@param {Array} arr | [
"Track",
"ecommerce",
"event",
"with",
"track",
"with",
"optional",
"arr",
"to",
"append",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12364-L12371 | train |
segmentio/analytics.js | analytics.js | clean | function clean(obj) {
var ret = {};
// Remove traits/properties that are already represented
// outside of the data container
// TODO: Refactor into `omit` call
var excludeKeys = ['id', 'name', 'firstName', 'lastName'];
each(excludeKeys, function(omitKey) {
clear(obj, omitKey);
});
// Flatten nest... | javascript | function clean(obj) {
var ret = {};
// Remove traits/properties that are already represented
// outside of the data container
// TODO: Refactor into `omit` call
var excludeKeys = ['id', 'name', 'firstName', 'lastName'];
each(excludeKeys, function(omitKey) {
clear(obj, omitKey);
});
// Flatten nest... | [
"function",
"clean",
"(",
"obj",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"// Remove traits/properties that are already represented",
"// outside of the data container",
"// TODO: Refactor into `omit` call",
"var",
"excludeKeys",
"=",
"[",
"'id'",
",",
"'name'",
",",
... | Clean all nested objects and arrays.
@api private
@param {Object} obj
@return {Object} | [
"Clean",
"all",
"nested",
"objects",
"and",
"arrays",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12526-L12559 | train |
segmentio/analytics.js | analytics.js | flatten | function flatten(source) {
var output = {};
function step(object, prev) {
for (var key in object) {
if (has.call(object, key)) {
var value = object[key];
var newKey = prev ? prev + ' ' + key : key;
if (!is.array(value) && is.object(value)) {
return step(value, newKey);
... | javascript | function flatten(source) {
var output = {};
function step(object, prev) {
for (var key in object) {
if (has.call(object, key)) {
var value = object[key];
var newKey = prev ? prev + ' ' + key : key;
if (!is.array(value) && is.object(value)) {
return step(value, newKey);
... | [
"function",
"flatten",
"(",
"source",
")",
"{",
"var",
"output",
"=",
"{",
"}",
";",
"function",
"step",
"(",
"object",
",",
"prev",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"object",
")",
"{",
"if",
"(",
"has",
".",
"call",
"(",
"object",
",",
... | Flatten a nested object into a single level space-delimited
hierarchy.
Based on https://github.com/hughsk/flat
@api private
@param {Object} source
@return {Object} | [
"Flatten",
"a",
"nested",
"object",
"into",
"a",
"single",
"level",
"space",
"-",
"delimited",
"hierarchy",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12586-L12607 | train |
segmentio/analytics.js | analytics.js | convert | function convert(key, value) {
key = camel(key);
if (is.string(value)) return key + '_str';
if (isInt(value)) return key + '_int';
if (isFloat(value)) return key + '_real';
if (is.date(value)) return key + '_date';
if (is.boolean(value)) return key + '_bool';
} | javascript | function convert(key, value) {
key = camel(key);
if (is.string(value)) return key + '_str';
if (isInt(value)) return key + '_int';
if (isFloat(value)) return key + '_real';
if (is.date(value)) return key + '_date';
if (is.boolean(value)) return key + '_bool';
} | [
"function",
"convert",
"(",
"key",
",",
"value",
")",
"{",
"key",
"=",
"camel",
"(",
"key",
")",
";",
"if",
"(",
"is",
".",
"string",
"(",
"value",
")",
")",
"return",
"key",
"+",
"'_str'",
";",
"if",
"(",
"isInt",
"(",
"value",
")",
")",
"retu... | Convert to FullStory format.
@param {string} trait
@param {*} value | [
"Convert",
"to",
"FullStory",
"format",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12688-L12695 | train |
segmentio/analytics.js | analytics.js | toCamelCase | function toCamelCase (string) {
return toSpace(string).replace(/\s(\w)/g, function (matches, letter) {
return letter.toUpperCase();
});
} | javascript | function toCamelCase (string) {
return toSpace(string).replace(/\s(\w)/g, function (matches, letter) {
return letter.toUpperCase();
});
} | [
"function",
"toCamelCase",
"(",
"string",
")",
"{",
"return",
"toSpace",
"(",
"string",
")",
".",
"replace",
"(",
"/",
"\\s(\\w)",
"/",
"g",
",",
"function",
"(",
"matches",
",",
"letter",
")",
"{",
"return",
"letter",
".",
"toUpperCase",
"(",
")",
";"... | Convert a `string` to camel case.
@param {String} string
@return {String} | [
"Convert",
"a",
"string",
"to",
"camel",
"case",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L12734-L12738 | train |
segmentio/analytics.js | analytics.js | path | function path(properties, options) {
if (!properties) return;
var str = properties.path;
if (options.includeSearch && properties.search) str += properties.search;
return str;
} | javascript | function path(properties, options) {
if (!properties) return;
var str = properties.path;
if (options.includeSearch && properties.search) str += properties.search;
return str;
} | [
"function",
"path",
"(",
"properties",
",",
"options",
")",
"{",
"if",
"(",
"!",
"properties",
")",
"return",
";",
"var",
"str",
"=",
"properties",
".",
"path",
";",
"if",
"(",
"options",
".",
"includeSearch",
"&&",
"properties",
".",
"search",
")",
"s... | Return the path based on `properties` and `options`.
@param {Object} properties
@param {Object} options
@return {string|undefined} | [
"Return",
"the",
"path",
"based",
"on",
"properties",
"and",
"options",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13320-L13325 | train |
segmentio/analytics.js | analytics.js | metrics | function metrics(obj, data) {
var dimensions = data.dimensions;
var metrics = data.metrics;
var names = keys(metrics).concat(keys(dimensions));
var ret = {};
for (var i = 0; i < names.length; ++i) {
var name = names[i];
var key = metrics[name] || dimensions[name];
var value = dot(obj, name) || ob... | javascript | function metrics(obj, data) {
var dimensions = data.dimensions;
var metrics = data.metrics;
var names = keys(metrics).concat(keys(dimensions));
var ret = {};
for (var i = 0; i < names.length; ++i) {
var name = names[i];
var key = metrics[name] || dimensions[name];
var value = dot(obj, name) || ob... | [
"function",
"metrics",
"(",
"obj",
",",
"data",
")",
"{",
"var",
"dimensions",
"=",
"data",
".",
"dimensions",
";",
"var",
"metrics",
"=",
"data",
".",
"metrics",
";",
"var",
"names",
"=",
"keys",
"(",
"metrics",
")",
".",
"concat",
"(",
"keys",
"(",... | Map google's custom dimensions & metrics with `obj`.
Example:
metrics({ revenue: 1.9 }, { { metrics : { revenue: 'metric8' } });
// => { metric8: 1.9 }
metrics({ revenue: 1.9 }, {});
// => {}
@param {Object} obj
@param {Object} data
@return {Object|null}
@api private | [
"Map",
"google",
"s",
"custom",
"dimensions",
"&",
"metrics",
"with",
"obj",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13356-L13371 | train |
segmentio/analytics.js | analytics.js | enhancedEcommerceTrackProduct | function enhancedEcommerceTrackProduct(track) {
var props = track.properties();
window.ga('ec:addProduct', {
id: track.id() || track.sku(),
name: track.name(),
category: track.category(),
quantity: track.quantity(),
price: track.price(),
brand: props.brand,
variant: props.variant,
c... | javascript | function enhancedEcommerceTrackProduct(track) {
var props = track.properties();
window.ga('ec:addProduct', {
id: track.id() || track.sku(),
name: track.name(),
category: track.category(),
quantity: track.quantity(),
price: track.price(),
brand: props.brand,
variant: props.variant,
c... | [
"function",
"enhancedEcommerceTrackProduct",
"(",
"track",
")",
"{",
"var",
"props",
"=",
"track",
".",
"properties",
"(",
")",
";",
"window",
".",
"ga",
"(",
"'ec:addProduct'",
",",
"{",
"id",
":",
"track",
".",
"id",
"(",
")",
"||",
"track",
".",
"sk... | Enhanced ecommerce track product.
Simple helper so that we don't repeat `ec:addProduct` everywhere.
@api private
@param {Track} track | [
"Enhanced",
"ecommerce",
"track",
"product",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13674-L13687 | train |
segmentio/analytics.js | analytics.js | enhancedEcommerceProductAction | function enhancedEcommerceProductAction(track, action, data) {
enhancedEcommerceTrackProduct(track);
window.ga('ec:setAction', action, data || {});
} | javascript | function enhancedEcommerceProductAction(track, action, data) {
enhancedEcommerceTrackProduct(track);
window.ga('ec:setAction', action, data || {});
} | [
"function",
"enhancedEcommerceProductAction",
"(",
"track",
",",
"action",
",",
"data",
")",
"{",
"enhancedEcommerceTrackProduct",
"(",
"track",
")",
";",
"window",
".",
"ga",
"(",
"'ec:setAction'",
",",
"action",
",",
"data",
"||",
"{",
"}",
")",
";",
"}"
] | Set `action` on `track` with `data`.
@api private
@param {Track} track
@param {String} action
@param {Object} data | [
"Set",
"action",
"on",
"track",
"with",
"data",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13698-L13701 | train |
segmentio/analytics.js | analytics.js | extractCheckoutOptions | function extractCheckoutOptions(props) {
var options = [
props.paymentMethod,
props.shippingMethod
];
// Remove all nulls, empty strings, zeroes, and join with commas.
var valid = select(options, function(e) {return e; });
return valid.length > 0 ? valid.join(', ') : null;
} | javascript | function extractCheckoutOptions(props) {
var options = [
props.paymentMethod,
props.shippingMethod
];
// Remove all nulls, empty strings, zeroes, and join with commas.
var valid = select(options, function(e) {return e; });
return valid.length > 0 ? valid.join(', ') : null;
} | [
"function",
"extractCheckoutOptions",
"(",
"props",
")",
"{",
"var",
"options",
"=",
"[",
"props",
".",
"paymentMethod",
",",
"props",
".",
"shippingMethod",
"]",
";",
"// Remove all nulls, empty strings, zeroes, and join with commas.",
"var",
"valid",
"=",
"select",
... | Extracts checkout options.
@api private
@param {Object} props
@return {string|null} | [
"Extracts",
"checkout",
"options",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13711-L13720 | train |
segmentio/analytics.js | analytics.js | createProductTrack | function createProductTrack(track, properties) {
properties.currency = properties.currency || track.currency();
return new Track({ properties: properties });
} | javascript | function createProductTrack(track, properties) {
properties.currency = properties.currency || track.currency();
return new Track({ properties: properties });
} | [
"function",
"createProductTrack",
"(",
"track",
",",
"properties",
")",
"{",
"properties",
".",
"currency",
"=",
"properties",
".",
"currency",
"||",
"track",
".",
"currency",
"(",
")",
";",
"return",
"new",
"Track",
"(",
"{",
"properties",
":",
"properties"... | Creates a track out of product properties.
@api private
@param {Track} track
@param {Object} properties
@return {Track} | [
"Creates",
"a",
"track",
"out",
"of",
"product",
"properties",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L13731-L13734 | train |
segmentio/analytics.js | analytics.js | push | function push() {
window._gs = window._gs || function() {
window._gs.q.push(arguments);
};
window._gs.q = window._gs.q || [];
window._gs.apply(null, arguments);
} | javascript | function push() {
window._gs = window._gs || function() {
window._gs.q.push(arguments);
};
window._gs.q = window._gs.q || [];
window._gs.apply(null, arguments);
} | [
"function",
"push",
"(",
")",
"{",
"window",
".",
"_gs",
"=",
"window",
".",
"_gs",
"||",
"function",
"(",
")",
"{",
"window",
".",
"_gs",
".",
"q",
".",
"push",
"(",
"arguments",
")",
";",
"}",
";",
"window",
".",
"_gs",
".",
"q",
"=",
"window... | Push to `_gs.q`.
@api private
@param {...*} args | [
"Push",
"to",
"_gs",
".",
"q",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14041-L14047 | train |
segmentio/analytics.js | analytics.js | omit | function omit(keys, object){
var ret = {};
for (var item in object) {
ret[item] = object[item];
}
for (var i = 0; i < keys.length; i++) {
delete ret[keys[i]];
}
return ret;
} | javascript | function omit(keys, object){
var ret = {};
for (var item in object) {
ret[item] = object[item];
}
for (var i = 0; i < keys.length; i++) {
delete ret[keys[i]];
}
return ret;
} | [
"function",
"omit",
"(",
"keys",
",",
"object",
")",
"{",
"var",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"item",
"in",
"object",
")",
"{",
"ret",
"[",
"item",
"]",
"=",
"object",
"[",
"item",
"]",
";",
"}",
"for",
"(",
"var",
"i",
"=",
... | Return a copy of the object without the specified keys.
@param {Array} keys
@param {Object} object
@return {Object} | [
"Return",
"a",
"copy",
"of",
"the",
"object",
"without",
"the",
"specified",
"keys",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14065-L14076 | train |
segmentio/analytics.js | analytics.js | pick | function pick(obj){
var keys = [].slice.call(arguments, 1);
var ret = {};
for (var i = 0, key; key = keys[i]; i++) {
if (key in obj) ret[key] = obj[key];
}
return ret;
} | javascript | function pick(obj){
var keys = [].slice.call(arguments, 1);
var ret = {};
for (var i = 0, key; key = keys[i]; i++) {
if (key in obj) ret[key] = obj[key];
}
return ret;
} | [
"function",
"pick",
"(",
"obj",
")",
"{",
"var",
"keys",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"var",
"ret",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"key",
";",
"key",
"=",
"keys"... | Pick keys from an `obj`.
@param {Object} obj
@param {Strings} keys...
@return {Object} | [
"Pick",
"keys",
"from",
"an",
"obj",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L14094-L14103 | train |
segmentio/analytics.js | analytics.js | prefix | function prefix(event, properties) {
var prefixed = {};
each(properties, function(key, val) {
if (key === 'Billing Amount') {
prefixed[key] = val;
} else {
prefixed[event + ' - ' + key] = val;
}
});
return prefixed;
} | javascript | function prefix(event, properties) {
var prefixed = {};
each(properties, function(key, val) {
if (key === 'Billing Amount') {
prefixed[key] = val;
} else {
prefixed[event + ' - ' + key] = val;
}
});
return prefixed;
} | [
"function",
"prefix",
"(",
"event",
",",
"properties",
")",
"{",
"var",
"prefixed",
"=",
"{",
"}",
";",
"each",
"(",
"properties",
",",
"function",
"(",
"key",
",",
"val",
")",
"{",
"if",
"(",
"key",
"===",
"'Billing Amount'",
")",
"{",
"prefixed",
"... | Prefix properties with the event name.
@param {String} event
@param {Object} properties
@return {Object} prefixed
@api private | [
"Prefix",
"properties",
"with",
"the",
"event",
"name",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15282-L15292 | train |
segmentio/analytics.js | analytics.js | convert | function convert(traits) {
var arr = [];
each(traits, function(key, value) {
arr.push({ name: key, value: value });
});
return arr;
} | javascript | function convert(traits) {
var arr = [];
each(traits, function(key, value) {
arr.push({ name: key, value: value });
});
return arr;
} | [
"function",
"convert",
"(",
"traits",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"each",
"(",
"traits",
",",
"function",
"(",
"key",
",",
"value",
")",
"{",
"arr",
".",
"push",
"(",
"{",
"name",
":",
"key",
",",
"value",
":",
"value",
"}",
")"... | Convert a traits object into the format LiveChat requires.
@param {Object} traits
@return {Array} | [
"Convert",
"a",
"traits",
"object",
"into",
"the",
"format",
"LiveChat",
"requires",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15533-L15539 | train |
segmentio/analytics.js | analytics.js | lowercase | function lowercase(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < arr.length; ++i) {
ret[i] = String(arr[i]).toLowerCase();
}
return ret;
} | javascript | function lowercase(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < arr.length; ++i) {
ret[i] = String(arr[i]).toLowerCase();
}
return ret;
} | [
"function",
"lowercase",
"(",
"arr",
")",
"{",
"var",
"ret",
"=",
"new",
"Array",
"(",
"arr",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
"[",
"i",
"]",
"=... | Lowercase the given `arr`.
@api private
@param {Array} arr
@return {Array} | [
"Lowercase",
"the",
"given",
"arr",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L15932-L15940 | train |
segmentio/analytics.js | analytics.js | ads | function ads(query){
var params = parse(query);
for (var key in params) {
for (var id in QUERYIDS) {
if (key === id) {
return {
id : params[key],
type : QUERYIDS[id]
};
}
}
}
} | javascript | function ads(query){
var params = parse(query);
for (var key in params) {
for (var id in QUERYIDS) {
if (key === id) {
return {
id : params[key],
type : QUERYIDS[id]
};
}
}
}
} | [
"function",
"ads",
"(",
"query",
")",
"{",
"var",
"params",
"=",
"parse",
"(",
"query",
")",
";",
"for",
"(",
"var",
"key",
"in",
"params",
")",
"{",
"for",
"(",
"var",
"id",
"in",
"QUERYIDS",
")",
"{",
"if",
"(",
"key",
"===",
"id",
")",
"{",
... | Get all ads info from the given `querystring`
@param {String} query
@return {Object}
@api private | [
"Get",
"all",
"ads",
"info",
"from",
"the",
"given",
"querystring"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18200-L18212 | train |
segmentio/analytics.js | analytics.js | store | function store(key, value){
var length = arguments.length;
if (0 == length) return all();
if (2 <= length) return set(key, value);
if (1 != length) return;
if (null == key) return storage.clear();
if ('string' == typeof key) return get(key);
if ('object' == typeof key) return each(key, set);
} | javascript | function store(key, value){
var length = arguments.length;
if (0 == length) return all();
if (2 <= length) return set(key, value);
if (1 != length) return;
if (null == key) return storage.clear();
if ('string' == typeof key) return get(key);
if ('object' == typeof key) return each(key, set);
} | [
"function",
"store",
"(",
"key",
",",
"value",
")",
"{",
"var",
"length",
"=",
"arguments",
".",
"length",
";",
"if",
"(",
"0",
"==",
"length",
")",
"return",
"all",
"(",
")",
";",
"if",
"(",
"2",
"<=",
"length",
")",
"return",
"set",
"(",
"key",... | Store the given `key`, `val`.
@param {String|Object} key
@param {Mixed} value
@return {Mixed}
@api public | [
"Store",
"the",
"given",
"key",
"val",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18250-L18258 | train |
segmentio/analytics.js | analytics.js | set | function set(key, val){
return null == val
? storage.removeItem(key)
: storage.setItem(key, JSON.stringify(val));
} | javascript | function set(key, val){
return null == val
? storage.removeItem(key)
: storage.setItem(key, JSON.stringify(val));
} | [
"function",
"set",
"(",
"key",
",",
"val",
")",
"{",
"return",
"null",
"==",
"val",
"?",
"storage",
".",
"removeItem",
"(",
"key",
")",
":",
"storage",
".",
"setItem",
"(",
"key",
",",
"JSON",
".",
"stringify",
"(",
"val",
")",
")",
";",
"}"
] | Set `key` to `val`.
@param {String} key
@param {Mixed} val | [
"Set",
"key",
"to",
"val",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18273-L18277 | train |
segmentio/analytics.js | analytics.js | all | function all(){
var len = storage.length;
var ret = {};
var key;
while (0 <= --len) {
key = storage.key(len);
ret[key] = get(key);
}
return ret;
} | javascript | function all(){
var len = storage.length;
var ret = {};
var key;
while (0 <= --len) {
key = storage.key(len);
ret[key] = get(key);
}
return ret;
} | [
"function",
"all",
"(",
")",
"{",
"var",
"len",
"=",
"storage",
".",
"length",
";",
"var",
"ret",
"=",
"{",
"}",
";",
"var",
"key",
";",
"while",
"(",
"0",
"<=",
"--",
"len",
")",
"{",
"key",
"=",
"storage",
".",
"key",
"(",
"len",
")",
";",
... | Get all.
@return {Object} | [
"Get",
"all",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18296-L18307 | train |
segmentio/analytics.js | analytics.js | set | function set (protocol) {
try {
define(window.location, 'protocol', {
get: function () { return protocol; }
});
} catch (err) {
mockedProtocol = protocol;
}
} | javascript | function set (protocol) {
try {
define(window.location, 'protocol', {
get: function () { return protocol; }
});
} catch (err) {
mockedProtocol = protocol;
}
} | [
"function",
"set",
"(",
"protocol",
")",
"{",
"try",
"{",
"define",
"(",
"window",
".",
"location",
",",
"'protocol'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"protocol",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"err",
")",
... | Sets the protocol
@param {String} protocol | [
"Sets",
"the",
"protocol"
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L18400-L18408 | train |
segmentio/analytics.js | analytics.js | formatOptions | function formatOptions(options) {
return alias(options, {
forumId: 'forum_id',
accentColor: 'accent_color',
smartvote: 'smartvote_enabled',
triggerColor: 'trigger_color',
triggerBackgroundColor: 'trigger_background_color',
triggerPosition: 'trigger_position',
screenshotEnabled: 'screenshot... | javascript | function formatOptions(options) {
return alias(options, {
forumId: 'forum_id',
accentColor: 'accent_color',
smartvote: 'smartvote_enabled',
triggerColor: 'trigger_color',
triggerBackgroundColor: 'trigger_background_color',
triggerPosition: 'trigger_position',
screenshotEnabled: 'screenshot... | [
"function",
"formatOptions",
"(",
"options",
")",
"{",
"return",
"alias",
"(",
"options",
",",
"{",
"forumId",
":",
"'forum_id'",
",",
"accentColor",
":",
"'accent_color'",
",",
"smartvote",
":",
"'smartvote_enabled'",
",",
"triggerColor",
":",
"'trigger_color'",
... | Format the options for UserVoice.
@api private
@param {Object} options
@return {Object} | [
"Format",
"the",
"options",
"for",
"UserVoice",
"."
] | 077efafa234d0bb4374169adb4e1ff71da39af8f | https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L19716-L19727 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.