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

backbone.localstorage

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.localstorage - npm Package Compare versions

Comparing version 1.1.16 to 2.0.0-alpha.1

.eslintrc.yaml

54

package.json
{
"author": "Jerome Gravel-Niquet <jeromegn@gmail.com> (http://jgn.me)",
"author": "Scott Walton <s@cott.me.uk>",
"name": "backbone.localstorage",
"version": "1.1.16",
"version": "2.0.0-alpha.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/jeromegn/Backbone.localStorage.git"
"url": "git://github.com/scott-w/backbone.localstorage.git"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.3.2",
"babel-preset-latest": "^6.22.0",
"backbone": "^1.3.3",
"coveralls": "^2.11.16",
"eslint": "^3.15.0",
"expect.js": "^0.3.1",
"html-webpack-plugin": "^2.28.0",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^2.0.0",
"jquery": "~3.1.1",
"karma": "^1.4.1",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^0.2.3",
"karma-coveralls": "^1.1.2",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-webpack": "^2.0.2",
"mocha": "^3.2.0",
"sinon": "next",
"uglify-js": "~1.2.6",
"mocha-phantomjs": "^3.5.1",
"browserify": "~2.x.x",
"jquery": "~2.1.0",
"backbone": "~1.x.x",
"underscore": ">=1.4.0"
"underscore": "1.8.3",
"webpack": "^2.2.1",
"window-or-global": "^1.0.1"
},
"peerDependencies": {
"backbone": "~1.x.x"
"backbone": "1.3.3"
},
"scripts": {
"build": "webpack",
"ci": "karma start --single-run --browsers Firefox",
"compile": "webpack -p",
"debug": "test",
"lint": "eslint src test",
"test": "karma start --single-run && eslint src test",
"watch": "karma start"
},
"keywords": [

@@ -28,6 +59,3 @@ "backbone",

],
"main": "./backbone.localStorage.js",
"engines": {
"node": "*"
}
"main": "./build/backbone.localstorage.js"
}

@@ -1,131 +0,96 @@

# Backbone localStorage Adapter v1.1.16
# Backbone localStorage Backend
[![Build Status](https://secure.travis-ci.org/jeromegn/Backbone.localStorage.png?branch=master)](http://travis-ci.org/jeromegn/Backbone.localStorage)
An adapter that replaces `Backbone.sync` to save to `window.localStorage`
instead of to the server.
Quite simply a localStorage adapter for Backbone. It's a drop-in replacement for Backbone.Sync() to handle saving to a localStorage database.
**Note** Backbone LocalStorage v2 changes the API to work more with ES6 modules.
See [Upgrade Notes](#upgrade-notes) for more details.
[![Gittip](http://badgr.co/gittip/jeromegn.png)](https://www.gittip.com/jeromegn/)
## Usage
Include Backbone.localStorage after having included Backbone.js:
Import `backbone.localstorage` and attach it to your models and collections:
```html
<script type="text/javascript" src="backbone.js"></script>
<script type="text/javascript" src="backbone.localStorage.js"></script>
```
```javascript
import {Collection, Model} from 'backbone';
import {LocalStorage} from 'backbone.localstorage';
Create your collections like so:
const SomeCollection = Collection.extend({
```javascript
window.SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection"), // Unique name within your app.
// ... everything else is normal.
localStorage: new LocalStorage('SomeCollection'), // Uniquely identify this
});
const SomeModel = Model.extend({
localStorage: new LocalStorage('SomeModel')
});
```
If needed, you can use the default `Backbone.sync` (instead of local storage) by passing the `ajaxSync` option flag to any Backbone AJAX function, for example:
To synchronise with the server, you can pass the `ajaxSync` flag to any options:
```javascript
var myModel = new SomeModel();
myModel.fetch({ ajaxSync: true });
myModel.save({ new: "value" }, { ajaxSync: true });
const myModel = new SomeModel();
myModel.fetch({
ajaxSync: true // Fetches from the server
});
myModel.save({
new: "value"
}, {
ajaxSync: true // Pushes back to the server
});
```
### RequireJS
## Upgrade Notes
Include [RequireJS](http://requirejs.org):
Backbone LocalStorage is now built using ES6. It should be fully compatible with
v1 with one difference: Instead of exporting the `LocalStorage` class as a
default module, v2 exports it as a named variable. Below are examples covering
the changes:
```html
<script type="text/javascript" src="lib/require.js"></script>
```
### JavaScript ES5
RequireJS config:
```javascript
require.config({
paths: {
jquery: "lib/jquery",
underscore: "lib/underscore",
backbone: "lib/backbone",
localstorage: "lib/backbone.localStorage"
}
});
```
In v1:
Define your collection as a module:
```javascript
define("SomeCollection", ["localstorage"], function() {
var SomeCollection = Backbone.Collection.extend({
localStorage: new Backbone.LocalStorage("SomeCollection") // Unique name within your app.
});
return SomeCollection;
});
var LocalStorage = require('backbone.localstorage');
```
Require your collection:
In v2:
```javascript
require(["SomeCollection"], function(SomeCollection) {
// ready to use SomeCollection
});
var localStorage = require('backbone.localstorage');
var LocalStorage = localStorage.LocalStorage;
```
### CommonJS
### JavaScript ES6+
If you're using [browserify](https://github.com/substack/node-browserify).
In v1:
Install using `npm install backbone.localstorage`, and require the module.
```javascript
Backbone.LocalStorage = require("backbone.localstorage");
import LocalStorage from 'backbone.localstorage';
```
##Support
In v2:
If you're having a problem with using the project, get help at CodersClan.
```javascript
import {LocalStorage} from 'backbone.localstorage';
```
<a href="http://codersclan.net/forum/index.php?repo_id=67"><img src="http://www.codersclan.net/graphics/getSupport_blue_big.png" width="160"></a>
## Contributing
You'll need node and to `npm install` before being able to run the minification script.
Install NodeJS and run `yarn` or `npm i` to get your dependencies, then:
1. Fork;
2. Write code, with tests;
3. `make test` or `open spec/runner.html`;
4. Create a pull request.
1. Open an issue identifying the fault
2. Provide a fix, with tests demonstrating the issue
3. Run `npm test`
4. Create a pull request
Have fun!
## Acknowledgments
- [Mark Woodall](https://github.com/llad): Initial tests (now refactored);
- [Martin Häcker](https://github.com/dwt): Many fixes and the test isolation.
- [Mark Woodall](https://github.com/llad): initial tests (now refactored);
- [Martin Häcker](https://github.com/dwt): many fixes and the test isolation.
## License
Licensed under MIT license
Copyright (c) 2010 Jerome Gravel-Niquet
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sorry, the diff of this file is not supported yet

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