UNPKG

axis-snapshot

Version:

A Node.js library written in TypeScript capable of getting snapshots from Axis Communication cameras.

56 lines 2.43 kB
"use strict"; var __awaiter = (this && this.__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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Snapshot = void 0; const axis_core_1 = require("axis-core"); const Bmp_1 = require("./Bmp"); const Jpeg_1 = require("./Jpeg"); const fetch = (0, axis_core_1.fetchBuilder)(global.fetch); /** * Class responsible for getting snapshots from a camera. */ class Snapshot { /** * Initializes a new instance of the class. * @param connection The connection to the device. */ constructor(connection) { this.connection = connection; } /** * Takes a {link https://wikipedia.org/wiki/BMP_file_format|BMP} snapshot from the camera. * @param options The BMP snapshot options. * @param init The object containing any custom settings that you want to apply to the request. */ bmp(options, init) { return __awaiter(this, void 0, void 0, function* () { const req = new Bmp_1.BmpRequest(this.connection, options); const res = yield fetch(req, init); const blob = yield (0, Bmp_1.handleBmp)(res); return blob; }); } /** * Takes a {link https://en.wikipedia.org/wiki/JPEG|JPEG} snapshot from the camera. * @param options The Jpeg snapshot options. * @param init The object containing any custom settings that you want to apply to the request. */ jpeg(options, init) { return __awaiter(this, void 0, void 0, function* () { const req = new Jpeg_1.JpegRequest(this.connection, options); const res = yield fetch(req, init); const blob = yield (0, Jpeg_1.handleJpeg)(res); return blob; }); } } exports.Snapshot = Snapshot; //# sourceMappingURL=Snapshot.js.map