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

foreign-country-utils

v1.16.0

Published

// 初始化 const camera = new Camera({ containerCanvas: canvas, customVideoConfig: {}, // 自定义视频配置 customAudioConfig: {}, // 自定义声音配置 callBack: (e:Blob) => { // todo something } })

Downloads

329

Readme

如何使用?

安装、npm i foreign-country-utils / yarn add foreign-country-utils / pnpm add foreign-country-utils

Camera类可以使用摄像头(google内核),可以截图,录像,视频旋转,视频放大缩小等功能(放大缩小目前只支持容器为canvas)

Camera使用方法介绍

// 初始化
const camera = new Camera({
  containerCanvas: canvas,
  customVideoConfig: {}, // 自定义视频配置
  customAudioConfig: {}, // 自定义声音配置
  callBack: (e:Blob) => {
   // todo something
  }
})

camera.startVideoStream(); // 开启视频流
camera.startAudioStream(); // 开启语音流
camera.close(); // 停止画面但不停止录像
camera.show(); // 开始/继续展示画面
camera.startRecord(option:{}); // option:MediaRecorderOptions , 开始录制
camera.pauseRecord(isPause); // isPause:boolean(是否停止播放) , 暂停录制
camera.resumeRecord(); // 继续录制
camera.stopRecord(isClose); //isClose:boolean(是否关闭视频), 停止录制,可以关闭视频
camera.scale(ratio); //ratio:number = 1.1(和上一次相比放大倍数), 放大
camera.spin(angle); //angle:number = 45(和上一次旋转角度), 旋转

base64ToBuffer方法是将base64格式的文件转为buffer格式

base64ToBuffer介绍

const buffer = base64ToBuffer(base64String); base64String: string, base64字符串

createColor 随机生成16位的颜色

createColor 介绍

 const color = createColor(); 16位颜色,如: #ff5645

Http 发送ajax请求类

Http 介绍

 const http = new Http(baseURL,timeout);
 // isUrlencoded为是否使用content-type为application/x-www-form-urlencoded,默认为false
 const promiseObj = http.get<T>(url,data,{自定义配置},isUrlencoded) // get请求
 const promiseObj = http.post<T>(url,data,{自定义配置},isUrlencoded) // post请求
 const promiseObj = http.delete<T>(url,data,{自定义配置},isUrlencoded) // delete请求
 const promiseObj = http.put<T>(url,data,{自定义配置},isUrlencoded) // put请求
 const promiseObj = http.patch<T>(url,data,{自定义配置},isUrlencoded) // patch请求
 const promiseObj = http.upload<T>(url,data:FormData,{自定义配置}) // post请求,发送文件(formdata类型)
 const promiseObj = http.cancel((key?:string) // key为取消的是哪一次请求,不传则取消全部请求,并清空map

storage 方法是本地存储相关,可配置保存在session里面还是local里面

storage 介绍

 const {get,set} = storage();
 key: 取出的键名, toJson是否需要转成JSON对象,默认是,fromSession:是否从session取值,默认是
 const obj: Record<string, T> | string | null = get<T>(key: string, toJson = true, fromSession = true);
 key: 需要保存的键名, value要保存的值,toSession:是否存入session,默认是
 const result: boolean = set(key: string, value: string | boolean | number | null | Record<string, unknown>, toSession = true);