Skip to content

Commit

Permalink
fix(defaults): fix wrong logic
Browse files Browse the repository at this point in the history
- make alias of mergeRight

Ref #118
  • Loading branch information
char0n committed Aug 10, 2017
1 parent eb95357 commit fbc373f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 43 deletions.
28 changes: 0 additions & 28 deletions src/defaults.js

This file was deleted.

19 changes: 11 additions & 8 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ declare namespace RamdaAdjunct {
*/
concatRight<T extends Array<any>|String>(firstList: T, secondList: T): T;

/**
* Set properties only if they don't exist. Useful for passing defaults. Basically this function
* is the alias of {@link http://ramdajs.com/docs/#merge|merge}.
*/
defaults(defaultOptions: Object, options: Object): Object;
defaults(defaultOptions: Object): (options: Object) => Object;

/**
* Acts as multiple path: arrays of paths in, array of values out. Preserves order.
*/
Expand Down Expand Up @@ -317,17 +310,27 @@ declare namespace RamdaAdjunct {
/**
* Create a new object with the own properties of the second object merged with
* the own properties of the first object. If a key exists in both objects,
* the value from the first object will be used.
* the value from the first object will be used. *
* Putting it simply: it sets properties only if they don't exist.
*/
mergeRight(source: Object, destination: Object): Object;
mergeRight(source: Object): (destination: Object) => Object;

/**
* Reset properties of the object to their default values.
* Alias of {@link http://ramdajs.com/docs/#merge|mergeRight}.
*/
resetToDefault(defaultOptions: Object, options: Object): Object; // alias of mergeRight
resetToDefault(defaultOptions: Object): (options: Object) => Object; // alias of mergeRight

/**
* Set properties only if they don't exist. Useful for passing defaults.
* Alias of {@link http://ramdajs.com/docs/#merge|mergeRight}.
*/
defaults(defaultOptions: Object, options: Object): Object;
defaults(defaultOptions: Object): (options: Object) => Object;


/**
* Weave a configuration into function returning the runnable monad like `Reader` or `Free`.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import list from './list';
import concatRight from './concatRight';
import reduceP from './reduceP';
// Object
import defaults from './defaults';
import paths from './paths';
import renameKeys from './renameKeys';
import renameKeysWith from './renameKeysWith';
Expand Down Expand Up @@ -127,7 +126,6 @@ export { default as list } from './list';
export { default as concatRight } from './concatRight';
export { default as reduceP } from './reduceP';
// Object
export { default as defaults } from './defaults';
export { default as paths } from './paths';
export { default as renameKeys } from './renameKeys';
export { default as renameKeysWith } from './renameKeysWith';
Expand Down Expand Up @@ -204,7 +202,7 @@ const RA = {
concatRight,
reduceP,
// Object
defaults,
defaults: mergeRight,
resetToDefault: mergeRight,
paths,
renameKeys,
Expand Down
9 changes: 5 additions & 4 deletions src/mergeRight.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { merge, flip } from 'ramda';
/**
* Create a new object with the own properties of the second object merged with
* the own properties of the first object. If a key exists in both objects,
* the value from the first object will be used.
* the value from the first object will be used. *
* Putting it simply: it sets properties only if they don't exist.
*
* @func mergeRight
* @aliases resetToDefault
* @aliases resetToDefault, defaults
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/1.6.0|v1.6.0}
* @category Object
* @sig {k: v} -> {k: v} -> {k: v}
* @param {Object} l Source
* @param {Object} r Destination
* @param {Object} l Source
* @return {Object}
* @see {@link http://ramdajs.com/docs/#merge|merge}
* @see {@link http://ramdajs.com/docs/#merge|merge}, {@link https://github.com/ramda/ramda/wiki/Cookbook#set-properties-only-if-they-dont-exist|Ramda Cookbook}
* @example
*
* RA.mergeRight({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
Expand Down

0 comments on commit fbc373f

Please sign in to comment.