1 | ## @0x/utils
|
2 |
|
3 | Utils to be shared across 0x projects and packages
|
4 |
|
5 | ## Installation
|
6 |
|
7 | ```bash
|
8 | yarn add @0x/utils
|
9 | ```
|
10 |
|
11 | If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
|
12 |
|
13 | ```json
|
14 | "compilerOptions": {
|
15 | "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
|
16 | }
|
17 | ```
|
18 |
|
19 | ## Usage
|
20 |
|
21 | ```javascript
|
22 | import { addressUtils, bigNumberConfigs, classUtils, intervalUtils, promisify } from '@0x/utils';
|
23 | ```
|
24 |
|
25 | ## Troubleshooting
|
26 |
|
27 | If you are still seeing TS type errors complaining about missing DOM types such as `Response`:
|
28 |
|
29 | ```
|
30 | error TS2304: Cannot find name 'Response'.
|
31 | ```
|
32 |
|
33 | Then you need to explicitly add the `dom` lib to your compiler options in `tsconfig.json`. The `dom` library is included by default, but customizing the `lib` option can cause it to be dropped.
|
34 |
|
35 | ```
|
36 | "compilerOptions": {
|
37 | "lib": [..., "dom"],
|
38 | ```
|
39 |
|
40 | ## Contributing
|
41 |
|
42 | We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
|
43 |
|
44 | Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
45 |
|
46 | ### Install dependencies
|
47 |
|
48 | If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
|
49 |
|
50 | ```bash
|
51 | yarn config set workspaces-experimental true
|
52 | ```
|
53 |
|
54 | Then install dependencies
|
55 |
|
56 | ```bash
|
57 | yarn install
|
58 | ```
|
59 |
|
60 | ### Build
|
61 |
|
62 | To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
63 |
|
64 | ```bash
|
65 | PKG=@0x/utils yarn build
|
66 | ```
|
67 |
|
68 | Or continuously rebuild on change:
|
69 |
|
70 | ```bash
|
71 | PKG=@0x/utils yarn watch
|
72 | ```
|
73 |
|
74 | ### Clean
|
75 |
|
76 | ```bash
|
77 | yarn clean
|
78 | ```
|
79 |
|
80 | ### Lint
|
81 |
|
82 | ```bash
|
83 | yarn lint
|
84 | ```
|
85 |
|
\ | No newline at end of file |