form-data-encoder
Advanced tools
Comparing version 0.4.0 to 0.5.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const crypto_1 = require("crypto"); | ||
const nanoid_1 = require("nanoid"); | ||
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; | ||
const generate = nanoid_1.customAlphabet(alphabet, 16); | ||
/** | ||
* Generates a boundary string for FormData encoder. | ||
*/ | ||
const createBoundary = () => (`FormDataBoundary${crypto_1.randomBytes(16).toString("hex")}`); | ||
const createBoundary = () => `form-data-boundary-${generate()}`; | ||
exports.default = createBoundary; |
@@ -1,6 +0,8 @@ | ||
import { randomBytes } from "crypto"; | ||
import { customAlphabet } from "nanoid"; | ||
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; | ||
const generate = customAlphabet(alphabet, 16); | ||
/** | ||
* Generates a boundary string for FormData encoder. | ||
*/ | ||
const createBoundary = () => (`FormDataBoundary${randomBytes(16).toString("hex")}`); | ||
const createBoundary = () => `form-data-boundary-${generate()}`; | ||
export default createBoundary; |
{ | ||
"name": "form-data-encoder", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Encode FormData content into the multipart/form-data format", | ||
"repository": "octet-stream/form-data-encoder", | ||
"sideEffects": false, | ||
"keywords": [ | ||
@@ -62,3 +63,6 @@ "form-data", | ||
"web-streams-polyfill": "3.0.3" | ||
}, | ||
"dependencies": { | ||
"nanoid": "3.1.23" | ||
} | ||
} |
@@ -73,4 +73,2 @@ # form-data-encoder | ||
```js | ||
import {randomBytes} from "crypto" | ||
import {FormData} from "formdata-polyfill/esm-min.js" | ||
@@ -84,5 +82,3 @@ import {blobFrom} from "fetch-blob/from.js" | ||
async function toBlob(form) { | ||
// Note that Blob will lowercase the boundary string before assign it to Blob#type property. So you may need to bring your own boundary string, which must contain only lowercase alphabetic characters. | ||
const boundary = randomBytes(16).toString("hex") | ||
const encoder = new Encoder(form, boundary) | ||
const encoder = new Encoder(form) | ||
const chunks = [] | ||
@@ -89,0 +85,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
532
29809
1
240
+ Addednanoid@3.1.23
+ Addednanoid@3.1.23(transitive)