Skip to content

Commit

Permalink
$.isNumeric -> core/utils/type/isNumeric
Browse files Browse the repository at this point in the history
  • Loading branch information
mpreyskurantov committed Oct 28, 2024
1 parent a826257 commit 2ac7418
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
47 changes: 24 additions & 23 deletions packages/devextreme/testing/helpers/nativePointerMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
const isString = function(val) { return typeof val === 'string'; };
const isBoolean = function(val) { return typeof val === 'boolean'; };
const isObject = function(val) { return typeof val === 'object'; };
const isNumeric = function(val) { return typeof val === 'number'; };

const MOUSE_EVENTS = {
'click': 1,
Expand Down Expand Up @@ -151,11 +152,11 @@
metaKey = false;
}

if(!$.isNumeric(keyCode)) {
if(!isNumeric(keyCode)) {
keyCode = 0;
}

if(!$.isNumeric(charCode)) {
if(!isNumeric(charCode)) {
charCode = 0;
}

Expand Down Expand Up @@ -222,23 +223,23 @@
view = window;
}

if(!$.isNumeric(detail)) {
if(!isNumeric(detail)) {
detail = 1;
}

if(!$.isNumeric(screenX)) {
if(!isNumeric(screenX)) {
screenX = 0;
}

if(!$.isNumeric(screenY)) {
if(!isNumeric(screenY)) {
screenY = 0;
}

if(!$.isNumeric(clientX)) {
if(!isNumeric(clientX)) {
clientX = 0;
}

if(!$.isNumeric(clientY)) {
if(!isNumeric(clientY)) {
clientY = 0;
}

Expand All @@ -258,7 +259,7 @@
metaKey = false;
}

if(!$.isNumeric(button)) {
if(!isNumeric(button)) {
button = 0;
}

Expand Down Expand Up @@ -325,7 +326,7 @@
if(!isObject(view)) {
view = window;

if(!$.isNumeric(detail)) {
if(!isNumeric(detail)) {
detail = 1;

if($.isFunction(document.createEvent)) {
Expand Down Expand Up @@ -366,18 +367,18 @@
if(!isBoolean(bubbles)) { bubbles = true; }
if(!isBoolean(cancelable)) { cancelable = true; }
if(!isObject(view)) { view = window; }
if(!$.isNumeric(detail)) { detail = 2; }
if(!$.isNumeric(screenX)) { screenX = 0; }
if(!$.isNumeric(screenY)) { screenY = 0; }
if(!$.isNumeric(clientX)) { clientX = 0; }
if(!$.isNumeric(clientY)) { clientY = 0; }
if(!isNumeric(detail)) { detail = 2; }
if(!isNumeric(screenX)) { screenX = 0; }
if(!isNumeric(screenY)) { screenY = 0; }
if(!isNumeric(clientX)) { clientX = 0; }
if(!isNumeric(clientY)) { clientY = 0; }
if(!isBoolean(ctrlKey)) { ctrlKey = false; }
if(!isBoolean(altKey)) { altKey = false; }
if(!isBoolean(shiftKey)) { shiftKey = false; }
if(!isBoolean(metaKey)) { metaKey = false; }

if(!$.isNumeric(scale)) { scale = 1.0; }
if(!$.isNumeric(rotation)) { rotation = 0.0; }
if(!isNumeric(scale)) { scale = 1.0; }
if(!isNumeric(rotation)) { rotation = 0.0; }

const customEvent = document.createEvent('GestureEvent');

Expand Down Expand Up @@ -421,17 +422,17 @@
cancelable = (type !== 'touchcancel');
}
if(!isObject(view)) { view = window; }
if(!$.isNumeric(detail)) { detail = 1; }
if(!$.isNumeric(screenX)) { screenX = 0; }
if(!$.isNumeric(screenY)) { screenY = 0; }
if(!$.isNumeric(clientX)) { clientX = 0; }
if(!$.isNumeric(clientY)) { clientY = 0; }
if(!isNumeric(detail)) { detail = 1; }
if(!isNumeric(screenX)) { screenX = 0; }
if(!isNumeric(screenY)) { screenY = 0; }
if(!isNumeric(clientX)) { clientX = 0; }
if(!isNumeric(clientY)) { clientY = 0; }
if(!isBoolean(ctrlKey)) { ctrlKey = false; }
if(!isBoolean(altKey)) { altKey = false; }
if(!isBoolean(shiftKey)) { shiftKey = false; }
if(!isBoolean(metaKey)) { metaKey = false; }
if(!$.isNumeric(scale)) { scale = 1.0; }
if(!$.isNumeric(rotation)) { rotation = 0.0; }
if(!isNumeric(scale)) { scale = 1.0; }
if(!isNumeric(rotation)) { rotation = 0.0; }

if(UA.android && !UA.chrome) {
customEvent = document.createEvent('MouseEvents');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const $ = require('jquery');
const animationFrame = require('animation/frame');
const coreUtilsType = require('core/utils/type');

QUnit.module('animation frame');

Expand All @@ -8,7 +9,7 @@ QUnit.testInActiveWindow('request', function(assert) {
const animationFrameID = animationFrame.requestAnimationFrame(function() {
done();
});
assert.ok($.isNumeric(animationFrameID));
assert.ok(coreUtilsType.isNumeric(animationFrameID));
});

QUnit.testInActiveWindow('cancel', function(assert) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setHeight, getHeight } from 'core/utils/size';
import { isNumeric } from 'core/utils/type';
import $ from 'jquery';
import { DEBUG_stub_createIncidentOccurred, DEBUG_restore_createIncidentOccurred } from 'viz/core/base_widget.utils';
import commons from './rangeSelectorParts/commons.js';
Expand Down Expand Up @@ -98,8 +99,8 @@ QUnit.test('check default value valueType when start value is numeric', function
});

const options = this.axis.updateOptions.lastCall.args[0];
assert.ok($.isNumeric(options.startValue));
assert.ok($.isNumeric(options.endValue));
assert.ok(isNumeric(options.startValue));
assert.ok(isNumeric(options.endValue));
assert.strictEqual(options.valueType, 'numeric');
});

Expand Down

0 comments on commit 2ac7418

Please sign in to comment.