Skip to content

Commit e528ba9

Browse files
committed
feat@fix docs
1 parent 7eb249a commit e528ba9

File tree

4 files changed

+58
-28
lines changed

4 files changed

+58
-28
lines changed

files/NEXT_VERSION_CHECKLIST.md

+50-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
---
33
ABOVE IS DONE
44
---
5+
6+
https://github.com/ramda/types/pull/127/files
7+
58
cneck
69
// expect(withNumber).toEqual(withNumberExpected)
710

11+
https://github.com/ramda/ramda/pull/3441/files
12+
https://github.com/ramda/types/pull/122/files
813

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

1116
update Rambdax and release to now
1217
https://github.com/selfrefactor/rambda/pull/744
@@ -33,6 +38,9 @@ release string.fn
3338
}
3439
}
3540
},
41+
42+
43+
https://github.com/ramda/types/pull/110/files
3644
---
3745

3846
## ABOVE IS IN PROGRESS
@@ -85,6 +93,29 @@ chech in to read for examples
8593
---
8694
https://zuplo.com/blog/2024/10/10/unlocking-the-power-of-json-patch
8795
---
96+
test('bug 524', () => {
97+
/*
98+
https://github.com/selfrefactor/rambda/issues/524
99+
*/
100+
const state = {}
101+
102+
const withDateLike = assocPathFn(
103+
[ 'outerProp', '2020-03-10' ],
104+
{ prop : 2 },
105+
state
106+
)
107+
const withNumber = assocPathFn(
108+
[ 'outerProp,5' ], { prop : 2 }, state
109+
)
110+
111+
const withDateLikeExpected = { outerProp : { '2020-03-10' : { prop : 2 } } }
112+
const withNumberExpected = { outerProp : { 5 : { prop : 2 } } }
113+
expect(withDateLike).toEqual(withDateLikeExpected)
114+
// expect(withNumber).toEqual(withNumberExpected)
115+
})
116+
117+
assocpath
118+
---
88119
bench against https://romgrk.com/posts/optimizing-javascript#3-avoid-arrayobject-methods
89120
---
90121

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

157188
---
189+
const nestedObject = {
190+
* a: {
191+
* b: {
192+
* c: 1
193+
* }
194+
* },
195+
* d: [2, 3]
196+
* };
197+
*
198+
* const flattened = flattenObject(nestedObject);
199+
* console.log(flattened);
200+
* // Output:
201+
* // {
202+
* // 'a.b.c': 1,
203+
* // 'd.0': 2,
204+
* // 'd.1': 3
205+
* // }
206+
---
158207

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

files/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ const path = 'b.c'
487487
const newValue = 2
488488
const obj = { a: 1 }
489489
490-
R.assocPath(path, newValue, Record<string, unknown>)
490+
const result = R.assocPath(path, newValue, obj)
491491
// => { a : 1, b : { c : 2 }}
492492
```
493493
@@ -2938,9 +2938,9 @@ const pathToSearch = 'a.b'
29382938
const pathToSearchList = ['a', 'b']
29392939
29402940
const result = [
2941-
R.path(pathToSearch, Record<string, unknown>),
2942-
R.path(pathToSearchList, Record<string, unknown>),
2943-
R.path('a.b.c.d', Record<string, unknown>)
2941+
R.path(pathToSearch, obj),
2942+
R.path(pathToSearchList, obj),
2943+
R.path('a.b.c.d', obj)
29442944
]
29452945
// => [1, 1, undefined]
29462946
```

source/assocPath.spec.js

-21
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,6 @@ test('difference with ramda - doesn\'t overwrite primitive values with keys in t
5555
})
5656
})
5757

58-
test('bug 524', () => {
59-
/*
60-
https://github.com/selfrefactor/rambda/issues/524
61-
*/
62-
const state = {}
63-
64-
const withDateLike = assocPathFn(
65-
[ 'outerProp', '2020-03-10' ],
66-
{ prop : 2 },
67-
state
68-
)
69-
const withNumber = assocPathFn(
70-
[ 'outerProp,5' ], { prop : 2 }, state
71-
)
72-
73-
const withDateLikeExpected = { outerProp : { '2020-03-10' : { prop : 2 } } }
74-
const withNumberExpected = { outerProp : { 5 : { prop : 2 } } }
75-
expect(withDateLike).toEqual(withDateLikeExpected)
76-
// expect(withNumber).toEqual(withNumberExpected)
77-
})
78-
7958
test('adds a key to an empty object', () => {
8059
expect(assocPathFn(
8160
[ 'a' ], 1, {}

source/path.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ test('works with string instead of array', () => {
2020

2121
test('path', () => {
2222
expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : { baz : 'yes' } } })).toBe('yes')
23-
2423
expect(path([ 'foo', 'bar', 'baz' ])(null)).toBeUndefined()
25-
2624
expect(path([ 'foo', 'bar', 'baz' ])({ foo : { bar : 'baz' } })).toBeUndefined()
2725
})
2826

27+
test('with number string in between', () => {
28+
expect(path(['a','1','b'], {a: [{b: 1}, {b: 2}]})).toBe(2)
29+
})
30+
2931
test('null is not a valid path', () => {
3032
expect(path('audio_tracks', {
3133
a : 1,

0 commit comments

Comments
 (0)