Socket
Socket
Sign inDemoInstall

instascan-last

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

instascan-last - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

2

package.json
{
"name": "instascan-last",
"version": "2.0.4",
"version": "2.0.5",
"description": "Webcam-driven QR code scanner.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

function cameraName (label) {
function cameraName(label) {
let clean = label.replace(/\s*\([0-9a-f]+(:[0-9a-f]+)?\)\s*$/, '');

@@ -7,3 +7,3 @@ return clean || label || null;

class MediaError extends Error {
constructor (type) {
constructor(type) {
super(`Cannot access video stream (${type}).`);

@@ -15,3 +15,3 @@ this.type = type;

class Camera {
constructor (id, name) {
constructor(id, name) {
this.id = id;

@@ -22,3 +22,3 @@ this.name = name;

async start () {
async start() {
this._stream = await Camera._wrapErrors(async () => {

@@ -38,3 +38,3 @@ return await navigator.mediaDevices.getUserMedia({

stop () {
stop() {
if (!this._stream) {

@@ -51,3 +51,3 @@ return;

static async getCameras () {
static async getCameras() {
await this._ensureAccess();

@@ -62,11 +62,14 @@

static async _ensureAccess () {
return this._wrapErrors(async () => {
await navigator.mediaDevices.getUserMedia({video: true});
static async _ensureAccess() {
return await this._wrapErrors(async () => {
let access = await navigator.mediaDevices.getUserMedia({video: true});
for (let stream of access.getVideoTracks()) {
stream.stop();
}
});
}
static async _wrapErrors (fn) {
static async _wrapErrors(fn) {
try {
return fn();
return await fn();
} catch (e) {

@@ -73,0 +76,0 @@ if (e.name) {

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