aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2022-01-22 20:29:58 -0500
committerPriyansh <[email protected]>2022-01-22 20:29:58 -0500
commit703b4176d84b3f3deadf9c0b86649c29c8c333f9 (patch)
treec0a69a6dc9cbe285bd880c37b23b42b3e3657af3 /src
parent9b744e4ce05b56a1aef94110c027d920a5e10005 (diff)
downloadizuku.js-703b4176d84b3f3deadf9c0b86649c29c8c333f9.tar.xz
izuku.js-703b4176d84b3f3deadf9c0b86649c29c8c333f9.zip
feat: rangeIndex function
Diffstat (limited to 'src')
-rw-r--r--src/index.ts6
-rw-r--r--src/lib/locate.ts10
2 files changed, 15 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts
index 7c10f85..acb613d 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,7 +3,8 @@ import {
getMultipleColumnDetails,
getSingleColumnDetails,
getSingleRowDetails,
- getMultipleRowDetails
+ getMultipleRowDetails,
+ rangeIndex
} from './lib/locate';
import { show, head, tail } from './lib/display';
import { getSize, info } from './lib/info';
@@ -57,6 +58,9 @@ class Izuku {
public flatten = () => {
return flatten(this.rowdata);
};
+ public rangeIndex = (index: number) => {
+ return rangeIndex(this, index);
+ };
}
class Frame extends Izuku {
diff --git a/src/lib/locate.ts b/src/lib/locate.ts
index 733ba9f..46d4712 100644
--- a/src/lib/locate.ts
+++ b/src/lib/locate.ts
@@ -1,3 +1,4 @@
+import { flatten } from './data';
interface Izuku {
rowdata: unknown[][];
columns: string[];
@@ -110,3 +111,12 @@ export function getMultipleRowDetails(iz: Izuku, rows: Array<number>) {
});
return { rowd: extractedRows, rowh: iz.columns };
}
+
+/**
+ * rangeIndex returns the element at the specified index of the complete frame
+ * @param index: the index of the element to be returned
+ * @returns the element at the specified index of the complete frame
+ */
+export function rangeIndex(iz: Izuku, index: number): any {
+ return flatten(iz.rowdata)[index];
+}