Repository: ViacomInc/data-point
Pull request #125 (2018-01-07 16:29:16)

Normalize name of reducer isType functions
**What**: Give each reducer an `isType` function instead of functions like `isFunction`, `isEntity`, etc.

<!-- Why are these changes necessary? -->
**Why**: More consistency, so we can say exactly what functions a new reducer will need to have.

<!-- How were these changes implemented? -->
**How**:

<!-- Have you done all of these things?  -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
- [ ] Documentation n/a
- [x] Tests
- [x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->

coveralls: 
[![Coverage Status](https://coveralls.io/builds/14938396/badge)](https://coveralls.io/builds/14938396)

Coverage remained the same at 100.0% when pulling **73f82d5f271e8676bbbd832bde8247c2e1838793 on raingerber:normalize-reducer-is-type-functions** into **c7edec115e953e01e9247bcd9b5477cf1fda247b on ViacomInc:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/14948445/badge)](https://coveralls.io/builds/14948445)

Coverage remained the same at 100.0% when pulling **75a804a518d30c17b6240eb2c0bb869c073d24b6 on raingerber:normalize-reducer-is-type-functions** into **d719c9f61089dcd99c918662e173093ba193c7c0 on ViacomInc:master**.


Patch:
diff --git a/packages/data-point/lib/entity-types/spec/index.js b/packages/data-point/lib/entity-types/spec/index.js
index 9d90c13..9622679 100644
--- a/packages/data-point/lib/entity-types/spec/index.js
+++ b/packages/data-point/lib/entity-types/spec/index.js
@@ -5,5 +5,5 @@ const reducer = require('./factory')
 module.exports = {
   create: reducer.create,
   type: reducer.type,
-  isType: reducer.isEntity
+  isType: reducer.isType
 }
diff --git a/packages/data-point/lib/reducer-types/reducer-entity/factory.js b/packages/data-point/lib/reducer-types/reducer-entity/factory.js
index bae8299..4eae6b4 100644
--- a/packages/data-point/lib/reducer-types/reducer-entity/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-entity/factory.js
@@ -23,14 +23,18 @@ function ReducerEntity () {
 
 module.exports.ReducerEntity = ReducerEntity
 
-function isEntity (source) {
+/**
+ * @param {*} source
+ * @returns {boolean}
+ */
+function isType (source) {
   return (
     _.isString(source) &&
     source.match(/^([^$][\w.]*):([\w.-]+)(\[])?$/) !== null
   )
 }
 
-module.exports.isEntity = isEntity
+module.exports.isType = isType
 
 /**
  * parse reducer
diff --git a/packages/data-point/lib/reducer-types/reducer-entity/index.js b/packages/data-point/lib/reducer-types/reducer-entity/index.js
index 7008c5a..e4b95bc 100644
--- a/packages/data-point/lib/reducer-types/reducer-entity/index.js
+++ b/packages/data-point/lib/reducer-types/reducer-entity/index.js
@@ -6,6 +6,6 @@ const resolve = require('./resolve').resolve
 module.exports = {
   create: reducer.create,
   type: reducer.type,
-  isType: reducer.isEntity,
+  isType: reducer.isType,
   resolve: resolve
 }
diff --git a/packages/data-point/lib/reducer-types/reducer-function/factory.js b/packages/data-point/lib/reducer-types/reducer-function/factory.js
index e3f9b3e..62c00b6 100644
--- a/packages/data-point/lib/reducer-types/reducer-function/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-function/factory.js
@@ -25,11 +25,11 @@ module.exports.ReducerFunction = ReducerFunction
  * @param {*} source
  * @returns {boolean}
  */
-function isFunction (source) {
+function isType (source) {
   return _.isFunction(source)
 }
 
-module.exports.isFunction = isFunction
+module.exports.isType = isType
 
 /**
  * @param {Function} fn
diff --git a/packages/data-point/lib/reducer-types/reducer-function/index.js b/packages/data-point/lib/reducer-types/reducer-function/index.js
index 45bdb83..e4b95bc 100644
--- a/packages/data-point/lib/reducer-types/reducer-function/index.js
+++ b/packages/data-point/lib/reducer-types/reducer-function/index.js
@@ -6,6 +6,6 @@ const resolve = require('./resolve').resolve
 module.exports = {
   create: reducer.create,
   type: reducer.type,
-  isType: reducer.isFunction,
+  isType: reducer.isType,
   resolve: resolve
 }
diff --git a/packages/data-point/lib/reducer-types/reducer-object/factory.js b/packages/data-point/lib/reducer-types/reducer-object/factory.js
index b63a2b0..9d6f4cc 100644
--- a/packages/data-point/lib/reducer-types/reducer-object/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-object/factory.js
@@ -20,11 +20,11 @@ module.exports.ReducerObject = ReducerObject
  * @param {*} source
  * @returns {boolean}
  */
-function isObject (source) {
+function isType (source) {
   return isPlainObject(source)
 }
 
-module.exports.isObject = isObject
+module.exports.isType = isType
 
 /**
  * @param {Function} createReducer
diff --git a/packages/data-point/lib/reducer-types/reducer-object/index.js b/packages/data-point/lib/reducer-types/reducer-object/index.js
index 4c6c98b..e4b95bc 100644
--- a/packages/data-point/lib/reducer-types/reducer-object/index.js
+++ b/packages/data-point/lib/reducer-types/reducer-object/index.js
@@ -6,6 +6,6 @@ const resolve = require('./resolve').resolve
 module.exports = {
   create: reducer.create,
   type: reducer.type,
-  isType: reducer.isObject,
+  isType: reducer.isType,
   resolve: resolve
 }
diff --git a/packages/data-point/lib/reducer-types/reducer-path/factory.js b/packages/data-point/lib/reducer-types/reducer-path/factory.js
index 300b988..eaf8cc9 100644
--- a/packages/data-point/lib/reducer-types/reducer-path/factory.js
+++ b/packages/data-point/lib/reducer-types/reducer-path/factory.js
@@ -25,11 +25,11 @@ module.exports.ReducerPath = ReducerPath
  * @param {*} source
  * @returns {boolean}
  */
-function isPath (source) {
+function isType (source) {
   return _.isString(source) && source.charAt(0) === '$'
 }
 
-module.exports.isPath = isPath
+module.exports.isType = isType
 
 /**
  * @param {Accumulator} acc
diff --git a/packages/data-point/lib/reducer-types/reducer-path/index.js b/packages/data-point/lib/reducer-types/reducer-path/index.js
index 0d2bbd2..e4b95bc 100644
--- a/packages/data-point/lib/reducer-types/reducer-path/index.js
+++ b/packages/data-point/lib/reducer-types/reducer-path/index.js
@@ -6,6 +6,6 @@ const resolve = require('./resolve').resolve
 module.exports = {
   create: reducer.create,
   type: reducer.type,
-  isType: reducer.isPath,
+  isType: reducer.isType,
   resolve: resolve
 }


Test patch:
diff --git a/packages/data-point/lib/reducer-types/reducer-entity/factory.test.js b/packages/data-point/lib/reducer-types/reducer-entity/factory.test.js
index 80c821b..958b5a6 100644
--- a/packages/data-point/lib/reducer-types/reducer-entity/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-entity/factory.test.js
@@ -3,25 +3,25 @@
 
 const factory = require('./factory')
 
-test('reducer/reducer-entity#isEntity', () => {
-  expect(factory.isEntity('a')).toBe(false)
-  expect(factory.isEntity('ab')).toBe(false)
-  expect(factory.isEntity('#ab')).toBe(false)
-  expect(factory.isEntity('abc')).toBe(false)
-  expect(factory.isEntity('ab:')).toBe(false)
-  expect(factory.isEntity(':ab')).toBe(false)
-  expect(factory.isEntity('$a:abc')).toBe(false)
-  expect(factory.isEntity('a-bc:abc')).toBe(false)
-  expect(factory.isEntity('a:abc')).toBe(true)
-  expect(factory.isEntity('abc:a')).toBe(true)
-  expect(factory.isEntity('abc:abc')).toBe(true)
-  expect(factory.isEntity('?abc:abc')).toBe(true)
-  expect(factory.isEntity('abc:ab-c-')).toBe(true)
-  expect(factory.isEntity('_abc:abc')).toBe(true)
-  expect(factory.isEntity('#abc:abc')).toBe(true)
-  expect(factory.isEntity('abc:abc[]')).toBe(true)
-  expect(factory.isEntity('abc:abc[][]')).toBe(false)
-  expect(factory.isEntity('abc:abc[]d')).toBe(false)
+test('reducer/reducer-entity#isType', () => {
+  expect(factory.isType('a')).toBe(false)
+  expect(factory.isType('ab')).toBe(false)
+  expect(factory.isType('#ab')).toBe(false)
+  expect(factory.isType('abc')).toBe(false)
+  expect(factory.isType('ab:')).toBe(false)
+  expect(factory.isType(':ab')).toBe(false)
+  expect(factory.isType('$a:abc')).toBe(false)
+  expect(factory.isType('a-bc:abc')).toBe(false)
+  expect(factory.isType('a:abc')).toBe(true)
+  expect(factory.isType('abc:a')).toBe(true)
+  expect(factory.isType('abc:abc')).toBe(true)
+  expect(factory.isType('?abc:abc')).toBe(true)
+  expect(factory.isType('abc:ab-c-')).toBe(true)
+  expect(factory.isType('_abc:abc')).toBe(true)
+  expect(factory.isType('#abc:abc')).toBe(true)
+  expect(factory.isType('abc:abc[]')).toBe(true)
+  expect(factory.isType('abc:abc[][]')).toBe(false)
+  expect(factory.isType('abc:abc[]d')).toBe(false)
 })
 
 describe('create', function () {
diff --git a/packages/data-point/lib/reducer-types/reducer-function/factory.test.js b/packages/data-point/lib/reducer-types/reducer-function/factory.test.js
index 959bc5e..657e3ab 100644
--- a/packages/data-point/lib/reducer-types/reducer-function/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-function/factory.test.js
@@ -3,10 +3,10 @@
 
 const rf = require('./factory')
 
-test('reducer/reducer-function#isFunction', () => {
-  expect(rf.isFunction('$foo')).toBe(false)
-  expect(rf.isFunction('foo()')).toBe(false)
-  expect(rf.isFunction(() => true)).toBe(true)
+test('reducer/reducer-function#isType', () => {
+  expect(rf.isType('$foo')).toBe(false)
+  expect(rf.isType('foo()')).toBe(false)
+  expect(rf.isType(() => true)).toBe(true)
 })
 
 describe('reducer/reducer-function#validateFunction', () => {
diff --git a/packages/data-point/lib/reducer-types/reducer-object/factory.test.js b/packages/data-point/lib/reducer-types/reducer-object/factory.test.js
index 4fa709a..e2d20fd 100644
--- a/packages/data-point/lib/reducer-types/reducer-object/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-object/factory.test.js
@@ -4,11 +4,11 @@
 const factory = require('./factory')
 const createReducer = require('../index').create
 
-test('reducer/reducer-function#isObject', () => {
-  expect(factory.isObject('$foo')).toBe(false)
-  expect(factory.isObject(() => true)).toBe(false)
-  expect(factory.isObject([])).toBe(false)
-  expect(factory.isObject({})).toBe(true)
+test('reducer/reducer-function#isType', () => {
+  expect(factory.isType('$foo')).toBe(false)
+  expect(factory.isType(() => true)).toBe(false)
+  expect(factory.isType([])).toBe(false)
+  expect(factory.isType({})).toBe(true)
 })
 
 describe('reducer/reducer-function#getReducerProps', () => {
diff --git a/packages/data-point/lib/reducer-types/reducer-path/factory.test.js b/packages/data-point/lib/reducer-types/reducer-path/factory.test.js
index f88848c..14387c3 100644
--- a/packages/data-point/lib/reducer-types/reducer-path/factory.test.js
+++ b/packages/data-point/lib/reducer-types/reducer-path/factory.test.js
@@ -3,9 +3,9 @@
 
 const factory = require('./factory')
 
-it('reducer/reducer-path#isPath', () => {
-  expect(factory.isPath('#a')).not.toBe('is not path')
-  expect(factory.isPath('$.')).toBeTruthy()
+it('reducer/reducer-path#isType', () => {
+  expect(factory.isType('#a')).not.toBe('is not path')
+  expect(factory.isType('$.')).toBeTruthy()
 })
 
 describe('ReducerPath getters', () => {