weakmap-shim

WebJar for weakmap-shim

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

weakmap-shim
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

weakmap-shim
WebJar for weakmap-shim
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Raynos/weakmap-shim

Download weakmap-shim

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/weakmap-shim/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>weakmap-shim</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/weakmap-shim/
implementation 'org.webjars.npm:weakmap-shim:1.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/weakmap-shim/
implementation ("org.webjars.npm:weakmap-shim:1.1.1")
'org.webjars.npm:weakmap-shim:jar:1.1.1'
<dependency org="org.webjars.npm" name="weakmap-shim" rev="1.1.1">
  <artifact name="weakmap-shim" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='weakmap-shim', version='1.1.1')
)
libraryDependencies += "org.webjars.npm" % "weakmap-shim" % "1.1.1"
[org.webjars.npm/weakmap-shim "1.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

weakmap-shim

A minimal weakmap shim

Example

var weakMap = require("weakmap-shim")

var map = weakMap()
var key = {}

map.set(key, 'some value')
var v = map.get(key) // 'some value'

create-store Example

var createStore = require('weakmap-shim/create-store')

var store = createStore()
var key = {}

var value = store(key)

// `value` is weakly bound to `key`. `value` is a plain object
value.foo = 'bar'

var value2 = store(key)

var v = value2.foo; // 'bar'
var bool = value === value2; // true

Motivation

Benvie has an excellent weakmap module that's far more robust. However it contains quite a bit of loc.

  • weakmap : 7451 bytes
  • weakmap-shim : 2106 bytes
  • weakmap-shim/create-store : 1311 bytes

This module is only worthwhile if you want to add a weakmap to a small module (10 - 30 loc) and dont want to bloat it with a heavier weakmap

Installation

npm install weakmap-shim

Contributors

  • Raynos

MIT Licenced

Versions

Version
1.1.1
1.0.0