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 🙏

© 2025 – Pkg Stats / Ryan Hefner

etter

v0.2.1

Published

Simpler getters and setters.

Readme

etter - Simpler getter/setters

Writing getters and setters in JavaScript is pretty verbose and boilerplate-y. etter is a small module for Node.js to make things simpler and nicer. Works nicely with plain JavaScript as well as CoffeeScript and LiveScript.

Installation

etter can be installed via npm:

$ npm install etter

Examples

JavaScript

var etter = require('etter');

function Test() {
  // bind etter to our current object as 'define'
  // this binding is required to make etter work, so don't forget it
  var define = etter.bind(this);

  // the actual values behind the getters and setters
  var _startTime = 0;
  var _endTime = 0;

  // this value will be recalculated whenever the two times are adjusted
  this.duration = 0;

  // this is needed in the update function below
  var self = this;

  // the update function
  var update = function(arg) {
    self.duration = self.endTime - self.startTime;
    return arg; 
  };

  // define startTime and endTime with getter/setters
  define('startTime', {
    get: function() { return _startTime; },
    set: function(num) { _startTime = num; return update(num); }
  });

  define('endTime', {
    get: function() { return _endTime; },
    set: function(num) { _endTime = num; return update(num); }
  });
}

var test = new Test();
test.startTime = 500;
test.endTime = 1500;
test.duration; // => 1000

CoffeeScript

etter = require 'etter'

class Test
  constructor: ->
    
    # bind etter to our current object as 'define'
    # this binding is required to make etter work, so don't forget it
    define = etter.bind @

    # the actual values behind the getters and setters
    _startTime = 0
    _endTime = 0

    # this value will be recalculated whenever the two times are adjusted
    @duration = 0

    # the update function
    update = (arg) =>
      @duration = @endTime - @startTime
      arg

    # define startTime and endTime with getter/setters
    define 'startTime', {
      get: -> _startTime
      set: (num) -> _startTime = num; update num
    }

    define 'endTime', {
      get: -> _endTime
      set: (num) -> _endTime = num; update num
    }

test = new Test()
test.startTime = 500
test.endTime = 1500
test.duration # => 1000

LiveScript

require! \etter

class Test
  ->

    # bind etter to our current object as 'define'
    # this binding is required to make etter work, so don't forget it
    define = etter.bind @

    # the actual values behind the getters and setters
    _start-time = 0
    _end-time = 0

    # this value will be recalculated whenever the two times are adjusted
    @duration = 0

    # the update function
    update = ~>
      @duration = @end-time - @start-time
      it

    # define start-time and end-time with getter/setters
    define \start-time,
      get: -> _start-time
      set: -> _start-time := it; update it

    define \end-time,
      get: -> _end-time
      set: -> _end-time := it; update it

test = new Test!
test.start-time = 500
test.end-time = 1500
test.duration # => 1000