-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathtea_ex.js
More file actions
102 lines (90 loc) · 3.13 KB
/
Copy pathtea_ex.js
File metadata and controls
102 lines (90 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Generated by BUCKLESCRIPT VERSION 2.2.3, PLEASE EDIT WITH CARE
'use strict';
var Block = require("bs-platform/lib/js/block.js");
var Curry = require("bs-platform/lib/js/curry.js");
var Tea_task = require("./tea_task.js");
var Web_window_localstorage = require("./web_window_localstorage.js");
var length = /* Task */[(function (cb) {
var match = Web_window_localstorage.length(window);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [match[0]]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
var clear = /* Task */[(function (cb) {
var match = Web_window_localstorage.clear(window);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [match[0]]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
function clearCmd() {
return Tea_task.attemptOpt((function () {
return /* None */0;
}), clear);
}
function key(idx) {
return /* Task */[(function (cb) {
var match = Web_window_localstorage.key(window, idx);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [match[0]]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
}
function getItem(key) {
return /* Task */[(function (cb) {
var match = Web_window_localstorage.getItem(window, key);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [match[0]]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
}
function removeItem(key) {
return /* Task */[(function (cb) {
var match = Web_window_localstorage.removeItem(window, key);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [match[0]]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
}
function removeItemCmd(key) {
return Tea_task.attemptOpt((function () {
return /* None */0;
}), removeItem(key));
}
function setItem(key, value) {
return /* Task */[(function (cb) {
var match = Web_window_localstorage.setItem(window, key, value);
if (match) {
return Curry._1(cb, /* Ok */Block.__(0, [/* () */0]));
} else {
return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"]));
}
})];
}
function setItemCmd(key, value) {
return Tea_task.attemptOpt((function () {
return /* None */0;
}), setItem(key, value));
}
var LocalStorage = /* module */[
/* length */length,
/* clear */clear,
/* clearCmd */clearCmd,
/* key */key,
/* getItem */getItem,
/* removeItem */removeItem,
/* removeItemCmd */removeItemCmd,
/* setItem */setItem,
/* setItemCmd */setItemCmd
];
exports.LocalStorage = LocalStorage;
/* No side effect */