Socket
Socket
Sign inDemoInstall

@aomex/utility

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aomex/utility - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

6

CHANGELOG.md
# @aomex/utility
## 0.0.5
### Patch Changes
- [`fbb7ab2`](https://github.com/aomex/aomex/commit/fbb7ab2e6ec2a18e7ad8f018788523952049b6fd) Thanks [@geekact](https://github.com/geekact)! - refactor(utility): move file-parser to utility
## 0.0.4

@@ -4,0 +10,0 @@

12

dist/index.d.ts

@@ -14,2 +14,12 @@ export { default as chalk } from 'chalk';

export { NonReadonly, Union2Intersection, sleep, toArray };
interface Options {
pattern: string[];
ignore?: string[];
dot?: boolean;
}
type PathToFileOptions = string | string[] | Options | Options[];
declare const pathToFiles: (paths: PathToFileOptions) => Promise<string[]>;
declare const fileToModules: <T extends unknown>(files: string[], filter?: ((item?: T | undefined) => boolean) | undefined) => Promise<T[]>;
export { NonReadonly, PathToFileOptions, Union2Intersection, fileToModules, pathToFiles, sleep, toArray };

@@ -11,2 +11,64 @@ // src/to-array.ts

// src/file-parser/path-to-files.ts
import path from "node:path";
import { stat } from "node:fs/promises";
import { glob, hasMagic } from "glob";
var pathToFiles = async (paths) => {
const opts = normalizeSearchPath(paths);
const files = await Promise.all(
opts.map((opt) => {
const { dot, pattern: patterns } = opt;
const options = {
nodir: true,
dot,
ignore: (opt.ignore || []).concat("**/*.d.{ts,mts,cts}"),
withFileTypes: false
};
return Promise.all(
patterns.map(async (pattern) => {
pattern = path.posix.resolve(pattern);
if (!hasMagic(pattern, { magicalBraces: true })) {
const stats = await stat(pattern);
if (!stats.isFile()) {
pattern = path.posix.resolve(
pattern,
`./**/*.{ts,js,mts,mjs,cts,cjs}`
);
}
}
return glob(pattern, options);
})
);
})
);
return [...new Set(files.flat(2))].sort();
};
var normalizeSearchPath = (paths) => {
if (typeof paths === "string") {
return [{ pattern: [paths] }];
}
if (Array.isArray(paths)) {
if (!paths.length)
return [];
return isStringArray(paths) ? [{ pattern: paths }] : paths;
}
return [paths];
};
var isStringArray = (data) => {
return typeof data[0] === "string";
};
// src/file-parser/file-to-modules.ts
import { pathToFileURL } from "node:url";
var fileToModules = async (files, filter) => {
const result = await Promise.all(
files.map(async (file) => {
const modules2 = await import(pathToFileURL(file).toString());
return typeof modules2 === "object" ? Object.values(modules2) : [];
})
);
const modules = [...new Set(result.flat())];
return filter ? modules.filter(filter) : modules;
};
// src/index.ts

@@ -18,2 +80,4 @@ import { default as default2 } from "chalk";

default2 as chalk,
fileToModules,
pathToFiles,
sleep,

@@ -20,0 +84,0 @@ toArray

5

package.json
{
"name": "@aomex/utility",
"version": "0.0.4",
"version": "0.0.5",
"description": "",

@@ -31,5 +31,6 @@ "type": "module",

"bytes": "^3.1.2",
"chalk": "^5.2.0"
"chalk": "^5.2.0",
"glob": "^9.2.1"
},
"scripts": {}
}

Sorry, the diff of this file is not supported yet

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