Skip to content

Commit e1da4fb

Browse files
committed
Export util functions
1 parent 777e2c4 commit e1da4fb

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

src/InputRange/util.js

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @param {number} max
1717
* @return {number}
1818
*/
19-
function clamp(value, min, max) {
19+
export function clamp(value, min, max) {
2020
return Math.min(Math.max(value, min), max);
2121
}
2222

@@ -27,7 +27,7 @@ function clamp(value, min, max) {
2727
* @param {...Object} sources - Source objects
2828
* @return {Object} Destination object, extended with members from sources
2929
*/
30-
function extend() {
30+
export function extend() {
3131
return Object.assign.apply(Object, arguments);
3232
}
3333

@@ -38,7 +38,7 @@ function extend() {
3838
* @param {number} value
3939
* @return {boolean}
4040
*/
41-
function includes(array, value) {
41+
export function includes(array, value) {
4242
return array.indexOf(value) > -1;
4343
}
4444

@@ -49,7 +49,7 @@ function includes(array, value) {
4949
* @param {Array.<string>} omitKeys
5050
* @return {Object}
5151
*/
52-
function omit(obj, omitKeys) {
52+
export function omit(obj, omitKeys) {
5353
const keys = Object.keys(obj);
5454
const outputObj = {};
5555

@@ -68,7 +68,7 @@ function omit(obj, omitKeys) {
6868
* @param {string} string
6969
* @return {string}
7070
*/
71-
function captialize(string) {
71+
export function captialize(string) {
7272
return string.charAt(0).toUpperCase() + string.slice(1);
7373
}
7474

@@ -79,7 +79,7 @@ function captialize(string) {
7979
* @param {Point} pointB
8080
* @return {number} Distance
8181
*/
82-
function distanceTo(pointA, pointB) {
82+
export function distanceTo(pointA, pointB) {
8383
return Math.sqrt(Math.pow(pointB.x - pointA.x, 2) + Math.pow(pointB.y - pointA.y, 2));
8484
}
8585

@@ -90,7 +90,7 @@ function distanceTo(pointA, pointB) {
9090
* @param {number} numB
9191
* @return {number}
9292
*/
93-
function length(numA, numB) {
93+
export function length(numA, numB) {
9494
return Math.abs(numA - numB);
9595
}
9696

@@ -100,7 +100,7 @@ function length(numA, numB) {
100100
* @param {*} value
101101
* @return {Boolean}
102102
*/
103-
function isNumber(value) {
103+
export function isNumber(value) {
104104
return typeof value === 'number';
105105
}
106106

@@ -110,7 +110,7 @@ function isNumber(value) {
110110
* @param {*} value
111111
* @return {Boolean}
112112
*/
113-
function isObject(value) {
113+
export function isObject(value) {
114114
return value !== null && typeof value === 'object';
115115
}
116116

@@ -120,7 +120,7 @@ function isObject(value) {
120120
* @param {*} value
121121
* @return {Boolean}
122122
*/
123-
function isDefined(value) {
123+
export function isDefined(value) {
124124
return value !== undefined && value !== null;
125125
}
126126

@@ -130,7 +130,7 @@ function isDefined(value) {
130130
* @param {Object|Array} obj
131131
* @return {Boolean}
132132
*/
133-
function isEmpty(obj) {
133+
export function isEmpty(obj) {
134134
if (!obj) {
135135
return true;
136136
}
@@ -149,7 +149,7 @@ function isEmpty(obj) {
149149
* @param {predicateFn} predicate
150150
* @return {Boolean}
151151
*/
152-
function arrayOf(array, predicate) {
152+
export function arrayOf(array, predicate) {
153153
if (!Array.isArray(array)) {
154154
return false;
155155
}
@@ -171,7 +171,7 @@ function arrayOf(array, predicate) {
171171
* @param {Array.<string>} keys
172172
* @return {Boolean}
173173
*/
174-
function objectOf(object, predicate, keys) {
174+
export function objectOf(object, predicate, keys) {
175175
if (!isObject(object)) {
176176
return false;
177177
}
@@ -195,24 +195,8 @@ function objectOf(object, predicate, keys) {
195195
* @param {Array.<Function>} methodNames
196196
* @param {Object} instance
197197
*/
198-
function autobind(methodNames, instance) {
198+
export function autobind(methodNames, instance) {
199199
methodNames.forEach((methodName) => {
200200
instance[methodName] = instance[methodName].bind(instance);
201201
});
202202
}
203-
204-
export default {
205-
arrayOf,
206-
autobind,
207-
captialize,
208-
clamp,
209-
distanceTo,
210-
extend,
211-
isDefined,
212-
isEmpty,
213-
isNumber,
214-
isObject,
215-
length,
216-
objectOf,
217-
omit,
218-
};

0 commit comments

Comments
 (0)