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

cytoplasm

v3.3.1

Published

a javascript [membrane](https://tvcutsem.github.io/membranes) implementation. This implementation is intended to provide *secure* isolation between any number of membrane spaces. This implementation intends to support all types of objects including functi

Downloads

38

Readme

🦠 cytoplasm 🔬

a javascript membrane implementation. This implementation is intended to provide secure isolation between any number of membrane spaces. This implementation intends to support all types of objects including functions, classes, etc. By default, all membrane spaces have a "transparent distortion", meaning all operations are forwarded to the original graph. In order for this membrane to be useful you will need to provide a distortion implementation.

status: has not been audited, here be dragons, etc

features

intent of secure isolation

(note: this module has not been audited for security) membrane-wrapped objects should always invoke the relevant distortion

multiple membrane spaces

the membrane will wrap/unwrap objects when passed across membrane space boundaries. If an object is created in space A, passed to space B, then to space C, and returned to space A, it will be given to space A unwrapped as a raw object.

support for any object type

the membrane is intended to support any type of javascript object (TypedArray instances, objects with prototype chains, Proxy instances). empty values (null, undefined) and non-object values (number, string) are passed through un-wrapped. Primordials (Object, Object.prototype, etc) are also passed through unwrapped.

set distortions per-object

distortions are hooks into interactions with objects across MembraneSpace boundaries. The distortions are set at the object's origin MebraneSpace. The distortions are applied when the object is referenced in another MembraneSpace. The distortions are not applied in the origin MembraneSpace, as the object is a raw (unwrapped) reference there. The distortions will not be applied in MembraneSpaces that specify the option { dangerouslyAlwaysUnwrap: true }.

distortions can be set in two ways:

  • via the default handler for the MembraneSpace via the createHandler option.
  • overridden for a specific reference via the membraneSpace.handlerForRef WeakMap.

Using these two approaches allows you to have a different distortion for a subset of the MembraneSpace's objects.

example

const { Membrane } = require('cytoplasm')
const createReadOnlyDistortion = require('cytoplasm/src/distortions/readOnly')

const membrane = new Membrane()
const graphA = membrane.makeMembraneSpace({ label: 'a', createHandler: createReadOnlyDistortion })
const graphB = membrane.makeMembraneSpace({ label: 'b' })

const objA = {
  value: 123,
  set: function (newVal) { this.value = newVal },
}
const objAWrappedForB = membrane.bridge(objA, graphA, graphB)

// original object is still mutable
objA.value = 456
// the specified readOnlyDistortion allows the wrapped object to internally mutate itself
// so the value is updated
objAWrappedForB.set(13)
// this assignment fails and throws an error under strict mode
objAWrappedForB.value = 42

class instance origin space

The origin space of an instance of a class with cross-space protoype chain is somewhat complicated, due to differences in class constructors vs function constructors, as well as the Builtins. The instance ends up being claimed by the first constructor it is exposed to. Since class constructors cant access this until they've called super(...), ownership is pushed further down the chain. The function constructors can access this immediately and will claim the instance. Builtins skip membrane wrapping and so do not trigger a claim on this.

examples:

inst
class A
class B
class C <-- origin space
Object
inst
class A
function B <-- origin space
function C
Object

comparison to other implementations

repo | n-sides | audit ---|---|--- cytoplasm | ✓ | x es-membrane | ✓ | x @caridy/sjs | x | x observable-membrane | x | x fast-membrane | x | x membrane-traits | x | x