Skip to content

WebReflection/safer-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

safer-class

Social Media Photo by freestocks.org on Unsplash

Build Status Coverage Status WebReflection status

Flattened classes with non configurable fields (basically safer-object applied to classes and prototypes).

import saferClass from 'safer-class';

const MyPromise = saferClass(class extends Promise {});

// even if inherited methods change
Promise.prototype.then = function () {
  throw new Error('Muahahahahaha!');
};

// instances from MyPromise will work like a charm
MyPromise.resolve('whatever').then(() => console.log('all good'));

Remember to eventually freeze the instance if you want extra safety.

About

Flattened classes with non configurable fields.

Resources

License

Stars

Watchers

Forks

Packages

No packages published