@hypernym/utils 3.2.0 → 3.2.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/README.md +168 -1
- package/dist/index.iife.js +1 -0
- package/dist/index.min.mjs +1 -0
- package/dist/index.umd.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
<pre align="center">pnpm add @hypernym/utils</pre>
|
|
16
16
|
|
|
17
|
-
<
|
|
17
|
+
<p align="center">
|
|
18
|
+
<strong>Hypernym Studio</strong>
|
|
19
|
+
</p>
|
|
18
20
|
|
|
19
21
|
<br>
|
|
20
22
|
|
|
@@ -26,14 +28,179 @@
|
|
|
26
28
|
|
|
27
29
|
## Usage
|
|
28
30
|
|
|
31
|
+
After installation, import `Hyperutils` into your project:
|
|
32
|
+
|
|
29
33
|
```ts
|
|
30
34
|
// ESM & TS
|
|
31
35
|
import { isNull, isString, ... } from '@hypernym/utils'
|
|
32
36
|
|
|
37
|
+
// ESM & TS
|
|
38
|
+
import { exists, copy, ... } from '@hypernym/utils/fs'
|
|
39
|
+
|
|
33
40
|
// Types
|
|
34
41
|
import type { IsAny, RequiredDeep, ... } from '@hypernym/utils'
|
|
35
42
|
```
|
|
36
43
|
|
|
44
|
+
## CDN
|
|
45
|
+
|
|
46
|
+
Here are some examples of how to integrate **Hyperutils** from a CDN via a script tag.
|
|
47
|
+
|
|
48
|
+
Also, it is possible to download files manually and serve them accordingly.
|
|
49
|
+
|
|
50
|
+
#### minified esm
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<script type="module">
|
|
54
|
+
import { isNull, isString, ... } from 'https://unpkg.com/@hypernym/utils/dist/index.min.mjs'
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### minified iief
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<script src="https://unpkg.com/@hypernym/utils/dist/index.iief.mjs"></script>
|
|
62
|
+
<script>
|
|
63
|
+
const { isNull, isString, ... } = Hyperutils
|
|
64
|
+
</script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### minified umd
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<script src="https://unpkg.com/@hypernym/utils/dist/index.umd.mjs"></script>
|
|
71
|
+
<script>
|
|
72
|
+
const { isNull, isString, ... } = Hyperutils
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## is
|
|
77
|
+
|
|
78
|
+
### isBrowser
|
|
79
|
+
|
|
80
|
+
Checks if the code is running in the browser.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { isBrowser } from '@hypernym/utils'
|
|
84
|
+
|
|
85
|
+
isBrowser // true
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### isNull
|
|
89
|
+
|
|
90
|
+
Returns a boolean if the given value is a `null`.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { isNull } from '@hypernym/utils'
|
|
94
|
+
|
|
95
|
+
isNull(null) // => true
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### isUndefined
|
|
99
|
+
|
|
100
|
+
Returns a boolean if the given value is a `undefined`.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { isUndefined } from '@hypernym/utils'
|
|
104
|
+
|
|
105
|
+
isUndefined(undefined) // => true
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### isString
|
|
109
|
+
|
|
110
|
+
Returns a boolean if the given value is a `string`.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { isString } from '@hypernym/utils'
|
|
114
|
+
|
|
115
|
+
isString('@hypernym/utils') // => true
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## fs
|
|
119
|
+
|
|
120
|
+
### exists
|
|
121
|
+
|
|
122
|
+
Checks if the file or directory exists.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { exists } from '@hypernym/utils/fs'
|
|
126
|
+
|
|
127
|
+
await exists('dir/file.ts') // => true
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### write
|
|
131
|
+
|
|
132
|
+
Writes data to a file recursively.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { write } from '@hypernym/utils/fs'
|
|
136
|
+
|
|
137
|
+
await write('dir/subdir/file.ts', `console.log('Hello World!')`)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### copy
|
|
141
|
+
|
|
142
|
+
Copies `files` or `directories` recursively.
|
|
143
|
+
|
|
144
|
+
Accepts a single source or a range of sources.
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { copy } from '@hypernym/utils/fs'
|
|
148
|
+
|
|
149
|
+
await copy('src/subdir/file.ts', './dist/subdir')
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### mkdir
|
|
153
|
+
|
|
154
|
+
Creates a `directory` recursively.
|
|
155
|
+
|
|
156
|
+
Accepts a single path or a range of paths.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import { mkdir } from '@hypernym/utils/fs'
|
|
160
|
+
|
|
161
|
+
await mkdir('src/subdir')
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### remove
|
|
165
|
+
|
|
166
|
+
Removes `files` and `directories` recursively.
|
|
167
|
+
|
|
168
|
+
Accepts a single path or a range of paths.
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
import { remove } from '@hypernym/utils/fs'
|
|
172
|
+
|
|
173
|
+
await remove('src/subdir/file.ts')
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Types
|
|
177
|
+
|
|
178
|
+
### PartialDeep
|
|
179
|
+
|
|
180
|
+
Constructs a type by recursively setting all properties as optional.
|
|
181
|
+
|
|
182
|
+
Use `Partial<T>` for one level.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
type PartialObject = PartialDeep<Object>
|
|
186
|
+
|
|
187
|
+
// Disables recursive mode for arrays and tuples.
|
|
188
|
+
type PartialObject = PartialDeep<Object, { arrays: false }>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### RequiredDeep
|
|
192
|
+
|
|
193
|
+
Constructs a type by recursively setting all properties as required.
|
|
194
|
+
|
|
195
|
+
Use `Required<T>` for one level.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
type RequiredObject = RequiredDeep<Object>
|
|
199
|
+
|
|
200
|
+
// Disables recursive mode for arrays and tuples.
|
|
201
|
+
type RequiredObject = RequiredDeep<Object, { arrays: false }>
|
|
202
|
+
```
|
|
203
|
+
|
|
37
204
|
## Community
|
|
38
205
|
|
|
39
206
|
Feel free to ask questions or share new ideas.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Hyperutils=function(t){"use strict";const u=()=>{},e=i=>Object.prototype.toString.call(i).slice(8,-1),N=typeof window<"u",s=i=>i===null,l=i=>typeof i>"u",n=i=>typeof i=="string",S=i=>n(i)&&i.trim().length===0,a=i=>typeof i=="boolean",b=i=>i===!0,r=i=>i===!1,c=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),d=i=>m(i)&&i.length===0,y=i=>e(i)==="Object",L=i=>y(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,M=i=>typeof i=="number"&&isNaN(i),O=i=>i instanceof RegExp,j=i=>i instanceof Map,k=i=>i instanceof WeakMap,v=i=>i instanceof Set,A=i=>i instanceof WeakSet,o=i=>e(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),f=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,W=i=>i instanceof URL,h=i=>i instanceof Error,C=i=>n(i)||c(i)||f(i)||a(i)||o(i)||s(i)||l(i),F=i=>i instanceof Element,U=i=>i instanceof HTMLElement,w=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,I=i=>E(i)&&i.length===0,g=i=>i instanceof HTMLCollection,T=i=>g(i)&&i.length===0;return t.isArray=m,t.isArrayEmpty=d,t.isBigInt=f,t.isBoolean=a,t.isBrowser=N,t.isDate=B,t.isElement=F,t.isError=h,t.isFalse=r,t.isFunction=H,t.isHtmlCollection=g,t.isHtmlCollectionEmpty=T,t.isHtmlElement=U,t.isInfinity=R,t.isMap=j,t.isNaNValue=M,t.isNodeList=E,t.isNodeListEmpty=I,t.isNull=s,t.isNumber=c,t.isObject=y,t.isObjectEmpty=L,t.isPrimitive=C,t.isRegExp=O,t.isSet=v,t.isString=n,t.isStringEmpty=S,t.isSvgElement=w,t.isSymbol=o,t.isTrue=b,t.isURL=W,t.isUndefined=l,t.isWeakMap=k,t.isWeakSet=A,t.noop=u,t.toString=e,t}({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=()=>{},i=e=>Object.prototype.toString.call(e).slice(8,-1),g=typeof window<"u",s=e=>e===null,n=e=>typeof e>"u",t=e=>typeof e=="string",E=e=>t(e)&&e.trim().length===0,o=e=>typeof e=="boolean",N=e=>e===!0,b=e=>e===!1,a=e=>typeof e=="number"&&!isNaN(e),l=e=>Array.isArray(e),u=e=>l(e)&&e.length===0,r=e=>i(e)==="Object",S=e=>r(e)&&Object.keys(e).length===0,L=e=>e instanceof Function,d=e=>typeof e=="number"&&isNaN(e),M=e=>e instanceof RegExp,O=e=>e instanceof Map,h=e=>e instanceof WeakMap,j=e=>e instanceof Set,k=e=>e instanceof WeakSet,c=e=>i(e)==="Symbol",H=e=>e instanceof Date&&!isNaN(e.valueOf()),f=e=>typeof e=="bigint",A=e=>e===1/0||e===-1/0,R=e=>e instanceof URL,W=e=>e instanceof Error,v=e=>t(e)||a(e)||f(e)||o(e)||c(e)||s(e)||n(e),w=e=>e instanceof Element,x=e=>e instanceof HTMLElement,B=e=>e instanceof SVGElement,p=e=>e instanceof NodeList,C=e=>p(e)&&e.length===0,m=e=>e instanceof HTMLCollection,F=e=>m(e)&&e.length===0;export{l as isArray,u as isArrayEmpty,f as isBigInt,o as isBoolean,g as isBrowser,H as isDate,w as isElement,W as isError,b as isFalse,L as isFunction,m as isHtmlCollection,F as isHtmlCollectionEmpty,x as isHtmlElement,A as isInfinity,O as isMap,d as isNaNValue,p as isNodeList,C as isNodeListEmpty,s as isNull,a as isNumber,r as isObject,S as isObjectEmpty,v as isPrimitive,M as isRegExp,j as isSet,t as isString,E as isStringEmpty,B as isSvgElement,c as isSymbol,N as isTrue,R as isURL,n as isUndefined,h as isWeakMap,k as isWeakSet,y as noop,i as toString};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(e=typeof globalThis<"u"?globalThis:e||self,n(e.Hyperutils={}))})(this,function(e){"use strict";const n=()=>{},t=i=>Object.prototype.toString.call(i).slice(8,-1),d=typeof window<"u",l=i=>i===null,a=i=>typeof i>"u",s=i=>typeof i=="string",N=i=>s(i)&&i.trim().length===0,o=i=>typeof i=="boolean",S=i=>i===!0,b=i=>i===!1,f=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),r=i=>m(i)&&i.length===0,c=i=>t(i)==="Object",L=i=>c(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,h=i=>typeof i=="number"&&isNaN(i),j=i=>i instanceof RegExp,M=i=>i instanceof Map,O=i=>i instanceof WeakMap,k=i=>i instanceof Set,A=i=>i instanceof WeakSet,y=i=>t(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),u=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,T=i=>i instanceof URL,W=i=>i instanceof Error,v=i=>s(i)||f(i)||u(i)||o(i)||y(i)||l(i)||a(i),C=i=>i instanceof Element,F=i=>i instanceof HTMLElement,U=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,w=i=>E(i)&&i.length===0,g=i=>i instanceof HTMLCollection,I=i=>g(i)&&i.length===0;e.isArray=m,e.isArrayEmpty=r,e.isBigInt=u,e.isBoolean=o,e.isBrowser=d,e.isDate=B,e.isElement=C,e.isError=W,e.isFalse=b,e.isFunction=H,e.isHtmlCollection=g,e.isHtmlCollectionEmpty=I,e.isHtmlElement=F,e.isInfinity=R,e.isMap=M,e.isNaNValue=h,e.isNodeList=E,e.isNodeListEmpty=w,e.isNull=l,e.isNumber=f,e.isObject=c,e.isObjectEmpty=L,e.isPrimitive=v,e.isRegExp=j,e.isSet=k,e.isString=s,e.isStringEmpty=N,e.isSvgElement=U,e.isSymbol=y,e.isTrue=S,e.isURL=T,e.isUndefined=a,e.isWeakMap=O,e.isWeakSet=A,e.noop=n,e.toString=t});
|