Skip to content
Wrap a primitive value in a reference pointer, and pass by reference!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
doc
lib
test
.babelrc
.editorconfig
.flowconfig
.gitignore
.npmignore
LICENSE
README.md
package-lock.json
package.json
rollup.config.js
shell.nix

README.md

Reference Pointer

This library simply wraps a primitive value (number, string) into an object, so instead of passing a value around, you pass the object around. This allows you do pass-by-reference. This is basically JavaScript's equivalent of a pointer.

Basic Usage

npm install --save 'reference-pointer';
import Reference from 'reference-pointer';

const changed = new Reference(false);

function changeBool (changed) {
  changed.set(true);
}

changeBool(changed);

console.log(changed.get()); // true

Development

To build this package for release:

npm run build

It will run tests, generate documentation and output multiple targets. One for browsers and one for nodejs. See rollup.config.js to see the target specification.

If your bundler is aware of the module field in package.json, you'll get the ES6 module directly.

Once you've updated the package run this:

npm version <update_type>
npm publish
You can’t perform that action at this time.