Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detection

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detection - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

6

lib/index.d.ts

@@ -22,3 +22,7 @@ /**

getIp(): Promise<string>;
testSpeed(): Promise<number>;
/**
* @param {string} resource 资源路径
* @param {number} size 资源大小 KB
*/
testSpeed(resource?: string, size?: number): Promise<number>;
[key: string]: any;

@@ -25,0 +29,0 @@ }

15

lib/index.js

@@ -138,13 +138,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

});
const testSpeed = () => __awaiter(this, void 0, void 0, function* () {
const testSpeed = (resource = 'https://zhiper-cdn.oss-cn-shanghai.aliyuncs.com/test-network-speed.jpg', size = 194.84) => __awaiter(this, void 0, void 0, function* () {
const testNetwork = () => {
return new Promise((resolve, reject) => {
let img = document.createElement('img');
img.src = 'https://zhiper-cdn.oss-cn-shanghai.aliyuncs.com/test-network-speed.jpg?_=' + Date.now();
let size = 194.84; // 图片大小为194KB
img.src = resource + '?_=' + Date.now();
img.onload = function (evt) {
resolve(size * 1000 / Math.ceil(evt.timeStamp));
};
img.onerror = function (evt) {
reject('download fail');
img.onerror = function () {
reject(`download fail`);
};

@@ -154,5 +153,5 @@ });

// 网速测试10次 取平均数
let size = 10;
let count = 10;
let rs = new Array();
for (let i = 0; i < size; i++) {
for (let i = 0; i < count; i++) {
try {

@@ -165,3 +164,3 @@ rs.push(yield testNetwork());

}
return rs.reduce((total, num) => total + num) / size;
return rs.reduce((total, num) => total + num) / count;
});

@@ -168,0 +167,0 @@ return {

{
"name": "detection",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc