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.data

v0.0.0-rc1

Published

simple data storage

Downloads

6

Readme

ng.data: data persistence getter/setter

ng.data aims to make it dead simple to persist data

api

ng.data has a very simple API

ng.data = function(key, value, persist)
{

}

get/set

ng.data is just a getter/setter

module('example').controller('ctrl', function(data)
{
	var val = 'Hello!'

	//Store the value under key
	data('key', val)

	//Get the value: logs Hello!
	console.log(data('key'))

	//Delete the value
	data('key', undefined)
})

persistance

If persist is truthy, data is persisted until deleted. On the client this is done with localStorage, on the server this is done with a JSON object.

If persist is undefined, data is persisted in memory only. On the client this is done with sessionStorage, on the server this is done with memory (until server restart).

If persist is falsey (but not undefined), data is stored as flash data. It will be available on the next location path change and then will be erased (this is great for alert messages)

shorthand

Sometimes getters/setters can be annoying if you only want to manipulate data. ng.data has shorthand for these common manipulations

####incrementing verbose

module('example').controller('ctrl', function(data)
{
  var count = data('count')

  count += 5

  data('count', count)
})

shorthand

module('example').controller('ctrl', function(data)
{
  data('count+', 5)
})

####decrementing verbose

module('example').controller('ctrl', function(data)
{
  var count = data('count')

  count -= 5

  data('count', count)
})

shorthand

module('example').controller('ctrl', function(data)
{
  data('count-', 5)
})

pushing values

verbose

module('example').controller('ctrl', function(data)
{
  var arr = data('arr')

  arr.push('Hello!')

  data('arr', arr)
})

shorthand note: this only works if arr is already an array

module('example').controller('ctrl', function(data)
{
  data('arr[]', 'Hello!')
})

adding properties

verbose

module('example').controller('ctrl', function(data)
{
  var obj = data('obj')

  obj.prop = 'Hello!'

  data('obj', obj)
})

shorthand note: this only works if obj is already an object

module('example').controller('ctrl', function(data)
{
  data('obj.prop', 'Hello!')
})

changelog

0.0.0-rc1

  • Initial commit

todos

  • ???

related projects

  • ng: angular reimagined
  • ng.seed: create a modular ng application using npm packages
  • ng.cql: realtime cassandra database syncing
  • ng.auth: example authentication using ng interceptors
  • ng.crud: example demonstrating a simple crud application using ng.seed
  • ng.style: beautiful html using twitter bootstrap