@jackens/nnn 2026.2.23 → 2026.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/nnn.d.ts +1 -1
- package/nnn.js +2 -2
- package/package.json +1 -1
- package/readme.md +38 -5
package/nnn.d.ts
CHANGED
|
@@ -145,7 +145,7 @@ export declare const s: {
|
|
|
145
145
|
*
|
|
146
146
|
* `true` if `ref` is not nullish and has `key` as an own property, `false` otherwise.
|
|
147
147
|
*/
|
|
148
|
-
export declare const
|
|
148
|
+
export declare const hasOwn: (ref: unknown, key: unknown) => boolean;
|
|
149
149
|
/**
|
|
150
150
|
* Checks whether the argument is an array.
|
|
151
151
|
*
|
package/nnn.js
CHANGED
|
@@ -162,7 +162,7 @@ var fixPlTypography = (node) => {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
// src/nnn/hasOwn.ts
|
|
165
|
-
var
|
|
165
|
+
var hasOwn = (ref, key) => ref != null && Object.hasOwn(ref, key);
|
|
166
166
|
// src/nnn/isFiniteNumber.ts
|
|
167
167
|
var isFiniteNumber = Number.isFinite;
|
|
168
168
|
// src/nnn/jsOnParse.ts
|
|
@@ -386,7 +386,7 @@ export {
|
|
|
386
386
|
isNumber,
|
|
387
387
|
isFiniteNumber,
|
|
388
388
|
isArray,
|
|
389
|
-
|
|
389
|
+
hasOwn,
|
|
390
390
|
h,
|
|
391
391
|
fixPlTypography,
|
|
392
392
|
escapeValues,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nnn
|
|
2
2
|
|
|
3
|
-
A collection of Jackens’ JavaScript helper utilities (version: `2026.2.
|
|
3
|
+
A collection of Jackens’ JavaScript helper utilities (version: `2026.2.24`).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
escapeValues,
|
|
24
24
|
fixPlTypography,
|
|
25
25
|
h,
|
|
26
|
-
|
|
26
|
+
hasOwn,
|
|
27
27
|
isArray,
|
|
28
28
|
isFiniteNumber,
|
|
29
29
|
isNumber,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
- [`escapeValues`](#escapeValues): Escapes an array of values using the provided escape map.
|
|
58
58
|
- [`fixPlTypography`](#fixPlTypography): Applies Polish-specific typographic corrections to a DOM subtree.
|
|
59
59
|
- [`h`](#h): A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also [`s`](#s)).
|
|
60
|
-
- [`
|
|
60
|
+
- [`hasOwn`](#hasOwn): Checks whether an object has the specified key as its own property.
|
|
61
61
|
- [`isArray`](#isArray): Checks whether the argument is an array.
|
|
62
62
|
- [`isFiniteNumber`](#isFiniteNumber): Checks whether the argument is a finite number (excludes `±Infinity` and `NaN`).
|
|
63
63
|
- [`isNumber`](#isNumber): Checks whether the argument is of type `number` (includes `NaN` and `±Infinity`).
|
|
@@ -522,10 +522,10 @@ h(div, { $key: { two: 2 } })
|
|
|
522
522
|
expect(div.key).to.deep.equal({ one: 1, two: 2 })
|
|
523
523
|
```
|
|
524
524
|
|
|
525
|
-
###
|
|
525
|
+
### hasOwn
|
|
526
526
|
|
|
527
527
|
```ts
|
|
528
|
-
const
|
|
528
|
+
const hasOwn: (ref: unknown, key: unknown) => boolean;
|
|
529
529
|
```
|
|
530
530
|
|
|
531
531
|
Checks whether an object has the specified key as its own property.
|
|
@@ -544,6 +544,39 @@ The property key to look for.
|
|
|
544
544
|
|
|
545
545
|
`true` if `ref` is not nullish and has `key` as an own property, `false` otherwise.
|
|
546
546
|
|
|
547
|
+
#### Usage Examples
|
|
548
|
+
|
|
549
|
+
```ts
|
|
550
|
+
const obj = { 42: null, null: 'k,e,y', 'k,e,y': 42 }
|
|
551
|
+
|
|
552
|
+
expect(42 in obj).to.be.true
|
|
553
|
+
expect(hasOwn(obj, 42)).to.be.true
|
|
554
|
+
|
|
555
|
+
expect('42' in obj).to.be.true
|
|
556
|
+
expect(hasOwn(obj, '42')).to.be.true
|
|
557
|
+
|
|
558
|
+
expect('null' in obj).to.be.true
|
|
559
|
+
expect(hasOwn(obj, 'null')).to.be.true
|
|
560
|
+
|
|
561
|
+
expect(null in obj).to.be.true
|
|
562
|
+
expect(hasOwn(obj, null)).to.be.true
|
|
563
|
+
|
|
564
|
+
expect('k,e,y' in obj).to.be.true
|
|
565
|
+
expect(hasOwn(obj, 'k,e,y')).to.be.true
|
|
566
|
+
|
|
567
|
+
expect(['k', 'e', 'y'] in obj).to.be.true
|
|
568
|
+
expect(hasOwn(obj, ['k', 'e', 'y'])).to.be.true
|
|
569
|
+
|
|
570
|
+
expect('toString' in obj).to.be.true
|
|
571
|
+
expect(hasOwn(obj, 'toString')).to.be.false
|
|
572
|
+
|
|
573
|
+
expect(() => 'key' in null).to.throw
|
|
574
|
+
expect(hasOwn(null, 'key')).to.be.false
|
|
575
|
+
|
|
576
|
+
expect(() => 'key' in undefined).to.throw
|
|
577
|
+
expect(hasOwn(undefined, 'key')).to.be.false
|
|
578
|
+
```
|
|
579
|
+
|
|
547
580
|
### isArray
|
|
548
581
|
|
|
549
582
|
```ts
|