Comments (6)
The issue got autoclosed with merging the PR.
I added a fallback for browsers that don't support positive lookbehind in regex. Let me know if it works! :)
We can still discuss if it makes sense to modify inputs in merge.
from moderndash.
Sorry about the original RegEx—just noticed there were tests! This one should cover everything in the tests, plus some other edge cases like "enable6HFormat" -> ["enable", "6H", "Format"] while still maintaining a small file size:
const splitWordsRegex = /(\d*[a-z]+)|([A-Z][a-z]+)|(\d*[A-Z]+(?=[^a-z]|$))|(\d+)/g;
(I got the enable6HFormat from here: https://github.com/lodash/lodash/blob/4.17.11/test/test.js#L2351)
P.S. The fallback works!
from moderndash.
Thanks, this is a much simpler solution. I deployed it in 3.3.1. It is 10% slower than my lookbehind solution, but the
"enable6HFormat" -> ["enable", "6H", "format"]
case was handled differently. It makes sense to match lodash's behaviour and its still 2x faster. 🥳
from moderndash.
Hi @acorn1010, thanks for the suggestion. I will answer this step by step. Your regex doesn't account for this case:
AssertionError: expected 'some_cruelw_orld' to be 'some_cruel_world' // Object.is equality
❯ test/string/snakeCase.test.ts:10:45
10| expect(snakeCase('someCRUELWorld')).toBe('some_cruel_world');
| ^
11| });
12|
- Expected "some_cruel_world"
+ Received "some_cruelw_orld"
But I agree that we should at least make it compatible with Safari 15. I will see what good replacements are out there when I have the time.
from moderndash.
range(0, 3) is inclusive instead of exclusive (e.g. returns [0, 1, 2, 3] instead of [0, 1, 2]). This is different from Lodash and caused some bugs.
I decided to do this to have a more readable syntax. All ranges in moderndash include the last parameter. In randomInt and randomFloat the last parameter is also included in the range.
ModernDash is not intended to be a drop-in replacement. Instead, I tried to make the syntax as readable as possible. Therefore I would like to keep the range
function as it is.
from moderndash.
@acorn1010 opened a new issue for the array mutations, where we can discuss this further. ⬆️
from moderndash.
Related Issues (20)
- T39 Decorators
- Switch to mutations instead of copy HOT 1
- `takeRightWhile` | Improve performance HOT 1
- `set` | Incorrect type if value is replaced by array
- Add possibility to wait until the queue finishes HOT 3
- Non-constructing `object.set`
- Shouldn't `hotscript` be in the main dependencies since it's imported in `dist/index.d.ts`? HOT 2
- Bundle hotscript types
- Feature request - `mergeWith` HOT 3
- Feature request: debounce.pending() HOT 2
- Feature request - `deepFreeze` HOT 1
- Return the result of the last `throttle` invocation HOT 3
- Feature request - `curry`
- PlainObject not working with Interfaces HOT 3
- Feature request - `truncate` HOT 2
- Deprecate array `group` HOT 2
- Feature request - Array/concat HOT 5
- Feature request - clone HOT 3
- Feature request - cloneDeep HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moderndash.