Skip to content

Commit

Permalink
Merge pull request #278 from nolanlawson/nolan/babel-runtime
Browse files Browse the repository at this point in the history
fix: fix babel-runtime not found
  • Loading branch information
nolanlawson committed Mar 9, 2019
2 parents a871cac + 28c05b2 commit 8c80e7d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"babel-runtime/helpers/extends": "./src/polyfills/extends",
"babel-runtime/helpers/inherits": "./src/polyfills/inherits",
"babel-runtime/helpers/createClass": "./src/polyfills/createClass",
"babel-runtime/helpers/possibleConstructorReturn": "./src/polyfills/possibleConstructorReturn"
"babel-runtime/helpers/possibleConstructorReturn": "./src/polyfills/possibleConstructorReturn",
"babel-runtime/helpers/classCallCheck": "./src/polyfills/classCallCheck",
"babel-runtime/core-js/object/keys": "./src/polyfills/keys"
}
}
]
Expand Down
5 changes: 5 additions & 0 deletions src/polyfills/classCallCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function')
}
}
38 changes: 38 additions & 0 deletions src/polyfills/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !{ toString: null }.propertyIsEnumerable('toString'),
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor',
],
dontEnumsLength = dontEnums.length

export default function(obj) {
if (typeof obj !== 'function' && (typeof obj !== 'object' || obj === null)) {
throw new TypeError('Object.keys called on non-object')
}

var result = [],
prop,
i

for (prop in obj) {
if (hasOwnProperty.call(obj, prop)) {
result.push(prop)
}
}

if (hasDontEnumBug) {
for (i = 0; i < dontEnumsLength; i++) {
if (hasOwnProperty.call(obj, dontEnums[i])) {
result.push(dontEnums[i])
}
}
}
return result
}

0 comments on commit 8c80e7d

Please sign in to comment.