-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add _.words implementation * Updating codesandbox references --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2403496
commit 9740872
Showing
7 changed files
with
33 additions
and
4 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
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,5 @@ | ||
// https://lodash.com/docs/#words | ||
import { words } from 'lodash' | ||
|
||
exports.enumeration = words('fred, barney, & pebbles') | ||
// => ['fred', 'barney', 'pebbles'] |
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,3 @@ | ||
Splits <code>string</code> into an array of its words. | ||
|
||
Resources: [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) |
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,11 @@ | ||
const expected = { | ||
enumeration: ['fred', 'barney', 'pebbles'], | ||
} | ||
|
||
const lodash = require('./lodash') | ||
const plain = require('./vanilla') | ||
|
||
test('words', () => { | ||
expect(lodash).toEqual(expected) | ||
expect(plain).toEqual(lodash) | ||
}) |
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,9 @@ | ||
const words = str => { | ||
const segmenter = new Intl.Segmenter('en', { granularity: 'word' }) | ||
return Array.from(segmenter.segment(str)) | ||
.filter(({ isWordLike }) => isWordLike) | ||
.map(({ segment }) => segment) | ||
} | ||
|
||
exports.enumeration = words('fred, barney, & pebbles') | ||
// => ['fred', 'barney', 'pebbles'] |