0.2.8 • Published 3 years ago

cn-base-utils v0.2.8

Weekly downloads
-
License
GPL v3
Repository
gitlab
Last release
3 years ago

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;
0.2.7

3 years ago

0.2.6

3 years ago

0.2.8

3 years ago

0.2.5

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.2.0

3 years ago