JSPM

  • Created
  • Published
  • Downloads 107
  • Score
    100M100P100Q58050F
  • License MIT

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nsuite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    nsuite

    Your missing nodejs development suite!

    If you develop with Node.js, you will find that there are many many many functions/packages you need to write/install across many projects. nsuite will make you feel more comfortable. After install with npm i -S nsuite, you will have all the following abilities at your hand.

    Env

    parseEnvFiles

    import { parseEnvFiles } from "nsuite/UtilsEnv.mjs";
    
    // note: the first value set for a varialble will win
    parseEnvFiles([
      path.resolve(process.cwd(), ".env.local"),
      path.resolve(process.cwd(), ".env"),
    ]);

    Path

    import { getDirname, joinPath } from "nsuite/UtilsPath.mjs";
    
    const __dirname = getDirname(import.meta.url);
    
    const targetPath = joinPath(__dirname, "../", "package.json");

    Promise

    withTimeout

    import { withTimeout } from "nsuite/UtilsPromise.mjs";
    const newPromise = withTimeout(promise);

    Log

    createLogger

    import { createLogger } from "nsuite/UtilsLog.mjs";
    export const logger = createLogger({
      filename: "./logs/application-%DATE%.log",
      zippedArchive: false,
      enableConsole: process.env.NODE_ENV !== "production",
    });

    File

    getSafeFileName

    Get a safe file name which you can use it in url after encodeURI handling.

    import { getSafeFileName } from "nsuite/UtilsFile.mjs";
    const safeFileName = getSafeFileName("测试有空格 和特殊符号 &.pdf");

    Captcha

    generateSvgCaptcha

    import { generateSvgCaptcha } from "nsuite/UtilsCaptcha.mjs";
    const { text, data } = await generateSvgCaptcha({
      width: 148,
      height: 48,
    });

    Text

    generateSummary

    Generate a summary of given text.

    import { generateSummary } from "nsuite/UtilsText.mjs";
    const summary = generateSummary({
      apiKey: "",
      baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
      model: "qwen-turbo",
      language: "English",
      maxWords: 200,
      content: "",
    });

    License

    This project is published under MIT license, which means you can use it in business projects for free. However, it would be better if you give this repo a star!