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

@gwenmohr/sensor-tiles

v1.0.6

Published

Algorithms for a geographical data visualization project that maps and interpolates sensor data onto a 2d tile matrix.

Downloads

5

Readme

sensor-tiles

npm version

Algorithms for our geographical data visualization project that maps and interpolates sensor data onto a 2D tile matrix.

Written in Purescript, targeting Javascript.

How to call from javascript

Installing with npm

Install the package as a dependency with npm

npm install --save-dev @gwenmohr/sensor-tiles

Now you have the choice between two ways of calling the library.

A: JS wrapper (Recommended)

To allow for idiomatic multi-parameter calls from javascript to our purescript code, we've written a javascript wrapper. It will also deep freeze all returned objects, making them completely immutable.

var Tiles = require ('@gwenmohr/sensor-tiles');

// ...

let w = 4;
let h = 6;

let tile_matrix = Tiles.init(w,h); // frozen

let sensor_x = 2;
let sensor_y = 3;
let sensor_value = 2.5

let with_sensor = Tiles.insertSensor(sensor_x, sensor_y, sensor_value, tile_matrix); // frozen

console.log(with_sensor);

B: Direct calls (Not recommended)

The compiled purescript code can also be called directly. Some precautions have to be taken to prevent possible errors in that case.

Immutability

You should treat all objects returned by the Tiles module as immutable if you plan to eventually pass them back to another function exposed by the module.

Immutability on the javascript side can be achieved by using the shallow freeze Object.freeze() or an appropriate deep freeze function. Read more about freezing objects and how to spin up a deep freeze function in the MDN web docs.

If you don't freeze the objects and mutate them manually, you risk breaking them.

Curried

By default, the exposed purescript functions are compiled to curried javascript functions, i.e. function parameters have to be applied one by one.

var Tiles = require ('@gwenmohr/sensor-tiles');
// curried functions are available under the PS (purescript) object
var TilesPS = Tiles.PS;

// ...

let w = 4;
let h = 6;

let tile_matrix = TilesPS.init(w)(h);
Object.freeze(tile_matrix)

let sensor_x = 2;
let sensor_y = 3;
let sensor_value = 2.5

let with_sensor = TilesPS.insertSensor(sensor_x)(sensor_y)(sensor_value)(tile_matrix);
Object.freeze(tile_matrix)

console.log(with_sensor);

Developers: How to build

# using your globally installed `spago` and `purs`
spago build

# using the recommended version of `spago` and `purs` from the npm dependencies
# run once
npm install
# run each build, (up to 50% faster than npm install)
npm run-script install