Skip to content

dyazincahya/local-storage-array-nativescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ko-fi

Local Storage Array for Nativescript

This is a simple Local Storage Array for Nativescript, integrated by application-settings module. With this you can add some array in localstorage.

Features

  • get all data or by index
  • insert
  • update
  • remove
  • drop

Support

Nativescript 8 or newer

Dependency with Module

application-settings

Documentation

import { LSget, LSinsert, LSupdate, LSremove, LSdrop } from '../localstorage_array'

you can adjust that Import path if you want

GET

With this, you can get all data or get data by index.

Method

LSget(index, distinct, xkey)

Param Description
Params Type Default Value Description
index number null For get data by index. If you want get all data, you can fill null for this field.
distinct boolean false Set TRUE if you want hide duplicate data in your array.
xkey String lsakc Your xkey.
Example
// you can adjust that Import path
import { LSget } from '../localstorage_array'

let a = LSget();
if(a.success){
  console.log(a.data);
} else {
  console.log(a.message);
}

INSERT

For insert new data.

Method

LSinsert(data, xkey)

Param Description
Params Type Default Value Description
data json or array [] Add your data here, data must be in json format.
xkey String lsakc You can make new your xkey here.
Example
// you can adjust that Import path
import { LSinsert } from '../localstorage_array'

let mydata = {
  "name"  : "kang cahya",
  "hobby" : "hiking",
  "color" : "blue"
};
let a = LSinsert(mydata);
if(a.success){
  console.log(a.data);
} else {
  console.log(a.message);
}

UPDATE

For update data by index.

Method

LSupdate(data, index, xkey)

Param Description
Params Type Default Value Description
data json {} Add your data here, data must be in json format.
index number 0 This is a key for update your data.
xkey String lsakc Your xkey.
Example
// you can adjust that Import path
import { LSupdate } from '../localstorage_array'

let mydata = {
  "name"  : "kang cahya",
  "hobby" : "hiking",
  "color" : "blue"
};
let a = LSupdate(mydata, 1);
if(a.success){
  console.log(a.data);
} else {
  console.log(a.message);
}

REMOVE

For delete data by index.

Method

LSremove(index, xkey)

Param Description
Params Type Default Value Description
index number 0 This is a key for delete your data.
xkey String lsakc Your xkey.
Example
// you can adjust that Import path
import { LSremove } from '../localstorage_array'

let a = LSremove(3);
if(a.success){
  console.log(a.message);
} else {
  console.log(a.message);
}

DROP

With this, you can delete all data in xkey.

Method

LSdrop(xkey)

Param Description
Params Type Default Value Description
xkey String lsakc Your xkey.
Example
// you can adjust that Import path
import { LSdrop } from '../localstorage_array'

let a = LSdrop("your_xkey");
if(a.success){
  console.log(a.message);
} else {
  console.log(a.message);
}

Author

Kang Cahya

License

MIT License