diff --git a/files/NEXT_VERSION_CHECKLIST.md b/files/NEXT_VERSION_CHECKLIST.md index 22add4e8..54d9ee46 100644 --- a/files/NEXT_VERSION_CHECKLIST.md +++ b/files/NEXT_VERSION_CHECKLIST.md @@ -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 @@ -33,6 +38,9 @@ release string.fn } } }, + + + https://github.com/ramda/types/pull/110/files --- ## ABOVE IS IN PROGRESS @@ -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 --- @@ -155,6 +186,24 @@ export function dissoc(prop: K, obj: T): Om export function dissoc(prop: K): (obj: T) => Omit; --- +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 diff --git a/files/index.d.ts b/files/index.d.ts index a62eddab..ec818ecc 100644 --- a/files/index.d.ts +++ b/files/index.d.ts @@ -487,7 +487,7 @@ const path = 'b.c' const newValue = 2 const obj = { a: 1 } -R.assocPath(path, newValue, Record) +const result = R.assocPath(path, newValue, obj) // => { a : 1, b : { c : 2 }} ``` @@ -2938,9 +2938,9 @@ const pathToSearch = 'a.b' const pathToSearchList = ['a', 'b'] const result = [ - R.path(pathToSearch, Record), - R.path(pathToSearchList, Record), - R.path('a.b.c.d', Record) + R.path(pathToSearch, obj), + R.path(pathToSearchList, obj), + R.path('a.b.c.d', obj) ] // => [1, 1, undefined] ``` diff --git a/source/assocPath.spec.js b/source/assocPath.spec.js index 1c3cd550..e8fbab27 100644 --- a/source/assocPath.spec.js +++ b/source/assocPath.spec.js @@ -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, {} diff --git a/source/path.spec.js b/source/path.spec.js index 238b9eb1..1c0ca299 100644 --- a/source/path.spec.js +++ b/source/path.spec.js @@ -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,