1.2.7 • Published 6 years ago
localjson v1.2.7
github address: https://github.com/fuel-efficient/localJson
Updated: getLJson() and clearLJson()
You can directly input key to get or delete the set of objects with key
English readme
Install
npm install localjson
If in ES5, without the addition of babel. Delete the export at the beginning of the index.js file and then import it as a script.
Each namespace exists in an array
Each obj exists in an array of objects
Import
Pay attention to the initial capitalization of the class name..
import Localjson from 'localjson'
1. First, set up the localName to store. (localName parameter required)
For example, namespace ----'myjson'is initialized at the time of initialization
This is required. Initialization without namespaces will be wrong
Note that if the namespaces are instantiated at the same time, the last namespace instantiated object will be returned
var myjson = new Localjson('myjson')
2. Adding obj to myjson. (obj parameters required, optional storageObj parameter)
If there is no storageObj, the obj at this point will be written to the myjson namespace automatically
If you have storageObj, then obj is added to the storageObj first and then written into the myjson namespace
myjson.setLJson(obj, storageObj)
3. Gets the record of the corresponding localName in localStorage. (index parameter optional)
The content of the cache is first obtained, and localStorage is called if it is not available
myjson.getLJson() //returns all the contents of the current namespace
myjson.getLJson(number) //returns the object at the corresponding number subscript position
myjson.getLJson('key','key',,,,) //returns the set of objects with the corresponding key input
4. Update the content in the myjson namespace. (obj parameters required, optional index parameter)
obj is a collection of objects (arrays) or object
If there is no index, obj replaces the entire namespace
If there is index, then obj replaces the object corresponding to the index subscript in the namespace
myjson.upLJson(obj, index)
5. Clear the contents in the myjso
Index parameter optional
If there is a index parameter, the object of the corresponding index position in the namespace is cleared
If you don't have index, empty the entire namespace
myjson.clearLJson()
myjson.clearLJson(index)
myjson.clearLJson('key','key',,,,) //Clears the input set of objects with the corresponding key key and returns the collection of objects without the key
Chinese readme
安装
npm install localjson
如果在es5,不添加babel的情况。把index.js文件中开头的export删除,然后以脚本的方式导入即可。
每一个命名空间都是以数组的方式存在的
每一个obj都以对象的方式存在数组中
导入
注意类名首字母大写。。
import Localjson from 'localjson'
1. 首先设置要存储的localName。(localName参数必选)
例如初始化时设置命名空间----'myjson'
这个是必需的,初始化没有命名空间会报错
注意如果实例化时的命名空间相同,则会返回上一次的创建的命名空间实例化的对象
var myjson = new Localjson('myjson')
2. 将obj加入myjson中。(obj参数必选,storageObj参数可选)
如果没有storageObj,此时的obj将会被自动写入myjson命名空间中
如果有storageObj,则obj会被先加入到storageObj中再写入到myjson命名空间中的
myjson.setLJson(obj, storageObj)
3. 获取localStorage中对应localName的记录。(index参数可选)
会首先获取缓存中的内容,获取不到才会调用localStorage
myjson.getLJson() //返回当前命名空间所有内容
myjson.getLJson(number) //返回相应number下标位置的对象
myjson.getLJson('key','key',,,,) //返回输入的具有相应key键的对象集合
4. 更新myjson命名空间中的内容。(obj参数必选,index参数可选)
obj可以是对象或对象集合(数组)
如果没有index,则obj会将整个命名空间替换
如果有index,则obj替换命名空间中对应index下标的对象
myjson.upLJson(obj, index)
5. 清除myjson命名空间中的内容
index参数可选
如果有index参数,则清除命名空间中相应index位置的对象
如果没有index,则清空整个命名空间
myjson.clearLJson()
myjson.clearLJson(index)
myjson.clearLJson('key','key',,,,) //清除输入的具有相应key键的对象集合,并返回不含油key键的对象集合
1.2.7
6 years ago
1.2.6
6 years ago
1.2.5
7 years ago
1.2.4
7 years ago
1.2.3
7 years ago
1.2.2
7 years ago
1.2.1
7 years ago
1.2.0
7 years ago
1.1.8
7 years ago
1.1.71
7 years ago
1.1.7
7 years ago
1.1.6
7 years ago
1.1.5
7 years ago
1.1.4
7 years ago
1.1.3
7 years ago
1.1.2
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago