Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ionic/storage

Package Overview
Dependencies
Maintainers
24
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/storage - npm Package Compare versions

Comparing version 2.3.1 to 3.0.0-alpha.2

dist/esm/index.d.ts

89

package.json
{
"name": "@ionic/storage",
"version": "2.3.1",
"description": "Ionic Storage utility",
"version": "3.0.0-alpha.2",
"description": "Ionic Storage Helper",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"dist/"
],
"author": "Ionic Team",
"license": "MIT",
"repository": {

@@ -9,64 +18,28 @@ "type": "git",

},
"keywords": [
"ionic",
"angular",
"localforage",
"cordova",
"hybrid"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/ionic-team/ionic-storage/issues"
},
"homepage": "https://github.com/ionic-team/ionic-storage#readme",
"keywords": [
"capacitor",
"plugin",
"native"
],
"scripts": {
"ts": "tsc",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build"
},
"dependencies": {
"localforage": "1.7.1",
"localforage-cordovasqlitedriver": "1.7.0",
"tslib": "^1.10.0"
"localforage": "^1.9.0"
},
"peerDependencies": {
"@angular/core": "*",
"rxjs": "*"
"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"rimraf": "^3.0.2",
"rollup": "^2.40.0",
"typescript": "^4.1.3"
},
"$schema": "./node_modules/ng-packagr/package.schema.json",
"release": {
"branches": "stable",
"pkgRoot": "dist",
"verifyConditions": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
],
"prepare": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git"
],
"publish": [
"@semantic-release/github",
"@semantic-release/npm"
],
"success": [
"@semantic-release/github"
],
"fail": [
"@semantic-release/github"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"main": "bundles/ionic-storage.umd.js",
"module": "fesm5/ionic-storage.js",
"es2015": "fesm2015/ionic-storage.js",
"esm5": "esm5/ionic-storage.js",
"esm2015": "esm2015/ionic-storage.js",
"fesm5": "fesm5/ionic-storage.js",
"fesm2015": "fesm2015/ionic-storage.js",
"typings": "ionic-storage.d.ts",
"metadata": "ionic-storage.metadata.json",
"sideEffects": false
"gitHead": "0b550acdc2d21c95c68e0655b28698ec60fa283a"
}

@@ -1,130 +0,1 @@

[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fionic-team%2Fionic-storage%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/ionic-team/ionic-storage/goto?ref=main)
# Ionic Storage
A simple key-value Storage module for Ionic apps based on LocalForage, with out-of-the-box support for SQLite. This utility makes it easy to use the best storage engine available without having to interact with it directly. Currently the ordering is SQLite, IndexedDB, WebSQL, and LocalStorage.
One reason we prioritize SQLite is because of some OS-dependent issues with storage in the browser in native apps. As a major example, iOS will currently clear out Local Storage (and IndexedDB it's been shown) when the device runs low on memory. To avoid that, a file-based storage approach with SQLite will retain all your data.
If you want to perform arbitrary SQL queries and have one of the best storage options around, we recommend using the [Ionic Native SQLite plugin](https://ionicframework.com/docs/v2/native/sqlite/) directly. This engine no longer supports the `query` feature underneath as it was not portable and only worked for SQLite anyways.
For those coming from Ionic pre RC.0, here is more insight in to the reason for us moving to this module: https://github.com/ionic-team/ionic/issues/8269#issuecomment-250590367
### Installation
To use this in your Ionic /Angular apps, either start a fresh Ionic project which has it installed by default, or run:
```bash
npm install @ionic/storage
```
If you'd like to use SQLite as a storage engine, install a SQLite plugin (only works while running in a simulator or on device):
```bash
cordova plugin add cordova-sqlite-storage --save
```
### Usage
Then edit your NgModule declaration in `src/app/app.module.ts` to add `IonicStorageModule` as an import:
```typescript
import { IonicStorageModule } from '@ionic/storage';
@NgModule({
declarations: [
...
],
imports: [
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
...
],
providers: [
...
]
})
export class AppModule { }
```
Now, you can easily inject `Storage` into a component:
```typescript
import { Component } from '@angular/core';
import { Storage } from '@ionic/storage';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private storage: Storage) {
}
}
```
To make sure the storage system is ready before using, call `Storage.ready()`. You must be
on 1.1.7 or greater to use the `ready()` method.
```javascript
storage.ready().then(() => {
});
```
To set an item, use `Storage.set(key, value)`:
```javascript
this.storage.set('name', 'Mr. Ionitron');
```
To get the item back, use `Storage.get(name).then((value) => {})` since `get()` returns a Promise:
```javascript
this.storage.get('name').then((name) => {
console.log('Me: Hey, ' + name + '! You have a very nice name.');
console.log('You: Thanks! I got it for my birthday.');
});
```
To remove the item, use `Storage.remove(key).then(() => { })`
### Configuring Storage (new in 1.1.7)
The Storage engine can be configured both with specific storage engine priorities, or custom configuration
options to pass to localForage. See the localForage config docs for possible options: https://github.com/localForage/localForage#configuration
```typescript
import { Storage } from '@ionic/storage';
@NgModule({
declarations: ...,
imports: [
IonicStorageModule.forRoot({
name: '__mydb',
driverOrder: ['indexeddb', 'sqlite', 'websql']
})
],
bootstrap: ...,
entryComponents: ...,
})
export class AppModule { }
```
### Development and release
When you're ready to release a new version, run the following commands:
1. npm version (patch|minor|major)
2. npm run build
3. commit and push: `git push origin master --tags`
4. cd dist
5. npm publish
# Ionic Storage Helper

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc