1.2.1 • Published 3 years ago

@darkwolf/primordials v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Primordials

Install

npm i --save @darkwolf/primordials

Usage

// ECMAScript
import * as primordials from '@darkwolf/primordials'
// CommonJS
const primordials = require('@darkwolf/primordials')

const {
  ObjectPrototypeToString,
  ObjectPrototypeToStringTag,
  SymbolIterator,
  ArrayPrototypeSymbolIterator,
  MapPrototypeSymbolIterator,
  SetPrototypeSymbolIterator,
  ArrayIteratorPrototype,
  MapIteratorPrototype,
  SetIteratorPrototype,
  SafeArrayIterator,
  SafeMap,
  SafeSet
} = primordials

ObjectPrototypeToString({}) // => '[object Object]'
ObjectPrototypeToStringTag({}) // => 'Object'

ArrayIteratorPrototype.next = null
const iterator = ArrayPrototypeSymbolIterator([])
iterator.next() // TypeError exception will be thrown
const safeIterator = new SafeArrayIterator([])
safeIterator.next() // => IteratorResult

MapIteratorPrototype.next = null
const mapIterator = MapPrototypeSymbolIterator(new Map())
mapIterator.next() // TypeError exception will be thrown
const safeMapIterator = new SafeMap()[SymbolIterator]()
safeMapIterator.next() // => IteratorResult

SetIteratorPrototype.next = null
const setIterator = SetPrototypeSymbolIterator(new Set())
setIterator.next() // TypeError exception will be thrown
const safeSetIterator = new SafeSet()[SymbolIterator]()
safeSetIterator.next() // => IteratorResult

API Documentation

Contact Me

GitHub: @PavelWolfDark

Telegram: @PavelWolfDark

Email: PavelWolfDark@gmail.com