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

strictly-hash

v0.1.0

Published

A strict Hash implementation allowing key restriction and virtualization

Downloads

8

Readme

strictly-hash

A strict Hash implementation allowing key restriction and virtualization

Build Status NPM Version

Installation

npm:

npm install strictly-hash

bower

bower install strictly-hash

Usage

coffeescript example:

inst = new Hash (
  param_one:"foo"
  param_two:"bar"
), ['param_one', 'param_two']

inst.set 'param_three', 'baz'
# param_three isn't allowed - prints 'undefined'
console.log inst.get 'param_three'
# prints 'foobar'
console.log "#{inst.get 'param_one'}#{inst.get 'param_two'}"

javascript example:

var inst = new Hash({
  param_one:'foo',
  param_two:'bar'
}, ['param_one', 'param_two']);

inst.set( 'param_three', 'baz' );
// param_three isn\'t allowed - prints \"undefined\"
console.log( inst.get( 'param_three' ) );
// prints \"foobar\"
console.log( ""+inst.get( 'param_one')+inst.get( 'param_two' ) );

coffeescript example:

class Instance extends Hash
  constructor:->
  	Instance.__super__.constructor.call @, (
  	  param_one:"foo"
  	  param_two:"bar"
  	), ['param_one', 'param_two']
inst = new Instance
inst.set 'param_three', 'baz'
# param_three isn't allowed - prints 'undefined'
console.log inst.get 'param_three'
# prints 'foobar'
console.log "#{inst.get 'param_one'}#{inst.get 'param_two'}"

javascript example:

(function() {
  var Instance, Hash,
    __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  Instance = (function(_super) {
    __extends(Instance, _super);
    
    function Instance() {
      return Instance.__super__.constructor.apply(this, {
	  	  param_one:"foo",
	  	  param_two:"bar"
      }, ['param_one', 'param_two']);
    }

  })(Hash);

}).call(this);

Constructor

Hash([object, restricted_keys])

Creates new hash instance

Arguments

Object object: (optional) Sets initial contents of Hash

Array restricted_keys: (optional) If present, restricts the hash keys to the provided values

Methods

get(key)

gets key/value from virtualized object

set(key, value)

sets key/value to virtualized object

has(key)

tests for key existance

del(key)

removes key from hash

forEach(iterator, scope)

traverses hash, calling iterator on each node

keys()

returns object keys

valueOf()

returns object

toJSON()

returns object

toString(pretty)

returns returns string representation of hash, if pretty is true will format the string for readability

canFreeze()

returns true if environment supports Object.freeze

freeze()

freezes Hash object if feature supported by environment

isFrozen()

returns true if Hash is frozen

canSeal()

returns true if environment supports Object.seal

seal()

seals Hash object if feature supported by environment

isSealed()

returns true if Hash is sealed

canPreventExtensions()

returns true if environment supports Object.canPreventExtensions

isExtensible()

returns false if Hash is not Extensible

preventExtensions()

prevent Extensability for Hash object if feature supported by environment