Visitar URL original
refactor(commons): Replace the `_` utilities with standalone functions (v6) by fratzinger · Pull Request #3724 · feathersjs/feathers · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor(commons): Replace the _ utilities with standalone function…
…s (v6)

`feathers/commons` exported a lodash-like `_` object. Feathers itself only
used `_.pick` and most of the other helpers have native replacements
(`Object.keys`, `Object.values`, `Object.assign`). The commons are now a
folder of standalone, typed functions:

- `feathers/commons` exports `isObject`, `pick`, `omit` and `stripSlashes`
- Remove `_` (`each`, `some`, `every`, `keys`, `values`, `isMatch`, `isEmpty`,
  `isObjectOrArray`, `extend`, `merge`), `isPromise`, `createSymbol` and the
  debug re-export (still available from `feathers`)
- `SERVICE` uses `Symbol.for()` directly (same value as before)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
fratzinger and claude committed Oct 22, 2026
commit 554e33dbc161f8e84d492df493e8a49be2e0f4c7
6 changes: 3 additions & 3 deletions packages/feathers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"require": "./cjs/hooks/index.js"
},
"./commons": {
"import": "./lib/commons.js",
"require": "./cjs/commons.js"
"import": "./lib/commons/index.js",
"require": "./cjs/commons/index.js"
},
"./errors": {
"import": "./lib/errors.js",
Expand Down Expand Up @@ -57,7 +57,7 @@
"./lib/hooks/index.d.ts"
],
"commons": [
"./lib/commons.d.ts"
"./lib/commons/index.d.ts"
],
"client": [
"./lib/client/index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/feathers/src/application.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventEmitter } from './event-emitter.js'
import { HOOKS, hooks, middleware } from './hooks/index.js'

import { stripSlashes } from './commons.js'
import { stripSlashes } from './commons/index.js'
import { createDebug } from './debug.js'

import version from './version.js'
Expand Down
9 changes: 6 additions & 3 deletions packages/feathers/src/client/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Params, Id, Query, NullableId } from '../declarations.js'
import { BadRequest, Unavailable, convert, errors } from '../errors.js'
import { _, stripSlashes } from '../commons.js'
import { pick, stripSlashes } from '../commons/index.js'
import { protectedProperties } from '../service.js'

function toError(error: Error & { code: string }, status?: number) {
function toError(
error: Error & { code: string; address?: string; port?: number; config?: unknown },
status?: number
) {
if (error.code === 'ECONNREFUSED') {
return new Unavailable(error.message, _.pick(error, 'address', 'port', 'config'))
return new Unavailable(error.message, pick(error, 'address', 'port', 'config'))
}

return convert(error, status)
Expand Down
226 changes: 0 additions & 226 deletions packages/feathers/src/commons.test.ts

This file was deleted.

106 changes: 0 additions & 106 deletions packages/feathers/src/commons.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/feathers/src/commons/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './object.js'
export * from './path.js'
Loading
Loading