Socket
Socket
Sign inDemoInstall

ts-viewers-core

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-viewers-core - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

7

dist/ts-viewers-core.d.ts

@@ -19,3 +19,10 @@ // Generated by dts-bundle-generator v5.9.0

}
export declare class DomUtils {
static htmlToElements(html: string): HTMLElement[];
static promisify<T>(callback: () => T): Promise<T>;
static runEmptyTimeout(): Promise<void>;
static downloadFile(blob: Blob, name?: string): void;
static loadImageAsync(url: string, revoke?: boolean): Promise<HTMLImageElement>;
}
export {};

72

dist/ts-viewers-core.esm.js

@@ -142,2 +142,72 @@ /**

export { ByteUtils };
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
class DomUtils {
static htmlToElements(html) {
const template = document.createElement("template");
template.innerHTML = html;
const nodes = [];
template.content.childNodes.forEach(x => {
if (x instanceof HTMLElement) {
nodes.push(x);
}
});
return nodes;
}
static promisify(callback) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(resolve => {
setTimeout(() => {
const result = callback();
resolve(result);
}, 0);
});
});
}
static runEmptyTimeout() {
return __awaiter(this, void 0, void 0, function* () {
yield this.promisify(() => undefined);
});
}
static downloadFile(blob, name) {
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.setAttribute("download", name);
link.href = url;
document.body.appendChild(link);
link.click();
link.remove();
setTimeout(() => URL.revokeObjectURL(url), 10000);
}
static loadImageAsync(url, revoke = false) {
return __awaiter(this, void 0, void 0, function* () {
const loadedImage = yield new Promise((resolve, reject) => {
const image = new Image();
image.onerror = (e) => {
if (revoke) {
URL.revokeObjectURL(url);
}
console.log(`Error while loading image: ${e}`);
resolve(null);
};
image.onload = () => {
if (revoke) {
URL.revokeObjectURL(url);
}
resolve(image);
};
image.src = url;
});
return loadedImage;
});
}
}
export { ByteUtils, DomUtils };

2

package.json
{
"name": "ts-viewers-core",
"version": "0.0.2",
"version": "0.0.3",
"description": "browser image viewer with basic painting support",

@@ -5,0 +5,0 @@ "module": "dist/ts-viewers-core.esm.js",

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