@jackens/nnn 2025.2.1 → 2025.2.2

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.
Files changed (4) hide show
  1. package/nnn.d.ts +1 -1
  2. package/nnn.js +3 -3
  3. package/package.json +1 -1
  4. package/readme.md +23 -24
package/nnn.d.ts CHANGED
@@ -103,7 +103,7 @@ export declare const svgUse: (id: string, ...args: Partial<Array<HArgs1>>) => SV
103
103
  /**
104
104
  * A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
105
105
  */
106
- export declare const has: (key: unknown, ref: unknown) => boolean;
106
+ export declare const hasOwn: (ref: unknown, key: unknown) => boolean;
107
107
  /**
108
108
  * A helper that checks if the given argument is of a certain type.
109
109
  */
package/nnn.js CHANGED
@@ -166,8 +166,8 @@ var fixTypography = (node) => {
166
166
  }
167
167
  }
168
168
  };
169
- // src/nnn/has.ts
170
- var has = (key, ref) => ref != null && Object.hasOwnProperty.call(ref, key);
169
+ // src/nnn/hasOwn.ts
170
+ var hasOwn = (ref, key) => ref != null && Object.hasOwn(ref, key);
171
171
  // src/nnn/jsOnParse.ts
172
172
  var jsOnParse = (handlers, text) => JSON.parse(text, (key, value) => {
173
173
  if (is(Object, value)) {
@@ -272,7 +272,7 @@ export {
272
272
  locale,
273
273
  jsOnParse,
274
274
  is,
275
- has,
275
+ hasOwn,
276
276
  h,
277
277
  fixTypography,
278
278
  escapeValues,
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "name": "@jackens/nnn",
37
37
  "type": "module",
38
38
  "types": "nnn.d.ts",
39
- "version": "2025.2.1"
39
+ "version": "2025.2.2"
40
40
  }
package/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Jackens’ JavaScript helpers.
4
4
 
5
- <sub>Version: <code class="version">2025.2.1</code></sub>
5
+ <sub>Version: <code class="version">2025.2.2</code></sub>
6
6
 
7
7
  * [Documentation](https://jackens.github.io/nnn/doc/)
8
8
  * [Tests](https://jackens.github.io/nnn/test/)
@@ -37,7 +37,7 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
37
37
  or
38
38
 
39
39
  ```js
40
- import { «something» } from 'https://unpkg.com/@jackens/nnn@2025.2.1/nnn.js'
40
+ import { «something» } from 'https://unpkg.com/@jackens/nnn@2025.2.2/nnn.js'
41
41
  ```
42
42
 
43
43
  ## Exports
@@ -53,7 +53,7 @@ import { «something» } from 'https://unpkg.com/@jackens/nnn@2025.2.1/nnn.js'
53
53
  - `escapeValues`: A generic helper for escaping `values` by given `escapeMap`.
54
54
  - `fixTypography`: A helper that implements typographic corrections specific to Polish typography.
55
55
  - `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
56
- - `has`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
56
+ - `hasOwn`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
57
57
  - `is`: A helper that checks if the given argument is of a certain type.
58
58
  - `jsOnParse`: `JSON.parse` with “JavaScript turned on”.
59
59
  - `locale`: Language translations helper.
@@ -525,10 +525,10 @@ h(div, { $key: { two: 2 } })
525
525
  expect(div.key).to.deep.equal({ one: 1, two: 2 })
526
526
  ```
527
527
 
528
- ### has
528
+ ### hasOwn
529
529
 
530
530
  ```ts
531
- const has: (key: unknown, ref: unknown) => boolean;
531
+ const hasOwn: (ref: unknown, key: unknown) => boolean;
532
532
  ```
533
533
 
534
534
  A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
@@ -536,35 +536,34 @@ A replacement for the `in` operator (not to be confused with the `for-in` loop)
536
536
  #### Usage Examples
537
537
 
538
538
  ```js
539
- const obj = { 'k,e,y': 42, null: 42 }
539
+ const obj = { 42: null, null: 'k,e,y', 'k,e,y': 42 }
540
540
 
541
- expect('k,e,y' in obj).to.be.true
542
- expect(has('k,e,y', obj)).to.be.true
541
+ expect(42 in obj).to.be.true
542
+ expect(hasOwn(obj, 42)).to.be.true
543
543
 
544
- expect(['k', 'e', 'y'] in obj).to.be.true
545
- expect(has(['k', 'e', 'y'], obj)).to.be.true
544
+ expect('42' in obj).to.be.true
545
+ expect(hasOwn(obj, '42')).to.be.true
546
546
 
547
547
  expect('null' in obj).to.be.true
548
- expect(has('null', obj)).to.be.true
548
+ expect(hasOwn(obj, 'null')).to.be.true
549
549
 
550
550
  expect(null in obj).to.be.true
551
- expect(has(null, obj)).to.be.true
551
+ expect(hasOwn(obj, null)).to.be.true
552
552
 
553
- expect('toString' in obj).to.be.true
554
- expect(has('toString', obj)).to.be.false
555
- ```
553
+ expect('k,e,y' in obj).to.be.true
554
+ expect(hasOwn(obj, 'k,e,y')).to.be.true
556
555
 
557
- ```js
558
- let typeError
556
+ expect(['k', 'e', 'y'] in obj).to.be.true
557
+ expect(hasOwn(obj, ['k', 'e', 'y'])).to.be.true
559
558
 
560
- try {
561
- 'key' in null
562
- } catch (error) {
563
- typeError = error
564
- }
559
+ expect('toString' in obj).to.be.true
560
+ expect(hasOwn(obj, 'toString')).to.be.false
561
+
562
+ expect(() => 'key' in null).to.throw
563
+ expect(hasOwn(null, 'key')).to.be.false
565
564
 
566
- expect(typeError instanceof TypeError) // Cannot use 'in' operator to search for 'key' in null
567
- expect(has('key', null)).to.be.false
565
+ expect(() => 'key' in undefined).to.throw
566
+ expect(hasOwn(undefined, 'key')).to.be.false
568
567
  ```
569
568
 
570
569
  ### is