@poppinss/utils
Advanced tools
Comparing version 2.1.1 to 2.1.2
"use strict"; | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +11,0 @@ var Exception_1 = require("./src/Exception"); |
@@ -0,1 +1,8 @@ | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
/** | ||
* Handles ESM `default` exports and common js vanilla exports. The `default` | ||
* exports are only entertained, when `esmEnabled` is set to true. | ||
*/ | ||
export declare function esmRequire(filePath: string): any; |
"use strict"; | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
const esmResolver_1 = require("./esmResolver"); | ||
/** | ||
* Handles ESM `default` exports and common js vanilla exports. The `default` | ||
* exports are only entertained, when `esmEnabled` is set to true. | ||
*/ | ||
function esmRequire(filePath) { | ||
@@ -5,0 +20,0 @@ return esmResolver_1.esmResolver(require(filePath)); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
export declare function esmResolver(output: any): any; |
"use strict"; | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
function esmResolver(output) { | ||
@@ -4,0 +15,0 @@ return output && output.__esModule && output.default ? output.default : output; |
@@ -0,1 +1,13 @@ | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
/** | ||
* Extended Error object with the option to set error `status` and `code`. | ||
* At AdonisJs, we prefer exceptions with proper error codes to handle | ||
* them without relying on message pattern matching. | ||
* | ||
* ```js | ||
* new Exception('message', 500, 'E_RUNTIME_EXCEPTION') | ||
* ``` | ||
*/ | ||
export declare class Exception extends Error { | ||
@@ -2,0 +14,0 @@ name: string; |
"use strict"; | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
/** | ||
* Extended Error object with the option to set error `status` and `code`. | ||
* At AdonisJs, we prefer exceptions with proper error codes to handle | ||
* them without relying on message pattern matching. | ||
* | ||
* ```js | ||
* new Exception('message', 500, 'E_RUNTIME_EXCEPTION') | ||
* ``` | ||
*/ | ||
class Exception extends Error { | ||
constructor(message, status = 500, code) { | ||
super(message); | ||
/** | ||
* Set error message | ||
*/ | ||
Object.defineProperty(this, 'message', { | ||
@@ -12,2 +35,5 @@ configurable: true, | ||
}); | ||
/** | ||
* Set error name as a public property | ||
*/ | ||
Object.defineProperty(this, 'name', { | ||
@@ -19,2 +45,5 @@ configurable: true, | ||
}); | ||
/** | ||
* Set status as a public property | ||
*/ | ||
Object.defineProperty(this, 'status', { | ||
@@ -26,2 +55,5 @@ configurable: true, | ||
}); | ||
/** | ||
* Set error code as a public property (only when defined) | ||
*/ | ||
if (code) { | ||
@@ -35,2 +67,5 @@ Object.defineProperty(this, 'code', { | ||
} | ||
/** | ||
* Update the stack trace | ||
*/ | ||
Error.captureStackTrace(this, this.constructor); | ||
@@ -37,0 +72,0 @@ } |
@@ -0,1 +1,4 @@ | ||
/** | ||
* Returns an array of file paths from the given location. | ||
*/ | ||
export declare function fsReadAll(location: string): string[]; |
"use strict"; | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,2 +16,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const isScriptFile_1 = require("./isScriptFile"); | ||
/** | ||
* Returns an array of file paths from the given location. | ||
*/ | ||
function fsReadAll(location) { | ||
@@ -10,0 +21,0 @@ return fs_readdir_recursive_1.default(location).filter(isScriptFile_1.isScriptFile); |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Returns `true` when file ends with `.js`, `.json` or | ||
* `.ts` but not `.d.ts`. | ||
*/ | ||
export declare function isScriptFile(file: string): boolean; |
"use strict"; | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path_1 = require("path"); | ||
const JS_MODULES = ['.js', '.json']; | ||
/** | ||
* Returns `true` when file ends with `.js`, `.json` or | ||
* `.ts` but not `.d.ts`. | ||
*/ | ||
function isScriptFile(file) { | ||
@@ -6,0 +18,0 @@ const ext = path_1.extname(file); |
@@ -0,1 +1,9 @@ | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
/** | ||
* Require all files from a given directory. The method automatically looks | ||
* for files ending with `.ts`, `.js` and `.json`. Also files ending with | ||
* `.d.ts` are ignored. | ||
*/ | ||
export declare function requireAll(location: string, recursive?: boolean, optional?: boolean): any; |
"use strict"; | ||
/** | ||
* @module @poppinss/utils | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,2 +9,10 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
const path_1 = require("path"); | ||
@@ -11,2 +22,5 @@ const require_all_1 = __importDefault(require("require-all")); | ||
const isScriptFile_1 = require("./isScriptFile"); | ||
/** | ||
* Function to filter selected files only | ||
*/ | ||
function fileFilter(file) { | ||
@@ -19,2 +33,7 @@ const ext = path_1.extname(file); | ||
} | ||
/** | ||
* Require all files from a given directory. The method automatically looks | ||
* for files ending with `.ts`, `.js` and `.json`. Also files ending with | ||
* `.d.ts` are ignored. | ||
*/ | ||
function requireAll(location, recursive = true, optional = false) { | ||
@@ -21,0 +40,0 @@ try { |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Resolves module from a given directory. It is similar to `require.resolve` | ||
* but carefull handles the absolute paths. | ||
*/ | ||
export declare function resolveFrom(fromLocation: string, modulePath: string): string; |
"use strict"; | ||
/* | ||
* @poppinss/utils | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,2 +16,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const resolve_from_1 = __importDefault(require("resolve-from")); | ||
/** | ||
* Resolves module from a given directory. It is similar to `require.resolve` | ||
* but carefull handles the absolute paths. | ||
*/ | ||
function resolveFrom(fromLocation, modulePath) { | ||
@@ -10,0 +22,0 @@ if (path_1.isAbsolute(modulePath)) { |
{ | ||
"name": "@poppinss/utils", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Handy utilities for repetitive work", | ||
@@ -30,20 +30,20 @@ "main": "build/index.js", | ||
"@adonisjs/fold": "^6.2.3", | ||
"@adonisjs/mrm-preset": "^2.2.2", | ||
"@adonisjs/mrm-preset": "^2.2.4", | ||
"@poppinss/dev-utils": "^1.0.3", | ||
"@types/node": "^12.12.21", | ||
"@types/node": "^13.7.0", | ||
"commitizen": "^4.0.3", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"cz-conventional-changelog": "^3.1.0", | ||
"del-cli": "^3.0.0", | ||
"doctoc": "^1.4.0", | ||
"eslint": "^6.7.2", | ||
"eslint-plugin-adonis": "^1.0.4", | ||
"husky": "^3.1.0", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-adonis": "^1.0.6", | ||
"husky": "^4.2.1", | ||
"japa": "^3.0.1", | ||
"mrm": "^2.0.2", | ||
"mrm": "^2.0.4", | ||
"np": "^5.2.1", | ||
"ts-node": "^8.5.4", | ||
"typedoc": "^0.15.5", | ||
"typedoc-plugin-external-module-name": "^2.1.0", | ||
"typedoc-plugin-markdown": "^2.2.14", | ||
"typescript": "^3.7.3" | ||
"ts-node": "^8.6.2", | ||
"typedoc": "^0.16.9", | ||
"typedoc-plugin-external-module-name": "^3.0.0", | ||
"typedoc-plugin-markdown": "^2.2.16", | ||
"typescript": "^3.7.5" | ||
}, | ||
@@ -50,0 +50,0 @@ "nyc": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17234
320