1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.indexRecord = exports.indexArray = exports.indexReadonlyMap = exports.indexReadonlyRecord = exports.indexReadonlyNonEmptyArray = exports.indexReadonlyArray = exports.fromIso = exports.fromAt = exports.index = void 0;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | var O = require("fp-ts/lib/Option");
|
14 | var pipeable_1 = require("fp-ts/lib/pipeable");
|
15 | var _ = require("./internal");
|
16 | var RM = require("fp-ts/lib/ReadonlyMap");
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | exports.index = _.index;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | var fromAt = function (at) {
|
30 | return (0, exports.index)(function (i) { return _.lensComposePrism(_.prismSome())(at.at(i)); });
|
31 | };
|
32 | exports.fromAt = fromAt;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | var fromIso = function (iso) { return function (sia) {
|
40 | return (0, exports.index)(function (i) { return (0, pipeable_1.pipe)(iso, _.isoAsOptional, _.optionalComposeOptional(sia.index(i))); });
|
41 | }; };
|
42 | exports.fromIso = fromIso;
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | exports.indexReadonlyArray = _.indexReadonlyArray;
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | exports.indexReadonlyNonEmptyArray = _.indexReadonlyNonEmptyArray;
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | exports.indexReadonlyRecord = _.indexReadonlyRecord;
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | var indexReadonlyMap = function (E) {
|
63 | var lookupE = RM.lookup(E);
|
64 | var insertAtE = RM.insertAt(E);
|
65 | return function () {
|
66 | return (0, exports.index)(function (key) {
|
67 | return _.optional(function (s) { return lookupE(key, s); }, function (next) {
|
68 | var insert = insertAtE(key, next);
|
69 | return function (s) {
|
70 | return (0, pipeable_1.pipe)(lookupE(key, s), O.fold(function () { return s; }, function (prev) { return (next === prev ? s : insert(s)); }));
|
71 | };
|
72 | });
|
73 | });
|
74 | };
|
75 | };
|
76 | exports.indexReadonlyMap = indexReadonlyMap;
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | exports.indexArray = _.indexReadonlyArray;
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | exports.indexRecord = _.indexReadonlyRecord;
|