Skip to content

Commit

Permalink
Merge 051a07d into 7e8038c
Browse files Browse the repository at this point in the history
  • Loading branch information
DarrenPaulWright committed Feb 14, 2019
2 parents 7e8038c + 051a07d commit 6985ffc
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 58 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [0.3.2] - 2019-2-14
### Changed
- Replaced dependencies on clone and deepEqual with object-agent
- Added ID and callback args to the methodQueue set option

## [0.3.1] - 2019-2-10
### Added
- [castArray](docs/castArray.md)
Expand Down Expand Up @@ -102,6 +107,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial enforcers, methods, and documentation

[0.3.2]: https://github.com/DarrenPaulWright/type-enforcer/compare/v0.3.1...c0.3.2
[0.3.1]: https://github.com/DarrenPaulWright/type-enforcer/compare/v0.3.0...c0.3.1
[0.3.0]: https://github.com/DarrenPaulWright/type-enforcer/compare/v0.2.4...c0.3.0
[0.2.4]: https://github.com/DarrenPaulWright/type-enforcer/compare/v0.2.3...c0.2.4
Expand Down
19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "type-enforcer",
"version": "0.3.1",
"version": "0.3.2",
"description": "Type enforcement library for javascript",
"main": "src/index.js",
"scripts": {
Expand Down Expand Up @@ -40,8 +40,7 @@
},
"homepage": "https://github.com/DarrenPaulWright/type-enforcer#readme",
"dependencies": {
"clone": "^2.1.2",
"deep-equal": "^1.0.1"
"object-agent": "^0.2.1"
},
"devDependencies": {
"@babel/core": "^7.2.2",
Expand Down
3 changes: 1 addition & 2 deletions src/methods/types/methodAny.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import clone from 'clone';
import deepEqual from 'deep-equal';
import { clone, deepEqual } from 'object-agent';
import isArray from '../../checks/types/isArray';
import enforceBoolean from '../../enforcer/types/enforceBoolean';
import before from '../variants/before';
Expand Down
2 changes: 1 addition & 1 deletion src/methods/types/methodKeyValue.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forOwn } from 'object-agent';
import isObject from '../../checks/types/isObject';
import forOwn from '../../utility/forOwn';

/**
* Builds a chainable method that accepts either:
Expand Down
6 changes: 3 additions & 3 deletions src/methods/types/methodQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Queue from '../../types/Queue';
* @function method.queue
*
* @arg {Object} [options]
* @arg {Function} [options.set] - Called after a new callback is added to the queue. Provides a reference to the queue, sets the context to the methods constructor.
* @arg {Function} [options.set] - Called after a new callback is added to the queue. Provides a reference to the queue, the new ID for the callback, the callback, and sets the context to the methods constructor.
*
* @returns {Function} accepts a new value and returns the methods constructor (allows chaining), or if no args are passed returns the instance of Queue
*/
Expand All @@ -27,10 +27,10 @@ export default (options = {}) => {

if (arguments.length) {
if (isFunction(callback)) {
this[key].add(callback);
const ID = this[key].add(callback);

if (options.set) {
options.set.call(this, this[key]);
options.set.call(this, this[key], ID, callback);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/types/Enum.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import forOwn from '../utility/forOwn';
import { forOwn } from 'object-agent';

const KEYS = Symbol();
const VALUES = Symbol();
Expand Down
8 changes: 3 additions & 5 deletions src/types/Queue.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forOwn } from 'object-agent';
import isFunction from '../checks/types/isFunction';
import forOwn from '../utility/forOwn';

const CALLBACKS = Symbol();
const CURRENT_ID = Symbol();
Expand Down Expand Up @@ -101,9 +101,7 @@ export default class Queue {
}
else {
forOwn(this[CALLBACKS], (callback) => {
if (callback) {
callback.function.apply(context, extraArguments);
}
callback.function.apply(context, extraArguments);
});
}
this[IS_BUSY] = false;
Expand All @@ -129,7 +127,7 @@ export default class Queue {
forOwn(this[CALLBACKS], (callback, ID) => {
callback.function.apply(context, extraArguments);
self.discard(ID);
return false;
return true;
});
this[IS_BUSY] = false;

Expand Down
4 changes: 0 additions & 4 deletions src/utility/difference.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/utility/forOwn.js

This file was deleted.

1 change: 0 additions & 1 deletion src/utility/startCase.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/TestUtil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { forOwn } from 'object-agent';
import { isObject } from '../src';
import forOwn from '../src/utility/forOwn';

export const eachPair = (array1, array2, callback, isUnique = false) => {
let i;
Expand Down
3 changes: 2 additions & 1 deletion tests/methods/methodTestUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { assert } from 'chai';
import powerset from 'powerset';
import { enforceString, method, Point } from '../../src';
import { processOutput } from '../../src/methods/variants/helper';
import startCase from '../../src/utility/startCase';

const startCase = (string) => string.split(' ').map((word) => word.charAt(0).toUpperCase()).join(' ');

const TEST_METHOD = 'testMethod';
const variantSet = powerset(['get', 'other', 'before', 'set']);
Expand Down
10 changes: 10 additions & 0 deletions tests/mixins/Removable.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,14 @@ describe('Removable', () => {

assert.isTrue(testClass.isRemoved);
});

it('should not throw an error if remove is called without adding any onRemove callbacks', () => {
class TestClass extends Removable {}

const testClass = new TestClass();

assert.doesNotThrow(() => {
testClass.remove();
});
});
});
6 changes: 5 additions & 1 deletion tests/testValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import {
VIEWPORT_WIDTH,
ZERO_PIXELS
} from '../src';
import difference from '../src/utility/difference';

const difference = (array1, ...args) => {
let diffArrays = [].concat(...args);
return array1.filter((item1) => diffArrays.every((item2) => item1 !== item2));
};

export const validArrays = [[1], [2], [], new Array(), Array()];
export const validBooleans = [true, false, new Boolean(true), Boolean()];
Expand Down
24 changes: 0 additions & 24 deletions tests/utility/difference.Test.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/utility/isElementInDom.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('isElementInDom', () => {
});
it('should return true for an element that is in the Dom', () => {
const element = document.createElement('div');
document.body.appendChild(element)
document.body.appendChild(element);
assert.isTrue(isElementInDom(element));
});
});

0 comments on commit 6985ffc

Please sign in to comment.