New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

own-keys

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

own-keys - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

7

CHANGELOG.md

@@ -8,2 +8,9 @@ # Changelog

## [v1.0.1](https://github.com/ljharb/own-keys/compare/v1.0.0...v1.0.1) - 2024-12-29
### Commits
- [Tests] sort with a proper comparator [`4a65b56`](https://github.com/ljharb/own-keys/commit/4a65b569d10985032a0773806dcdec8866132baa)
- [Fix] fix function name when `Reflect.ownKeys` is absent [`5cf17cb`](https://github.com/ljharb/own-keys/commit/5cf17cb1c9adfa836a1ddc467da4da20973db2ae)
## v1.0.0 - 2024-12-28

@@ -10,0 +17,0 @@

8

index.js

@@ -14,9 +14,9 @@ 'use strict';

/** @type {import('.')} */
module.exports = $ownKeys || function OwnPropertyKeys(source) {
module.exports = $ownKeys || function ownKeys(source) {
/** @type {(keyof typeof source)[]} */
var ownKeys = ($gOPN || keys)(source);
var sourceKeys = ($gOPN || keys)(source);
if ($gOPS) {
safePushApply(ownKeys, $gOPS(source));
safePushApply(sourceKeys, $gOPS(source));
}
return ownKeys;
return sourceKeys;
};
{
"name": "own-keys",
"version": "1.0.0",
"version": "1.0.1",
"description": "Robustly get an object's own property keys (strings and symbols), including non-enumerables when possible",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,2 +9,13 @@ 'use strict';

/** @type {(a: PropertyKey, b: PropertyKey) => number} */
function comparator(a, b) {
if (typeof a === 'string' && typeof b === 'string') {
return a.localeCompare(b);
}
if (typeof a === 'number' && typeof b === 'number') {
return a - b;
}
return typeof a === 'symbol' ? 1 : -1;
}
test('ownKeys', function (t) {

@@ -30,4 +41,4 @@ t.equal(typeof ownKeys, 'function', 'is a function');

st.deepEqual(
ownKeys(obj).sort(),
(hasPropertyDescriptors ? ['a', 'b', 'c'] : ['a', 'b']).sort(),
ownKeys(obj).sort(comparator),
(hasPropertyDescriptors ? ['a', 'b', 'c'] : ['a', 'b']).sort(comparator),
'includes non-enumerable properties'

@@ -54,4 +65,4 @@ );

st.deepEqual(
ownKeys(obj).sort(),
['a', sym, nonEnumSym].sort(),
ownKeys(obj).sort(comparator),
['a', sym, nonEnumSym].sort(comparator),
'works with symbols, both enum and non-enum'

@@ -58,0 +69,0 @@ );

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc