emoji-mart-lazyload/src/polyfills/inherits.js

25 lines
627 B
JavaScript
Raw Normal View History

2017-09-17 08:54:22 +00:00
const _Object = Object
2017-09-24 00:06:29 +00:00
export default function inherits(subClass, superClass) {
2017-10-07 04:02:02 +00:00
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError(
'Super expression must either be null or a function, not ' +
2018-03-27 18:51:26 +00:00
typeof superClass,
2017-10-07 04:02:02 +00:00
)
2017-09-17 08:54:22 +00:00
}
subClass.prototype = _Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
2017-10-07 04:02:02 +00:00
configurable: true,
},
})
2017-09-17 08:54:22 +00:00
if (superClass) {
2017-10-07 04:02:02 +00:00
_Object.setPrototypeOf
? _Object.setPrototypeOf(subClass, superClass)
: (subClass.__proto__ = superClass)
2017-09-17 08:54:22 +00:00
}
2017-10-07 04:02:02 +00:00
}