repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
trustnote/trustnote-pow-common
wallet/supernode.js
signWithLocalPrivateKey
function signWithLocalPrivateKey(wallet_id, account, is_change, address_index, text_to_sign, handleSig){ var path = "m/44'/0'/" + account + "'/"+is_change+"/"+address_index; var privateKey = xPrivKey.derive(path).privateKey; var privKeyBuf = privateKey.bn.toBuffer({size:32}); // https://github.com/bitpay/bitcore-lib...
javascript
function signWithLocalPrivateKey(wallet_id, account, is_change, address_index, text_to_sign, handleSig){ var path = "m/44'/0'/" + account + "'/"+is_change+"/"+address_index; var privateKey = xPrivKey.derive(path).privateKey; var privKeyBuf = privateKey.bn.toBuffer({size:32}); // https://github.com/bitpay/bitcore-lib...
[ "function", "signWithLocalPrivateKey", "(", "wallet_id", ",", "account", ",", "is_change", ",", "address_index", ",", "text_to_sign", ",", "handleSig", ")", "{", "var", "path", "=", "\"m/44'/0'/\"", "+", "account", "+", "\"'/\"", "+", "is_change", "+", "\"/\"", ...
sign with local privateKey @param {string} wallet_id - wallet id @param {number} account - account index @param {number} is_change - is_change is 0 not is_change is 1 @param {number} address_index - address index @param {string} text_to_sign - text @param {function} handleSig - callback
[ "sign", "with", "local", "privateKey" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/wallet/supernode.js#L154-L159
train
trustnote/trustnote-pow-common
wallet/supernode.js
readSingleAddress
function readSingleAddress(conn, handleAddress){ readSingleWallet(conn, function(wallet_id){ conn.query("SELECT address FROM my_addresses WHERE wallet=?", [wallet_id], function(rows){ if (rows.length === 0) throw Error("no addresses"); if (rows.length > 1) throw Error("more than 1 address"); handleA...
javascript
function readSingleAddress(conn, handleAddress){ readSingleWallet(conn, function(wallet_id){ conn.query("SELECT address FROM my_addresses WHERE wallet=?", [wallet_id], function(rows){ if (rows.length === 0) throw Error("no addresses"); if (rows.length > 1) throw Error("more than 1 address"); handleA...
[ "function", "readSingleAddress", "(", "conn", ",", "handleAddress", ")", "{", "readSingleWallet", "(", "conn", ",", "function", "(", "wallet_id", ")", "{", "conn", ".", "query", "(", "\"SELECT address FROM my_addresses WHERE wallet=?\"", ",", "[", "wallet_id", "]", ...
read single address, If amount of addresses is bigger than one, will throw an error @param {object} conn - database connection @param {function} handleAddress - callback
[ "read", "single", "address", "If", "amount", "of", "addresses", "is", "bigger", "than", "one", "will", "throw", "an", "error" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/wallet/supernode.js#L233-L243
train
trustnote/trustnote-pow-common
wallet/supernode.js
readSingleWallet
function readSingleWallet(conn, handleWallet){ conn.query("SELECT wallet FROM wallets", function(rows){ if (rows.length === 0) throw Error("no wallets"); if (rows.length > 1) throw Error("more than 1 wallet"); handleWallet(rows[0].wallet); }); }
javascript
function readSingleWallet(conn, handleWallet){ conn.query("SELECT wallet FROM wallets", function(rows){ if (rows.length === 0) throw Error("no wallets"); if (rows.length > 1) throw Error("more than 1 wallet"); handleWallet(rows[0].wallet); }); }
[ "function", "readSingleWallet", "(", "conn", ",", "handleWallet", ")", "{", "conn", ".", "query", "(", "\"SELECT wallet FROM wallets\"", ",", "function", "(", "rows", ")", "{", "if", "(", "rows", ".", "length", "===", "0", ")", "throw", "Error", "(", "\"no...
read single wallet, If amount of wallets is bigger than one, will throw an error @param {object} conn - database connection @param {function} handleWallet - callback
[ "read", "single", "wallet", "If", "amount", "of", "wallets", "is", "bigger", "than", "one", "will", "throw", "an", "error" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/wallet/supernode.js#L250-L258
train
trustnote/trustnote-pow-common
wallet/supernode.js
readMinerDeposit
function readMinerDeposit( sSuperNodeAddress, pfnCallback ) { readMinerAddress( sSuperNodeAddress, function( err, sMinerAddress ) { if ( err ) { return pfnCallback( err ); } // // query deposit // let nDeposit = 0; // ... return pfnCallback( null, nDeposit ); }); }
javascript
function readMinerDeposit( sSuperNodeAddress, pfnCallback ) { readMinerAddress( sSuperNodeAddress, function( err, sMinerAddress ) { if ( err ) { return pfnCallback( err ); } // // query deposit // let nDeposit = 0; // ... return pfnCallback( null, nDeposit ); }); }
[ "function", "readMinerDeposit", "(", "sSuperNodeAddress", ",", "pfnCallback", ")", "{", "readMinerAddress", "(", "sSuperNodeAddress", ",", "function", "(", "err", ",", "sMinerAddress", ")", "{", "if", "(", "err", ")", "{", "return", "pfnCallback", "(", "err", ...
read miner deposit @param {string} sSuperNodeAddress @param {function} pfnCallback( err, nDeposit )
[ "read", "miner", "deposit" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/wallet/supernode.js#L284-L301
train
trustnote/trustnote-pow-common
asset/divisible_asset.js
getSavingCallbacks
function getSavingCallbacks(callbacks){ return { ifError: callbacks.ifError, ifNotEnoughFunds: callbacks.ifNotEnoughFunds, ifOk: function(objJoint, private_payload, composer_unlock){ var objUnit = objJoint.unit; var unit = objUnit.unit; validation.validate(objJoint, { ifUnitError: function(err){ ...
javascript
function getSavingCallbacks(callbacks){ return { ifError: callbacks.ifError, ifNotEnoughFunds: callbacks.ifNotEnoughFunds, ifOk: function(objJoint, private_payload, composer_unlock){ var objUnit = objJoint.unit; var unit = objUnit.unit; validation.validate(objJoint, { ifUnitError: function(err){ ...
[ "function", "getSavingCallbacks", "(", "callbacks", ")", "{", "return", "{", "ifError", ":", "callbacks", ".", "ifError", ",", "ifNotEnoughFunds", ":", "callbacks", ".", "ifNotEnoughFunds", ",", "ifOk", ":", "function", "(", "objJoint", ",", "private_payload", "...
ifOk validates and saves before calling back
[ "ifOk", "validates", "and", "saves", "before", "calling", "back" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/asset/divisible_asset.js#L258-L340
train
trustnote/trustnote-pow-common
unit/composer.js
pickDivisibleCoinsForAmount
function pickDivisibleCoinsForAmount(conn, objAsset, arrAddresses, last_ball_mci, amount, bMultiAuthored, onDone){ var asset = objAsset ? objAsset.asset : null; console.log("pick coins "+asset+" amount "+amount); var is_base = objAsset ? 0 : 1; var arrInputsWithProofs = []; var total_amount = 0; var required_amou...
javascript
function pickDivisibleCoinsForAmount(conn, objAsset, arrAddresses, last_ball_mci, amount, bMultiAuthored, onDone){ var asset = objAsset ? objAsset.asset : null; console.log("pick coins "+asset+" amount "+amount); var is_base = objAsset ? 0 : 1; var arrInputsWithProofs = []; var total_amount = 0; var required_amou...
[ "function", "pickDivisibleCoinsForAmount", "(", "conn", ",", "objAsset", ",", "arrAddresses", ",", "last_ball_mci", ",", "amount", ",", "bMultiAuthored", ",", "onDone", ")", "{", "var", "asset", "=", "objAsset", "?", "objAsset", ".", "asset", ":", "null", ";",...
bMultiAuthored includes all addresses, not just those that pay arrAddresses is paying addresses
[ "bMultiAuthored", "includes", "all", "addresses", "not", "just", "those", "that", "pay", "arrAddresses", "is", "paying", "addresses" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/unit/composer.js#L57-L280
train
trustnote/trustnote-pow-common
unit/composer.js
composePowJoint
function composePowJoint(from_address, round_index, seed, deposit, solution, signer, callbacks){ var payload = {seed: seed, deposit:deposit, solution: solution}; var objMessage = { app: "pow_equihash", payload_location: "inline", payload_hash: objectHash.getBase64Hash(payload), payload: payload }; composeJo...
javascript
function composePowJoint(from_address, round_index, seed, deposit, solution, signer, callbacks){ var payload = {seed: seed, deposit:deposit, solution: solution}; var objMessage = { app: "pow_equihash", payload_location: "inline", payload_hash: objectHash.getBase64Hash(payload), payload: payload }; composeJo...
[ "function", "composePowJoint", "(", "from_address", ",", "round_index", ",", "seed", ",", "deposit", ",", "solution", ",", "signer", ",", "callbacks", ")", "{", "var", "payload", "=", "{", "seed", ":", "seed", ",", "deposit", ":", "deposit", ",", "solution...
pow add pow joint
[ "pow", "add", "pow", "joint" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/unit/composer.js#L371-L388
train
trustnote/trustnote-pow-common
unit/composer.js
composeTrustMEJoint
function composeTrustMEJoint(from_address, round_index, signer, callbacks){ composeJoint({ paying_addresses: [from_address], outputs: [{address: from_address, amount: 0}], round_index: round_index, pow_type: constants.POW_TYPE_TRUSTME, signer: signer, callbacks: callbacks }); }
javascript
function composeTrustMEJoint(from_address, round_index, signer, callbacks){ composeJoint({ paying_addresses: [from_address], outputs: [{address: from_address, amount: 0}], round_index: round_index, pow_type: constants.POW_TYPE_TRUSTME, signer: signer, callbacks: callbacks }); }
[ "function", "composeTrustMEJoint", "(", "from_address", ",", "round_index", ",", "signer", ",", "callbacks", ")", "{", "composeJoint", "(", "{", "paying_addresses", ":", "[", "from_address", "]", ",", "outputs", ":", "[", "{", "address", ":", "from_address", "...
pow add trustme joint
[ "pow", "add", "trustme", "joint" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/unit/composer.js#L391-L400
train
trustnote/trustnote-pow-common
unit/composer.js
composeCoinbaseJoint
function composeCoinbaseJoint(from_address, coinbase_address, round_index, coinbase_amount, signer, callbacks){ var coinbase_foundation_amount = Math.floor(coinbase_amount*constants.FOUNDATION_RATIO); composeJoint({ paying_addresses: [from_address], outputs: [{address: coinbase_address, amount: 0}, {address: cons...
javascript
function composeCoinbaseJoint(from_address, coinbase_address, round_index, coinbase_amount, signer, callbacks){ var coinbase_foundation_amount = Math.floor(coinbase_amount*constants.FOUNDATION_RATIO); composeJoint({ paying_addresses: [from_address], outputs: [{address: coinbase_address, amount: 0}, {address: cons...
[ "function", "composeCoinbaseJoint", "(", "from_address", ",", "coinbase_address", ",", "round_index", ",", "coinbase_amount", ",", "signer", ",", "callbacks", ")", "{", "var", "coinbase_foundation_amount", "=", "Math", ".", "floor", "(", "coinbase_amount", "*", "con...
pow add Coinbase joint
[ "pow", "add", "Coinbase", "joint" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/unit/composer.js#L403-L416
train
trustnote/trustnote-pow-common
pow/pow_service.js
connectToServer
function connectToServer( oOptions ) { let sUrl; let oWs; if ( 'object' !== typeof oOptions ) { throw new Error( 'call connectToServer with invalid oOptions' ); } if ( 'string' !== typeof oOptions.minerGateway || 0 === oOptions.minerGateway.length ) { throw new Error( 'call connectToServer with invalid oO...
javascript
function connectToServer( oOptions ) { let sUrl; let oWs; if ( 'object' !== typeof oOptions ) { throw new Error( 'call connectToServer with invalid oOptions' ); } if ( 'string' !== typeof oOptions.minerGateway || 0 === oOptions.minerGateway.length ) { throw new Error( 'call connectToServer with invalid oO...
[ "function", "connectToServer", "(", "oOptions", ")", "{", "let", "sUrl", ";", "let", "oWs", ";", "if", "(", "'object'", "!==", "typeof", "oOptions", ")", "{", "throw", "new", "Error", "(", "'call connectToServer with invalid oOptions'", ")", ";", "}", "if", ...
CLIENT connect to server @public @param {object} oOptions @param {string} oOptions.minerGateway e.g. : wss://1.miner.trustnote.org @param {function} oOptions.onOpen( err, oWsClient ) @param {function} oOptions.onMessage( oWsClient, sMessage ) @param {function} oOptions.onError( oWsClient, vError ) @param {function} ...
[ "CLIENT", "connect", "to", "server" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L199-L304
train
trustnote/trustnote-pow-common
pow/pow_service.js
sendMessageOnce
function sendMessageOnce( oWs, sCommand, jsonMessage ) { // ... sendMessage( oWs, sCommand, jsonMessage ); // ... let nCheckInterval = setInterval( () => { if ( 0 === oWs.bufferedAmount ) { // Im' not busy anymore - set a flag or something like that clearInterval( nCheckInterval ); nCheckInterval = n...
javascript
function sendMessageOnce( oWs, sCommand, jsonMessage ) { // ... sendMessage( oWs, sCommand, jsonMessage ); // ... let nCheckInterval = setInterval( () => { if ( 0 === oWs.bufferedAmount ) { // Im' not busy anymore - set a flag or something like that clearInterval( nCheckInterval ); nCheckInterval = n...
[ "function", "sendMessageOnce", "(", "oWs", ",", "sCommand", ",", "jsonMessage", ")", "{", "//\t...", "sendMessage", "(", "oWs", ",", "sCommand", ",", "jsonMessage", ")", ";", "//\t...", "let", "nCheckInterval", "=", "setInterval", "(", "(", ")", "=>", "{", ...
send message and then close the socket @public @param {object} oWs @param {string} sCommand @param {object} jsonMessage @return {boolean}
[ "send", "message", "and", "then", "close", "the", "socket" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L363-L381
train
trustnote/trustnote-pow-common
pow/pow_service.js
_cacheGetHandleByUrl
function _cacheGetHandleByUrl( sUrl ) { let oRet; let arrResult; if ( 'string' !== typeof sUrl || 0 === sUrl.length ) { return null; } // ... oRet = null; sUrl = sUrl.trim().toLowerCase(); arrResult = m_arrCacheOutboundPeers.filter( oSocket => oSocket.peer === sUrl ); if ( Array.isArray( arrResult ) && ...
javascript
function _cacheGetHandleByUrl( sUrl ) { let oRet; let arrResult; if ( 'string' !== typeof sUrl || 0 === sUrl.length ) { return null; } // ... oRet = null; sUrl = sUrl.trim().toLowerCase(); arrResult = m_arrCacheOutboundPeers.filter( oSocket => oSocket.peer === sUrl ); if ( Array.isArray( arrResult ) && ...
[ "function", "_cacheGetHandleByUrl", "(", "sUrl", ")", "{", "let", "oRet", ";", "let", "arrResult", ";", "if", "(", "'string'", "!==", "typeof", "sUrl", "||", "0", "===", "sUrl", ".", "length", ")", "{", "return", "null", ";", "}", "//\t...", "oRet", "=...
get socket handle by url @private @param {string} sUrl @returns {null}
[ "get", "socket", "handle", "by", "url" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L393-L413
train
trustnote/trustnote-pow-common
pow/pow_service.js
_cacheAddHandle
function _cacheAddHandle( oSocket ) { if ( ! oSocket ) { return false; } // ... _cacheRemoveHandle( oSocket ); m_arrCacheOutboundPeers.push( oSocket ); return true; }
javascript
function _cacheAddHandle( oSocket ) { if ( ! oSocket ) { return false; } // ... _cacheRemoveHandle( oSocket ); m_arrCacheOutboundPeers.push( oSocket ); return true; }
[ "function", "_cacheAddHandle", "(", "oSocket", ")", "{", "if", "(", "!", "oSocket", ")", "{", "return", "false", ";", "}", "//\t...", "_cacheRemoveHandle", "(", "oSocket", ")", ";", "m_arrCacheOutboundPeers", ".", "push", "(", "oSocket", ")", ";", "return", ...
add new socket handle by url @private @param {object} oSocket @returns {boolean}
[ "add", "new", "socket", "handle", "by", "url" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L422-L433
train
trustnote/trustnote-pow-common
pow/pow_service.js
_cacheRemoveHandle
function _cacheRemoveHandle( oSocket ) { let bRet; let nIndex; if ( ! oSocket ) { return false; } // ... bRet = false; nIndex = m_arrCacheOutboundPeers.indexOf( oSocket ); if ( -1 !== nIndex ) { bRet = true; m_arrCacheOutboundPeers.splice( nIndex, 1 ); } return bRet; }
javascript
function _cacheRemoveHandle( oSocket ) { let bRet; let nIndex; if ( ! oSocket ) { return false; } // ... bRet = false; nIndex = m_arrCacheOutboundPeers.indexOf( oSocket ); if ( -1 !== nIndex ) { bRet = true; m_arrCacheOutboundPeers.splice( nIndex, 1 ); } return bRet; }
[ "function", "_cacheRemoveHandle", "(", "oSocket", ")", "{", "let", "bRet", ";", "let", "nIndex", ";", "if", "(", "!", "oSocket", ")", "{", "return", "false", ";", "}", "//\t...", "bRet", "=", "false", ";", "nIndex", "=", "m_arrCacheOutboundPeers", ".", "...
remove socket handle by url @private @param {object} oSocket @returns {boolean}
[ "remove", "socket", "handle", "by", "url" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L442-L462
train
trustnote/trustnote-pow-common
pow/pow_service.js
_getHostByPeerUrl
function _getHostByPeerUrl( sUrl ) { let arrMatches; // // this regex will match wss://xxx and ws://xxx // arrMatches = sUrl.match( /^wss?:\/\/(.*)$/i ); if ( Array.isArray( arrMatches ) && arrMatches.length >= 1 ) { sUrl = arrMatches[ 1 ]; } // ... arrMatches = sUrl.match( /^(.*?)[:\/]/ ); return ( Arra...
javascript
function _getHostByPeerUrl( sUrl ) { let arrMatches; // // this regex will match wss://xxx and ws://xxx // arrMatches = sUrl.match( /^wss?:\/\/(.*)$/i ); if ( Array.isArray( arrMatches ) && arrMatches.length >= 1 ) { sUrl = arrMatches[ 1 ]; } // ... arrMatches = sUrl.match( /^(.*?)[:\/]/ ); return ( Arra...
[ "function", "_getHostByPeerUrl", "(", "sUrl", ")", "{", "let", "arrMatches", ";", "//", "//\tthis regex will match wss://xxx and ws://xxx", "//", "arrMatches", "=", "sUrl", ".", "match", "(", "/", "^wss?:\\/\\/(.*)$", "/", "i", ")", ";", "if", "(", "Array", ".",...
get host by peer url @private @param {string} sUrl @return {string}
[ "get", "host", "by", "peer", "url" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L472-L488
train
trustnote/trustnote-pow-common
pow/pow_service.js
_getRemoteAddress
function _getRemoteAddress( oSocket ) { let sRet; if ( 'object' !== typeof oSocket ) { return null; } // ... sRet = oSocket.upgradeReq.connection.remoteAddress; if ( sRet ) { // // check for proxy // ONLY VALID FOR 127.0.0.1 and resources addresses // if ( oSocket.upgradeReq.headers[ 'x-real-ip' ]...
javascript
function _getRemoteAddress( oSocket ) { let sRet; if ( 'object' !== typeof oSocket ) { return null; } // ... sRet = oSocket.upgradeReq.connection.remoteAddress; if ( sRet ) { // // check for proxy // ONLY VALID FOR 127.0.0.1 and resources addresses // if ( oSocket.upgradeReq.headers[ 'x-real-ip' ]...
[ "function", "_getRemoteAddress", "(", "oSocket", ")", "{", "let", "sRet", ";", "if", "(", "'object'", "!==", "typeof", "oSocket", ")", "{", "return", "null", ";", "}", "//\t...", "sRet", "=", "oSocket", ".", "upgradeReq", ".", "connection", ".", "remoteAdd...
get remote address @private @param {object} oSocket
[ "get", "remote", "address" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow_service.js#L497-L522
train
trustnote/trustnote-pow-common
witness/witness_pow_proof.js
validateUnit
function validateUnit( objUnit, bRequireDefinitionOrChange, cb2 ) { let bFound = false; _async.eachSeries ( objUnit.authors, function( author, cb3 ) { let sAddress = author.address; if ( -1 === arrFoundTrustMEAuthors.indexOf( sAddress ) ) { // not a witness - skip it return cb3(); ...
javascript
function validateUnit( objUnit, bRequireDefinitionOrChange, cb2 ) { let bFound = false; _async.eachSeries ( objUnit.authors, function( author, cb3 ) { let sAddress = author.address; if ( -1 === arrFoundTrustMEAuthors.indexOf( sAddress ) ) { // not a witness - skip it return cb3(); ...
[ "function", "validateUnit", "(", "objUnit", ",", "bRequireDefinitionOrChange", ",", "cb2", ")", "{", "let", "bFound", "=", "false", ";", "_async", ".", "eachSeries", "(", "objUnit", ".", "authors", ",", "function", "(", "author", ",", "cb3", ")", "{", "let...
checks signatures and updates definitions
[ "checks", "signatures", "and", "updates", "definitions" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/witness/witness_pow_proof.js#L207-L324
train
trustnote/trustnote-pow-common
sc/deposit.js
isDepositDefinition
function isDepositDefinition(arrDefinition){ if (!validationUtils.isArrayOfLength(arrDefinition, 2)) return false; if (arrDefinition[0] !== 'or') return false; if (!validationUtils.isArrayOfLength(arrDefinition[1], 2)) return false; if (!validationUtils.isArrayOfLength(arrDefinit...
javascript
function isDepositDefinition(arrDefinition){ if (!validationUtils.isArrayOfLength(arrDefinition, 2)) return false; if (arrDefinition[0] !== 'or') return false; if (!validationUtils.isArrayOfLength(arrDefinition[1], 2)) return false; if (!validationUtils.isArrayOfLength(arrDefinit...
[ "function", "isDepositDefinition", "(", "arrDefinition", ")", "{", "if", "(", "!", "validationUtils", ".", "isArrayOfLength", "(", "arrDefinition", ",", "2", ")", ")", "return", "false", ";", "if", "(", "arrDefinition", "[", "0", "]", "!==", "'or'", ")", "...
verify if a deposit definition is valid. @param {Array} arrDefinition @return {boolean}
[ "verify", "if", "a", "deposit", "definition", "is", "valid", "." ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L18-L35
train
trustnote/trustnote-pow-common
sc/deposit.js
hasInvalidUnitsFromHistory
function hasInvalidUnitsFromHistory(conn, address, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(address)) return cb("param address is null or empty string"); if(!validationUtils.isValidAddress(address)) return cb("param address is not a valid address"); conn.query( ...
javascript
function hasInvalidUnitsFromHistory(conn, address, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(address)) return cb("param address is null or empty string"); if(!validationUtils.isValidAddress(address)) return cb("param address is not a valid address"); conn.query( ...
[ "function", "hasInvalidUnitsFromHistory", "(", "conn", ",", "address", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isNonemptyString", "(", "address", ")", ")", "return", "cb", "(", "\"param add...
Check if an address has sent invalid unit. @param {obj} conn if conn is null, use db query, otherwise use conn. @param {string} address @param {function} cb( err, hasInvalidUnits ) callback function If there's error, err is the error message and hasInvalidUnits is null. If there's no error and there's invalid...
[ "Check", "if", "an", "address", "has", "sent", "invalid", "unit", "." ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L46-L60
train
trustnote/trustnote-pow-common
sc/deposit.js
getBalanceOfDepositContract
function getBalanceOfDepositContract(conn, depositAddress, roundIndex, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(depositAddress)) return cb("param depositAddress is null or empty string"); if(!validationUtils.isValidAddress(depositAddress)) return cb("param depositAddr...
javascript
function getBalanceOfDepositContract(conn, depositAddress, roundIndex, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(depositAddress)) return cb("param depositAddress is null or empty string"); if(!validationUtils.isValidAddress(depositAddress)) return cb("param depositAddr...
[ "function", "getBalanceOfDepositContract", "(", "conn", ",", "depositAddress", ",", "roundIndex", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isNonemptyString", "(", "depositAddress", ")", ")", "...
Returns deposit address stable balance, Before the roundIndex @param {obj} conn if conn is null, use db query, otherwise use conn. @param {String} depositAddress @param {String} roundIndex @param {function} cb( err, balance ) callback function If address is invalid, then returns err "invalid addre...
[ "Returns", "deposit", "address", "stable", "balance", "Before", "the", "roundIndex" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L74-L117
train
trustnote/trustnote-pow-common
sc/deposit.js
getBalanceOfAllDepositContract
function getBalanceOfAllDepositContract(conn, roundIndex, cb){ var conn = conn || db; if(!validationUtils.isPositiveInteger(roundIndex)) return cb("param roundIndex is not a positive integer"); round.getMaxMciByRoundIndex(conn, roundIndex, function(lastRoundMaxMci){ conn.query("SELECT deposi...
javascript
function getBalanceOfAllDepositContract(conn, roundIndex, cb){ var conn = conn || db; if(!validationUtils.isPositiveInteger(roundIndex)) return cb("param roundIndex is not a positive integer"); round.getMaxMciByRoundIndex(conn, roundIndex, function(lastRoundMaxMci){ conn.query("SELECT deposi...
[ "function", "getBalanceOfAllDepositContract", "(", "conn", ",", "roundIndex", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isPositiveInteger", "(", "roundIndex", ")", ")", "return", "cb", "(", "...
Get all deposit address stable balance, Before the roundIndex @param {obj} conn if conn is null, use db query, otherwise use conn. @param {String} roundIndex @param {function} cb( err, balance ) callback function @return {"base":{"stable":{Integer},"pending":{Integer}}} balance
[ "Get", "all", "deposit", "address", "stable", "balance", "Before", "the", "roundIndex" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L129-L151
train
trustnote/trustnote-pow-common
sc/deposit.js
getDepositAddressBySafeAddress
function getDepositAddressBySafeAddress(conn, safeAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(safeAddress)) return cb("param safeAddress is null or empty string"); if(!validationUtils.isValidAddress(safeAddress)) return cb("param safeAddress is not a valid addre...
javascript
function getDepositAddressBySafeAddress(conn, safeAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(safeAddress)) return cb("param safeAddress is null or empty string"); if(!validationUtils.isValidAddress(safeAddress)) return cb("param safeAddress is not a valid addre...
[ "function", "getDepositAddressBySafeAddress", "(", "conn", ",", "safeAddress", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isNonemptyString", "(", "safeAddress", ")", ")", "return", "cb", "(", ...
Returns deposit address by supernode safe address. @param {obj} conn if conn is null, use db query, otherwise use conn. @param {String} safeAddress @param {function} cb( err, depositAddress ) callback function If address is invalid, then returns err "invalid address". If can not find the address, then ...
[ "Returns", "deposit", "address", "by", "supernode", "safe", "address", "." ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L162-L182
train
trustnote/trustnote-pow-common
sc/deposit.js
getDepositAddressBySupernodeAddress
function getDepositAddressBySupernodeAddress(conn, supernodeAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(supernodeAddress)) return cb("param supernodeAddress is null or empty string"); if(!validationUtils.isValidAddress(supernodeAddress)) return cb("param superno...
javascript
function getDepositAddressBySupernodeAddress(conn, supernodeAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(supernodeAddress)) return cb("param supernodeAddress is null or empty string"); if(!validationUtils.isValidAddress(supernodeAddress)) return cb("param superno...
[ "function", "getDepositAddressBySupernodeAddress", "(", "conn", ",", "supernodeAddress", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isNonemptyString", "(", "supernodeAddress", ")", ")", "return", ...
Returns deposit address by supernode address. @param {obj} conn if conn is null, use db query, otherwise use conn. @param {String} supernodeAddress @param {function} cb( err, deposit_address ) callback function If depositAddress is invalid, then returns err "invalid address". If can not find the addres...
[ "Returns", "deposit", "address", "by", "supernode", "address", "." ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L193-L206
train
trustnote/trustnote-pow-common
sc/deposit.js
getSupernodeByDepositAddress
function getSupernodeByDepositAddress(conn, depositAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(depositAddress)) return cb("param depostiAddress is null or empty string"); if(!validationUtils.isValidAddress(depositAddress)) return cb("param depostiAddress is not ...
javascript
function getSupernodeByDepositAddress(conn, depositAddress, cb){ var conn = conn || db; if(!validationUtils.isNonemptyString(depositAddress)) return cb("param depostiAddress is null or empty string"); if(!validationUtils.isValidAddress(depositAddress)) return cb("param depostiAddress is not ...
[ "function", "getSupernodeByDepositAddress", "(", "conn", ",", "depositAddress", ",", "cb", ")", "{", "var", "conn", "=", "conn", "||", "db", ";", "if", "(", "!", "validationUtils", ".", "isNonemptyString", "(", "depositAddress", ")", ")", "return", "cb", "("...
Returns supernode address by deposit address. @param {obj} conn if conn is null, use db query, otherwise use conn. @param {String} depositAddress @param {function} cb( err, supernodeAddress ) callback function If depositAddress is invalid, then returns err "invalid address". If can not find the address...
[ "Returns", "supernode", "address", "by", "deposit", "address", "." ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L217-L230
train
trustnote/trustnote-pow-common
sc/deposit.js
createDepositAddress
function createDepositAddress(my_address, callback) { var arrDefinition = [ 'or', [ ['address', constants.FOUNDATION_SAFE_ADDRESS], ['address', my_address], ] ]; var shared_address = objectHash.getChash160(arrDefinition) if(isDepositDefinition(arrDefinition)){ return callback.ifOk(shared_add...
javascript
function createDepositAddress(my_address, callback) { var arrDefinition = [ 'or', [ ['address', constants.FOUNDATION_SAFE_ADDRESS], ['address', my_address], ] ]; var shared_address = objectHash.getChash160(arrDefinition) if(isDepositDefinition(arrDefinition)){ return callback.ifOk(shared_add...
[ "function", "createDepositAddress", "(", "my_address", ",", "callback", ")", "{", "var", "arrDefinition", "=", "[", "'or'", ",", "[", "[", "'address'", ",", "constants", ".", "FOUNDATION_SAFE_ADDRESS", "]", ",", "[", "'address'", ",", "my_address", "]", ",", ...
Create Deposit Address @param {String} my_address - address that use to generate deposit address @param {Array} arrDefinition - definiton of miner shared address @param {Object} assocSignersByPath - address paths of shared address @param {Function} callback - callback(deposit_address)
[ "Create", "Deposit", "Address" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/sc/deposit.js#L239-L255
train
trustnote/trustnote-pow-common
validation/validation_byzantine.js
validateProposalJoint
function validateProposalJoint(objJoint, callbacks){ var objUnit = objJoint.unit; if (typeof objUnit !== "object" || objUnit === null) return callbacks.ifInvalid("no unit object"); console.log("\nvalidating joint identified by unit "+objJoint.unit.unit); if (!isStringOfLength(objUnit.unit, constants.HASH_LENG...
javascript
function validateProposalJoint(objJoint, callbacks){ var objUnit = objJoint.unit; if (typeof objUnit !== "object" || objUnit === null) return callbacks.ifInvalid("no unit object"); console.log("\nvalidating joint identified by unit "+objJoint.unit.unit); if (!isStringOfLength(objUnit.unit, constants.HASH_LENG...
[ "function", "validateProposalJoint", "(", "objJoint", ",", "callbacks", ")", "{", "var", "objUnit", "=", "objJoint", ".", "unit", ";", "if", "(", "typeof", "objUnit", "!==", "\"object\"", "||", "objUnit", "===", "null", ")", "return", "callbacks", ".", "ifIn...
validate proposed value
[ "validate", "proposed", "value" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/validation/validation_byzantine.js#L272-L407
train
trustnote/trustnote-pow-common
pow/pow.js
obtainMiningInput
function obtainMiningInput( oConn, uRoundIndex, pfnCallback ) { if ( ! oConn ) { throw new Error( `call obtainMiningInput with invalid oConn.` ); } if ( 'number' !== typeof uRoundIndex ) { throw new Error( `call obtainMiningInput with invalid nRoundIndex.` ); } if ( 'function' !== typeof pfnCallback ) { /...
javascript
function obtainMiningInput( oConn, uRoundIndex, pfnCallback ) { if ( ! oConn ) { throw new Error( `call obtainMiningInput with invalid oConn.` ); } if ( 'number' !== typeof uRoundIndex ) { throw new Error( `call obtainMiningInput with invalid nRoundIndex.` ); } if ( 'function' !== typeof pfnCallback ) { /...
[ "function", "obtainMiningInput", "(", "oConn", ",", "uRoundIndex", ",", "pfnCallback", ")", "{", "if", "(", "!", "oConn", ")", "{", "throw", "new", "Error", "(", "`", "`", ")", ";", "}", "if", "(", "'number'", "!==", "typeof", "uRoundIndex", ")", "{", ...
obtain mining input @param {handle} oConn @param {function} oConn.query @param {number} uRoundIndex @param {function} pfnCallback( err ) @return {boolean} @description start successfully pfnCallback( null, objInput ); failed to start pfnCallback( error );
[ "obtain", "mining", "input" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L235-L386
train
trustnote/trustnote-pow-common
pow/pow.js
startMiningWithInputs
function startMiningWithInputs( oInput, pfnCallback ) { console.log( `>***< will start mining with inputs : ${ JSON.stringify( oInput ) }` ); if ( _bBrowser && ! _bWallet ) { throw new Error( 'I am not be able to run in a Web Browser.' ); } if ( 'object' !== typeof oInput ) { throw new Error( 'call startMini...
javascript
function startMiningWithInputs( oInput, pfnCallback ) { console.log( `>***< will start mining with inputs : ${ JSON.stringify( oInput ) }` ); if ( _bBrowser && ! _bWallet ) { throw new Error( 'I am not be able to run in a Web Browser.' ); } if ( 'object' !== typeof oInput ) { throw new Error( 'call startMini...
[ "function", "startMiningWithInputs", "(", "oInput", ",", "pfnCallback", ")", "{", "console", ".", "log", "(", "`", "${", "JSON", ".", "stringify", "(", "oInput", ")", "}", "`", ")", ";", "if", "(", "_bBrowser", "&&", "!", "_bWallet", ")", "{", "throw",...
start calculation with inputs @param {object} oInput @param {number} oInput.roundIndex @param {string} oInput.firstTrustMEBall @param {string} oInput.bits @param {string} oInput.publicSeed @param {string} oInput.superNodeAuthor @param {function} pfnCallback( err ) will be called immediately while we start mining @retu...
[ "start", "calculation", "with", "inputs" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L418-L515
train
trustnote/trustnote-pow-common
pow/pow.js
calculatePublicSeedByRoundIndex
function calculatePublicSeedByRoundIndex( oConn, nRoundIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call calculatePublicSeedByRoundIndex with invalid oConn` ); } if ( 'number' !== typeof nRoundIndex ) { return pfnCallback( `call calculatePublicSeedByRoundIndex with invalid nRoundIndex` ); } i...
javascript
function calculatePublicSeedByRoundIndex( oConn, nRoundIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call calculatePublicSeedByRoundIndex with invalid oConn` ); } if ( 'number' !== typeof nRoundIndex ) { return pfnCallback( `call calculatePublicSeedByRoundIndex with invalid nRoundIndex` ); } i...
[ "function", "calculatePublicSeedByRoundIndex", "(", "oConn", ",", "nRoundIndex", ",", "pfnCallback", ")", "{", "if", "(", "!", "oConn", ")", "{", "return", "pfnCallback", "(", "`", "`", ")", ";", "}", "if", "(", "'number'", "!==", "typeof", "nRoundIndex", ...
calculate public seed by round index @param {handle} oConn @param {function} oConn.query @param {number} nRoundIndex round 1 hard code round 2 previous seed [] TrustME Ball round 3 previous seed [] TrustME Ball @param {function} pfnCallback( err, sSeed ) @documentation https://github.com/trustnote/document/blob/mast...
[ "calculate", "public", "seed", "by", "round", "index" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L675-L780
train
trustnote/trustnote-pow-common
pow/pow.js
queryPublicSeedByRoundIndex
function queryPublicSeedByRoundIndex( oConn, nRoundIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call queryPublicSeedByRoundIndex with invalid oConn` ); } if ( 'number' !== typeof nRoundIndex || nRoundIndex <= 0 ) { return pfnCallback( `call queryPublicSeedByRoundIndex with invalid nRoundIndex` ...
javascript
function queryPublicSeedByRoundIndex( oConn, nRoundIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call queryPublicSeedByRoundIndex with invalid oConn` ); } if ( 'number' !== typeof nRoundIndex || nRoundIndex <= 0 ) { return pfnCallback( `call queryPublicSeedByRoundIndex with invalid nRoundIndex` ...
[ "function", "queryPublicSeedByRoundIndex", "(", "oConn", ",", "nRoundIndex", ",", "pfnCallback", ")", "{", "if", "(", "!", "oConn", ")", "{", "return", "pfnCallback", "(", "`", "`", ")", ";", "}", "if", "(", "'number'", "!==", "typeof", "nRoundIndex", "||"...
get public seed by round index @param {handle} oConn @param {function} oConn.query @param {number} nRoundIndex @param {function} pfnCallback( err, arrCoinBaseList )
[ "get", "public", "seed", "by", "round", "index" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L791-L820
train
trustnote/trustnote-pow-common
pow/pow.js
queryBitsValueByCycleIndex
function queryBitsValueByCycleIndex( oConn, uCycleIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call queryBitsValueByCycleIndex with invalid oConn` ); } if ( 'number' !== typeof uCycleIndex || uCycleIndex <= 0 ) { return pfnCallback( `call queryBitsValueByCycleIndex with invalid uCycleIndex` ); ...
javascript
function queryBitsValueByCycleIndex( oConn, uCycleIndex, pfnCallback ) { if ( ! oConn ) { return pfnCallback( `call queryBitsValueByCycleIndex with invalid oConn` ); } if ( 'number' !== typeof uCycleIndex || uCycleIndex <= 0 ) { return pfnCallback( `call queryBitsValueByCycleIndex with invalid uCycleIndex` ); ...
[ "function", "queryBitsValueByCycleIndex", "(", "oConn", ",", "uCycleIndex", ",", "pfnCallback", ")", "{", "if", "(", "!", "oConn", ")", "{", "return", "pfnCallback", "(", "`", "`", ")", ";", "}", "if", "(", "'number'", "!==", "typeof", "uCycleIndex", "||",...
query bits value by round index from database @param {handle} oConn @param {function} oConn.query @param {number} uCycleIndex @param {function} pfnCallback( err, nBitsValue )
[ "query", "bits", "value", "by", "round", "index", "from", "database" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L831-L860
train
trustnote/trustnote-pow-common
pow/pow.js
_createMiningInputBufferFromObject
function _createMiningInputBufferFromObject( objInput ) { let objInputCpy; let sInput; let bufSha512; let bufMd5; let bufRmd160; let bufSha384; if ( 'object' !== typeof objInput ) { return null; } // ... objInputCpy = { roundIndex : objInput.roundIndex, firstTrustMEBall : objInput.firstTrustMEBall, ...
javascript
function _createMiningInputBufferFromObject( objInput ) { let objInputCpy; let sInput; let bufSha512; let bufMd5; let bufRmd160; let bufSha384; if ( 'object' !== typeof objInput ) { return null; } // ... objInputCpy = { roundIndex : objInput.roundIndex, firstTrustMEBall : objInput.firstTrustMEBall, ...
[ "function", "_createMiningInputBufferFromObject", "(", "objInput", ")", "{", "let", "objInputCpy", ";", "let", "sInput", ";", "let", "bufSha512", ";", "let", "bufMd5", ";", "let", "bufRmd160", ";", "let", "bufSha384", ";", "if", "(", "'object'", "!==", "typeof...
create an input buffer with length of 140 from Js plain object @public @param {object} objInput @return {Buffer}
[ "create", "an", "input", "buffer", "with", "length", "of", "140", "from", "Js", "plain", "object" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L1226-L1255
train
trustnote/trustnote-pow-common
pow/pow.js
_generateRandomInteger
function _generateRandomInteger( nMin, nMax ) { return Math.floor( Math.random() * ( nMax + 1 - nMin ) ) + nMin; }
javascript
function _generateRandomInteger( nMin, nMax ) { return Math.floor( Math.random() * ( nMax + 1 - nMin ) ) + nMin; }
[ "function", "_generateRandomInteger", "(", "nMin", ",", "nMax", ")", "{", "return", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "(", "nMax", "+", "1", "-", "nMin", ")", ")", "+", "nMin", ";", "}" ]
generate random integer @private @param {number} nMin @param {number} nMax @returns {*}
[ "generate", "random", "integer" ]
582965aee4cf98ad15188bfa2392f01b86fe8683
https://github.com/trustnote/trustnote-pow-common/blob/582965aee4cf98ad15188bfa2392f01b86fe8683/pow/pow.js#L1266-L1269
train
ethereumjs/ethereumjs-block
header-from-rpc.js
blockHeaderFromRpc
function blockHeaderFromRpc (blockParams) { const blockHeader = new BlockHeader({ parentHash: blockParams.parentHash, uncleHash: blockParams.sha3Uncles, coinbase: blockParams.miner, stateRoot: blockParams.stateRoot, transactionsTrie: blockParams.transactionsRoot, receiptTrie: blockParams.recei...
javascript
function blockHeaderFromRpc (blockParams) { const blockHeader = new BlockHeader({ parentHash: blockParams.parentHash, uncleHash: blockParams.sha3Uncles, coinbase: blockParams.miner, stateRoot: blockParams.stateRoot, transactionsTrie: blockParams.transactionsRoot, receiptTrie: blockParams.recei...
[ "function", "blockHeaderFromRpc", "(", "blockParams", ")", "{", "const", "blockHeader", "=", "new", "BlockHeader", "(", "{", "parentHash", ":", "blockParams", ".", "parentHash", ",", "uncleHash", ":", "blockParams", ".", "sha3Uncles", ",", "coinbase", ":", "bloc...
Creates a new block header object from Ethereum JSON RPC. @param {Object} blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber)
[ "Creates", "a", "new", "block", "header", "object", "from", "Ethereum", "JSON", "RPC", "." ]
2c3908e5bbb6c9c94aeb5547a779295433f42545
https://github.com/ethereumjs/ethereumjs-block/blob/2c3908e5bbb6c9c94aeb5547a779295433f42545/header-from-rpc.js#L11-L36
train
ethereumjs/ethereumjs-block
from-rpc.js
blockFromRpc
function blockFromRpc (blockParams, uncles) { uncles = uncles || [] const block = new Block({ transactions: [], uncleHeaders: [] }) block.header = blockHeaderFromRpc(blockParams) block.transactions = (blockParams.transactions || []).map(function (_txParams) { const txParams = normalizeTxParams(_t...
javascript
function blockFromRpc (blockParams, uncles) { uncles = uncles || [] const block = new Block({ transactions: [], uncleHeaders: [] }) block.header = blockHeaderFromRpc(blockParams) block.transactions = (blockParams.transactions || []).map(function (_txParams) { const txParams = normalizeTxParams(_t...
[ "function", "blockFromRpc", "(", "blockParams", ",", "uncles", ")", "{", "uncles", "=", "uncles", "||", "[", "]", "const", "block", "=", "new", "Block", "(", "{", "transactions", ":", "[", "]", ",", "uncleHeaders", ":", "[", "]", "}", ")", "block", "...
Creates a new block object from Ethereum JSON RPC. @param {Object} blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber) @param {Array.<Object>} Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex)
[ "Creates", "a", "new", "block", "object", "from", "Ethereum", "JSON", "RPC", "." ]
2c3908e5bbb6c9c94aeb5547a779295433f42545
https://github.com/ethereumjs/ethereumjs-block/blob/2c3908e5bbb6c9c94aeb5547a779295433f42545/from-rpc.js#L14-L40
train
ethereumjs/ethereumjs-block
index.js
function (cb3) { blockChain.getDetails(uncle.hash(), function (err, blockInfo) { // TODO: remove uncles from BC if (blockInfo && blockInfo.isUncle) { cb3(err || 'uncle already included') } else { cb3() } }) }
javascript
function (cb3) { blockChain.getDetails(uncle.hash(), function (err, blockInfo) { // TODO: remove uncles from BC if (blockInfo && blockInfo.isUncle) { cb3(err || 'uncle already included') } else { cb3() } }) }
[ "function", "(", "cb3", ")", "{", "blockChain", ".", "getDetails", "(", "uncle", ".", "hash", "(", ")", ",", "function", "(", "err", ",", "blockInfo", ")", "{", "// TODO: remove uncles from BC", "if", "(", "blockInfo", "&&", "blockInfo", ".", "isUncle", ")...
check to make sure the uncle is not already in the blockchain
[ "check", "to", "make", "sure", "the", "uncle", "is", "not", "already", "in", "the", "blockchain" ]
2c3908e5bbb6c9c94aeb5547a779295433f42545
https://github.com/ethereumjs/ethereumjs-block/blob/2c3908e5bbb6c9c94aeb5547a779295433f42545/index.js#L271-L280
train
kcartlidge/nodepub
src/index.js
replacements
function replacements(document, original) { var modified = moment().format('YYYY-MM-DD'); var result = original; result = tagReplace(result, 'EOL', '\n'); result = tagReplace(result, 'ID', document.metadata.id); result = tagReplace(result, 'TITLE', document.metadata.title); result = tagReplace(result, 'SERI...
javascript
function replacements(document, original) { var modified = moment().format('YYYY-MM-DD'); var result = original; result = tagReplace(result, 'EOL', '\n'); result = tagReplace(result, 'ID', document.metadata.id); result = tagReplace(result, 'TITLE', document.metadata.title); result = tagReplace(result, 'SERI...
[ "function", "replacements", "(", "document", ",", "original", ")", "{", "var", "modified", "=", "moment", "(", ")", ".", "format", "(", "'YYYY-MM-DD'", ")", ";", "var", "result", "=", "original", ";", "result", "=", "tagReplace", "(", "result", ",", "'EO...
Do all in-line replacements needed.
[ "Do", "all", "in", "-", "line", "replacements", "needed", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L178-L199
train
kcartlidge/nodepub
src/index.js
getContainer
function getContainer(document) { var content = structuralFiles.getContainer(document); return replacements(document, replacements(document, content)); }
javascript
function getContainer(document) { var content = structuralFiles.getContainer(document); return replacements(document, replacements(document, content)); }
[ "function", "getContainer", "(", "document", ")", "{", "var", "content", "=", "structuralFiles", ".", "getContainer", "(", "document", ")", ";", "return", "replacements", "(", "document", ",", "replacements", "(", "document", ",", "content", ")", ")", ";", "...
Provide the contents of the container XML file.
[ "Provide", "the", "contents", "of", "the", "container", "XML", "file", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L207-L210
train
kcartlidge/nodepub
src/index.js
getNCX
function getNCX(document) { var content = structuralFiles.getNCX(document); return replacements(document, replacements(document, content)); }
javascript
function getNCX(document) { var content = structuralFiles.getNCX(document); return replacements(document, replacements(document, content)); }
[ "function", "getNCX", "(", "document", ")", "{", "var", "content", "=", "structuralFiles", ".", "getNCX", "(", "document", ")", ";", "return", "replacements", "(", "document", ",", "replacements", "(", "document", ",", "content", ")", ")", ";", "}" ]
Provide the contents of the NCX file.
[ "Provide", "the", "contents", "of", "the", "NCX", "file", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L219-L222
train
kcartlidge/nodepub
src/index.js
getTOC
function getTOC(document) { var content = ""; if (document.generateContentsCallback) { var callbackContent = document.generateContentsCallback(document.filesForTOC); content = markupFiles.getContents(document, callbackContent); } else { content = markupFiles.getContents(document); } return replace...
javascript
function getTOC(document) { var content = ""; if (document.generateContentsCallback) { var callbackContent = document.generateContentsCallback(document.filesForTOC); content = markupFiles.getContents(document, callbackContent); } else { content = markupFiles.getContents(document); } return replace...
[ "function", "getTOC", "(", "document", ")", "{", "var", "content", "=", "\"\"", ";", "if", "(", "document", ".", "generateContentsCallback", ")", "{", "var", "callbackContent", "=", "document", ".", "generateContentsCallback", "(", "document", ".", "filesForTOC"...
Provide the contents of the TOC file.
[ "Provide", "the", "contents", "of", "the", "TOC", "file", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L225-L234
train
kcartlidge/nodepub
src/index.js
getCover
function getCover(document) { var content = markupFiles.getCover(); return replacements(document, replacements(document, content)); }
javascript
function getCover(document) { var content = markupFiles.getCover(); return replacements(document, replacements(document, content)); }
[ "function", "getCover", "(", "document", ")", "{", "var", "content", "=", "markupFiles", ".", "getCover", "(", ")", ";", "return", "replacements", "(", "document", ",", "replacements", "(", "document", ",", "content", ")", ")", ";", "}" ]
Provide the contents of the cover HTML enclosure.
[ "Provide", "the", "contents", "of", "the", "cover", "HTML", "enclosure", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L237-L240
train
kcartlidge/nodepub
src/index.js
getCSS
function getCSS(document) { var content = document.CSS; return replacements(document, replacements(document, content)); }
javascript
function getCSS(document) { var content = document.CSS; return replacements(document, replacements(document, content)); }
[ "function", "getCSS", "(", "document", ")", "{", "var", "content", "=", "document", ".", "CSS", ";", "return", "replacements", "(", "document", ",", "replacements", "(", "document", ",", "content", ")", ")", ";", "}" ]
Provide the contents of the CSS file.
[ "Provide", "the", "contents", "of", "the", "CSS", "file", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L243-L246
train
kcartlidge/nodepub
src/index.js
getSection
function getSection(document, sectionNumber) { var content = markupFiles.getSection(document, sectionNumber); return replacements(document, replacements(document, content)); }
javascript
function getSection(document, sectionNumber) { var content = markupFiles.getSection(document, sectionNumber); return replacements(document, replacements(document, content)); }
[ "function", "getSection", "(", "document", ",", "sectionNumber", ")", "{", "var", "content", "=", "markupFiles", ".", "getSection", "(", "document", ",", "sectionNumber", ")", ";", "return", "replacements", "(", "document", ",", "replacements", "(", "document", ...
Provide the contents of a single section's HTML.
[ "Provide", "the", "contents", "of", "a", "single", "section", "s", "HTML", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L249-L252
train
kcartlidge/nodepub
src/index.js
makeFolder
function makeFolder(path, cb) { if (cb) { fs.mkdir(path, function (err) { if (err && err.code != 'EEXIST') { throw err; } cb(); }); } }
javascript
function makeFolder(path, cb) { if (cb) { fs.mkdir(path, function (err) { if (err && err.code != 'EEXIST') { throw err; } cb(); }); } }
[ "function", "makeFolder", "(", "path", ",", "cb", ")", "{", "if", "(", "cb", ")", "{", "fs", ".", "mkdir", "(", "path", ",", "function", "(", "err", ")", "{", "if", "(", "err", "&&", "err", ".", "code", "!=", "'EEXIST'", ")", "{", "throw", "err...
Create a folder, throwing an error only if the error is not that the folder already exists. Effectively creates if not found.
[ "Create", "a", "folder", "throwing", "an", "error", "only", "if", "the", "error", "is", "not", "that", "the", "folder", "already", "exists", ".", "Effectively", "creates", "if", "not", "found", "." ]
4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258
https://github.com/kcartlidge/nodepub/blob/4c4b53a3c559f6a0e32f70d63c2b750b2eaa1258/src/index.js#L256-L265
train
royriojas/file-entry-cache
cache.js
function ( files ) { var me = this; files = files || [ ]; return me.normalizeEntries( files ).filter( function ( entry ) { return entry.changed; } ).map( function ( entry ) { return entry.key; } ); }
javascript
function ( files ) { var me = this; files = files || [ ]; return me.normalizeEntries( files ).filter( function ( entry ) { return entry.changed; } ).map( function ( entry ) { return entry.key; } ); }
[ "function", "(", "files", ")", "{", "var", "me", "=", "this", ";", "files", "=", "files", "||", "[", "]", ";", "return", "me", ".", "normalizeEntries", "(", "files", ")", ".", "filter", "(", "function", "(", "entry", ")", "{", "return", "entry", "....
Return the list o the files that changed compared against the ones stored in the cache @method getUpdated @param files {Array} the array of files to compare against the ones in the cache @returns {Array}
[ "Return", "the", "list", "o", "the", "files", "that", "changed", "compared", "against", "the", "ones", "stored", "in", "the", "cache" ]
03f700c99b76133dc14648b465a1550ec2930e5c
https://github.com/royriojas/file-entry-cache/blob/03f700c99b76133dc14648b465a1550ec2930e5c/cache.js#L176-L185
train
royriojas/file-entry-cache
cache.js
function ( files ) { files = files || [ ]; var me = this; var nEntries = files.map( function ( file ) { return me.getFileDescriptor( file ); } ); //normalizeEntries = nEntries; return nEntries; }
javascript
function ( files ) { files = files || [ ]; var me = this; var nEntries = files.map( function ( file ) { return me.getFileDescriptor( file ); } ); //normalizeEntries = nEntries; return nEntries; }
[ "function", "(", "files", ")", "{", "files", "=", "files", "||", "[", "]", ";", "var", "me", "=", "this", ";", "var", "nEntries", "=", "files", ".", "map", "(", "function", "(", "file", ")", "{", "return", "me", ".", "getFileDescriptor", "(", "file...
return the list of files @method normalizeEntries @param files @returns {*}
[ "return", "the", "list", "of", "files" ]
03f700c99b76133dc14648b465a1550ec2930e5c
https://github.com/royriojas/file-entry-cache/blob/03f700c99b76133dc14648b465a1550ec2930e5c/cache.js#L193-L203
train
royriojas/file-entry-cache
cache.js
function ( noPrune ) { removeNotFoundFiles(); noPrune = typeof noPrune === 'undefined' ? true : noPrune; var entries = normalizedEntries; var keys = Object.keys( entries ); if ( keys.length === 0 ) { return; } var me = this; keys.forEach( fu...
javascript
function ( noPrune ) { removeNotFoundFiles(); noPrune = typeof noPrune === 'undefined' ? true : noPrune; var entries = normalizedEntries; var keys = Object.keys( entries ); if ( keys.length === 0 ) { return; } var me = this; keys.forEach( fu...
[ "function", "(", "noPrune", ")", "{", "removeNotFoundFiles", "(", ")", ";", "noPrune", "=", "typeof", "noPrune", "===", "'undefined'", "?", "true", ":", "noPrune", ";", "var", "entries", "=", "normalizedEntries", ";", "var", "keys", "=", "Object", ".", "ke...
Sync the files and persist them to the cache @method reconcile
[ "Sync", "the", "files", "and", "persist", "them", "to", "the", "cache" ]
03f700c99b76133dc14648b465a1550ec2930e5c
https://github.com/royriojas/file-entry-cache/blob/03f700c99b76133dc14648b465a1550ec2930e5c/cache.js#L253-L283
train
aerospike/aerospike-client-nodejs
lib/filter.js
typeOf
function typeOf (value) { if (value === null) return 'null' var valueType = typeof value if (valueType === 'object') { valueType = value.constructor.name.toLowerCase() } return valueType }
javascript
function typeOf (value) { if (value === null) return 'null' var valueType = typeof value if (valueType === 'object') { valueType = value.constructor.name.toLowerCase() } return valueType }
[ "function", "typeOf", "(", "value", ")", "{", "if", "(", "value", "===", "null", ")", "return", "'null'", "var", "valueType", "=", "typeof", "value", "if", "(", "valueType", "===", "'object'", ")", "{", "valueType", "=", "value", ".", "constructor", ".",...
Helper function to determine the type of a primitive or Object
[ "Helper", "function", "to", "determine", "the", "type", "of", "a", "primitive", "or", "Object" ]
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/lib/filter.js#L94-L101
train
aerospike/aerospike-client-nodejs
lib/info.js
parseKeyValue
function parseKeyValue (str, sep1, sep2) { var result = {} str.split(sep1).forEach(function (kv) { if (kv.length > 0) { kv = kv.split(sep2, 2) result[kv[0]] = parseValue(kv[1]) } }) return result }
javascript
function parseKeyValue (str, sep1, sep2) { var result = {} str.split(sep1).forEach(function (kv) { if (kv.length > 0) { kv = kv.split(sep2, 2) result[kv[0]] = parseValue(kv[1]) } }) return result }
[ "function", "parseKeyValue", "(", "str", ",", "sep1", ",", "sep2", ")", "{", "var", "result", "=", "{", "}", "str", ".", "split", "(", "sep1", ")", ".", "forEach", "(", "function", "(", "kv", ")", "{", "if", "(", "kv", ".", "length", ">", "0", ...
Parses a string value representing a key-value-map separated by sep1 and sep2 into an Object. Ex.: - parseKeyValue('a=1;b=2', ';', '=') => { a: 1, b: 2 } @private
[ "Parses", "a", "string", "value", "representing", "a", "key", "-", "value", "-", "map", "separated", "by", "sep1", "and", "sep2", "into", "an", "Object", "." ]
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/lib/info.js#L104-L113
train
aerospike/aerospike-client-nodejs
lib/info.js
smartParse
function smartParse (str, sep1, sep2) { sep1 = sep1 || ';' sep2 = sep2 || '=' if ((typeof str === 'string') && str.indexOf(sep1) >= 0) { if (str.indexOf(sep2) >= 0) { return parseKeyValue(str, sep1, sep2) } else { return str.split(sep1) } } return str }
javascript
function smartParse (str, sep1, sep2) { sep1 = sep1 || ';' sep2 = sep2 || '=' if ((typeof str === 'string') && str.indexOf(sep1) >= 0) { if (str.indexOf(sep2) >= 0) { return parseKeyValue(str, sep1, sep2) } else { return str.split(sep1) } } return str }
[ "function", "smartParse", "(", "str", ",", "sep1", ",", "sep2", ")", "{", "sep1", "=", "sep1", "||", "';'", "sep2", "=", "sep2", "||", "'='", "if", "(", "(", "typeof", "str", "===", "'string'", ")", "&&", "str", ".", "indexOf", "(", "sep1", ")", ...
Split string into list or key-value-pairs depending on whether the given separator chars appear in the string. This is the logic used by the old parseInfo function and the default logic used by the new parse function unless a specific format is defined for an info key. Ex.: - smartParse('foo') => 'foo' - smartParse('f...
[ "Split", "string", "into", "list", "or", "key", "-", "value", "-", "pairs", "depending", "on", "whether", "the", "given", "separator", "chars", "appear", "in", "the", "string", ".", "This", "is", "the", "logic", "used", "by", "the", "old", "parseInfo", "...
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/lib/info.js#L128-L139
train
aerospike/aerospike-client-nodejs
lib/info.js
getSeparators
function getSeparators (key) { let pattern = Object.keys(separators).find(p => minimatch(key, p)) const seps = separators[pattern] || defaultSeparators return seps.slice() // return a copy of the array }
javascript
function getSeparators (key) { let pattern = Object.keys(separators).find(p => minimatch(key, p)) const seps = separators[pattern] || defaultSeparators return seps.slice() // return a copy of the array }
[ "function", "getSeparators", "(", "key", ")", "{", "let", "pattern", "=", "Object", ".", "keys", "(", "separators", ")", ".", "find", "(", "p", "=>", "minimatch", "(", "key", ",", "p", ")", ")", "const", "seps", "=", "separators", "[", "pattern", "]"...
Returns separators to use for the given info key. @private
[ "Returns", "separators", "to", "use", "for", "the", "given", "info", "key", "." ]
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/lib/info.js#L146-L150
train
aerospike/aerospike-client-nodejs
lib/info.js
deepSplitString
function deepSplitString (input, separators) { if (input === null || typeof input === 'undefined') { return input } if (separators.length === 0) { return input } const sep = separators.shift() let output = input if (typeof input === 'string') { output = splitString(input, sep) } else if (A...
javascript
function deepSplitString (input, separators) { if (input === null || typeof input === 'undefined') { return input } if (separators.length === 0) { return input } const sep = separators.shift() let output = input if (typeof input === 'string') { output = splitString(input, sep) } else if (A...
[ "function", "deepSplitString", "(", "input", ",", "separators", ")", "{", "if", "(", "input", "===", "null", "||", "typeof", "input", "===", "'undefined'", ")", "{", "return", "input", "}", "if", "(", "separators", ".", "length", "===", "0", ")", "{", ...
Splits a string into a, possibly nested, array or object using the given separators. @private
[ "Splits", "a", "string", "into", "a", "possibly", "nested", "array", "or", "object", "using", "the", "given", "separators", "." ]
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/lib/info.js#L158-L185
train
aerospike/aerospike-client-nodejs
benchmarks/main.js
workerProbe
function workerProbe () { Object.keys(cluster.workers).forEach(function (id) { cluster.workers[id].send(['trans']) }) }
javascript
function workerProbe () { Object.keys(cluster.workers).forEach(function (id) { cluster.workers[id].send(['trans']) }) }
[ "function", "workerProbe", "(", ")", "{", "Object", ".", "keys", "(", "cluster", ".", "workers", ")", ".", "forEach", "(", "function", "(", "id", ")", "{", "cluster", ".", "workers", "[", "id", "]", ".", "send", "(", "[", "'trans'", "]", ")", "}", ...
Signal all workers asking for data on transactions
[ "Signal", "all", "workers", "asking", "for", "data", "on", "transactions" ]
2b9554d1158abda58c17cfbd0438d78f0212ef9e
https://github.com/aerospike/aerospike-client-nodejs/blob/2b9554d1158abda58c17cfbd0438d78f0212ef9e/benchmarks/main.js#L127-L131
train
nebulasio/neb.js
lib/account.js
function (priv) { if (utils.isString(priv) || Buffer.isBuffer(priv)) { this.privKey = priv.length === 32 ? priv : Buffer(priv, 'hex'); this.pubKey = null; this.address = null; } }
javascript
function (priv) { if (utils.isString(priv) || Buffer.isBuffer(priv)) { this.privKey = priv.length === 32 ? priv : Buffer(priv, 'hex'); this.pubKey = null; this.address = null; } }
[ "function", "(", "priv", ")", "{", "if", "(", "utils", ".", "isString", "(", "priv", ")", "||", "Buffer", ".", "isBuffer", "(", "priv", ")", ")", "{", "this", ".", "privKey", "=", "priv", ".", "length", "===", "32", "?", "priv", ":", "Buffer", "(...
Private Key setter. @param {Hash} priv - Account private key. @example account.setPrivateKey("ac3773e06ae74c0fa566b0e421d4e391333f31aef90b383f0c0e83e4873609d6");
[ "Private", "Key", "setter", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/account.js#L188-L194
train
nebulasio/neb.js
lib/account.js
function () { if (utils.isNull(this.address)) { var pubKey = this.getPublicKey(); if (pubKey.length !== 64) { pubKey = cryptoUtils.secp256k1.publicKeyConvert(pubKey, false).slice(1); } // The uncompressed form consists of a 0x04 (in analogy to th...
javascript
function () { if (utils.isNull(this.address)) { var pubKey = this.getPublicKey(); if (pubKey.length !== 64) { pubKey = cryptoUtils.secp256k1.publicKeyConvert(pubKey, false).slice(1); } // The uncompressed form consists of a 0x04 (in analogy to th...
[ "function", "(", ")", "{", "if", "(", "utils", ".", "isNull", "(", "this", ".", "address", ")", ")", "{", "var", "pubKey", "=", "this", ".", "getPublicKey", "(", ")", ";", "if", "(", "pubKey", ".", "length", "!==", "64", ")", "{", "pubKey", "=", ...
Accaunt address getter. @return {Buffer} Account address. @example var publicKey = account.getAddress(); //<Buffer 7f 87 83 58 46 96 12 7d 1a c0 57 1a 42 87 c6 25 36 08 ff 32 61 36 51 7c>
[ "Accaunt", "address", "getter", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/account.js#L250-L272
train
nebulasio/neb.js
lib/account.js
function (password, opts) { /*jshint maxcomplexity:17 */ opts = opts || {}; var salt = opts.salt || cryptoUtils.crypto.randomBytes(32); var iv = opts.iv || cryptoUtils.crypto.randomBytes(16); var derivedKey; var kdf = opts.kdf || 'scrypt'; var kdfparams = { ...
javascript
function (password, opts) { /*jshint maxcomplexity:17 */ opts = opts || {}; var salt = opts.salt || cryptoUtils.crypto.randomBytes(32); var iv = opts.iv || cryptoUtils.crypto.randomBytes(16); var derivedKey; var kdf = opts.kdf || 'scrypt'; var kdfparams = { ...
[ "function", "(", "password", ",", "opts", ")", "{", "/*jshint maxcomplexity:17 */", "opts", "=", "opts", "||", "{", "}", ";", "var", "salt", "=", "opts", ".", "salt", "||", "cryptoUtils", ".", "crypto", ".", "randomBytes", "(", "32", ")", ";", "var", "...
Generate key buy passphrase and options. @param {Password} password - Provided password. @param {KeyOptions} opts - Key options. @return {Key} Key Object. @example var key = account.toKey("passphrase");
[ "Generate", "key", "buy", "passphrase", "and", "options", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/account.js#L295-L344
train
nebulasio/neb.js
lib/account.js
function (input, password, nonStrict) { /*jshint maxcomplexity:10 */ var json = (typeof input === 'object') ? input : JSON.parse(nonStrict ? input.toLowerCase() : input); if (json.version !== KeyVersion3 && json.version !== KeyCurrentVersion) { throw new Error('Not supported wallet ...
javascript
function (input, password, nonStrict) { /*jshint maxcomplexity:10 */ var json = (typeof input === 'object') ? input : JSON.parse(nonStrict ? input.toLowerCase() : input); if (json.version !== KeyVersion3 && json.version !== KeyCurrentVersion) { throw new Error('Not supported wallet ...
[ "function", "(", "input", ",", "password", ",", "nonStrict", ")", "{", "/*jshint maxcomplexity:10 */", "var", "json", "=", "(", "typeof", "input", "===", "'object'", ")", "?", "input", ":", "JSON", ".", "parse", "(", "nonStrict", "?", "input", ".", "toLowe...
Restore account from key and passphrase. @param {Key} input - Key Object. @param {Password} password - Provided password. @param {Boolean} nonStrict - Strict сase sensitivity flag. @return {@link Account} - Instance of Account restored from key and passphrase.
[ "Restore", "account", "from", "key", "and", "passphrase", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/account.js#L368-L411
train
nebulasio/neb.js
lib/transaction.js
function (options) { if (arguments.length > 0) { options = utils.argumentsToObject(['chainID', 'from', 'to', 'value', 'nonce', 'gasPrice', 'gasLimit', 'contract'], arguments); this.chainID = options.chainID; this.from = account.fromAddress(options.from); this.to = account.fromAddres...
javascript
function (options) { if (arguments.length > 0) { options = utils.argumentsToObject(['chainID', 'from', 'to', 'value', 'nonce', 'gasPrice', 'gasLimit', 'contract'], arguments); this.chainID = options.chainID; this.from = account.fromAddress(options.from); this.to = account.fromAddres...
[ "function", "(", "options", ")", "{", "if", "(", "arguments", ".", "length", ">", "0", ")", "{", "options", "=", "utils", ".", "argumentsToObject", "(", "[", "'chainID'", ",", "'from'", ",", "'to'", ",", "'value'", ",", "'nonce'", ",", "'gasPrice'", ",...
Represent Transaction parameters @typedef {Object} TransactionOptions @property {Number} options.chainID - Transaction chain id. @property {HexString} options.from - Hex string of the sender account addresss.. @property {HexString} options.to - Hex string of the receiver account addresss.. @property {Number} options.v...
[ "Represent", "Transaction", "parameters" ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/transaction.js#L128-L154
train
nebulasio/neb.js
lib/transaction.js
function () { var Data = root.lookup("corepb.Data"); var err = Data.verify(this.data); if (err) { throw new Error(err); } var data = Data.create(this.data); var dataBuffer = Data.encode(data).finish(); var hash = cryptoUtils.sha3( this.from...
javascript
function () { var Data = root.lookup("corepb.Data"); var err = Data.verify(this.data); if (err) { throw new Error(err); } var data = Data.create(this.data); var dataBuffer = Data.encode(data).finish(); var hash = cryptoUtils.sha3( this.from...
[ "function", "(", ")", "{", "var", "Data", "=", "root", ".", "lookup", "(", "\"corepb.Data\"", ")", ";", "var", "err", "=", "Data", ".", "verify", "(", "this", ".", "data", ")", ";", "if", "(", "err", ")", "{", "throw", "new", "Error", "(", "err",...
Convert transaction to hash by SHA3-256 algorithm. @return {Hash} hash of Transaction. @example var acc = Account.NewAccount(); var tx = new Transaction({ chainID: 1, from: acc, to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17", value: 10, nonce: 12, gasPrice: 1000000, gasLimit: 2000000 }); var txHash = tx.hashTransaction()...
[ "Convert", "transaction", "to", "hash", "by", "SHA3", "-", "256", "algorithm", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/transaction.js#L254-L274
train
nebulasio/neb.js
lib/transaction.js
function () { if (this.from.getPrivateKey() !== null) { this.hash = this.hashTransaction(); this.alg = SECP256K1; this.sign = cryptoUtils.sign(this.hash, this.from.getPrivateKey()); } else { throw new Error("transaction from address's private key is invali...
javascript
function () { if (this.from.getPrivateKey() !== null) { this.hash = this.hashTransaction(); this.alg = SECP256K1; this.sign = cryptoUtils.sign(this.hash, this.from.getPrivateKey()); } else { throw new Error("transaction from address's private key is invali...
[ "function", "(", ")", "{", "if", "(", "this", ".", "from", ".", "getPrivateKey", "(", ")", "!==", "null", ")", "{", "this", ".", "hash", "=", "this", ".", "hashTransaction", "(", ")", ";", "this", ".", "alg", "=", "SECP256K1", ";", "this", ".", "...
Sign transaction with the specified algorithm. @example var acc = Account.NewAccount(); var tx = new Transaction({ chainID: 1, from: acc, to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17", value: 10, nonce: 12, gasPrice: 1000000, gasLimit: 2000000 }); tx.signTransaction();
[ "Sign", "transaction", "with", "the", "specified", "algorithm", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/transaction.js#L292-L300
train
nebulasio/neb.js
lib/transaction.js
function() { return { chainID: this.chainID, from: this.from.getAddressString(), to: this.to.getAddressString(), value: utils.isBigNumber(this.value) ? this.value.toNumber() : this.value, nonce: this.nonce, gasPrice: utils.isBigNumber(this....
javascript
function() { return { chainID: this.chainID, from: this.from.getAddressString(), to: this.to.getAddressString(), value: utils.isBigNumber(this.value) ? this.value.toNumber() : this.value, nonce: this.nonce, gasPrice: utils.isBigNumber(this....
[ "function", "(", ")", "{", "return", "{", "chainID", ":", "this", ".", "chainID", ",", "from", ":", "this", ".", "from", ".", "getAddressString", "(", ")", ",", "to", ":", "this", ".", "to", ".", "getAddressString", "(", ")", ",", "value", ":", "ut...
Conver transaction data to plain JavaScript object. @return {Object} Plain JavaScript object with Transaction fields. @example var acc = Account.NewAccount(); var tx = new Transaction({ chainID: 1, from: acc, to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17", value: 10, nonce: 12, gasPrice: 1000000, gasLimit: 2000000 }); txDa...
[ "Conver", "transaction", "data", "to", "plain", "JavaScript", "object", "." ]
ad307a4be2015e5dba165ecab9c6e87104875f37
https://github.com/nebulasio/neb.js/blob/ad307a4be2015e5dba165ecab9c6e87104875f37/lib/transaction.js#L319-L330
train
pillarjs/finalhandler
index.js
createHtmlDocument
function createHtmlDocument (message) { var body = escapeHtml(message) .replace(NEWLINE_REGEXP, '<br>') .replace(DOUBLE_SPACE_REGEXP, ' &nbsp;') return '<!DOCTYPE html>\n' + '<html lang="en">\n' + '<head>\n' + '<meta charset="utf-8">\n' + '<title>Error</title>\n' + '</head>\n' + '<b...
javascript
function createHtmlDocument (message) { var body = escapeHtml(message) .replace(NEWLINE_REGEXP, '<br>') .replace(DOUBLE_SPACE_REGEXP, ' &nbsp;') return '<!DOCTYPE html>\n' + '<html lang="en">\n' + '<head>\n' + '<meta charset="utf-8">\n' + '<title>Error</title>\n' + '</head>\n' + '<b...
[ "function", "createHtmlDocument", "(", "message", ")", "{", "var", "body", "=", "escapeHtml", "(", "message", ")", ".", "replace", "(", "NEWLINE_REGEXP", ",", "'<br>'", ")", ".", "replace", "(", "DOUBLE_SPACE_REGEXP", ",", "' &nbsp;'", ")", "return", "'<!DOCTY...
Create a minimal HTML document. @param {string} message @private
[ "Create", "a", "minimal", "HTML", "document", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L43-L58
train
pillarjs/finalhandler
index.js
finalhandler
function finalhandler (req, res, options) { var opts = options || {} // get environment var env = opts.env || process.env.NODE_ENV || 'development' // get error callback var onerror = opts.onerror return function (err) { var headers var msg var status // ignore 404 on in-flight response ...
javascript
function finalhandler (req, res, options) { var opts = options || {} // get environment var env = opts.env || process.env.NODE_ENV || 'development' // get error callback var onerror = opts.onerror return function (err) { var headers var msg var status // ignore 404 on in-flight response ...
[ "function", "finalhandler", "(", "req", ",", "res", ",", "options", ")", "{", "var", "opts", "=", "options", "||", "{", "}", "// get environment", "var", "env", "=", "opts", ".", "env", "||", "process", ".", "env", ".", "NODE_ENV", "||", "'development'",...
Create a function to handle the final response. @param {Request} req @param {Response} res @param {Object} [options] @return {Function} @public
[ "Create", "a", "function", "to", "handle", "the", "final", "response", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L77-L135
train
pillarjs/finalhandler
index.js
getErrorHeaders
function getErrorHeaders (err) { if (!err.headers || typeof err.headers !== 'object') { return undefined } var headers = Object.create(null) var keys = Object.keys(err.headers) for (var i = 0; i < keys.length; i++) { var key = keys[i] headers[key] = err.headers[key] } return headers }
javascript
function getErrorHeaders (err) { if (!err.headers || typeof err.headers !== 'object') { return undefined } var headers = Object.create(null) var keys = Object.keys(err.headers) for (var i = 0; i < keys.length; i++) { var key = keys[i] headers[key] = err.headers[key] } return headers }
[ "function", "getErrorHeaders", "(", "err", ")", "{", "if", "(", "!", "err", ".", "headers", "||", "typeof", "err", ".", "headers", "!==", "'object'", ")", "{", "return", "undefined", "}", "var", "headers", "=", "Object", ".", "create", "(", "null", ")"...
Get headers from Error object. @param {Error} err @return {object} @private
[ "Get", "headers", "from", "Error", "object", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L145-L159
train
pillarjs/finalhandler
index.js
getErrorMessage
function getErrorMessage (err, status, env) { var msg if (env !== 'production') { // use err.stack, which typically includes err.message msg = err.stack // fallback to err.toString() when possible if (!msg && typeof err.toString === 'function') { msg = err.toString() } } return msg ...
javascript
function getErrorMessage (err, status, env) { var msg if (env !== 'production') { // use err.stack, which typically includes err.message msg = err.stack // fallback to err.toString() when possible if (!msg && typeof err.toString === 'function') { msg = err.toString() } } return msg ...
[ "function", "getErrorMessage", "(", "err", ",", "status", ",", "env", ")", "{", "var", "msg", "if", "(", "env", "!==", "'production'", ")", "{", "// use err.stack, which typically includes err.message", "msg", "=", "err", ".", "stack", "// fallback to err.toString()...
Get message from Error object, fallback to status message. @param {Error} err @param {number} status @param {string} env @return {string} @private
[ "Get", "message", "from", "Error", "object", "fallback", "to", "status", "message", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L171-L185
train
pillarjs/finalhandler
index.js
getErrorStatusCode
function getErrorStatusCode (err) { // check err.status if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) { return err.status } // check err.statusCode if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) { return err.statusCode } re...
javascript
function getErrorStatusCode (err) { // check err.status if (typeof err.status === 'number' && err.status >= 400 && err.status < 600) { return err.status } // check err.statusCode if (typeof err.statusCode === 'number' && err.statusCode >= 400 && err.statusCode < 600) { return err.statusCode } re...
[ "function", "getErrorStatusCode", "(", "err", ")", "{", "// check err.status", "if", "(", "typeof", "err", ".", "status", "===", "'number'", "&&", "err", ".", "status", ">=", "400", "&&", "err", ".", "status", "<", "600", ")", "{", "return", "err", ".", ...
Get status code from Error object. @param {Error} err @return {number} @private
[ "Get", "status", "code", "from", "Error", "object", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L195-L207
train
pillarjs/finalhandler
index.js
getResponseStatusCode
function getResponseStatusCode (res) { var status = res.statusCode // default status code to 500 if outside valid range if (typeof status !== 'number' || status < 400 || status > 599) { status = 500 } return status }
javascript
function getResponseStatusCode (res) { var status = res.statusCode // default status code to 500 if outside valid range if (typeof status !== 'number' || status < 400 || status > 599) { status = 500 } return status }
[ "function", "getResponseStatusCode", "(", "res", ")", "{", "var", "status", "=", "res", ".", "statusCode", "// default status code to 500 if outside valid range", "if", "(", "typeof", "status", "!==", "'number'", "||", "status", "<", "400", "||", "status", ">", "5...
Get status code from response. @param {OutgoingMessage} res @return {number} @private
[ "Get", "status", "code", "from", "response", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L236-L245
train
pillarjs/finalhandler
index.js
setHeaders
function setHeaders (res, headers) { if (!headers) { return } var keys = Object.keys(headers) for (var i = 0; i < keys.length; i++) { var key = keys[i] res.setHeader(key, headers[key]) } }
javascript
function setHeaders (res, headers) { if (!headers) { return } var keys = Object.keys(headers) for (var i = 0; i < keys.length; i++) { var key = keys[i] res.setHeader(key, headers[key]) } }
[ "function", "setHeaders", "(", "res", ",", "headers", ")", "{", "if", "(", "!", "headers", ")", "{", "return", "}", "var", "keys", "=", "Object", ".", "keys", "(", "headers", ")", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keys", ".", "l...
Set response headers from an object. @param {OutgoingMessage} res @param {object} headers @private
[ "Set", "response", "headers", "from", "an", "object", "." ]
1b2c36949db50aa766d4691a5f38eb6639d01d66
https://github.com/pillarjs/finalhandler/blob/1b2c36949db50aa766d4691a5f38eb6639d01d66/index.js#L321-L331
train
Peer5/videojs-contrib-hls.js
src/videojs.hlsjs.js
Html5HlsJS
function Html5HlsJS(source, tech) { var options = tech.options_; var el = tech.el(); var duration = null; var hls = this.hls = new Hls(options.hlsjsConfig); /** * creates an error handler function * @returns {Function} */ function errorHandlerFactory() { var _recoverDecodingErrorDate = null; ...
javascript
function Html5HlsJS(source, tech) { var options = tech.options_; var el = tech.el(); var duration = null; var hls = this.hls = new Hls(options.hlsjsConfig); /** * creates an error handler function * @returns {Function} */ function errorHandlerFactory() { var _recoverDecodingErrorDate = null; ...
[ "function", "Html5HlsJS", "(", "source", ",", "tech", ")", "{", "var", "options", "=", "tech", ".", "options_", ";", "var", "el", "=", "tech", ".", "el", "(", ")", ";", "var", "duration", "=", "null", ";", "var", "hls", "=", "this", ".", "hls", "...
hls.js source handler @param source @param tech @constructor
[ "hls", ".", "js", "source", "handler" ]
9e1faddae5adbd27860b602376a705c793d5ff71
https://github.com/Peer5/videojs-contrib-hls.js/blob/9e1faddae5adbd27860b602376a705c793d5ff71/src/videojs.hlsjs.js#L15-L122
train
Peer5/videojs-contrib-hls.js
src/videojs.hlsjs.js
errorHandlerFactory
function errorHandlerFactory() { var _recoverDecodingErrorDate = null; var _recoverAudioCodecErrorDate = null; return function() { var now = Date.now(); if (!_recoverDecodingErrorDate || (now - _recoverDecodingErrorDate) > 2000) { _recoverDecodingErrorDate = now; hls.recoverMed...
javascript
function errorHandlerFactory() { var _recoverDecodingErrorDate = null; var _recoverAudioCodecErrorDate = null; return function() { var now = Date.now(); if (!_recoverDecodingErrorDate || (now - _recoverDecodingErrorDate) > 2000) { _recoverDecodingErrorDate = now; hls.recoverMed...
[ "function", "errorHandlerFactory", "(", ")", "{", "var", "_recoverDecodingErrorDate", "=", "null", ";", "var", "_recoverAudioCodecErrorDate", "=", "null", ";", "return", "function", "(", ")", "{", "var", "now", "=", "Date", ".", "now", "(", ")", ";", "if", ...
creates an error handler function @returns {Function}
[ "creates", "an", "error", "handler", "function" ]
9e1faddae5adbd27860b602376a705c793d5ff71
https://github.com/Peer5/videojs-contrib-hls.js/blob/9e1faddae5adbd27860b602376a705c793d5ff71/src/videojs.hlsjs.js#L25-L45
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function() { // Used to make sure the dropdown becomes focused (fixes IE issue) self.dropdown.trigger("focus", true); // The `click` handler logic will only be applied if the dropdown list is enabled if (!self.originalElem.disabled) { ...
javascript
function() { // Used to make sure the dropdown becomes focused (fixes IE issue) self.dropdown.trigger("focus", true); // The `click` handler logic will only be applied if the dropdown list is enabled if (!self.originalElem.disabled) { ...
[ "function", "(", ")", "{", "// Used to make sure the dropdown becomes focused (fixes IE issue)", "self", ".", "dropdown", ".", "trigger", "(", "\"focus\"", ",", "true", ")", ";", "// The `click` handler logic will only be applied if the dropdown list is enabled", "if", "(", "!"...
`click` event with the `selectBoxIt` namespace
[ "click", "event", "with", "the", "selectBoxIt", "namespace" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1135-L1154
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function(e) { // Stores the `keycode` value in a local variable var currentKey = self._keyMappings[e.keyCode], keydownMethod = self._keydownMethods()[currentKey]; if(keydownMethod) { keydownMethod(); ...
javascript
function(e) { // Stores the `keycode` value in a local variable var currentKey = self._keyMappings[e.keyCode], keydownMethod = self._keydownMethods()[currentKey]; if(keydownMethod) { keydownMethod(); ...
[ "function", "(", "e", ")", "{", "// Stores the `keycode` value in a local variable", "var", "currentKey", "=", "self", ".", "_keyMappings", "[", "e", ".", "keyCode", "]", ",", "keydownMethod", "=", "self", ".", "_keydownMethods", "(", ")", "[", "currentKey", "]"...
`keydown` event with the `selectBoxIt` namespace. Catches all user keyboard navigations
[ "keydown", "event", "with", "the", "selectBoxIt", "namespace", ".", "Catches", "all", "user", "keyboard", "navigations" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1237-L1262
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function(e) { if (!self.originalElem.disabled) { // Sets the current key to the `keyCode` value if `charCode` does not exist. Used for cross // browser support since IE uses `keyCode` instead of `charCode`. var currentKey = e....
javascript
function(e) { if (!self.originalElem.disabled) { // Sets the current key to the `keyCode` value if `charCode` does not exist. Used for cross // browser support since IE uses `keyCode` instead of `charCode`. var currentKey = e....
[ "function", "(", "e", ")", "{", "if", "(", "!", "self", ".", "originalElem", ".", "disabled", ")", "{", "// Sets the current key to the `keyCode` value if `charCode` does not exist. Used for cross", "// browser support since IE uses `keyCode` instead of `charCode`.", "var", "cur...
`keypress` event with the `selectBoxIt` namespace. Catches all user keyboard text searches since you can only reliably get character codes using the `keypress` event
[ "keypress", "event", "with", "the", "selectBoxIt", "namespace", ".", "Catches", "all", "user", "keyboard", "text", "searches", "since", "you", "can", "only", "reliably", "get", "character", "codes", "using", "the", "keypress", "event" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1265-L1291
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function() { // Removes the hover class from the previous drop down option self.listItems.not($(this)).removeAttr("data-active"); $(this).attr("data-active", ""); var listIsHidden = self.list.is(":hidden"); if((self....
javascript
function() { // Removes the hover class from the previous drop down option self.listItems.not($(this)).removeAttr("data-active"); $(this).attr("data-active", ""); var listIsHidden = self.list.is(":hidden"); if((self....
[ "function", "(", ")", "{", "// Removes the hover class from the previous drop down option", "self", ".", "listItems", ".", "not", "(", "$", "(", "this", ")", ")", ".", "removeAttr", "(", "\"data-active\"", ")", ";", "$", "(", "this", ")", ".", "attr", "(", "...
Delegates the `focusin` event with the `selectBoxIt` namespace to the list items
[ "Delegates", "the", "focusin", "event", "with", "the", "selectBoxIt", "namespace", "to", "the", "list", "items" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1367-L1385
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function() { if(nativeMousedown && !customShowHideEvent) { self._update($(this)); self.triggerEvent("option-mouseup"); // If the current drop down option is not disabled if ($(this).attr("data-disable...
javascript
function() { if(nativeMousedown && !customShowHideEvent) { self._update($(this)); self.triggerEvent("option-mouseup"); // If the current drop down option is not disabled if ($(this).attr("data-disable...
[ "function", "(", ")", "{", "if", "(", "nativeMousedown", "&&", "!", "customShowHideEvent", ")", "{", "self", ".", "_update", "(", "$", "(", "this", ")", ")", ";", "self", ".", "triggerEvent", "(", "\"option-mouseup\"", ")", ";", "// If the current drop down ...
Delegates the `focus` event with the `selectBoxIt` namespace to the list items
[ "Delegates", "the", "focus", "event", "with", "the", "selectBoxIt", "namespace", "to", "the", "list", "items" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1388-L1406
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function() { // If the currently moused over drop down option is not disabled if($(this).attr("data-disabled") === "false") { self.listItems.removeAttr("data-active"); $(this).addClass(focusClass).attr("data-active", ""); ...
javascript
function() { // If the currently moused over drop down option is not disabled if($(this).attr("data-disabled") === "false") { self.listItems.removeAttr("data-active"); $(this).addClass(focusClass).attr("data-active", ""); ...
[ "function", "(", ")", "{", "// If the currently moused over drop down option is not disabled", "if", "(", "$", "(", "this", ")", ".", "attr", "(", "\"data-disabled\"", ")", "===", "\"false\"", ")", "{", "self", ".", "listItems", ".", "removeAttr", "(", "\"data-act...
Delegates the `mouseenter` event with the `selectBoxIt` namespace to the list items
[ "Delegates", "the", "mouseenter", "event", "with", "the", "selectBoxIt", "namespace", "to", "the", "list", "items" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1409-L1427
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function(event, internal) { var currentOption, currentDataSelectedText; // If the user called the change method if(!internal) { currentOption = self.list.find('li[data-val="' + self.originalElem.value + '"]');...
javascript
function(event, internal) { var currentOption, currentDataSelectedText; // If the user called the change method if(!internal) { currentOption = self.list.find('li[data-val="' + self.originalElem.value + '"]');...
[ "function", "(", "event", ",", "internal", ")", "{", "var", "currentOption", ",", "currentDataSelectedText", ";", "// If the user called the change method", "if", "(", "!", "internal", ")", "{", "currentOption", "=", "self", ".", "list", ".", "find", "(", "'li[d...
`change` event handler with the `selectBoxIt` namespace
[ "change", "event", "handler", "with", "the", "selectBoxIt", "namespace" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1472-L1516
train
gfranko/jquery.selectBoxIt.js
src/javascripts/modules/jquery.selectBoxIt.core.js
function() { var currentElem = self.list.find("li[data-val='" + self.dropdownText.attr("data-val") + "']"), activeElem; // If no current element can be found, then select the first drop down option if(!currentElem.length) { ...
javascript
function() { var currentElem = self.list.find("li[data-val='" + self.dropdownText.attr("data-val") + "']"), activeElem; // If no current element can be found, then select the first drop down option if(!currentElem.length) { ...
[ "function", "(", ")", "{", "var", "currentElem", "=", "self", ".", "list", ".", "find", "(", "\"li[data-val='\"", "+", "self", ".", "dropdownText", ".", "attr", "(", "\"data-val\"", ")", "+", "\"']\"", ")", ",", "activeElem", ";", "// If no current element c...
`open` event with the `selectBoxIt` namespace
[ "open", "event", "with", "the", "selectBoxIt", "namespace" ]
31d714060aa94d980be57b2fc052eb7ae73f486e
https://github.com/gfranko/jquery.selectBoxIt.js/blob/31d714060aa94d980be57b2fc052eb7ae73f486e/src/javascripts/modules/jquery.selectBoxIt.core.js#L1535-L1569
train
tj/node-querystring
index.js
compact
function compact(obj) { if ('object' != typeof obj) return obj; if (isArray(obj)) { var ret = []; for (var i in obj) { if (hasOwnProperty.call(obj, i)) { ret.push(obj[i]); } } return ret; } for (var key in obj) { obj[key] = compact(obj[key]); } return obj; }
javascript
function compact(obj) { if ('object' != typeof obj) return obj; if (isArray(obj)) { var ret = []; for (var i in obj) { if (hasOwnProperty.call(obj, i)) { ret.push(obj[i]); } } return ret; } for (var key in obj) { obj[key] = compact(obj[key]); } return obj; }
[ "function", "compact", "(", "obj", ")", "{", "if", "(", "'object'", "!=", "typeof", "obj", ")", "return", "obj", ";", "if", "(", "isArray", "(", "obj", ")", ")", "{", "var", "ret", "=", "[", "]", ";", "for", "(", "var", "i", "in", "obj", ")", ...
Compact sparse arrays.
[ "Compact", "sparse", "arrays", "." ]
2769b6e3a09a9dc9887be26ccd1effe9fea639d8
https://github.com/tj/node-querystring/blob/2769b6e3a09a9dc9887be26ccd1effe9fea639d8/index.js#L155-L175
train
tj/node-querystring
index.js
parseObject
function parseObject(obj){ var ret = { base: {} }; forEach(objectKeys(obj), function(name){ merge(ret, name, obj[name]); }); return compact(ret.base); }
javascript
function parseObject(obj){ var ret = { base: {} }; forEach(objectKeys(obj), function(name){ merge(ret, name, obj[name]); }); return compact(ret.base); }
[ "function", "parseObject", "(", "obj", ")", "{", "var", "ret", "=", "{", "base", ":", "{", "}", "}", ";", "forEach", "(", "objectKeys", "(", "obj", ")", ",", "function", "(", "name", ")", "{", "merge", "(", "ret", ",", "name", ",", "obj", "[", ...
Parse the given obj.
[ "Parse", "the", "given", "obj", "." ]
2769b6e3a09a9dc9887be26ccd1effe9fea639d8
https://github.com/tj/node-querystring/blob/2769b6e3a09a9dc9887be26ccd1effe9fea639d8/index.js#L181-L189
train
tj/node-querystring
index.js
parseString
function parseString(str, options){ var ret = reduce(String(str).split(options.separator), function(ret, pair){ var eql = indexOf(pair, '=') , brace = lastBraceInKey(pair) , key = pair.substr(0, brace || eql) , val = pair.substr(brace || eql, pair.length) , val = val.substr(indexOf(val, '=...
javascript
function parseString(str, options){ var ret = reduce(String(str).split(options.separator), function(ret, pair){ var eql = indexOf(pair, '=') , brace = lastBraceInKey(pair) , key = pair.substr(0, brace || eql) , val = pair.substr(brace || eql, pair.length) , val = val.substr(indexOf(val, '=...
[ "function", "parseString", "(", "str", ",", "options", ")", "{", "var", "ret", "=", "reduce", "(", "String", "(", "str", ")", ".", "split", "(", "options", ".", "separator", ")", ",", "function", "(", "ret", ",", "pair", ")", "{", "var", "eql", "="...
Parse the given str.
[ "Parse", "the", "given", "str", "." ]
2769b6e3a09a9dc9887be26ccd1effe9fea639d8
https://github.com/tj/node-querystring/blob/2769b6e3a09a9dc9887be26ccd1effe9fea639d8/index.js#L195-L211
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
bindMany
function bindMany($el, options, events) { var name, namespaced; for (name in events) { if (events.hasOwnProperty(name)) { namespaced = name.replace(/ |$/g, options.eventNamespace); $el.bind(namespaced, events[name]); } } }
javascript
function bindMany($el, options, events) { var name, namespaced; for (name in events) { if (events.hasOwnProperty(name)) { namespaced = name.replace(/ |$/g, options.eventNamespace); $el.bind(namespaced, events[name]); } } }
[ "function", "bindMany", "(", "$el", ",", "options", ",", "events", ")", "{", "var", "name", ",", "namespaced", ";", "for", "(", "name", "in", "events", ")", "{", "if", "(", "events", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "namespaced", "=...
For backwards compatibility with older jQuery libraries, only bind one thing at a time. Also, this function adds our namespace to events in one consistent location, shrinking the minified code. The properties on the events object are the names of the events that we are supposed to add to. It can be a space separated...
[ "For", "backwards", "compatibility", "with", "older", "jQuery", "libraries", "only", "bind", "one", "thing", "at", "a", "time", ".", "Also", "this", "function", "adds", "our", "namespace", "to", "events", "in", "one", "consistent", "location", "shrinking", "th...
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L49-L58
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
bindUi
function bindUi($el, $target, options) { bindMany($el, options, { focus: function () { $target.addClass(options.focusClass); }, blur: function () { $target.removeClass(options.focusClass); $target.removeClass(options.activeClass...
javascript
function bindUi($el, $target, options) { bindMany($el, options, { focus: function () { $target.addClass(options.focusClass); }, blur: function () { $target.removeClass(options.focusClass); $target.removeClass(options.activeClass...
[ "function", "bindUi", "(", "$el", ",", "$target", ",", "options", ")", "{", "bindMany", "(", "$el", ",", "options", ",", "{", "focus", ":", "function", "(", ")", "{", "$target", ".", "addClass", "(", "options", ".", "focusClass", ")", ";", "}", ",", ...
Bind the hover, active, focus, and blur UI updates @param {jQuery} $el Original element @param {jQuery} $target Target for the events (our div/span) @param {Object} options Uniform options for the element $target
[ "Bind", "the", "hover", "active", "focus", "and", "blur", "UI", "updates" ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L67-L92
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
divSpanWrap
function divSpanWrap($el, $container, method) { switch (method) { case "after": // Result: <element /> <container /> $el.after($container); return $el.next(); case "before": // Result: <container /> <element /> ...
javascript
function divSpanWrap($el, $container, method) { switch (method) { case "after": // Result: <element /> <container /> $el.after($container); return $el.next(); case "before": // Result: <container /> <element /> ...
[ "function", "divSpanWrap", "(", "$el", ",", "$container", ",", "method", ")", "{", "switch", "(", "method", ")", "{", "case", "\"after\"", ":", "// Result: <element /> <container />", "$el", ".", "after", "(", "$container", ")", ";", "return", "$el", ".", "...
Wrap an element inside of a container or put the container next to the element. See the code for examples of the different methods. Returns the container that was added to the HTML. @param {jQuery} $el Element to wrap @param {jQuery} $container Add this new container around/near $el @param {String} method One of "af...
[ "Wrap", "an", "element", "inside", "of", "a", "container", "or", "put", "the", "container", "next", "to", "the", "element", ".", "See", "the", "code", "for", "examples", "of", "the", "different", "methods", "." ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L176-L193
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
highContrast
function highContrast() { var c, $div, el, rgb; // High contrast mode deals with white and black rgb = 'rgb(120,2,153)'; $div = $('<div style="width:0;height:0;color:' + rgb + '">'); $('body').append($div); el = $div.get(0); // $div.css() will get the style defi...
javascript
function highContrast() { var c, $div, el, rgb; // High contrast mode deals with white and black rgb = 'rgb(120,2,153)'; $div = $('<div style="width:0;height:0;color:' + rgb + '">'); $('body').append($div); el = $div.get(0); // $div.css() will get the style defi...
[ "function", "highContrast", "(", ")", "{", "var", "c", ",", "$div", ",", "el", ",", "rgb", ";", "// High contrast mode deals with white and black", "rgb", "=", "'rgb(120,2,153)'", ";", "$div", "=", "$", "(", "'<div style=\"width:0;height:0;color:'", "+", "rgb", "+...
Test if high contrast mode is enabled. In high contrast mode, background images can not be set and they are always returned as 'none'. @return {Boolean} True if in high contrast mode
[ "Test", "if", "high", "contrast", "mode", "is", "enabled", "." ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L286-L305
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
setFilename
function setFilename($el, $filenameTag, options) { var filenames = $.map($el[0].files, function (file) {return file.name}).join(', '); if (filenames === "") { filenames = options.fileDefaultHtml; } else { filenames = filenames.split(/[\/\\]+/); filenames = fi...
javascript
function setFilename($el, $filenameTag, options) { var filenames = $.map($el[0].files, function (file) {return file.name}).join(', '); if (filenames === "") { filenames = options.fileDefaultHtml; } else { filenames = filenames.split(/[\/\\]+/); filenames = fi...
[ "function", "setFilename", "(", "$el", ",", "$filenameTag", ",", "options", ")", "{", "var", "filenames", "=", "$", ".", "map", "(", "$el", "[", "0", "]", ".", "files", ",", "function", "(", "file", ")", "{", "return", "file", ".", "name", "}", ")"...
Updates the filename tag based on the value of the real input element. @param {jQuery} $el Actual form element @param {jQuery} $filenameTag Span/div to update @param {Object} options Uniform options for this element
[ "Updates", "the", "filename", "tag", "based", "on", "the", "value", "of", "the", "real", "input", "element", "." ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L396-L407
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
swap
function swap($elements, newCss, callback) { var restore, item; restore = []; $elements.each(function () { var name; for (name in newCss) { if (Object.prototype.hasOwnProperty.call(newCss, name)) { restore.push({ ...
javascript
function swap($elements, newCss, callback) { var restore, item; restore = []; $elements.each(function () { var name; for (name in newCss) { if (Object.prototype.hasOwnProperty.call(newCss, name)) { restore.push({ ...
[ "function", "swap", "(", "$elements", ",", "newCss", ",", "callback", ")", "{", "var", "restore", ",", "item", ";", "restore", "=", "[", "]", ";", "$elements", ".", "each", "(", "function", "(", ")", "{", "var", "name", ";", "for", "(", "name", "in...
Function from jQuery to swap some CSS values, run a callback, then restore the CSS. Modified to pass JSLint and handle undefined values with 'use strict'. @param {jQuery} $elements Element @param {Object} newCss CSS values to swap out @param {Function} callback Function to run
[ "Function", "from", "jQuery", "to", "swap", "some", "CSS", "values", "run", "a", "callback", "then", "restore", "the", "CSS", ".", "Modified", "to", "pass", "JSLint", "and", "handle", "undefined", "values", "with", "use", "strict", "." ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L418-L445
train
AudithSoftworks/Uniform
src/js/jquery.uniform.js
sizingInvisible
function sizingInvisible($el, callback) { var targets; // We wish to target ourselves and any parents as long as // they are not visible targets = $el.parents(); targets.push($el[0]); targets = targets.not(':visible'); swap(targets, { visibility: "hid...
javascript
function sizingInvisible($el, callback) { var targets; // We wish to target ourselves and any parents as long as // they are not visible targets = $el.parents(); targets.push($el[0]); targets = targets.not(':visible'); swap(targets, { visibility: "hid...
[ "function", "sizingInvisible", "(", "$el", ",", "callback", ")", "{", "var", "targets", ";", "// We wish to target ourselves and any parents as long as", "// they are not visible", "targets", "=", "$el", ".", "parents", "(", ")", ";", "targets", ".", "push", "(", "$...
The browser doesn't provide sizes of elements that are not visible. This will clone an element and add it to the DOM for calculations. @param {jQuery} $el @param {Function} callback
[ "The", "browser", "doesn", "t", "provide", "sizes", "of", "elements", "that", "are", "not", "visible", ".", "This", "will", "clone", "an", "element", "and", "add", "it", "to", "the", "DOM", "for", "calculations", "." ]
e1c0583a4fe06493e9fb35c8fadc46b6f1de0423
https://github.com/AudithSoftworks/Uniform/blob/e1c0583a4fe06493e9fb35c8fadc46b6f1de0423/src/js/jquery.uniform.js#L454-L467
train
shakilsiraj/json-object-mapper
dist/ObjectMapper.js
function (typeName) { switch (typeName) { case Constants.STRING_TYPE: return true; case Constants.NUMBER_TYPE: return true; case Constants.BOOLEAN_TYPE: return true; case Constants.DATE_TYPE: return true; case Constants.STRING_TYPE_LOWERCASE: return true; case Constan...
javascript
function (typeName) { switch (typeName) { case Constants.STRING_TYPE: return true; case Constants.NUMBER_TYPE: return true; case Constants.BOOLEAN_TYPE: return true; case Constants.DATE_TYPE: return true; case Constants.STRING_TYPE_LOWERCASE: return true; case Constan...
[ "function", "(", "typeName", ")", "{", "switch", "(", "typeName", ")", "{", "case", "Constants", ".", "STRING_TYPE", ":", "return", "true", ";", "case", "Constants", ".", "NUMBER_TYPE", ":", "return", "true", ";", "case", "Constants", ".", "BOOLEAN_TYPE", ...
Checks to see if the specified type is a standard JS object type.
[ "Checks", "to", "see", "if", "the", "specified", "type", "is", "a", "standard", "JS", "object", "type", "." ]
718c8f8697080bdf7eb44701e34065b87be08e9c
https://github.com/shakilsiraj/json-object-mapper/blob/718c8f8697080bdf7eb44701e34065b87be08e9c/dist/ObjectMapper.js#L61-L73
train
shakilsiraj/json-object-mapper
dist/ObjectMapper.js
function (metadata) { if (typeof metadata === 'string') { return getJsonPropertyDecorator({ name: metadata, required: false, access: exports.AccessType.BOTH }); } else { return getJsonPropertyDecorator(metadata); } }
javascript
function (metadata) { if (typeof metadata === 'string') { return getJsonPropertyDecorator({ name: metadata, required: false, access: exports.AccessType.BOTH }); } else { return getJsonPropertyDecorator(metadata); } }
[ "function", "(", "metadata", ")", "{", "if", "(", "typeof", "metadata", "===", "'string'", ")", "{", "return", "getJsonPropertyDecorator", "(", "{", "name", ":", "metadata", ",", "required", ":", "false", ",", "access", ":", "exports", ".", "AccessType", "...
JsonProperty Decorator function.
[ "JsonProperty", "Decorator", "function", "." ]
718c8f8697080bdf7eb44701e34065b87be08e9c
https://github.com/shakilsiraj/json-object-mapper/blob/718c8f8697080bdf7eb44701e34065b87be08e9c/dist/ObjectMapper.js#L132-L139
train
shakilsiraj/json-object-mapper
dist/ObjectMapper.js
function (instance, instanceKey, type, json, jsonKey) { var jsonObject = (jsonKey !== undefined) ? (json[jsonKey] || []) : json; var jsonArraySize = jsonObject.length; var conversionFunctionsList = []; var arrayInstance = []; instance[instanceKey] = arrayInstance; if (jsonArraySize > 0) { ...
javascript
function (instance, instanceKey, type, json, jsonKey) { var jsonObject = (jsonKey !== undefined) ? (json[jsonKey] || []) : json; var jsonArraySize = jsonObject.length; var conversionFunctionsList = []; var arrayInstance = []; instance[instanceKey] = arrayInstance; if (jsonArraySize > 0) { ...
[ "function", "(", "instance", ",", "instanceKey", ",", "type", ",", "json", ",", "jsonKey", ")", "{", "var", "jsonObject", "=", "(", "jsonKey", "!==", "undefined", ")", "?", "(", "json", "[", "jsonKey", "]", "||", "[", "]", ")", ":", "json", ";", "v...
Deserializes a JS array type from json.
[ "Deserializes", "a", "JS", "array", "type", "from", "json", "." ]
718c8f8697080bdf7eb44701e34065b87be08e9c
https://github.com/shakilsiraj/json-object-mapper/blob/718c8f8697080bdf7eb44701e34065b87be08e9c/dist/ObjectMapper.js#L205-L227
train
shakilsiraj/json-object-mapper
dist/ObjectMapper.js
function (key, instance, serializer) { var value = serializer.serialize(instance); if (key !== undefined) { return "\"" + key + "\":" + value; } else { return value; } }
javascript
function (key, instance, serializer) { var value = serializer.serialize(instance); if (key !== undefined) { return "\"" + key + "\":" + value; } else { return value; } }
[ "function", "(", "key", ",", "instance", ",", "serializer", ")", "{", "var", "value", "=", "serializer", ".", "serialize", "(", "instance", ")", ";", "if", "(", "key", "!==", "undefined", ")", "{", "return", "\"\\\"\"", "+", "key", "+", "\"\\\":\"", "+...
Serialize any type with key value pairs
[ "Serialize", "any", "type", "with", "key", "value", "pairs" ]
718c8f8697080bdf7eb44701e34065b87be08e9c
https://github.com/shakilsiraj/json-object-mapper/blob/718c8f8697080bdf7eb44701e34065b87be08e9c/dist/ObjectMapper.js#L462-L470
train
klaascuvelier/gulp-copy
lib/gulp-copy.js
gulpCopy
function gulpCopy(destination, opts) { const throughOptions = { objectMode: true }; // Make sure a destination was verified if (typeof destination !== 'string') { throw new PluginError('gulp-copy', 'No valid destination specified'); } // Default options if (opts === undefined) { ...
javascript
function gulpCopy(destination, opts) { const throughOptions = { objectMode: true }; // Make sure a destination was verified if (typeof destination !== 'string') { throw new PluginError('gulp-copy', 'No valid destination specified'); } // Default options if (opts === undefined) { ...
[ "function", "gulpCopy", "(", "destination", ",", "opts", ")", "{", "const", "throughOptions", "=", "{", "objectMode", ":", "true", "}", ";", "// Make sure a destination was verified", "if", "(", "typeof", "destination", "!==", "'string'", ")", "{", "throw", "new...
gulp copy method @param {string} destination @param {object} opts @returns {object}
[ "gulp", "copy", "method" ]
4b4c3391b3704f14c7edb9f2fc149e4f801d26b1
https://github.com/klaascuvelier/gulp-copy/blob/4b4c3391b3704f14c7edb9f2fc149e4f801d26b1/lib/gulp-copy.js#L14-L77
train
klaascuvelier/gulp-copy
lib/gulp-copy.js
createDestination
function createDestination(destination) { const folders = destination.split(separator); const pathParts = []; const l = folders.length; // for absolute paths if (folders[0] === '') { pathParts.push(separator); folders.shift(); } for (let i = 0; i < l; i++) { pathPar...
javascript
function createDestination(destination) { const folders = destination.split(separator); const pathParts = []; const l = folders.length; // for absolute paths if (folders[0] === '') { pathParts.push(separator); folders.shift(); } for (let i = 0; i < l; i++) { pathPar...
[ "function", "createDestination", "(", "destination", ")", "{", "const", "folders", "=", "destination", ".", "split", "(", "separator", ")", ";", "const", "pathParts", "=", "[", "]", ";", "const", "l", "=", "folders", ".", "length", ";", "// for absolute path...
Recursively creates the path @param {string} destination
[ "Recursively", "creates", "the", "path" ]
4b4c3391b3704f14c7edb9f2fc149e4f801d26b1
https://github.com/klaascuvelier/gulp-copy/blob/4b4c3391b3704f14c7edb9f2fc149e4f801d26b1/lib/gulp-copy.js#L83-L105
train
klaascuvelier/gulp-copy
lib/gulp-copy.js
doesPathExist
function doesPathExist(pathToVerify) { let pathExists = true; try { fs.accessSync(pathToVerify); } catch (error) { pathExists = false; } return pathExists; }
javascript
function doesPathExist(pathToVerify) { let pathExists = true; try { fs.accessSync(pathToVerify); } catch (error) { pathExists = false; } return pathExists; }
[ "function", "doesPathExist", "(", "pathToVerify", ")", "{", "let", "pathExists", "=", "true", ";", "try", "{", "fs", ".", "accessSync", "(", "pathToVerify", ")", ";", "}", "catch", "(", "error", ")", "{", "pathExists", "=", "false", ";", "}", "return", ...
Check if the path exists @param path @returns {boolean}
[ "Check", "if", "the", "path", "exists" ]
4b4c3391b3704f14c7edb9f2fc149e4f801d26b1
https://github.com/klaascuvelier/gulp-copy/blob/4b4c3391b3704f14c7edb9f2fc149e4f801d26b1/lib/gulp-copy.js#L112-L122
train
klaascuvelier/gulp-copy
lib/gulp-copy.js
copyFile
function copyFile(source, target, copyCallback) { const readStream = fs.createReadStream(source); const writeStream = fs.createWriteStream(target); let done = false; readStream.on('error', copyDone); writeStream.on('error', copyDone); writeStream.on('close', function onWriteCb() { copy...
javascript
function copyFile(source, target, copyCallback) { const readStream = fs.createReadStream(source); const writeStream = fs.createWriteStream(target); let done = false; readStream.on('error', copyDone); writeStream.on('error', copyDone); writeStream.on('close', function onWriteCb() { copy...
[ "function", "copyFile", "(", "source", ",", "target", ",", "copyCallback", ")", "{", "const", "readStream", "=", "fs", ".", "createReadStream", "(", "source", ")", ";", "const", "writeStream", "=", "fs", ".", "createWriteStream", "(", "target", ")", ";", "...
Copy a file to its new destination @param {string} source @param {string} target @param {function} copyCallback
[ "Copy", "a", "file", "to", "its", "new", "destination" ]
4b4c3391b3704f14c7edb9f2fc149e4f801d26b1
https://github.com/klaascuvelier/gulp-copy/blob/4b4c3391b3704f14c7edb9f2fc149e4f801d26b1/lib/gulp-copy.js#L130-L154
train
eslint/eslint-scope
lib/index.js
defaultOptions
function defaultOptions() { return { optimistic: false, directive: false, nodejsScope: false, impliedStrict: false, sourceType: "script", // one of ['script', 'module'] ecmaVersion: 5, childVisitorKeys: null, fallback: "iteration" }; }
javascript
function defaultOptions() { return { optimistic: false, directive: false, nodejsScope: false, impliedStrict: false, sourceType: "script", // one of ['script', 'module'] ecmaVersion: 5, childVisitorKeys: null, fallback: "iteration" }; }
[ "function", "defaultOptions", "(", ")", "{", "return", "{", "optimistic", ":", "false", ",", "directive", ":", "false", ",", "nodejsScope", ":", "false", ",", "impliedStrict", ":", "false", ",", "sourceType", ":", "\"script\"", ",", "// one of ['script', 'module...
Set the default options @returns {Object} options
[ "Set", "the", "default", "options" ]
5d2ec4fa322095067bd5a262b0c218d1bdf9270c
https://github.com/eslint/eslint-scope/blob/5d2ec4fa322095067bd5a262b0c218d1bdf9270c/lib/index.js#L65-L76
train
eslint/eslint-scope
lib/index.js
updateDeeply
function updateDeeply(target, override) { /** * Is hash object * @param {Object} value - Test value * @returns {boolean} Result */ function isHashObject(value) { return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp); ...
javascript
function updateDeeply(target, override) { /** * Is hash object * @param {Object} value - Test value * @returns {boolean} Result */ function isHashObject(value) { return typeof value === "object" && value instanceof Object && !(value instanceof Array) && !(value instanceof RegExp); ...
[ "function", "updateDeeply", "(", "target", ",", "override", ")", "{", "/**\n * Is hash object\n * @param {Object} value - Test value\n * @returns {boolean} Result\n */", "function", "isHashObject", "(", "value", ")", "{", "return", "typeof", "value", "===", "\"o...
Preform deep update on option object @param {Object} target - Options @param {Object} override - Updates @returns {Object} Updated options
[ "Preform", "deep", "update", "on", "option", "object" ]
5d2ec4fa322095067bd5a262b0c218d1bdf9270c
https://github.com/eslint/eslint-scope/blob/5d2ec4fa322095067bd5a262b0c218d1bdf9270c/lib/index.js#L84-L111
train
aws/awsmobile-cli
lib/utils/directory-file-ops.js
getDirContentMTime
function getDirContentMTime(dirPath, ignoredDirs, ignoredFiles){ let mtime if(fs.existsSync(dirPath)){ _ignoredDirs.push.apply(_ignoredDirs, ignoredDirs) _ignoredFiles.push.apply(_ignoredFiles, ignoredFiles) mtime = recursiveGetDirContentMTime(dirPath) } return mtime }
javascript
function getDirContentMTime(dirPath, ignoredDirs, ignoredFiles){ let mtime if(fs.existsSync(dirPath)){ _ignoredDirs.push.apply(_ignoredDirs, ignoredDirs) _ignoredFiles.push.apply(_ignoredFiles, ignoredFiles) mtime = recursiveGetDirContentMTime(dirPath) } return mtime }
[ "function", "getDirContentMTime", "(", "dirPath", ",", "ignoredDirs", ",", "ignoredFiles", ")", "{", "let", "mtime", "if", "(", "fs", ".", "existsSync", "(", "dirPath", ")", ")", "{", "_ignoredDirs", ".", "push", ".", "apply", "(", "_ignoredDirs", ",", "ig...
get the last modification time of the directory including its files and subdirectories
[ "get", "the", "last", "modification", "time", "of", "the", "directory", "including", "its", "files", "and", "subdirectories" ]
dc17aeb3975f5f3a039ed2d8a24bb2ba5ff373be
https://github.com/aws/awsmobile-cli/blob/dc17aeb3975f5f3a039ed2d8a24bb2ba5ff373be/lib/utils/directory-file-ops.js#L21-L29
train
aws/awsmobile-cli
lib/backend-operations/backend-spec-manager.js
onClearBackend
function onClearBackend(projectInfo){ let backendProject = getBackendProjectObject(projectInfo) if(backendProject){ backendProject.name = '' setBackendProjectObject(backendProject, projectInfo) } }
javascript
function onClearBackend(projectInfo){ let backendProject = getBackendProjectObject(projectInfo) if(backendProject){ backendProject.name = '' setBackendProjectObject(backendProject, projectInfo) } }
[ "function", "onClearBackend", "(", "projectInfo", ")", "{", "let", "backendProject", "=", "getBackendProjectObject", "(", "projectInfo", ")", "if", "(", "backendProject", ")", "{", "backendProject", ".", "name", "=", "''", "setBackendProjectObject", "(", "backendPro...
happens with delete or detach backend project
[ "happens", "with", "delete", "or", "detach", "backend", "project" ]
dc17aeb3975f5f3a039ed2d8a24bb2ba5ff373be
https://github.com/aws/awsmobile-cli/blob/dc17aeb3975f5f3a039ed2d8a24bb2ba5ff373be/lib/backend-operations/backend-spec-manager.js#L183-L189
train