当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript isArray.default函数代码示例

本文整理汇总了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)))
	)
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:7,代码来源:isValidType.ts

示例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
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:11,代码来源:matchesType.ts

示例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--) {
//.........这里部分代码省略.........
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:101,代码来源:dragDrop.ts

示例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)
	}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:31,代码来源:DragDropMonitor.ts

示例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)
 }
开发者ID:Baltox,项目名称:searchkit,代码行数:12,代码来源:LevelState.ts

示例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.',
	)
}
开发者ID:Shintaroa,项目名称:react-dnd,代码行数:13,代码来源:contracts.ts

示例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
    }
  }
}
开发者ID:Baltox,项目名称:searchkit,代码行数:14,代码来源:BoolQueries.ts

示例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;
 }
开发者ID:pradel,项目名称:node-instagram,代码行数:19,代码来源:index.ts

示例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
    }
  }
}
开发者ID:BenJamesbabala,项目名称:searchkit,代码行数:21,代码来源:BoolQueries.ts


注:本文中的lodash/isArray.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。