@native-router/core 1.0.0 → 1.0.1

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/dist/index.mjs CHANGED
@@ -1,25 +1,6 @@
1
1
  import { parsePath, createPath } from 'history';
2
2
  import { match as match$1 } from 'path-to-regexp';
3
-
4
- let i = 1;
5
- function uniqId() {
6
- return i++;
7
- }
8
- function noop() {}
9
- const reject = /* @__PURE__ */Promise.reject.bind(Promise);
10
- function cancelPromise() {
11
- return new Promise(noop);
12
- }
13
- function createCurrentGuard() {
14
- let current;
15
- return [function currentGuard(promise) {
16
- const cur = uniqId();
17
- current = cur;
18
- return promise.then(result => current === cur ? result : cancelPromise()).catch(err => current === cur ? Promise.reject(err) : cancelPromise());
19
- }, function cancel() {
20
- current = undefined;
21
- }];
22
- }
3
+ import { reject, noop, createCurrentGuard } from './util.mjs';
23
4
 
24
5
  /* eslint-disable max-classes-per-file */
25
6
 
package/dist/util.mjs ADDED
@@ -0,0 +1,36 @@
1
+ let i = 1;
2
+ function uniqId() {
3
+ return i++;
4
+ }
5
+ function noop() {}
6
+ const resolve = /* @__PURE__ */Promise.resolve.bind(Promise);
7
+ const reject = /* @__PURE__ */Promise.reject.bind(Promise);
8
+ function cancelPromise() {
9
+ return new Promise(noop);
10
+ }
11
+ function createCurrentGuard() {
12
+ let current;
13
+ return [function currentGuard(promise) {
14
+ const cur = uniqId();
15
+ current = cur;
16
+ return promise.then(result => current === cur ? result : cancelPromise()).catch(err => current === cur ? Promise.reject(err) : cancelPromise());
17
+ }, function cancel() {
18
+ current = undefined;
19
+ }];
20
+ }
21
+ function splitProps(obj, keys) {
22
+ const picked = {};
23
+ const rest = {
24
+ ...obj
25
+ };
26
+ keys.forEach(key => {
27
+ picked[key] = rest[key];
28
+ delete rest[key];
29
+ });
30
+ return [picked, rest];
31
+ }
32
+ function isString(maybeString) {
33
+ return typeof maybeString === 'string';
34
+ }
35
+
36
+ export { cancelPromise, createCurrentGuard, isString, noop, reject, resolve, splitProps, uniqId };
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@native-router/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.mjs",
7
7
  "types": "./dist/types/index.d.ts"
8
+ },
9
+ "./util": {
10
+ "import": "./dist/util.mjs",
11
+ "types": "./dist/types/util.d.ts"
8
12
  }
9
13
  },
10
14
  "types": "./dist/types/index.d.ts",
@@ -30,7 +34,7 @@
30
34
  "coverage": "nyc report --reporter=text-lcov > ./.nyc_output/coverage.txt",
31
35
  "lint": "eslint --fix src test demos *.js --ext .js,.jsx,.ts,.tsx",
32
36
  "doc:gen": "typedoc",
33
- "deploy": "npm run doc:gen && npm run build:demo && gh-pages -d dist",
37
+ "deploy": "npm run doc:gen && gh-pages -d dist",
34
38
  "test": "cross-env NODE_ENV=test nyc mocha",
35
39
  "preversion": "npm run build",
36
40
  "postversion": "npm publish",