1.2.1 • Published 5 years ago

yourstorage v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

npm.io Storage: yourstorage npm.io npm.io

npm.io npm.io

  1. npm install yourstorage --save.

  2. Add "moduleResolution": "node" to your tsconfig file to allow build-in types to be used. This will not affect any other types.

  3. Commonjs import * as storage from 'yourstorage' or amd const storage = require('storage').

Using storage

storage.set assign the variabel to a function to get or set value.

const username = storage.set('username', prompt('Username please: ') || 'Bill Gates', options);

Get or set storage value

// set the username to 'Donald Trump'
username('Donald Trump');

username();
// Expected output: 'Donald Trump'

Readonly storages

const options = {
  readonly: true
}

Cookie storage

Storage is default set to LocalStorage but you can change it to cookie so the server can access it.

const options = {
  storage: 'cookie'
}

Secure cookie connection

Storage option secure is default set to 'http' (unsecure) but you can set it to 'https' (secure) by changing the secure option to true (or false for unsecure connection).

const options = {
  secure: true
}
  • storage

'cookie' | 'local'

Which storage the key should be stored in. local will not share data to the server. Cookie will share data to the server

  • expires

number | Date

Define when the cookie will be removed. Value can be a Number which will be interpreted as days from time of creation or a Date instance. If omitted, the cookie becomes a session cookie.

  • path

string

Define the path where the cookie is available. Defaults to '/'.

  • domain

string

Define the domain where the cookie is available. Defaults to the domain of the page where the cookie was created.

  • secure

boolean

A Boolean indicating if the cookie transmission requires a secure protocol (https). Defaults to false.

Please sponsor me by giving this repo a star!

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago