cn-base-utils
TypeScript icon, indicating that this package has built-in type declarations

0.2.8 • Public • Published

cn-utils

使用场景

菜鸟组件的常用方法,不包含 lodash 和 ahooks

引用方式

import { isImage } from '@alife/cn-utils';

使用文档

getCnEnv

基于 hostname 和 script src 判断当前菜鸟运行环境,判断规范基于菜鸟通用域名规范

import { getCnEnv } from '@alife/cn-utils';

getCnEnv(cnEnvOptions: {
    /**
     * 待匹配的域名, 默认读取 window.location.hostname
     */
    hostname?: string;
    /**
     * 当前 script 的 src, 默认读取顺序
     * window.__CURRENT_SCRIPT_SRC__
     * window.document.currentScript.src
     */
    currentScriptSrc?: string;
}) => 'prod' | 'pre' | 'test' | 'daily';

isImage

通过文件路径判断是否为图片,图片后缀判断依据 image-extensions 进行

import { isImage } from '@alife/cn-utils';

isImage(fileUrl: string) => boolean;

downloadFile

import { downloadFile } from '@alife/cn-utils';

downloadFile(fileUrl: string) => boolean;

useGuid

生成 guid

import { useGuid } from '@alife/cn-utils';

useGuid(prefix: string) => string;

Readme

Keywords

Package Sidebar

Install

npm i cn-base-utils

Weekly Downloads

4

Version

0.2.8

License

GPL v3

Unpacked Size

76 kB

Total Files

45

Last publish

Collaborators

  • joshuasui
  • sr2318522