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

ko-extender-stored

v0.1.0

Published

> [Knockout.js](http://knockoutjs.com) extender that stores observables in the browser's LocalStorage.

Downloads

24

Readme

ko-extender-stored

Knockout.js extender that stores observables in the browser's LocalStorage.

Download

Using Bower (preferred)

This project is available through the Bower package manager. To download the project run

bower install ko-extender-stored

Using GitHub releases

You can also use the GitHub Release-Page to download this project.

Installation

This project requires Knockout to be added before itself.

As you may have seen, the download contains multiple files named ko-extender-stored.js. Refer to Which file to use to get the best out of this project.

Using AMD (preferred)

Just define Knockout.js and ko-extender-stored as dependencies of the modules that use the extender. E.g.:

define(['knockout', 'ko-extender-stored'], function(ko) {
    // ko-extender-stored is available as ko.extenders.stored
})

Using a <script>-Tag

Simply reference the main-file after importing Knockout.js within the HTML head or body:

<script src="path/to/knockout.js"></script>
<script src="path/to/ko-extender-stored.js"></script>

Usage

Just like a regular Knockout extender.

var storedObservable = ko.observable('initial value').extend({stored: 'testVar'});

In this example, storedObservable is stored in LocalStorage as testVar. If LocalStorage already contains an item named testVar, the extender uses the stored value.

Options

The following options can be passed to ko.extenders.stored.options. E.g. (using AMD):

define(['knockout', 'ko-extender-stored'], function(ko) {
  ko.extenders.stored.options.anOption = theValueToSet;
});

Note that options must be set before using the extender.

prefix

In some cases it may be required to prefix the stored item names. In this case set ko.extenders.stored.options.prefix to true (to use the default prefix) or a string containing the prefix you want to use.

Further Info

Which file to use

The download contains multiple versions of the main file:

| Path | Content | Usage | |---------------------------------------|-----------------------|------------------------------------------------------------------------------------------| | out/dist/ko-extender-stored.js | Main production build | Can be used as AMD, CommonJS or browser global module, minified. | | out/dist/amd/ko-extender-stored.js | AMD production build | Can be used as an AMD module, minified. | | out/debug/ko-extender-stored.js | Main debug build | Can be used as AMD, CommonJS or browser global module, prints debug messages to console. | | out/debug/amd/ko-extender-stored.js | AMD debug build | Can be used as an AMD module, prints debug messages to console. | | src/ko-extender-stored.js | ES6 Source module | Useful if you want to generate custom builds. |