id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
16,900 | aeternity/aepp-sdk-js | es/ae/index.js | transferFunds | async function transferFunds (percentage, recipientId, options = { excludeFee: false }) {
if (percentage < 0 || percentage > 1) throw new Error(`Percentage should be a number between 0 and 1, got ${percentage}`)
const opt = R.merge(this.Ae.defaults, options)
const requestTransferAmount = BigNumber(await this.bal... | javascript | async function transferFunds (percentage, recipientId, options = { excludeFee: false }) {
if (percentage < 0 || percentage > 1) throw new Error(`Percentage should be a number between 0 and 1, got ${percentage}`)
const opt = R.merge(this.Ae.defaults, options)
const requestTransferAmount = BigNumber(await this.bal... | [
"async",
"function",
"transferFunds",
"(",
"percentage",
",",
"recipientId",
",",
"options",
"=",
"{",
"excludeFee",
":",
"false",
"}",
")",
"{",
"if",
"(",
"percentage",
"<",
"0",
"||",
"percentage",
">",
"1",
")",
"throw",
"new",
"Error",
"(",
"`",
"... | Send a percentage of funds to another account
@instance
@category async
@rtype (percentage: Number|String, recipientId: String, options?: Object) => Promise[String]
@param {Number|String} percentage - Percentage of amount to spend
@param {String} recipientId - Address of recipient account
@param {Object} options - Opti... | [
"Send",
"a",
"percentage",
"of",
"funds",
"to",
"another",
"account"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/index.js#L75-L95 |
16,901 | aeternity/aepp-sdk-js | es/ae/aens.js | transfer | async function transfer (nameId, account, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameTransferTx = await this.nameTransferTx(R.merge(opt, {
nameId,
accountId: await this.address(),
recipientId: account
}))
return this.send(nameTransferTx, opt)
} | javascript | async function transfer (nameId, account, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameTransferTx = await this.nameTransferTx(R.merge(opt, {
nameId,
accountId: await this.address(),
recipientId: account
}))
return this.send(nameTransferTx, opt)
} | [
"async",
"function",
"transfer",
"(",
"nameId",
",",
"account",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"const",
"nameTransferTx",
"=",
"await",
"t... | Transfer a domain to another account
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@category async
@param {String} nameId
@param {String} account
@param {Object} [options={}]
@return {Promise<Object>} | [
"Transfer",
"a",
"domain",
"to",
"another",
"account"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L45-L55 |
16,902 | aeternity/aepp-sdk-js | es/ae/aens.js | revoke | async function revoke (nameId, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameRevokeTx = await this.nameRevokeTx(R.merge(opt, {
nameId,
accountId: await this.address()
}))
return this.send(nameRevokeTx, opt)
} | javascript | async function revoke (nameId, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameRevokeTx = await this.nameRevokeTx(R.merge(opt, {
nameId,
accountId: await this.address()
}))
return this.send(nameRevokeTx, opt)
} | [
"async",
"function",
"revoke",
"(",
"nameId",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"const",
"nameRevokeTx",
"=",
"await",
"this",
".",
"nameRevo... | Revoke a domain
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@category async
@param {String} nameId
@param {Object} [options={}]
@return {Promise<Object>} | [
"Revoke",
"a",
"domain"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L67-L76 |
16,903 | aeternity/aepp-sdk-js | es/ae/aens.js | classify | function classify (s) {
const keys = {
ak: 'account_pubkey',
ok: 'oracle_pubkey'
}
if (!s.match(/^[a-z]{2}_.+/)) {
throw Error('Not a valid hash')
}
const klass = s.substr(0, 2)
if (klass in keys) {
return keys[klass]
} else {
throw Error(`Unknown class ${klass}`)
}
} | javascript | function classify (s) {
const keys = {
ak: 'account_pubkey',
ok: 'oracle_pubkey'
}
if (!s.match(/^[a-z]{2}_.+/)) {
throw Error('Not a valid hash')
}
const klass = s.substr(0, 2)
if (klass in keys) {
return keys[klass]
} else {
throw Error(`Unknown class ${klass}`)
}
} | [
"function",
"classify",
"(",
"s",
")",
"{",
"const",
"keys",
"=",
"{",
"ak",
":",
"'account_pubkey'",
",",
"ok",
":",
"'oracle_pubkey'",
"}",
"if",
"(",
"!",
"s",
".",
"match",
"(",
"/",
"^[a-z]{2}_.+",
"/",
")",
")",
"{",
"throw",
"Error",
"(",
"'... | What kind of a hash is this? If it begins with 'ak_' it is an
account key, if with 'ok_' it's an oracle key.
@param s - the hash.
returns the type, or throws an exception if type not found. | [
"What",
"kind",
"of",
"a",
"hash",
"is",
"this?",
"If",
"it",
"begins",
"with",
"ak_",
"it",
"is",
"an",
"account",
"key",
"if",
"with",
"ok_",
"it",
"s",
"an",
"oracle",
"key",
"."
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L85-L101 |
16,904 | aeternity/aepp-sdk-js | es/ae/aens.js | update | async function update (nameId, target, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameUpdateTx = await this.nameUpdateTx(R.merge(opt, {
nameId: nameId,
accountId: await this.address(),
pointers: [R.fromPairs([['id', target], ['key', classify(target)]])]
}))
return this.sen... | javascript | async function update (nameId, target, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const nameUpdateTx = await this.nameUpdateTx(R.merge(opt, {
nameId: nameId,
accountId: await this.address(),
pointers: [R.fromPairs([['id', target], ['key', classify(target)]])]
}))
return this.sen... | [
"async",
"function",
"update",
"(",
"nameId",
",",
"target",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"const",
"nameUpdateTx",
"=",
"await",
"this",... | Update an aens entry
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@param nameId domain hash
@param target new target
@param options
@return {Object} | [
"Update",
"an",
"aens",
"entry"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L113-L122 |
16,905 | aeternity/aepp-sdk-js | es/ae/aens.js | query | async function query (name) {
const o = await this.getName(name)
const nameId = o.id
return Object.freeze(Object.assign(o, {
pointers: o.pointers || {},
update: async (target, options) => {
return {
...(await this.aensUpdate(nameId, target, options)),
...(await this.aensQuery(name))... | javascript | async function query (name) {
const o = await this.getName(name)
const nameId = o.id
return Object.freeze(Object.assign(o, {
pointers: o.pointers || {},
update: async (target, options) => {
return {
...(await this.aensUpdate(nameId, target, options)),
...(await this.aensQuery(name))... | [
"async",
"function",
"query",
"(",
"name",
")",
"{",
"const",
"o",
"=",
"await",
"this",
".",
"getName",
"(",
"name",
")",
"const",
"nameId",
"=",
"o",
".",
"id",
"return",
"Object",
".",
"freeze",
"(",
"Object",
".",
"assign",
"(",
"o",
",",
"{",
... | Query the status of an AENS registration
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@param {string} name
@return {Promise<Object>} | [
"Query",
"the",
"status",
"of",
"an",
"AENS",
"registration"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L132-L152 |
16,906 | aeternity/aepp-sdk-js | es/ae/aens.js | claim | async function claim (name, salt, waitForHeight, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
// wait until block was mined before send claim transaction
// if (waitForHeight) await this.awaitHeight(waitForHeight, { attempts: 200 })
const claimTx = await this.nameClaimTx(R.merge(opt, {
acc... | javascript | async function claim (name, salt, waitForHeight, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
// wait until block was mined before send claim transaction
// if (waitForHeight) await this.awaitHeight(waitForHeight, { attempts: 200 })
const claimTx = await this.nameClaimTx(R.merge(opt, {
acc... | [
"async",
"function",
"claim",
"(",
"name",
",",
"salt",
",",
"waitForHeight",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"// wait until block was mined be... | Claim a previously preclaimed registration. This can only be done after the
preclaim step
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@param {String} name
@param {String} salt
@param {Number} waitForHeight
@param {Record} [options={}]
@return {Promise<Object>} the result of the claim | [
"Claim",
"a",
"previously",
"preclaimed",
"registration",
".",
"This",
"can",
"only",
"be",
"done",
"after",
"the",
"preclaim",
"step"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L166-L182 |
16,907 | aeternity/aepp-sdk-js | es/ae/aens.js | preclaim | async function preclaim (name, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const _salt = salt()
const height = await this.height()
const hash = await commitmentHash(name, _salt)
const preclaimTx = await this.namePreclaimTx(R.merge(opt, {
accountId: await this.address(),
commitmentI... | javascript | async function preclaim (name, options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const _salt = salt()
const height = await this.height()
const hash = await commitmentHash(name, _salt)
const preclaimTx = await this.namePreclaimTx(R.merge(opt, {
accountId: await this.address(),
commitmentI... | [
"async",
"function",
"preclaim",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"const",
"_salt",
"=",
"salt",
"(",
")",
"const",
"height",... | Preclaim a name. Sends a hash of the name and a random salt to the node
@instance
@function
@alias module:@aeternity/aepp-sdk/es/ae/aens
@param {string} name
@param {Record} [options={}]
@return {Promise<Object>} | [
"Preclaim",
"a",
"name",
".",
"Sends",
"a",
"hash",
"of",
"the",
"name",
"and",
"a",
"random",
"salt",
"to",
"the",
"node"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/aens.js#L193-L213 |
16,908 | aeternity/aepp-sdk-js | es/ae/contract.js | handleCallError | async function handleCallError (result) {
const error = Buffer.from(result.returnValue).toString()
if (isBase64(error.slice(3))) {
const decodedError = Buffer.from(error.slice(3), 'base64').toString()
throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error... | javascript | async function handleCallError (result) {
const error = Buffer.from(result.returnValue).toString()
if (isBase64(error.slice(3))) {
const decodedError = Buffer.from(error.slice(3), 'base64').toString()
throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error... | [
"async",
"function",
"handleCallError",
"(",
"result",
")",
"{",
"const",
"error",
"=",
"Buffer",
".",
"from",
"(",
"result",
".",
"returnValue",
")",
".",
"toString",
"(",
")",
"if",
"(",
"isBase64",
"(",
"error",
".",
"slice",
"(",
"3",
")",
")",
"... | Handle contract call error
@function
@alias module:@aeternity/aepp-sdk/es/ae/contract
@category async
@param {Object} result call result object
@throws Error Decoded error
@return {Promise<void>} | [
"Handle",
"contract",
"call",
"error"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/contract.js#L46-L55 |
16,909 | aeternity/aepp-sdk-js | es/ae/contract.js | contractCall | async function contractCall (source, address, name, args = [], options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const tx = await this.contractCallTx(R.merge(opt, {
callerId: await this.address(),
contractId: address,
callData: await this.contractEncodeCall(source, name, args)
}))
con... | javascript | async function contractCall (source, address, name, args = [], options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const tx = await this.contractCallTx(R.merge(opt, {
callerId: await this.address(),
contractId: address,
callData: await this.contractEncodeCall(source, name, args)
}))
con... | [
"async",
"function",
"contractCall",
"(",
"source",
",",
"address",
",",
"name",
",",
"args",
"=",
"[",
"]",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
... | Call contract function
@function
@alias module:@aeternity/aepp-sdk/es/ae/contract
@category async
@param {String} source Contract source code
@param {String} address Contract address
@param {String} name Name of function to call
@param {Array} args Argument's for call function
@param {Object} options Transaction option... | [
"Call",
"contract",
"function"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/contract.js#L158-L180 |
16,910 | aeternity/aepp-sdk-js | es/ae/contract.js | contractDeploy | async function contractDeploy (code, source, initState = [], options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const callData = await this.contractEncodeCall(source, 'init', initState)
const ownerId = await this.address()
const { tx, contractId } = await this.contractCreateTx(R.merge(opt, {
ca... | javascript | async function contractDeploy (code, source, initState = [], options = {}) {
const opt = R.merge(this.Ae.defaults, options)
const callData = await this.contractEncodeCall(source, 'init', initState)
const ownerId = await this.address()
const { tx, contractId } = await this.contractCreateTx(R.merge(opt, {
ca... | [
"async",
"function",
"contractDeploy",
"(",
"code",
",",
"source",
",",
"initState",
"=",
"[",
"]",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"R",
".",
"merge",
"(",
"this",
".",
"Ae",
".",
"defaults",
",",
"options",
")",
"cons... | Deploy contract to the node
@function
@alias module:@aeternity/aepp-sdk/es/ae/contract
@category async
@param {String} code Compiled contract
@param {String} source Contract source code
@param {Array} initState Arguments of contract constructor(init) function
@param {Object} options Transaction options (fee, ttl, gas, ... | [
"Deploy",
"contract",
"to",
"the",
"node"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/contract.js#L204-L228 |
16,911 | aeternity/aepp-sdk-js | es/ae/contract.js | contractCompile | async function contractCompile (source, options = {}) {
const bytecode = await this.compileContractAPI(source, options)
return Object.freeze(Object.assign({
encodeCall: async (name, args) => this.contractEncodeCall(source, name, args),
deploy: async (init, options = {}) => this.contractDeploy(bytecode, sour... | javascript | async function contractCompile (source, options = {}) {
const bytecode = await this.compileContractAPI(source, options)
return Object.freeze(Object.assign({
encodeCall: async (name, args) => this.contractEncodeCall(source, name, args),
deploy: async (init, options = {}) => this.contractDeploy(bytecode, sour... | [
"async",
"function",
"contractCompile",
"(",
"source",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"bytecode",
"=",
"await",
"this",
".",
"compileContractAPI",
"(",
"source",
",",
"options",
")",
"return",
"Object",
".",
"freeze",
"(",
"Object",
".",... | Compile contract source code
@function
@alias module:@aeternity/aepp-sdk/es/ae/contract
@category async
@param {String} source Contract sourece code
@param {Object} options Transaction options (fee, ttl, gas, amount, deposit)
@return {Promise<Object>} Result object
@example
const compiled = await client.contractCompile... | [
"Compile",
"contract",
"source",
"code"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/ae/contract.js#L246-L252 |
16,912 | aeternity/aepp-sdk-js | es/contract/aci.js | transform | function transform (type, value) {
let { t, generic } = readType(type)
// contract TestContract = ...
// fn(ct: TestContract)
if (typeof value === 'string' && value.slice(0, 2) === 'ct') t = SOPHIA_TYPES.address // Handle Contract address transformation
switch (t) {
case SOPHIA_TYPES.string:
retur... | javascript | function transform (type, value) {
let { t, generic } = readType(type)
// contract TestContract = ...
// fn(ct: TestContract)
if (typeof value === 'string' && value.slice(0, 2) === 'ct') t = SOPHIA_TYPES.address // Handle Contract address transformation
switch (t) {
case SOPHIA_TYPES.string:
retur... | [
"function",
"transform",
"(",
"type",
",",
"value",
")",
"{",
"let",
"{",
"t",
",",
"generic",
"}",
"=",
"readType",
"(",
"type",
")",
"// contract TestContract = ...",
"// fn(ct: TestContract)",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
"&&",
"value",
... | Transform JS type to Sophia-type
@param type
@param value
@return {string} | [
"Transform",
"JS",
"type",
"to",
"Sophia",
"-",
"type"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L50-L78 |
16,913 | aeternity/aepp-sdk-js | es/contract/aci.js | readType | function readType (type, returnType = false) {
const [t] = Array.isArray(type) ? type : [type]
// Base types
if (typeof t === 'string') return { t }
// Map, Tuple, List
if (typeof t === 'object') {
const [[baseType, generic]] = Object.entries(t)
return { t: baseType, generic }
}
} | javascript | function readType (type, returnType = false) {
const [t] = Array.isArray(type) ? type : [type]
// Base types
if (typeof t === 'string') return { t }
// Map, Tuple, List
if (typeof t === 'object') {
const [[baseType, generic]] = Object.entries(t)
return { t: baseType, generic }
}
} | [
"function",
"readType",
"(",
"type",
",",
"returnType",
"=",
"false",
")",
"{",
"const",
"[",
"t",
"]",
"=",
"Array",
".",
"isArray",
"(",
"type",
")",
"?",
"type",
":",
"[",
"type",
"]",
"// Base types",
"if",
"(",
"typeof",
"t",
"===",
"'string'",
... | Parse sophia type
@param type
@param returnType
@return {*} | [
"Parse",
"sophia",
"type"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L86-L96 |
16,914 | aeternity/aepp-sdk-js | es/contract/aci.js | validate | function validate (type, value) {
const { t } = readType(type)
if (value === undefined || value === null) return { require: true }
switch (t) {
case SOPHIA_TYPES.int:
return isNaN(value) || ['boolean'].includes(typeof value)
case SOPHIA_TYPES.bool:
return typeof value !== 'boolean'
case S... | javascript | function validate (type, value) {
const { t } = readType(type)
if (value === undefined || value === null) return { require: true }
switch (t) {
case SOPHIA_TYPES.int:
return isNaN(value) || ['boolean'].includes(typeof value)
case SOPHIA_TYPES.bool:
return typeof value !== 'boolean'
case S... | [
"function",
"validate",
"(",
"type",
",",
"value",
")",
"{",
"const",
"{",
"t",
"}",
"=",
"readType",
"(",
"type",
")",
"if",
"(",
"value",
"===",
"undefined",
"||",
"value",
"===",
"null",
")",
"return",
"{",
"require",
":",
"true",
"}",
"switch",
... | Validate argument sophia-type
@param type
@param value
@return {*} | [
"Validate",
"argument",
"sophia",
"-",
"type"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L104-L118 |
16,915 | aeternity/aepp-sdk-js | es/contract/aci.js | transformDecodedData | function transformDecodedData (aci, result, { skipTransformDecoded = false, addressPrefix = 'ak' } = {}) {
if (skipTransformDecoded) return result
const { t, generic } = readType(aci, true)
switch (t) {
case SOPHIA_TYPES.bool:
return !!result.value
case SOPHIA_TYPES.address:
return result.val... | javascript | function transformDecodedData (aci, result, { skipTransformDecoded = false, addressPrefix = 'ak' } = {}) {
if (skipTransformDecoded) return result
const { t, generic } = readType(aci, true)
switch (t) {
case SOPHIA_TYPES.bool:
return !!result.value
case SOPHIA_TYPES.address:
return result.val... | [
"function",
"transformDecodedData",
"(",
"aci",
",",
"result",
",",
"{",
"skipTransformDecoded",
"=",
"false",
",",
"addressPrefix",
"=",
"'ak'",
"}",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"skipTransformDecoded",
")",
"return",
"result",
"const",
"{",
"t",
"... | Transform decoded data to JS type
@param aci
@param result
@param transformDecodedData
@return {*} | [
"Transform",
"decoded",
"data",
"to",
"JS",
"type"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L132-L170 |
16,916 | aeternity/aepp-sdk-js | es/contract/aci.js | prepareArgsForEncode | function prepareArgsForEncode (aci, params) {
if (!aci) return params
// Validation
const validation = aci.arguments
.map(
({ type }, i) =>
validate(type, params[i])
? `Argument index: ${i}, value: [${params[i]}] must be of type [${type}]`
: false
).filter(e => e)
if (v... | javascript | function prepareArgsForEncode (aci, params) {
if (!aci) return params
// Validation
const validation = aci.arguments
.map(
({ type }, i) =>
validate(type, params[i])
? `Argument index: ${i}, value: [${params[i]}] must be of type [${type}]`
: false
).filter(e => e)
if (v... | [
"function",
"prepareArgsForEncode",
"(",
"aci",
",",
"params",
")",
"{",
"if",
"(",
"!",
"aci",
")",
"return",
"params",
"// Validation",
"const",
"validation",
"=",
"aci",
".",
"arguments",
".",
"map",
"(",
"(",
"{",
"type",
"}",
",",
"i",
")",
"=>",
... | Validated contract call arguments using contract ACI
@function validateCallParams
@rtype (aci: Object, params: Array) => Object
@param {Object} aci Contract ACI
@param {Array} params Contract call arguments
@return {Array} Object with validation errors | [
"Validated",
"contract",
"call",
"arguments",
"using",
"contract",
"ACI"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L180-L193 |
16,917 | aeternity/aepp-sdk-js | es/contract/aci.js | getFunctionACI | function getFunctionACI (aci, name) {
const fn = aci.functions.find(f => f.name === name)
if (!fn && name !== 'init') throw new Error(`Function ${name} doesn't exist in contract`)
return fn
} | javascript | function getFunctionACI (aci, name) {
const fn = aci.functions.find(f => f.name === name)
if (!fn && name !== 'init') throw new Error(`Function ${name} doesn't exist in contract`)
return fn
} | [
"function",
"getFunctionACI",
"(",
"aci",
",",
"name",
")",
"{",
"const",
"fn",
"=",
"aci",
".",
"functions",
".",
"find",
"(",
"f",
"=>",
"f",
".",
"name",
"===",
"name",
")",
"if",
"(",
"!",
"fn",
"&&",
"name",
"!==",
"'init'",
")",
"throw",
"n... | Get function schema from contract ACI object
@param {Object} aci Contract ACI object
@param {String} name Function name
@return {Object} function ACI | [
"Get",
"function",
"schema",
"from",
"contract",
"ACI",
"object"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L201-L206 |
16,918 | aeternity/aepp-sdk-js | es/contract/aci.js | getContractInstance | async function getContractInstance (source, { aci, contractAddress } = {}) {
aci = aci || await this.contractGetACI(source)
const instance = {
interface: aci.interface,
aci: aci.encoded_aci.contract,
source,
compiled: null,
deployInfo: { address: contractAddress }
}
/**
* Compile contract... | javascript | async function getContractInstance (source, { aci, contractAddress } = {}) {
aci = aci || await this.contractGetACI(source)
const instance = {
interface: aci.interface,
aci: aci.encoded_aci.contract,
source,
compiled: null,
deployInfo: { address: contractAddress }
}
/**
* Compile contract... | [
"async",
"function",
"getContractInstance",
"(",
"source",
",",
"{",
"aci",
",",
"contractAddress",
"}",
"=",
"{",
"}",
")",
"{",
"aci",
"=",
"aci",
"||",
"await",
"this",
".",
"contractGetACI",
"(",
"source",
")",
"const",
"instance",
"=",
"{",
"interfa... | Generate contract ACI object with predefined js methods for contract usage
@alias module:@aeternity/aepp-sdk/es/contract/aci
@param {String} source Contract source code
@param {Object} [options] Options object
@param {Object} [options.aci] Contract ACI
@return {ContractInstance} JS Contract API
@example
const contractI... | [
"Generate",
"contract",
"ACI",
"object",
"with",
"predefined",
"js",
"methods",
"for",
"contract",
"usage"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/contract/aci.js#L222-L263 |
16,919 | aeternity/aepp-sdk-js | es/account/memory.js | setKeypair | function setKeypair (keypair) {
if (keypair.hasOwnProperty('priv') && keypair.hasOwnProperty('pub')) {
keypair = { secretKey: keypair.priv, publicKey: keypair.pub }
console.warn('pub/priv naming for accounts has been deprecated, please use secretKey/publicKey')
}
secrets.set(this, {
secretKey: Buffer.... | javascript | function setKeypair (keypair) {
if (keypair.hasOwnProperty('priv') && keypair.hasOwnProperty('pub')) {
keypair = { secretKey: keypair.priv, publicKey: keypair.pub }
console.warn('pub/priv naming for accounts has been deprecated, please use secretKey/publicKey')
}
secrets.set(this, {
secretKey: Buffer.... | [
"function",
"setKeypair",
"(",
"keypair",
")",
"{",
"if",
"(",
"keypair",
".",
"hasOwnProperty",
"(",
"'priv'",
")",
"&&",
"keypair",
".",
"hasOwnProperty",
"(",
"'pub'",
")",
")",
"{",
"keypair",
"=",
"{",
"secretKey",
":",
"keypair",
".",
"priv",
",",
... | Select specific account
@alias module:@aeternity/aepp-sdk/es/account/memory
@function
@instance
@rtype (keypair: {publicKey: String, secretKey: String}) => Void
@param {Object} keypair - Key pair to use
@param {String} keypair.publicKey - Public key
@param {String} keypair.secretKey - Private key
@return {Void}
@exampl... | [
"Select",
"specific",
"account"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/account/memory.js#L50-L59 |
16,920 | aeternity/aepp-sdk-js | es/tx/builder/index.js | deserializeField | function deserializeField (value, type, prefix) {
if (!value) return ''
switch (type) {
case FIELD_TYPES.int:
return readInt(value)
case FIELD_TYPES.id:
return readId(value)
case FIELD_TYPES.ids:
return value.map(readId)
case FIELD_TYPES.bool:
return value[0] === 1
case F... | javascript | function deserializeField (value, type, prefix) {
if (!value) return ''
switch (type) {
case FIELD_TYPES.int:
return readInt(value)
case FIELD_TYPES.id:
return readId(value)
case FIELD_TYPES.ids:
return value.map(readId)
case FIELD_TYPES.bool:
return value[0] === 1
case F... | [
"function",
"deserializeField",
"(",
"value",
",",
"type",
",",
"prefix",
")",
"{",
"if",
"(",
"!",
"value",
")",
"return",
"''",
"switch",
"(",
"type",
")",
"{",
"case",
"FIELD_TYPES",
".",
"int",
":",
"return",
"readInt",
"(",
"value",
")",
"case",
... | SERIALIZE AND DESERIALIZE PART | [
"SERIALIZE",
"AND",
"DESERIALIZE",
"PART"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/tx/builder/index.js#L34-L76 |
16,921 | aeternity/aepp-sdk-js | es/tx/tx.js | calculateTtl | async function calculateTtl (ttl = 0, relative = true) {
if (ttl === 0) return 0
if (ttl < 0) throw new Error('ttl must be greater than 0')
if (relative) {
const { height } = await this.api.getCurrentKeyBlock()
return +(height) + ttl
}
return ttl
} | javascript | async function calculateTtl (ttl = 0, relative = true) {
if (ttl === 0) return 0
if (ttl < 0) throw new Error('ttl must be greater than 0')
if (relative) {
const { height } = await this.api.getCurrentKeyBlock()
return +(height) + ttl
}
return ttl
} | [
"async",
"function",
"calculateTtl",
"(",
"ttl",
"=",
"0",
",",
"relative",
"=",
"true",
")",
"{",
"if",
"(",
"ttl",
"===",
"0",
")",
"return",
"0",
"if",
"(",
"ttl",
"<",
"0",
")",
"throw",
"new",
"Error",
"(",
"'ttl must be greater than 0'",
")",
"... | Compute the absolute ttl by adding the ttl to the current height of the chain
@param {number} ttl
@param {boolean} relative ttl is absolute or relative(default: true(relative))
@return {number} Absolute Ttl | [
"Compute",
"the",
"absolute",
"ttl",
"by",
"adding",
"the",
"ttl",
"to",
"the",
"current",
"height",
"of",
"the",
"chain"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/tx/tx.js#L365-L374 |
16,922 | aeternity/aepp-sdk-js | es/tx/tx.js | getAccountNonce | async function getAccountNonce (accountId, nonce) {
if (nonce) return nonce
const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId).catch(() => ({ nonce: 0 }))
return accountNonce + 1
} | javascript | async function getAccountNonce (accountId, nonce) {
if (nonce) return nonce
const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId).catch(() => ({ nonce: 0 }))
return accountNonce + 1
} | [
"async",
"function",
"getAccountNonce",
"(",
"accountId",
",",
"nonce",
")",
"{",
"if",
"(",
"nonce",
")",
"return",
"nonce",
"const",
"{",
"nonce",
":",
"accountNonce",
"}",
"=",
"await",
"this",
".",
"api",
".",
"getAccountByPubkey",
"(",
"accountId",
")... | Get the next nonce to be used for a transaction for an account
@param {string} accountId
@param {number} nonce
@return {number} Next Nonce | [
"Get",
"the",
"next",
"nonce",
"to",
"be",
"used",
"for",
"a",
"transaction",
"for",
"an",
"account"
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/tx/tx.js#L383-L387 |
16,923 | aeternity/aepp-sdk-js | es/utils/keystore.js | str2buf | function str2buf (str, enc) {
if (!str || str.constructor !== String) return str
if (!enc && isHex(str)) enc = 'hex'
if (!enc && isBase64(str)) enc = 'base64'
return Buffer.from(str, enc)
} | javascript | function str2buf (str, enc) {
if (!str || str.constructor !== String) return str
if (!enc && isHex(str)) enc = 'hex'
if (!enc && isBase64(str)) enc = 'base64'
return Buffer.from(str, enc)
} | [
"function",
"str2buf",
"(",
"str",
",",
"enc",
")",
"{",
"if",
"(",
"!",
"str",
"||",
"str",
".",
"constructor",
"!==",
"String",
")",
"return",
"str",
"if",
"(",
"!",
"enc",
"&&",
"isHex",
"(",
"str",
")",
")",
"enc",
"=",
"'hex'",
"if",
"(",
... | Convert a string to a Buffer. If encoding is not specified, hex-encoding
will be used if the input is valid hex. If the input is valid base64 but
not valid hex, base64 will be used. Otherwise, utf8 will be used.
@param {string} str String to be converted.
@param {string=} enc Encoding of the input string (optional).... | [
"Convert",
"a",
"string",
"to",
"a",
"Buffer",
".",
"If",
"encoding",
"is",
"not",
"specified",
"hex",
"-",
"encoding",
"will",
"be",
"used",
"if",
"the",
"input",
"is",
"valid",
"hex",
".",
"If",
"the",
"input",
"is",
"valid",
"base64",
"but",
"not",
... | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/utils/keystore.js#L69-L74 |
16,924 | aeternity/aepp-sdk-js | es/utils/keystore.js | deriveKey | async function deriveKey (password, nonce, options = {
kdf_params: DEFAULTS.crypto.kdf_params,
kdf: DEFAULTS.crypto.kdf
}) {
if (typeof password === 'undefined' || password === null || !nonce) {
throw new Error('Must provide password and nonce to derive a key')
}
if (!DERIVED_KEY_FUNCTIONS.hasOwnProperty... | javascript | async function deriveKey (password, nonce, options = {
kdf_params: DEFAULTS.crypto.kdf_params,
kdf: DEFAULTS.crypto.kdf
}) {
if (typeof password === 'undefined' || password === null || !nonce) {
throw new Error('Must provide password and nonce to derive a key')
}
if (!DERIVED_KEY_FUNCTIONS.hasOwnProperty... | [
"async",
"function",
"deriveKey",
"(",
"password",
",",
"nonce",
",",
"options",
"=",
"{",
"kdf_params",
":",
"DEFAULTS",
".",
"crypto",
".",
"kdf_params",
",",
"kdf",
":",
"DEFAULTS",
".",
"crypto",
".",
"kdf",
"}",
")",
"{",
"if",
"(",
"typeof",
"pas... | Derive secret key from password with key derivation function.
@param {string} password User-supplied password.
@param {buffer|Uint8Array} nonce Randomly generated nonce.
@param {Object=} options Encryption parameters.
@param {string=} options.kdf Key derivation function (default: DEFAULTS.crypto.kdf).
@param {Object=} ... | [
"Derive",
"secret",
"key",
"from",
"password",
"with",
"key",
"derivation",
"function",
"."
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/utils/keystore.js#L111-L122 |
16,925 | aeternity/aepp-sdk-js | es/utils/keystore.js | marshal | function marshal (name, derivedKey, privateKey, nonce, salt, options = {}) {
const opt = Object.assign({}, DEFAULTS.crypto, options)
return Object.assign(
{ name, version: 1, public_key: getAddressFromPriv(privateKey), id: uuid.v4() },
{
crypto: Object.assign(
{
secret_type: opt.secr... | javascript | function marshal (name, derivedKey, privateKey, nonce, salt, options = {}) {
const opt = Object.assign({}, DEFAULTS.crypto, options)
return Object.assign(
{ name, version: 1, public_key: getAddressFromPriv(privateKey), id: uuid.v4() },
{
crypto: Object.assign(
{
secret_type: opt.secr... | [
"function",
"marshal",
"(",
"name",
",",
"derivedKey",
",",
"privateKey",
",",
"nonce",
",",
"salt",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"opt",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"DEFAULTS",
".",
"crypto",
",",
"options",... | Assemble key data object in secret-storage format.
@param {buffer} name Key name.
@param {buffer} derivedKey Password-derived secret key.
@param {buffer} privateKey Private key.
@param {buffer} nonce Randomly generated 24byte nonce.
@param {buffer} salt Randomly generated 16byte salt.
@param {Object=} options Encryptio... | [
"Assemble",
"key",
"data",
"object",
"in",
"secret",
"-",
"storage",
"format",
"."
] | 1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6 | https://github.com/aeternity/aepp-sdk-js/blob/1ad86b72235e88d357a03d6ae4dd4ce1a4158ca6/es/utils/keystore.js#L137-L153 |
16,926 | sendinblue/APIv3-nodejs-library | src/model/GetChildInfo.js | function(email, firstName, lastName, companyName, password) {
var _this = this;
GetClient.call(_this, email, firstName, lastName, companyName);
_this['password'] = password;
} | javascript | function(email, firstName, lastName, companyName, password) {
var _this = this;
GetClient.call(_this, email, firstName, lastName, companyName);
_this['password'] = password;
} | [
"function",
"(",
"email",
",",
"firstName",
",",
"lastName",
",",
"companyName",
",",
"password",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"GetClient",
".",
"call",
"(",
"_this",
",",
"email",
",",
"firstName",
",",
"lastName",
",",
"companyName",
")"... | The GetChildInfo model module.
@module model/GetChildInfo
@version 7.x.x
Constructs a new <code>GetChildInfo</code>.
@alias module:model/GetChildInfo
@class
@implements module:model/GetClient
@param email {String} Login Email
@param firstName {String} First Name
@param lastName {String} Last Name
@param companyName {... | [
"The",
"GetChildInfo",
"model",
"module",
"."
] | 9663ee86370be7577853d2b7565b11380d5fe736 | https://github.com/sendinblue/APIv3-nodejs-library/blob/9663ee86370be7577853d2b7565b11380d5fe736/src/model/GetChildInfo.js#L54-L63 | |
16,927 | sendinblue/APIv3-nodejs-library | src/model/GetAccount.js | function(email, firstName, lastName, companyName, address, plan, relay) {
var _this = this;
GetExtendedClient.call(_this, email, firstName, lastName, companyName, address);
_this['plan'] = plan;
_this['relay'] = relay;
} | javascript | function(email, firstName, lastName, companyName, address, plan, relay) {
var _this = this;
GetExtendedClient.call(_this, email, firstName, lastName, companyName, address);
_this['plan'] = plan;
_this['relay'] = relay;
} | [
"function",
"(",
"email",
",",
"firstName",
",",
"lastName",
",",
"companyName",
",",
"address",
",",
"plan",
",",
"relay",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"GetExtendedClient",
".",
"call",
"(",
"_this",
",",
"email",
",",
"firstName",
",",
... | The GetAccount model module.
@module model/GetAccount
@version 7.x.x
Constructs a new <code>GetAccount</code>.
@alias module:model/GetAccount
@class
@implements module:model/GetExtendedClient
@param email {String} Login Email
@param firstName {String} First Name
@param lastName {String} Last Name
@param companyName {... | [
"The",
"GetAccount",
"model",
"module",
"."
] | 9663ee86370be7577853d2b7565b11380d5fe736 | https://github.com/sendinblue/APIv3-nodejs-library/blob/9663ee86370be7577853d2b7565b11380d5fe736/src/model/GetAccount.js#L56-L63 | |
16,928 | dcmjs-org/dicomweb-client | src/message.js | uint8ArrayToString | function uint8ArrayToString(arr, offset, limit) {
offset = offset || 0;
limit = limit || arr.length - offset;
let str = '';
for (let i = offset; i < offset + limit; i++) {
str += String.fromCharCode(arr[i]);
}
return str;
} | javascript | function uint8ArrayToString(arr, offset, limit) {
offset = offset || 0;
limit = limit || arr.length - offset;
let str = '';
for (let i = offset; i < offset + limit; i++) {
str += String.fromCharCode(arr[i]);
}
return str;
} | [
"function",
"uint8ArrayToString",
"(",
"arr",
",",
"offset",
",",
"limit",
")",
"{",
"offset",
"=",
"offset",
"||",
"0",
";",
"limit",
"=",
"limit",
"||",
"arr",
".",
"length",
"-",
"offset",
";",
"let",
"str",
"=",
"''",
";",
"for",
"(",
"let",
"i... | Converts a Uint8Array to a String.
@param {Uint8Array} array that should be converted
@param {Number} offset array offset in case only subset of array items should be extracted (default: 0)
@param {Number} limit maximum number of array items that should be extracted (defaults to length of array)
@returns {String} | [
"Converts",
"a",
"Uint8Array",
"to",
"a",
"String",
"."
] | 22bb19a19fc85aa6b34a9399734cd508d15f36ff | https://github.com/dcmjs-org/dicomweb-client/blob/22bb19a19fc85aa6b34a9399734cd508d15f36ff/src/message.js#L8-L16 |
16,929 | dcmjs-org/dicomweb-client | src/message.js | stringToUint8Array | function stringToUint8Array(str) {
const arr = new Uint8Array(str.length);
for (let i = 0, j = str.length; i < j; i++) {
arr[i] = str.charCodeAt(i);
}
return arr;
} | javascript | function stringToUint8Array(str) {
const arr = new Uint8Array(str.length);
for (let i = 0, j = str.length; i < j; i++) {
arr[i] = str.charCodeAt(i);
}
return arr;
} | [
"function",
"stringToUint8Array",
"(",
"str",
")",
"{",
"const",
"arr",
"=",
"new",
"Uint8Array",
"(",
"str",
".",
"length",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"j",
"=",
"str",
".",
"length",
";",
"i",
"<",
"j",
";",
"i",
"++",
")... | Converts a String to a Uint8Array.
@param {String} str string that should be converted
@returns {Uint8Array} | [
"Converts",
"a",
"String",
"to",
"a",
"Uint8Array",
"."
] | 22bb19a19fc85aa6b34a9399734cd508d15f36ff | https://github.com/dcmjs-org/dicomweb-client/blob/22bb19a19fc85aa6b34a9399734cd508d15f36ff/src/message.js#L24-L30 |
16,930 | dcmjs-org/dicomweb-client | src/message.js | containsToken | function containsToken(message, token, offset=0) {
if (offset + token.length > message.length) {
return false;
}
let index = offset;
for (let i = 0; i < token.length; i++) {
if (token[i] !== message[index++]) {
return false;
}
}
return true;
} | javascript | function containsToken(message, token, offset=0) {
if (offset + token.length > message.length) {
return false;
}
let index = offset;
for (let i = 0; i < token.length; i++) {
if (token[i] !== message[index++]) {
return false;
}
}
return true;
} | [
"function",
"containsToken",
"(",
"message",
",",
"token",
",",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"offset",
"+",
"token",
".",
"length",
">",
"message",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"let",
"index",
"=",
"offset",
";",
... | Checks whether a given token is contained by a message at a given offset.
@param {Uint8Array} message message content
@param {Uint8Array} token substring that should be present
@param {Number} offset offset in message content from where search should start
@returns {Boolean} whether message contains token at offset | [
"Checks",
"whether",
"a",
"given",
"token",
"is",
"contained",
"by",
"a",
"message",
"at",
"a",
"given",
"offset",
"."
] | 22bb19a19fc85aa6b34a9399734cd508d15f36ff | https://github.com/dcmjs-org/dicomweb-client/blob/22bb19a19fc85aa6b34a9399734cd508d15f36ff/src/message.js#L56-L68 |
16,931 | dcmjs-org/dicomweb-client | src/message.js | findToken | function findToken(message, token, offset=0, maxSearchLength) {
let searchLength = message.length;
if (maxSearchLength) {
searchLength = Math.min(offset + maxSearchLength, message.length);
}
for (let i = offset; i < searchLength; i++) {
// If the first value of the message matches
// the first valu... | javascript | function findToken(message, token, offset=0, maxSearchLength) {
let searchLength = message.length;
if (maxSearchLength) {
searchLength = Math.min(offset + maxSearchLength, message.length);
}
for (let i = offset; i < searchLength; i++) {
// If the first value of the message matches
// the first valu... | [
"function",
"findToken",
"(",
"message",
",",
"token",
",",
"offset",
"=",
"0",
",",
"maxSearchLength",
")",
"{",
"let",
"searchLength",
"=",
"message",
".",
"length",
";",
"if",
"(",
"maxSearchLength",
")",
"{",
"searchLength",
"=",
"Math",
".",
"min",
... | Finds a given token in a message at a given offset.
@param {Uint8Array} message message content
@param {Uint8Array} token substring that should be found
@param {String} offset message body offset from where search should start
@returns {Boolean} whether message has a part at given offset or not | [
"Finds",
"a",
"given",
"token",
"in",
"a",
"message",
"at",
"a",
"given",
"offset",
"."
] | 22bb19a19fc85aa6b34a9399734cd508d15f36ff | https://github.com/dcmjs-org/dicomweb-client/blob/22bb19a19fc85aa6b34a9399734cd508d15f36ff/src/message.js#L78-L96 |
16,932 | dcmjs-org/dicomweb-client | src/message.js | multipartDecode | function multipartDecode(response) {
const message = new Uint8Array(response);
/* Set a maximum length to search for the header boundaries, otherwise
findToken can run for a long time
*/
const maxSearchLength = 1000;
// First look for the multipart mime header
let separator = stringToU... | javascript | function multipartDecode(response) {
const message = new Uint8Array(response);
/* Set a maximum length to search for the header boundaries, otherwise
findToken can run for a long time
*/
const maxSearchLength = 1000;
// First look for the multipart mime header
let separator = stringToU... | [
"function",
"multipartDecode",
"(",
"response",
")",
"{",
"const",
"message",
"=",
"new",
"Uint8Array",
"(",
"response",
")",
";",
"/* Set a maximum length to search for the header boundaries, otherwise\n findToken can run for a long time\n */",
"const",
"maxSearchLength",... | Decode a Multipart encoded ArrayBuffer and return the components as an Array.
@param {ArrayBuffer} response Data encoded as a 'multipart/related' message
@returns {Array} The content | [
"Decode",
"a",
"Multipart",
"encoded",
"ArrayBuffer",
"and",
"return",
"the",
"components",
"as",
"an",
"Array",
"."
] | 22bb19a19fc85aa6b34a9399734cd508d15f36ff | https://github.com/dcmjs-org/dicomweb-client/blob/22bb19a19fc85aa6b34a9399734cd508d15f36ff/src/message.js#L164-L219 |
16,933 | koola/pix-diff | lib/camelCase.js | camelCase | function camelCase(text) {
text = text || '';
return text.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => {
return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
}).replace(/\s+/g, '');
} | javascript | function camelCase(text) {
text = text || '';
return text.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter, index) => {
return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
}).replace(/\s+/g, '');
} | [
"function",
"camelCase",
"(",
"text",
")",
"{",
"text",
"=",
"text",
"||",
"''",
";",
"return",
"text",
".",
"replace",
"(",
"/",
"(?:^\\w|[A-Z]|\\b\\w)",
"/",
"g",
",",
"(",
"letter",
",",
"index",
")",
"=>",
"{",
"return",
"index",
"===",
"0",
"?",... | Converts string to a camel cased string
@method camelCase
@param {string} text
@returns {string}
@public | [
"Converts",
"string",
"to",
"a",
"camel",
"cased",
"string"
] | 0402b9bec5f1d577ef0b73419ac8e52f52cad81b | https://github.com/koola/pix-diff/blob/0402b9bec5f1d577ef0b73419ac8e52f52cad81b/lib/camelCase.js#L12-L17 |
16,934 | wireapp/wire-web-packages | packages/cryptobox/src/demo/benchmark.js | createCryptobox | async function createCryptobox(storeName, amountOfPreKeys = 1) {
const engine = new MemoryEngine();
await engine.init(storeName);
return new Cryptobox(engine, amountOfPreKeys);
} | javascript | async function createCryptobox(storeName, amountOfPreKeys = 1) {
const engine = new MemoryEngine();
await engine.init(storeName);
return new Cryptobox(engine, amountOfPreKeys);
} | [
"async",
"function",
"createCryptobox",
"(",
"storeName",
",",
"amountOfPreKeys",
"=",
"1",
")",
"{",
"const",
"engine",
"=",
"new",
"MemoryEngine",
"(",
")",
";",
"await",
"engine",
".",
"init",
"(",
"storeName",
")",
";",
"return",
"new",
"Cryptobox",
"(... | Creates a Cryptobox with an initialized store. | [
"Creates",
"a",
"Cryptobox",
"with",
"an",
"initialized",
"store",
"."
] | b352ac2ba63bf069f13f3d0c706cbb98f2f8e719 | https://github.com/wireapp/wire-web-packages/blob/b352ac2ba63bf069f13f3d0c706cbb98f2f8e719/packages/cryptobox/src/demo/benchmark.js#L25-L29 |
16,935 | wireapp/wire-web-packages | packages/cryptobox/src/demo/benchmark.js | initialSetup | async function initialSetup() {
const alice = await createCryptobox('alice', 1);
await alice.create();
const bob = await createCryptobox('bob', 1);
await bob.create();
const bobBundle = Proteus.keys.PreKeyBundle.new(
bob.identity.public_key,
await bob.store.load_prekey(Proteus.keys.PreKey.MAX_PREKEY... | javascript | async function initialSetup() {
const alice = await createCryptobox('alice', 1);
await alice.create();
const bob = await createCryptobox('bob', 1);
await bob.create();
const bobBundle = Proteus.keys.PreKeyBundle.new(
bob.identity.public_key,
await bob.store.load_prekey(Proteus.keys.PreKey.MAX_PREKEY... | [
"async",
"function",
"initialSetup",
"(",
")",
"{",
"const",
"alice",
"=",
"await",
"createCryptobox",
"(",
"'alice'",
",",
"1",
")",
";",
"await",
"alice",
".",
"create",
"(",
")",
";",
"const",
"bob",
"=",
"await",
"createCryptobox",
"(",
"'bob'",
",",... | Creates participants and establishes sessions between them. | [
"Creates",
"participants",
"and",
"establishes",
"sessions",
"between",
"them",
"."
] | b352ac2ba63bf069f13f3d0c706cbb98f2f8e719 | https://github.com/wireapp/wire-web-packages/blob/b352ac2ba63bf069f13f3d0c706cbb98f2f8e719/packages/cryptobox/src/demo/benchmark.js#L32-L48 |
16,936 | wireapp/wire-web-packages | packages/cryptobox/src/demo/benchmark.js | encryptBeforeDecrypt | async function encryptBeforeDecrypt({alice, bob}, messageCount) {
const numbers = numbersInArray(messageCount);
// Encryption
process.stdout.write(`Measuring encryption time for "${messageCount}" messages ... `);
let startTime = process.hrtime();
const encryptedMessages = await Promise.all(
numbers.map(v... | javascript | async function encryptBeforeDecrypt({alice, bob}, messageCount) {
const numbers = numbersInArray(messageCount);
// Encryption
process.stdout.write(`Measuring encryption time for "${messageCount}" messages ... `);
let startTime = process.hrtime();
const encryptedMessages = await Promise.all(
numbers.map(v... | [
"async",
"function",
"encryptBeforeDecrypt",
"(",
"{",
"alice",
",",
"bob",
"}",
",",
"messageCount",
")",
"{",
"const",
"numbers",
"=",
"numbersInArray",
"(",
"messageCount",
")",
";",
"// Encryption",
"process",
".",
"stdout",
".",
"write",
"(",
"`",
"${",... | Runs the test scenario and measures times. | [
"Runs",
"the",
"test",
"scenario",
"and",
"measures",
"times",
"."
] | b352ac2ba63bf069f13f3d0c706cbb98f2f8e719 | https://github.com/wireapp/wire-web-packages/blob/b352ac2ba63bf069f13f3d0c706cbb98f2f8e719/packages/cryptobox/src/demo/benchmark.js#L51-L75 |
16,937 | donatj/CsvToMarkdownTable | lib/CsvToMarkdown.js | csvToMarkdown | function csvToMarkdown(csvContent, delimiter, hasHeader) {
if (delimiter === void 0) { delimiter = "\t"; }
if (hasHeader === void 0) { hasHeader = false; }
if (delimiter != "\t") {
csvContent = csvContent.replace(/\t/g, " ");
}
var columns = csvContent.split("\n");
var tabularData = [... | javascript | function csvToMarkdown(csvContent, delimiter, hasHeader) {
if (delimiter === void 0) { delimiter = "\t"; }
if (hasHeader === void 0) { hasHeader = false; }
if (delimiter != "\t") {
csvContent = csvContent.replace(/\t/g, " ");
}
var columns = csvContent.split("\n");
var tabularData = [... | [
"function",
"csvToMarkdown",
"(",
"csvContent",
",",
"delimiter",
",",
"hasHeader",
")",
"{",
"if",
"(",
"delimiter",
"===",
"void",
"0",
")",
"{",
"delimiter",
"=",
"\"\\t\"",
";",
"}",
"if",
"(",
"hasHeader",
"===",
"void",
"0",
")",
"{",
"hasHeader",
... | Converts CSV to Markdown Table
@param {string} csvContent - The string content of the CSV
@param {string} delimiter - The character(s) to use as the CSV column delimiter
@param {boolean} hasHeader - Whether to use the first row of Data as headers
@returns {string} | [
"Converts",
"CSV",
"to",
"Markdown",
"Table"
] | 2f3182f99e84a88f393d0d02d23e9dc7e499b2f3 | https://github.com/donatj/CsvToMarkdownTable/blob/2f3182f99e84a88f393d0d02d23e9dc7e499b2f3/lib/CsvToMarkdown.js#L11-L67 |
16,938 | wcm-io-frontend/aem-clientlib-generator | lib/clientlib.js | writeClientLibJson | function writeClientLibJson(item, options) {
var content = {
'jcr:primaryType': 'cq:ClientLibraryFolder'
};
// if categories is a config entry append the values to the array, else use item.name
if (item.hasOwnProperty('categories')) {
content.categories = item['categories'];
} else {
content.cate... | javascript | function writeClientLibJson(item, options) {
var content = {
'jcr:primaryType': 'cq:ClientLibraryFolder'
};
// if categories is a config entry append the values to the array, else use item.name
if (item.hasOwnProperty('categories')) {
content.categories = item['categories'];
} else {
content.cate... | [
"function",
"writeClientLibJson",
"(",
"item",
",",
"options",
")",
"{",
"var",
"content",
"=",
"{",
"'jcr:primaryType'",
":",
"'cq:ClientLibraryFolder'",
"}",
";",
"// if categories is a config entry append the values to the array, else use item.name",
"if",
"(",
"item",
"... | Write a configuration JSON file for a clientlib
with the given properties in `item`
@param {ClientLibItem} item - clientlib configuration properties
@param {Object} options - further options | [
"Write",
"a",
"configuration",
"JSON",
"file",
"for",
"a",
"clientlib",
"with",
"the",
"given",
"properties",
"in",
"item"
] | 1693581f1da375f8c5ac60a33e5e1636df6e8f35 | https://github.com/wcm-io-frontend/aem-clientlib-generator/blob/1693581f1da375f8c5ac60a33e5e1636df6e8f35/lib/clientlib.js#L154-L178 |
16,939 | wcm-io-frontend/aem-clientlib-generator | lib/clientlib.js | writeClientLibXml | function writeClientLibXml(item, options) {
var content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' +
' jcr:primaryType="cq:ClientLibraryFolder"';
if (item.hasOwnProperty('categories')) {
var fi... | javascript | function writeClientLibXml(item, options) {
var content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' +
' jcr:primaryType="cq:ClientLibraryFolder"';
if (item.hasOwnProperty('categories')) {
var fi... | [
"function",
"writeClientLibXml",
"(",
"item",
",",
"options",
")",
"{",
"var",
"content",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\"?>'",
"+",
"'<jcr:root xmlns:cq=\"http://www.day.com/jcr/cq/1.0\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"'",
"+",
"' jcr:primaryType=\"cq:ClientLibr... | Write a configuration XML file for a clientlib
with the given properties in `item`
@param {ClientLibItem} item - clientlib configuration properties
@param {Object} options - further options | [
"Write",
"a",
"configuration",
"XML",
"file",
"for",
"a",
"clientlib",
"with",
"the",
"given",
"properties",
"in",
"item"
] | 1693581f1da375f8c5ac60a33e5e1636df6e8f35 | https://github.com/wcm-io-frontend/aem-clientlib-generator/blob/1693581f1da375f8c5ac60a33e5e1636df6e8f35/lib/clientlib.js#L186-L221 |
16,940 | wcm-io-frontend/aem-clientlib-generator | lib/clientlib.js | start | function start(itemList, options, done) {
if (_.isFunction(options)) {
done = options;
options = {};
}
if (!_.isArray(itemList)) {
itemList = [itemList];
}
if (options.context || options.cwd) {
options.cwd = options.context || options.cwd;
process.chdir(options.cwd);
}
if (options.... | javascript | function start(itemList, options, done) {
if (_.isFunction(options)) {
done = options;
options = {};
}
if (!_.isArray(itemList)) {
itemList = [itemList];
}
if (options.context || options.cwd) {
options.cwd = options.context || options.cwd;
process.chdir(options.cwd);
}
if (options.... | [
"function",
"start",
"(",
"itemList",
",",
"options",
",",
"done",
")",
"{",
"if",
"(",
"_",
".",
"isFunction",
"(",
"options",
")",
")",
"{",
"done",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isArray",
... | Iterate through the given array of clientlib configuration objects and
process them asynchronously.
@param {Array<ClientLibItem>} itemList - array of clientlib configuration items
@param {Object} [options] - global configuration options
@param {Function} done - to be called if everything is done | [
"Iterate",
"through",
"the",
"given",
"array",
"of",
"clientlib",
"configuration",
"objects",
"and",
"process",
"them",
"asynchronously",
"."
] | 1693581f1da375f8c5ac60a33e5e1636df6e8f35 | https://github.com/wcm-io-frontend/aem-clientlib-generator/blob/1693581f1da375f8c5ac60a33e5e1636df6e8f35/lib/clientlib.js#L230-L255 |
16,941 | wcm-io-frontend/aem-clientlib-generator | lib/clientlib.js | normalizeAssets | function normalizeAssets(clientLibPath, assets) {
var list = assets;
// transform object to array
if (!_.isArray(assets)) {
list = [];
_.keys(assets).forEach(function (assetKey) {
var assetItem = assets[assetKey];
// check/transform short version
if (_.isArray(assetItem)) {
as... | javascript | function normalizeAssets(clientLibPath, assets) {
var list = assets;
// transform object to array
if (!_.isArray(assets)) {
list = [];
_.keys(assets).forEach(function (assetKey) {
var assetItem = assets[assetKey];
// check/transform short version
if (_.isArray(assetItem)) {
as... | [
"function",
"normalizeAssets",
"(",
"clientLibPath",
",",
"assets",
")",
"{",
"var",
"list",
"=",
"assets",
";",
"// transform object to array",
"if",
"(",
"!",
"_",
".",
"isArray",
"(",
"assets",
")",
")",
"{",
"list",
"=",
"[",
"]",
";",
"_",
".",
"k... | Normalize different asset configuration options.
@param {String} clientLibPath - clientlib subfolder
@param {Object} assets - asset configuration object
@returns {*} | [
"Normalize",
"different",
"asset",
"configuration",
"options",
"."
] | 1693581f1da375f8c5ac60a33e5e1636df6e8f35 | https://github.com/wcm-io-frontend/aem-clientlib-generator/blob/1693581f1da375f8c5ac60a33e5e1636df6e8f35/lib/clientlib.js#L263-L351 |
16,942 | wcm-io-frontend/aem-clientlib-generator | lib/clientlib.js | processItem | function processItem(item, options, processDone) {
if (!item.path) {
item.path = options.clientLibRoot;
}
options.verbose && console.log("\n\nprocessing clientlib: " + item.name);
// remove current files if exists
removeClientLib(item, function (err) {
var clientLibPath = item.outputPath || path.j... | javascript | function processItem(item, options, processDone) {
if (!item.path) {
item.path = options.clientLibRoot;
}
options.verbose && console.log("\n\nprocessing clientlib: " + item.name);
// remove current files if exists
removeClientLib(item, function (err) {
var clientLibPath = item.outputPath || path.j... | [
"function",
"processItem",
"(",
"item",
",",
"options",
",",
"processDone",
")",
"{",
"if",
"(",
"!",
"item",
".",
"path",
")",
"{",
"item",
".",
"path",
"=",
"options",
".",
"clientLibRoot",
";",
"}",
"options",
".",
"verbose",
"&&",
"console",
".",
... | Process the given clientlib configuration object.
@param {ClientLibItem} item - clientlib configuration object
@param {Object} options - configuration options
@param {Function} processDone - to be called if everything is done | [
"Process",
"the",
"given",
"clientlib",
"configuration",
"object",
"."
] | 1693581f1da375f8c5ac60a33e5e1636df6e8f35 | https://github.com/wcm-io-frontend/aem-clientlib-generator/blob/1693581f1da375f8c5ac60a33e5e1636df6e8f35/lib/clientlib.js#L359-L418 |
16,943 | vsiakka/gherkin-lint | src/rules/no-restricted-patterns.js | checkFeatureChildNode | function checkFeatureChildNode(node, restrictedPatterns, errors) {
checkNameAndDescription(node, restrictedPatterns, errors);
node.steps.forEach(function(step) {
// Use the node type of the parent to determine which rule configuration to use
checkStepNode(step, restrictedPatterns[node.type], errors);
});
... | javascript | function checkFeatureChildNode(node, restrictedPatterns, errors) {
checkNameAndDescription(node, restrictedPatterns, errors);
node.steps.forEach(function(step) {
// Use the node type of the parent to determine which rule configuration to use
checkStepNode(step, restrictedPatterns[node.type], errors);
});
... | [
"function",
"checkFeatureChildNode",
"(",
"node",
",",
"restrictedPatterns",
",",
"errors",
")",
"{",
"checkNameAndDescription",
"(",
"node",
",",
"restrictedPatterns",
",",
"errors",
")",
";",
"node",
".",
"steps",
".",
"forEach",
"(",
"function",
"(",
"step",
... | Background, Scenarios and Scenario Outlines are children of a feature | [
"Background",
"Scenarios",
"and",
"Scenario",
"Outlines",
"are",
"children",
"of",
"a",
"feature"
] | 59ea830b8d84e95642290d74f6e8ff592f8c849a | https://github.com/vsiakka/gherkin-lint/blob/59ea830b8d84e95642290d74f6e8ff592f8c849a/src/rules/no-restricted-patterns.js#L54-L60 |
16,944 | vsiakka/gherkin-lint | src/feature-finder.js | getFeatureFiles | function getFeatureFiles(args, ignoreArg) {
var files = [];
var patterns = args.length ? args : ['.'];
patterns.forEach(function(pattern) {
// First we need to fix up the pattern so that it only matches .feature files
// and it's in the format that glob expects it to be
var fixedPattern;
if (patt... | javascript | function getFeatureFiles(args, ignoreArg) {
var files = [];
var patterns = args.length ? args : ['.'];
patterns.forEach(function(pattern) {
// First we need to fix up the pattern so that it only matches .feature files
// and it's in the format that glob expects it to be
var fixedPattern;
if (patt... | [
"function",
"getFeatureFiles",
"(",
"args",
",",
"ignoreArg",
")",
"{",
"var",
"files",
"=",
"[",
"]",
";",
"var",
"patterns",
"=",
"args",
".",
"length",
"?",
"args",
":",
"[",
"'.'",
"]",
";",
"patterns",
".",
"forEach",
"(",
"function",
"(",
"patt... | Ignore node_modules by default | [
"Ignore",
"node_modules",
"by",
"default"
] | 59ea830b8d84e95642290d74f6e8ff592f8c849a | https://github.com/vsiakka/gherkin-lint/blob/59ea830b8d84e95642290d74f6e8ff592f8c849a/src/feature-finder.js#L10-L44 |
16,945 | CleverCloud/clever-tools | src/models/log.js | getContinuousLogs | function getContinuousLogs (api, appId, before, after, search, deploymentId) {
function makeUrl (retryTimestamp) {
const newAfter = retryTimestamp === null || after.getTime() > retryTimestamp.getTime() ? after : retryTimestamp;
return getWsLogUrl(appId, newAfter.toISOString(), search, deploymentId);
};
r... | javascript | function getContinuousLogs (api, appId, before, after, search, deploymentId) {
function makeUrl (retryTimestamp) {
const newAfter = retryTimestamp === null || after.getTime() > retryTimestamp.getTime() ? after : retryTimestamp;
return getWsLogUrl(appId, newAfter.toISOString(), search, deploymentId);
};
r... | [
"function",
"getContinuousLogs",
"(",
"api",
",",
"appId",
",",
"before",
",",
"after",
",",
"search",
",",
"deploymentId",
")",
"{",
"function",
"makeUrl",
"(",
"retryTimestamp",
")",
"{",
"const",
"newAfter",
"=",
"retryTimestamp",
"===",
"null",
"||",
"af... | Get logs as they arrive from a web socket.
Automatically reconnect if the connexion is closed.
api: The API object
appId: The appId of the application
before (Date): only display log lines that happened before this date
after (Date): only display log lines that happened after this date
deploymentId: Only display log ... | [
"Get",
"logs",
"as",
"they",
"arrive",
"from",
"a",
"web",
"socket",
".",
"Automatically",
"reconnect",
"if",
"the",
"connexion",
"is",
"closed",
"."
] | 82fbfadf7ae33cfa61d93148432a98c1274a877d | https://github.com/CleverCloud/clever-tools/blob/82fbfadf7ae33cfa61d93148432a98c1274a877d/src/models/log.js#L43-L57 |
16,946 | CleverCloud/clever-tools | src/models/ws-stream.js | openStream | function openStream (makeUrl, authorization, endTimestamp, retries = MAX_RETRY_COUNT) {
const endTs = endTimestamp || null;
const s_websocket = openWebSocket(makeUrl(endTs), authorization);
// Stream which contains only one element: the date at which the websocket closed
const s_endTimestamp = s_websocket.filt... | javascript | function openStream (makeUrl, authorization, endTimestamp, retries = MAX_RETRY_COUNT) {
const endTs = endTimestamp || null;
const s_websocket = openWebSocket(makeUrl(endTs), authorization);
// Stream which contains only one element: the date at which the websocket closed
const s_endTimestamp = s_websocket.filt... | [
"function",
"openStream",
"(",
"makeUrl",
",",
"authorization",
",",
"endTimestamp",
",",
"retries",
"=",
"MAX_RETRY_COUNT",
")",
"{",
"const",
"endTs",
"=",
"endTimestamp",
"||",
"null",
";",
"const",
"s_websocket",
"=",
"openWebSocket",
"(",
"makeUrl",
"(",
... | Open a never-ending stream of events, backed by a websocket.
If websocket connection is closed, it is automatically re-opened.
Ping messages are regularly sent to the server to keep the connection alive and
avoid disconnections.
makeUrl: Timestamp => String :
The WS URL can be constructed based on the closing date, in... | [
"Open",
"a",
"never",
"-",
"ending",
"stream",
"of",
"events",
"backed",
"by",
"a",
"websocket",
".",
"If",
"websocket",
"connection",
"is",
"closed",
"it",
"is",
"automatically",
"re",
"-",
"opened",
".",
"Ping",
"messages",
"are",
"regularly",
"sent",
"t... | 82fbfadf7ae33cfa61d93148432a98c1274a877d | https://github.com/CleverCloud/clever-tools/blob/82fbfadf7ae33cfa61d93148432a98c1274a877d/src/models/ws-stream.js#L65-L82 |
16,947 | CleverCloud/clever-tools | src/commands/login.js | randomToken | function randomToken () {
return crypto.randomBytes(20).toString('base64').replace(/\//g, '-').replace(/\+/g, '_').replace(/=/g, '');
} | javascript | function randomToken () {
return crypto.randomBytes(20).toString('base64').replace(/\//g, '-').replace(/\+/g, '_').replace(/=/g, '');
} | [
"function",
"randomToken",
"(",
")",
"{",
"return",
"crypto",
".",
"randomBytes",
"(",
"20",
")",
".",
"toString",
"(",
"'base64'",
")",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'-'",
")",
".",
"replace",
"(",
"/",
"\\+",
"/",
"g",
",",
"... | 20 random bytes as Base64URL | [
"20",
"random",
"bytes",
"as",
"Base64URL"
] | 82fbfadf7ae33cfa61d93148432a98c1274a877d | https://github.com/CleverCloud/clever-tools/blob/82fbfadf7ae33cfa61d93148432a98c1274a877d/src/commands/login.js#L19-L21 |
16,948 | CleverCloud/clever-tools | src/models/addon.js | performPreorder | function performPreorder (api, orgaId, name, planId, providerId, region) {
const params = orgaId ? [orgaId] : [];
return api.owner(orgaId).addons.preorders.post().withParams(params).send(JSON.stringify({
name: name,
plan: planId,
providerId: providerId,
region: region,
}));
} | javascript | function performPreorder (api, orgaId, name, planId, providerId, region) {
const params = orgaId ? [orgaId] : [];
return api.owner(orgaId).addons.preorders.post().withParams(params).send(JSON.stringify({
name: name,
plan: planId,
providerId: providerId,
region: region,
}));
} | [
"function",
"performPreorder",
"(",
"api",
",",
"orgaId",
",",
"name",
",",
"planId",
",",
"providerId",
",",
"region",
")",
"{",
"const",
"params",
"=",
"orgaId",
"?",
"[",
"orgaId",
"]",
":",
"[",
"]",
";",
"return",
"api",
".",
"owner",
"(",
"orga... | Generate a preview creation, to get access to the price that will be charged,
as well as to verify that the payment methods are correctly configured | [
"Generate",
"a",
"preview",
"creation",
"to",
"get",
"access",
"to",
"the",
"price",
"that",
"will",
"be",
"charged",
"as",
"well",
"as",
"to",
"verify",
"that",
"the",
"payment",
"methods",
"are",
"correctly",
"configured"
] | 82fbfadf7ae33cfa61d93148432a98c1274a877d | https://github.com/CleverCloud/clever-tools/blob/82fbfadf7ae33cfa61d93148432a98c1274a877d/src/models/addon.js#L103-L111 |
16,949 | latelierco/vue-application-insights | src/index.js | setupPageTracking | function setupPageTracking(options, Vue) {
const router = options.router
const baseName = options.baseName || '(Vue App)'
router.beforeEach( (route, from, next) => {
const name = baseName + ' / ' + route.name;
Vue.appInsights.startTrackPage(name)
next()
})
router.afterEach( route => {
cons... | javascript | function setupPageTracking(options, Vue) {
const router = options.router
const baseName = options.baseName || '(Vue App)'
router.beforeEach( (route, from, next) => {
const name = baseName + ' / ' + route.name;
Vue.appInsights.startTrackPage(name)
next()
})
router.afterEach( route => {
cons... | [
"function",
"setupPageTracking",
"(",
"options",
",",
"Vue",
")",
"{",
"const",
"router",
"=",
"options",
".",
"router",
"const",
"baseName",
"=",
"options",
".",
"baseName",
"||",
"'(Vue App)'",
"router",
".",
"beforeEach",
"(",
"(",
"route",
",",
"from",
... | Track route changes as page views with AppInsights
@param options | [
"Track",
"route",
"changes",
"as",
"page",
"views",
"with",
"AppInsights"
] | 9f9d7cfddc2a8f9f67c0776a2f285910775d412b | https://github.com/latelierco/vue-application-insights/blob/9f9d7cfddc2a8f9f67c0776a2f285910775d412b/src/index.js#L44-L61 |
16,950 | mapbox/cwlogs | lib/readable.js | readable | function readable(options) {
options = options || {};
if (!options.region || typeof options.region !== 'string') return invalid();
if (!options.group || typeof options.group !== 'string') return invalid();
if (options.start && typeof options.start !== 'number') return invalid();
if (options.end && typeof opt... | javascript | function readable(options) {
options = options || {};
if (!options.region || typeof options.region !== 'string') return invalid();
if (!options.group || typeof options.group !== 'string') return invalid();
if (options.start && typeof options.start !== 'number') return invalid();
if (options.end && typeof opt... | [
"function",
"readable",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"options",
".",
"region",
"||",
"typeof",
"options",
".",
"region",
"!==",
"'string'",
")",
"return",
"invalid",
"(",
")",
";",
"if",
"(... | Provide a readable stream of log events for a particular log group
@memberof cwlogs
@param {object} options - default Node.js [ReadableStream options](https://nodejs.org/api/stream.html#stream_class_stream_readable_1)
with extensions detailed below.
@param {string} options.group - the name of the LogGroup to read
@par... | [
"Provide",
"a",
"readable",
"stream",
"of",
"log",
"events",
"for",
"a",
"particular",
"log",
"group"
] | 15fd2140b52fff29c676c6d3972066235f5159e2 | https://github.com/mapbox/cwlogs/blob/15fd2140b52fff29c676c6d3972066235f5159e2/lib/readable.js#L35-L95 |
16,951 | joe-sky/nornj | dist/nornj.runtime.common.js | camelCase | function camelCase(str) {
if (str.indexOf('-') > -1) {
str = str.replace(/-\w/g, function (letter) {
return letter.substr(1).toUpperCase();
});
}
return str;
} | javascript | function camelCase(str) {
if (str.indexOf('-') > -1) {
str = str.replace(/-\w/g, function (letter) {
return letter.substr(1).toUpperCase();
});
}
return str;
} | [
"function",
"camelCase",
"(",
"str",
")",
"{",
"if",
"(",
"str",
".",
"indexOf",
"(",
"'-'",
")",
">",
"-",
"1",
")",
"{",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"-\\w",
"/",
"g",
",",
"function",
"(",
"letter",
")",
"{",
"return",
"lette... | Transform to camel-case | [
"Transform",
"to",
"camel",
"-",
"case"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L207-L215 |
16,952 | joe-sky/nornj | dist/nornj.runtime.common.js | getData | function getData(prop, data, hasSource) {
var value, obj;
if (!data) {
data = this.data;
}
for (var i = 0, l = data.length; i < l; i++) {
obj = data[i];
if (obj) {
value = obj[prop];
if (value !== undefined) {
if (hasSource) {
return {
source: obj,
... | javascript | function getData(prop, data, hasSource) {
var value, obj;
if (!data) {
data = this.data;
}
for (var i = 0, l = data.length; i < l; i++) {
obj = data[i];
if (obj) {
value = obj[prop];
if (value !== undefined) {
if (hasSource) {
return {
source: obj,
... | [
"function",
"getData",
"(",
"prop",
",",
"data",
",",
"hasSource",
")",
"{",
"var",
"value",
",",
"obj",
";",
"if",
"(",
"!",
"data",
")",
"{",
"data",
"=",
"this",
".",
"data",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"data... | Get value from multiple datas | [
"Get",
"value",
"from",
"multiple",
"datas"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L421-L448 |
16,953 | joe-sky/nornj | dist/nornj.runtime.common.js | newContext | function newContext(context, params) {
if (!params) {
return context;
}
return assign({}, context, {
data: params.data ? arrayPush(params.data, context.data) : context.data,
parent: params.newParent ? context : context.parent,
index: 'index' in params ? params.index : context.index,
item: 'it... | javascript | function newContext(context, params) {
if (!params) {
return context;
}
return assign({}, context, {
data: params.data ? arrayPush(params.data, context.data) : context.data,
parent: params.newParent ? context : context.parent,
index: 'index' in params ? params.index : context.index,
item: 'it... | [
"function",
"newContext",
"(",
"context",
",",
"params",
")",
"{",
"if",
"(",
"!",
"params",
")",
"{",
"return",
"context",
";",
"}",
"return",
"assign",
"(",
"{",
"}",
",",
"context",
",",
"{",
"data",
":",
"params",
".",
"data",
"?",
"arrayPush",
... | Rebuild local variables in the new context | [
"Rebuild",
"local",
"variables",
"in",
"the",
"new",
"context"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L497-L508 |
16,954 | joe-sky/nornj | dist/nornj.runtime.common.js | registerExtension | function registerExtension(name, extension, options, mergeConfig) {
var params = name;
if (!isObject(name)) {
params = {};
params[name] = {
extension: extension,
options: options
};
}
each(params, function (v, name) {
if (v) {
var _extension = v.extension,
_options3... | javascript | function registerExtension(name, extension, options, mergeConfig) {
var params = name;
if (!isObject(name)) {
params = {};
params[name] = {
extension: extension,
options: options
};
}
each(params, function (v, name) {
if (v) {
var _extension = v.extension,
_options3... | [
"function",
"registerExtension",
"(",
"name",
",",
"extension",
",",
"options",
",",
"mergeConfig",
")",
"{",
"var",
"params",
"=",
"name",
";",
"if",
"(",
"!",
"isObject",
"(",
"name",
")",
")",
"{",
"params",
"=",
"{",
"}",
";",
"params",
"[",
"nam... | Register extension and also can batch add | [
"Register",
"extension",
"and",
"also",
"can",
"batch",
"add"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L985-L1018 |
16,955 | joe-sky/nornj | dist/nornj.runtime.common.js | _ | function _(obj, prop, options) {
if (obj == null) {
return obj;
}
return getAccessorData(obj[prop], options.context);
} | javascript | function _(obj, prop, options) {
if (obj == null) {
return obj;
}
return getAccessorData(obj[prop], options.context);
} | [
"function",
"_",
"(",
"obj",
",",
"prop",
",",
"options",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"obj",
";",
"}",
"return",
"getAccessorData",
"(",
"obj",
"[",
"prop",
"]",
",",
"options",
".",
"context",
")",
";",
"}"
] | Get accessor properties | [
"Get",
"accessor",
"properties"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L1066-L1072 |
16,956 | joe-sky/nornj | dist/nornj.runtime.common.js | int | function int(val) {
var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
var ret = parseInt(val, radix);
return isNaN(ret) ? 0 : ret;
} | javascript | function int(val) {
var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
var ret = parseInt(val, radix);
return isNaN(ret) ? 0 : ret;
} | [
"function",
"int",
"(",
"val",
")",
"{",
"var",
"radix",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"10",
";",
"var",
"ret",
"=",
"parseInt",
"(",
"val",
... | Convert to int | [
"Convert",
"to",
"int"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L1089-L1093 |
16,957 | joe-sky/nornj | dist/nornj.runtime.common.js | float | function float(val, bit) {
var ret = parseFloat(val);
return isNaN(ret) ? 0 : bit != null ? ret.toFixed(bit) : ret;
} | javascript | function float(val, bit) {
var ret = parseFloat(val);
return isNaN(ret) ? 0 : bit != null ? ret.toFixed(bit) : ret;
} | [
"function",
"float",
"(",
"val",
",",
"bit",
")",
"{",
"var",
"ret",
"=",
"parseFloat",
"(",
"val",
")",
";",
"return",
"isNaN",
"(",
"ret",
")",
"?",
"0",
":",
"bit",
"!=",
"null",
"?",
"ret",
".",
"toFixed",
"(",
"bit",
")",
":",
"ret",
";",
... | Convert to float | [
"Convert",
"to",
"float"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L1095-L1098 |
16,958 | joe-sky/nornj | dist/nornj.runtime.common.js | registerFilter | function registerFilter(name, filter, options, mergeConfig) {
var params = name;
if (!isObject(name)) {
params = {};
params[name] = {
filter: filter,
options: options
};
}
each(params, function (v, name) {
if (v) {
var _filter = v.filter,
_options = v.options;
... | javascript | function registerFilter(name, filter, options, mergeConfig) {
var params = name;
if (!isObject(name)) {
params = {};
params[name] = {
filter: filter,
options: options
};
}
each(params, function (v, name) {
if (v) {
var _filter = v.filter,
_options = v.options;
... | [
"function",
"registerFilter",
"(",
"name",
",",
"filter",
",",
"options",
",",
"mergeConfig",
")",
"{",
"var",
"params",
"=",
"name",
";",
"if",
"(",
"!",
"isObject",
"(",
"name",
")",
")",
"{",
"params",
"=",
"{",
"}",
";",
"params",
"[",
"name",
... | Register filter and also can batch add | [
"Register",
"filter",
"and",
"also",
"can",
"batch",
"add"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.runtime.common.js#L1240-L1294 |
16,959 | joe-sky/nornj | src/utils/createTmplRule.js | _clearRepeat | function _clearRepeat(str) {
let ret = '',
i = 0,
l = str.length,
char;
for (; i < l; i++) {
char = str[i];
if (ret.indexOf(char) < 0) {
ret += char;
}
}
return ret;
} | javascript | function _clearRepeat(str) {
let ret = '',
i = 0,
l = str.length,
char;
for (; i < l; i++) {
char = str[i];
if (ret.indexOf(char) < 0) {
ret += char;
}
}
return ret;
} | [
"function",
"_clearRepeat",
"(",
"str",
")",
"{",
"let",
"ret",
"=",
"''",
",",
"i",
"=",
"0",
",",
"l",
"=",
"str",
".",
"length",
",",
"char",
";",
"for",
"(",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"char",
"=",
"str",
"[",
"i",
... | Clear the repeated characters | [
"Clear",
"the",
"repeated",
"characters"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/src/utils/createTmplRule.js#L9-L23 |
16,960 | joe-sky/nornj | dist/nornj.common.js | getOpenTagParams | function getOpenTagParams(tag, tmplRule) {
var pattern = tmplRule.openTagParams,
matchArr,
ret;
while (matchArr = pattern.exec(tag)) {
var key = matchArr[1];
if (key === '/') {
//If match to the last of "/", then continue the loop.
continue;
}
if (!ret) {
ret = [];
... | javascript | function getOpenTagParams(tag, tmplRule) {
var pattern = tmplRule.openTagParams,
matchArr,
ret;
while (matchArr = pattern.exec(tag)) {
var key = matchArr[1];
if (key === '/') {
//If match to the last of "/", then continue the loop.
continue;
}
if (!ret) {
ret = [];
... | [
"function",
"getOpenTagParams",
"(",
"tag",
",",
"tmplRule",
")",
"{",
"var",
"pattern",
"=",
"tmplRule",
".",
"openTagParams",
",",
"matchArr",
",",
"ret",
";",
"while",
"(",
"matchArr",
"=",
"pattern",
".",
"exec",
"(",
"tag",
")",
")",
"{",
"var",
"... | Extract parameters inside the xml open tag | [
"Extract",
"parameters",
"inside",
"the",
"xml",
"open",
"tag"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.common.js#L1886-L1944 |
16,961 | joe-sky/nornj | dist/nornj.common.js | addParamsEx | function addParamsEx(node, parent, isDirective, isSubTag) {
var exPropsName = 'paramsEx';
if (!parent[exPropsName]) {
var exPropsNode;
if (isDirective || isSubTag) {
exPropsNode = {
type: 'nj_ex',
ex: 'props',
content: [node]
};
} else {
exPropsNode = node;
... | javascript | function addParamsEx(node, parent, isDirective, isSubTag) {
var exPropsName = 'paramsEx';
if (!parent[exPropsName]) {
var exPropsNode;
if (isDirective || isSubTag) {
exPropsNode = {
type: 'nj_ex',
ex: 'props',
content: [node]
};
} else {
exPropsNode = node;
... | [
"function",
"addParamsEx",
"(",
"node",
",",
"parent",
",",
"isDirective",
",",
"isSubTag",
")",
"{",
"var",
"exPropsName",
"=",
"'paramsEx'",
";",
"if",
"(",
"!",
"parent",
"[",
"exPropsName",
"]",
")",
"{",
"var",
"exPropsNode",
";",
"if",
"(",
"isDire... | Add to the "paramsEx" property of the parent node | [
"Add",
"to",
"the",
"paramsEx",
"property",
"of",
"the",
"parent",
"node"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.common.js#L1997-L2018 |
16,962 | joe-sky/nornj | dist/nornj.common.js | _setElem | function _setElem(elem, elemName, elemParams, elemArr, bySelfClose, tmplRule, outputH) {
var ret,
paramsEx,
fixedExTagName = fixExTagName(elemName, tmplRule);
if (fixedExTagName) {
elemName = fixedExTagName;
}
if (isEx(elemName, tmplRule, true)) {
ret = elem.substring(1, elem.length - 1);
... | javascript | function _setElem(elem, elemName, elemParams, elemArr, bySelfClose, tmplRule, outputH) {
var ret,
paramsEx,
fixedExTagName = fixExTagName(elemName, tmplRule);
if (fixedExTagName) {
elemName = fixedExTagName;
}
if (isEx(elemName, tmplRule, true)) {
ret = elem.substring(1, elem.length - 1);
... | [
"function",
"_setElem",
"(",
"elem",
",",
"elemName",
",",
"elemParams",
",",
"elemArr",
",",
"bySelfClose",
",",
"tmplRule",
",",
"outputH",
")",
"{",
"var",
"ret",
",",
"paramsEx",
",",
"fixedExTagName",
"=",
"fixExTagName",
"(",
"elemName",
",",
"tmplRule... | Set element node | [
"Set",
"element",
"node"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.common.js#L3353-L3394 |
16,963 | joe-sky/nornj | dist/nornj.common.js | _getSplitParams | function _getSplitParams(elem, tmplRule, outputH) {
var extensionRule = tmplRule.extensionRule,
startRule = tmplRule.startRule,
endRule = tmplRule.endRule,
firstChar = tmplRule.firstChar,
lastChar = tmplRule.lastChar,
spreadProp = tmplRule.spreadProp,
directives = tmplRule.directiv... | javascript | function _getSplitParams(elem, tmplRule, outputH) {
var extensionRule = tmplRule.extensionRule,
startRule = tmplRule.startRule,
endRule = tmplRule.endRule,
firstChar = tmplRule.firstChar,
lastChar = tmplRule.lastChar,
spreadProp = tmplRule.spreadProp,
directives = tmplRule.directiv... | [
"function",
"_getSplitParams",
"(",
"elem",
",",
"tmplRule",
",",
"outputH",
")",
"{",
"var",
"extensionRule",
"=",
"tmplRule",
".",
"extensionRule",
",",
"startRule",
"=",
"tmplRule",
".",
"startRule",
",",
"endRule",
"=",
"tmplRule",
".",
"endRule",
",",
"... | Extract split parameters | [
"Extract",
"split",
"parameters"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.common.js#L3398-L3465 |
16,964 | joe-sky/nornj | dist/nornj.common.js | _setSelfCloseElem | function _setSelfCloseElem(elem, elemName, elemParams, elemArr, tmplRule, outputH) {
if (/\/$/.test(elemName)) {
elemName = elemName.substr(0, elemName.length - 1);
}
_setElem(elem, elemName, elemParams, elemArr, true, tmplRule, outputH);
} | javascript | function _setSelfCloseElem(elem, elemName, elemParams, elemArr, tmplRule, outputH) {
if (/\/$/.test(elemName)) {
elemName = elemName.substr(0, elemName.length - 1);
}
_setElem(elem, elemName, elemParams, elemArr, true, tmplRule, outputH);
} | [
"function",
"_setSelfCloseElem",
"(",
"elem",
",",
"elemName",
",",
"elemParams",
",",
"elemArr",
",",
"tmplRule",
",",
"outputH",
")",
"{",
"if",
"(",
"/",
"\\/$",
"/",
".",
"test",
"(",
"elemName",
")",
")",
"{",
"elemName",
"=",
"elemName",
".",
"su... | Set self close element node | [
"Set",
"self",
"close",
"element",
"node"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/dist/nornj.common.js#L3468-L3474 |
16,965 | joe-sky/nornj | examples/backbone-marionette-nornj-todomvc/js/TodoMVC.Router.js | function () {
this.showHeader(this.todoList);
this.showFooter(this.todoList);
this.showTodoList(this.todoList);
this.todoList.on('all', this.updateHiddenElements, this);
this.todoList.fetch();
} | javascript | function () {
this.showHeader(this.todoList);
this.showFooter(this.todoList);
this.showTodoList(this.todoList);
this.todoList.on('all', this.updateHiddenElements, this);
this.todoList.fetch();
} | [
"function",
"(",
")",
"{",
"this",
".",
"showHeader",
"(",
"this",
".",
"todoList",
")",
";",
"this",
".",
"showFooter",
"(",
"this",
".",
"todoList",
")",
";",
"this",
".",
"showTodoList",
"(",
"this",
".",
"todoList",
")",
";",
"this",
".",
"todoLi... | Start the app by showing the appropriate views and fetching the list of todo items, if there are any | [
"Start",
"the",
"app",
"by",
"showing",
"the",
"appropriate",
"views",
"and",
"fetching",
"the",
"list",
"of",
"todo",
"items",
"if",
"there",
"are",
"any"
] | 63616d30475580bb358b56781a49aebb4a4fc967 | https://github.com/joe-sky/nornj/blob/63616d30475580bb358b56781a49aebb4a4fc967/examples/backbone-marionette-nornj-todomvc/js/TodoMVC.Router.js#L34-L40 | |
16,966 | mapbox/which-polygon | index.js | insidePolygon | function insidePolygon(rings, p) {
var inside = false;
for (var i = 0, len = rings.length; i < len; i++) {
var ring = rings[i];
for (var j = 0, len2 = ring.length, k = len2 - 1; j < len2; k = j++) {
if (rayIntersect(p, ring[j], ring[k])) inside = !inside;
}
}
return i... | javascript | function insidePolygon(rings, p) {
var inside = false;
for (var i = 0, len = rings.length; i < len; i++) {
var ring = rings[i];
for (var j = 0, len2 = ring.length, k = len2 - 1; j < len2; k = j++) {
if (rayIntersect(p, ring[j], ring[k])) inside = !inside;
}
}
return i... | [
"function",
"insidePolygon",
"(",
"rings",
",",
"p",
")",
"{",
"var",
"inside",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"rings",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"ring",
"=",
... | ray casting algorithm for detecting if point is in polygon | [
"ray",
"casting",
"algorithm",
"for",
"detecting",
"if",
"point",
"is",
"in",
"polygon"
] | e6faafe98ba4623e3c45fc00a24bdd018169f174 | https://github.com/mapbox/which-polygon/blob/e6faafe98ba4623e3c45fc00a24bdd018169f174/index.js#L78-L87 |
16,967 | mapbox/vtcomposite | bench/rules.js | getTiles | function getTiles(name) {
let tiles = [];
let dir = `./node_modules/@mapbox/mvt-fixtures/real-world/${name}`;
var files = fs.readdirSync(dir);
files.forEach(function(file) {
let buffer = fs.readFileSync(path.join(dir, '/', file));
file = file.replace('.mvt', '');
let zxy = file.split('-');
tiles... | javascript | function getTiles(name) {
let tiles = [];
let dir = `./node_modules/@mapbox/mvt-fixtures/real-world/${name}`;
var files = fs.readdirSync(dir);
files.forEach(function(file) {
let buffer = fs.readFileSync(path.join(dir, '/', file));
file = file.replace('.mvt', '');
let zxy = file.split('-');
tiles... | [
"function",
"getTiles",
"(",
"name",
")",
"{",
"let",
"tiles",
"=",
"[",
"]",
";",
"let",
"dir",
"=",
"`",
"${",
"name",
"}",
"`",
";",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
";",
"files",
".",
"forEach",
"(",
"function",... | get all tiles | [
"get",
"all",
"tiles"
] | baf3b420a6e3f4c8dab9f329dfa6caab9205c234 | https://github.com/mapbox/vtcomposite/blob/baf3b420a6e3f4c8dab9f329dfa6caab9205c234/bench/rules.js#L160-L171 |
16,968 | mapbox/osm-compare | comparators/new_user_footway.js | isFootway | function isFootway(newVersion) {
if (
newVersion.properties &&
newVersion.properties.highway === 'footway' &&
newVersion.properties['osm:version'] === 1
) {
return true;
}
return false;
} | javascript | function isFootway(newVersion) {
if (
newVersion.properties &&
newVersion.properties.highway === 'footway' &&
newVersion.properties['osm:version'] === 1
) {
return true;
}
return false;
} | [
"function",
"isFootway",
"(",
"newVersion",
")",
"{",
"if",
"(",
"newVersion",
".",
"properties",
"&&",
"newVersion",
".",
"properties",
".",
"highway",
"===",
"'footway'",
"&&",
"newVersion",
".",
"properties",
"[",
"'osm:version'",
"]",
"===",
"1",
")",
"{... | check if the user is new user check if the feature is actually a footway and it is version 1 check if the footway has imposible angle check if the footway is selfintersecting | [
"check",
"if",
"the",
"user",
"is",
"new",
"user",
"check",
"if",
"the",
"feature",
"is",
"actually",
"a",
"footway",
"and",
"it",
"is",
"version",
"1",
"check",
"if",
"the",
"footway",
"has",
"imposible",
"angle",
"check",
"if",
"the",
"footway",
"is",
... | 45b0d8bb2ab6a0db0981474da707296fc2eaec72 | https://github.com/mapbox/osm-compare/blob/45b0d8bb2ab6a0db0981474da707296fc2eaec72/comparators/new_user_footway.js#L12-L21 |
16,969 | remarkablemark/html-react-parser | lib/utilities.js | camelCase | function camelCase(string) {
if (typeof string !== 'string') {
throw new TypeError('First argument must be a string');
}
// custom property or no hyphen found
if (CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX.test(string)) {
return string;
}
// convert to camelCase
return string
.toLowerCase()
.rep... | javascript | function camelCase(string) {
if (typeof string !== 'string') {
throw new TypeError('First argument must be a string');
}
// custom property or no hyphen found
if (CUSTOM_PROPERTY_OR_NO_HYPHEN_REGEX.test(string)) {
return string;
}
// convert to camelCase
return string
.toLowerCase()
.rep... | [
"function",
"camelCase",
"(",
"string",
")",
"{",
"if",
"(",
"typeof",
"string",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'First argument must be a string'",
")",
";",
"}",
"// custom property or no hyphen found",
"if",
"(",
"CUSTOM_PROPERTY_O... | Converts a string to camelCase.
@param {String} string - The string.
@return {String} | [
"Converts",
"a",
"string",
"to",
"camelCase",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/utilities.js#L11-L27 |
16,970 | remarkablemark/html-react-parser | lib/utilities.js | invertObject | function invertObject(obj, override) {
if (!obj || typeof obj !== 'object') {
throw new TypeError('First argument must be an object');
}
var key;
var value;
var isOverridePresent = typeof override === 'function';
var overrides = {};
var result = {};
for (key in obj) {
value = obj[key];
if... | javascript | function invertObject(obj, override) {
if (!obj || typeof obj !== 'object') {
throw new TypeError('First argument must be an object');
}
var key;
var value;
var isOverridePresent = typeof override === 'function';
var overrides = {};
var result = {};
for (key in obj) {
value = obj[key];
if... | [
"function",
"invertObject",
"(",
"obj",
",",
"override",
")",
"{",
"if",
"(",
"!",
"obj",
"||",
"typeof",
"obj",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'First argument must be an object'",
")",
";",
"}",
"var",
"key",
";",
"var",
... | Swap key with value in an object.
@param {Object} obj - The object.
@param {Function} [override] - The override method.
@return {Object} - The inverted object. | [
"Swap",
"key",
"with",
"value",
"in",
"an",
"object",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/utilities.js#L36-L64 |
16,971 | remarkablemark/html-react-parser | lib/utilities.js | isCustomComponent | function isCustomComponent(tagName, props) {
if (tagName.indexOf('-') === -1) {
return props && typeof props.is === 'string';
}
switch (tagName) {
// These are reserved SVG and MathML elements.
// We don't mind this whitelist too much because we expect it to never grow.
// The alternative is to t... | javascript | function isCustomComponent(tagName, props) {
if (tagName.indexOf('-') === -1) {
return props && typeof props.is === 'string';
}
switch (tagName) {
// These are reserved SVG and MathML elements.
// We don't mind this whitelist too much because we expect it to never grow.
// The alternative is to t... | [
"function",
"isCustomComponent",
"(",
"tagName",
",",
"props",
")",
"{",
"if",
"(",
"tagName",
".",
"indexOf",
"(",
"'-'",
")",
"===",
"-",
"1",
")",
"{",
"return",
"props",
"&&",
"typeof",
"props",
".",
"is",
"===",
"'string'",
";",
"}",
"switch",
"... | Check if a given tag is a custom component.
@see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
@param {string} tagName - The name of the html tag.
@param {Object} props - The props being passed to the element.
@return {boolean} | [
"Check",
"if",
"a",
"given",
"tag",
"is",
"a",
"custom",
"component",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/utilities.js#L75-L97 |
16,972 | remarkablemark/html-react-parser | lib/attributes-to-props.js | attributesToProps | function attributesToProps(attributes) {
attributes = attributes || {};
var props = {};
var propertyName;
var propertyValue;
var reactProperty;
for (propertyName in attributes) {
propertyValue = attributes[propertyName];
// custom attributes (`data-` and `aria-`)
if (isCustomAttribute(property... | javascript | function attributesToProps(attributes) {
attributes = attributes || {};
var props = {};
var propertyName;
var propertyValue;
var reactProperty;
for (propertyName in attributes) {
propertyValue = attributes[propertyName];
// custom attributes (`data-` and `aria-`)
if (isCustomAttribute(property... | [
"function",
"attributesToProps",
"(",
"attributes",
")",
"{",
"attributes",
"=",
"attributes",
"||",
"{",
"}",
";",
"var",
"props",
"=",
"{",
"}",
";",
"var",
"propertyName",
";",
"var",
"propertyValue",
";",
"var",
"reactProperty",
";",
"for",
"(",
"prope... | Makes attributes compatible with React props.
@param {Object} [attributes={}] - The attributes.
@return {Object} - The props. | [
"Makes",
"attributes",
"compatible",
"with",
"React",
"props",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/attributes-to-props.js#L18-L62 |
16,973 | remarkablemark/html-react-parser | lib/attributes-to-props.js | cssToJs | function cssToJs(style) {
if (typeof style !== 'string') {
throw new TypeError('First argument must be a string.');
}
var styleObj = {};
styleToObject(style, function(propName, propValue) {
// Check if it's not a comment node
if (propName && propValue) {
styleObj[utilities.camelCase(propName)... | javascript | function cssToJs(style) {
if (typeof style !== 'string') {
throw new TypeError('First argument must be a string.');
}
var styleObj = {};
styleToObject(style, function(propName, propValue) {
// Check if it's not a comment node
if (propName && propValue) {
styleObj[utilities.camelCase(propName)... | [
"function",
"cssToJs",
"(",
"style",
")",
"{",
"if",
"(",
"typeof",
"style",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'First argument must be a string.'",
")",
";",
"}",
"var",
"styleObj",
"=",
"{",
"}",
";",
"styleToObject",
"(",
"s... | Converts CSS style string to JS style object.
@param {String} style - The CSS style.
@return {Object} - The JS style object. | [
"Converts",
"CSS",
"style",
"string",
"to",
"JS",
"style",
"object",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/attributes-to-props.js#L70-L83 |
16,974 | remarkablemark/html-react-parser | index.js | HTMLReactParser | function HTMLReactParser(html, options) {
if (typeof html !== 'string') {
throw new TypeError('First argument must be a string');
}
return domToReact(htmlToDOM(html, domParserOptions), options);
} | javascript | function HTMLReactParser(html, options) {
if (typeof html !== 'string') {
throw new TypeError('First argument must be a string');
}
return domToReact(htmlToDOM(html, domParserOptions), options);
} | [
"function",
"HTMLReactParser",
"(",
"html",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"html",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'First argument must be a string'",
")",
";",
"}",
"return",
"domToReact",
"(",
"htmlToDOM",
"(",... | Convert HTML string to React elements.
@param {String} html - The HTML string.
@param {Object} [options] - The additional options.
@param {Function} [options.replace] - The replace method.
@return {ReactElement|Array} | [
"Convert",
"HTML",
"string",
"to",
"React",
"elements",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/index.js#L15-L20 |
16,975 | remarkablemark/html-react-parser | lib/dom-to-react.js | domToReact | function domToReact(nodes, options) {
options = options || {};
var result = [];
var node;
var isReplacePresent = typeof options.replace === 'function';
var replacement;
var props;
var children;
for (var i = 0, len = nodes.length; i < len; i++) {
node = nodes[i];
// replace with custom React el... | javascript | function domToReact(nodes, options) {
options = options || {};
var result = [];
var node;
var isReplacePresent = typeof options.replace === 'function';
var replacement;
var props;
var children;
for (var i = 0, len = nodes.length; i < len; i++) {
node = nodes[i];
// replace with custom React el... | [
"function",
"domToReact",
"(",
"nodes",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"node",
";",
"var",
"isReplacePresent",
"=",
"typeof",
"options",
".",
"replace",
"===",
"'fun... | Converts DOM nodes to React elements.
@param {Array} nodes - The DOM nodes.
@param {Object} [options] - The additional options.
@param {Function} [options.replace] - The replace method.
@return {ReactElement|Array} | [
"Converts",
"DOM",
"nodes",
"to",
"React",
"elements",
"."
] | eb3085ab1d0e9c151959ae21f60a13f073d5b978 | https://github.com/remarkablemark/html-react-parser/blob/eb3085ab1d0e9c151959ae21f60a13f073d5b978/lib/dom-to-react.js#L13-L91 |
16,976 | CrystalComputerCorp/smpte-timecode | smpte-timecode.js | function ( timeCode, frameRate, dropFrame ) {
// Make this class safe for use without "new"
if (!(this instanceof Timecode)) return new Timecode( timeCode, frameRate, dropFrame);
// Get frame rate
if (typeof frameRate === 'undefined') this.frameRate = 29.97;
else if (typeof fra... | javascript | function ( timeCode, frameRate, dropFrame ) {
// Make this class safe for use without "new"
if (!(this instanceof Timecode)) return new Timecode( timeCode, frameRate, dropFrame);
// Get frame rate
if (typeof frameRate === 'undefined') this.frameRate = 29.97;
else if (typeof fra... | [
"function",
"(",
"timeCode",
",",
"frameRate",
",",
"dropFrame",
")",
"{",
"// Make this class safe for use without \"new\"",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Timecode",
")",
")",
"return",
"new",
"Timecode",
"(",
"timeCode",
",",
"frameRate",
",",
"d... | Timecode object constructor
@param {number|String|Date|Object} timeCode Frame count as number, "HH:MM:SS(:|;|.)FF", Date(), or object.
@param {number} [frameRate=29.97] Frame rate
@param {boolean} [dropFrame=true] Whether the timecode is drop-frame or not
@constructor
@returns {Timecode} timecode | [
"Timecode",
"object",
"constructor"
] | fb9031de573ab648fbbbb1fbb0d2a4e78859e0fe | https://github.com/CrystalComputerCorp/smpte-timecode/blob/fb9031de573ab648fbbbb1fbb0d2a4e78859e0fe/smpte-timecode.js#L13-L73 | |
16,977 | namics/webpack-config-plugins | packages/ts-config-webpack-plugin/src/TsConfigValidator.js | verifyTsConfig | function verifyTsConfig(configFilePath) {
/**
* @type {string[]}
*/
const warnings = [];
const createConfigFileHost = {
onUnRecoverableConfigFileDiagnostic() {},
useCaseSensitiveFileNames: false,
readDirectory: typescript.sys.readDirectory,
fileExists: typescript.sys.fileExists,
readFile: typescript.sy... | javascript | function verifyTsConfig(configFilePath) {
/**
* @type {string[]}
*/
const warnings = [];
const createConfigFileHost = {
onUnRecoverableConfigFileDiagnostic() {},
useCaseSensitiveFileNames: false,
readDirectory: typescript.sys.readDirectory,
fileExists: typescript.sys.fileExists,
readFile: typescript.sy... | [
"function",
"verifyTsConfig",
"(",
"configFilePath",
")",
"{",
"/**\n\t * @type {string[]}\n\t */",
"const",
"warnings",
"=",
"[",
"]",
";",
"const",
"createConfigFileHost",
"=",
"{",
"onUnRecoverableConfigFileDiagnostic",
"(",
")",
"{",
"}",
",",
"useCaseSensitiveFileN... | Check for known TSConfig issues and output warnings
@param {string} configFilePath
@returns {string[]} warnings | [
"Check",
"for",
"known",
"TSConfig",
"issues",
"and",
"output",
"warnings"
] | 74f04974b98226e2afac25422cc57dfb96e4f77b | https://github.com/namics/webpack-config-plugins/blob/74f04974b98226e2afac25422cc57dfb96e4f77b/packages/ts-config-webpack-plugin/src/TsConfigValidator.js#L20-L58 |
16,978 | TooTallNate/node-time | index.js | listTimezones | function listTimezones () {
if (arguments.length == 0) {
throw new Error("You must set a callback");
}
if (typeof arguments[arguments.length - 1] != "function") {
throw new Error("You must set a callback");
}
var cb = arguments[arguments.length - 1]
, subset = (arguments.length > 1 ? arguments[0] ... | javascript | function listTimezones () {
if (arguments.length == 0) {
throw new Error("You must set a callback");
}
if (typeof arguments[arguments.length - 1] != "function") {
throw new Error("You must set a callback");
}
var cb = arguments[arguments.length - 1]
, subset = (arguments.length > 1 ? arguments[0] ... | [
"function",
"listTimezones",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"You must set a callback\"",
")",
";",
"}",
"if",
"(",
"typeof",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1... | Lists the timezones that the current system can accept. It does this by going
on a recursive walk through the timezone dir and collecting filenames. | [
"Lists",
"the",
"timezones",
"that",
"the",
"current",
"system",
"can",
"accept",
".",
"It",
"does",
"this",
"by",
"going",
"on",
"a",
"recursive",
"walk",
"through",
"the",
"timezone",
"dir",
"and",
"collecting",
"filenames",
"."
] | 2739eac5d5e11d47f4048af7711f68556ae893d4 | https://github.com/TooTallNate/node-time/blob/2739eac5d5e11d47f4048af7711f68556ae893d4/index.js#L177-L191 |
16,979 | TooTallNate/node-time | index.js | pad | function pad (num, padLen) {
var padding = '0000';
num = String(num);
return padding.substring(0, padLen - num.length) + num;
} | javascript | function pad (num, padLen) {
var padding = '0000';
num = String(num);
return padding.substring(0, padLen - num.length) + num;
} | [
"function",
"pad",
"(",
"num",
",",
"padLen",
")",
"{",
"var",
"padding",
"=",
"'0000'",
";",
"num",
"=",
"String",
"(",
"num",
")",
";",
"return",
"padding",
".",
"substring",
"(",
"0",
",",
"padLen",
"-",
"num",
".",
"length",
")",
"+",
"num",
... | Pads a number with 0s if required. | [
"Pads",
"a",
"number",
"with",
"0s",
"if",
"required",
"."
] | 2739eac5d5e11d47f4048af7711f68556ae893d4 | https://github.com/TooTallNate/node-time/blob/2739eac5d5e11d47f4048af7711f68556ae893d4/index.js#L635-L639 |
16,980 | assistunion/xml-stream | lib/xml-stream.js | normalizeSelector | function normalizeSelector(selector) {
var parts = selector.match(/[^\s>]+|>/ig);
selector = (parts) ? parts.join(' ') : '';
return {
normalized: selector,
parts: parts || []
};
} | javascript | function normalizeSelector(selector) {
var parts = selector.match(/[^\s>]+|>/ig);
selector = (parts) ? parts.join(' ') : '';
return {
normalized: selector,
parts: parts || []
};
} | [
"function",
"normalizeSelector",
"(",
"selector",
")",
"{",
"var",
"parts",
"=",
"selector",
".",
"match",
"(",
"/",
"[^\\s>]+|>",
"/",
"ig",
")",
";",
"selector",
"=",
"(",
"parts",
")",
"?",
"parts",
".",
"join",
"(",
"' '",
")",
":",
"''",
";",
... | Normalizes the selector and returns the new version and its parts. | [
"Normalizes",
"the",
"selector",
"and",
"returns",
"the",
"new",
"version",
"and",
"its",
"parts",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L210-L217 |
16,981 | assistunion/xml-stream | lib/xml-stream.js | parseEvent | function parseEvent(event) {
var eventParts = event.match(/^((?:start|end|update)Element|text):?(.*)/);
if (eventParts === null) {
return null;
}
var eventType = eventParts[1];
var selector = normalizeSelector(eventParts[2]);
return {
selector: selector,
type: eventType,
name: (eventParts[2]... | javascript | function parseEvent(event) {
var eventParts = event.match(/^((?:start|end|update)Element|text):?(.*)/);
if (eventParts === null) {
return null;
}
var eventType = eventParts[1];
var selector = normalizeSelector(eventParts[2]);
return {
selector: selector,
type: eventType,
name: (eventParts[2]... | [
"function",
"parseEvent",
"(",
"event",
")",
"{",
"var",
"eventParts",
"=",
"event",
".",
"match",
"(",
"/",
"^((?:start|end|update)Element|text):?(.*)",
"/",
")",
";",
"if",
"(",
"eventParts",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"var",
"e... | Parses the selector event string and returns event information. | [
"Parses",
"the",
"selector",
"event",
"string",
"and",
"returns",
"event",
"information",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L220-L233 |
16,982 | assistunion/xml-stream | lib/xml-stream.js | getFinalState | function getFinalState(selector) {
if (__own.call(this._finalStates, selector.normalized)) {
var finalState = this._finalStates[selector.normalized];
} else {
var n = selector.parts.length;
var immediate = false;
this._startState[this._lastState] = true;
for (var i = 0; i < n; i++) {
var p... | javascript | function getFinalState(selector) {
if (__own.call(this._finalStates, selector.normalized)) {
var finalState = this._finalStates[selector.normalized];
} else {
var n = selector.parts.length;
var immediate = false;
this._startState[this._lastState] = true;
for (var i = 0; i < n; i++) {
var p... | [
"function",
"getFinalState",
"(",
"selector",
")",
"{",
"if",
"(",
"__own",
".",
"call",
"(",
"this",
".",
"_finalStates",
",",
"selector",
".",
"normalized",
")",
")",
"{",
"var",
"finalState",
"=",
"this",
".",
"_finalStates",
"[",
"selector",
".",
"no... | Compiles a given selector object to a finite automata and returns its last state. | [
"Compiles",
"a",
"given",
"selector",
"object",
"to",
"a",
"finite",
"automata",
"and",
"returns",
"its",
"last",
"state",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L237-L260 |
16,983 | assistunion/xml-stream | lib/xml-stream.js | emitStart | function emitStart(name, attrs) {
this.emit('data', '<' + name);
for (var attr in attrs) if (__own.call(attrs, attr)) {
this.emit('data', ' ' + attr + '="' + escape(attrs[attr]) + '"');
}
this.emit('data', '>');
} | javascript | function emitStart(name, attrs) {
this.emit('data', '<' + name);
for (var attr in attrs) if (__own.call(attrs, attr)) {
this.emit('data', ' ' + attr + '="' + escape(attrs[attr]) + '"');
}
this.emit('data', '>');
} | [
"function",
"emitStart",
"(",
"name",
",",
"attrs",
")",
"{",
"this",
".",
"emit",
"(",
"'data'",
",",
"'<'",
"+",
"name",
")",
";",
"for",
"(",
"var",
"attr",
"in",
"attrs",
")",
"if",
"(",
"__own",
".",
"call",
"(",
"attrs",
",",
"attr",
")",
... | Emits XML for element opening tag. | [
"Emits",
"XML",
"for",
"element",
"opening",
"tag",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L263-L269 |
16,984 | assistunion/xml-stream | lib/xml-stream.js | emitElement | function emitElement(element, name, onLeave) {
if (Array.isArray(element)) {
var i;
for (i = 0; i < element.length - 1; i++) {
emitOneElement.call(this, element[i], name);
}
emitOneElement.call(this, element[i], name, onLeave);
} else {
emitOneElement.call(this, element, name, onLeave);
... | javascript | function emitElement(element, name, onLeave) {
if (Array.isArray(element)) {
var i;
for (i = 0; i < element.length - 1; i++) {
emitOneElement.call(this, element[i], name);
}
emitOneElement.call(this, element[i], name, onLeave);
} else {
emitOneElement.call(this, element, name, onLeave);
... | [
"function",
"emitElement",
"(",
"element",
",",
"name",
",",
"onLeave",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"element",
")",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"element",
".",
"length",
"-",
"1",
... | Emits a single element and its descendants, or an array of elements. | [
"Emits",
"a",
"single",
"element",
"and",
"its",
"descendants",
"or",
"an",
"array",
"of",
"elements",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L282-L292 |
16,985 | assistunion/xml-stream | lib/xml-stream.js | emitChildren | function emitChildren(elements) {
var i;
for (i = 0; i < elements.length; i++) {
var element = elements[i];
if (typeof element === 'object') {
emitStart.call(this, element.$name, element.$);
emitChildren.call(this, element.$children);
emitEnd.call(this, element.$name);
} else {
e... | javascript | function emitChildren(elements) {
var i;
for (i = 0; i < elements.length; i++) {
var element = elements[i];
if (typeof element === 'object') {
emitStart.call(this, element.$name, element.$);
emitChildren.call(this, element.$children);
emitEnd.call(this, element.$name);
} else {
e... | [
"function",
"emitChildren",
"(",
"elements",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"elements",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"element",
"=",
"elements",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"... | Emits child element collection and their descendants. Works only with preserved nodes. | [
"Emits",
"child",
"element",
"collection",
"and",
"their",
"descendants",
".",
"Works",
"only",
"with",
"preserved",
"nodes",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L296-L308 |
16,986 | assistunion/xml-stream | lib/xml-stream.js | emitOneElement | function emitOneElement(element, name, onLeave) {
if (typeof element === 'object') {
emitStart.call(this, name, element.$);
if (__own.call(element, '$children')) {
emitChildren.call(this, element.$children);
} else {
var hasText = false;
for (var child in element) {
if (__own.cal... | javascript | function emitOneElement(element, name, onLeave) {
if (typeof element === 'object') {
emitStart.call(this, name, element.$);
if (__own.call(element, '$children')) {
emitChildren.call(this, element.$children);
} else {
var hasText = false;
for (var child in element) {
if (__own.cal... | [
"function",
"emitOneElement",
"(",
"element",
",",
"name",
",",
"onLeave",
")",
"{",
"if",
"(",
"typeof",
"element",
"===",
"'object'",
")",
"{",
"emitStart",
".",
"call",
"(",
"this",
",",
"name",
",",
"element",
".",
"$",
")",
";",
"if",
"(",
"__ow... | Recursively emits a given element and its descendants. | [
"Recursively",
"emits",
"a",
"given",
"element",
"and",
"its",
"descendants",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L311-L338 |
16,987 | assistunion/xml-stream | lib/xml-stream.js | function(data) {
if (self._encoder) {
data = self._encoder.convert(data);
}
if (!xml.parse(data, false)) {
self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
}
} | javascript | function(data) {
if (self._encoder) {
data = self._encoder.convert(data);
}
if (!xml.parse(data, false)) {
self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
}
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"self",
".",
"_encoder",
")",
"{",
"data",
"=",
"self",
".",
"_encoder",
".",
"convert",
"(",
"data",
")",
";",
"}",
"if",
"(",
"!",
"xml",
".",
"parse",
"(",
"data",
",",
"false",
")",
")",
"{",
... | Parse incoming chunk. Convert to UTF-8 or emit errors when appropriate. | [
"Parse",
"incoming",
"chunk",
".",
"Convert",
"to",
"UTF",
"-",
"8",
"or",
"emit",
"errors",
"when",
"appropriate",
"."
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/lib/xml-stream.js#L519-L526 | |
16,988 | assistunion/xml-stream | examples/encoding.js | setup | function setup(encoding) {
var stream = fs.createReadStream(path.join(__dirname, 'encoding.xml'));
var xml = new XmlStream(stream, encoding);
xml.on('endElement: node', function(node) {
console.log(node);
});
xml.on('error', function(message) {
console.log('Parsing as ' + (encoding || 'auto') + ' fail... | javascript | function setup(encoding) {
var stream = fs.createReadStream(path.join(__dirname, 'encoding.xml'));
var xml = new XmlStream(stream, encoding);
xml.on('endElement: node', function(node) {
console.log(node);
});
xml.on('error', function(message) {
console.log('Parsing as ' + (encoding || 'auto') + ' fail... | [
"function",
"setup",
"(",
"encoding",
")",
"{",
"var",
"stream",
"=",
"fs",
".",
"createReadStream",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'encoding.xml'",
")",
")",
";",
"var",
"xml",
"=",
"new",
"XmlStream",
"(",
"stream",
",",
"encoding",
... | Create a file stream and pass it to XmlStream | [
"Create",
"a",
"file",
"stream",
"and",
"pass",
"it",
"to",
"XmlStream"
] | d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c | https://github.com/assistunion/xml-stream/blob/d4b60adba5a8e8b0c08aeb2ff5129c6c2d92aa0c/examples/encoding.js#L7-L17 |
16,989 | DHTMLX/scheduler | codebase/sources/ext/dhtmlxscheduler_mvc.js | sanitize | function sanitize(ev){
var obj = {};
for (var key in ev)
if (key.indexOf("_") !== 0)
obj[key] = ev[key];
if (!cfg.use_id)
delete obj.id;
return obj;
} | javascript | function sanitize(ev){
var obj = {};
for (var key in ev)
if (key.indexOf("_") !== 0)
obj[key] = ev[key];
if (!cfg.use_id)
delete obj.id;
return obj;
} | [
"function",
"sanitize",
"(",
"ev",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"ev",
")",
"if",
"(",
"key",
".",
"indexOf",
"(",
"\"_\"",
")",
"!==",
"0",
")",
"obj",
"[",
"key",
"]",
"=",
"ev",
"[",
"key",
"... | remove private properties | [
"remove",
"private",
"properties"
] | f1629dd8647b08978d3f8ba4d56eacc9b741f543 | https://github.com/DHTMLX/scheduler/blob/f1629dd8647b08978d3f8ba4d56eacc9b741f543/codebase/sources/ext/dhtmlxscheduler_mvc.js#L16-L26 |
16,990 | ricklupton/d3-sankey-diagram | src/sankeyLayout/link-ordering.js | orderEdgesOne | function orderEdgesOne (G, v) {
const node = G.node(v)
node.ports.forEach(port => {
port.incoming.sort(compareDirection(G, node, false))
port.outgoing.sort(compareDirection(G, node, true))
})
} | javascript | function orderEdgesOne (G, v) {
const node = G.node(v)
node.ports.forEach(port => {
port.incoming.sort(compareDirection(G, node, false))
port.outgoing.sort(compareDirection(G, node, true))
})
} | [
"function",
"orderEdgesOne",
"(",
"G",
",",
"v",
")",
"{",
"const",
"node",
"=",
"G",
".",
"node",
"(",
"v",
")",
"node",
".",
"ports",
".",
"forEach",
"(",
"port",
"=>",
"{",
"port",
".",
"incoming",
".",
"sort",
"(",
"compareDirection",
"(",
"G",... | Order the edges at the given node.
The ports have already been setup and sorted. | [
"Order",
"the",
"edges",
"at",
"the",
"given",
"node",
".",
"The",
"ports",
"have",
"already",
"been",
"setup",
"and",
"sorted",
"."
] | baeb5bb1ca3df45af0ed175e5b733700ddddcfcb | https://github.com/ricklupton/d3-sankey-diagram/blob/baeb5bb1ca3df45af0ed175e5b733700ddddcfcb/src/sankeyLayout/link-ordering.js#L16-L22 |
16,991 | expo/stripe-expo | index.js | _convertDetails | function _convertDetails(type, details) {
var convertedDetails = {}
for (var data in details) {
const string = type + '[' + data + ']';
convertedDetails[string] = details[data];
}
return convertedDetails;
} | javascript | function _convertDetails(type, details) {
var convertedDetails = {}
for (var data in details) {
const string = type + '[' + data + ']';
convertedDetails[string] = details[data];
}
return convertedDetails;
} | [
"function",
"_convertDetails",
"(",
"type",
",",
"details",
")",
"{",
"var",
"convertedDetails",
"=",
"{",
"}",
"for",
"(",
"var",
"data",
"in",
"details",
")",
"{",
"const",
"string",
"=",
"type",
"+",
"'['",
"+",
"data",
"+",
"']'",
";",
"convertedDe... | _convertDetails converts and returns the data in the given details to the correct Stripe format for the given type. | [
"_convertDetails",
"converts",
"and",
"returns",
"the",
"data",
"in",
"the",
"given",
"details",
"to",
"the",
"correct",
"Stripe",
"format",
"for",
"the",
"given",
"type",
"."
] | c917a32f8bcc78f5aecb4147a16495e06d1a69c3 | https://github.com/expo/stripe-expo/blob/c917a32f8bcc78f5aecb4147a16495e06d1a69c3/index.js#L37-L44 |
16,992 | expo/stripe-expo | index.js | _parseJSON | async function _parseJSON(token) {
if (token._bodyInit == null) {
return token;
} else {
const body = await token.json();
return body;
}
} | javascript | async function _parseJSON(token) {
if (token._bodyInit == null) {
return token;
} else {
const body = await token.json();
return body;
}
} | [
"async",
"function",
"_parseJSON",
"(",
"token",
")",
"{",
"if",
"(",
"token",
".",
"_bodyInit",
"==",
"null",
")",
"{",
"return",
"token",
";",
"}",
"else",
"{",
"const",
"body",
"=",
"await",
"token",
".",
"json",
"(",
")",
";",
"return",
"body",
... | Stripe gives a JSON object with the token object embedded as a JSON string. _parseJSON finds that string in and returns it as a JSON object, or an error if Stripe threw an error instead. If the JSON does not need to be parsed, returns the token. | [
"Stripe",
"gives",
"a",
"JSON",
"object",
"with",
"the",
"token",
"object",
"embedded",
"as",
"a",
"JSON",
"string",
".",
"_parseJSON",
"finds",
"that",
"string",
"in",
"and",
"returns",
"it",
"as",
"a",
"JSON",
"object",
"or",
"an",
"error",
"if",
"Stri... | c917a32f8bcc78f5aecb4147a16495e06d1a69c3 | https://github.com/expo/stripe-expo/blob/c917a32f8bcc78f5aecb4147a16495e06d1a69c3/index.js#L49-L56 |
16,993 | hflabs/suggestions-jquery | src/includes/container.js | highlightMatches | function highlightMatches(chunks) {
return $.map(chunks, function (chunk) {
var text = utils.escapeHtml(chunk.text);
if (text && chunk.matched) {
text = '<strong>' + text + '</strong>';
}
return text;
}).join('');
} | javascript | function highlightMatches(chunks) {
return $.map(chunks, function (chunk) {
var text = utils.escapeHtml(chunk.text);
if (text && chunk.matched) {
text = '<strong>' + text + '</strong>';
}
return text;
}).join('');
} | [
"function",
"highlightMatches",
"(",
"chunks",
")",
"{",
"return",
"$",
".",
"map",
"(",
"chunks",
",",
"function",
"(",
"chunk",
")",
"{",
"var",
"text",
"=",
"utils",
".",
"escapeHtml",
"(",
"chunk",
".",
"text",
")",
";",
"if",
"(",
"text",
"&&",
... | Methods related to suggestions dropdown list | [
"Methods",
"related",
"to",
"suggestions",
"dropdown",
"list"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/container.js#L16-L25 |
16,994 | hflabs/suggestions-jquery | src/includes/container.js | function (origin, elLayout) {
var that = this,
scrollLeft = that.$viewport.scrollLeft(),
style;
if (that.isMobile) {
style = that.options.floating ? {
left: scrollLeft + 'px',
top: elLayout.top + elLayout.outerHeight + 'px'
... | javascript | function (origin, elLayout) {
var that = this,
scrollLeft = that.$viewport.scrollLeft(),
style;
if (that.isMobile) {
style = that.options.floating ? {
left: scrollLeft + 'px',
top: elLayout.top + elLayout.outerHeight + 'px'
... | [
"function",
"(",
"origin",
",",
"elLayout",
")",
"{",
"var",
"that",
"=",
"this",
",",
"scrollLeft",
"=",
"that",
".",
"$viewport",
".",
"scrollLeft",
"(",
")",
",",
"style",
";",
"if",
"(",
"that",
".",
"isMobile",
")",
"{",
"style",
"=",
"that",
... | Dropdown UI methods | [
"Dropdown",
"UI",
"methods"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/container.js#L121-L160 | |
16,995 | hflabs/suggestions-jquery | src/includes/container.js | function () {
var that = this;
return that.suggestions.length > 1 ||
(that.suggestions.length === 1 &&
(!that.selection || $.trim(that.suggestions[0].value) !== $.trim(that.selection.value))
);
} | javascript | function () {
var that = this;
return that.suggestions.length > 1 ||
(that.suggestions.length === 1 &&
(!that.selection || $.trim(that.suggestions[0].value) !== $.trim(that.selection.value))
);
} | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"that",
".",
"suggestions",
".",
"length",
">",
"1",
"||",
"(",
"that",
".",
"suggestions",
".",
"length",
"===",
"1",
"&&",
"(",
"!",
"that",
".",
"selection",
"||",
"$",
".",
... | Shows if there are any suggestions besides currently selected
@returns {boolean} | [
"Shows",
"if",
"there",
"are",
"any",
"suggestions",
"besides",
"currently",
"selected"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/container.js#L190-L197 | |
16,996 | hflabs/suggestions-jquery | src/includes/suggestions.js | function () {
var that = this;
that.uniqueId = utils.uniqueId('i');
that.createWrapper();
that.notify('initialize');
that.bindWindowEvents();
that.setOptions();
that.fixPosition();
} | javascript | function () {
var that = this;
that.uniqueId = utils.uniqueId('i');
that.createWrapper();
that.notify('initialize');
that.bindWindowEvents();
that.setOptions();
that.fixPosition();
} | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"that",
".",
"uniqueId",
"=",
"utils",
".",
"uniqueId",
"(",
"'i'",
")",
";",
"that",
".",
"createWrapper",
"(",
")",
";",
"that",
".",
"notify",
"(",
"'initialize'",
")",
";",
"that",
"."... | Creation and destruction | [
"Creation",
"and",
"destruction"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/suggestions.js#L103-L115 | |
16,997 | hflabs/suggestions-jquery | src/includes/suggestions.js | function () {
var that = this,
events = 'mouseover focus keydown',
timer,
callback = function () {
that.initializer.resolve();
that.enable();
};
that.initializer.always(function(){
that.el.off(events, callback);... | javascript | function () {
var that = this,
events = 'mouseover focus keydown',
timer,
callback = function () {
that.initializer.resolve();
that.enable();
};
that.initializer.always(function(){
that.el.off(events, callback);... | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"events",
"=",
"'mouseover focus keydown'",
",",
"timer",
",",
"callback",
"=",
"function",
"(",
")",
"{",
"that",
".",
"initializer",
".",
"resolve",
"(",
")",
";",
"that",
".",
"enable",
"("... | Initialize when element is firstly interacted | [
"Initialize",
"when",
"element",
"is",
"firstly",
"interacted"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/suggestions.js#L120-L141 | |
16,998 | hflabs/suggestions-jquery | src/includes/suggestions.js | function (e) {
var that = this,
elLayout = {},
wrapperOffset,
origin;
that.isMobile = that.$viewport.width() <= that.options.mobileWidth;
if (!that.isInitialized() || (e && e.type == 'scroll' && !(that.options.floating || that.isMobile))) return;
tha... | javascript | function (e) {
var that = this,
elLayout = {},
wrapperOffset,
origin;
that.isMobile = that.$viewport.width() <= that.options.mobileWidth;
if (!that.isInitialized() || (e && e.type == 'scroll' && !(that.options.floating || that.isMobile))) return;
tha... | [
"function",
"(",
"e",
")",
"{",
"var",
"that",
"=",
"this",
",",
"elLayout",
"=",
"{",
"}",
",",
"wrapperOffset",
",",
"origin",
";",
"that",
".",
"isMobile",
"=",
"that",
".",
"$viewport",
".",
"width",
"(",
")",
"<=",
"that",
".",
"options",
".",... | Common public methods | [
"Common",
"public",
"methods"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/suggestions.js#L292-L333 | |
16,999 | hflabs/suggestions-jquery | src/includes/suggestions.js | function () {
var that = this,
fullQuery = that.extendedCurrentValue(),
currentValue = that.el.val(),
resolver = $.Deferred();
resolver
.done(function (suggestion) {
that.selectSuggestion(suggestion, 0, currentValue, { hasBeenEnriched: tru... | javascript | function () {
var that = this,
fullQuery = that.extendedCurrentValue(),
currentValue = that.el.val(),
resolver = $.Deferred();
resolver
.done(function (suggestion) {
that.selectSuggestion(suggestion, 0, currentValue, { hasBeenEnriched: tru... | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"fullQuery",
"=",
"that",
".",
"extendedCurrentValue",
"(",
")",
",",
"currentValue",
"=",
"that",
".",
"el",
".",
"val",
"(",
")",
",",
"resolver",
"=",
"$",
".",
"Deferred",
"(",
")",
";... | Fetch full object for current INPUT's value
if no suitable object found, clean input element | [
"Fetch",
"full",
"object",
"for",
"current",
"INPUT",
"s",
"value",
"if",
"no",
"suitable",
"object",
"found",
"clean",
"input",
"element"
] | 17e3ac383790069ad4d3dd92185d9fb9e30382a7 | https://github.com/hflabs/suggestions-jquery/blob/17e3ac383790069ad4d3dd92185d9fb9e30382a7/src/includes/suggestions.js#L428-L463 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.