New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fs-props

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-props - npm Package Compare versions

Comparing version

to
3.0.5

2

CHANGELOG.md

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

## v3.0.4
## v3.0.5

@@ -3,0 +3,0 @@ - Package build issue fix

import * as ffmpeg from 'fluent-ffmpeg';
import * as fs from "fs";
import { Options } from "humanize-duration";
import { AudioProps, ImageProps, Properties, StatsProps, VideoProps } from './types';

@@ -70,3 +69,3 @@ /**

*/
export declare const humanizeDuration: (durationInMilliSeconds?: number | string, options?: Options) => string;
export declare const humanizeDuration: (durationInMilliSeconds?: number | string, options?: object) => string;
/**

@@ -73,0 +72,0 @@ * It returns an promise object with all the properties of the file or folder,

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

"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.videoProps=exports.timeStampSync=exports.timeStamp=exports.statSync=exports.stat=exports.props=exports.imageProps=exports.humanizeDuration=exports.ffprobePromise=exports.deepStatSync=exports.deepStat=exports.deepProps=exports.convertBytes=exports.audioProps=void 0;var ExifReader=_interopRequireWildcard(require("exifreader")),ffmpeg=_interopRequireWildcard(require("fluent-ffmpeg")),fs=_interopRequireWildcard(require("fs")),fsProm=_interopRequireWildcard(require("fs/promises")),_humanizeDuration=_interopRequireDefault(require("humanize-duration")),_imageSize=_interopRequireDefault(require("image-size")),mime=_interopRequireWildcard(require("mime")),_moment=_interopRequireDefault(require("moment")),path=_interopRequireWildcard(require("path"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,o){var a=t&&t.prototype instanceof d?t:d,i=Object.create(a.prototype),c=new R(o||[]);return n(i,"_invoke",{value:x(e,r,c)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var p={};function d(){}function f(){}function m(){}var v={};u(v,a,(function(){return this}));var h=Object.getPrototypeOf,y=h&&h(h(j([])));y&&y!==t&&r.call(y,a)&&(v=y);var g=m.prototype=d.prototype=Object.create(v);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function o(n,a,i,c){var u=l(e[n],e,a);if("throw"!==u.type){var s=u.arg,p=s.value;return p&&"object"==_typeof(p)&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){o("next",e,i,c)}),(function(e){o("throw",e,i,c)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return o("throw",e,i,c)}))}c(u.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function x(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return L()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=w(i,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return f.prototype=m,n(g,"constructor",{value:m,configurable:!0}),n(m,"constructor",{value:f,configurable:!0}),f.displayName=u(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(_.prototype),u(_.prototype,i,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new _(s(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),u(g,c,"Generator"),u(g,a,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=j,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}var ffprobe=require("@ffprobe-installer/ffprobe");ffmpeg.setFfprobePath(ffprobe.path);var getSizeAndContains=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.stat(t);case 2:if(!(r=e.sent).isFile()){e.next=5;break}return e.abrupt("return",{size:r.size,contains:void 0});case 5:return n={files:0,folders:0},o=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,a,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.readdir(t,{withFileTypes:!0});case 2:return r=e.sent,a=r.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var a,i,c,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=path.join(t,r.name),e.next=3,fsProm.stat(a);case 3:if(i=e.sent,c=i.size,!r.isFile()){e.next=8;break}return n.files++,e.abrupt("return",[c]);case 8:return n.folders++,e.next=12,o(a);case 12:return u=e.sent,e.abrupt("return",[c].concat(_toConsumableArray(u)));case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=6,Promise.all(a);case 6:return i=e.sent,e.abrupt("return",i.flat(1/0).filter(Boolean));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=9,o(t);case 9:return a=e.sent.reduce((function(e,t){return e+t}),0),e.abrupt("return",{size:a,contains:n});case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getSizeAndContainsSync=function(e){var t=fs.statSync(e);if(t.isFile())return{size:t.size,contains:void 0};var r={files:0,folders:0},n=function e(t){return fs.readdirSync(t,{withFileTypes:!0}).map((function(n){var o=path.join(t,n.name),a=fs.statSync(o).size;if(n.isFile())return r.files++,[a];r.folders++;var i=e(o);return[a].concat(_toConsumableArray(i))})).flat(1/0).filter(Boolean)}(e).reduce((function(e,t){return e+t}),0);return{size:n,contains:r}},timeStamp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h,y,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,fsProm.stat(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return r=e.t0,n=r.birthtime,o=r.ctime,a=r.mtime,i=r.atime,c=r.birthtime.toLocaleString(),u=r.ctime.toLocaleString(),s=r.mtime.toLocaleString(),l=r.atime.toLocaleString(),p=(0,_moment.default)(r.birthtime).fromNow(),d=(0,_moment.default)(r.ctime).fromNow(),f=(0,_moment.default)(r.mtime).fromNow(),m=(0,_moment.default)(r.atime).fromNow(),v=r.birthtimeMs,h=r.ctimeMs,y=r.mtimeMs,g=r.atimeMs,e.abrupt("return",{created:n,changed:o,modified:a,accessed:i,createdMs:v,changedMs:h,modifiedMs:y,accessedMs:g,createdLocal:c,changedLocal:u,modifiedLocal:s,accessedLocal:l,createdRelative:p,changedRelative:d,modifiedRelative:f,accessedRelative:m});case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.timeStamp=timeStamp;var timeStampSync=function(e){var t="string"==typeof e?fs.statSync(e):e,r=t.birthtime,n=t.ctime,o=t.mtime,a=t.atime,i=t.birthtime.toLocaleString(),c=t.ctime.toLocaleString(),u=t.mtime.toLocaleString(),s=t.atime.toLocaleString(),l=(0,_moment.default)(t.birthtime).fromNow(),p=(0,_moment.default)(t.ctime).fromNow(),d=(0,_moment.default)(t.mtime).fromNow(),f=(0,_moment.default)(t.atime).fromNow();return{created:r,changed:n,modified:o,accessed:a,createdMs:t.birthtimeMs,changedMs:t.ctimeMs,modifiedMs:t.mtimeMs,accessedMs:t.atimeMs,createdLocal:i,changedLocal:c,modifiedLocal:u,accessedLocal:s,createdRelative:l,changedRelative:p,modifiedRelative:d,accessedRelative:f}};exports.timeStampSync=timeStampSync;var convertBytes=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["Bytes","KB","MB","GB","TB"],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(0===e)return"0 bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return 0===n?e+" "+t[n]:(e/Math.pow(1024,n)).toFixed(2)+" "+t[n]+(r?" (".concat(e," bytes)"):"")};exports.convertBytes=convertBytes;var ffprobePromise=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,r){return ffmpeg.ffprobe(t,(function(t,n){t?r(t):e(n)}))}));case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.ffprobePromise=ffprobePromise;var humanizeDuration=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==e){var r="number"==typeof e?e:parseFloat(e);return(0,_humanizeDuration.default)(r,_objectSpread({maxDecimalPoints:2},t))}};exports.humanizeDuration=humanizeDuration;var getImageDimensions=function(e){var t,r,n,o,a,i,c,u,s,l,p=null!==(t=null!==(r=null===(n=e.ImageWidth)||void 0===n?void 0:n.value)&&void 0!==r?r:null===(o=e["Image Width"])||void 0===o?void 0:o.description)&&void 0!==t?t:null===(a=e.PixelXDimension)||void 0===a?void 0:a.value,d=null!==(i=null!==(c=null===(u=e.ImageLength)||void 0===u?void 0:u.value)&&void 0!==c?c:null===(s=e["Image Height"])||void 0===s?void 0:s.description)&&void 0!==i?i:null===(l=e.PixelYDimension)||void 0===l?void 0:l.value;return{dimensions:void 0!==p&&void 0!==d?"".concat(p," x ").concat(d," pixels"):void 0,width:p,height:d}},getImageResolution=function(e){var t,r,n=parseInt((null===(t=e.XResolution)||void 0===t?void 0:t.description)||"0",10),o=parseInt((null===(r=e.YResolution)||void 0===r?void 0:r.description)||"0",10);return{resolution:void 0!==n&&void 0!==o?"".concat(n," x ").concat(o," Dpi"):void 0,xResolution:n,yResolution:o}},stat=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.stat(t);case 2:if(r=e.sent,n=r.isFile(),o=path.basename(t),a=n?path.extname(t):void 0,i=path.basename(t,a),c=!r.isFile(),u=t.replace(/\\/g,"/"),s=path.dirname(t).replace(/\\/g,"/"),l=n?"File":"Folder",p=n?mime.getType(t)||"[unknown]":void 0,!n){e.next=16;break}e.t0=[],e.next=19;break;case 16:return e.next=18,fsProm.readdir(t,{withFileTypes:!0});case 18:e.t0=e.sent;case 19:return d=e.t0,e.next=22,timeStamp(r);case 22:return f=e.sent,e.next=25,getSizeAndContains(t);case 25:return m=e.sent,v=m.size,h=m.contains,e.abrupt("return",_objectSpread(_objectSpread({fileName:o,baseName:i,extension:a,directory:s,location:u,size:v,sizePretty:convertBytes(v),type:l,mimeType:p,isFile:n,isDirectory:c,children:d,containedFiles:null==h?void 0:h.files,containedFolders:null==h?void 0:h.folders,contains:h,containsPretty:h?"".concat(h.files," Files, ").concat(h.folders," Folders"):void 0},f),{},{stats:r}));case 29:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.stat=stat;var statSync=function(e){var t=fs.statSync(e),r=t.isFile(),n=path.basename(e),o=r?path.extname(e):void 0,a=path.basename(e,o),i=!t.isFile(),c=e.replace(/\\/g,"/"),u=path.dirname(e).replace(/\\/g,"/"),s=r?"File":"Folder",l=r?mime.getType(e)||"[unknown]":void 0,p=r?[]:fs.readdirSync(e,{withFileTypes:!0}),d=timeStampSync(t),f=getSizeAndContainsSync(e),m=f.size,v=f.contains;return _objectSpread(_objectSpread({fileName:n,baseName:a,extension:o,directory:u,location:c,size:m,sizePretty:convertBytes(m),type:s,mimeType:l,isFile:r,isDirectory:i,children:p,containedFiles:null==v?void 0:v.files,containedFolders:null==v?void 0:v.folders,contains:v,containsPretty:v?"".concat(v.files," Files, ").concat(v.folders," Folders"):void 0},d),{},{stats:t})};exports.statSync=statSync;var deepStat=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,stat(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",[]);case 5:if(!r.isFile){e.next=7;break}return e.abrupt("return",[r]);case 7:return n=r.children.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=path.join(t,r.name),e.next=3,deepStat(n);case 3:return o=e.sent,e.abrupt("return",o);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=10,Promise.all(n);case 10:return o=e.sent,e.abrupt("return",[r].concat(_toConsumableArray(o.flat(1/0).filter(Boolean))));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.deepStat=deepStat;var deepStatSync=function e(t){var r=statSync(t);if(!r)return[];if(r.isFile)return[r];var n=r.children.map((function(r){var n=path.join(t,r.name);return e(n)}));return[r].concat(_toConsumableArray(n.flat(1/0).filter(Boolean)))};exports.deepStatSync=deepStatSync;var imageProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h,y,g,b,_,x,w,S,P;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ExifReader.load(t);case 3:return S=e.sent,e.abrupt("return",_objectSpread(_objectSpread(_objectSpread({isImage:!0},getImageDimensions(S)),getImageResolution(S)),{},{orientation:null===(r=S.Orientation)||void 0===r?void 0:r.description,bitDepth:null!==(n=null!==(o=null!==(a=null===(i=S["Bit Depth"])||void 0===i?void 0:i.description)&&void 0!==a?a:null===(c=S.BitDepth)||void 0===c?void 0:c.description)&&void 0!==o?o:null===(u=S["Bits Per Sample"])||void 0===u?void 0:u.description)&&void 0!==n?n:null===(s=S.BitsPerSample)||void 0===s?void 0:s.description,colorType:null!==(l=null!==(p=null!==(d=null===(f=S["Color Type"])||void 0===f?void 0:f.description)&&void 0!==d?d:null===(m=S.ColorType)||void 0===m?void 0:m.description)&&void 0!==p?p:null===(v=S["Color Space"])||void 0===v?void 0:v.description)&&void 0!==l?l:null===(h=S.ColorSpace)||void 0===h?void 0:h.description,subSampling:null!==(y=null===(g=S.Subsampling)||void 0===g?void 0:g.description)&&void 0!==y?y:null===(b=S.YCbCrSubSampling)||void 0===b?void 0:b.description,compression:null===(_=S.Compression)||void 0===_?void 0:_.description,filter:null===(x=S.Filter)||void 0===x?void 0:x.description,resourceURL:null===(w=S.ResourceURL)||void 0===w?void 0:w.description,metaData:S}));case 7:return e.prev=7,e.t0=e.catch(0),console.error(e.t0.message),e.prev=10,P=(0,_imageSize.default)(t),e.abrupt("return",{isImage:!0,dimensions:void 0!==P.width&&void 0!==P.height?"".concat(P.width," x ").concat(P.height," pixels"):void 0,height:P.height,width:P.width,orientation:P.orientation,metaData:P});case 15:return e.prev=15,e.t1=e.catch(10),console.error(e.t1.message),e.abrupt("return",{});case 19:case"end":return e.stop()}}),e,null,[[0,7],[10,15]])})));return function(t){return e.apply(this,arguments)}}();exports.imageProps=imageProps;var audioProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ffprobePromise(t);case 3:return n=e.sent,o=n.streams.find((function(e){return"audio"===e.codec_type}))||{},a=n.format.tags||{},i=null!==(r=n.format.duration)&&void 0!==r?r:0,u=humanizeDuration(c=1e3*i,{maxDecimalPoints:2}),s=parseInt(o.bit_rate||"0",10),l=s?convertBytes(s,["bps","kbps","mbps"],!1):void 0,p=void 0!==o.channels?o.channel_layout?"".concat(o.channels," (").concat(o.channel_layout,")"):o.channels:void 0,e.abrupt("return",{isAudio:!0,title:a.title,album:a.album,artist:a.artist,composer:a.composer,genre:a.genre,year:a.date,duration:i,durationMs:c,durationPretty:u,bitRate:s,bitRatePretty:l,channels:p,metaData:n});case 15:return e.prev=15,e.t0=e.catch(0),console.error(e.t0.message),e.abrupt("return",{});case 19:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}();exports.audioProps=audioProps;var videoProps=function(){var _ref17=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(videoPath){var _metaData$format$dura2,metaData,video,dimensions,duration,durationMs,durationPretty,bitRate,bitRatePretty,frameRate,frameRatePretty;return _regeneratorRuntime().wrap((function _callee11$(_context11){for(;;)switch(_context11.prev=_context11.next){case 0:return _context11.prev=0,_context11.next=3,ffprobePromise(videoPath);case 3:return metaData=_context11.sent,video=metaData.streams.find((function(e){return"video"===e.codec_type}))||{},dimensions="".concat(video.width," x ").concat(video.height," pixels"),duration=null!==(_metaData$format$dura2=metaData.format.duration)&&void 0!==_metaData$format$dura2?_metaData$format$dura2:0,durationMs=1e3*duration,durationPretty=humanizeDuration(durationMs,{maxDecimalPoints:2}),bitRate=parseInt(video.bit_rate||"0",10),bitRatePretty=bitRate?convertBytes(bitRate,["bps","kbps","mbps"],!1):void 0,frameRate=video.r_frame_rate?parseFloat(eval(video.r_frame_rate||"0").toFixed(2)):void 0,frameRatePretty=frameRate?"".concat(eval(video.r_frame_rate||"0").toFixed(2)," fps"):void 0,_context11.abrupt("return",{isVideo:!0,dimensions:dimensions,width:video.width,height:video.height,resolution:dimensions,duration:duration,durationMs:durationMs,durationPretty:durationPretty,bitRate:bitRate,bitRatePretty:bitRatePretty,frameRate:frameRate,frameRatePretty:frameRatePretty,framesPerSecond:frameRatePretty,ratio:video.display_aspect_ratio,metaData:metaData});case 16:return _context11.prev=16,_context11.t0=_context11.catch(0),console.error(_context11.t0.message),_context11.abrupt("return",{});case 20:case"end":return _context11.stop()}}),_callee11,null,[[0,16]])})));return function(e){return _ref17.apply(this,arguments)}}();exports.videoProps=videoProps;var props=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,stat(t);case 2:if(a=e.sent,null===(r=a.mimeType)||void 0===r||!r.includes("image")){e.next=9;break}return e.next=6,imageProps(t);case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0={};case 10:if(i=e.t0,null===(n=a.mimeType)||void 0===n||!n.includes("audio")){e.next=17;break}return e.next=14,audioProps(t);case 14:e.t1=e.sent,e.next=18;break;case 17:e.t1={};case 18:if(c=e.t1,null===(o=a.mimeType)||void 0===o||!o.includes("video")){e.next=25;break}return e.next=22,videoProps(t);case 22:e.t2=e.sent,e.next=26;break;case 25:e.t2={};case 26:return u=e.t2,e.abrupt("return",_objectSpread(_objectSpread(_objectSpread(_objectSpread({},a),i),c),u));case 28:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.props=props;var deepProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,props(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",[]);case 5:if(!r.isFile){e.next=7;break}return e.abrupt("return",[r]);case 7:return e.next=9,fsProm.readdir(t,{withFileTypes:!0});case 9:return n=e.sent,o=n.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=path.join(t,r.name),e.next=3,deepProps(n);case 3:return o=e.sent,e.abrupt("return",o);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=13,Promise.all(o);case 13:return a=e.sent,e.abrupt("return",[r].concat(_toConsumableArray(a.flat(1/0).filter(Boolean))));case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.deepProps=deepProps;
"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.videoProps=exports.timeStampSync=exports.timeStamp=exports.statSync=exports.stat=exports.props=exports.imageProps=exports.humanizeDuration=exports.ffprobePromise=exports.deepStatSync=exports.deepStat=exports.deepProps=exports.convertBytes=exports.audioProps=void 0;var ExifReader=_interopRequireWildcard(require("exifreader")),ffmpeg=_interopRequireWildcard(require("fluent-ffmpeg")),fs=_interopRequireWildcard(require("fs")),fsProm=_interopRequireWildcard(require("fs/promises")),_humanizeDuration=_interopRequireDefault(require("humanize-duration")),_imageSize=_interopRequireDefault(require("image-size")),mime=_interopRequireWildcard(require("mime")),_moment=_interopRequireDefault(require("moment")),path=_interopRequireWildcard(require("path"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==_typeof(e)&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=o?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(n,a,i):n[a]=e[a]}return n.default=e,r&&r.set(e,n),n}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,o){var a=t&&t.prototype instanceof d?t:d,i=Object.create(a.prototype),c=new R(o||[]);return n(i,"_invoke",{value:x(e,r,c)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var p={};function d(){}function f(){}function m(){}var v={};u(v,a,(function(){return this}));var h=Object.getPrototypeOf,y=h&&h(h(j([])));y&&y!==t&&r.call(y,a)&&(v=y);var g=m.prototype=d.prototype=Object.create(v);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function _(e,t){function o(n,a,i,c){var u=l(e[n],e,a);if("throw"!==u.type){var s=u.arg,p=s.value;return p&&"object"==_typeof(p)&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){o("next",e,i,c)}),(function(e){o("throw",e,i,c)})):t.resolve(p).then((function(e){s.value=e,i(s)}),(function(e){return o("throw",e,i,c)}))}c(u.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function x(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return L()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=w(i,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=l(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return f.prototype=m,n(g,"constructor",{value:m,configurable:!0}),n(m,"constructor",{value:f,configurable:!0}),f.displayName=u(m,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,u(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(_.prototype),u(_.prototype,i,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new _(s(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),u(g,c,"Generator"),u(g,a,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=j,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:j(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)}))}}var ffprobe=require("@ffprobe-installer/ffprobe");ffmpeg.setFfprobePath(ffprobe.path);var getSizeAndContains=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.stat(t);case 2:if(!(r=e.sent).isFile()){e.next=5;break}return e.abrupt("return",{size:r.size,contains:void 0});case 5:return n={files:0,folders:0},o=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,a,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.readdir(t,{withFileTypes:!0});case 2:return r=e.sent,a=r.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var a,i,c,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=path.join(t,r.name),e.next=3,fsProm.stat(a);case 3:if(i=e.sent,c=i.size,!r.isFile()){e.next=8;break}return n.files++,e.abrupt("return",[c]);case 8:return n.folders++,e.next=12,o(a);case 12:return u=e.sent,e.abrupt("return",[c].concat(_toConsumableArray(u)));case 14:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=6,Promise.all(a);case 6:return i=e.sent,e.abrupt("return",i.flat(1/0).filter(Boolean));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=9,o(t);case 9:return a=e.sent.reduce((function(e,t){return e+t}),0),e.abrupt("return",{size:a,contains:n});case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),getSizeAndContainsSync=function(e){var t=fs.statSync(e);if(t.isFile())return{size:t.size,contains:void 0};var r={files:0,folders:0},n=function e(t){return fs.readdirSync(t,{withFileTypes:!0}).map((function(n){var o=path.join(t,n.name),a=fs.statSync(o).size;if(n.isFile())return r.files++,[a];r.folders++;var i=e(o);return[a].concat(_toConsumableArray(i))})).flat(1/0).filter(Boolean)}(e).reduce((function(e,t){return e+t}),0);return{size:n,contains:r}},timeStamp=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h,y,g;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=6;break}return e.next=3,fsProm.stat(t);case 3:e.t0=e.sent,e.next=7;break;case 6:e.t0=t;case 7:return r=e.t0,n=r.birthtime,o=r.ctime,a=r.mtime,i=r.atime,c=r.birthtime.toLocaleString(),u=r.ctime.toLocaleString(),s=r.mtime.toLocaleString(),l=r.atime.toLocaleString(),p=(0,_moment.default)(r.birthtime).fromNow(),d=(0,_moment.default)(r.ctime).fromNow(),f=(0,_moment.default)(r.mtime).fromNow(),m=(0,_moment.default)(r.atime).fromNow(),v=r.birthtimeMs,h=r.ctimeMs,y=r.mtimeMs,g=r.atimeMs,e.abrupt("return",{created:n,changed:o,modified:a,accessed:i,createdMs:v,changedMs:h,modifiedMs:y,accessedMs:g,createdLocal:c,changedLocal:u,modifiedLocal:s,accessedLocal:l,createdRelative:p,changedRelative:d,modifiedRelative:f,accessedRelative:m});case 25:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.timeStamp=timeStamp;var timeStampSync=function(e){var t="string"==typeof e?fs.statSync(e):e,r=t.birthtime,n=t.ctime,o=t.mtime,a=t.atime,i=t.birthtime.toLocaleString(),c=t.ctime.toLocaleString(),u=t.mtime.toLocaleString(),s=t.atime.toLocaleString(),l=(0,_moment.default)(t.birthtime).fromNow(),p=(0,_moment.default)(t.ctime).fromNow(),d=(0,_moment.default)(t.mtime).fromNow(),f=(0,_moment.default)(t.atime).fromNow();return{created:r,changed:n,modified:o,accessed:a,createdMs:t.birthtimeMs,changedMs:t.ctimeMs,modifiedMs:t.mtimeMs,accessedMs:t.atimeMs,createdLocal:i,changedLocal:c,modifiedLocal:u,accessedLocal:s,createdRelative:l,changedRelative:p,modifiedRelative:d,accessedRelative:f}};exports.timeStampSync=timeStampSync;var convertBytes=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["Bytes","KB","MB","GB","TB"],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(0===e)return"0 bytes";var n=Math.floor(Math.log(e)/Math.log(1024));return 0===n?e+" "+t[n]:(e/Math.pow(1024,n)).toFixed(2)+" "+t[n]+(r?" (".concat(e," bytes)"):"")};exports.convertBytes=convertBytes;var ffprobePromise=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e,r){return ffmpeg.ffprobe(t,(function(t,n){t?r(t):e(n)}))}));case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.ffprobePromise=ffprobePromise;var humanizeDuration=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(void 0!==e){var r="number"==typeof e?e:parseFloat(e);return(0,_humanizeDuration.default)(r,_objectSpread({maxDecimalPoints:2},t))}};exports.humanizeDuration=humanizeDuration;var getImageDimensions=function(e){var t,r,n,o,a,i,c,u,s,l,p=null!==(t=null!==(r=null===(n=e.ImageWidth)||void 0===n?void 0:n.value)&&void 0!==r?r:null===(o=e["Image Width"])||void 0===o?void 0:o.description)&&void 0!==t?t:null===(a=e.PixelXDimension)||void 0===a?void 0:a.value,d=null!==(i=null!==(c=null===(u=e.ImageLength)||void 0===u?void 0:u.value)&&void 0!==c?c:null===(s=e["Image Height"])||void 0===s?void 0:s.description)&&void 0!==i?i:null===(l=e.PixelYDimension)||void 0===l?void 0:l.value;return{dimensions:void 0!==p&&void 0!==d?"".concat(p," x ").concat(d," pixels"):void 0,width:p,height:d}},getImageResolution=function(e){var t,r,n=parseInt((null===(t=e.XResolution)||void 0===t?void 0:t.description)||"0",10),o=parseInt((null===(r=e.YResolution)||void 0===r?void 0:r.description)||"0",10);return{resolution:n||o?"".concat(n," x ").concat(o," Dpi"):void 0,xResolution:n,yResolution:o}},stat=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fsProm.stat(t);case 2:if(r=e.sent,n=r.isFile(),o=path.basename(t),a=n?path.extname(t):void 0,i=path.basename(t,a),c=!r.isFile(),u=t.replace(/\\/g,"/"),s=path.dirname(t).replace(/\\/g,"/"),l=n?"File":"Folder",p=n?mime.getType(t)||"[unknown]":void 0,!n){e.next=16;break}e.t0=[],e.next=19;break;case 16:return e.next=18,fsProm.readdir(t,{withFileTypes:!0});case 18:e.t0=e.sent;case 19:return d=e.t0,e.next=22,timeStamp(r);case 22:return f=e.sent,e.next=25,getSizeAndContains(t);case 25:return m=e.sent,v=m.size,h=m.contains,e.abrupt("return",_objectSpread(_objectSpread({fileName:o,baseName:i,extension:a,directory:s,location:u,size:v,sizePretty:convertBytes(v),type:l,mimeType:p,isFile:n,isDirectory:c,children:d,containedFiles:null==h?void 0:h.files,containedFolders:null==h?void 0:h.folders,contains:h,containsPretty:h?"".concat(h.files," Files, ").concat(h.folders," Folders"):void 0},f),{},{stats:r}));case 29:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.stat=stat;var statSync=function(e){var t=fs.statSync(e),r=t.isFile(),n=path.basename(e),o=r?path.extname(e):void 0,a=path.basename(e,o),i=!t.isFile(),c=e.replace(/\\/g,"/"),u=path.dirname(e).replace(/\\/g,"/"),s=r?"File":"Folder",l=r?mime.getType(e)||"[unknown]":void 0,p=r?[]:fs.readdirSync(e,{withFileTypes:!0}),d=timeStampSync(t),f=getSizeAndContainsSync(e),m=f.size,v=f.contains;return _objectSpread(_objectSpread({fileName:n,baseName:a,extension:o,directory:u,location:c,size:m,sizePretty:convertBytes(m),type:s,mimeType:l,isFile:r,isDirectory:i,children:p,containedFiles:null==v?void 0:v.files,containedFolders:null==v?void 0:v.folders,contains:v,containsPretty:v?"".concat(v.files," Files, ").concat(v.folders," Folders"):void 0},d),{},{stats:t})};exports.statSync=statSync;var deepStat=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,stat(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",[]);case 5:if(!r.isFile){e.next=7;break}return e.abrupt("return",[r]);case 7:return n=r.children.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=path.join(t,r.name),e.next=3,deepStat(n);case 3:return o=e.sent,e.abrupt("return",o);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=10,Promise.all(n);case 10:return o=e.sent,e.abrupt("return",[r].concat(_toConsumableArray(o.flat(1/0).filter(Boolean))));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.deepStat=deepStat;var deepStatSync=function e(t){var r=statSync(t);if(!r)return[];if(r.isFile)return[r];var n=r.children.map((function(r){var n=path.join(t,r.name);return e(n)}));return[r].concat(_toConsumableArray(n.flat(1/0).filter(Boolean)))};exports.deepStatSync=deepStatSync;var imageProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p,d,f,m,v,h,y,g,b,_,x,w,S,P;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ExifReader.load(t);case 3:return S=e.sent,e.abrupt("return",_objectSpread(_objectSpread(_objectSpread({isImage:!0},getImageDimensions(S)),getImageResolution(S)),{},{orientation:null===(r=S.Orientation)||void 0===r?void 0:r.description,bitDepth:null!==(n=null!==(o=null!==(a=null===(i=S["Bit Depth"])||void 0===i?void 0:i.description)&&void 0!==a?a:null===(c=S.BitDepth)||void 0===c?void 0:c.description)&&void 0!==o?o:null===(u=S["Bits Per Sample"])||void 0===u?void 0:u.description)&&void 0!==n?n:null===(s=S.BitsPerSample)||void 0===s?void 0:s.description,colorType:null!==(l=null!==(p=null!==(d=null===(f=S["Color Type"])||void 0===f?void 0:f.description)&&void 0!==d?d:null===(m=S.ColorType)||void 0===m?void 0:m.description)&&void 0!==p?p:null===(v=S["Color Space"])||void 0===v?void 0:v.description)&&void 0!==l?l:null===(h=S.ColorSpace)||void 0===h?void 0:h.description,subSampling:null!==(y=null===(g=S.Subsampling)||void 0===g?void 0:g.description)&&void 0!==y?y:null===(b=S.YCbCrSubSampling)||void 0===b?void 0:b.description,compression:null===(_=S.Compression)||void 0===_?void 0:_.description,filter:null===(x=S.Filter)||void 0===x?void 0:x.description,resourceURL:null===(w=S.ResourceURL)||void 0===w?void 0:w.description,metaData:S}));case 7:return e.prev=7,e.t0=e.catch(0),console.error(e.t0.message),e.prev=10,P=(0,_imageSize.default)(t),e.abrupt("return",{isImage:!0,dimensions:void 0!==P.width&&void 0!==P.height?"".concat(P.width," x ").concat(P.height," pixels"):void 0,height:P.height,width:P.width,orientation:P.orientation,metaData:P});case 15:return e.prev=15,e.t1=e.catch(10),console.error(e.t1.message),e.abrupt("return",{});case 19:case"end":return e.stop()}}),e,null,[[0,7],[10,15]])})));return function(t){return e.apply(this,arguments)}}();exports.imageProps=imageProps;var audioProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u,s,l,p;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ffprobePromise(t);case 3:return n=e.sent,o=n.streams.find((function(e){return"audio"===e.codec_type}))||{},a=n.format.tags||{},i=null!==(r=n.format.duration)&&void 0!==r?r:0,u=humanizeDuration(c=1e3*i,{maxDecimalPoints:2}),s=parseInt(o.bit_rate||"0",10),l=s?convertBytes(s,["bps","kbps","mbps"],!1):void 0,p=void 0!==o.channels?o.channel_layout?"".concat(o.channels," (").concat(o.channel_layout,")"):o.channels:void 0,e.abrupt("return",{isAudio:!0,title:a.title,album:a.album,artist:a.artist,composer:a.composer,genre:a.genre,year:a.date,duration:i,durationMs:c,durationPretty:u,bitRate:s,bitRatePretty:l,channels:p,metaData:n});case 15:return e.prev=15,e.t0=e.catch(0),console.error(e.t0.message),e.abrupt("return",{});case 19:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}();exports.audioProps=audioProps;var videoProps=function(){var _ref17=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(videoPath){var _metaData$format$dura2,metaData,video,dimensions,duration,durationMs,durationPretty,bitRate,bitRatePretty,frameRate,frameRatePretty;return _regeneratorRuntime().wrap((function _callee11$(_context11){for(;;)switch(_context11.prev=_context11.next){case 0:return _context11.prev=0,_context11.next=3,ffprobePromise(videoPath);case 3:return metaData=_context11.sent,video=metaData.streams.find((function(e){return"video"===e.codec_type}))||{},dimensions="".concat(video.width," x ").concat(video.height," pixels"),duration=null!==(_metaData$format$dura2=metaData.format.duration)&&void 0!==_metaData$format$dura2?_metaData$format$dura2:0,durationMs=1e3*duration,durationPretty=humanizeDuration(durationMs,{maxDecimalPoints:2}),bitRate=parseInt(video.bit_rate||"0",10),bitRatePretty=bitRate?convertBytes(bitRate,["bps","kbps","mbps"],!1):void 0,frameRate=video.r_frame_rate?parseFloat(eval(video.r_frame_rate||"0").toFixed(2)):void 0,frameRatePretty=frameRate?"".concat(eval(video.r_frame_rate||"0").toFixed(2)," fps"):void 0,_context11.abrupt("return",{isVideo:!0,dimensions:dimensions,width:video.width,height:video.height,resolution:dimensions,duration:duration,durationMs:durationMs,durationPretty:durationPretty,bitRate:bitRate,bitRatePretty:bitRatePretty,frameRate:frameRate,frameRatePretty:frameRatePretty,framesPerSecond:frameRatePretty,ratio:video.display_aspect_ratio,metaData:metaData});case 16:return _context11.prev=16,_context11.t0=_context11.catch(0),console.error(_context11.t0.message),_context11.abrupt("return",{});case 20:case"end":return _context11.stop()}}),_callee11,null,[[0,16]])})));return function(e){return _ref17.apply(this,arguments)}}();exports.videoProps=videoProps;var props=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a,i,c,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,stat(t);case 2:if(a=e.sent,null===(r=a.mimeType)||void 0===r||!r.includes("image")){e.next=9;break}return e.next=6,imageProps(t);case 6:e.t0=e.sent,e.next=10;break;case 9:e.t0={};case 10:if(i=e.t0,null===(n=a.mimeType)||void 0===n||!n.includes("audio")){e.next=17;break}return e.next=14,audioProps(t);case 14:e.t1=e.sent,e.next=18;break;case 17:e.t1={};case 18:if(c=e.t1,null===(o=a.mimeType)||void 0===o||!o.includes("video")){e.next=25;break}return e.next=22,videoProps(t);case 22:e.t2=e.sent,e.next=26;break;case 25:e.t2={};case 26:return u=e.t2,e.abrupt("return",_objectSpread(_objectSpread(_objectSpread(_objectSpread({},a),i),c),u));case 28:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.props=props;var deepProps=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,o,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,props(t);case 2:if(r=e.sent){e.next=5;break}return e.abrupt("return",[]);case 5:if(!r.isFile){e.next=7;break}return e.abrupt("return",[r]);case 7:return e.next=9,fsProm.readdir(t,{withFileTypes:!0});case 9:return n=e.sent,o=n.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=path.join(t,r.name),e.next=3,deepProps(n);case 3:return o=e.sent,e.abrupt("return",o);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.next=13,Promise.all(o);case 13:return a=e.sent,e.abrupt("return",[r].concat(_toConsumableArray(a.flat(1/0).filter(Boolean))));case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.deepProps=deepProps;
{
"name": "fs-props",
"version": "3.0.4",
"version": "3.0.5",
"description": "Get fs stats, image dimensions, audio and video metada ",

@@ -41,2 +41,3 @@ "main": "index.js",

"devDependencies": {
"@types/humanize-duration": "^3.27.1",
"@types/image-size": "^0.8.0",

@@ -51,3 +52,2 @@ "@types/mime": "^3.0.1",

"dependencies": {
"@types/humanize-duration": "^3.27.1",
"@ffprobe-installer/ffprobe": "^1.4.1",

@@ -54,0 +54,0 @@ "@types/fluent-ffmpeg": "^2.1.20",

/// <reference types="node" />
import { ISizeCalculationResult } from 'image-size/dist/types/interface';
import { FfprobeData } from 'fluent-ffmpeg';
import { Stats, Dirent } from 'fs';
import { Tags, XmpTags, IccTags } from "exifreader";
import * as ExifReader from "exifreader";
export declare type StatsProps = {

@@ -44,2 +43,9 @@ fileName: string;

};
interface ISize {
width: number | undefined;
height: number | undefined;
orientation?: number;
type?: string;
images?: ISize[];
}
export declare type ImageProps = {

@@ -60,3 +66,3 @@ isImage?: boolean;

height?: string | number;
metaData?: Tags & XmpTags & IccTags | ISizeCalculationResult;
metaData?: Awaited<ReturnType<typeof ExifReader.load>> | ISize;
};

@@ -97,1 +103,2 @@ export declare type AudioProps = {

export declare type Properties = StatsProps & ImageProps & AudioProps & VideoProps;
export {};