StackedMemory class
MemoryInterface 的 Stack 實作。 記憶體變數具有階層式關聯性。
- Extends
-
Array<MemoryInterface>
屬性
Array |
繼承的屬性
length | 取得或設定陣列的長度。 這是比陣列所定義最高項目高一的數字。 |
方法
get |
從指定的路徑取得值。 |
set |
將值設定為指定的路徑。 |
version() | 取得目前 StackedMemory的版本。 |
wrap(Memory |
將實作 MemoryInterface 的物件包裝至 StackedMemory 物件。 |
繼承的方法
屬性詳細資料
Array
static Array: ArrayConstructor
屬性值
ArrayConstructor
繼承的屬性詳細資料
length
取得或設定陣列的長度。 這是比陣列所定義最高項目高一的數字。
length: number
屬性值
number
繼承自 Array.length
方法詳細資料
getValue(string)
從指定的路徑取得值。
function getValue(path: string): any
參數
- path
-
string
指定的路徑。
傳回
any
如果找到,則為指定路徑中的值,否則為未定義。
setValue(string, any)
將值設定為指定的路徑。
function setValue(_path: string, _value: any)
參數
- _path
-
string
記憶體路徑。
- _value
-
any
要設定的值。
version()
wrap(MemoryInterface)
將實作 MemoryInterface 的物件包裝至 StackedMemory 物件。
static function wrap(memory: MemoryInterface): StackedMemory
參數
- memory
- MemoryInterface
實作 MemoryInterface的物件。
傳回
繼承的方法的詳細資料
concat(ConcatArray<MemoryInterface>[])
結合兩個或多個陣列。
function concat(items: ConcatArray<MemoryInterface>[]): MemoryInterface[]
參數
- items
-
ConcatArray<MemoryInterface>[]
要新增至 array1 結尾的其他專案。
傳回
繼承自 Array.concat
concat(T | ConcatArray<T>[])
結合兩個或多個陣列。
function concat(items: T | ConcatArray<T>[]): MemoryInterface[]
參數
- items
-
T | ConcatArray<T>[]
要新增至 array1 結尾的其他專案。
傳回
繼承自 Array.concat
every((value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, any)
判斷陣列的所有成員是否符合指定的測試。
function every(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, thisArg?: any): boolean
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown
最多可以接受三個引數的函式。 每個方法都會針對 array1 中的每個元素呼叫 callbackfn 函式,直到 callbackfn 傳回 false,或直到陣列結尾為止。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 做為此值。
傳回
boolean
繼承自 Array.every
filter((value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, any)
傳回符合回呼函式中所指定條件之陣列的專案。
function filter(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, thisArg?: any): MemoryInterface[]
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown
最多可以接受三個引數的函式。 篩選方法會針對陣列中的每個專案呼叫 callbackfn 函式一次。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 做為此值。
傳回
繼承自 Array.filter
filter<S>((value: MemoryInterface, index: number, array: MemoryInterface[]) => boolean, any)
傳回符合回呼函式中所指定條件之陣列的專案。
function filter<S>(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => boolean, thisArg?: any): S[]
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => boolean
最多可以接受三個引數的函式。 篩選方法會針對陣列中的每個專案呼叫 callbackfn 函式一次。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 作為此值。
傳回
S[]
繼承自 Array.filter
forEach((value: MemoryInterface, index: number, array: MemoryInterface[]) => void, any)
針對陣列中的每個元素執行指定的動作。
function forEach(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => void, thisArg?: any)
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => void
最多可以接受三個引數的函式。 forEach 會針對陣列中的每個元素呼叫 callbackfn 函式一次。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 作為此值。
繼承自 Array.forEach
indexOf(MemoryInterface, number)
傳回陣列中值第一個出現位置的索引。
function indexOf(searchElement: MemoryInterface, fromIndex?: number): number
參數
- searchElement
- MemoryInterface
陣列中要尋找的值。
- fromIndex
-
number
要開始搜尋的陣列索引。 如果省略 fromIndex,搜尋會從索引 0 開始。
傳回
number
繼承自 Array.indexOf
join(string)
加入以指定分隔符號字串分隔之陣列的所有專案。
function join(separator?: string): string
參數
- separator
-
string
字串,用來分隔陣列的其中一個專案與產生的 String 中的下一個專案。 如果省略,陣列元素會以逗號分隔。
傳回
string
繼承自 Array.join
lastIndexOf(MemoryInterface, number)
傳回陣列中所指定值最後一個出現位置的索引。
function lastIndexOf(searchElement: MemoryInterface, fromIndex?: number): number
參數
- searchElement
- MemoryInterface
陣列中要尋找的值。
- fromIndex
-
number
要開始搜尋的陣列索引。 如果省略 fromIndex,搜尋會從陣列中的最後一個索引開始。
傳回
number
繼承自 Array.lastIndexOf
map<U>((value: MemoryInterface, index: number, array: MemoryInterface[]) => U, any)
在陣列中的每個元素上呼叫定義的回呼函式,並傳回包含結果的陣列。
function map<U>(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => U, thisArg?: any): U[]
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => U
最多可以接受三個引數的函式。 map 方法會針對陣列中的每個元素呼叫 callbackfn 函式一次。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 作為此值。
傳回
U[]
繼承自 Array.map
pop()
移除陣列的最後一個元素,然後將它傳回。
function pop(): MemoryInterface | undefined
傳回
MemoryInterface | undefined
繼承自 Array.pop
push(MemoryInterface[])
附加新元素到陣列中,並傳回陣列的新長度。
function push(items: MemoryInterface[]): number
參數
- items
Array 的新元素。
傳回
number
繼承自 Array.push
reduce((previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface)
呼叫陣列中所有專案的指定回呼函式。 回呼函式的傳回值即為累加結果,並做為下一個呼叫的引數提供給回呼函式。
function reduce(callbackfn: (previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface): MemoryInterface
參數
- callbackfn
-
(previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface
最多接受四個引數的函式。 reduce 方法會針對陣列中的每個元素呼叫 callbackfn 函式一次。
傳回
繼承自 Array.reduce
reduce((previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface, MemoryInterface)
function reduce(callbackfn: (previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface, initialValue: MemoryInterface): MemoryInterface
參數
- callbackfn
-
(previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface
- initialValue
- MemoryInterface
傳回
繼承自 Array.reduce
reduce<U>((previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U, U)
呼叫陣列中所有專案的指定回呼函式。 回呼函式的傳回值即為累加結果,並做為下一個呼叫的引數提供給回呼函式。
function reduce<U>(callbackfn: (previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U, initialValue: U): U
參數
- callbackfn
-
(previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U
最多接受四個引數的函式。 reduce 方法會針對陣列中的每個元素呼叫 callbackfn 函式一次。
- initialValue
-
U
如果指定 initialValue,則會用來做為初始值來啟動累積。 對 callbackfn 函式的第一次呼叫會提供此值做為引數,而不是陣列值。
傳回
U
繼承自 Array.reduce
reduceRight((previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface)
以遞減順序呼叫陣列中所有專案的指定回呼函式。 回呼函式的傳回值即為累加結果,並做為下一個呼叫的引數提供給回呼函式。
function reduceRight(callbackfn: (previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface): MemoryInterface
參數
- callbackfn
-
(previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface
最多接受四個引數的函式。 reduceRight 方法會針對陣列中的每個元素呼叫 callbackfn 函式一次。
傳回
繼承自 Array.reduceRight
reduceRight((previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface, MemoryInterface)
function reduceRight(callbackfn: (previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface, initialValue: MemoryInterface): MemoryInterface
參數
- callbackfn
-
(previousValue: MemoryInterface, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => MemoryInterface
- initialValue
- MemoryInterface
傳回
繼承自 Array.reduceRight
reduceRight<U>((previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U, U)
以遞減順序呼叫陣列中所有專案的指定回呼函式。 回呼函式的傳回值即為累加結果,並做為下一個呼叫的引數提供給回呼函式。
function reduceRight<U>(callbackfn: (previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U, initialValue: U): U
參數
- callbackfn
-
(previousValue: U, currentValue: MemoryInterface, currentIndex: number, array: MemoryInterface[]) => U
最多接受四個引數的函式。 reduceRight 方法會針對陣列中的每個元素呼叫 callbackfn 函式一次。
- initialValue
-
U
如果指定 initialValue,則會用來做為初始值來啟動累積。 對 callbackfn 函式的第一次呼叫會提供此值做為引數,而不是陣列值。
傳回
U
繼承自 Array.reduceRight
reverse()
shift()
移除陣列的第一個項目,然後將它傳回。
function shift(): MemoryInterface | undefined
傳回
MemoryInterface | undefined
繼承自 Array.shift
slice(number, number)
傳回陣列的一個區段。
function slice(start?: number, end?: number): MemoryInterface[]
參數
- start
-
number
陣列指定部分的開頭。
- end
-
number
陣列指定部分的結尾。
傳回
繼承自 Array.slice
some((value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, any)
判斷指定的回呼函式是否針對陣列的任何專案傳回 true。
function some(callbackfn: (value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown, thisArg?: any): boolean
參數
- callbackfn
-
(value: MemoryInterface, index: number, array: MemoryInterface[]) => unknown
最多可以接受三個引數的函式。 某些方法會呼叫 array1 中每個元素的 callbackfn 函式,直到 callbackfn 傳回 true,或直到陣列結尾為止。
- thisArg
-
any
這個關鍵字可以在 callbackfn 函式中參考的物件。 如果省略 thisArg,則會使用 undefined 作為此值。
傳回
boolean
繼承自 Array.some
sort((a: MemoryInterface, b: MemoryInterface) => number)
排序陣列。
function sort(compareFn?: (a: MemoryInterface, b: MemoryInterface) => number): this
參數
- compareFn
-
(a: MemoryInterface, b: MemoryInterface) => number
用來判斷專案順序的函式名稱。 如果省略,元素會以遞增、ASCII 字元順序排序。
傳回
this
繼承自 Array.sort
splice(number, number)
移除陣列中的元素,並依需要在適當位置插入新元素,然後傳回被刪除的元素。
function splice(start: number, deleteCount?: number): MemoryInterface[]
參數
- start
-
number
陣列中以零起始的位置,要從中開始移除專案。
- deleteCount
-
number
要移除的項目數目。
傳回
繼承自 Array.splice
splice(number, number, MemoryInterface[])
移除陣列中的元素,並依需要在適當位置插入新元素,然後傳回被刪除的元素。
function splice(start: number, deleteCount: number, items: MemoryInterface[]): MemoryInterface[]
參數
- start
-
number
陣列中以零起始的位置,要從中開始移除專案。
- deleteCount
-
number
要移除的項目數目。
- items
要插入陣列中的元素取代已刪除的專案。
傳回
繼承自 Array.splice
toLocaleString()
傳回陣列的字串表示。 元素會使用其 toLocalString 方法轉換成字串。
function toLocaleString(): string
傳回
string
繼承自 Array.toLocaleString
toString()
傳回陣列的字串表示。
function toString(): string
傳回
string
繼承自 Array.toString
unshift(MemoryInterface[])
在陣列的開頭插入新元素。
function unshift(items: MemoryInterface[]): number
參數
- items
要插入陣列開頭的專案。
傳回
number
繼承自 Array.unshift