• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript isArray.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript isEmpty.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript get.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap