Skip to content

Commit 9b7a583

Browse files
committed
rename addContent to put
1 parent 58adf1b commit 9b7a583

8 files changed

Lines changed: 42 additions & 48 deletions

File tree

‎src/cell/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from "./Cell.js"
22
export * from "./Nothing.js"
3-
export * from "./addContent.js"
43
export * from "./addPropagator.js"
4+
export * from "./put.js"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isContradiction } from "../merge/index.js"
22
import { schedule } from "../scheduler/index.js"
33
import { type Cell } from "./Cell.js"
44

5-
export function addContent<T>(cell: Cell<T>, increment?: T): void {
5+
export function put<T>(cell: Cell<T>, increment?: T): void {
66
const newContent = cell.merge(cell.content, increment)
77
if (newContent === cell.content) {
88
return

‎src/examples/barometer.test.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from "node:assert"
22
import { test } from "node:test"
3-
import { Cell, addContent } from "../cell/index.js"
3+
import { Cell, put } from "../cell/index.js"
44
import { Interval, intervalAlmostEqual } from "../interval/index.js"
55
import { run } from "../scheduler/index.js"
66
import { fallDuration, similarTriangles } from "./barometer.js"
77

88
test("examples / barometer / fallDuration", async () => {
99
const [fallTime, buildingHeight] = fallDuration()
10-
addContent(fallTime, Interval(2.9, 3.1))
10+
put(fallTime, Interval(2.9, 3.1))
1111

1212
await run()
1313

@@ -22,11 +22,11 @@ test("examples / barometer / fallDuration", async () => {
2222

2323
test("examples / barometer / fallDuration / Interval + Number", async () => {
2424
const [fallTime, buildingHeight] = fallDuration()
25-
addContent(fallTime, Interval(2.9, 3.1))
25+
put(fallTime, Interval(2.9, 3.1))
2626

2727
await run()
2828

29-
addContent(buildingHeight, Interval(45, 45))
29+
put(buildingHeight, Interval(45, 45))
3030

3131
await run()
3232

@@ -36,9 +36,9 @@ test("examples / barometer / fallDuration / Interval + Number", async () => {
3636
test("examples / barometer / similarTriangles & fallDuration", async () => {
3737
const [barometerShadow, barometerHeight, buildingShadow, buildingHeight] =
3838
similarTriangles()
39-
addContent(buildingShadow, Interval(54.9, 55.1))
40-
addContent(barometerHeight, Interval(0.3, 0.32))
41-
addContent(barometerShadow, Interval(0.36, 0.37))
39+
put(buildingShadow, Interval(54.9, 55.1))
40+
put(barometerHeight, Interval(0.3, 0.32))
41+
put(barometerShadow, Interval(0.36, 0.37))
4242

4343
await run()
4444

@@ -52,7 +52,7 @@ test("examples / barometer / similarTriangles & fallDuration", async () => {
5252

5353
const fallTime = Cell()
5454
fallDuration(fallTime, buildingHeight)
55-
addContent(fallTime, Interval(2.9, 3.1))
55+
put(fallTime, Interval(2.9, 3.1))
5656

5757
await run()
5858

‎src/examples/celsius.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from "node:assert"
22
import { test } from "node:test"
3-
import { addContent } from "../cell/addContent.js"
3+
import { put } from "../cell/put.js"
44
import { run } from "../scheduler/index.js"
55
import {
66
celsiusKelvin,
@@ -10,7 +10,7 @@ import {
1010

1111
test("examples / celsius / fahrenheitToCelsius", async () => {
1212
const [f, c] = fahrenheitToCelsius()
13-
addContent(f, 77)
13+
put(f, 77)
1414

1515
await run()
1616

@@ -20,7 +20,7 @@ test("examples / celsius / fahrenheitToCelsius", async () => {
2020
test("examples / celsius / fahrenheitCelsius", async () => {
2121
{
2222
const [f, c] = fahrenheitCelsius()
23-
addContent(f, 77)
23+
put(f, 77)
2424

2525
await run()
2626

@@ -29,7 +29,7 @@ test("examples / celsius / fahrenheitCelsius", async () => {
2929

3030
{
3131
const [f, c] = fahrenheitCelsius()
32-
addContent(c, 25)
32+
put(c, 25)
3333

3434
await run()
3535

@@ -40,7 +40,7 @@ test("examples / celsius / fahrenheitCelsius", async () => {
4040
test("examples / celsius / celsiusKelvin", async () => {
4141
const [f, c] = fahrenheitCelsius()
4242
const k = celsiusKelvin(c)
43-
addContent(f, 77)
43+
put(f, 77)
4444

4545
await run()
4646

‎src/examples/heron.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import assert from "node:assert"
22
import { test } from "node:test"
33
import { Cell } from "../cell/Cell.js"
4-
import { addContent } from "../cell/addContent.js"
4+
import { put } from "../cell/put.js"
55
import { run } from "../scheduler/index.js"
66
import { heronStep } from "./heron.js"
77

88
test("examples / heron / heronStep", async () => {
99
const [x, guess, betterGuess] = heronStep()
10-
addContent(x, 2)
11-
addContent(guess, 1.4)
10+
put(x, 2)
11+
put(guess, 1.4)
1212

1313
await run()
1414

‎src/propagator/definePrimitive.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
addContent,
3-
addPropagator,
4-
Cell,
5-
isNothing,
6-
nothing,
7-
} from "../cell/index.js"
1+
import { Cell, addPropagator, isNothing, nothing, put } from "../cell/index.js"
82
import { schedule } from "../scheduler/index.js"
93
import type { MaybePromise } from "../utils/MaybePromise.js"
104
import { repeatApply } from "../utils/repeatApply.js"
@@ -42,14 +36,14 @@ export function definePrimitive<A extends number>(
4236
const output = args[args.length - 1]
4337

4438
watch(inputs, async () => {
45-
addContent(output, await liftedFn(...inputs))
39+
put(output, await liftedFn(...inputs))
4640
})
4741
} else if (args.length === arity - 1) {
4842
const inputs = args
4943
const output = Cell()
5044

5145
watch(inputs, async () => {
52-
addContent(output, await liftedFn(...inputs))
46+
put(output, await liftedFn(...inputs))
5347
})
5448

5549
return output
@@ -59,7 +53,7 @@ export function definePrimitive<A extends number>(
5953
const output = Cell()
6054

6155
watch(inputs, async () => {
62-
addContent(output, await liftedFn(...inputs))
56+
put(output, await liftedFn(...inputs))
6357
})
6458

6559
return [...paddings, output]

‎src/propagators/arithmetic.test.ts‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import assert from "node:assert"
22
import { test } from "node:test"
33
import { Cell } from "../cell/Cell.js"
4-
import { addContent } from "../cell/addContent.js"
4+
import { put } from "../cell/put.js"
55
import { run } from "../scheduler/index.js"
66
import { adder, multiplier, product, sum } from "./index.js"
77

88
test("propagators / arithmetic / adder", async () => {
99
const [x, y, z] = adder()
10-
addContent(x, 1)
11-
addContent(y, 2)
10+
put(x, 1)
11+
put(y, 2)
1212

1313
await run()
1414

@@ -25,8 +25,8 @@ test("propagators / arithmetic / adder / expression-like", async () => {
2525

2626
test("propagators / arithmetic / multiplier", async () => {
2727
const [x, y, z] = multiplier()
28-
addContent(x, 2)
29-
addContent(y, 3)
28+
put(x, 2)
29+
put(y, 3)
3030

3131
await run()
3232

@@ -36,8 +36,8 @@ test("propagators / arithmetic / multiplier", async () => {
3636
test("propagators / arithmetic / sum", async () => {
3737
{
3838
const [x, y, z] = sum()
39-
addContent(x, 1)
40-
addContent(y, 2)
39+
put(x, 1)
40+
put(y, 2)
4141

4242
await run()
4343

@@ -46,8 +46,8 @@ test("propagators / arithmetic / sum", async () => {
4646

4747
{
4848
const [x, y, z] = sum()
49-
addContent(x, 1)
50-
addContent(z, 3)
49+
put(x, 1)
50+
put(z, 3)
5151

5252
await run()
5353

@@ -56,8 +56,8 @@ test("propagators / arithmetic / sum", async () => {
5656

5757
{
5858
const [x, y, z] = sum()
59-
addContent(y, 2)
60-
addContent(z, 3)
59+
put(y, 2)
60+
put(z, 3)
6161

6262
await run()
6363

@@ -68,8 +68,8 @@ test("propagators / arithmetic / sum", async () => {
6868
test("propagators / arithmetic / product", async () => {
6969
{
7070
const [x, y, z] = product()
71-
addContent(x, 2)
72-
addContent(y, 3)
71+
put(x, 2)
72+
put(y, 3)
7373

7474
await run()
7575

@@ -78,8 +78,8 @@ test("propagators / arithmetic / product", async () => {
7878

7979
{
8080
const [x, y, z] = product()
81-
addContent(x, 2)
82-
addContent(z, 6)
81+
put(x, 2)
82+
put(z, 6)
8383

8484
await run()
8585

@@ -88,8 +88,8 @@ test("propagators / arithmetic / product", async () => {
8888

8989
{
9090
const [x, y, z] = product()
91-
addContent(y, 3)
92-
addContent(z, 6)
91+
put(y, 3)
92+
put(z, 6)
9393

9494
await run()
9595

‎src/propagators/quadratic.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from "node:assert"
22
import test from "node:test"
3-
import { addContent } from "../cell/addContent.js"
3+
import { put } from "../cell/put.js"
44
import { run } from "../scheduler/index.js"
55
import { quadratic } from "./quadratic.js"
66

77
test("propagators / quadratic", async () => {
88
{
99
const [r, s] = quadratic()
10-
addContent(r, 2)
10+
put(r, 2)
1111

1212
await run()
1313

@@ -16,7 +16,7 @@ test("propagators / quadratic", async () => {
1616

1717
{
1818
const [r, s] = quadratic()
19-
addContent(s, 4)
19+
put(s, 4)
2020

2121
await run()
2222

0 commit comments

Comments
 (0)