@soratani-code/samtools 1.3.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/lib/color.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare function rgbToHex(_color: string): string;
2
+ export declare function rgbaToHex(_color: string): string;
3
+ export declare function hexToRgb(_color: string): string;
4
+ export declare function hex(_color: string): string;
5
+ export declare function completionHex(color: string): string;
6
+ export declare function color(str: string, num?: number, dark?: boolean): string;
7
+ export declare function opacity(code: string, num?: number): string;
8
+ export declare function complementaryColor(code: string): string;
package/lib/color.js ADDED
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.complementaryColor = exports.opacity = exports.color = exports.completionHex = exports.hex = exports.hexToRgb = exports.rgbaToHex = exports.rgbToHex = void 0;
4
+ const type_1 = require("./type");
5
+ function repeatWord(word, num) {
6
+ var result = '';
7
+ for (let i = 0; i < num; i++) {
8
+ result += word;
9
+ }
10
+ return result;
11
+ }
12
+ function repeatLetter(word, num) {
13
+ var result = '';
14
+ for (let letter of word) {
15
+ result += repeatWord(letter, num);
16
+ }
17
+ return result;
18
+ }
19
+ function rgbToHex(_color) {
20
+ let arr = _color.replace('rgb(', '').replace(')', '').split(',').map((i) => Number(i));
21
+ let r = +arr[0];
22
+ let g = +arr[1];
23
+ let b = +arr[2];
24
+ return `#${(r << 16 | g << 8 | b).toString(16).padStart(6, '0')}`;
25
+ }
26
+ exports.rgbToHex = rgbToHex;
27
+ function rgbaToHex(_color) {
28
+ return _color.replace('rgba(', '').replace(')', '').split(',').reduce((a, chanel, i) => {
29
+ let hexNum = "";
30
+ if (i === 3) {
31
+ hexNum = Number(Math.round(Number(chanel) * 255)).toString(16);
32
+ }
33
+ else {
34
+ hexNum = Number(chanel).toString(16);
35
+ }
36
+ return `${a}${hexNum.length === 1 ? '0' + hexNum : hexNum}`;
37
+ }, '#');
38
+ }
39
+ exports.rgbaToHex = rgbaToHex;
40
+ function hexToRgb(_color) {
41
+ try {
42
+ if (!_color.startsWith('#'))
43
+ return '';
44
+ let hex = _color.replace('#', '');
45
+ hex = hex.length < 6 ? repeatLetter(hex, 2) : hex;
46
+ hex = `0x${hex}`;
47
+ return `rgb(${hex >> 16},${hex >> 8 & 0xff},${hex & 0xff})`;
48
+ }
49
+ catch (error) {
50
+ return '';
51
+ }
52
+ }
53
+ exports.hexToRgb = hexToRgb;
54
+ function hex(_color) {
55
+ if (!_color)
56
+ return '';
57
+ if (_color.startsWith('rgba('))
58
+ return rgbaToHex(_color);
59
+ if (_color.startsWith('rgb('))
60
+ return rgbToHex(_color);
61
+ return '';
62
+ }
63
+ exports.hex = hex;
64
+ function completionHex(color) {
65
+ let _color = color;
66
+ _color = _color.startsWith('#') ? _color.replace(/\#/g, '') : _color;
67
+ if (_color.length > 3)
68
+ return `#${_color}`;
69
+ return _color.split('').reduce((a, b) => `${a}${b}${b}`, '#');
70
+ }
71
+ exports.completionHex = completionHex;
72
+ function colorLight(hex, lum) {
73
+ hex = String(hex).replace(/[^0-9a-f]/gi, '');
74
+ if (hex.length < 6) {
75
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
76
+ }
77
+ lum = lum || 0;
78
+ var rgb = "#", c, i;
79
+ for (i = 0; i < 3; i++) {
80
+ c = parseInt(hex.substr(i * 2, 2), 16);
81
+ c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
82
+ rgb += ("00" + c).substr(c.length);
83
+ }
84
+ return rgb;
85
+ }
86
+ function colorDark(hex, lum) {
87
+ let rgb = hexToRgb(hex).replace('rgb(', '').replace(')', '').split(',');
88
+ lum = lum || 0;
89
+ for (var i = 0; i < 3; i++)
90
+ rgb[i] = Math.floor(Number(rgb[i]) * (1 - lum));
91
+ return rgbToHex(`rgb(${rgb.join(',')})`);
92
+ }
93
+ function color(str, num, dark) {
94
+ let _color = str;
95
+ if (str.startsWith('rgba(') || str.startsWith('rgb(')) {
96
+ _color = hexToRgb(hex(str));
97
+ }
98
+ if ((0, type_1.isUndefined)(num))
99
+ return str;
100
+ return dark ? colorDark(_color, num) : colorLight(_color, num);
101
+ }
102
+ exports.color = color;
103
+ function opacity(code, num) {
104
+ if (!(0, type_1.isNum)(num))
105
+ return code;
106
+ let _color = code.toLowerCase();
107
+ if (_color && /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(_color)) {
108
+ if (_color.length === 4) {
109
+ var colorNew = '#';
110
+ for (var i = 1; i < 4; i += 1) {
111
+ colorNew += _color.slice(i, i + 1).concat(_color.slice(i, i + 1));
112
+ }
113
+ _color = colorNew;
114
+ }
115
+ var colorChange = [];
116
+ for (var j = 1; j < 7; j += 2) {
117
+ colorChange.push(parseInt('0x' + _color.slice(j, j + 2)));
118
+ }
119
+ return color(`rgba(${colorChange.join(',')},${num})`);
120
+ }
121
+ if (_color.startsWith('rgb(')) {
122
+ let numbers = _color.match(/(\d(\.\d+)?)+/g);
123
+ numbers = numbers.slice(0, 3).concat(num);
124
+ return color('rgba(' + numbers.join(',') + ')');
125
+ }
126
+ if (_color.startsWith('rgba(')) {
127
+ return opacity(rgbaToHex(_color), num);
128
+ }
129
+ return _color;
130
+ }
131
+ exports.opacity = opacity;
132
+ function complementaryColor(code) {
133
+ const _color = color(code).slice(1);
134
+ const ind = parseInt(_color, 16);
135
+ let iter = ((1 << 4 * _color.length) - 1 - ind).toString(16);
136
+ if (iter.length >= _color.length)
137
+ return `#${iter}`;
138
+ iter = new Array(_color.length - 1).fill('0').reduce((a, b) => b + a, iter);
139
+ return '#' + iter;
140
+ }
141
+ exports.complementaryColor = complementaryColor;
@@ -0,0 +1,9 @@
1
+ type PickKeys<T = any> = T[];
2
+ type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? 'length' extends keyof T ? number extends T['length'] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
3
+ type FieldWithPossiblyUndefined<T, Key> = GetFieldType<Exclude<T, undefined>, Key> | Extract<T, undefined>;
4
+ type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
5
+ type GetFieldType<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
6
+ export declare function get<TObject, TPath extends string, TDefault = GetFieldType<TObject, TPath>>(data: TObject, id: TPath, defaultData?: TDefault): Exclude<GetFieldType<TObject, TPath>, null | undefined> | TDefault;
7
+ export declare function pick<D extends object, T extends keyof D>(data: D, keys?: PickKeys<T>): Pick<D, T>;
8
+ export declare function omit<D extends object, T extends keyof D>(data: D, keys?: PickKeys<T>): Omit<D, T>;
9
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = exports.pick = exports.get = void 0;
4
+ const type_1 = require("./type");
5
+ function get(data, id, defaultData) {
6
+ if (!id || !data)
7
+ return defaultData;
8
+ let keys = id.replace(/[{}\[\]()]/g, '.').split('.').filter(Boolean);
9
+ let node = data;
10
+ while (keys.length && !(0, type_1.isNull)(node) && !(0, type_1.isUndefined)(node)) {
11
+ const key = keys.shift();
12
+ node = node[key];
13
+ }
14
+ return (node || defaultData);
15
+ }
16
+ exports.get = get;
17
+ function pick(data, keys = []) {
18
+ if (!data || !keys || !keys.length || !(0, type_1.isObject)(data))
19
+ return data;
20
+ return Object.entries(data).reduce((a, b) => {
21
+ const [key, value] = b;
22
+ if (keys.includes(key)) {
23
+ a[key] = value;
24
+ }
25
+ return a;
26
+ }, {});
27
+ }
28
+ exports.pick = pick;
29
+ function omit(data, keys = []) {
30
+ if (!data || !keys || !keys.length || !(0, type_1.isObject)(data))
31
+ return data;
32
+ return Object.entries(data).reduce((a, b) => {
33
+ const [key, value] = b;
34
+ if (!keys.includes(key)) {
35
+ a[key] = value;
36
+ }
37
+ return a;
38
+ }, {});
39
+ }
40
+ exports.omit = omit;
package/lib/delay.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ interface Curry<T extends any[], R> {
2
+ (...args: T): R | Promise<R>;
3
+ }
4
+ export declare function delay<T extends any[], R>(fun: Curry<T, R>, timer?: number): Curry<T, R>;
5
+ export {};
package/lib/delay.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delay = void 0;
4
+ const type_1 = require("./type");
5
+ function delay(fun, timer = 1000) {
6
+ return (...args) => {
7
+ const task = new Promise((resolve, reject) => {
8
+ let time = setTimeout(() => {
9
+ const data = fun(...args);
10
+ if ((0, type_1.isPromise)(data)) {
11
+ data.then(resolve).catch(reject);
12
+ }
13
+ else {
14
+ resolve(data);
15
+ }
16
+ clearTimeout(time);
17
+ time = undefined;
18
+ }, timer);
19
+ });
20
+ return task;
21
+ };
22
+ }
23
+ exports.delay = delay;
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./interface";
2
+ export * from "./type";
3
+ export * from "./delay";
4
+ export * from "./database";
5
+ export * from "./time";
6
+ export * as platform from "./platform";
7
+ export * as set from "./set";
8
+ export * as log from "./log";
9
+ export * as color from "./color";
10
+ export * as query from "./query";
11
+ export * as transform from "./transform";
package/lib/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.transform = exports.query = exports.color = exports.log = exports.set = exports.platform = void 0;
30
+ __exportStar(require("./interface"), exports);
31
+ __exportStar(require("./type"), exports);
32
+ __exportStar(require("./delay"), exports);
33
+ __exportStar(require("./database"), exports);
34
+ __exportStar(require("./time"), exports);
35
+ exports.platform = __importStar(require("./platform"));
36
+ exports.set = __importStar(require("./set"));
37
+ exports.log = __importStar(require("./log"));
38
+ exports.color = __importStar(require("./color"));
39
+ exports.query = __importStar(require("./query"));
40
+ exports.transform = __importStar(require("./transform"));
@@ -0,0 +1,7 @@
1
+ export type BaseType = "string" | "function" | "object" | "array" | "bigint" | "boolean" | "symbol" | "number" | "undefined" | "null";
2
+ export type TreeChildren<P = any> = P & {
3
+ children: TreeChildren<P>[];
4
+ };
5
+ export type ListToTreeSchema = {
6
+ [key: string]: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { default as Link } from './link';
2
+ export * from './node';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Link = void 0;
21
+ var link_1 = require("./link");
22
+ Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return __importDefault(link_1).default; } });
23
+ __exportStar(require("./node"), exports);
@@ -0,0 +1,9 @@
1
+ import { LinkNode } from "./node";
2
+ export default class Link<V = any> {
3
+ constructor(id: string | number, value: V);
4
+ head: LinkNode<V>;
5
+ insert(value: LinkNode, head?: boolean): LinkNode<V>;
6
+ nodeInsert(id: string | number, value: LinkNode, head?: boolean): LinkNode<V>;
7
+ remove(id: string | number): LinkNode<V>;
8
+ get(id: string | number): LinkNode<V>;
9
+ }
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_1 = require("./node");
4
+ class Link {
5
+ constructor(id, value) {
6
+ this.head = new node_1.LinkNode(id, value);
7
+ }
8
+ insert(value, head = false) {
9
+ const node = value;
10
+ if (head) {
11
+ node.next = this.head;
12
+ this.head = node;
13
+ return this.head;
14
+ }
15
+ else {
16
+ let next = this.head.next;
17
+ if (!next) {
18
+ this.head.next = node;
19
+ return this.head;
20
+ }
21
+ while (next.next) {
22
+ next = next.next;
23
+ }
24
+ next.next = node;
25
+ }
26
+ return this.head;
27
+ }
28
+ nodeInsert(id, value, head = false) {
29
+ const node = value;
30
+ let headNode = this.head;
31
+ let current = headNode.next;
32
+ let status = headNode.id === id;
33
+ if (head) {
34
+ if (status) {
35
+ node.next = headNode;
36
+ this.head = node;
37
+ return this.head;
38
+ }
39
+ while (!status && current) {
40
+ status = current.id === id;
41
+ if (!status) {
42
+ headNode = current;
43
+ current = current.next;
44
+ }
45
+ }
46
+ if (status && current) {
47
+ node.next = current;
48
+ headNode.next = node;
49
+ }
50
+ return this.head;
51
+ }
52
+ else {
53
+ if (status) {
54
+ node.next = current;
55
+ headNode.next = node;
56
+ return this.head;
57
+ }
58
+ while (!status && current) {
59
+ status = current.id === id;
60
+ if (!status) {
61
+ headNode = current;
62
+ current = current.next;
63
+ }
64
+ }
65
+ if (status && current) {
66
+ headNode = current;
67
+ current = current.next;
68
+ headNode.next = node;
69
+ node.next = current;
70
+ }
71
+ return this.head;
72
+ }
73
+ }
74
+ remove(id) {
75
+ let head = this.head;
76
+ let current = head.next;
77
+ let status = head.id === id;
78
+ if (status) {
79
+ this.head = this.head.next;
80
+ return this.head;
81
+ }
82
+ while (!status && current) {
83
+ status = current.id === id;
84
+ if (!status) {
85
+ head = current;
86
+ current = current.next;
87
+ }
88
+ }
89
+ if (status && current) {
90
+ current = current.next;
91
+ head.next = current;
92
+ }
93
+ return this.head;
94
+ }
95
+ get(id) {
96
+ let node = this.head;
97
+ let status = false;
98
+ while (!status && node) {
99
+ status = node.id === id;
100
+ if (!status) {
101
+ node = node.next;
102
+ }
103
+ }
104
+ if (status && node) {
105
+ return node;
106
+ }
107
+ return null;
108
+ }
109
+ }
110
+ exports.default = Link;
@@ -0,0 +1,7 @@
1
+ export declare class LinkNode<V = any> {
2
+ constructor(id: string | number, value: V);
3
+ id: any;
4
+ value: V;
5
+ next?: LinkNode;
6
+ pre?: LinkNode;
7
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkNode = void 0;
4
+ class LinkNode {
5
+ constructor(id, value) {
6
+ this.value = value;
7
+ this.id = id;
8
+ }
9
+ }
10
+ exports.LinkNode = LinkNode;
package/lib/log.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function log(label: string, message: string): void;
2
+ export declare function error(label: string, ...message: any): void;
3
+ export declare function warn(label: string, ...message: any): void;
4
+ export declare function info(label: string, ...message: any): void;
package/lib/log.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.info = exports.warn = exports.error = exports.log = void 0;
4
+ const type_1 = require("./type");
5
+ function log(label, message) {
6
+ return console.log(`%c ${label} %c ${message}`, 'background:#000;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
7
+ }
8
+ exports.log = log;
9
+ function error(label, ...message) {
10
+ if (message.length === 1 && (0, type_1.isString)(message[0])) {
11
+ return console.log(`%c ${label} %c ${message[0]}`, 'background:#eb1168;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
12
+ }
13
+ console.groupCollapsed(`%c ERROR %c${label}`, 'background:#eb1168;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
14
+ console.log(...message);
15
+ console.groupEnd();
16
+ }
17
+ exports.error = error;
18
+ function warn(label, ...message) {
19
+ if (message.length === 1 && (0, type_1.isString)(message[0])) {
20
+ return console.log(`%c ${label} %c ${message[0]}`, 'background:#ffcc00;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
21
+ }
22
+ console.groupCollapsed(`%c WARN %c${label}`, 'background:#ffcc00;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
23
+ console.log(...message);
24
+ console.groupEnd();
25
+ }
26
+ exports.warn = warn;
27
+ function info(label, ...message) {
28
+ if (message.length === 1 && (0, type_1.isString)(message[0])) {
29
+ return console.log(`%c ${label} %c ${message[0]}`, 'background:#028f55;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
30
+ }
31
+ console.groupCollapsed(`%c INFO %c${label}`, 'background:#028f55;color:#fff;border-top-left-radius:4px;border-bottom-left-radius:4px;padding:4px', 'background:#ddd;border-top-right-radius:4px;border-bottom-right-radius:4px;padding:4px;color:#000');
32
+ console.log(...message);
33
+ console.groupEnd();
34
+ }
35
+ exports.info = info;
@@ -0,0 +1,4 @@
1
+ type System = 'windows' | 'mac' | 'linux' | 'android' | 'ios' | 'blackberry' | 'symbian' | 'webos' | 'unknown' | 'windows-phone';
2
+ export declare function system(useragent?: string): System;
3
+ export declare function version(useragent?: string): string;
4
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = exports.system = void 0;
4
+ const database_1 = require("./database");
5
+ const system_map = {
6
+ 'Windows': 'windows',
7
+ 'Macintosh': 'mac',
8
+ 'Linux': 'linux',
9
+ 'Android': 'android',
10
+ 'iPhone': 'ios',
11
+ 'iPad': 'ios',
12
+ 'BlackBerry': 'blackberry',
13
+ 'BB10': 'blackberry',
14
+ 'SymbianOS': 'symbian',
15
+ 'Windows Phone': 'windows-phone',
16
+ 'webOS': 'webos',
17
+ };
18
+ function macVersion(useragent = navigator.userAgent) {
19
+ const rule = /Mac OS X ([\d._]+)/;
20
+ const match = (0, database_1.get)(rule.exec(useragent), '1');
21
+ if (match) {
22
+ const version = match.replace(/_/g, '.').replace(/\./g, ',').split(',').join('.');
23
+ return version || 'unknown';
24
+ }
25
+ return 'unknown';
26
+ }
27
+ function windowsVersion(useragent = navigator.userAgent) {
28
+ const rule = /Windows NT(\d+\.\d+)/i;
29
+ const match = (0, database_1.get)(rule.exec(useragent), '1');
30
+ return match || 'unknown';
31
+ }
32
+ function windowsPhoneVersion(useragent = navigator.userAgent) {
33
+ const rule = /Windows Phone(\d+\.\d+)/i;
34
+ const match = (0, database_1.get)(rule.exec(useragent), '1');
35
+ return match || 'unknown';
36
+ }
37
+ function androidVersion(useragent = navigator.userAgent) {
38
+ const rule = /Android (\d+(\.\d+)+(\.\d+)?)/i;
39
+ const match = (0, database_1.get)(rule.exec(useragent), '1');
40
+ return match || 'unknown';
41
+ }
42
+ function iosVersion(useragent = navigator.userAgent) {
43
+ const rule = /CPU( iPhone)? OS (\d+)_(\d+)(?:_\d+)? like Mac OS X/i;
44
+ const match_major = (0, database_1.get)(rule.exec(useragent), '2');
45
+ const match_minor = (0, database_1.get)(rule.exec(useragent), '3');
46
+ if (match_major && match_minor) {
47
+ return `${parseInt(match_major)}.${parseInt(match_minor)}`;
48
+ }
49
+ return 'unknown';
50
+ }
51
+ function system(useragent = navigator.userAgent) {
52
+ const rule = /(Windows|Macintosh|Android|iPhone|iPad|iPod|BlackBerry|BB10|SymbianOS|Windows Phone|webOS)/i;
53
+ const match = (0, database_1.get)(rule.exec(useragent), '1');
54
+ if (match && system_map[match])
55
+ return system_map[match];
56
+ return 'unknown';
57
+ }
58
+ exports.system = system;
59
+ function version(useragent = navigator.userAgent) {
60
+ const sys = system(useragent);
61
+ if (sys === 'windows')
62
+ return windowsVersion(useragent);
63
+ if (sys === 'windows-phone')
64
+ return windowsPhoneVersion(useragent);
65
+ if (sys === 'mac')
66
+ return macVersion(useragent);
67
+ if (sys === 'android')
68
+ return androidVersion(useragent);
69
+ if (sys === 'ios')
70
+ return iosVersion(useragent);
71
+ return 'unknown';
72
+ }
73
+ exports.version = version;
package/lib/query.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function make(obj: any): string;
2
+ export declare function parseQuery(str?: string): any;
3
+ export declare function parseUrl(url: string): string;
4
+ export declare function mergeQueryToURL(url: string, obj?: any): string;
package/lib/query.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeQueryToURL = exports.parseUrl = exports.parseQuery = exports.make = void 0;
4
+ const _1 = require(".");
5
+ function make(obj) {
6
+ if (!(0, _1.isObject)(obj) || (0, _1.isEmpty)(obj))
7
+ return "";
8
+ return Object.entries(obj).reduce((a, b, idx) => {
9
+ const [key, value] = b;
10
+ if ((0, _1.isEmpty)(value))
11
+ return a;
12
+ if (!idx)
13
+ return `${a}?${key}=${encodeURIComponent(value)}`;
14
+ return `${a}&${key}=${value}`;
15
+ }, "");
16
+ }
17
+ exports.make = make;
18
+ function parseQuery(str = '') {
19
+ if (!(0, _1.isString)(str) || (0, _1.isEmpty)(str))
20
+ return {};
21
+ const [, query] = str.split("?");
22
+ if ((0, _1.isEmpty)(query))
23
+ return {};
24
+ return query.split("&").filter(Boolean).reduce((a, b) => {
25
+ const [key, value] = b.split("=").filter(Boolean);
26
+ if ((0, _1.isEmpty)(value))
27
+ return a;
28
+ if ((0, _1.isNum)(Number(decodeURIComponent(value)))) {
29
+ a[key] = Number(decodeURIComponent(value));
30
+ }
31
+ else if (['true', 'false'].includes(decodeURIComponent(value))) {
32
+ a[key] = decodeURIComponent(value) === 'true';
33
+ }
34
+ else {
35
+ a[key] = decodeURIComponent(value);
36
+ }
37
+ return a;
38
+ }, {});
39
+ }
40
+ exports.parseQuery = parseQuery;
41
+ function parseUrl(url) {
42
+ if (!(0, _1.isString)(url) || (0, _1.isEmpty)(url))
43
+ return '';
44
+ const [_url] = url.split("?");
45
+ return _url;
46
+ }
47
+ exports.parseUrl = parseUrl;
48
+ function mergeQueryToURL(url, obj) {
49
+ const _url = parseUrl(url);
50
+ const _query = parseQuery(url);
51
+ const query = make(Object.assign(Object.assign({}, _query), obj));
52
+ return `${_url}${query}`;
53
+ }
54
+ exports.mergeQueryToURL = mergeQueryToURL;
package/lib/set.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare function unrepetition<D = any>(array: D[], index?: string): D[];
2
+ export declare function intersection<D = any>(array1: D[], array2: D[]): D[];
3
+ export declare function union<D = any>(array1: D[], array2: D[]): D[];
4
+ export declare function difference<D = any>(array1: D[], array2: D[]): D[];
package/lib/set.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.difference = exports.union = exports.intersection = exports.unrepetition = void 0;
4
+ const type_1 = require("./type");
5
+ function unrepetition(array, index) {
6
+ if ((0, type_1.isString)(index)) {
7
+ const maps = array.filter(item => (0, type_1.isObject)(item));
8
+ if (maps.length) {
9
+ const keys = unrepetition(maps.map(item => item[index]).filter(Boolean));
10
+ return keys.reduce((a, b, idx) => {
11
+ const item = maps.find(item => item[index] === b);
12
+ return a.concat([item]);
13
+ }, []);
14
+ }
15
+ }
16
+ return [...new Set(array)];
17
+ }
18
+ exports.unrepetition = unrepetition;
19
+ function intersection(array1, array2) {
20
+ const temp = [...array1].filter((a) => array2.some((b) => b === a));
21
+ return [...new Set(temp)];
22
+ }
23
+ exports.intersection = intersection;
24
+ function union(array1, array2) {
25
+ return [...new Set([...array1, ...array2])];
26
+ }
27
+ exports.union = union;
28
+ function difference(array1, array2) {
29
+ const un = union(array1, array2);
30
+ const int = intersection(array1, array2);
31
+ return un.filter((u) => !int.some(i => i === u));
32
+ }
33
+ exports.difference = difference;
package/lib/time.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ type FormatType = "YYYY-MM-DD" | "YYYY/MM/DD" | "DD/MM/YYYY" | "YYYY-MM-DD HH:mm:ss" | "YYYY/MM/DD HH:mm:ss" | "DD/MM/YYYY HH:mm:ss" | "YYYY-MM-DD HH:mm" | "YYYY/MM/DD HH:mm" | "DD/MM/YYYY HH:mm" | "YYYY-MM-DD HH" | "YYYY/MM/DD HH" | "DD/MM/YYYY HH";
2
+ export declare class Time {
3
+ private readonly time;
4
+ private static types;
5
+ static verification(time: string | number): number;
6
+ constructor(time: string | number);
7
+ private data;
8
+ private YYYY;
9
+ private MM;
10
+ private DD;
11
+ private HH;
12
+ private mm;
13
+ private ss;
14
+ private _format;
15
+ format(type: FormatType): string;
16
+ }
17
+ export {};
package/lib/time.js ADDED
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Time = void 0;
4
+ class Time {
5
+ static verification(time) {
6
+ try {
7
+ return new Date(time).getTime();
8
+ }
9
+ catch (error) {
10
+ return Date.now();
11
+ }
12
+ }
13
+ constructor(time) {
14
+ this.time = time;
15
+ this.data = new Date(Time.verification(time));
16
+ }
17
+ YYYY() {
18
+ return this.data.getFullYear();
19
+ }
20
+ MM() {
21
+ const t = this.data.getMonth() + 1;
22
+ return String(t).padStart(2, "0");
23
+ }
24
+ DD() {
25
+ const t = this.data.getDate();
26
+ return String(t).padStart(2, "0");
27
+ }
28
+ HH() {
29
+ return this.data.getHours();
30
+ }
31
+ mm() {
32
+ return this.data.getMinutes();
33
+ }
34
+ ss() {
35
+ return this.data.getSeconds();
36
+ }
37
+ _format(type, sep = "/") {
38
+ if (!type)
39
+ return undefined;
40
+ return type
41
+ .split(sep)
42
+ .map((item) => {
43
+ return this[item]();
44
+ })
45
+ .join(sep);
46
+ }
47
+ format(type) {
48
+ let defaultTime = type;
49
+ if (!Time.types.includes(type)) {
50
+ defaultTime = "YYYY-MM-DD";
51
+ }
52
+ const [time1, time2] = defaultTime.split(" ");
53
+ return [time1, time2]
54
+ .map((i) => {
55
+ if (!i)
56
+ return undefined;
57
+ if (i.includes("-"))
58
+ return this._format(i, "-");
59
+ if (i.includes("/"))
60
+ return this._format(i, "/");
61
+ if (i.includes(":"))
62
+ return this._format(i, ":");
63
+ return undefined;
64
+ })
65
+ .filter(Boolean)
66
+ .join(" ");
67
+ }
68
+ }
69
+ exports.Time = Time;
70
+ Time.types = [
71
+ "YYYY-MM-DD",
72
+ "YYYY/MM/DD",
73
+ "DD/MM/YYYY",
74
+ "YYYY-MM-DD HH:mm:ss",
75
+ "YYYY/MM/DD HH:mm:ss",
76
+ "DD/MM/YYYY HH:mm:ss",
77
+ "YYYY-MM-DD HH:mm",
78
+ "YYYY/MM/DD HH:mm",
79
+ "DD/MM/YYYY HH:mm",
80
+ "YYYY-MM-DD HH",
81
+ "YYYY/MM/DD HH",
82
+ "DD/MM/YYYY HH",
83
+ ];
@@ -0,0 +1,7 @@
1
+ import { ListToTreeSchema, TreeChildren } from '.';
2
+ export declare function listToTree<P = any, I = "id", PI = "parentId">(list: P[], id: I, parentId: PI, value: any, schema?: ListToTreeSchema): TreeChildren<P>[];
3
+ export declare function enumToList<K = number, V = string>(params: any): [K, V][];
4
+ export declare function enumToOptions(params?: any): {
5
+ label: string;
6
+ value: any;
7
+ }[];
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enumToOptions = exports.enumToList = exports.listToTree = void 0;
4
+ const type_1 = require("./type");
5
+ function schemaToObj(obj, schema) {
6
+ if (!(0, type_1.isObject)(obj) || !schema || !(0, type_1.isObject)(schema) || (0, type_1.isEmpty)(schema))
7
+ return obj;
8
+ const keys = Object.entries(schema);
9
+ return Object.entries(obj).reduce((a, b) => {
10
+ const [key, value] = b;
11
+ const sch = keys.find((k) => k[0] === key);
12
+ if ((0, type_1.isArray)(sch) && !!sch && !!sch[1]) {
13
+ a[sch[1]] = value;
14
+ }
15
+ return a;
16
+ }, {});
17
+ }
18
+ function listToTree(list, id, parentId, value, schema) {
19
+ const root = list.filter((l) => l[parentId] == value);
20
+ const childrens = list.filter((l) => l[parentId] !== value);
21
+ return root.map((r) => {
22
+ return Object.assign(Object.assign({}, schemaToObj(r, schema)), { children: listToTree(childrens, id, parentId, r[id], schema) });
23
+ });
24
+ }
25
+ exports.listToTree = listToTree;
26
+ function enumToList(params) {
27
+ if ((0, type_1.isEmpty)(params))
28
+ return [];
29
+ const list = [];
30
+ for (const key in params) {
31
+ if ((0, type_1.isNum)(params[key]))
32
+ list.push([params[key], key]);
33
+ }
34
+ return list;
35
+ }
36
+ exports.enumToList = enumToList;
37
+ function enumToOptions(params = {}) {
38
+ return Object.entries(params).reduce((a, b) => {
39
+ return a.concat([{ label: b[0], value: b[1] }]);
40
+ }, []);
41
+ }
42
+ exports.enumToOptions = enumToOptions;
package/lib/type.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" />
2
+ import { BaseType } from "./interface";
3
+ export declare function isFunc(func: any): func is Function;
4
+ export declare function isArray(arr: any): arr is any[];
5
+ export declare function isObject(obj: any): boolean;
6
+ export declare function isString(str: any): str is string;
7
+ export declare function isBigint(big: any): big is bigint;
8
+ export declare function isBigInt64Array(big: any): big is bigint;
9
+ export declare function isBigUint64Array(big: any): big is bigint;
10
+ export declare function isBlob(data: any): data is Blob;
11
+ export declare function isBuffer(data: any): data is Buffer;
12
+ export declare function isFile(data: any): data is File;
13
+ export declare function isBoolean(bol: any): bol is boolean;
14
+ export declare function isSymbol(sbl: any): sbl is symbol;
15
+ export declare function isNum(num: any): num is number;
16
+ export declare function isDate(date: any): date is Date;
17
+ export declare function isRegExp(reg: any): reg is RegExp;
18
+ export declare function isUndefined(un?: any): un is undefined;
19
+ export declare function isNull(un?: any): un is null;
20
+ export declare function isPromise(obj?: any): obj is Promise<any>;
21
+ export declare function type(value: any): BaseType;
22
+ export declare function isEmpty(value: any): boolean;
package/lib/type.js ADDED
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmpty = exports.type = exports.isPromise = exports.isNull = exports.isUndefined = exports.isRegExp = exports.isDate = exports.isNum = exports.isSymbol = exports.isBoolean = exports.isFile = exports.isBuffer = exports.isBlob = exports.isBigUint64Array = exports.isBigInt64Array = exports.isBigint = exports.isString = exports.isObject = exports.isArray = exports.isFunc = void 0;
4
+ function isFunc(func) {
5
+ return Object.prototype.toString.call(func) === '[object Function]';
6
+ }
7
+ exports.isFunc = isFunc;
8
+ function isArray(arr) {
9
+ return Object.prototype.toString.call(arr) === '[object Array]';
10
+ }
11
+ exports.isArray = isArray;
12
+ function isObject(obj) {
13
+ return Object.prototype.toString.call(obj) === '[object Object]';
14
+ }
15
+ exports.isObject = isObject;
16
+ function isString(str) {
17
+ return Object.prototype.toString.call(str) === '[object String]';
18
+ }
19
+ exports.isString = isString;
20
+ function isBigint(big) {
21
+ return Object.prototype.toString.call(big) === '[object BigInt]';
22
+ }
23
+ exports.isBigint = isBigint;
24
+ function isBigInt64Array(big) {
25
+ return Object.prototype.toString.call(big) === '[object BigInt64Array]';
26
+ }
27
+ exports.isBigInt64Array = isBigInt64Array;
28
+ function isBigUint64Array(big) {
29
+ return Object.prototype.toString.call(big) === '[object BigUint64Array]';
30
+ }
31
+ exports.isBigUint64Array = isBigUint64Array;
32
+ function isBlob(data) {
33
+ return Object.prototype.toString.call(data) === '[object Blob]';
34
+ }
35
+ exports.isBlob = isBlob;
36
+ function isBuffer(data) {
37
+ return Object.prototype.toString.call(data) === '[object Buffer]';
38
+ }
39
+ exports.isBuffer = isBuffer;
40
+ function isFile(data) {
41
+ return Object.prototype.toString.call(data) === '[object File]';
42
+ }
43
+ exports.isFile = isFile;
44
+ function isBoolean(bol) {
45
+ return Object.prototype.toString.call(bol) === '[object Boolean]';
46
+ }
47
+ exports.isBoolean = isBoolean;
48
+ function isSymbol(sbl) {
49
+ return Object.prototype.toString.call(sbl) === '[object Symbol]';
50
+ }
51
+ exports.isSymbol = isSymbol;
52
+ function isNum(num) {
53
+ return Object.prototype.toString.call(num) === '[object Number]' && !isNaN(num);
54
+ }
55
+ exports.isNum = isNum;
56
+ function isDate(date) {
57
+ return Object.prototype.toString.call(date) === '[object Date]';
58
+ }
59
+ exports.isDate = isDate;
60
+ function isRegExp(reg) {
61
+ return Object.prototype.toString.call(reg) === '[object RegExp]';
62
+ }
63
+ exports.isRegExp = isRegExp;
64
+ function isUndefined(un) {
65
+ return Object.prototype.toString.call(un) === '[object Undefined]';
66
+ }
67
+ exports.isUndefined = isUndefined;
68
+ function isNull(un) {
69
+ return Object.prototype.toString.call(un) === '[object Null]';
70
+ }
71
+ exports.isNull = isNull;
72
+ function isPromise(obj) {
73
+ return Object.prototype.toString.call(obj) === '[object Promise]';
74
+ }
75
+ exports.isPromise = isPromise;
76
+ function type(value) {
77
+ if (isString(value))
78
+ return "string";
79
+ if (isNum(value))
80
+ return "number";
81
+ if (isArray(value))
82
+ return "array";
83
+ if (isObject(value))
84
+ return 'object';
85
+ if (isFunc(value))
86
+ return 'function';
87
+ if (isSymbol(value))
88
+ return 'symbol';
89
+ if (isUndefined(value))
90
+ return 'undefined';
91
+ if (isNull(value))
92
+ return "null";
93
+ if (isBigint(value))
94
+ return "bigint";
95
+ if (isBoolean(value))
96
+ return 'boolean';
97
+ return "undefined";
98
+ }
99
+ exports.type = type;
100
+ function isEmpty(value) {
101
+ if (isUndefined(value) || isNull(value))
102
+ return true;
103
+ if (isArray(value))
104
+ return !value.length;
105
+ if (isObject(value))
106
+ return !Object.keys(value).length;
107
+ if (isString(value))
108
+ return !value;
109
+ return false;
110
+ }
111
+ exports.isEmpty = isEmpty;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@soratani-code/samtools",
3
+ "version": "1.3.1",
4
+ "description": "",
5
+ "typings": "lib/index.d.ts",
6
+ "main": "lib/index.js",
7
+ "files": [
8
+ "lib"
9
+ ],
10
+ "publishConfig": {
11
+ "registry": "https://registry.npmjs.org",
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "test": "jest --verbose",
16
+ "build": "pnpm run build:lib && pnpm run build:dist",
17
+ "build:dist": "rollup --config rollup.config.js && rm -rf dist/lib",
18
+ "build:lib": "rm -rf lib && tsc -p ./tsconfig.json",
19
+ "changeset": "changeset",
20
+ "version": "changeset version && pnpm install"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/soratani/samtools.git"
25
+ },
26
+ "author": "",
27
+ "license": "MIT",
28
+ "bugs": {
29
+ "url": "https://github.com/soratani/samtools/issues"
30
+ },
31
+ "homepage": "https://github.com/soratani/samtools#readme",
32
+ "devDependencies": {
33
+ "@changesets/cli": "^2.26.1",
34
+ "@rollup/plugin-commonjs": "^25.0.7",
35
+ "@rollup/plugin-node-resolve": "^15.2.3",
36
+ "@rollup/plugin-terser": "^0.4.4",
37
+ "@rollup/plugin-typescript": "^11.1.6",
38
+ "@types/enzyme": "^3.10.13",
39
+ "@types/jest": "^29.5.2",
40
+ "@types/node": "^20.2.5",
41
+ "@types/platform": "^1.3.3",
42
+ "enzyme": "^3.11.0",
43
+ "jest": "^29.5.0",
44
+ "jest-enzyme": "^7.1.2",
45
+ "rollup": "^4.14.2",
46
+ "ts-jest": "^29.1.0",
47
+ "ts-node": "^10.9.1",
48
+ "tslib": "^2.6.2",
49
+ "typescript": "^4.8.3"
50
+ }
51
+ }