Skip to content

Commit

Permalink
refactor: update module
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove namespace
  • Loading branch information
ricardogobbosouza committed Aug 13, 2019
1 parent 38c012b commit a208314
Show file tree
Hide file tree
Showing 27 changed files with 883 additions and 821 deletions.
28 changes: 0 additions & 28 deletions .codeclimate.yml

This file was deleted.

8 changes: 1 addition & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{json,json.dist,yml,yml.dist}]
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.txt]
insert_final_newline = false
11 changes: 6 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
root: true,
extends: [
'@cknow/eslint-config'
]
};
root: true,
extends: '@datalogix/eslint-config',
env: {
browser: true
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.nyc_output/
coverage/
node_modules/
npm-debug.log
Expand Down
12 changes: 0 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ cache:
notifications:
email: false

env:
global:
- CC_TEST_REPORTER_ID=754d8da795dcfd341f07f12695d8b22cb213c48322d2a00f73c27ae6d6538c62

node_js:
- 12
- 11
Expand All @@ -22,19 +18,11 @@ node_js:
install:
- travis_retry npm install

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

script:
- node --version
- npm --version
- npm test

after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

after_success:
- npm run report-coverage

Expand Down
84 changes: 30 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# @storage-js/vue-localforage
# v-localforage

[![NPM Version](https://img.shields.io/npm/v/@storage-js/vue-localforage.svg)](https://www.npmjs.com/package/@storage-js/vue-localforage)
[![Downloads](https://img.shields.io/npm/dt/@storage-js/vue-localforage.svg)](https://www.npmjs.com/package/@storage-js/vue-localforage)
[![MIT License](https://img.shields.io/npm/l/@storage-js/vue-localforage.svg)](LICENSE)

[![Build Status](https://travis-ci.org/storage-js/vue-localforage.svg?branch=master)](https://travis-ci.org/storage-js/vue-localforage)
[![Build status](https://ci.appveyor.com/api/projects/status/dy8i5evw1iah5lkj/branch/master?svg=true)](https://ci.appveyor.com/project/cknow/vue-localforage/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/storage-js/vue-localforage/badge.svg?branch=master)](https://coveralls.io/github/storage-js/vue-localforage?branch=master)

[![Code Climate](https://codeclimate.com/github/storage-js/vue-localforage/badges/gpa.svg)](https://codeclimate.com/github/storage-js/vue-localforage)
[![Test Coverage](https://codeclimate.com/github/storage-js/vue-localforage/badges/coverage.svg)](https://codeclimate.com/github/storage-js/vue-localforage/coverage)
[![Issue Count](https://codeclimate.com/github/storage-js/vue-localforage/badges/issue_count.svg)](https://codeclimate.com/github/storage-js/vue-localforage)

[![Dependencies Status](https://david-dm.org/storage-js/vue-localforage/status.svg)](https://david-dm.org/storage-js/vue-localforage)
[![devDependencies Status](https://david-dm.org/storage-js/vue-localforage/dev-status.svg)](https://david-dm.org/storage-js/vue-localforage?type=dev)
[![peerDependencies Status](https://david-dm.org/storage-js/vue-localforage/peer-status.svg)](https://david-dm.org/storage-js/vue-localforage?type=peer)

[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/storage-js/vue-localforage.svg)](http://isitmaintained.com/project/storage-js/vue-localforage)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/storage-js/vue-localforage.svg)](http://isitmaintained.com/project/storage-js/vue-localforage)
[![Gitter](https://badges.gitter.im/storage-js/vue-localforage.svg)](https://gitter.im/storage-js/vue-localforage?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Version](https://img.shields.io/npm/v/v-localforage.svg)](https://www.npmjs.com/package/v-localforage)
[![Downloads](https://img.shields.io/npm/dt/v-localforage.svg)](https://www.npmjs.com/package/v-localforage)
[![Build Status](https://img.shields.io/travis/ricardogobbosouza/v-localforage)](https://travis-ci.org/ricardogobbosouza/v-localforage)
[![Codecov](https://img.shields.io/codecov/c/github/ricardogobbosouza/v-localforage)](https://codecov.io/gh/ricardogobbosouza/v-localforage)
[![License](https://img.shields.io/npm/l/v-localforage.svg)](LICENSE)

> A plugin wrapped from [localForage](https://github.com/localForage/localForage) for Vue.js.
Expand All @@ -29,75 +14,75 @@

```bash
# install it via npm
npm install @storage-js/vue-localforage --save
npm install v-localforage --save
```

### Install using yarn

```bash
# install it via yarn
yarn add @storage-js/vue-localforage
yarn add v-localforage
```

### Direct usage with html

```html
<!-- insert the vue core before it -->
<script src="https://unpkg.com/@storage-js/vue-localforage"></script>
<script src="https://unpkg.com/v-localforage"></script>
```

## Usage

```js
// register the plugin on vue
import VueLocalforage from '@storage-js/vue-localforage';
import VueLocalforage from 'v-localforage'

Vue.use(VueLocalforage);
Vue.use(VueLocalforage)

// you can also pass options, check options reference below
Vue.use(VueLocalforage, Options);
Vue.use(VueLocalforage, Options)
```

### Get item

```js
let item = await this.$localForage.getItem(key)
let item = await this.$localforage.getItem(key)
```

### Set item

```js
await this.$localForage.setItem(key, value)
await this.$localforage.setItem(key, value)
```

### Remove item

```js
await this.$localForage.removeItem(key)
await this.$localforage.removeItem(key)
```

### Clear

```js
await this.$localForage.clear()
await this.$localforage.clear()
```

### Gets the length

```js
let length = await this.$localForage.length()
let length = await this.$localforage.length()
```

### Get the name of a key based on its ID

```js
let k = await this.$localForage.key(keyIndex)
let k = await this.$localforage.key(keyIndex)
```

### Get the list of all keys

```js
let keys = await this.$localForage.keys()
let keys = await this.$localforage.keys()
```

[More informations on LocalForage documentation](https://localforage.github.io/localForage/#data-api)
Expand All @@ -108,22 +93,21 @@ You can register multiple instances, see below:

```js
Vue.use(VueLocalforage, {
instances: [
{
storeName: 'instance1'
},

{
storeName: 'instance2'
}
]
});
instances: [
{
storeName: 'instance1'
},
{
storeName: 'instance2'
}
]
})

// for instance1
await this.$localForage.instance1.setItem(key, value)
await this.$localforage.instance1.setItem(key, value)

// for instance2
await this.$localForage.instance2.setItem(key, value)
await this.$localforage.instance2.setItem(key, value)
```

## Options
Expand Down Expand Up @@ -171,11 +155,3 @@ The schema version of your database.
A description of the database.

[More informations on LocalForage documentation](https://localforage.github.io/localForage/#settings-api-config)

## License

[MIT License](./LICENSE)

### Contributors

- [Ricardo Gobbo de Souza](https://github.com/ricardogobbosouza)
23 changes: 0 additions & 23 deletions appveyor.yml

This file was deleted.

18 changes: 9 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
presets: [
[
'@babel/preset-env', {
targets: {
node: 'current'
}
}
]
presets: [
[
'@babel/preset-env', {
targets: {
node: 'current'
}
}
]
};
]
}
8 changes: 4 additions & 4 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: [
'@commitlint/config-conventional'
]
};
extends: [
'@commitlint/config-conventional'
]
}
34 changes: 34 additions & 0 deletions dist/v-localforage.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var localforage = _interopDefault(require('localforage'));

const VueLocalforage = {
install(Vue, options = {}) {
Vue.$localforage = localforage.createInstance(options);
Vue.prototype.$localforage = Vue.$localforage;

if (!options.instances) {
return
}

for (const instance of options.instances) {
const name = instance.storeName || instance.name;

if (!name) {
continue
}

Vue.$localforage[name] = localforage.createInstance(instance);
Vue.prototype.$localforage[name] = Vue.$localforage[name];
}
}
};

/* istanbul ignore next */
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VueLocalforage);
}

module.exports = VueLocalforage;
30 changes: 30 additions & 0 deletions dist/v-localforage.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import localforage from 'localforage';

const VueLocalforage = {
install(Vue, options = {}) {
Vue.$localforage = localforage.createInstance(options);
Vue.prototype.$localforage = Vue.$localforage;

if (!options.instances) {
return
}

for (const instance of options.instances) {
const name = instance.storeName || instance.name;

if (!name) {
continue
}

Vue.$localforage[name] = localforage.createInstance(instance);
Vue.prototype.$localforage[name] = Vue.$localforage[name];
}
}
};

/* istanbul ignore next */
if (typeof window !== 'undefined' && window.Vue) {
window.Vue.use(VueLocalforage);
}

export default VueLocalforage;
Loading

0 comments on commit a208314

Please sign in to comment.