🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

foreign-country-utils

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

foreign-country-utils

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

latest
npmnpm
Version
1.16.3
Version published
Weekly downloads
253
772.41%
Maintainers
1
Weekly downloads
 
Created
Source

如何使用?

安装、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);  

Keywords

摄像头

FAQs

Package last updated on 12 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts