本文整理汇总了TypeScript中lodash/isArray.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isValidType
export default function isValidType(type: any, allowArray?: boolean): boolean {
return (
typeof type === 'string' ||
typeof type === 'symbol' ||
(!!allowArray && isArray(type) && type.every(t => isValidType(t, false)))
)
}
示例2: matchesType
export default function matchesType(
targetType: TargetType | null,
draggedItemType: ItemType | null,
) {
if (draggedItemType === null) {
return targetType === null
}
return isArray(targetType)
? (targetType as ItemType[]).some(t => t === draggedItemType)
: targetType === draggedItemType
}
示例3: isObject
export default function createDragDropActions<Context>(
manager: IDragDropManager<Context>,
) {
return {
beginDrag(
sourceIds: string[] = [],
{
publishSource,
clientOffset,
getSourceClientOffset,
}: IBeginDragOptions = {
publishSource: true,
},
): IAction<IBeginDragPayload> | undefined {
const monitor = manager.getMonitor()
const registry = manager.getRegistry()
invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.')
for (const s of sourceIds) {
invariant(registry.getSource(s), 'Expected sourceIds to be registered.')
}
let sourceId = null
for (let i = sourceIds.length - 1; i >= 0; i--) {
if (monitor.canDragSource(sourceIds[i])) {
sourceId = sourceIds[i]
break
}
}
if (sourceId === null) {
return
}
let sourceClientOffset: IXYCoord | null = null
if (clientOffset) {
invariant(
typeof getSourceClientOffset === 'function',
'When clientOffset is provided, getSourceClientOffset must be a function.',
)
sourceClientOffset = (getSourceClientOffset as any)(sourceId)
}
const source = registry.getSource(sourceId)
const item = source.beginDrag(monitor, sourceId)
invariant(isObject(item), 'Item must be an object.')
registry.pinSource(sourceId)
const itemType = registry.getSourceType(sourceId)
return {
type: BEGIN_DRAG,
payload: {
itemType,
item,
sourceId,
clientOffset: clientOffset || null,
sourceClientOffset: sourceClientOffset || null,
isSourcePublic: !!publishSource,
},
}
},
publishDragSource(): ISentinelAction | undefined {
const monitor = manager.getMonitor()
if (!monitor.isDragging()) {
return
}
return { type: PUBLISH_DRAG_SOURCE }
},
hover(
targetIdsArg: string[],
{ clientOffset }: IHoverOptions = {},
): IAction<IHoverPayload> {
invariant(isArray(targetIdsArg), 'Expected targetIds to be an array.')
const targetIds = targetIdsArg.slice(0)
const monitor = manager.getMonitor()
const registry = manager.getRegistry()
invariant(monitor.isDragging(), 'Cannot call hover while not dragging.')
invariant(!monitor.didDrop(), 'Cannot call hover after drop.')
// First check invariants.
for (let i = 0; i < targetIds.length; i++) {
const targetId = targetIds[i]
invariant(
targetIds.lastIndexOf(targetId) === i,
'Expected targetIds to be unique in the passed array.',
)
const target = registry.getTarget(targetId)
invariant(target, 'Expected targetIds to be registered.')
}
const draggedItemType = monitor.getItemType()
// Remove those targetIds that don't match the targetType. This
// fixes shallow isOver which would only be non-shallow because of
// non-matching targets.
for (let i = targetIds.length - 1; i >= 0; i--) {
//.........这里部分代码省略.........
示例4: subscribeToStateChange
public subscribeToStateChange(
listener: Listener,
options: { handlerIds: string[] | undefined } = { handlerIds: undefined },
): Unsubscribe {
const { handlerIds } = options
invariant(typeof listener === 'function', 'listener must be a function.')
invariant(
typeof handlerIds === 'undefined' || isArray(handlerIds),
'handlerIds, when specified, must be an array of strings.',
)
let prevStateId = this.store.getState().stateId
const handleChange = () => {
const state = this.store.getState()
const currentStateId = state.stateId
try {
const canSkipListener =
currentStateId === prevStateId ||
(currentStateId === prevStateId + 1 &&
!areDirty(state.dirtyHandlerIds, handlerIds))
if (!canSkipListener) {
listener()
}
} finally {
prevStateId = currentStateId
}
}
return this.store.subscribe(handleChange)
}
示例5: add
add(level:number, val) {
var ob = this.getValue()
if (!isArray(ob[level])) {
ob = update(ob, {
[level]:{$set:[]}
})
}
ob = update(ob, {
[level]:{$push:[val]}
})
return this.create(ob)
}
示例6: validateType
export function validateType(type: ItemType, allowArray?: boolean) {
if (allowArray && isArray(type)) {
type.forEach(t => validateType(t, false))
return
}
invariant(
typeof type === 'string' || typeof type === 'symbol',
allowArray
? 'Type can only be a string, a symbol, or an array of either.'
: 'Type can only be a string or a symbol.',
)
}
示例7: boolHelper
function boolHelper(val, operator){
const isArr = isArray(val)
if(isArr && val.length === 1){
return val[0]
}
else if(isArr && val.length === 0){
return {}
}
return {
bool:{
[operator]:val
}
}
}
示例8: getAuthorizationUrl
/**
* Get instagram authorization url
* @param redirectUri
*/
public getAuthorizationUrl(redirectUri: string, options: any = {}): string {
let authorizationUrl = `${this.baseApiUrl}/oauth/authorize/?client_id=${
this.config.clientId
}&redirect_uri=${redirectUri}&response_type=code`;
if (options.scope) {
if (isArray(options.scope)) {
options.scope = options.scope.join('+');
}
authorizationUrl += `&scope=${options.scope}`;
}
if (options.state) {
authorizationUrl += `&state=${options.state}`;
}
return authorizationUrl;
}
示例9: boolHelper
function boolHelper(val, operator){
const isArr = isArray(val)
if (isArr) {
// Remove empty filters
val = filter(val, f => !isEmpty(f))
if (isArr && val.length === 1) {
return val[0]
} else if (isArr && val.length === 0) {
return {}
} else if (isArr
&& (operator == "must" || operator == "should")
&& (findIndex(val, isBoolOp.bind(null, operator)) != -1)) {
val = flattenBool(operator, val)
}
}
return {
bool:{
[operator]:val
}
}
}