File tree Expand file tree Collapse file tree 5 files changed +21
-17
lines changed Expand file tree Collapse file tree 5 files changed +21
-17
lines changed Original file line number Diff line number Diff line change 1
1
# lattice
2
2
3
- ` lattice/conceptBelow ` & ` lattice/conceptAbove `
3
+ ` lattice/conceptBelow `
4
+ ` lattice/conceptAbove `
5
+
4
6
` LatticeLayout `
5
7
` layoutLattice(context) `
6
8
Original file line number Diff line number Diff line change @@ -3,20 +3,26 @@ import type { Concept } from "./Concept.js"
3
3
4
4
export function assertSameContext (
5
5
concepts : Array < Concept > ,
6
- options : {
7
- who : string
8
- message : string
9
- } & Record < string , any > ,
6
+ options : { who : string } ,
10
7
) : void {
11
8
if ( concepts . length < 2 ) return
12
9
13
- const { who, message } = options
10
+ const { who } = options
14
11
15
- const [ first , ...rest ] = concepts
16
- const firstContext = first . context
12
+ const [ firstConcept , ...rest ] = concepts
13
+ const firstContext = firstConcept . context
17
14
for ( const concept of rest ) {
18
15
if ( firstContext !== concept . context ) {
19
- log ( options )
16
+ const message = "I expect the contexts of x and y to be the same."
17
+
18
+ log ( {
19
+ who,
20
+ message,
21
+ concepts,
22
+ first : firstConcept ,
23
+ offendingConcept : concept ,
24
+ } )
25
+
20
26
throw new Error ( `[assertSameContext by ${ who } ] ${ message } ` )
21
27
}
22
28
}
Original file line number Diff line number Diff line change @@ -4,10 +4,7 @@ import type { Concept } from "./Concept.js"
4
4
import { conceptFromAttributes } from "./conceptFromAttributes.js"
5
5
6
6
export function conceptJoin ( x : Concept , y : Concept ) : Concept {
7
- assertSameContext ( [ x , y ] , {
8
- who : "conceptJoin" ,
9
- message : "I expect the contexts of x and y to be the same." ,
10
- } )
7
+ assertSameContext ( [ x , y ] , { who : "conceptJoin" } )
11
8
12
9
return conceptFromAttributes ( x . context , setIntersection ( x . intent , y . intent ) )
13
10
}
Original file line number Diff line number Diff line change @@ -4,10 +4,7 @@ import type { Concept } from "./Concept.js"
4
4
import { conceptFromEntities } from "./conceptFromEntities.js"
5
5
6
6
export function conceptMeet ( x : Concept , y : Concept ) : Concept {
7
- assertSameContext ( [ x , y ] , {
8
- who : "conceptMeet" ,
9
- message : "I expect the contexts of x and y to be the same." ,
10
- } )
7
+ assertSameContext ( [ x , y ] , { who : "conceptMeet" } )
11
8
12
9
return conceptFromEntities ( x . context , setIntersection ( x . extent , y . extent ) )
13
10
}
Original file line number Diff line number Diff line change
1
+ import { assertSameContext } from "../concept/assertSameContext.js"
1
2
import type { Concept } from "../concept/Concept.js"
2
3
3
4
export function conceptBelow ( x : Concept , y : Concept ) : boolean {
5
+ assertSameContext ( [ x , y ] , { who : "conceptBelow" } )
4
6
return false
5
7
}
You can’t perform that action at this time.
0 commit comments