angular-slickgrid 4.1.4 → 4.2.2
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 +182 -180
- package/app/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +2 -2
- package/app/modules/angular-slickgrid/extensions/slickRowDetailView.d.ts +0 -2
- package/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +15 -12
- package/esm2020/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +1 -3
- package/esm2020/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +7 -10
- package/esm2020/app/modules/angular-slickgrid/services/angularUtil.service.mjs +3 -3
- package/esm2020/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +3 -3
- package/esm2020/app/modules/angular-slickgrid/services/container.service.mjs +3 -3
- package/esm2020/app/modules/angular-slickgrid/services/translater.service.mjs +3 -3
- package/fesm2015/angular-slickgrid.mjs +32 -34
- package/fesm2015/angular-slickgrid.mjs.map +1 -1
- package/fesm2020/angular-slickgrid.mjs +32 -34
- package/fesm2020/angular-slickgrid.mjs.map +1 -1
- package/{angular-slickgrid.d.ts → index.d.ts} +0 -0
- package/package.json +14 -15
- package/test/cypress/node_modules/@cypress/request/README.md +1038 -0
- package/test/cypress/node_modules/@cypress/xvfb/README.md +48 -0
- package/test/cypress/node_modules/@cypress/xvfb/node_modules/debug/README.md +437 -0
- package/test/cypress/node_modules/@types/node/README.md +16 -0
- package/test/cypress/node_modules/@types/sinonjs__fake-timers/README.md +16 -0
- package/test/cypress/node_modules/@types/sizzle/README.md +16 -0
- package/test/cypress/node_modules/@types/yauzl/README.md +16 -0
- package/test/cypress/node_modules/@types/yauzl/node_modules/@types/node/README.md +16 -0
- package/test/cypress/node_modules/aggregate-error/README.md +61 -0
- package/test/cypress/node_modules/ansi-colors/README.md +315 -0
- package/test/cypress/node_modules/ansi-escapes/README.md +245 -0
- package/test/cypress/node_modules/ansi-regex/README.md +78 -0
- package/test/cypress/node_modules/ansi-styles/README.md +152 -0
- package/test/cypress/node_modules/arch/README.md +71 -0
- package/test/cypress/node_modules/asn1/README.md +50 -0
- package/test/cypress/node_modules/assert-plus/README.md +162 -0
- package/test/cypress/node_modules/astral-regex/README.md +46 -0
- package/test/cypress/node_modules/async/README.md +60 -0
- package/test/cypress/node_modules/asynckit/README.md +233 -0
- package/test/cypress/node_modules/at-least-node/README.md +25 -0
- package/test/cypress/node_modules/aws-sign2/README.md +4 -0
- package/test/cypress/node_modules/aws4/README.md +183 -0
- package/test/cypress/node_modules/balanced-match/README.md +91 -0
- package/test/cypress/node_modules/base64-js/README.md +34 -0
- package/test/cypress/node_modules/bcrypt-pbkdf/README.md +45 -0
- package/test/cypress/node_modules/blob-util/README.md +623 -0
- package/test/cypress/node_modules/bluebird/README.md +57 -0
- package/test/cypress/node_modules/brace-expansion/README.md +129 -0
- package/test/cypress/node_modules/buffer/README.md +410 -0
- package/test/cypress/node_modules/buffer-crc32/README.md +47 -0
- package/test/cypress/node_modules/cachedir/README.md +27 -0
- package/test/cypress/node_modules/caseless/README.md +45 -0
- package/test/cypress/node_modules/chalk/README.md +293 -0
- package/test/cypress/node_modules/chalk/node_modules/supports-color/README.md +76 -0
- package/test/cypress/node_modules/check-more-types/README.md +952 -0
- package/test/cypress/node_modules/ci-info/README.md +114 -0
- package/test/cypress/node_modules/clean-stack/README.md +76 -0
- package/test/cypress/node_modules/cli-cursor/README.md +55 -0
- package/test/cypress/node_modules/cli-table3/README.md +218 -0
- package/test/cypress/node_modules/cli-truncate/README.md +139 -0
- package/test/cypress/node_modules/color-convert/README.md +68 -0
- package/test/cypress/node_modules/color-name/README.md +11 -0
- package/test/cypress/node_modules/colorette/README.md +102 -0
- package/test/cypress/node_modules/colors/README.md +221 -0
- package/test/cypress/node_modules/combined-stream/README.md +138 -0
- package/test/cypress/node_modules/commander/README.md +737 -0
- package/test/cypress/node_modules/common-tags/README.md +687 -0
- package/test/cypress/node_modules/core-util-is/README.md +3 -0
- package/test/cypress/node_modules/cross-spawn/README.md +96 -0
- package/test/cypress/node_modules/cypress/README.md +25 -0
- package/test/cypress/node_modules/cypress/mount-utils/README.md +14 -0
- package/test/cypress/node_modules/cypress/react/README.md +414 -0
- package/test/cypress/node_modules/cypress/vue/README.md +678 -0
- package/test/cypress/node_modules/cypress/vue2/README.md +693 -0
- package/test/cypress/node_modules/dashdash/README.md +574 -0
- package/test/cypress/node_modules/dayjs/README.md +128 -0
- package/test/cypress/node_modules/debug/README.md +455 -0
- package/test/cypress/node_modules/delayed-stream/README.md +141 -0
- package/test/cypress/node_modules/ecc-jsbn/README.md +8 -0
- package/test/cypress/node_modules/emoji-regex/README.md +73 -0
- package/test/cypress/node_modules/end-of-stream/README.md +54 -0
- package/test/cypress/node_modules/enquirer/README.md +1752 -0
- package/test/cypress/node_modules/escape-string-regexp/README.md +27 -0
- package/test/cypress/node_modules/eventemitter2/README.md +809 -0
- package/test/cypress/node_modules/execa/README.md +656 -0
- package/test/cypress/node_modules/executable/README.md +64 -0
- package/test/cypress/node_modules/extend/README.md +81 -0
- package/test/cypress/node_modules/extract-zip/README.md +57 -0
- package/test/cypress/node_modules/extract-zip/node_modules/debug/README.md +455 -0
- package/test/cypress/node_modules/extsprintf/README.md +46 -0
- package/test/cypress/node_modules/fd-slicer/README.md +199 -0
- package/test/cypress/node_modules/figures/README.md +139 -0
- package/test/cypress/node_modules/forever-agent/README.md +4 -0
- package/test/cypress/node_modules/form-data/README.md +234 -0
- package/test/cypress/node_modules/fs-extra/README.md +264 -0
- package/test/cypress/node_modules/fs.realpath/README.md +33 -0
- package/test/cypress/node_modules/get-stream/README.md +124 -0
- package/test/cypress/node_modules/getos/README.md +79 -0
- package/test/cypress/node_modules/getpass/README.md +32 -0
- package/test/cypress/node_modules/glob/README.md +375 -0
- package/test/cypress/node_modules/global-dirs/README.md +72 -0
- package/test/cypress/node_modules/graceful-fs/README.md +133 -0
- package/test/cypress/node_modules/has-flag/README.md +89 -0
- package/test/cypress/node_modules/http-signature/README.md +80 -0
- package/test/cypress/node_modules/human-signals/README.md +155 -0
- package/test/cypress/node_modules/ieee754/README.md +51 -0
- package/test/cypress/node_modules/indent-string/README.md +70 -0
- package/test/cypress/node_modules/inflight/README.md +37 -0
- package/test/cypress/node_modules/inherits/README.md +42 -0
- package/test/cypress/node_modules/ini/README.md +102 -0
- package/test/cypress/node_modules/is-ci/README.md +50 -0
- package/test/cypress/node_modules/is-fullwidth-code-point/README.md +39 -0
- package/test/cypress/node_modules/is-installed-globally/README.md +31 -0
- package/test/cypress/node_modules/is-path-inside/README.md +63 -0
- package/test/cypress/node_modules/is-stream/README.md +57 -0
- package/test/cypress/node_modules/is-typedarray/README.md +16 -0
- package/test/cypress/node_modules/isexe/README.md +51 -0
- package/test/cypress/node_modules/isstream/README.md +66 -0
- package/test/cypress/node_modules/jsbn/README.md +175 -0
- package/test/cypress/node_modules/json-schema/README.md +3 -0
- package/test/cypress/node_modules/json-stringify-safe/README.md +52 -0
- package/test/cypress/node_modules/jsonfile/README.md +205 -0
- package/test/cypress/node_modules/jsonfile/node_modules/universalify/README.md +76 -0
- package/test/cypress/node_modules/jsprim/README.md +287 -0
- package/test/cypress/node_modules/lazy-ass/README.md +269 -0
- package/test/cypress/node_modules/listr2/README.md +17 -0
- package/test/cypress/node_modules/lodash/README.md +39 -0
- package/test/cypress/node_modules/lodash.once/README.md +18 -0
- package/test/cypress/node_modules/log-symbols/README.md +51 -0
- package/test/cypress/node_modules/log-update/README.md +97 -0
- package/test/cypress/node_modules/log-update/node_modules/slice-ansi/README.md +66 -0
- package/test/cypress/node_modules/log-update/node_modules/wrap-ansi/README.md +97 -0
- package/test/cypress/node_modules/lru-cache/README.md +166 -0
- package/test/cypress/node_modules/merge-stream/README.md +78 -0
- package/test/cypress/node_modules/mime-db/README.md +102 -0
- package/test/cypress/node_modules/mime-types/README.md +123 -0
- package/test/cypress/node_modules/mimic-fn/README.md +69 -0
- package/test/cypress/node_modules/minimatch/README.md +209 -0
- package/test/cypress/node_modules/ms/README.md +60 -0
- package/test/cypress/node_modules/npm-run-path/README.md +115 -0
- package/test/cypress/node_modules/once/README.md +79 -0
- package/test/cypress/node_modules/onetime/README.md +94 -0
- package/test/cypress/node_modules/ospath/README.md +53 -0
- package/test/cypress/node_modules/p-map/README.md +89 -0
- package/test/cypress/node_modules/path-is-absolute/README.md +59 -0
- package/test/cypress/node_modules/path-key/README.md +61 -0
- package/test/cypress/node_modules/pend/README.md +41 -0
- package/test/cypress/node_modules/performance-now/README.md +30 -0
- package/test/cypress/node_modules/pify/README.md +119 -0
- package/test/cypress/node_modules/pretty-bytes/README.md +131 -0
- package/test/cypress/node_modules/proxy-from-env/README.md +131 -0
- package/test/cypress/node_modules/psl/README.md +215 -0
- package/test/cypress/node_modules/pump/README.md +65 -0
- package/test/cypress/node_modules/punycode/README.md +122 -0
- package/test/cypress/node_modules/qs/README.md +475 -0
- package/test/cypress/node_modules/request-progress/README.md +78 -0
- package/test/cypress/node_modules/restore-cursor/README.md +26 -0
- package/test/cypress/node_modules/rimraf/README.md +101 -0
- package/test/cypress/node_modules/rxjs/README.md +147 -0
- package/test/cypress/node_modules/rxjs/_esm2015/README.md +147 -0
- package/test/cypress/node_modules/rxjs/_esm5/README.md +147 -0
- package/test/cypress/node_modules/rxjs/src/README.md +147 -0
- package/test/cypress/node_modules/safe-buffer/README.md +584 -0
- package/test/cypress/node_modules/safer-buffer/README.md +156 -0
- package/test/cypress/node_modules/semver/README.md +566 -0
- package/test/cypress/node_modules/shebang-command/README.md +34 -0
- package/test/cypress/node_modules/shebang-regex/README.md +33 -0
- package/test/cypress/node_modules/signal-exit/README.md +39 -0
- package/test/cypress/node_modules/slice-ansi/README.md +72 -0
- package/test/cypress/node_modules/sshpk/README.md +804 -0
- package/test/cypress/node_modules/string-width/README.md +50 -0
- package/test/cypress/node_modules/strip-ansi/README.md +46 -0
- package/test/cypress/node_modules/strip-final-newline/README.md +30 -0
- package/test/cypress/node_modules/supports-color/README.md +77 -0
- package/test/cypress/node_modules/throttleit/README.md +32 -0
- package/test/cypress/node_modules/tmp/README.md +365 -0
- package/test/cypress/node_modules/tough-cookie/README.md +527 -0
- package/test/cypress/node_modules/tslib/README.md +142 -0
- package/test/cypress/node_modules/tunnel-agent/README.md +4 -0
- package/test/cypress/node_modules/tweetnacl/README.md +459 -0
- package/test/cypress/node_modules/type-fest/README.md +760 -0
- package/test/cypress/node_modules/universalify/README.md +76 -0
- package/test/cypress/node_modules/untildify/README.md +30 -0
- package/test/cypress/node_modules/uuid/README.md +505 -0
- package/test/cypress/node_modules/verror/README.md +528 -0
- package/test/cypress/node_modules/verror/node_modules/extsprintf/README.md +46 -0
- package/test/cypress/node_modules/which/README.md +54 -0
- package/test/cypress/node_modules/wrap-ansi/README.md +91 -0
- package/test/cypress/node_modules/wrappy/README.md +36 -0
- package/test/cypress/node_modules/yallist/README.md +204 -0
- package/test/cypress/node_modules/yauzl/README.md +658 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# fd-slicer
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/andrewrk/node-fd-slicer)
|
|
4
|
+
|
|
5
|
+
Safe `fs.ReadStream` and `fs.WriteStream` using the same fd.
|
|
6
|
+
|
|
7
|
+
Let's say that you want to perform a parallel upload of a file to a remote
|
|
8
|
+
server. To do this, we want to create multiple read streams. The first thing
|
|
9
|
+
you might think of is to use the `{start: 0, end: 0}` API of
|
|
10
|
+
`fs.createReadStream`. This gives you two choices:
|
|
11
|
+
|
|
12
|
+
0. Use the same file descriptor for all `fs.ReadStream` objects.
|
|
13
|
+
0. Open the file multiple times, resulting in a separate file descriptor
|
|
14
|
+
for each read stream.
|
|
15
|
+
|
|
16
|
+
Neither of these are acceptable options. The first one is a severe bug,
|
|
17
|
+
because the API docs for `fs.write` state:
|
|
18
|
+
|
|
19
|
+
> Note that it is unsafe to use `fs.write` multiple times on the same file
|
|
20
|
+
> without waiting for the callback. For this scenario, `fs.createWriteStream`
|
|
21
|
+
> is strongly recommended.
|
|
22
|
+
|
|
23
|
+
`fs.createWriteStream` will solve the problem if you only create one of them
|
|
24
|
+
for the file descriptor, but it will exhibit this unsafety if you create
|
|
25
|
+
multiple write streams per file descriptor.
|
|
26
|
+
|
|
27
|
+
The second option suffers from a race condition. For each additional time the
|
|
28
|
+
file is opened after the first, it is possible that the file is modified. So
|
|
29
|
+
in our parallel uploading example, we might upload a corrupt file that never
|
|
30
|
+
existed on the client's computer.
|
|
31
|
+
|
|
32
|
+
This module solves this problem by providing `createReadStream` and
|
|
33
|
+
`createWriteStream` that operate on a shared file descriptor and provides
|
|
34
|
+
the convenient stream API while still allowing slicing and dicing.
|
|
35
|
+
|
|
36
|
+
This module also gives you some additional power that the builtin
|
|
37
|
+
`fs.createWriteStream` do not give you. These features are:
|
|
38
|
+
|
|
39
|
+
* Emitting a 'progress' event on write.
|
|
40
|
+
* Ability to set a maximum size and emit an error if this size is exceeded.
|
|
41
|
+
* Ability to create an `FdSlicer` instance from a `Buffer`. This enables you
|
|
42
|
+
to provide API for handling files as well as buffers using the same API.
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
var fdSlicer = require('fd-slicer');
|
|
48
|
+
var fs = require('fs');
|
|
49
|
+
|
|
50
|
+
fs.open("file.txt", 'r', function(err, fd) {
|
|
51
|
+
if (err) throw err;
|
|
52
|
+
var slicer = fdSlicer.createFromFd(fd);
|
|
53
|
+
var firstPart = slicer.createReadStream({start: 0, end: 100});
|
|
54
|
+
var secondPart = slicer.createReadStream({start: 100});
|
|
55
|
+
var firstOut = fs.createWriteStream("first.txt");
|
|
56
|
+
var secondOut = fs.createWriteStream("second.txt");
|
|
57
|
+
firstPart.pipe(firstOut);
|
|
58
|
+
secondPart.pipe(secondOut);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You can also create from a buffer:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
var fdSlicer = require('fd-slicer');
|
|
66
|
+
var slicer = FdSlicer.createFromBuffer(someBuffer);
|
|
67
|
+
var firstPart = slicer.createReadStream({start: 0, end: 100});
|
|
68
|
+
var secondPart = slicer.createReadStream({start: 100});
|
|
69
|
+
var firstOut = fs.createWriteStream("first.txt");
|
|
70
|
+
var secondOut = fs.createWriteStream("second.txt");
|
|
71
|
+
firstPart.pipe(firstOut);
|
|
72
|
+
secondPart.pipe(secondOut);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## API Documentation
|
|
76
|
+
|
|
77
|
+
### fdSlicer.createFromFd(fd, [options])
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
var fdSlicer = require('fd-slicer');
|
|
81
|
+
fs.open("file.txt", 'r', function(err, fd) {
|
|
82
|
+
if (err) throw err;
|
|
83
|
+
var slicer = fdSlicer.createFromFd(fd);
|
|
84
|
+
// ...
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Make sure `fd` is a properly initialized file descriptor. If you want to
|
|
89
|
+
use `createReadStream` make sure you open it for reading and if you want
|
|
90
|
+
to use `createWriteStream` make sure you open it for writing.
|
|
91
|
+
|
|
92
|
+
`options` is an optional object which can contain:
|
|
93
|
+
|
|
94
|
+
* `autoClose` - if set to `true`, the file descriptor will be automatically
|
|
95
|
+
closed once the last stream that references it is closed. Defaults to
|
|
96
|
+
`false`. `ref()` and `unref()` can be used to increase or decrease the
|
|
97
|
+
reference count, respectively.
|
|
98
|
+
|
|
99
|
+
### fdSlicer.createFromBuffer(buffer, [options])
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
var fdSlicer = require('fd-slicer');
|
|
103
|
+
var slicer = fdSlicer.createFromBuffer(someBuffer);
|
|
104
|
+
// ...
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`options` is an optional object which can contain:
|
|
108
|
+
|
|
109
|
+
* `maxChunkSize` - A `Number` of bytes. see `createReadStream()`.
|
|
110
|
+
If falsey, defaults to unlimited.
|
|
111
|
+
|
|
112
|
+
#### Properties
|
|
113
|
+
|
|
114
|
+
##### fd
|
|
115
|
+
|
|
116
|
+
The file descriptor passed in. `undefined` if created from a buffer.
|
|
117
|
+
|
|
118
|
+
#### Methods
|
|
119
|
+
|
|
120
|
+
##### createReadStream(options)
|
|
121
|
+
|
|
122
|
+
Available `options`:
|
|
123
|
+
|
|
124
|
+
* `start` - Number. The offset into the file to start reading from. Defaults
|
|
125
|
+
to 0.
|
|
126
|
+
* `end` - Number. Exclusive upper bound offset into the file to stop reading
|
|
127
|
+
from.
|
|
128
|
+
* `highWaterMark` - Number. The maximum number of bytes to store in the
|
|
129
|
+
internal buffer before ceasing to read from the underlying resource.
|
|
130
|
+
Defaults to 16 KB.
|
|
131
|
+
* `encoding` - String. If specified, then buffers will be decoded to strings
|
|
132
|
+
using the specified encoding. Defaults to `null`.
|
|
133
|
+
|
|
134
|
+
The ReadableStream that this returns has these additional methods:
|
|
135
|
+
|
|
136
|
+
* `destroy(err)` - stop streaming. `err` is optional and is the error that
|
|
137
|
+
will be emitted in order to cause the streaming to stop. Defaults to
|
|
138
|
+
`new Error("stream destroyed")`.
|
|
139
|
+
|
|
140
|
+
If `maxChunkSize` was specified (see `createFromBuffer()`), the read stream
|
|
141
|
+
will provide chunks of at most that size. Normally, the read stream provides
|
|
142
|
+
the entire range requested in a single chunk, but this can cause performance
|
|
143
|
+
problems in some circumstances.
|
|
144
|
+
See [thejoshwolfe/yauzl#87](https://github.com/thejoshwolfe/yauzl/issues/87).
|
|
145
|
+
|
|
146
|
+
##### createWriteStream(options)
|
|
147
|
+
|
|
148
|
+
Available `options`:
|
|
149
|
+
|
|
150
|
+
* `start` - Number. The offset into the file to start writing to. Defaults to
|
|
151
|
+
0.
|
|
152
|
+
* `end` - Number. Exclusive upper bound offset into the file. If this offset
|
|
153
|
+
is reached, the write stream will emit an 'error' event and stop functioning.
|
|
154
|
+
In this situation, `err.code === 'ETOOBIG'`. Defaults to `Infinity`.
|
|
155
|
+
* `highWaterMark` - Number. Buffer level when `write()` starts returning
|
|
156
|
+
false. Defaults to 16KB.
|
|
157
|
+
* `decodeStrings` - Boolean. Whether or not to decode strings into Buffers
|
|
158
|
+
before passing them to` _write()`. Defaults to `true`.
|
|
159
|
+
|
|
160
|
+
The WritableStream that this returns has these additional methods:
|
|
161
|
+
|
|
162
|
+
* `destroy()` - stop streaming
|
|
163
|
+
|
|
164
|
+
And these additional properties:
|
|
165
|
+
|
|
166
|
+
* `bytesWritten` - number of bytes written to the stream
|
|
167
|
+
|
|
168
|
+
And these additional events:
|
|
169
|
+
|
|
170
|
+
* 'progress' - emitted when `bytesWritten` changes.
|
|
171
|
+
|
|
172
|
+
##### read(buffer, offset, length, position, callback)
|
|
173
|
+
|
|
174
|
+
Equivalent to `fs.read`, but with concurrency protection.
|
|
175
|
+
`callback` must be defined.
|
|
176
|
+
|
|
177
|
+
##### write(buffer, offset, length, position, callback)
|
|
178
|
+
|
|
179
|
+
Equivalent to `fs.write`, but with concurrency protection.
|
|
180
|
+
`callback` must be defined.
|
|
181
|
+
|
|
182
|
+
##### ref()
|
|
183
|
+
|
|
184
|
+
Increase the `autoClose` reference count by 1.
|
|
185
|
+
|
|
186
|
+
##### unref()
|
|
187
|
+
|
|
188
|
+
Decrease the `autoClose` reference count by 1.
|
|
189
|
+
|
|
190
|
+
#### Events
|
|
191
|
+
|
|
192
|
+
##### 'error'
|
|
193
|
+
|
|
194
|
+
Emitted if `fs.close` returns an error when auto closing.
|
|
195
|
+
|
|
196
|
+
##### 'close'
|
|
197
|
+
|
|
198
|
+
Emitted when fd-slicer closes the file descriptor due to `autoClose`. Never
|
|
199
|
+
emitted if created from a buffer.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# figures [](https://travis-ci.org/sindresorhus/figures)
|
|
2
|
+
|
|
3
|
+
> Unicode symbols with Windows CMD fallbacks
|
|
4
|
+
|
|
5
|
+
[](index.js)
|
|
6
|
+
|
|
7
|
+
[*and more...*](index.js)
|
|
8
|
+
|
|
9
|
+
Windows CMD only supports a [limited character set](http://en.wikipedia.org/wiki/Code_page_437).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
$ npm install figures
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
See the [source](index.js) for supported symbols.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const figures = require('figures');
|
|
23
|
+
|
|
24
|
+
console.log(figures('✔︎ check'));
|
|
25
|
+
// On non-Windows OSes: ✔︎ check
|
|
26
|
+
// On Windows: √ check
|
|
27
|
+
|
|
28
|
+
console.log(figures.tick);
|
|
29
|
+
// On non-Windows OSes: ✔︎
|
|
30
|
+
// On Windows: √
|
|
31
|
+
|
|
32
|
+
console.log(figures.main.tick);
|
|
33
|
+
// On all OSes: ✔︎
|
|
34
|
+
|
|
35
|
+
console.log(figures.windows.tick);
|
|
36
|
+
// On all OSes: √
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### figures(string)
|
|
42
|
+
|
|
43
|
+
Returns the input with replaced fallback Unicode symbols on Windows.
|
|
44
|
+
|
|
45
|
+
All the below [figures](#figures) are attached to the main export as shown in the example above.
|
|
46
|
+
|
|
47
|
+
#### string
|
|
48
|
+
|
|
49
|
+
Type: `string`
|
|
50
|
+
|
|
51
|
+
String where the Unicode symbols will be replaced with fallback symbols depending on the OS.
|
|
52
|
+
|
|
53
|
+
### figures.main
|
|
54
|
+
|
|
55
|
+
Symbols to use when not running on Windows.
|
|
56
|
+
|
|
57
|
+
### figures.windows
|
|
58
|
+
|
|
59
|
+
Symbols to use when running on Windows.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Figures
|
|
63
|
+
|
|
64
|
+
| Name | Non-Windows | Windows |
|
|
65
|
+
| ------------------ | :---------: | :-----: |
|
|
66
|
+
| tick | ✔ | √ |
|
|
67
|
+
| cross | ✖ | × |
|
|
68
|
+
| star | ★ | * |
|
|
69
|
+
| square | ▇ | █ |
|
|
70
|
+
| squareSmall | ◻ | [ ] |
|
|
71
|
+
| squareSmallFilled | ◼ | [█] |
|
|
72
|
+
| play | ▶ | ► |
|
|
73
|
+
| circle | ◯ | ( ) |
|
|
74
|
+
| circleFilled | ◉ | (*) |
|
|
75
|
+
| circleDotted | ◌ | ( ) |
|
|
76
|
+
| circleDouble | ◎ | ( ) |
|
|
77
|
+
| circleCircle | ⓞ | (○) |
|
|
78
|
+
| circleCross | ⓧ | (×) |
|
|
79
|
+
| circlePipe | Ⓘ | (│) |
|
|
80
|
+
| circleQuestionMark | ?⃝ | (?) |
|
|
81
|
+
| bullet | ● | * |
|
|
82
|
+
| dot | ․ | . |
|
|
83
|
+
| line | ─ | ─ |
|
|
84
|
+
| ellipsis | … | ... |
|
|
85
|
+
| pointer | ❯ | > |
|
|
86
|
+
| pointerSmall | › | » |
|
|
87
|
+
| info | ℹ | i |
|
|
88
|
+
| warning | ⚠ | ‼ |
|
|
89
|
+
| hamburger | ☰ | ≡ |
|
|
90
|
+
| smiley | ㋡ | ☺ |
|
|
91
|
+
| mustache | ෴ | ┌─┐ |
|
|
92
|
+
| heart | ♥ | ♥ |
|
|
93
|
+
| nodejs | ⬢ | ♦ |
|
|
94
|
+
| arrowUp | ↑ | ↑ |
|
|
95
|
+
| arrowDown | ↓ | ↓ |
|
|
96
|
+
| arrowLeft | ← | ← |
|
|
97
|
+
| arrowRight | → | → |
|
|
98
|
+
| radioOn | ◉ | (*) |
|
|
99
|
+
| radioOff | ◯ | ( ) |
|
|
100
|
+
| checkboxOn | ☒ | [×] |
|
|
101
|
+
| checkboxOff | ☐ | [ ] |
|
|
102
|
+
| checkboxCircleOn | ⓧ | (×) |
|
|
103
|
+
| checkboxCircleOff | Ⓘ | ( ) |
|
|
104
|
+
| questionMarkPrefix | ?⃝ | ? |
|
|
105
|
+
| oneHalf | ½ | 1/2 |
|
|
106
|
+
| oneThird | ⅓ | 1/3 |
|
|
107
|
+
| oneQuarter | ¼ | 1/4 |
|
|
108
|
+
| oneFifth | ⅕ | 1/5 |
|
|
109
|
+
| oneSixth | ⅙ | 1/6 |
|
|
110
|
+
| oneSeventh | ⅐ | 1/7 |
|
|
111
|
+
| oneEighth | ⅛ | 1/8 |
|
|
112
|
+
| oneNinth | ⅑ | 1/9 |
|
|
113
|
+
| oneTenth | ⅒ | 1/10 |
|
|
114
|
+
| twoThirds | ⅔ | 2/3 |
|
|
115
|
+
| twoFifths | ⅖ | 2/5 |
|
|
116
|
+
| threeQuarters | ¾ | 3/4 |
|
|
117
|
+
| threeFifths | ⅗ | 3/5 |
|
|
118
|
+
| threeEighths | ⅜ | 3/8 |
|
|
119
|
+
| fourFifths | ⅘ | 4/5 |
|
|
120
|
+
| fiveSixths | ⅚ | 5/6 |
|
|
121
|
+
| fiveEighths | ⅝ | 5/8 |
|
|
122
|
+
| sevenEighths | ⅞ | 7/8 |
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
## Related
|
|
126
|
+
|
|
127
|
+
- [log-symbols](https://github.com/sindresorhus/log-symbols) - Colored symbols for various log levels
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
<div align="center">
|
|
132
|
+
<b>
|
|
133
|
+
<a href="https://tidelift.com/subscription/pkg/npm-figures?utm_source=npm-figures&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
|
134
|
+
</b>
|
|
135
|
+
<br>
|
|
136
|
+
<sub>
|
|
137
|
+
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
|
138
|
+
</sub>
|
|
139
|
+
</div>
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data)
|
|
2
|
+
|
|
3
|
+
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
|
4
|
+
|
|
5
|
+
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
|
6
|
+
|
|
7
|
+
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
|
8
|
+
|
|
9
|
+
[](https://travis-ci.org/form-data/form-data)
|
|
10
|
+
[](https://travis-ci.org/form-data/form-data)
|
|
11
|
+
[](https://ci.appveyor.com/project/alexindigo/form-data)
|
|
12
|
+
|
|
13
|
+
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
|
14
|
+
[](https://david-dm.org/form-data/form-data)
|
|
15
|
+
[](https://www.bithound.io/github/form-data/form-data)
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install --save form-data
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
In this example we are constructing a form with 3 fields that contain a string,
|
|
26
|
+
a buffer and a file stream.
|
|
27
|
+
|
|
28
|
+
``` javascript
|
|
29
|
+
var FormData = require('form-data');
|
|
30
|
+
var fs = require('fs');
|
|
31
|
+
|
|
32
|
+
var form = new FormData();
|
|
33
|
+
form.append('my_field', 'my value');
|
|
34
|
+
form.append('my_buffer', new Buffer(10));
|
|
35
|
+
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Also you can use http-response stream:
|
|
39
|
+
|
|
40
|
+
``` javascript
|
|
41
|
+
var FormData = require('form-data');
|
|
42
|
+
var http = require('http');
|
|
43
|
+
|
|
44
|
+
var form = new FormData();
|
|
45
|
+
|
|
46
|
+
http.request('http://nodejs.org/images/logo.png', function(response) {
|
|
47
|
+
form.append('my_field', 'my value');
|
|
48
|
+
form.append('my_buffer', new Buffer(10));
|
|
49
|
+
form.append('my_logo', response);
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Or @mikeal's [request](https://github.com/request/request) stream:
|
|
54
|
+
|
|
55
|
+
``` javascript
|
|
56
|
+
var FormData = require('form-data');
|
|
57
|
+
var request = require('request');
|
|
58
|
+
|
|
59
|
+
var form = new FormData();
|
|
60
|
+
|
|
61
|
+
form.append('my_field', 'my value');
|
|
62
|
+
form.append('my_buffer', new Buffer(10));
|
|
63
|
+
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
|
67
|
+
|
|
68
|
+
``` javascript
|
|
69
|
+
form.submit('http://example.org/', function(err, res) {
|
|
70
|
+
// res – response object (http.IncomingMessage) //
|
|
71
|
+
res.resume();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
|
77
|
+
|
|
78
|
+
### Custom options
|
|
79
|
+
|
|
80
|
+
You can provide custom options, such as `maxDataSize`:
|
|
81
|
+
|
|
82
|
+
``` javascript
|
|
83
|
+
var FormData = require('form-data');
|
|
84
|
+
|
|
85
|
+
var form = new FormData({ maxDataSize: 20971520 });
|
|
86
|
+
form.append('my_field', 'my value');
|
|
87
|
+
form.append('my_buffer', /* something big */);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
|
91
|
+
|
|
92
|
+
### Alternative submission methods
|
|
93
|
+
|
|
94
|
+
You can use node's http client interface:
|
|
95
|
+
|
|
96
|
+
``` javascript
|
|
97
|
+
var http = require('http');
|
|
98
|
+
|
|
99
|
+
var request = http.request({
|
|
100
|
+
method: 'post',
|
|
101
|
+
host: 'example.org',
|
|
102
|
+
path: '/upload',
|
|
103
|
+
headers: form.getHeaders()
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
form.pipe(request);
|
|
107
|
+
|
|
108
|
+
request.on('response', function(res) {
|
|
109
|
+
console.log(res.statusCode);
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Or if you would prefer the `'Content-Length'` header to be set for you:
|
|
114
|
+
|
|
115
|
+
``` javascript
|
|
116
|
+
form.submit('example.org/upload', function(err, res) {
|
|
117
|
+
console.log(res.statusCode);
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
To use custom headers and pre-known length in parts:
|
|
122
|
+
|
|
123
|
+
``` javascript
|
|
124
|
+
var CRLF = '\r\n';
|
|
125
|
+
var form = new FormData();
|
|
126
|
+
|
|
127
|
+
var options = {
|
|
128
|
+
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
|
129
|
+
knownLength: 1
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
form.append('my_buffer', buffer, options);
|
|
133
|
+
|
|
134
|
+
form.submit('http://example.com/', function(err, res) {
|
|
135
|
+
if (err) throw err;
|
|
136
|
+
console.log('Done');
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
|
141
|
+
|
|
142
|
+
``` javascript
|
|
143
|
+
someModule.stream(function(err, stdout, stderr) {
|
|
144
|
+
if (err) throw err;
|
|
145
|
+
|
|
146
|
+
var form = new FormData();
|
|
147
|
+
|
|
148
|
+
form.append('file', stdout, {
|
|
149
|
+
filename: 'unicycle.jpg', // ... or:
|
|
150
|
+
filepath: 'photos/toys/unicycle.jpg',
|
|
151
|
+
contentType: 'image/jpeg',
|
|
152
|
+
knownLength: 19806
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
form.submit('http://example.com/', function(err, res) {
|
|
156
|
+
if (err) throw err;
|
|
157
|
+
console.log('Done');
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
|
163
|
+
|
|
164
|
+
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
|
165
|
+
|
|
166
|
+
``` javascript
|
|
167
|
+
form.submit({
|
|
168
|
+
host: 'example.com',
|
|
169
|
+
path: '/probably.php?extra=params',
|
|
170
|
+
auth: 'username:password'
|
|
171
|
+
}, function(err, res) {
|
|
172
|
+
console.log(res.statusCode);
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
|
177
|
+
|
|
178
|
+
``` javascript
|
|
179
|
+
form.submit({
|
|
180
|
+
host: 'example.com',
|
|
181
|
+
path: '/surelynot.php',
|
|
182
|
+
headers: {'x-test-header': 'test-header-value'}
|
|
183
|
+
}, function(err, res) {
|
|
184
|
+
console.log(res.statusCode);
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Integration with other libraries
|
|
189
|
+
|
|
190
|
+
#### Request
|
|
191
|
+
|
|
192
|
+
Form submission using [request](https://github.com/request/request):
|
|
193
|
+
|
|
194
|
+
```javascript
|
|
195
|
+
var formData = {
|
|
196
|
+
my_field: 'my_value',
|
|
197
|
+
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) {
|
|
201
|
+
if (err) {
|
|
202
|
+
return console.error('upload failed:', err);
|
|
203
|
+
}
|
|
204
|
+
console.log('Upload successful! Server responded with:', body);
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
|
209
|
+
|
|
210
|
+
#### node-fetch
|
|
211
|
+
|
|
212
|
+
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
var form = new FormData();
|
|
216
|
+
|
|
217
|
+
form.append('a', 1);
|
|
218
|
+
|
|
219
|
+
fetch('http://example.com', { method: 'POST', body: form })
|
|
220
|
+
.then(function(res) {
|
|
221
|
+
return res.json();
|
|
222
|
+
}).then(function(json) {
|
|
223
|
+
console.log(json);
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Notes
|
|
228
|
+
|
|
229
|
+
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
|
230
|
+
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
Form-Data is released under the [MIT](License) license.
|