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

game-of-life-es6

v0.2.4

Published

Conway's Game of life - ES6 JavaScript algorithm implementation

Downloads

14

Readme

Conway's Game of life Build Status npm version

ES6 JavaScript algorithm implementation.

Installation

You can install Game of life using npm:

npm install -g game-of-life-es6

Usage

Node

var GameOfLife = require('game-of-life-es6'),
  world = new GameOfLife.World(1, 1);

Browser

<script src="dist/bundle.js"></script>
<script>
  var world = new GameOfLife.World(1, 1);
</script>

API

Please check API Documentation for more details.

Rules

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  • Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by overcrowding.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

Good coding pratices

According to Kent Back four rules for a simple system are in order (most important first):

  1. Run all the tests
  2. Contain no duplicate code
  3. Express all the ideas the author wants to express
  4. Minimize classes and methods

SOLID principles:

  1. Single Responsibility (SRP): A class (component) should have one, and only one, reason to change.
  2. Open-Closed (OCP): A system should be open for extension, but closed for modification.
  3. Liskov Substitution (LSP): Derived types should be substitutable for their base types.
  4. Interface Segregation (ISP): Abstractions should not depend upon details. Details should depend upon abstractions.
  5. Dependency Inversion (DIP): Interfaces should be small, focused on a specific use case.

The DRY (Don't Repeat Yourself) Principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

Contributing

Requirements

  • Node 0.12.x or io.js 1.x
  • grunt-cli: run npm install -g grunt-cli if needed.
  • Windows only: remember to set Git and Node path in environment variable %PATH%.

Grunt tasks

  • grunt dependencies - helps to update package.json file
  • grunt spec - lints the code and runs unit tests
  • grunt build - lints the code, runs unit tests, creates dist/bundle.js transformed ES5 code
  • grunt - runs grunt build

Useful Links

General

Design

ES6

Grunt tasks