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

sailing-utils

v1.1.2

Published

``` npm i sailing-utils -S ```

Downloads

42

Readme

安装

npm i sailing-utils -S

使用

import sailing from 'sailing-utils'
sailing.auth.IdentificationCheck(id)

方法

  • 身份验证类-auth
IdentificationCheck(idCardNo:String):Boolean; 
//检测中国公民身份证是否规范 string
  • 时间类-time
formatSeconds(seconds:Number):String; 
//将秒数格式化为HH:mm:SS,61s => 00:01:01

getDateDiff(str:String)
//格式化时间
//getDateDiff('2021-06-10 18:14:02')=> 3分钟前/x小时前/x天前

formatEndTime(num:Number):String
/**
 * 获取指定的时间,返回数据格式 yyyy-MM-dd HH:mm:ss 类型 String
 * @param num 0代表今天,-3代表3天前,3代表3天后,以此类推
 * @returns {string}
 */

 formatEndTime(num:Number):String
 /**
 * 获取指定的时间,返回数据格式 yyyy-MM-dd HH:mm:ss 类型 String
 * @param num 0代表今天,-3代表3天前,3代表3天后,以此类推 ,末尾时分秒规定是 23:59:59
 * @returns {string}
 */


 getWeek.run(String):Object
 /**
 * 获取指定年份内存在的周及明细
 * @param String 2021
 * @returns {Object}{1:['2021-01-01','',...],2:[],3:[]....}
 */
  • 节点类-node
handleGetTreeExtent(node:Array<any>):Number
//广度遍历

handleGetTreeDeep(node:Array<any>):Number
//深度遍历
  • 数据类型-dataType
cloneDeep(val):T
//深拷贝

isPrimitive(val):Boolean
//是否为基本数据类型


isObject(val):Boolean
//是否为对象
  • 请求类-request
formatQuery(req:Object):Object
//格式化请求
// formatQuery({a:1,b:0,c:'',d:null,e:undefined}) => {a:1,b:0}

GetUrlQuery(urlStr:String):Object
//获取地址栏query
//GetUrlQuery('http://www.xx.com?a=1&b=2&c=3') => {a:1,b:2,c:3}
  • 字符串类-str
isChineseWord(str:String):Boolean; 
//检测字符串是否为全中文 string

sliceStrByDeLengh(str:String,length:Number,extra:String):String
//格式化(裁取)字符串
//sliceStrByDeLengh(abcdefg,5,'....') => abcd...

trim(String):String
//去掉开头和结尾的space, tab, form feed, and line feed (same as [\f\n\r\t\v]).
// str.replace(/(^\s*)|(\s*$)/g, "")
  • 文件类-file
dataURLtoFile(base64:string,filename:string):File
//base64转文件

Blob2File(blob:Blob,filename:string):File
//Bolb转file
  • 地图类-map
/坐标系转换
mapTransform:{
    bd09_to_gcj02: bd09_to_gcj02,
    gcj02_to_bd09: gcj02_to_bd09,
    wgs84_to_gcj02: wgs84_to_gcj02,
    gcj02_to_wgs84: gcj02_to_wgs84,
    wgs84_to_bd09:wgs84togcj02tobd09
}
WGS84坐标系:地球坐标系,国际通用坐标系
GCJ02坐标系:火星坐标系,WGS84坐标系加密后的坐标系;Google国内地图、高德、QQ地图 使用
BD09坐标系:百度坐标系,GCJ02坐标系加密后的坐标系
例:mapTransform.bd09_to_gcj02(lng,lat):[]
  • 交互类-interaction
debounce(Function, String):Function
// 防抖

_throttle(Function, String):Function
// 节流
  • 浏览器-browser
getUserIP(onNewIP):String
// 获取用户IP 信息

browser():Object
// 读取浏览器内核
  • 其他工具-tools
watermark(text:String,slogan?:String,options:Object):T;
    // text:水印文字,必填,
    // slogan:警示标语,必填,可传空字符串'',
    // options:水印设置,可选,默认值:{
    //     watermark_txt:settings,
    //     watermark_x:20,//水印起始位置x轴坐标
    //     watermark_y:20,//水印起始位置Y轴坐标
    //     watermark_rows:20,//水印行数
    //     watermark_cols:20,//水印列数
    //     watermark_x_space:20,//水印x轴间隔
    //     watermark_y_space:60,//水印y轴间隔
    //     watermark_color:'#000000',//水印字体颜色
    //     watermark_alpha:0.1,//水印透明度
    //     watermark_fontsize:'15px',//水印字体大小
    //     watermark_font:'微软雅黑',//水印字体
    //     watermark_width:300,//水印宽度
    //     watermark_height:80,//水印长度
    //     watermark_angle:15//水印倾斜度数
    // };