Skip to content

javajosh/combine-keys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

CombineKeys is a function that combines javascript objects key-wise. This module exposes a single function, combineKeys, which has the following interface:

oResult = combineKeys(oSource, oTarget, bMutate = false)

This is hungarian notation to indicate types, where "o" means "object" and "b" means "boolean". The = false part means that a) the argument isn't required, and b) the default is false.

The action of the function is to combine source and target into a new object that has the keys of both. What is different about combineKeys is that it strives to be lossless. Target values with the same key aren't replaced, but rather the source and target is combined a controlled way that "makes sense".

To be honest it's a very short function, and I recommend you read the source. The tests are also important.

How to use the function.

>npm install --save combine-keys
var combineKeys = require('combineKeys')

How to test, build, contribute.

[install node]
[open a terminal]
git checkout combine-keys
cd combine-keys
npm install
npm run test

npm browser

If you don't get errors in the terminal (npm run test) or the browser console (npm browser), then it works. You'll then want to edit combineKeys.js, and/or add tests to tests.js, then run npm run test again. (Actually you should fork this repo, create a branch, edit the branch, cleanup the branch, run npm run lint and issue a pull request. But that's beyond the scope of this document!)

Note that you'll also want to install an EditorConfig plugin into your editor.

TODO:

  1. Add code to allow direct inclusion into a browser (with script.src='combineKeys.js').
  2. Write more tests, especially around mutation
  3. Spruce this project up with tips from filipedeschamps/rss-feed-emitter#119
  4. Push to github.
  5. push to npm
  6. Add http://editorconfig.org/ Also see https://duckduckgo.com/?q=sublime+text+editorconfig see .editorconfig
  7. Add http://eslint.org/ npm run lint see .eslintrc
  8. Add babel npm run build see .babelrc - support es2015 (es6). outputs to combineKeys.build.js

About

CombineKeys is a JavaScript function that combines the keys of two objects in novel ways.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published