code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
onOrderBook ({ symbol, prec, len, cbGID }, cb) {
this._registerListener('orderbook', {
0: symbol,
1: prec,
2: len
}, OrderBook, cbGID, cb)
} | Register a handler to be called with each received candle
@param {object} opts - options
@param {string} opts.symbol - book symbol
@param {string} opts.prec - book precision, i.e. 'R0'
@param {string} opts.len - book length, i.e. '25'
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - callb... | onOrderBook | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onOrderBookChecksum ({ symbol, prec, len, cbGID }, cb) {
this._registerListener('ob_checksum', {
0: symbol,
1: prec,
2: len
}, null, cbGID, cb)
} | Register a handler to be called with each received order book checksum
@param {object} opts - options
@param {string} opts.symbol - book symbol
@param {string} opts.prec - book precision, i.e. 'R0'
@param {string} opts.len - book length, i.e. '25'
@param {string|number} [opts.cbGID] - callback group id
@param {Functio... | onOrderBookChecksum | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onTrades ({ symbol, pair, cbGID }, cb) {
const id = pair || symbol || ''
const model = id[0] === 'f' ? FundingTrade : PublicTrade
this._registerListener('trades', { 0: id }, model, cbGID, cb)
} | Register a handler to be called with each received trade (pair or symbol
required)
@param {object} opts - options
@param {string} [opts.pair] - required if no symbol specified
@param {string} [opts.symbol] - required if no pair specified
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - ca... | onTrades | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onTradeEntry ({ pair, symbol, cbGID }, cb) {
const id = pair || symbol || ''
this._registerListener('trade-entry', { 0: id }, PublicTrade, cbGID, cb)
} | Register a handler to be called on each trade `'te'` event
@param {object} opts - options
@param {string} [opts.pair] - required if no symbol specified
@param {string} [opts.symbol] - required if no pair specified
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs... | onTradeEntry | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onAccountTradeEntry ({ symbol, cbGID }, cb) {
this._registerListener('auth-te', { 1: symbol }, Trade, cbGID, cb)
} | Register a handler to be called on each personal trade `'te'` event
@param {object} opts - options
@param {string} [opts.pair] - required if no symbol specified
@param {string} [opts.symbol] - required if no pair specified
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see htt... | onAccountTradeEntry | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onAccountTradeUpdate ({ symbol, cbGID }, cb) {
this._registerListener('auth-tu', { 1: symbol }, Trade, cbGID, cb)
} | Register a handler to be called on each personal trade `'tu'` event
@param {object} opts - options
@param {string} [opts.pair] - required if no symbol specified
@param {string} [opts.symbol] - required if no pair specified
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see htt... | onAccountTradeUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onTicker ({ symbol = '', cbGID } = {}, cb) {
const m = symbol[0] === 'f' ? FundingTicker : TradingTicker
this._registerListener('ticker', { 0: symbol }, m, cbGID, cb)
} | Register a handler to be called on each received ticker
@param {object} opts - options
@param {string} opts.symbol - symbol for tickers
@param {string|number} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-public-ticker
@see WSv2#subscribeTicker
@see WSv... | onTicker | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onStatus ({ key = '', cbGID } = {}, cb) {
this._registerListener('status', { 0: key }, null, cbGID, cb)
} | Register a handler to be called on each message for the desired status
feed.
@param {object} opts - options
@param {string} opts.key - key of feed to listen on
@param {string|number} [opts.cbGID] - callback group ID
@param {Function} cb - callback
@see WSv2#subscribeStatus | onStatus | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onOrderSnapshot ({ symbol, id, cid, gid, cbGID }, cb) {
this._registerListener('os', {
0: id,
1: gid,
2: cid,
3: symbol
}, Order, cbGID, cb)
} | Register a handler to be called on each full order snapshot (sent on auth)
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {number} [opts.id] - order ID to match
@param {number} [opts.cid] - order client ID to match
@param {number} [opts.gid] - order group ID to match
@param {stri... | onOrderSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onOrderUpdate ({ symbol, id, cid, gid, cbGID }, cb) {
this._registerListener('ou', {
0: id,
1: gid,
2: cid,
3: symbol
}, Order, cbGID, cb)
} | Register a handler to be called on each order update packet
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {number} [opts.id] - order ID to match
@param {number} [opts.cid] - order client ID to match
@param {number} [opts.gid] - order group ID to match
@param {string} [opts.cbGID... | onOrderUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onOrderClose ({ symbol, id, cid, gid, cbGID }, cb) {
this._registerListener('oc', {
0: id,
1: gid,
2: cid,
3: symbol
}, Order, cbGID, cb)
} | Register a handler to be called on each order close packet
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {number} [opts.id] - order ID to match
@param {number} [opts.cid] - order client ID to match
@param {number} [opts.gid] - order group ID to match
@param {string} [opts.cbGID]... | onOrderClose | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onPositionSnapshot ({ symbol, cbGID }, cb) {
this._registerListener('ps', { 0: symbol }, Position, cbGID, cb)
} | Register a handler to be called on each position snapshot (sent on auth)
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-position
@see WSv2#auth | onPositionSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onPositionNew ({ symbol, cbGID }, cb) {
this._registerListener('pn', { 0: symbol }, Position, cbGID, cb)
} | Register a handler to be called when a position is opened
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-position | onPositionNew | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onPositionUpdate ({ symbol, cbGID }, cb) {
this._registerListener('pu', { 0: symbol }, Position, cbGID, cb)
} | Register a handler to be called when a position is updated
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-position | onPositionUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onPositionClose ({ symbol, cbGID }, cb) {
this._registerListener('pc', { 0: symbol }, Position, cbGID, cb)
} | Register a handler to be called when a position is closed
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-position | onPositionClose | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingOfferSnapshot ({ symbol, cbGID }, cb) {
this._registerListener('fos', { 1: symbol }, FundingOffer, cbGID, cb)
} | Register a handler to be called on each fundign offer snapshot (sent on
auth)
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-offers
@see WSv2#auth | onFundingOfferSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingOfferNew ({ symbol, cbGID }, cb) {
this._registerListener('fon', { 1: symbol }, FundingOffer, cbGID, cb)
} | Register a handler to be called when a funding offer is created
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-offers | onFundingOfferNew | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingOfferUpdate ({ symbol, cbGID }, cb) {
this._registerListener('fou', { 1: symbol }, FundingOffer, cbGID, cb)
} | Register a handler to be called when a funding offer is updated
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-offers | onFundingOfferUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingOfferClose ({ symbol, cbGID }, cb) {
this._registerListener('foc', { 1: symbol }, FundingOffer, cbGID, cb)
} | Register a handler to be called when a funding offer is closed
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-offers | onFundingOfferClose | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingCreditSnapshot ({ symbol, cbGID }, cb) {
this._registerListener('fcs', { 1: symbol }, FundingCredit, cbGID, cb)
} | Register a handler to be called on each funding credit snapshot (sent on
auth)
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-credits
@see WSv2#auth | onFundingCreditSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingCreditNew ({ symbol, cbGID }, cb) {
this._registerListener('fcn', { 1: symbol }, FundingCredit, cbGID, cb)
} | Register a handler to be called when a funding credit is created
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-credits | onFundingCreditNew | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingCreditUpdate ({ symbol, cbGID }, cb) {
this._registerListener('fcu', { 1: symbol }, FundingCredit, cbGID, cb)
} | Register a handler to be called when a funding credit is updated
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-credits | onFundingCreditUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingCreditClose ({ symbol, cbGID }, cb) {
this._registerListener('fcc', { 1: symbol }, FundingCredit, cbGID, cb)
} | Register a handler to be called when a funding credit is closed
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-credits | onFundingCreditClose | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingLoanSnapshot ({ symbol, cbGID }, cb) {
this._registerListener('fls', { 1: symbol }, FundingLoan, cbGID, cb)
} | Register a handler to be called on each funding loan snapshot (sent on
auth)
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-loans
@see WSv2#auth | onFundingLoanSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingLoanNew ({ symbol, cbGID }, cb) {
this._registerListener('fln', { 1: symbol }, FundingLoan, cbGID, cb)
} | Register a handler to be called when a funding loan is created
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-loans | onFundingLoanNew | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingLoanUpdate ({ symbol, cbGID }, cb) {
this._registerListener('flu', { 1: symbol }, FundingLoan, cbGID, cb)
} | Register a handler to be called when a funding loan is updated
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-loans | onFundingLoanUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingLoanClose ({ symbol, cbGID }, cb) {
this._registerListener('flc', { 1: symbol }, FundingLoan, cbGID, cb)
} | Register a handler to be called when a funding loan is closed
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-loans | onFundingLoanClose | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onWalletSnapshot ({ cbGID }, cb) {
this._registerListener('ws', null, Wallet, cbGID, cb)
} | Register a handler to be called on each wallet snapshot (sent on auth)
@param {object} opts - options
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-wallets | onWalletSnapshot | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onWalletUpdate ({ cbGID }, cb) {
this._registerListener('wu', null, Wallet, cbGID, cb)
} | Register a handler to be called on each wallet update
@param {object} opts - options
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-wallets | onWalletUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onBalanceInfoUpdate ({ cbGID }, cb) {
this._registerListener('bu', null, BalanceInfo, cbGID, cb)
} | Register a handler to be called on each balance info update
@param {object} opts - options
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-balance | onBalanceInfoUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onMarginInfoUpdate ({ cbGID }, cb) {
this._registerListener('miu', null, MarginInfo, cbGID, cb)
} | Register a handler to be called on each margin info update
@param {object} opts - options
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-margin | onMarginInfoUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingInfoUpdate ({ cbGID }, cb) {
this._registerListener('fiu', null, FundingInfo, cbGID, cb)
} | Register a handler to be called on each funding info update
@param {object} opts - options
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-funding | onFundingInfoUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingTradeEntry ({ symbol, cbGID }, cb) {
this._registerListener('fte', { 0: symbol }, FundingTrade, cbGID, cb)
} | Register a handler to be called on each funding trade `'te'` event
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-funding-trades | onFundingTradeEntry | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onFundingTradeUpdate ({ symbol, cbGID }, cb) {
this._registerListener('ftu', { 0: symbol }, FundingTrade, cbGID, cb)
} | Register a handler to be called on each funding trade `'tu'` event
@param {object} opts - options
@param {string} [opts.symbol] - symbol to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-funding-trades | onFundingTradeUpdate | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
onNotification ({ type, cbGID }, cb) {
this._registerListener('n', { 1: type }, Notification, cbGID, cb)
} | Register a handler to be called on each notification
@param {object} opts - options
@param {string} [opts.type] - type to match
@param {string} [opts.cbGID] - callback group id
@param {Function} cb - callback
@see https://docs.bitfinex.com/v2/reference#ws-auth-notifications | onNotification | javascript | bitfinexcom/bitfinex-api-node | lib/transports/ws2.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/transports/ws2.js | MIT |
setSigFig = (number = 0, maxSigs = DEFAULT_SIG_FIGS) => {
const n = +(number)
if (!isFinite(n)) {
return number
}
const value = n.toPrecision(maxSigs)
return /e/.test(value)
? new Big(value).toString()
: value
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | setSigFig | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
setSigFig = (number = 0, maxSigs = DEFAULT_SIG_FIGS) => {
const n = +(number)
if (!isFinite(n)) {
return number
}
const value = n.toPrecision(maxSigs)
return /e/.test(value)
? new Big(value).toString()
: value
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | setSigFig | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
setPrecision = (number = 0, decimals = 0) => {
const n = +(number)
return (isFinite(n))
? n.toFixed(decimals)
: number
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | setPrecision | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
setPrecision = (number = 0, decimals = 0) => {
const n = +(number)
return (isFinite(n))
? n.toFixed(decimals)
: number
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | setPrecision | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
prepareAmount = (amount = 0) => {
return setPrecision(amount, AMOUNT_DECIMALS)
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | prepareAmount | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
prepareAmount = (amount = 0) => {
return setPrecision(amount, AMOUNT_DECIMALS)
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | prepareAmount | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
preparePrice = (price = 0) => {
return setSigFig(price, PRICE_SIG_FIGS)
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | preparePrice | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
preparePrice = (price = 0) => {
return setSigFig(price, PRICE_SIG_FIGS)
} | Smartly set the precision (decimal) on a value based off of the significant
digit maximum. For example, calling with 3.34 when the max sig figs allowed
is 5 would return '3.3400', the representation number of decimals IF they
weren't zeros.
@param {number} number - number to manipulate
@param {number} [maxSigs] - defa... | preparePrice | javascript | bitfinexcom/bitfinex-api-node | lib/util/precision.js | https://github.com/bitfinexcom/bitfinex-api-node/blob/master/lib/util/precision.js | MIT |
function processResponse() {
// attempt to parse the json now
if(util.isJsonResponse(res)) {
if(body) {
try {
body = JSON.parse(body);
} catch (e) {
return resolver.reject(errors.invalidJson());
}
}
}
// salesforce returned a... | options:
- sobject
- uri
- callback
- oauth
- multipart
- method
- encoding
- body
- qs
- headers | processResponse | javascript | kevinohara80/nforce | index.js | https://github.com/kevinohara80/nforce/blob/master/index.js | MIT |
authenticate = (username, password, securityToken) =>
new Promise((resolve, reject) => {
// Authenticate using multi user mode
org.authenticate(
{
username: username,
password: password,
securityToken: securityToken
},
(error, response) => {
if (!error) {
... | Authenticate to login a user in the org
@param {string} username - e.g. john@example.com
@param {string} password
@param {string} securityToken - Your user's security token.
This can be reset in the org if needed. | authenticate | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
authenticate = (username, password, securityToken) =>
new Promise((resolve, reject) => {
// Authenticate using multi user mode
org.authenticate(
{
username: username,
password: password,
securityToken: securityToken
},
(error, response) => {
if (!error) {
... | Authenticate to login a user in the org
@param {string} username - e.g. john@example.com
@param {string} password
@param {string} securityToken - Your user's security token.
This can be reset in the org if needed. | authenticate | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
query = (queryString, oauth) =>
new Promise((resolve, reject) => {
org.query(
{
query: queryString,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(response.records)
} else {
reject(error)
}
}
)
}) | Perform a SOQL Query
@param {string} queryString - SOQL query
@param {object} oauth - OAuth string received from successful authentication | query | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
query = (queryString, oauth) =>
new Promise((resolve, reject) => {
org.query(
{
query: queryString,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(response.records)
} else {
reject(error)
}
}
)
}) | Perform a SOQL Query
@param {string} queryString - SOQL query
@param {object} oauth - OAuth string received from successful authentication | query | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
createRecord = (sobjectName, recordData, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordData)
return new Promise((resolve, reject) => {
org.insert(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(response)
... | Create a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordData - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | createRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
createRecord = (sobjectName, recordData, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordData)
return new Promise((resolve, reject) => {
org.insert(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(response)
... | Create a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordData - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | createRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
updateRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordDataWithID)
return new Promise((resolve, reject) => {
org.update(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(resp... | Update a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | updateRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
updateRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordDataWithID)
return new Promise((resolve, reject) => {
org.update(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(resp... | Update a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | updateRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
upsertRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName)
const recordId = !!recordDataWithID.id ? recordDataWithID.id : ''
sobj.setExternalId('Id', recordId)
Object.entries(recordDataWithID).map(([key, value]) => {
sobj.set(key, value)
})
return new Promi... | Upsert a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | upsertRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
upsertRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName)
const recordId = !!recordDataWithID.id ? recordDataWithID.id : ''
sobj.setExternalId('Id', recordId)
Object.entries(recordDataWithID).map(([key, value]) => {
sobj.set(key, value)
})
return new Promi... | Upsert a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | upsertRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
deleteRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordDataWithID)
return new Promise((resolve, reject) => {
org.delete(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(resp... | Delete a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | deleteRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
deleteRecord = (sobjectName, recordDataWithID, oauth) => {
const sobj = nforce.createSObject(sobjectName, recordDataWithID)
return new Promise((resolve, reject) => {
org.delete(
{
sobject: sobj,
oauth: oauth
},
(error, response) => {
if (!error) {
resolve(resp... | Delete a record
@param {string} sobjectName - Name of the SObject (e.g. Account)
@param {object} recordDataWithID - Key value pair of Field Names and Field Values
@param {object} oauth - OAuth string received from successful authentication | deleteRecord | javascript | kevinohara80/nforce | examples/async-await-cruds.js | https://github.com/kevinohara80/nforce/blob/master/examples/async-await-cruds.js | MIT |
Usage = (props) => {
return <HelloWorld />
} | !!!!!!!!!!!!!!!!!!!!!!!!!!!
DO NOT DELETE OR CHANGE THIS.
This is how you would use your above component and
the output of this code is displayed on the browser | Usage | javascript | tyroprogrammer/learn-react-app | src/exercise/solution/01-HelloWorld-solution.js | https://github.com/tyroprogrammer/learn-react-app/blob/master/src/exercise/solution/01-HelloWorld-solution.js | MIT |
Usage = (props) => {
return <HelloWorld />
} | !!!!!!!!!!!!!!!!!!!!!!!!!!!
DO NOT DELETE OR CHANGE THIS.
This is how you would use your above component and
the output of this code is displayed on the browser | Usage | javascript | tyroprogrammer/learn-react-app | src/exercise/solution/01-HelloWorld-solution.js | https://github.com/tyroprogrammer/learn-react-app/blob/master/src/exercise/solution/01-HelloWorld-solution.js | MIT |
Usage = (props) => {
return <HelloWorld />
} | !!!!!!!!!!!!!!!!!!!!!!!!!!!
DO NOT DELETE OR CHANGE THIS.
This is how you would use your above component and
the output of this code is displayed on the browser | Usage | javascript | tyroprogrammer/learn-react-app | src/exercise/solution/02-IntroToJSX-solution.js | https://github.com/tyroprogrammer/learn-react-app/blob/master/src/exercise/solution/02-IntroToJSX-solution.js | MIT |
Usage = (props) => {
return <HelloWorld />
} | !!!!!!!!!!!!!!!!!!!!!!!!!!!
DO NOT DELETE OR CHANGE THIS.
This is how you would use your above component and
the output of this code is displayed on the browser | Usage | javascript | tyroprogrammer/learn-react-app | src/exercise/solution/02-IntroToJSX-solution.js | https://github.com/tyroprogrammer/learn-react-app/blob/master/src/exercise/solution/02-IntroToJSX-solution.js | MIT |
install(app) {
app.component('Swiper', Swiper);
app.component('SwiperSlide', SwiperSlide);
} | @file vue-awesome-swiper
@author Surmon <https://github.com/surmon-china> | install | javascript | surmon-china/vue-awesome-swiper | index.js | https://github.com/surmon-china/vue-awesome-swiper/blob/master/index.js | MIT |
render = async (fullMarkdown, extraOptions = {}) => {
const { yamlOptions, markdown: contentOnlyMarkdown } = parseYamlFrontMatter(fullMarkdown);
const options = Object.assign(getSlideOptions(yamlOptions), extraOptions);
const { title } = options;
const themeUrl = getThemeUrl(options.theme, options.assetsDir, o... | Renders the given markdown content into HTML.
@param {string} fullMarkdown - The contents of the markdown file, including a possible YAML front matter
@param {Object} extraOptions - Additional options (mostly used by tests)
@returns {string} The rendered HTML compatible with reveal.js | render | javascript | webpro/reveal-md | lib/render.js | https://github.com/webpro/reveal-md/blob/master/lib/render.js | MIT |
render = async (fullMarkdown, extraOptions = {}) => {
const { yamlOptions, markdown: contentOnlyMarkdown } = parseYamlFrontMatter(fullMarkdown);
const options = Object.assign(getSlideOptions(yamlOptions), extraOptions);
const { title } = options;
const themeUrl = getThemeUrl(options.theme, options.assetsDir, o... | Renders the given markdown content into HTML.
@param {string} fullMarkdown - The contents of the markdown file, including a possible YAML front matter
@param {Object} extraOptions - Additional options (mostly used by tests)
@returns {string} The rendered HTML compatible with reveal.js | render | javascript | webpro/reveal-md | lib/render.js | https://github.com/webpro/reveal-md/blob/master/lib/render.js | MIT |
renderFile = async (filePath, extraOptions) => {
try {
const content = await readFile(filePath);
return render(content.toString(), extraOptions);
} catch (e) {
return render('File not found.', extraOptions);
}
} | Renders the given markdown content into HTML.
@param {string} fullMarkdown - The contents of the markdown file, including a possible YAML front matter
@param {Object} extraOptions - Additional options (mostly used by tests)
@returns {string} The rendered HTML compatible with reveal.js | renderFile | javascript | webpro/reveal-md | lib/render.js | https://github.com/webpro/reveal-md/blob/master/lib/render.js | MIT |
renderFile = async (filePath, extraOptions) => {
try {
const content = await readFile(filePath);
return render(content.toString(), extraOptions);
} catch (e) {
return render('File not found.', extraOptions);
}
} | Renders the given markdown content into HTML.
@param {string} fullMarkdown - The contents of the markdown file, including a possible YAML front matter
@param {Object} extraOptions - Additional options (mostly used by tests)
@returns {string} The rendered HTML compatible with reveal.js | renderFile | javascript | webpro/reveal-md | lib/render.js | https://github.com/webpro/reveal-md/blob/master/lib/render.js | MIT |
replaceArgs = (cmd, shell) => {
const replacements = { f: this._getFile(shell), d: this._getFolder(shell), m: this._getMountFolder(shell) }
return cmd.replace(/\$([fdm])\b/g, match => `"${replacements[match.slice(1)]}"`)
} | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | replaceArgs | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
replaceArgs = (cmd, shell) => {
const replacements = { f: this._getFile(shell), d: this._getFolder(shell), m: this._getMountFolder(shell) }
return cmd.replace(/\$([fdm])\b/g, match => `"${replacements[match.slice(1)]}"`)
} | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | replaceArgs | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
getShellCommand = shell => {
switch (shell) {
case this.SHELL.GIT_BASH:
return `bash.exe -c`
case this.SHELL.POWER_SHELL:
return `powershell /C`
case this.SHELL.WSL:
return `wsl.exe -e bash -c`
... | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | getShellCommand | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
getShellCommand = shell => {
switch (shell) {
case this.SHELL.GIT_BASH:
return `bash.exe -c`
case this.SHELL.POWER_SHELL:
return `powershell /C`
case this.SHELL.WSL:
return `wsl.exe -e bash -c`
... | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | getShellCommand | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
callback_ = (err, stdout, stderr) => {
const hasError = err || stderr.length > 0
const errorMessage = hasError ? (err || stderr.toString()) : null
if (reject && hasError) {
reject(errorMessage)
} else if (resolve && !hasError) {
resolve(std... | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | callback_ | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
callback_ = (err, stdout, stderr) => {
const hasError = err || stderr.length > 0
const errorMessage = hasError ? (err || stderr.toString()) : null
if (reject && hasError) {
reject(errorMessage)
} else if (resolve && !hasError) {
resolve(std... | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | callback_ | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
reject = data => {
this.entities.pre.textContent += data.toString();
this.entities.pre.classList.add("error");
} | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | reject | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
reject = data => {
this.entities.pre.textContent += data.toString();
this.entities.pre.classList.add("error");
} | Implementing this plugin requires three types of compatibility:
1. Abstracting operating system differences to support Windows and Linux.
2. Abstracting shell differences to support cmd, WSL, and bash, including nested shell calls.
3. Abstracting parameter differences, where cmd uses %VAR% and bash uses $VAR. | reject | javascript | obgnail/typora_plugin | plugin/commander.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/commander.js | MIT |
constructor(plugin, formatBrushString) {
this.utils = plugin.utils
this.formatBrushObj = this.parseStyleString(formatBrushString)
} | This code contains workarounds and hacks to address specific behaviors of Typora.
Understanding the intricacies may be challenging. This documentation outlines the implementation logic for future modifications.
Core Idea: Simplify the problem by initially focusing on single-line selections.
1. Single-Line Selection S... | constructor | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
innerSelected = () => {
if (line.substring(bookmark.start, bookmark.end + suffix.length).endsWith(suffix)) {
const result = beforeText.match(/<span .*?>/g);
if (!result) return;
const last = result[result.length - 1];
if (last && beforeText.end... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | innerSelected | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
innerSelected = () => {
if (line.substring(bookmark.start, bookmark.end + suffix.length).endsWith(suffix)) {
const result = beforeText.match(/<span .*?>/g);
if (!result) return;
const last = result[result.length - 1];
if (last && beforeText.end... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | innerSelected | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
outerSelected = () => {
const result = innerText.match(matcher);
return result && result.groups && result.groups.wrapper;
} | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | outerSelected | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
outerSelected = () => {
const result = innerText.match(matcher);
return result && result.groups && result.groups.wrapper;
} | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | outerSelected | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
splitArray = (array, separatorFunc) => {
return array.reduce((acc, current) => {
if (separatorFunc(current)) {
acc.push([]);
} else {
if (acc.length === 0) {
acc.push([]);
}
... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | splitArray | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
splitArray = (array, separatorFunc) => {
return array.reduce((acc, current) => {
if (separatorFunc(current)) {
acc.push([]);
} else {
if (acc.length === 0) {
acc.push([]);
}
... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | splitArray | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
isEqualRange = (a, b) => (
a && b && a.startContainer === b.startContainer && a.startOffset === b.startOffset
&& a.endContainer === b.endContainer && a.endOffset === b.endOffset
) | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | isEqualRange | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
isEqualRange = (a, b) => (
a && b && a.startContainer === b.startContainer && a.startOffset === b.startOffset
&& a.endContainer === b.endContainer && a.endOffset === b.endOffset
) | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | isEqualRange | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
newRange = (startContainer, startOffset, endContainer, endOffset) => ({
startContainer, startOffset, endContainer, endOffset
}) | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | newRange | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
newRange = (startContainer, startOffset, endContainer, endOffset) => ({
startContainer, startOffset, endContainer, endOffset
}) | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | newRange | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
getTextNodes = node => {
if (node.nodeType === document.TEXT_NODE) {
textNodes.push(node);
} else if (node.nodeType === document.ELEMENT_NODE && (node.classList.contains("md-raw-inline") || node.classList.contains("md-softbreak"))) {
} else {
for (let ... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | getTextNodes | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
getTextNodes = node => {
if (node.nodeType === document.TEXT_NODE) {
textNodes.push(node);
} else if (node.nodeType === document.ELEMENT_NODE && (node.classList.contains("md-raw-inline") || node.classList.contains("md-softbreak"))) {
} else {
for (let ... | There are four possible user selection scenarios, for example: `123<span style="color:#FF0000;">abc</span>defg`
a. No selection.
b. Standard selection (e.g., "efg").
c. Selection within an existing styled span (e.g., "abc"): Modify the outer text.
d. Selection encompassing an entire styled span (e.g., `<span st... | getTextNodes | javascript | obgnail/typora_plugin | plugin/text_stylize.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/text_stylize.js | MIT |
_getLatestVersion = async () => {
const resp = await this.utils.fetch(url, this.requestOption);
return resp.json()
} | Force update: skip the check and directly update using the URL. | _getLatestVersion | javascript | obgnail/typora_plugin | plugin/updater.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/updater.js | MIT |
_getLatestVersion = async () => {
const resp = await this.utils.fetch(url, this.requestOption);
return resp.json()
} | Force update: skip the check and directly update using the URL. | _getLatestVersion | javascript | obgnail/typora_plugin | plugin/updater.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/updater.js | MIT |
_getCurrentVersion = async () => {
try {
const exist = await this.utils.existPath(this.versionFile)
if (exist) {
return this.pkgFsExtra.readJson(this.versionFile);
}
} catch (e) {
console.debug("not exist version... | Force update: skip the check and directly update using the URL. | _getCurrentVersion | javascript | obgnail/typora_plugin | plugin/updater.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/updater.js | MIT |
_getCurrentVersion = async () => {
try {
const exist = await this.utils.existPath(this.versionFile)
if (exist) {
return this.pkgFsExtra.readJson(this.versionFile);
}
} catch (e) {
console.debug("not exist version... | Force update: skip the check and directly update using the URL. | _getCurrentVersion | javascript | obgnail/typora_plugin | plugin/updater.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/updater.js | MIT |
constructor(controller) {
this.utils = controller.utils
} | Force update: skip the check and directly update using the URL. | constructor | javascript | obgnail/typora_plugin | plugin/updater.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/updater.js | MIT |
initGlobalVars = settings => {
// "global" is a general setting, not a plugin setting
Object.defineProperty(settings, "global", { enumerable: false })
global.BasePlugin = BasePlugin
global.BaseCustomPlugin = BaseCustomPlugin
global.LoadPlugins = LoadPlugins
global.__plug... | Initializes global variables.
The plugin system exposes the following global variables, but only 3 are actually useful: BasePlugin, BaseCustomPlugin, and LoadPlugins.
The remaining variables are exposed by the static class `utils` and should never be referenced by business plugins.
Furthermore, `utils` is also an insta... | initGlobalVars | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
initGlobalVars = settings => {
// "global" is a general setting, not a plugin setting
Object.defineProperty(settings, "global", { enumerable: false })
global.BasePlugin = BasePlugin
global.BaseCustomPlugin = BaseCustomPlugin
global.LoadPlugins = LoadPlugins
global.__plug... | Initializes global variables.
The plugin system exposes the following global variables, but only 3 are actually useful: BasePlugin, BaseCustomPlugin, and LoadPlugins.
The remaining variables are exposed by the static class `utils` and should never be referenced by business plugins.
Furthermore, `utils` is also an insta... | initGlobalVars | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
loadPlugins = async () => {
const { enable, disable, stop, error, nosetting } = await LoadPlugins(global.__plugin_settings__)
global.__plugins__ = enable
} | Initializes global variables.
The plugin system exposes the following global variables, but only 3 are actually useful: BasePlugin, BaseCustomPlugin, and LoadPlugins.
The remaining variables are exposed by the static class `utils` and should never be referenced by business plugins.
Furthermore, `utils` is also an insta... | loadPlugins | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
loadPlugins = async () => {
const { enable, disable, stop, error, nosetting } = await LoadPlugins(global.__plugin_settings__)
global.__plugins__ = enable
} | Initializes global variables.
The plugin system exposes the following global variables, but only 3 are actually useful: BasePlugin, BaseCustomPlugin, and LoadPlugins.
The remaining variables are exposed by the static class `utils` and should never be referenced by business plugins.
Furthermore, `utils` is also an insta... | loadPlugins | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
warn = () => {
const incompatible = utils.compareVersion(utils.typoraVersion, "0.9.98") < 0
if (incompatible) {
const msg = i18n.t("global", "incompatibilityWarning")
utils.notification.show(msg, "warning", 5000)
}
} | For Typora versions below 0.9.98, a compatibility warning is issued when running the plugin system. | warn | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
warn = () => {
const incompatible = utils.compareVersion(utils.typoraVersion, "0.9.98") < 0
if (incompatible) {
const msg = i18n.t("global", "incompatibilityWarning")
utils.notification.show(msg, "warning", 5000)
}
} | For Typora versions below 0.9.98, a compatibility warning is issued when running the plugin system. | warn | javascript | obgnail/typora_plugin | plugin/global/core/index.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/index.js | MIT |
LoadPlugin = async (fixedName, setting, isBasePlugin) => {
const path = isBasePlugin ? "./plugin" : "./plugin/custom/plugins"
const { plugin } = utils.requireFilePath(path, fixedName)
if (!plugin) {
return new Error(`There is not ${fixedName} in ${path}`)
}
const instance = new plugin(fixedN... | Cleanup, generally used for memory reclamation, used infrequently. | LoadPlugin | javascript | obgnail/typora_plugin | plugin/global/core/plugin.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/plugin.js | MIT |
LoadPlugin = async (fixedName, setting, isBasePlugin) => {
const path = isBasePlugin ? "./plugin" : "./plugin/custom/plugins"
const { plugin } = utils.requireFilePath(path, fixedName)
if (!plugin) {
return new Error(`There is not ${fixedName} in ${path}`)
}
const instance = new plugin(fixedN... | Cleanup, generally used for memory reclamation, used infrequently. | LoadPlugin | javascript | obgnail/typora_plugin | plugin/global/core/plugin.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/plugin.js | MIT |
LoadPlugins = async (settings) => {
const isBase = settings.hasOwnProperty("global")
const plugins = { enable: {}, disable: {}, stop: {}, error: {}, nosetting: {} }
const promises = Object.entries(settings).map(async ([fixedName, setting]) => {
if (!setting) {
plugins.nosetting[fixedName... | Cleanup, generally used for memory reclamation, used infrequently. | LoadPlugins | javascript | obgnail/typora_plugin | plugin/global/core/plugin.js | https://github.com/obgnail/typora_plugin/blob/master/plugin/global/core/plugin.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.