npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@totvs/storage

v0.0.1-20220307.3

Published

Mingle Storage

Downloads

127

Readme

@TOTVS/STORAGE

This Package @totvs/storage provides a service for storing data on the local device,

This package is compatible with Angular, React and Javascript projects.

Installation

Using npm: $ npm install --save @totvs/storage

// using ES6 modules
import { TotvsStorage } from @totvs/storage;
var storage = new TotvsStorage();

// using CommonJS modules
var storageInstance = require('@totvs/http')
var storage = new storageInstance.TotvsStorage('your bank name');

Methods

appendArrayToArray

Searches for a list stored by the key and concatenates it with the list passed by parameter.


const clients = [ { name: 'Marie', age: 23 }, { name: 'Pether', age: 39 }];

this.storage.appendArrayToArray('myKey', clients).subscribe( res => {
    console.log(res);
});

clear

Removes all items from the database and delete the storage


this.storage.clear().subscribe( res => {
    console.log(res);
});

exists

Checks whether a value exists within a given key.


this.storage.exists('myKey').subscribe( res => {
    console.log(res);
});

get

Returns the value stored in a given key.


this.storage.get('myKey', false).subscribe( res => {
    console.log(res);
});

getAll

Returns the value stored in a given key.


this.storage.getAll().subscribe( res => {
    console.log(res);
});

getItemAndRemove

Removes the first item from a list from the key.

getItemByField

Searches for the first object found within a list by the value of a field.

  const clients = [ { name: 'Marie', age: 23 }, { name: 'Pether', age: 39 }];

  this.thfStorageService.set('clientKey', clients).then(() => {});

  ...

  this.thfStorageService.getItemByField('clientKey', 'name', 'Marie').then(client => {
    console.log(client);
     // console.log result: { name: 'Marie', age: 23 }
  });

keys

List with all keys stored.


this.storage.keys().subscribe( res => {
    console.log(res);
});

length

Number of keys stored.


this.storage.length().subscribe( res => {
    console.log(res);
});

limitedCallWrap

Used to manage the locking and unlocking of resources in the TotvsStorage. Waiting to release the resource that participates in this behavior and later involves the resource passed as a parameter in a lock and unlock behavior.

This method behaves the same as using the methods together: TotvsStorage.requestIdlePromise (), TotvsStorage.lock (), and TotvsStorage.unlook ().

lock

Increments a value in the Totvs Storage lock queue. Used in conjunction with the unlock method to be able to control the execution of a given task with TotvsStorage.requestIdlePromise ().

remove

Removes a value associated with a key.


this.storage.remove('myKey').subscribe( res => {
    console.log(res);
});

removeItemFromArray

Removes an object from a list stored by the value of a property.


this.storage.removeItemFromArray('myKey', 'name', 'Marie').subscribe( res => {
    console.log(res);
});

requestIdlePromise

Method that checks whether the access to the configured database is released.

Used in conjunction with the lock () and unlock () methods between tasks that can not be performed in parallel, so as not to cause inconsistencies in the data.

// Waiting for release to continue
await this.storage.requestIdlePromise();

this.storage.lock();

// Performs a task that will read and / or write to the configured database.

this.storage.unlock();

It is important to always use it before executing the lock () and unlock () methods to ensure that the task will only be executed if access is free.

set

Writes a value to a given key.


this.storage.set('myKey', 'this is my content').subscribe( res => {
    console.log(res);
});

unlock

Decrements a value in the lock queue. Used in conjunction with the lock method to control the execution of a given task with TotvsStorage.requestIdlePromise ().