本文整理匯總了TypeScript中jQuery.isArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isArray函數的具體用法?TypeScript isArray怎麽用?TypeScript isArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isArray函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildEventDefs
buildEventDefs(isAllDay) {
let rawComplexDef = this.rawComplexDef
let rawDefs = []
let requireDow = false
let i
let defs = []
if (rawComplexDef === true) {
rawDefs = [ {} ] // will get BUSINESS_HOUR_EVENT_DEFAULTS verbatim
} else if ($.isPlainObject(rawComplexDef)) {
rawDefs = [ rawComplexDef ]
} else if ($.isArray(rawComplexDef)) {
rawDefs = rawComplexDef
requireDow = true // every sub-definition NEEDS a day-of-week
}
for (i = 0; i < rawDefs.length; i++) {
if (!requireDow || rawDefs[i].dow) {
defs.push(
this.buildEventDef(isAllDay, rawDefs[i])
)
}
}
return defs
}
示例2: processOptions
/* Options
------------------------------------------------------------------------------------------------------------------*/
// Parses various options into properties of this object
processOptions() {
let slotDuration = this.opt('slotDuration')
let snapDuration = this.opt('snapDuration')
let input
slotDuration = moment.duration(slotDuration)
snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration
this.slotDuration = slotDuration
this.snapDuration = snapDuration
this.snapsPerSlot = slotDuration / snapDuration // TODO: ensure an integer multiple?
// might be an array value (for TimelineView).
// if so, getting the most granular entry (the last one probably).
input = this.opt('slotLabelFormat')
if ($.isArray(input)) {
input = input[input.length - 1]
}
this.labelFormat = input ||
this.opt('smallTimeFormat') // the computed default
input = this.opt('slotLabelInterval')
this.labelInterval = input ?
moment.duration(input) :
this.computeLabelInterval(slotDuration)
}
示例3: parse
static parse(rawInput, calendar) {
let rawProps
// normalize raw input
if ($.isArray(rawInput.events)) { // extended form
rawProps = rawInput
} else if ($.isArray(rawInput)) { // short form
rawProps = { events: rawInput }
}
if (rawProps) {
return EventSource.parse.call(this, rawProps, calendar)
}
return false
}
示例4: transform
transform(value: Array<any>, args: string[] = null): any {
let filter:any = args[0];
if (filter && $.isArray(value)) {
let allUndefined:boolean = true;
Object.keys(filter).forEach((key:string) => {
if(filter[key]) {
allUndefined = false;
}
});
if(allUndefined) {
return value;
}
return value.filter((item:any) => {
let valid:boolean = false;
Object.keys(filter).forEach((key:string) => {
if(item[key] && item[key].toLowerCase().indexOf(filter[key].toLowerCase()) !== -1) {
valid = true;
}
});
return valid;
});
} else {
return value;
}
}
示例5: parseFieldSpecs
export function parseFieldSpecs(input) {
let specs = []
let tokens = []
let i
let token
if (typeof input === 'string') {
tokens = input.split(/\s*,\s*/)
} else if (typeof input === 'function') {
tokens = [ input ]
} else if ($.isArray(input)) {
tokens = input
}
for (i = 0; i < tokens.length; i++) {
token = tokens[i]
if (typeof token === 'string') {
specs.push(
token.charAt(0) === '-' ?
{ field: token.substring(1), order: -1 } :
{ field: token, order: 1 }
)
} else if (typeof token === 'function') {
specs.push({ func: token })
}
}
return specs
}
示例6: makeMoment
// Builds an enhanced moment from args. When given an existing moment, it clones. When given a
// native Date, or called with no arguments (the current time), the resulting moment will be local.
// Anything else needs to be "parsed" (a string or an array), and will be affected by:
// parseAsUTC - if there is no zone information, should we parse the input in UTC?
// parseZone - if there is zone information, should we force the zone of the moment?
function makeMoment(args, parseAsUTC= false, parseZone= false) {
let input = args[0]
let isSingleString = args.length === 1 && typeof input === 'string'
let isAmbigTime
let isAmbigZone
let ambigMatch
let mom
if (moment.isMoment(input) || isNativeDate(input) || input === undefined) {
mom = moment.apply(null, args)
} else { // "parsing" is required
isAmbigTime = false
isAmbigZone = false
if (isSingleString) {
if (ambigDateOfMonthRegex.test(input)) {
// accept strings like '2014-05', but convert to the first of the month
input += '-01'
args = [ input ] // for when we pass it on to moment's constructor
isAmbigTime = true
isAmbigZone = true
} else if ((ambigMatch = ambigTimeOrZoneRegex.exec(input))) {
isAmbigTime = !ambigMatch[5] // no time part?
isAmbigZone = true
}
} else if ($.isArray(input)) {
// arrays have no timezone information, so assume ambiguous zone
isAmbigZone = true
}
// otherwise, probably a string with a format
if (parseAsUTC || isAmbigTime) {
mom = moment.utc.apply(moment, args)
} else {
mom = moment.apply(null, args)
}
if (isAmbigTime) {
mom._ambigTime = true
mom._ambigZone = true // ambiguous time always means ambiguous zone
} else if (parseZone) { // let's record the inputted zone somehow
if (isAmbigZone) {
mom._ambigZone = true
} else if (isSingleString) {
mom.utcOffset(input) // if not a valid zone, will assign UTC
}
}
}
mom._fullCalendar = true // flag for extended functionality
return mom
}
示例7: multiQuerySources
// like querySources, but accepts multple match criteria (like multiple IDs)
multiQuerySources(matchInputs) {
// coerce into an array
if (!matchInputs) {
matchInputs = []
} else if (!$.isArray(matchInputs)) {
matchInputs = [ matchInputs ]
}
let matchingSources = []
let i
// resolve raw inputs to real event source objects
for (i = 0; i < matchInputs.length; i++) {
matchingSources.push.apply( // append
matchingSources,
this.querySources(matchInputs[i])
)
}
return matchingSources
}
示例8: processOptions
/* Options
------------------------------------------------------------------------------------------------------------------*/
// Parses various options into properties of this object
processOptions() {
let slotDuration = this.opt('slotDuration')
let snapDuration = this.opt('snapDuration')
let input
slotDuration = moment.duration(slotDuration)
snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration
this.slotDuration = slotDuration
this.snapDuration = snapDuration
this.snapsPerSlot = slotDuration / snapDuration // TODO: ensure an integer multiple?
// might be an array value (for TimelineView).
// if so, getting the most granular entry (the last one probably).
input = this.opt('slotLabelFormat')
if ($.isArray(input)) {
input = input[input.length - 1]
}
this.labelFormat = input ||
this.opt('smallTimeFormat') // the computed default
let slots = this.opt('slots')
if (slots && Array.isArray(slots)) {
// filter valid slots
slots = $.grep(slots, function(sl) {
return sl.hasOwnProperty('start') && sl.hasOwnProperty('end') &&
typeof(sl.start) === 'string' && typeof(sl.end) === 'string' &&
sl.start.match(/^[0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?$/) &&
sl.end.match(/^[0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?$/) &&
true
})
if (slots.length >= 1) { // require at least 1 slot to display properly
// sort slots by start time
slots.sort(function(sl1, sl2) {
let start1 = moment(sl1.start, 'HH:mm:ss')
let start2 = moment(sl2.start, 'HH:mm:ss')
if (start1.isBefore(start2)) {
return -1
} else if (start2.isBefore(start1)) {
return 1
} else {
return 0
}
})
// make sure each slot ends after it starts, and before the next one starts
for (let i = 0; i < slots.length; i++) {
let start1 = moment(slots[i].start, 'HH:mm:ss')
let end1 = moment(slots[i].end, 'HH:mm:ss')
if (end1.isBefore(start1)) {
slots[i].end = slots[i].start
}
if (i + 1 < slots.length) {
let start2 = moment(slots[i + 1].start, 'HH:mm:ss')
if (start2.isBefore(end1)) {
slots[i].end = slots[i + 1].start
}
}
}
this.slots = slots
// options related to slots
let showSlotEndTime = this.opt('showSlotEndTime')
if (showSlotEndTime !== false) { // defaults to true
this.showSlotEndTime = true
}
let showMinorSlotTime = this.opt('showMinorSlotTime')
if (showMinorSlotTime !== false) { // defaults to true
this.showMinorSlotTime = true
}
let snapOnSlots = this.opt('snapOnSlots')
if (snapOnSlots && (snapOnSlots === true || // defaults to false
snapOnSlots.hasOwnProperty('snapPolicy')
)) {
this.snapOnSlots = {
snapPolicy: 'enlarge' // could also be 'closest'
}
if (snapOnSlots.snapPolicy === 'closest') {
this.snapOnSlots.snapPolicy = 'closest'
}
}
}
}
input = this.opt('slotLabelInterval')
this.labelInterval = input ?
moment.duration(input) :
this.computeLabelInterval(slotDuration)
}