@thi.ng/boids 1.0.33 → 1.0.34

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-05-08T18:24:31Z
3
+ - **Last updated**: 2024-06-21T19:34:38Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [1.0.34](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.0.34) (2024-06-21)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - dedupe wrap2/3() internals ([6ca4b99](https://github.com/thi-ng/umbrella/commit/6ca4b99))
17
+
12
18
  ### [1.0.30](https://github.com/thi-ng/umbrella/tree/@thi.ng/boids@1.0.30) (2024-04-20)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 192 standalone projects, maintained as part
10
+ > This is one of 193 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -111,7 +111,7 @@ For Node.js REPL:
111
111
  const boids = await import("@thi.ng/boids");
112
112
  ```
113
113
 
114
- Package sizes (brotli'd, pre-treeshake): ESM: 1.92 KB
114
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.91 KB
115
115
 
116
116
  ## Dependencies
117
117
 
package/constrain.js CHANGED
@@ -2,36 +2,20 @@ import { wrapOnce } from "@thi.ng/math/interval";
2
2
  import { clamp2 as $clamp2, clamp3 as $clamp3 } from "@thi.ng/vectors/clamp";
3
3
  const clamp2 = (min, max) => (p) => $clamp2(p, p, min, max);
4
4
  const clamp3 = (min, max) => (p) => $clamp3(p, p, min, max);
5
- const wrap2 = (min, max) => (p, boid) => {
6
- const [x, y] = p;
7
- let wrap = false;
8
- if (x < min[0] || x > max[0]) {
9
- p[0] = wrapOnce(x, min[0], max[0]);
10
- wrap = true;
11
- }
12
- if (y < min[1] || y > max[1]) {
13
- p[1] = wrapOnce(y, min[1], max[1]);
14
- wrap = true;
5
+ const __wrap = (p, i, x, min, max) => {
6
+ if (x < min || x > max) {
7
+ p[i] = wrapOnce(x, min, max);
8
+ return true;
15
9
  }
16
- if (wrap) boid.pos.reset(p);
10
+ };
11
+ const wrap2 = (min, max) => (p, boid) => {
12
+ if (__wrap(p, 0, p[0], min[0], max[0]) || __wrap(p, 1, p[1], min[1], max[1]))
13
+ boid.pos.reset(p);
17
14
  return p;
18
15
  };
19
16
  const wrap3 = (min, max) => (p, boid) => {
20
- let [x, y, z] = p;
21
- let wrap = false;
22
- if (x < min[0] || x > max[0]) {
23
- p[0] = wrapOnce(x, min[0], max[0]);
24
- wrap = true;
25
- }
26
- if (y < min[1] || y > max[1]) {
27
- p[1] = wrapOnce(y, min[1], max[1]);
28
- wrap = true;
29
- }
30
- if (z < min[2] || z > max[2]) {
31
- p[2] = wrapOnce(z, min[2], max[2]);
32
- wrap = true;
33
- }
34
- if (wrap) boid.pos.reset(p);
17
+ if (__wrap(p, 0, p[0], min[0], max[0]) || __wrap(p, 1, p[1], min[1], max[1]) || __wrap(p, 2, p[2], min[2], max[2]))
18
+ boid.pos.reset(p);
35
19
  return p;
36
20
  };
37
21
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/boids",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "n-dimensional boids simulation with modular behavior system",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/boids#readme",
13
+ "homepage": "https://thi.ng/boids",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -36,20 +36,20 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.2",
40
- "@thi.ng/checks": "^3.6.4",
41
- "@thi.ng/distance": "^2.4.73",
42
- "@thi.ng/geom-closest-point": "^2.1.127",
43
- "@thi.ng/geom-resample": "^2.3.53",
44
- "@thi.ng/math": "^5.10.13",
45
- "@thi.ng/timestep": "^0.5.49",
46
- "@thi.ng/vectors": "^7.10.31"
39
+ "@thi.ng/api": "^8.11.3",
40
+ "@thi.ng/checks": "^3.6.5",
41
+ "@thi.ng/distance": "^2.4.74",
42
+ "@thi.ng/geom-closest-point": "^2.1.128",
43
+ "@thi.ng/geom-resample": "^3.0.0",
44
+ "@thi.ng/math": "^5.11.0",
45
+ "@thi.ng/timestep": "^0.5.50",
46
+ "@thi.ng/vectors": "^7.11.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@microsoft/api-extractor": "^7.43.2",
50
- "esbuild": "^0.21.1",
49
+ "@microsoft/api-extractor": "^7.47.0",
50
+ "esbuild": "^0.21.5",
51
51
  "typedoc": "^0.25.13",
52
- "typescript": "^5.4.5"
52
+ "typescript": "^5.5.2"
53
53
  },
54
54
  "keywords": [
55
55
  "nd",
@@ -143,5 +143,5 @@
143
143
  "status": "alpha",
144
144
  "year": 2023
145
145
  },
146
- "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
146
+ "gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
147
147
  }