@keymanapp/kmc-keyboard-info
Version:
Keyman Developer .keyboard_info compiler
57 lines (55 loc) • 1.74 kB
JavaScript
/**
* ttfmeta
* Copyright(c) 2021-2022 Khen Solomon Lethil
* MIT Licensed
* v1.0.9
*/
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd51ff2e-4413-51bf-8ccb-e984073780c0")}catch(e){}}();
import * as fs from "fs";
import * as ttf from "./main.js";
/**
* @namespace
* @param {string | number | Buffer | URL} pathOrData
* @param {{(error:string|null,meta?:typeof ttf.result):void}} callback
*/
export function ttfInfo(pathOrData, callback) {
try {
if (pathOrData instanceof Buffer) {
ttf.ttfInfo(ttf.view(pathOrData), callback);
}
else {
fs.readFile(pathOrData, function (error, data) {
if (error) {
callback(error.message || error.toString());
}
else {
ttf.ttfInfo(ttf.view(data), callback);
}
});
}
}
catch ( /** @type {any}*/error) {
callback(error.message || error.toString());
}
}
/**
* @param {string | number | Buffer | URL} pathOrData
* @returns {Promise<typeof ttf.result>}
*/
export function promise(pathOrData) {
return new Promise(function (res, rej) {
ttfInfo(pathOrData, function (e, d) {
if (d) {
res(d);
}
else {
rej(e);
}
});
});
}
/** @namespace */
export const ttfMeta = { ttfInfo, promise };
export default ttfMeta;
//# sourceMappingURL=index.js.map
//# debugId=cd51ff2e-4413-51bf-8ccb-e984073780c0