@inglorious/utils 3.2.0 → 3.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/utils",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A set of general-purpose utility functions designed with functional programming principles in mind.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -4,7 +4,6 @@
4
4
  * @typedef {import('./types').Vector3} Vector3
5
5
  */
6
6
 
7
- import { isArray } from "../data-structures/array.js"
8
7
  import { v } from "../v.js"
9
8
  import {
10
9
  abs as nAbs,
@@ -128,17 +127,13 @@ export function fromAngle(angle) {
128
127
 
129
128
  /**
130
129
  * Checks if a value is a vector.
131
- * A vector is an array of numbers. For performance, vectors created with `v()`
132
- * are tagged and can be identified more quickly.
130
+ * This is determined by checking for the `__isVector__` property, which is
131
+ * added by the `v()` factory function for efficient type checking.
133
132
  * @param {*} value - The value to check.
134
133
  * @returns {boolean} True if the value is a vector, false otherwise.
135
134
  */
136
135
  export function isVector(value) {
137
- return (
138
- value?.__isVector__ ||
139
- (isArray(value) &&
140
- value.every((coordinate) => typeof coordinate === "number"))
141
- )
136
+ return !!value?.__isVector__
142
137
  }
143
138
 
144
139
  /**
@@ -126,8 +126,7 @@ test("it should compute the magnitude of a vector (aka length)", () => {
126
126
  })
127
127
 
128
128
  test("it should check if a value is a vector", () => {
129
- expect(isVector([1, 2, 3])).toBe(true)
130
- expect(isVector([])).toBe(true)
129
+ expect(isVector([1, 2, 3])).toBe(false)
131
130
  expect(isVector(v(1, 2, 3))).toBe(true)
132
131
  })
133
132