file-prompt
Version:
An interactive prompt for selecting files from a directory.
1 lines • 1.74 kB
JavaScript
;function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _stream=require("stream"),GenericTransform=function(e){function t(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];_classCallCheck(this,t);var n=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,Object.assign({},r,{objectMode:!0})));return n._transformCallback=e,n}return _inherits(t,e),_createClass(t,[{key:"destroy",value:function(e){var t=this;this.isDestroyed||(this.isDestroyed=!0,process.nextTick(function(){e&&t.emit("error",e),t.emit("close")}))}},{key:"pushError",value:function(e){this.push({creator:"generic-transformer",type:"error",data:e}),this.push(null)}},{key:"_transform",value:function(e,t,r){try{this._transformCallback(this,e),r()}catch(n){this.emit("error",n),r()}}}]),t}(_stream.Transform);exports["default"]=GenericTransform;