Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Utilities to generate JavaScript code.
# ✨ Auto-detect
npx nypm install knitwork
# npm
npm install knitwork
# yarn
yarn add knitwork
# pnpm
pnpm install knitwork
# bun
bun install knitwork
ESM (Node.js, Bun)
import {} from "knitwork";
CommonJS (Legacy Node.js)
const {} = require("knitwork");
CDN (Deno, Bun and Browsers)
import {} from "https://esm.sh/knitwork";
genDynamicImport(specifier, options)
Generate an ESM dynamic import()
statement.
genExport(specifier, exports?, options)
Generate an ESM export
statement.
genImport(specifier, imports?, options)
Generate an ESM import
statement.
Example:
genImport("pkg", "foo");
// ~> `import foo from "pkg";`
genImport("pkg", ["foo"]);
// ~> `import { foo } from "pkg";`
genImport("pkg", ["a", "b"]);
// ~> `import { a, b } from "pkg`;
genImport("pkg", [{ name: "default", as: "bar" }]);
// ~> `import { default as bar } from "pkg`;
genImport("pkg", [{ name: "foo", as: "bar" }]);
// ~> `import { foo as bar } from "pkg`;
genImport("pkg", "foo", { attributes: { type: "json" } });
// ~> `import foo from "pkg" with { type: "json" };
genExport("pkg", "foo");
// ~> `export foo from "pkg";`
genExport("pkg", ["a", "b"]);
// ~> `export { a, b } from "pkg";`
// export * as bar from "pkg"
genExport("pkg", { name: "*", as: "bar" });
// ~> `export * as bar from "pkg";`
genTypeImport(specifier, imports, options)
Generate an ESM import type
statement.
genArrayFromRaw(array, indent, options)
Serialize an array to a string.
Example:
genArrayFromRaw([1, 2, 3])
// ~> `[1, 2, 3]`
genObjectFromRaw(object, indent, options)
Serialize an object to a string.
Example:
genObjectFromValues({ foo: "bar", test: '() => import("pkg")' })
// ~> `{ foo: bar, test: () => import("pkg") }`
genObjectFromRawEntries(array, indent, options)
Serialize an array of key-value pairs to a string.
genObjectFromValues(obj, indent, options)
Serialize an object to a string.
Example:
genObjectFromValues({ foo: "bar" })
// ~> `{ foo: "bar" }`
escapeString(id)
Escape a string for use in a javascript string.
genSafeVariableName(name)
Generate a safe javascript variable name.
genString(input, options)
Generate a string with double or single quotes and handle escapes.
genAugmentation(specifier)
Generate typescript declare module
augmentation.
genInlineTypeImport(specifier, name, options)
Generate an typescript typeof import()
statement for default import.
genInterface(name, contents?, options, indent)
Generate typescript interface.
genTypeExport(specifier, imports, options)
Generate a typescript export type
statement.
genTypeObject(object, indent)
Generate typescript object type.
Published under the MIT license.
Made by @pi0, @danielroe and community 💛
🤖 auto updated with automd
v1.1.0
singleQuotes
option (#88)CODECOV_TOKEN
(c205569)FAQs
Utilities to generate JavaScript code.
The npm package knitwork receives a total of 413,852 weekly downloads. As such, knitwork popularity was classified as popular.
We found that knitwork demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.