Skip to content

Commit

Permalink
feat@fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
selfrefactor committed Nov 23, 2024
1 parent 7eb249a commit e528ba9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
51 changes: 50 additions & 1 deletion files/NEXT_VERSION_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
---
ABOVE IS DONE
---

https://github.com/ramda/types/pull/127/files

cneck
// expect(withNumber).toEqual(withNumberExpected)

https://github.com/ramda/ramda/pull/3441/files
https://github.com/ramda/types/pull/122/files

share about bug with assocpath
https://github.com/ramda/types/pull/129/files#diff-d9fac8353ad9864266cabb1f64898d7290f9c71bac877858f72feeaef3c55351

update Rambdax and release to now
https://github.com/selfrefactor/rambda/pull/744
Expand All @@ -33,6 +38,9 @@ release string.fn
}
}
},


https://github.com/ramda/types/pull/110/files
---

## ABOVE IS IN PROGRESS
Expand Down Expand Up @@ -85,6 +93,29 @@ chech in to read for examples
---
https://zuplo.com/blog/2024/10/10/unlocking-the-power-of-json-patch
---
test('bug 524', () => {
/*
https://github.com/selfrefactor/rambda/issues/524
*/
const state = {}

const withDateLike = assocPathFn(
[ 'outerProp', '2020-03-10' ],
{ prop : 2 },
state
)
const withNumber = assocPathFn(
[ 'outerProp,5' ], { prop : 2 }, state
)

const withDateLikeExpected = { outerProp : { '2020-03-10' : { prop : 2 } } }
const withNumberExpected = { outerProp : { 5 : { prop : 2 } } }
expect(withDateLike).toEqual(withDateLikeExpected)
// expect(withNumber).toEqual(withNumberExpected)
})

assocpath
---
bench against https://romgrk.com/posts/optimizing-javascript#3-avoid-arrayobject-methods
---

Expand Down Expand Up @@ -155,6 +186,24 @@ export function dissoc<T extends object, K extends keyof T>(prop: K, obj: T): Om
export function dissoc<K extends string | number>(prop: K): <T extends object>(obj: T) => Omit<T, K>;

---
const nestedObject = {
* a: {
* b: {
* c: 1
* }
* },
* d: [2, 3]
* };
*
* const flattened = flattenObject(nestedObject);
* console.log(flattened);
* // Output:
* // {
* // 'a.b.c': 1,
* // 'd.0': 2,
* // 'd.1': 3
* // }
---

## https://github.com/ramda/ramda/issues/3390

Expand Down
8 changes: 4 additions & 4 deletions files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ const path = 'b.c'
const newValue = 2
const obj = { a: 1 }
R.assocPath(path, newValue, Record<string, unknown>)
const result = R.assocPath(path, newValue, obj)
// => { a : 1, b : { c : 2 }}
```
Expand Down Expand Up @@ -2938,9 +2938,9 @@ const pathToSearch = 'a.b'
const pathToSearchList = ['a', 'b']
const result = [
R.path(pathToSearch, Record<string, unknown>),
R.path(pathToSearchList, Record<string, unknown>),
R.path('a.b.c.d', Record<string, unknown>)
R.path(pathToSearch, obj),
R.path(pathToSearchList, obj),
R.path('a.b.c.d', obj)
]
// => [1, 1, undefined]
```
Expand Down
21 changes: 0 additions & 21 deletions source/assocPath.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,6 @@ test('difference with ramda - doesn\'t overwrite primitive values with keys in t
})
})

test('bug 524', () => {
/*
https://github.com/selfrefactor/rambda/issues/524
*/
const state = {}

const withDateLike = assocPathFn(
[ 'outerProp', '2020-03-10' ],
{ prop : 2 },
state
)
const withNumber = assocPathFn(
[ 'outerProp,5' ], { prop : 2 }, state
)

const withDateLikeExpected = { outerProp : { '2020-03-10' : { prop : 2 } } }
const withNumberExpected = { outerProp : { 5 : { prop : 2 } } }
expect(withDateLike).toEqual(withDateLikeExpected)
// expect(withNumber).toEqual(withNumberExpected)
})

test('adds a key to an empty object', () => {
expect(assocPathFn(
[ 'a' ], 1, {}
Expand Down
6 changes: 4 additions & 2 deletions source/path.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ test('works with string instead of array', () => {

test('path', () => {
expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : { baz : 'yes' } } })).toBe('yes')

expect(path([ 'foo', 'bar', 'baz' ])(null)).toBeUndefined()

expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : 'baz' } })).toBeUndefined()
})

test('with number string in between', () => {
expect(path(['a','1','b'], {a: [{b: 1}, {b: 2}]})).toBe(2)
})

test('null is not a valid path', () => {
expect(path('audio_tracks', {
a : 1,
Expand Down

0 comments on commit e528ba9

Please sign in to comment.