MCPcopy
hub / github.com/jeromegn/Backbone.localStorage

github.com/jeromegn/Backbone.localStorage @2.0.0 sqlite

repository ↗ · DeepWiki ↗ · release 2.0.0 ↗
28 symbols 77 edges 7 files 18 documented · 64%
README

Backbone localStorage Backend

Build Status Coverage Status npm version

An adapter that replaces Backbone.sync to save to window.localStorage instead of to the server.

Note Backbone LocalStorage v2 changes the API to work more with ES6 modules. See Upgrade Notes for more details.

Usage

Import backbone.localstorage and attach it to your models and collections:

import {Collection, Model} from 'backbone';
import {LocalStorage} from 'backbone.localstorage';

const SomeCollection = Collection.extend({

  localStorage: new LocalStorage('SomeCollection'), // Uniquely identify this

});

const SomeModel = Model.extend({

  localStorage: new LocalStorage('SomeModel')

});

To synchronise with the server, you can pass the ajaxSync flag to any options:

const myModel = new SomeModel();
myModel.fetch({
  ajaxSync: true  // Fetches from the server
});

myModel.save({
  new: "value"
}, {
  ajaxSync: true  // Pushes back to the server
});

Upgrade Notes

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:

JavaScript ES5

In v1:

var LocalStorage = require('backbone.localstorage');

In v2:

var localStorage = require('backbone.localstorage');
var LocalStorage = localStorage.LocalStorage;

JavaScript ES6+

In v1:

import LocalStorage from 'backbone.localstorage';

In v2:

import {LocalStorage} from 'backbone.localstorage';

Contributing

Install NodeJS and run yarn or npm i to get your dependencies, then:

  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

Acknowledgments

Core symbols most depended-on inside this repo

save
called by 13
src/localstorage.js
s4
called by 8
src/utils.js
localStorage
called by 5
src/localstorage.js
create
called by 5
src/localstorage.js
_itemName
called by 5
src/localstorage.js
find
called by 3
src/localstorage.js
destroy
called by 3
src/localstorage.js
_getItem
called by 3
src/localstorage.js

Shape

Method 14
Function 12
Class 2

Languages

TypeScript100%

Modules by API surface

src/localstorage.js18 symbols
src/utils.js4 symbols
test/localstorage.test.js3 symbols
src/sync.js2 symbols
src/driver.js1 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

babel-cli6.23.0 · 1×
babel-core6.23.1 · 1×
babel-eslint7.1.1 · 1×
babel-loader6.3.2 · 1×
babel-preset-latest6.22.0 · 1×
backbone1.3.3 · 1×
coveralls2.11.16 · 1×
eslint3.15.0 · 1×
expect.js0.3.1 · 1×
html-webpack-plugin2.28.0 · 1×
istanbul0.4.5 · 1×
istanbul-instrumenter-loader2.0.0 · 1×

For agents

$ claude mcp add Backbone.localStorage \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact