Skip to content

Determine if the JS environment has private fields (`class { #x; }`) support.

License

Notifications You must be signed in to change notification settings

inspect-js/has-private-fields

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

has-private-fields Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Determine if the JS environment has private fields (class { #x; }) support.

Example

const assert = require('assert');
const hasPrivateFields = require('has-private-fields');

assert.equal(hasPrivateFields(), true); // if the environment has native class private fields support (node v12+)

const { hasPrivateAccessors, hasPrivateMethods } = hasPrivateFields;

assert.equal(hasPrivateAccessors(), true); // if the environment has native class private accessors support (node v14.6+)
assert.equal(hasPrivateMethods(), true); // if the environment has native class private methods support (node v14.6+)

Tests

Simply clone the repo, npm install, and run npm test