Socket
Book a DemoInstallSign in
Socket

known

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

known

Allow only access to known object properties using ES2015 Proxy

latest
Source
npmnpm
Version
4.0.0
Version published
Maintainers
1
Created
Source

known

Allow only access to known object properties using ES2015 Proxy

Install

$ npm install known

Usage

import known from 'known';

const object = {foo: true};

console.log(object.bar);
//=> undefined

const object2 = known(object);

// Throws a TypeError when you try to access an unknown property
console.log(object2.bar);
//=> [TypeError] Unknown property: bar

Note that known transparently wraps the given object, meaning prototype properties will also exist. So known(someObject).__proto__ does not throw. If you want non-own properties to throw, ensure your object is created with Object.create(null).

  • on-change - Watch an object or array for changes (Uses Proxy too)
  • negative-array - Negative array index support (Uses Proxy too)

Keywords

object

FAQs

Package last updated on 10 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts