GithubHelp home page GithubHelp logo

xing-chuan / locally-cookie Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 9 KB

:tada: locally-cookie is a 1KB lightweight library base localStorage that looks like cookie.

License: MIT License

JavaScript 100.00%
cookie

locally-cookie's Introduction

English | 简体中文

locally-cookie is a 1KB lightweight library based on localStorage that stores session data and fixed time-length data locally

Getting Started

  • Storage is only valid in subdomains
  • across domains it is not recommended to store large amounts of data, such as the cache of the entire page
  • support IE8 or more

Installation

npm i -S locally-cookie

API

import locallyCookie from 'locally-cookie';

set

/**
 * Parameter
 * key {String} required
 * value {String|Boolean|Number|Array|Object} required
 * day {Number} 0 session data, Turn off browser invalidation
 | 1,2... Expired after 1, 2 days | -1 Theory is permanent and effective, optional, default 0
*/
locallyCookie.set('key', value, [day]);

get

/**
 * Parameter
 * key {String} required
*/
locallyCookie.get('key');

delete

/**
 * Parameter
 * key {String} required
*/
locallyCookie.del('key');

has

/**
 * Parameter
 * key {String} required
*/
locallyCookie.has('key');

locally-cookie's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.