Class: BalanceArray<T>
T extends NumberType
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:875
Extends
BaseTypedArray<BalanceArray<T>,Balance<T>>
Type Parameters
T
T extends NumberType
Implements
BalanceFunctions<T>
Indexable
[
n:number]:Balance<T>
Constructors
Constructor
new BalanceArray<
T>(arrayLength):BalanceArray<T>
Defined in: site/node_modules/typescript/lib/lib.es5.d.ts:1513
Parameters
arrayLength
number
Returns
BalanceArray<T>
Inherited from
BaseTypedArray<BalanceArray<T>, Balance<T>>.constructor
Constructor
new BalanceArray<
T>(...items):BalanceArray<T>
Defined in: site/node_modules/typescript/lib/lib.es5.d.ts:1514
Parameters
items
...Balance<T>[]
Returns
BalanceArray<T>
Inherited from
BaseTypedArray<BalanceArray<T>, Balance<T>>.constructor
Methods
addBalance()
addBalance(
balanceToAdd):this
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:993
Adds the balanceToAdd to the existing balances. Returns a new BalanceArray.
Parameters
balanceToAdd
iBalance<T>
Returns
this
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.addBalance
addBalances()
addBalances(
balancesToAdd):this
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:983
Adds multiple balances to the existing balances. Returns a new BalanceArray.
Parameters
balancesToAdd
BalanceArray<T> | iBalance<T>[]
Returns
this
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.addBalances
applyIncrements()
applyIncrements(
incrementTokenIdsBy,incrementOwnershipTimesBy,numIncrements,durationFromTimestamp,blockTime):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:1030
Applys increments to balances. Returns a new BalanceArray with the incremented balances.
Parameters
incrementTokenIdsBy
T
incrementOwnershipTimesBy
T
numIncrements
T
durationFromTimestamp
T
blockTime
T
Returns
BalanceArray<T>
Remarks
Can also be used via the applyIncrements method on BalanceArray
Implementation of
BalanceFunctions.applyIncrements
clone()
clone():
BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:913
Returns
BalanceArray<T>
convert()
convert<
U>(convertFunction,options?):BalanceArray<U>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:909
Type Parameters
U
U extends NumberType
Parameters
convertFunction
(item) => U
options?
Returns
BalanceArray<U>
equalBalances()
equalBalances(
other,checkZeroBalances?):boolean
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:962
Checks if two balances are equal. Flag to check if the balances with zero amounts should be checked as well.
Parameters
other
BalanceArray<T> | iBalance<T>[]
checkZeroBalances?
boolean = false
Returns
boolean
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.equalBalances
every()
every(
predicate,thisArg?):boolean
Defined in: packages/bitbadgesjs-sdk/src/common/typed-arrays.ts:108
Determines whether all the members of an array satisfy the specified test.
Parameters
predicate
(value, index, array) => unknown
A function that accepts up to three arguments. The every method calls the predicate function for each element in the array until the predicate returns a value which is coercible to the Boolean value false, or until the end of the array.
thisArg?
any
An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
Returns
boolean
Inherited from
BaseTypedArray.every
filterZeroBalances()
filterZeroBalances():
this
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:941
Filters out all balances with amount == 0. Returns a new BalanceArray.
Returns
this
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.filterZeroBalances
getAllTokenIds()
getAllTokenIds():
UintRangeArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:1047
Gets all token IDs from the balances (sorted and merged).
Returns
getBalanceForIdAndTime()
getBalanceForIdAndTime(
tokenId,ownedTime):T
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:920
Find the balance amount for a specific token ID at a specific time within a set of balances. Returns x0 if not found.
Parameters
tokenId
T
The Token ID to search for.
ownedTime
T
The time to search for.
Returns
T
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.getBalanceForIdAndTime
getBalancesForId()
getBalancesForId(
tokenId):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:927
Returns all matching balances for a specific token ID. Returns a new BalanceArray.
Parameters
tokenId
T
Returns
BalanceArray<T>
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.getBalancesForId
getBalancesForTime()
getBalancesForTime(
ownedTime):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:934
Returns all matching balances for a specific time via a new BalanceArray.
Parameters
ownedTime
T
Returns
BalanceArray<T>
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.getBalancesForTime
sortBalancesByAmount()
sortBalancesByAmount():
BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:1020
Sorts balances by their amount property. Returns a new BalanceArray.
Returns
BalanceArray<T>
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.sortBalancesByAmount
subsetOf()
subsetOf(
threshold):boolean
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:951
Checks if the current balances are a subset of the threshold balances (i.e. doesn't exceed the threshold).
Parameters
threshold
BalanceArray<T> | iBalance<T>[]
Returns
boolean
Implementation of
BalanceFunctions.subsetOf
subtractBalance()
subtractBalance(
balanceToSubtract,allowUnderflow):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:1013
Subtracts the balanceToRemove from the existing balances. Returns a new BalanceArray.
Throws an error if the balances underflow.
Parameters
balanceToSubtract
iBalance<T>
allowUnderflow
boolean
Returns
BalanceArray<T>
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.subtractBalance
subtractBalances()
subtractBalances(
balancesToSubtract,allowNegatives?):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:1003
Subtracts multiple balances from the existing balances. Returns a new BalanceArray.
Throws an error if the balances underflow.
Parameters
balancesToSubtract
BalanceArray<T> | iBalance<T>[]
allowNegatives?
boolean = false
Returns
BalanceArray<T>
Remarks
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.subtractBalances
updateBalances()
updateBalances(
newBalance):this
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:973
Updates the balance for what it currently is to newAmount.
Parameters
newBalance
iBalance<T>
Returns
this
Remarks
Returns a new BalanceArray. Does not modify the original.
Can also be used via the corresponding method with same name on BalanceArray
Implementation of
BalanceFunctions.updateBalances
From()
staticFrom<T>(arr):BalanceArray<T>
Defined in: packages/bitbadgesjs-sdk/src/core/balances.ts:876
Type Parameters
T
T extends NumberType
Parameters
arr
iBalance<T> | iBalance<T>[] | BalanceArray<T>
Returns
BalanceArray<T>