fnclip
v2.1.0
Published
_description_
Readme
fnclip lets you copy and use only the functions you need, without installing entire libraries or worrying about dependencies.
QUICK START!
npx fnclip add pipeThis will add the pipe function to src/utils/fnclip/pipe.ts (or .js and .d.ts) and update src/utils/fnclip/index.ts to export it.
✨ Features
- Each single file under
src/functions/represents an independent function without any dependencies, you can copy and use it directly! - Provide a convenient cli for quick access (see below).
- Automatically detects whether you are using JavaScript or TypeScript, but you can specify manually if needed.
- The cli only support nodejs currently. But you can still just copy the file you want!
🚀 Usage
To check all details, please use --help!
Now have commands add, clear, list.
npx fnclip -h
npx fnclip add -hAdding functions
npx fnclip add pipeThis will add pipe to src/utils/fnclip/pipe.ts, and automatically add or update src/utils/fnclip/index.ts which contains export * from './pipe.ts'.
You can also use the following aliases: add, i, install.
npx fnclip i objectKeys objectMap nonNullableThis will add multiple functions to your project, which may be useful when you start a new project.
Changing target path
Add a function to a custom directory, for example:
npx fnclip add pipe --cwd packages/other --dir fnclipAbout index file
This will prevent adding/updating index file.
npx fnclip add pipe --no-indexOr specify a path of index file
npx fnclip add pipe --index-path ../fnclip.jsIt will specify index path in src/utils/fnclip.js instead of src/utils/fnclip/index.js
You can also omit extension and it will automatically add it for you --index-path ../fnclip
Typescript or Javascript
By default it will automatically choose ts or js. Or you can manually specify it:
npx fnclip add pipe --ts
npx fnclip add pipe --no-tsPre-configuration
You can use npx fnclip config to add a config file to your project:
<root>/fnclip.config.js
It looks like:
export default defineConfig({})The option can also be a function/async function. It supports all options which cli provided.
Or just prepare for it in package.json/scripts.
{
"scripts": {
"fnclip:add": "npx fnclip add --no-index --ts --dir src/utils/my-fn",
"fnclip:clear": "npx fnclip clear --dir src/utils/my-fn"
}
}Now you can run npm fnclip:add pipe to add functions easily.
... and more!
Please refer to npx fnclip --help npx fnclip <command> --help
npx fnclip add pipe
npx fnclip remove pipe
npx fnclip clear # remove all fnclip functions
npx fnclip list # list all installed functions
npx fnclip list --remote # list all fnclip functions