Comparing version 1.0.5 to 1.0.7
{ | ||
"name": "baseliner", | ||
"version": "1.0.5", | ||
"version": "1.0.7", | ||
"description": "compare objects with ease", | ||
"main": "build/index.js", | ||
"main": "build/index.cjs.js", | ||
"module": "build/index.es.js", | ||
"scripts": { | ||
"build": "babel src -d build", | ||
"build": "rollup --config", | ||
"test": "jest", | ||
@@ -20,3 +21,2 @@ "test:watch": "npm test -- --watch", | ||
"babel-cli": "^6.26.0", | ||
"babel-jest": "^21.2.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
@@ -26,6 +26,4 @@ "babel-preset-env": "^1.6.1", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-commonjs": "^8.2.6", | ||
"rollup-plugin-node-resolve": "^3.0.0" | ||
}, | ||
"dependencies": {} | ||
} | ||
} |
@@ -1,1 +0,65 @@ | ||
# baseliner | ||
# Baseliner | ||
A small utility that makes comparing objects easy. | ||
## Install | ||
Simply install the package in your project with npm, and you're ready to go. | ||
``` | ||
npm install --save baseliner | ||
``` | ||
## Usage | ||
Baseliner exports a default function called `baseliner`, which takes in four arguments: | ||
``` | ||
baseliner(baseObject, compareObject, key, compareFunction) | ||
``` | ||
### Arguments | ||
| Input | Type | Description | | ||
|:--- |:--- |:--- | | ||
|`baseObject`| object | The object acting as the baseline | | ||
| `compareObject`| object | The object to compare to the baseline | | ||
| `key` | string | The key on which to compare the objects | | ||
|`compareFunction` | function | A function that compares two values | | ||
### Returns | ||
* Whatever `compareFunction` returns | ||
### Example | ||
Say we are have three friends, and we want to compare their ages. We can use `baseliner` to help us do this. | ||
```javascript | ||
import baseliner from 'baseliner'; | ||
// Ages of the three friends | ||
const legolas = { age: 600 }; | ||
const gimli = { age: 140 }; | ||
const aragorn = { age: 88 }; | ||
// function to compare ages--return true if older than the base | ||
const compare = (base, obj) => obj > base; | ||
// Say Gimli is our base | ||
const vsLegolas = baseliner(gimli, legolas, "age", compare); // true | ||
const vsAragorn = baseliner(gimli, aragorn, "age", compare); // false | ||
``` | ||
## Contributing | ||
Contributions are welcome! Here are some suggestions: | ||
* Links to use cases/examples | ||
* Adding common comparison functions | ||
* Additional utilities for advanced usage | ||
* Update documentation/readme | ||
## License | ||
This project is licensed under the MIT License |
import resolve from "rollup-plugin-node-resolve"; | ||
import commonjs from "rollup-plugin-commonjs"; | ||
import babel from "rollup-plugin-babel"; | ||
@@ -7,17 +6,27 @@ | ||
input: "src/index.js", | ||
output: { | ||
file: "build/bundle.js", | ||
format: "cjs" | ||
}, | ||
output: [ | ||
{ | ||
file: "build/index.cjs.js", | ||
format: "cjs" | ||
}, | ||
{ | ||
file: "build/index.es.js", | ||
format: "es" | ||
} | ||
], | ||
plugins: [ | ||
resolve(), | ||
babel({ | ||
exclude: "node_modules/**" | ||
}), | ||
commonjs({ | ||
namedExports: { | ||
"node_modules/lodash.curry/index.js": ["named"] | ||
} | ||
presets: [ | ||
[ | ||
"env", | ||
{ | ||
modules: false | ||
} | ||
] | ||
], | ||
plugins: ["external-helpers"], | ||
babelrc: false | ||
}) | ||
] | ||
}; |
3733
6
8
52
65