Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ts-emplace

LinusU230MIT2.0.1TypeScript support: included

This package includes the core-js polyfill for Map#emplace and WeakMap#emplace, along with TypeScript typings.

emplace, Map, polyfill, upsert, WeakMap

readme

Map#emplace & WeakMap#emplace polyfill for TypeScript

This package includes the core-js polyfill for Map#emplace and WeakMap#emplace, along with TypeScript typings.

The emplace function is defined in this TC39 proposal.

Installation

npm install --save ts-emplace

Usage

import 'ts-emplace'

const map = new Map<string, number>()

map.emplace('foo', {
  insert (key, map) {
    return 0
  },
  update (existing, key, map) {
    return existing + 1
  }
})

API

The API specification is available in the TC39 proposal.