npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-offline-model

v1.0.2

Published

NGOfflineModel: Your Module for Offline operations with AngularJS

Downloads

3

Readme

ngOfflineModel

Your module for Offline operations with AngularJS

Build Status Coverage Status Code Climate

Installation

1 - Via NPM

$ npm install ng-offline-model

2 - Via bower

$ bower install ng-offline-model

3 - Clone this repository and access the generated folder

$ git clone git://github.com/willmendesneto/ngOfflineModel.git [project-name]
$ cd [project-name]

Once you have ngOfflineModel in your project, just include 'keepr.ngOfflineModel' as a dependency in your Angular application and you’re good to go. It's works!

    angular.module('myModule', ['keepr.ngOfflineModel'])

Methods and attributes

attributes

  • primaryKey: Primary Key that will be used for ngOfflineModel. This value will be unique;
  • fields: Fields for mapp in ngOfflineModel. Only these chosen fields will be stored for the service;
  • key: Key used for store locally (localStorage and sessionStorage are stored key value based);
  • secret: Secret key for store;

Methods

  • init: service contructor;
  • createValueObject: Create the ValueObject of item for add/edit/list, based in fields attribute;
  • setStorageType: set/update storageType (localStorage/sessionStorage);
  • setKey: Set the storageType key for store in browser, based in key => value;
  • getKey: Return the key used in this moment for ngOfflineModel instance;
  • setListItems: Add default/first list items for store in storageType selected;
  • getListItems: Return list items stored locally in browser;
  • setFields: Set fields that ngOfflineModel will be map for store;
  • countTotalItems: Return the count of totalItems, based in Primary Key;
  • create: Create new item in list items stored locally;
  • update: Update item stored locally in list items;
  • delete: Remove item stored locally;
  • clearAll: Clear all items stored locally, based in storageType;

Example

var contactMock = [
  {_id: 1, name: 'Allan Benjamin', address: 'St. Claire Avenue, Nº 101', phone: '557188339933'},
  {_id: 2, name: 'Georgia Smith', address: 'St. Claire Avenue, Nº 102', phone: '557188339933'},
  {_id: 3, name: 'Gregory Levinsky', address: 'St. Claire Avenue, Nº 103', phone: '557188339933'},
  {_id: 4, name: 'Jackeline Macfly', address: 'St. Claire Avenue, Nº 104', phone: '557188339933'},
  {_id: 5, name: 'Joseph Climber', address: 'St. Claire Avenue, Nº 105', phone: '557188339933'},
  {_id: 6, name: 'Joshua Jackson', address: 'St. Claire Avenue, Nº 106', phone: '557188339933'}
];

var params = {
  // localStorage/sessionStorage key
  key: 'contactMock',
  // primary field. This field will be increased automatically
  primaryKey: '_id',
  // Fields mapped for store
  fields: ['_id', 'name', 'address', 'phone'],
  // you can add new methods via params too
  myMethod: function() {
    console.log('My method is working!');
  }
};

var ContactModel = ngOfflineModel.setStorageType('localStorage')
                                  .init(contactMock, params);

// return contactMock value;
ContactModel.getListItems();
// return 'contactMock';
ContactModel.getKey();
// === contactMock.length;
ContactModel.countTotalItems(contactMock);


// Create an item
var contact = {
  name: 'This is a test',
  address: 'Adress test',
  phone: '557188998877'
};
ContactModel.create(contact);

// Update the item
contact = {
  phone: '559554138698',
  // This field is verified based in `primaryKey` attribute value
  _id: 7
};

ContactModel.update(contact);

// Removing the item
ContactModel.delete(7);

// Removing all items of storage
ContactModel.clearAll();

Author

Wilson Mendes (willmendesneto)

New features comming soon.