Skip to content

Commit c333806

Browse files
committed
fix: module.exports hack assign for cjs
1 parent 3ef1cd7 commit c333806

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/commons/src/index.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function stripSlashes(name: string) {
66
export type KeyValueCallback<T> = (value: any, key: string) => T
77

88
/**
9-
* If the object is an array, it will iterate over every element.
9+
* If the object is an array, it will iterate over every element.
1010
* Otherwise, it will iterate over every key in the object.
1111
*/
1212
export function each(obj: Record<string, any> | any[], callback: KeyValueCallback<void>) {
@@ -19,9 +19,9 @@ export function each(obj: Record<string, any> | any[], callback: KeyValueCallbac
1919

2020
/**
2121
* Check if some values in the object pass the test implemented by the provided function
22-
*
22+
*
2323
* returns true if some values pass the test, otherwise false
24-
*
24+
*
2525
* returns false if the object is empty
2626
*/
2727
export function some(value: Record<string, any>, callback: KeyValueCallback<boolean>) {
@@ -36,9 +36,9 @@ export function some(value: Record<string, any>, callback: KeyValueCallback<bool
3636

3737
/**
3838
* Check if all values in the object pass the test implemented by the provided function
39-
*
39+
*
4040
* returns true if all values pass the test, otherwise false
41-
*
41+
*
4242
* returns true if the object is empty
4343
*/
4444
export function every(value: any, callback: KeyValueCallback<boolean>) {
@@ -67,7 +67,7 @@ export function values(obj: any) {
6767

6868
/**
6969
* Check if values in the source object are equal to the target object
70-
*
70+
*
7171
* Does a shallow comparison
7272
*/
7373
export function isMatch(target: any, source: any) {
@@ -162,9 +162,9 @@ export function createSymbol(name: string) {
162162
/**
163163
* A set of lodash-y utility functions that use ES6
164164
*
165-
* @deprecated Don't use `import { _ } from '@feathersjs/commons'`. You're importing a bunch of functions. You probably only need a few.
165+
* @deprecated Don't use `import { _ } from '@feathersjs/commons'`. You're importing a bunch of functions. You probably only need a few.
166166
* Import them directly instead. For example: `import { merge } from '@feathersjs/commons'`.
167-
*
167+
*
168168
* If you really want to import all functions or do not care about cherry picking, you can use `import * as _ from '@feathersjs/commons'`.
169169
*/
170170
export const _ = {
@@ -180,7 +180,13 @@ export const _ = {
180180
extend,
181181
omit,
182182
pick,
183-
merge
183+
merge,
184+
isPromise,
185+
createSymbol
184186
}
185187

186188
export * from './debug'
189+
190+
if (typeof module !== 'undefined') {
191+
module.exports = Object.assign(_, module.exports)
192+
}

0 commit comments

Comments
 (0)