rrule-rust 0.0.1-2 → 0.0.1-5
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/index.js +14 -14
- package/package.json +19 -16
- package/src/lib.rs +40 -10
package/index.js
CHANGED
|
@@ -31,7 +31,7 @@ switch (platform) {
|
|
|
31
31
|
if (localFileExisted) {
|
|
32
32
|
nativeBinding = require('./rrule-rust.android-arm64.node')
|
|
33
33
|
} else {
|
|
34
|
-
nativeBinding = require('@rrule-rust/android-arm64')
|
|
34
|
+
nativeBinding = require('@rrule-rust/lib-android-arm64')
|
|
35
35
|
}
|
|
36
36
|
} catch (e) {
|
|
37
37
|
loadError = e
|
|
@@ -43,7 +43,7 @@ switch (platform) {
|
|
|
43
43
|
if (localFileExisted) {
|
|
44
44
|
nativeBinding = require('./rrule-rust.android-arm-eabi.node')
|
|
45
45
|
} else {
|
|
46
|
-
nativeBinding = require('@rrule-rust/android-arm-eabi')
|
|
46
|
+
nativeBinding = require('@rrule-rust/lib-android-arm-eabi')
|
|
47
47
|
}
|
|
48
48
|
} catch (e) {
|
|
49
49
|
loadError = e
|
|
@@ -63,7 +63,7 @@ switch (platform) {
|
|
|
63
63
|
if (localFileExisted) {
|
|
64
64
|
nativeBinding = require('./rrule-rust.win32-x64-msvc.node')
|
|
65
65
|
} else {
|
|
66
|
-
nativeBinding = require('@rrule-rust/win32-x64-msvc')
|
|
66
|
+
nativeBinding = require('@rrule-rust/lib-win32-x64-msvc')
|
|
67
67
|
}
|
|
68
68
|
} catch (e) {
|
|
69
69
|
loadError = e
|
|
@@ -77,7 +77,7 @@ switch (platform) {
|
|
|
77
77
|
if (localFileExisted) {
|
|
78
78
|
nativeBinding = require('./rrule-rust.win32-ia32-msvc.node')
|
|
79
79
|
} else {
|
|
80
|
-
nativeBinding = require('@rrule-rust/win32-ia32-msvc')
|
|
80
|
+
nativeBinding = require('@rrule-rust/lib-win32-ia32-msvc')
|
|
81
81
|
}
|
|
82
82
|
} catch (e) {
|
|
83
83
|
loadError = e
|
|
@@ -91,7 +91,7 @@ switch (platform) {
|
|
|
91
91
|
if (localFileExisted) {
|
|
92
92
|
nativeBinding = require('./rrule-rust.win32-arm64-msvc.node')
|
|
93
93
|
} else {
|
|
94
|
-
nativeBinding = require('@rrule-rust/win32-arm64-msvc')
|
|
94
|
+
nativeBinding = require('@rrule-rust/lib-win32-arm64-msvc')
|
|
95
95
|
}
|
|
96
96
|
} catch (e) {
|
|
97
97
|
loadError = e
|
|
@@ -107,7 +107,7 @@ switch (platform) {
|
|
|
107
107
|
if (localFileExisted) {
|
|
108
108
|
nativeBinding = require('./rrule-rust.darwin-universal.node')
|
|
109
109
|
} else {
|
|
110
|
-
nativeBinding = require('@rrule-rust/darwin-universal')
|
|
110
|
+
nativeBinding = require('@rrule-rust/lib-darwin-universal')
|
|
111
111
|
}
|
|
112
112
|
break
|
|
113
113
|
} catch {}
|
|
@@ -118,7 +118,7 @@ switch (platform) {
|
|
|
118
118
|
if (localFileExisted) {
|
|
119
119
|
nativeBinding = require('./rrule-rust.darwin-x64.node')
|
|
120
120
|
} else {
|
|
121
|
-
nativeBinding = require('@rrule-rust/darwin-x64')
|
|
121
|
+
nativeBinding = require('@rrule-rust/lib-darwin-x64')
|
|
122
122
|
}
|
|
123
123
|
} catch (e) {
|
|
124
124
|
loadError = e
|
|
@@ -132,7 +132,7 @@ switch (platform) {
|
|
|
132
132
|
if (localFileExisted) {
|
|
133
133
|
nativeBinding = require('./rrule-rust.darwin-arm64.node')
|
|
134
134
|
} else {
|
|
135
|
-
nativeBinding = require('@rrule-rust/darwin-arm64')
|
|
135
|
+
nativeBinding = require('@rrule-rust/lib-darwin-arm64')
|
|
136
136
|
}
|
|
137
137
|
} catch (e) {
|
|
138
138
|
loadError = e
|
|
@@ -151,7 +151,7 @@ switch (platform) {
|
|
|
151
151
|
if (localFileExisted) {
|
|
152
152
|
nativeBinding = require('./rrule-rust.freebsd-x64.node')
|
|
153
153
|
} else {
|
|
154
|
-
nativeBinding = require('@rrule-rust/freebsd-x64')
|
|
154
|
+
nativeBinding = require('@rrule-rust/lib-freebsd-x64')
|
|
155
155
|
}
|
|
156
156
|
} catch (e) {
|
|
157
157
|
loadError = e
|
|
@@ -168,7 +168,7 @@ switch (platform) {
|
|
|
168
168
|
if (localFileExisted) {
|
|
169
169
|
nativeBinding = require('./rrule-rust.linux-x64-musl.node')
|
|
170
170
|
} else {
|
|
171
|
-
nativeBinding = require('@rrule-rust/linux-x64-musl')
|
|
171
|
+
nativeBinding = require('@rrule-rust/lib-linux-x64-musl')
|
|
172
172
|
}
|
|
173
173
|
} catch (e) {
|
|
174
174
|
loadError = e
|
|
@@ -181,7 +181,7 @@ switch (platform) {
|
|
|
181
181
|
if (localFileExisted) {
|
|
182
182
|
nativeBinding = require('./rrule-rust.linux-x64-gnu.node')
|
|
183
183
|
} else {
|
|
184
|
-
nativeBinding = require('@rrule-rust/linux-x64-gnu')
|
|
184
|
+
nativeBinding = require('@rrule-rust/lib-linux-x64-gnu')
|
|
185
185
|
}
|
|
186
186
|
} catch (e) {
|
|
187
187
|
loadError = e
|
|
@@ -197,7 +197,7 @@ switch (platform) {
|
|
|
197
197
|
if (localFileExisted) {
|
|
198
198
|
nativeBinding = require('./rrule-rust.linux-arm64-musl.node')
|
|
199
199
|
} else {
|
|
200
|
-
nativeBinding = require('@rrule-rust/linux-arm64-musl')
|
|
200
|
+
nativeBinding = require('@rrule-rust/lib-linux-arm64-musl')
|
|
201
201
|
}
|
|
202
202
|
} catch (e) {
|
|
203
203
|
loadError = e
|
|
@@ -210,7 +210,7 @@ switch (platform) {
|
|
|
210
210
|
if (localFileExisted) {
|
|
211
211
|
nativeBinding = require('./rrule-rust.linux-arm64-gnu.node')
|
|
212
212
|
} else {
|
|
213
|
-
nativeBinding = require('@rrule-rust/linux-arm64-gnu')
|
|
213
|
+
nativeBinding = require('@rrule-rust/lib-linux-arm64-gnu')
|
|
214
214
|
}
|
|
215
215
|
} catch (e) {
|
|
216
216
|
loadError = e
|
|
@@ -225,7 +225,7 @@ switch (platform) {
|
|
|
225
225
|
if (localFileExisted) {
|
|
226
226
|
nativeBinding = require('./rrule-rust.linux-arm-gnueabihf.node')
|
|
227
227
|
} else {
|
|
228
|
-
nativeBinding = require('@rrule-rust/linux-arm-gnueabihf')
|
|
228
|
+
nativeBinding = require('@rrule-rust/lib-linux-arm-gnueabihf')
|
|
229
229
|
}
|
|
230
230
|
} catch (e) {
|
|
231
231
|
loadError = e
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-rust",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
7
7
|
"name": "rrule-rust",
|
|
8
|
+
"package": {
|
|
9
|
+
"name": "@rrule-rust/lib"
|
|
10
|
+
},
|
|
8
11
|
"triples": {
|
|
9
12
|
"additional": [
|
|
10
13
|
"aarch64-apple-darwin",
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"artifacts": "napi artifacts",
|
|
37
|
-
"build": "napi build --platform --release",
|
|
40
|
+
"build": "napi build --platform --release --js-package-name @rrule-rust/lib",
|
|
38
41
|
"build:debug": "napi build --platform",
|
|
39
42
|
"prepublishOnly": "napi prepublish -t npm",
|
|
40
43
|
"test": "ava",
|
|
@@ -42,19 +45,19 @@
|
|
|
42
45
|
"version": "napi version"
|
|
43
46
|
},
|
|
44
47
|
"optionalDependencies": {
|
|
45
|
-
"rrule-rust-win32-x64-msvc": "0.0.1-
|
|
46
|
-
"rrule-rust-darwin-x64": "0.0.1-
|
|
47
|
-
"rrule-rust-linux-x64-gnu": "0.0.1-
|
|
48
|
-
"rrule-rust-darwin-arm64": "0.0.1-
|
|
49
|
-
"rrule-rust-android-arm64": "0.0.1-
|
|
50
|
-
"rrule-rust-linux-arm64-gnu": "0.0.1-
|
|
51
|
-
"rrule-rust-linux-arm64-musl": "0.0.1-
|
|
52
|
-
"rrule-rust-win32-arm64-msvc": "0.0.1-
|
|
53
|
-
"rrule-rust-linux-arm-gnueabihf": "0.0.1-
|
|
54
|
-
"rrule-rust-linux-x64-musl": "0.0.1-
|
|
55
|
-
"rrule-rust-freebsd-x64": "0.0.1-
|
|
56
|
-
"rrule-rust-win32-ia32-msvc": "0.0.1-
|
|
57
|
-
"rrule-rust-android-arm-eabi": "0.0.1-
|
|
58
|
-
"rrule-rust-darwin-universal": "0.0.1-
|
|
48
|
+
"@rrule-rust/lib-win32-x64-msvc": "0.0.1-5",
|
|
49
|
+
"@rrule-rust/lib-darwin-x64": "0.0.1-5",
|
|
50
|
+
"@rrule-rust/lib-linux-x64-gnu": "0.0.1-5",
|
|
51
|
+
"@rrule-rust/lib-darwin-arm64": "0.0.1-5",
|
|
52
|
+
"@rrule-rust/lib-android-arm64": "0.0.1-5",
|
|
53
|
+
"@rrule-rust/lib-linux-arm64-gnu": "0.0.1-5",
|
|
54
|
+
"@rrule-rust/lib-linux-arm64-musl": "0.0.1-5",
|
|
55
|
+
"@rrule-rust/lib-win32-arm64-msvc": "0.0.1-5",
|
|
56
|
+
"@rrule-rust/lib-linux-arm-gnueabihf": "0.0.1-5",
|
|
57
|
+
"@rrule-rust/lib-linux-x64-musl": "0.0.1-5",
|
|
58
|
+
"@rrule-rust/lib-freebsd-x64": "0.0.1-5",
|
|
59
|
+
"@rrule-rust/lib-win32-ia32-msvc": "0.0.1-5",
|
|
60
|
+
"@rrule-rust/lib-android-arm-eabi": "0.0.1-5",
|
|
61
|
+
"@rrule-rust/lib-darwin-universal": "0.0.1-5"
|
|
59
62
|
}
|
|
60
63
|
}
|
package/src/lib.rs
CHANGED
|
@@ -280,6 +280,8 @@ impl JsRRule {
|
|
|
280
280
|
pub struct JsRRuleSet {
|
|
281
281
|
tz: Tz,
|
|
282
282
|
rrule_set: RRuleSet,
|
|
283
|
+
before: Option<i64>,
|
|
284
|
+
after: Option<i64>,
|
|
283
285
|
}
|
|
284
286
|
|
|
285
287
|
#[napi]
|
|
@@ -290,7 +292,12 @@ impl JsRRuleSet {
|
|
|
290
292
|
let date = timestamp_to_date_with_tz(dtstart, &tz);
|
|
291
293
|
let rrule_set = RRuleSet::new(date);
|
|
292
294
|
|
|
293
|
-
JsRRuleSet {
|
|
295
|
+
JsRRuleSet {
|
|
296
|
+
rrule_set,
|
|
297
|
+
tz,
|
|
298
|
+
before: None,
|
|
299
|
+
after: None,
|
|
300
|
+
}
|
|
294
301
|
}
|
|
295
302
|
|
|
296
303
|
#[napi]
|
|
@@ -319,18 +326,14 @@ impl JsRRuleSet {
|
|
|
319
326
|
|
|
320
327
|
#[napi]
|
|
321
328
|
pub fn after(&mut self, timestamp: i64) -> napi::Result<&Self> {
|
|
322
|
-
|
|
323
|
-
self_.after(timestamp_to_date_with_tz(timestamp, &self.tz))
|
|
324
|
-
});
|
|
329
|
+
self.after = Some(timestamp);
|
|
325
330
|
|
|
326
331
|
Ok(self)
|
|
327
332
|
}
|
|
328
333
|
|
|
329
334
|
#[napi]
|
|
330
335
|
pub fn before(&mut self, timestamp: i64) -> napi::Result<&Self> {
|
|
331
|
-
|
|
332
|
-
self_.before(timestamp_to_date_with_tz(timestamp, &self.tz))
|
|
333
|
-
});
|
|
336
|
+
self.before = Some(timestamp);
|
|
334
337
|
|
|
335
338
|
Ok(self)
|
|
336
339
|
}
|
|
@@ -368,23 +371,50 @@ impl JsRRuleSet {
|
|
|
368
371
|
Ok(arr)
|
|
369
372
|
}*/
|
|
370
373
|
|
|
374
|
+
fn is_after(&self, timestamp: i64) -> bool {
|
|
375
|
+
if let Some(after) = self.after {
|
|
376
|
+
if timestamp <= after {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
true
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
fn is_before(&self, timestamp: i64) -> bool {
|
|
385
|
+
if let Some(before) = self.before {
|
|
386
|
+
if timestamp >= before {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
true
|
|
392
|
+
}
|
|
393
|
+
|
|
371
394
|
#[napi(ts_return_type = "number[]")]
|
|
372
395
|
pub fn all(&self, env: Env, limit: Option<u32>) -> napi::Result<Array> {
|
|
373
396
|
let mut arr = env.create_array(0).unwrap();
|
|
374
|
-
let iter = self.rrule_set.into_iter();
|
|
375
397
|
let mut left = match limit {
|
|
376
398
|
Some(number) => number,
|
|
377
399
|
None => 0,
|
|
378
400
|
};
|
|
379
401
|
|
|
380
|
-
for date in
|
|
402
|
+
for date in self.rrule_set.into_iter() {
|
|
381
403
|
if left > 0 {
|
|
382
404
|
left = left - 1;
|
|
383
405
|
} else if limit.is_some() {
|
|
384
406
|
break;
|
|
385
407
|
}
|
|
386
408
|
|
|
387
|
-
|
|
409
|
+
let timestamp = date.timestamp_millis();
|
|
410
|
+
let is_after = self.is_after(timestamp);
|
|
411
|
+
let is_before = self.is_before(timestamp);
|
|
412
|
+
|
|
413
|
+
if is_after && is_before {
|
|
414
|
+
arr.insert(timestamp).unwrap();
|
|
415
|
+
} else if !is_before {
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
388
418
|
}
|
|
389
419
|
|
|
390
420
|
Ok(arr)
|