-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log one-time warning when not specifying a partitioner
This is to hopefully avoid people mistakenly using the wrong partitioner because they're relying on the default. This warning will be removed in a future version.
- Loading branch information
Showing
5 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = fn => { | ||
let called = false | ||
|
||
return (...args) => { | ||
if (!called) { | ||
called = true | ||
return fn(...args) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const once = require('./once') | ||
|
||
describe('Utils > once', () => { | ||
it('should call the wrapped function only once', () => { | ||
const original = jest.fn().mockReturnValue('foo') | ||
const wrapped = once(original) | ||
|
||
expect(wrapped('hello')).toEqual('foo') | ||
expect(wrapped('hello')).toBeUndefined() | ||
|
||
expect(original).toHaveBeenCalledTimes(1) | ||
expect(original).toHaveBeenCalledWith('hello') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
const BASE_URL = 'https://kafka.js.org' | ||
const stripLeading = char => str => (str.charAt(0) === char ? str.substring(1) : str) | ||
const stripLeadingSlash = stripLeading('/') | ||
const stripLeadingHash = stripLeading('#') | ||
|
||
module.exports = (path, hash) => `${BASE_URL}/${path}${hash ? '#' + hash : ''}` | ||
module.exports = (path, hash) => | ||
`${BASE_URL}/${stripLeadingSlash(path)}${hash ? '#' + stripLeadingHash(hash) : ''}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters