Skip to content

Commit

Permalink
update .
Browse files Browse the repository at this point in the history
  • Loading branch information
xyhp915 committed Nov 30, 2017
1 parent 5bce94d commit 8dd110f
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 19 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
]
},
"devDependencies": {
"@vui/rollup-standalone": "0.0.2",
"@vui/rollup-standalone": "0.0.4",
"ava": "^0.22.0",
"avoriaz": "^6.0.1",
"browser-env": "^3.2.2",
Expand All @@ -41,6 +41,8 @@
"require-extension-hooks": "^0.3.2",
"require-extension-hooks-babel": "^0.1.1",
"require-extension-hooks-vue": "^0.4.1",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.1.0",
"standard": "^10.0.3",
"standard-sass": "0.0.6",
"vue": "^2.5.9",
Expand All @@ -49,7 +51,8 @@
"watch-cli": "^0.2.3"
},
"dependencies": {
"is-type-of": "^1.2.0",
"core-util-is": "^1.0.2",
"is-class": "0.0.4",
"moment": "^2.19.2",
"vue-template-compiler": "^2.5.9"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/datepicker/impl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
</template>

<script>
import { isFunction } from '../../sources/utils/is'
import VDatepickerTable from './impl_table.vue'
import busMixin from '../common/mixinBus'
import SCalendar from '../../sources/plugins/s.calendar'
import moment from 'moment'
import is from 'is-type-of'
export default {
name: 'VDatepicker',
Expand Down Expand Up @@ -103,7 +103,7 @@
_selectItem (item) {
const {scalendar} = this.$options
if (item && is.function(item.toMoment)) {
if (item && isFunction(item.toMoment)) {
scalendar.date = item.toMoment() // Unique entry
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/datepicker/impl_input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
</template>

<script>
import { isDate } from '../../sources/utils/is'
import Scalendar from '../../sources/plugins/s.calendar'
import VDropdown from '../dropdown'
import VDatepicker from './impl.vue'
import moment from 'moment'
import is from 'is-type-of'
export default {
name: 'VDatepickerInput',
Expand Down Expand Up @@ -154,7 +154,7 @@
},
formatDateValue () {
if (is.date(this.value)) {
if (isDate(this.value)) {
return moment(this.val).format(this.format)
} else if (moment.isMoment(this.value)) {
return this.value.format(this.format)
Expand Down
6 changes: 3 additions & 3 deletions packages/message/impl_popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</template>

<script>
import is from 'is-type-of'
import { isFunction, isObject } from '../../sources/utils/is'
const typeMaps = {
success: 'success',
Expand Down Expand Up @@ -80,7 +80,7 @@
close () {
this.closed = true
if (is.function(this.onClose)) {
if (isFunction(this.onClose)) {
this.onClose(this)
}
},
Expand All @@ -104,7 +104,7 @@
if (!this.closed) {
this.close()
}
}, is.object(e) ? 1000 : this.duration)
}, isObject(e) ? 1000 : this.duration)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/modal/impl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</template>

<script>
import is from 'is-type-of'
import { isString, isPromise } from '../../sources/utils/is'
import { createMixins } from '../../sources/utils/mixin'
export default {
Expand Down Expand Up @@ -88,7 +88,7 @@
created () {
// handle events
this.$on('dimission', (e) => {
if (is.string(e)) {
if (isString(e)) {
switch (e) {
case 'close':
this.$emit('close')
Expand All @@ -107,7 +107,7 @@
})
break
}
} else if (is.promise(e)) {
} else if (isPromise(e)) {
e.then(() => {
this.$emit('close')
}, (err) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/table/impl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</template>

<script>
import is from 'is-type-of'
import { isFunction } from '../../sources/utils/is'
import { createMixins } from '../../sources/utils/mixin'
const ORDER_ASC = 'asc'
Expand Down Expand Up @@ -188,7 +188,7 @@
_injectRowItemField (key, value) {
this.rows && this.rows.forEach((it, index) => {
if (it && !it.hasOwnProperty(key)) {
this.$set(it, key, is.function(value) ? value(it, index) : value) // force set row field reactive
this.$set(it, key, isFunction(value) ? value(it, index) : value) // force set row field reactive
}
})
},
Expand Down
9 changes: 8 additions & 1 deletion scripts/build-components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const {executeRollup} = require('@vui/rollup-standalone')
// const builtins = require('rollup-plugin-node-builtins')
// const globals = require('rollup-plugin-node-globals')
const path = require('path')


Expand All @@ -15,7 +17,12 @@ executeRollup({
localPopperPath
],
namedExports: {}
}
},
resolveOptions: {},
extraPlugins: [
// globals(),
// builtins()
]
})

process.on('unhandledRejection', (reason, p) => {
Expand Down
4 changes: 2 additions & 2 deletions sources/plugins/s.calendar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment'
import is from 'is-type-of'
import { isDate } from '../utils/is'

const SUPPORTED_FORMATS = ['MM-DD-YYYY', 'YYYY-MM-DD', 'MM/DD/YYYY', 'YYYY/MM/DD']

Expand Down Expand Up @@ -42,7 +42,7 @@ class SCalendar {
if (typeof value === 'string') {
value = moment(value, SUPPORTED_FORMATS)
}
if (is.date(value)) {
if (isDate(value)) {
value = moment(value)
}
if (moment.isMoment(value) && value.isValid()) {
Expand Down
4 changes: 2 additions & 2 deletions sources/plugins/tooltip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Popper from '../plugins/popper.js'
import is from 'is-type-of'
import { isFunction } from '../../sources/utils/is'
import { addClass } from '../utils/dom'

const DEFAULT_OPTIONS = {
Expand Down Expand Up @@ -160,7 +160,7 @@ export default class Tooltip {
if (title.nodeType === 1 || title.nodeType === 11) {
// if title is a element node or document fragment, append it only if allowHtml is true
allowHtml && titleNode.appendChild(title)
} else if (is.function(title)) {
} else if (isFunction(title)) {
// if title is a function, call it and set innerText or innerHtml depending by `allowHtml` value
const titleText = title.call(reference)
allowHtml
Expand Down
98 changes: 98 additions & 0 deletions sources/utils/is.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import utils from 'core-util-is'

const toString = Function.prototype.toString

function fnBody (fn) {
return toString.call(fn).replace(/^[^{]*{\s*/, '').replace(/\s*}[^}]*$/, '')
}

export const isClass = function (fn) {
return (typeof fn === 'function' &&
(/^class\s/.test(toString.call(fn)) ||
(/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
)
}

export const isFinite = function (obj) {
return Number.isFinite(obj)
}

export const isNaN = function (obj) {
return Number.isNaN(obj)
}

export const isGenerator = function (obj) {
return obj
&& 'function' === typeof obj.next
&& 'function' === typeof obj.throw
}

export const isGeneratorFunction = function (obj) {
return obj
&& obj.constructor
&& 'GeneratorFunction' === obj.constructor.name
}

export const isAsyncFunction = function (obj) {
return obj
&& obj.constructor
&& 'AsyncFunction' === obj.constructor.name
}

export const isPromise = function (obj) {
return obj
&& 'function' === typeof obj.then
}

const MAX_INT_31 = Math.pow(2, 31)

export const isInt = function (obj) {
return utils.isNumber(obj)
&& obj % 1 === 0
}

export const isInt32 = function (obj) {
return isInt(obj)
&& obj < MAX_INT_31
&& obj >= -MAX_INT_31
}

export const isLong = function (obj) {
return isInt(obj)
&& (obj >= MAX_INT_31 || obj < -MAX_INT_31)
}

export const isDouble = function (obj) {
return utils.isNumber(obj)
&& !isNaN(obj)
&& obj % 1 !== 0
}

/**
* override core-util-is
*/
export const isNullOrUndefined = utils.isNullOrUndefined
export const isNumber = utils.isNumber
export const isSymbol = utils.isSymbol
export const isString = utils.isString
export const isUndefined = utils.isUndefined
export const isBoolean = utils.isBoolean
export const isObject = utils.isObject
export const isNull = utils.isNull
export const isPrimitive = utils.isPrimitive
export const isBuffer = utils.isBuffer
export const isFunction = utils.isFunction
export const isDate = function isDate (obj) {
return obj instanceof Date
}
export const isRegExp = function isRegExp (obj) {
return obj instanceof RegExp
}
export const isError = function isError (obj) {
return obj instanceof Error
}
export const isArray = function isArray (obj) {
return Array.isArray(obj)
}

export default utils

0 comments on commit 8dd110f

Please sign in to comment.