All Projects → azu → localstorage-ponyfill

azu / localstorage-ponyfill

Licence: MIT License
Universal LocalStorage for browser and Node.js.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to localstorage-ponyfill

lvm-localpv
CSI Driver for dynamic provisioning of Persistent Local Volumes for Kubernetes using LVM.
Stars: ✭ 86 (+65.38%)
Mutual labels:  storage
storage
Go library providing common interface for working across multiple cloud storage backends
Stars: ✭ 154 (+196.15%)
Mutual labels:  storage
gasper
Gasper is a CLI for safe, privacy-aware file storage based on Shamir's Secret Sharing
Stars: ✭ 37 (-28.85%)
Mutual labels:  storage
Ionic-2-sqlite-demo
Simple demo to show how to work with Sqlite Storage in Ionic 2
Stars: ✭ 20 (-61.54%)
Mutual labels:  storage
one
🚥 Idempotency Handler, for making sure incoming requests are idempotent. Useful for payments, "at least once delivery" systems and more.
Stars: ✭ 18 (-65.38%)
Mutual labels:  storage
S4
S4 is 100% S3 compatible storage, accessed through Tor and distributed using IPFS.
Stars: ✭ 67 (+28.85%)
Mutual labels:  storage
modernstorage
ModernStorage is a group of libraries that provide an abstraction layer over storage on Android to simplify its interactions
Stars: ✭ 982 (+1788.46%)
Mutual labels:  storage
web
realness.online
Stars: ✭ 15 (-71.15%)
Mutual labels:  storage
o9n
🖥 A screen.orientation ponyfill
Stars: ✭ 55 (+5.77%)
Mutual labels:  ponyfill
form-data
Spec-compliant FormData implementation for Node.js
Stars: ✭ 73 (+40.38%)
Mutual labels:  ponyfill
tag-storage
🗄CNCF Storage TAG
Stars: ✭ 94 (+80.77%)
Mutual labels:  storage
EDS
💡 💾 💽 A simple, intuitive and Efficient single cell binary Data Storage format
Stars: ✭ 16 (-69.23%)
Mutual labels:  storage
file-storage-system
一个基于 Go 语言实现的分布式云存储服务,慕课网实战仿百度网盘项目。
Stars: ✭ 149 (+186.54%)
Mutual labels:  storage
minio-rclone-webdav-server
A @rclone served WebDAV server with @minio as the s3 storage backend docker example
Stars: ✭ 17 (-67.31%)
Mutual labels:  storage
infinitree
Scalable and encrypted embedded database with 3-tier caching
Stars: ✭ 80 (+53.85%)
Mutual labels:  storage
perfmonger
No description or website provided.
Stars: ✭ 39 (-25%)
Mutual labels:  storage
carrierwave-dropbox
Carrierwave storage for Dropbox
Stars: ✭ 67 (+28.85%)
Mutual labels:  storage
snowfs
SnowFS - a fast, scalable version control file storage for graphic files 🎨
Stars: ✭ 1,101 (+2017.31%)
Mutual labels:  storage
xayah
WEB文件管理器
Stars: ✭ 19 (-63.46%)
Mutual labels:  storage
xfsvol
Local Docker Volumes with XFS Project Quota
Stars: ✭ 24 (-53.85%)
Mutual labels:  storage

localstorage-ponyfill Actions Status: test

Universal LocalStorage ponyfill library for Browser and Node.js.

Install

Install with npm:

npm install localstorage-ponyfill

Usage

Auto(Browser or Node.js)

Automatically select mode.

  • If the environment defined window.localStorage -> "browser"
  • else -> "node"
import { createLocalStorage } from "localstorage-ponyfill";
const localStorage = createLocalStorage();
localStorage.setItem("key", "value");
const value = localStorage.getItem("key");
assert.strictEqual(value, "value");        

Browser

Native localStorage.

import { createLocalStorage } from "localstorage-ponyfill";
const localStorage = createLocalStorage({ mode : "browser" });

Node.js

Use node-localstorage

Store data to <app-root>/.cache/localstorage-ponyfill/* by default.

import { createLocalStorage } from "localstorage-ponyfill";
const localStorage = createLocalStorage({ mode : "node" });

You can setting the path by storeFilePath option.

import { createLocalStorage } from "localstorage-ponyfill";
const localStorage = createLocalStorage({ mode : "node", storeFilePath: "./path/to/dir" });

InMemory

InMemory localStorage work on Node.js and Browser.

Use localstorage-memory

import { createLocalStorage } from "localstorage-ponyfill";
const localStorage = createLocalStorage({ mode : "memory" });

API

Same with Window.localStorage

export interface LocalStoragePonyfill {
    readonly length: number;

    clear(): void;

    getItem(key: string): string | null;

    key(index: number): string | null;

    removeItem(key: string): void;

    setItem(key: string, data: string): void;

    [key: string]: any;

    [index: number]: string;
}

IndexedDB

If you want to get IndexedDB storage, please use azu/kvs.

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].