-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add accessible
Object#hasOwnProperty
stage 2 proposal, `Object.hasO…
- Loading branch information
Showing
14 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../modules/esnext.object.has-own'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Object.hasOwn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var hasOwnProperty = {}.hasOwnProperty; | ||
|
||
module.exports = function (it, key) { | ||
module.exports = function hasOwn(it, key) { | ||
return hasOwnProperty.call(it, key); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var $ = require('../internals/export'); | ||
var hasOwn = require('../internals/has'); | ||
|
||
// `Object.hasOwn` method | ||
// https://github.com/tc39/proposal-accessible-object-hasownproperty | ||
$({ target: 'Object', stat: true }, { | ||
hasOwn: hasOwn | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/core-js/proposals/accessible-object-hasownproperty.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// https://github.com/tc39/proposal-accessible-object-hasownproperty | ||
require('../modules/esnext.object.has-own'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import create from 'core-js-pure/features/object/create'; | ||
import hasOwn from 'core-js-pure/features/object/has-own'; | ||
|
||
QUnit.test('Object.hasOwn', assert => { | ||
assert.isFunction(hasOwn); | ||
assert.arity(hasOwn, 2); | ||
assert.name(hasOwn, 'hasOwn'); | ||
assert.deepEqual(hasOwn({ q: 42 }, 'q'), true); | ||
assert.deepEqual(hasOwn({ q: 42 }, 'w'), false); | ||
assert.deepEqual(hasOwn(create({ q: 42 }), 'q'), false); | ||
assert.deepEqual(hasOwn(Object.prototype, 'hasOwnProperty'), true); | ||
assert.throws(() => hasOwn(null, 'foo'), TypeError, 'throws on null'); | ||
assert.throws(() => hasOwn(undefined, 'foo'), TypeError, 'throws on undefined'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
QUnit.test('Object.hasOwn', assert => { | ||
const { create, hasOwn } = Object; | ||
assert.isFunction(hasOwn); | ||
assert.arity(hasOwn, 2); | ||
assert.name(hasOwn, 'hasOwn'); | ||
assert.looksNative(hasOwn); | ||
assert.nonEnumerable(Object, 'hasOwn'); | ||
assert.deepEqual(hasOwn({ q: 42 }, 'q'), true); | ||
assert.deepEqual(hasOwn({ q: 42 }, 'w'), false); | ||
assert.deepEqual(hasOwn(create({ q: 42 }), 'q'), false); | ||
assert.deepEqual(hasOwn(Object.prototype, 'hasOwnProperty'), true); | ||
assert.throws(() => hasOwn(null, 'foo'), TypeError, 'throws on null'); | ||
assert.throws(() => hasOwn(undefined, 'foo'), TypeError, 'throws on undefined'); | ||
}); |