Socket
Socket
Sign inDemoInstall

@poppinss/utils

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/utils - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

build/src/lodash/index.js

1

build/index.d.ts

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

export * as lodash from './src/lodash';
export { Exception } from './src/Exception';

@@ -2,0 +3,0 @@ export { fsReadAll } from './src/fsReadAll';

@@ -10,3 +10,11 @@ "use strict";

*/
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lodash = __importStar(require("./src/lodash"));
var Exception_1 = require("./src/Exception");

@@ -13,0 +21,0 @@ exports.Exception = Exception_1.Exception;

2

build/src/fsReadAll.d.ts
/**
* Returns an array of file paths from the given location.
*/
export declare function fsReadAll(location: string): string[];
export declare function fsReadAll(location: string, callback?: (file: string) => boolean): string[];

@@ -19,5 +19,5 @@ "use strict";

*/
function fsReadAll(location) {
return fs_readdir_recursive_1.default(location).filter(isScriptFile_1.isScriptFile);
function fsReadAll(location, callback) {
return fs_readdir_recursive_1.default(location).filter(typeof (callback) === 'function' ? callback : isScriptFile_1.isScriptFile);
}
exports.fsReadAll = fsReadAll;
{
"name": "@poppinss/utils",
"version": "2.1.2",
"version": "2.1.3",
"description": "Handy utilities for repetitive work",

@@ -18,3 +18,5 @@ "main": "build/index.js",

"compile": "npm run lint && npm run clean && tsc",
"build": "npm run compile && typedoc --theme markdown --HideSources --excludePrivate && git add docs",
"build:docs": "typedoc --theme markdown --HideSources --excludePrivate && git add docs",
"build:lodash": "lodash exports=node include=pick,omit,get,set,mergeWith,merge,snakeCase,camelCase,startCase -o build/src/lodash/index.js --production",
"build": "npm run compile && npm run build:lodash && npm run build:docs",
"commit": "git-cz",

@@ -32,5 +34,5 @@ "release": "np",

"@adonisjs/mrm-preset": "^2.2.4",
"@poppinss/dev-utils": "^1.0.3",
"@types/node": "^13.7.0",
"commitizen": "^4.0.3",
"@poppinss/dev-utils": "^1.0.4",
"@types/node": "^13.11.0",
"commitizen": "^4.0.4",
"cz-conventional-changelog": "^3.1.0",

@@ -40,12 +42,13 @@ "del-cli": "^3.0.0",

"eslint": "^6.8.0",
"eslint-plugin-adonis": "^1.0.6",
"husky": "^4.2.1",
"eslint-plugin-adonis": "^1.0.8",
"husky": "^4.2.3",
"japa": "^3.0.1",
"mrm": "^2.0.4",
"lodash-cli": "^4.17.5",
"mrm": "^2.2.0",
"np": "^5.2.1",
"ts-node": "^8.6.2",
"typedoc": "^0.16.9",
"ts-node": "^8.8.2",
"typedoc": "^0.17.4",
"typedoc-plugin-external-module-name": "^3.0.0",
"typedoc-plugin-markdown": "^2.2.16",
"typescript": "^3.7.5"
"typedoc-plugin-markdown": "^2.2.17",
"typescript": "^3.8.3"
},

@@ -52,0 +55,0 @@ "nyc": {

@@ -6,5 +6,4 @@ # Utils

This module exports a collection of re-usable utilties to avoid re-writing the same code in every other package.
This module exports a collection of re-usable utilties to avoid re-writing the same code in every other package. We also include a handful of Lodash utilities, which are used across the AdonisJS packages eco-system.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->

@@ -21,2 +20,4 @@ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [resolveFrom](#resolvefrom)
- [Lodash utilities](#lodash-utilities)
- [Exported methods](#exported-methods)

@@ -63,2 +64,10 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

You can also define your custom filter function. The filter function must return `true` for files to be included.
```ts
const files = fsReadAll(__dirname, (file) => {
return file.endsWith('.foo.js')
})
```
## requireAll

@@ -143,2 +152,32 @@ Same as `fsReadAll`, but instead require the files. Helpful when you want to load all the config files inside a directory on app boot.

## Lodash utilities
Lodash itself is a bulky library and most of the times, we don't need all the functions from it. For this purpose, the lodash team decided to publish individual methods to npm as packages. However, most of those individual packages are outdated.
At this point, whether we should use the complete lodash build or use outdated individual packages. Both are not acceptable.
Instead, we make use of `lodash-cli` to create a custom build of all the utilities we ever need inside the AdonisJS eco-system and export it as part of this package. Why part of this package?
Well, creating custom builds in multiple packages will cause friction, so it's better to keep it at a single place.
> **Do note: There are no Typescript types for the lodash methods, since their CLI doesn't generate one and the one published on `@types/lodash` package are again maintained by community and not the lodash core team, so at times, they can also be outdated.**
```ts
import { lodash } from '@poppinss/utils'
lodash.snakeCase('HelloWorld') // hello_world
```
### Exported methods
Following is the list of exported helpers.
- [pick](https://lodash.com/docs/latest#pick)
- [omit](https://lodash.com/docs/latest#omit)
- [get](https://lodash.com/docs/latest#get)
- [set](https://lodash.com/docs/latest#set)
- [mergeWith](https://lodash.com/docs/latest#mergeWith)
- [merge](https://lodash.com/docs/latest#merge)
- [snakeCase](https://lodash.com/docs/latest#snakeCase)
- [camelCase](https://lodash.com/docs/latest#camelCase)
- [startCase](https://lodash.com/docs/latest#startCase)
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/utils/master.svg?style=for-the-badge&logo=circleci

@@ -145,0 +184,0 @@ [circleci-url]: https://circleci.com/gh/poppinss/utils "circleci"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc