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

entropy-lang

v0.0.3

Published

entropy-lang ===

Downloads

2

Readme

entropy-lang

build status

An implementation of the Entropy Programming language in javascript created with decorators.

npm install entropy-lang

Usage

The entropy-lang package provides a few functions that can be used as decorators to create the randomness of the entropy programming language.

import {number} from 'entropy-lang';
class Test{
  @number
  foo() {
    return 5;
  }
}
var t = new Test();
// every time foo is called the returned value is modified
t.foo(); // 5.3325573585461825
t.foo(); // 4.976981917163357
t.foo(); // 4.678662626305595
// it is possible to set the value of foo
t.foo(10);
// but it will not stay that way for long
t.foo(); // 9.747475580545142
t.foo(); // 10.13371781539172
t.foo(); // 10.43714217748493

99 Bottles of Beer

Implementing the song 99 bottles of beer shows how quickly the entropy is able to take over in a few steps.

# first few iterations
98.40 bottles of bfer on the wall, 98.40 bpttles of beer.
Takeone down, pbss it around,
98.17 bottles of bfer on the wall, 98.17 bpttlds of beer.
Takeone down, pbssit around,
96.59 bottles of bger on the wall, 96.59 cpttlds of bfer.
Takeond down, pbssit around-
# last few iterations
2.38aotypdr"le"bferml"sfbv`nq,2.38 ^ptnngw mg`cco.
S_mionf"fouk*"pbrokrctpslf+!
1.58aotypdr"le"bferml"sfbv`nq,1.58 ^ptnngw mgadco.
S_lionf"fouk*"pbrokrctpslf+
0.89aotzqdr"le"bferml"sfbv_nq,0.89 ^ptnngw mgadco.
S_lionf!fouk*"pbrokrctpslf+
-0.18aotzqdr"le"bferml"sfbv_nq,-0.18 ^ptnngw mgadco/
S_lionf!fouk*"pbrokrdtpslf+
// example/beer.js
import {number, str} from 'entropy-lang';

class WallOBeers {

  @number
  beers() {
    return 99;
  }

  @str
  verse1() {
    return ' bottles of beer on the wall, ';
  }

  @str
  verse2() {
    return ' bottles of beer.\nTake one down, pass it around, ';
  }

  takeOneDown() {
    var current = this.beers();
    current -= 1;
    this.beers(current);
    return current;
  }

  sing() {
    var beers = this.beers().toFixed(2);
    var v1 = this.verse1();
    var v2 = this.verse2();
    return beers + v1 + beers + v2;
  }

  commenceDrinking() {
    while(this.beers() > 0) {
      wall.takeOneDown();
      console.log(wall.sing());
    }
  }

}

API

Example use:

import {number, char, string, any} from 'entropy-lang';

class Foo {
  @number
  a() {
    return 5;
  }

  @char
  b() {
    return 'b';
  }

  @str
  c() {
    return 'randomness';
  }

  @any(_date)
  d() {
    return new Date();
  }
}

function _date(current_value) {
  let time = current_value.getTime();
  time = Math.floor(time + (Math.random() - 0.5))
  return new Date(time);
}
number

Modifies number types based on (Math.random() - 0.5).

char

Modifies the first character in a string by changing its character code.

str

Modifies each character in a string with a 10% change with the same logic as char.

any(modifier)

Modifies arbitrary data based on the given modifier(current_value). The modifier takes on argument, which is the current value of the variable, and must return the next value of the variable.

License

MIT