This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// method | |
const flat = function *(arr) { | |
const {length} = arr; | |
for(let i = 0; i< length; i++) { | |
const item = arr[i]; | |
if(Array.isArray(item)){ | |
yield* flat(item); | |
} else { | |
yield item; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 测试字符串 | |
const stringArray = 'dadasdadawqfsdfaabbabcdedcbabbasadada13dfasafafa'.split( | |
''); | |
// 测试字符串倒转 | |
const stringArrayReverse = stringArray.slice().reverse(); | |
const stringArrayReverseJoin = stringArrayReverse.join(''); | |
// 最终结果 | |
let resultString = ''; | |
// 统计计算次数 | |
let calcNum = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 转自:https://www.ibm.com/developerworks/cn/web/1306_jiangjj_jsinstanceof/ | |
// instanceof 原理大概解析 | |
function instance_of(L, R) {// L 表示左表达式,R 表示右表达式 | |
var O = R.prototype;// 取 R 的显示原型 | |
L = L.__proto__;// 取 L 的隐式原型 | |
while (true) { | |
if (L === null) | |
return false; | |
if (O === L)// 这里重点:当 O 严格等于 L 时,返回 true | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface ICachedFnTreeOptions<This = any> { | |
context: This; | |
manipulable: boolean; | |
} | |
/** | |
* Made a function result cacheable, no matter its args' length. | |
* @param targetFn {(*) => *} The target function. | |
* @param [options] {ICachedFnTreeOptions} The options | |
* @return {(*) => *} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
name: "TeleportVariable", | |
inheritAttrs: false, // Must set as `false`. Or you will see your bindings existed on your slot DOM attributes, as data="[object Object]" | |
render () { | |
return this.$scopedSlots.default(this.$attrs); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @typedef {{ status: 'fulfilled', value: *}} TPromiseAllSettledFulfilledResult | |
* @typedef {{ status: 'rejected', reason: (*|Error) }} TPromiseAllSettledRejectedResult | |
* @typedef {(TPromiseAllSettledFulfilledResult|TPromiseAllSettledRejectedResult)[]} TDeferAllSettledResult | |
*/ | |
/** | |
* Same as `Promise.allSettled`. | |
* Try hard to not to use `Promise`, all from JQuery. | |
* @param deferIterator {JQuery.Deferred[]|JQuery.jqXHR[]|Object<string, JQuery.Deferred>} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-unused-vars */ | |
import { Component, Prop, Vue } from 'vue-property-decorator'; | |
import { CreateElement } from 'vue'; | |
import _ from 'lodash'; | |
@Component | |
export default class VIfOrShow extends Vue { | |
/* Data START */ | |
/* Data END */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx h */ | |
/// <reference no-default-lib="true"/> | |
/// <reference lib="dom" /> | |
/// <reference lib="dom.asynciterable" /> | |
/// <reference lib="deno.ns" /> | |
import { serve } from "https://deno.land/std@0.114.0/http/server.ts"; | |
import { h, ssr, tw } from "https://crux.land/nanossr@0.0.1"; | |
const ShowDate = (props) => ( | |
<div class={tw`bg-white flex h-screen`}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue, { ComponentOptions, CreateElement } from 'vue'; | |
import { VNodeData } from 'vue/types/vnode'; | |
import { AsyncComponentFactory, AsyncComponentPromise, FunctionalComponentOptions } from 'vue/types/options'; | |
import _ from 'lodash'; | |
import $ from 'jquery'; | |
export type TArrayOrPrimitive<T> = T extends Array<any> | ReadonlyArray<any> | |
? T | TArrayMember<T> | |
: Array<T> | T; |
OlderNewer