npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nce-utils

v0.2.16

Published

nce 项目公用的工具类

Downloads

4

Readme

nce-utils

nce 项目公用的工具类

地址

https://www.npmjs.com/package/nce-utils

安装

可以在浏览器中直接使用JavaScript文件 nce-utils.umd.js或通过npm方式安装。

浏览器直接加载

会在全局环境添加NceUtils对象:

<script src='path/to/nce-utils.umd.js'></script>

npm方式

npm install nce-utils -S

使用

示例

通过script标签方式引入:

<script>
    let date = NceUtils.dateTool.getFormatDate();
    console.info(date);
</script>

按需引入:

import { dateTool } from "nce-utils";
let date = dateTool.getForamtDate();
console.info(date);

模块说明

  • AES
    • generatekey随机生成指定数量的16进制key
    • encrypt加密
    • decrypt解密
  • AES128
    • uuid
    • decrypt
    • encrypt
    • getMixedText
    • getUnMixedText
  • dateTool 日期格式化
    • formatDate
    • getCurrentDayZeroTime
    • getDateStr
    • getCurrentTime
    • getFormatDate
  • featureMeta 地理要素
    • coordEach
    • coordReduce
    • propEach
    • propReduce
    • featureEach
    • featureReduce
    • coordAll
    • geomEach
    • geomReduce
    • feature
    • flattenEach
    • flattenReduce
  • loadTools
    • loadScript
    • loadScriptCode
    • loadScripts
    • removeScript
    • removeScripts
    • loadStyle
    • loadStyleCode
    • loadStyles
    • removeStyle
    • removeStyles
  • MapApiLoader 加载地图Api的类
    • tools
      • removeAllApi
      • load2dBaseApi
      • loadPluginApi
      • load3dBaseApi
      • loadCDNApi
      import { MapApiLoader } from "nce-utils";
      // 创建实例时需要传入url参数
      const mapApiLoader = new MapApiLoader({
            APP_JS_2D_API_URL: "",
            APP_JS_3D_API_URL: "",
            APP_JS_API_PLUGINS_URL: "",
            APP_JS_API_CDN_URL: "",
          });
      console.info(mapApiLoader.tools.loadPluginApi);
  • message
    • 封装element-ui的message
      // main.js
      import { message } from "nce-utils";
      Vue.prototype.$message = message;
      // 使用
      this.$message({
          message: res.msg,
          type: "success",
        });
  • storageUtil
    • setSession
    • getSession
    • removeSession
    • setLocal
    • getLocal
    • removeLocal
  • transformUnit
    • changeSizeUnit 字节单位向上转换
    • changeTimeUnit 秒数转为时长字符串
  • user 处理登录、退出登录、平台间跳转。

    • logout 退出登录,并跳转到登录页

    | 参数名称 | 说明 | 类型 | 默认值 | | - | - | - | - | | userkey |在localstorage中储存用户信息的key|string|"user"| |loginRoute|登录页的路由|string | "/nce-user/portalLogin"|

    user的所有方法中参数需要按顺序传入,有默认值的可不传,不再重复说明。
    • checkLogin 检查用户是否登录,未登录会自动跳转到登录页

    | 参数名称 | 说明 | 类型 | 默认值 | | - | - | - | - | | userkey |在localstorage中储存用户信息的key|string|"user"| |loginRoute|登录页的路由|string | "/nce-user/portalLogin"|

    • toLogin 跳转到登录页,建议使用checkLogin方法代替

    | 参数名称 | 说明 | 类型 | 默认值 | | - | - | - | - | | data |跳转到登录页时需要放在url中携带的数据|object| null | |loginRoute|登录页的路由|string | "/nce-user/portalLogin"|

    • getFromUrl 从url解析fromUrl,返回值:包含fromUrl的对象

    | 返回值说明 | | - | | 带有fromUrl的对象,如{ fromUrl: "www.xxx.com/data" }|

    • switchPlatform 切换平台

    | 参数名称 | 说明 | 类型 | 默认值 | | - | - | - | - | | route |切换的平台,不需要完整路径,域名后面的部分即可,如/nce-data |string|| |url|目标平台地址的协议+域名,如:http://cloud.app.ncloud.navinfo.com|string | window.location.protocol + "//" + window.location.host| | type | 打开浏览器窗口的方式 | "_self" 或 "_blank" | "_self" |

    • openUrl 打开页面

    | 参数名称 | 说明 | 类型 | 默认值 | | - | - | - | - | | url | 目标页面地址 |string|| | type | 打开浏览器窗口的方式 | "_self" 或 "_blank" | "_blank" |

  • uuidUtil
    • getUuid
    • getUuid_Eight
    • loadjscssfile
    • removejscssfile
    • createjscssfile
    • replacejscssfile
  • validator 校验
    • validateUsername
    • validateMail
    • validatePass
    • validateCheckPass
    • validatePhone
    • validateServicename
  • common
    • getMenuByRouter
    • joinParamToUrl
    • debounce 函数防抖