随笔分类 -  javascript构件

javascript的一些特殊思路,凝结出来的智慧宝石!
摘要:module.exports = { JSONToPathArr(data){ const resArr=[] const pArr=[''] const list=[data] for(let i=0;i<list.length;i++){ const json=list[i] for(let k 阅读全文
posted @ 2024-12-13 16:26 无工时代 阅读(6) 评论(0) 推荐(0) 编辑
该文被密码保护。
posted @ 2024-09-07 15:35 无工时代 阅读(1) 评论(0) 推荐(0) 编辑
摘要:分为前端版本和服务器版本 /* 缓存并发接口函数,解决重复请求和并发请求问题 id:唯一值 cacheSecond:缓存时间,单位秒 syncFunc:加载函数 */ const _map = {} const _startTimeMap = {} const _idArr=[] const _re 阅读全文
posted @ 2024-08-27 00:12 无工时代 阅读(7) 评论(0) 推荐(0) 编辑
摘要:const appendChild=document.head.appendChilddocument.head.appendChild=function(dom) { if(dom.tagName 'SCRIPT'){ //加载js LCache.loadAll(dom.src,onload) } 阅读全文
posted @ 2022-03-04 15:07 无工时代 阅读(232) 评论(0) 推荐(0) 编辑
摘要:使用:输入文件夹路径数组 const path = require("path"); function resolve(dir) { return path.join(__dirname, "..", dir); } //demo plugins: [ new AliasDirReplacement 阅读全文
posted @ 2021-12-25 22:05 无工时代 阅读(256) 评论(0) 推荐(0) 编辑
摘要:/* 并发加载函数 id:唯一值 syncFunc:加载函数 */ const _map={} const _startTimeMap={} async function conCurentLoad (id,syncFunc) { //兼容并发加载的情况 if(!_map[id]){ _map[id 阅读全文
posted @ 2021-09-24 11:18 无工时代 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Array.prototype.pushOnly=function(one){ if(this.indexOf(one) 1){ this.push(one) } } /* * 分类器*/ class ArraySplit { constructor(getDis,sArr,maxDeep) { t 阅读全文
posted @ 2021-05-21 14:17 无工时代 阅读(40) 评论(0) 推荐(0) 编辑
摘要:const axios=require('axios') const fs = require('fs-extra'); const https=require('https') const path=require('path') function resolve (dir) { return p 阅读全文
posted @ 2021-05-20 18:29 无工时代 阅读(115) 评论(0) 推荐(0) 编辑
摘要:/* 缓存管理器 cacheLen:最多缓存多少个数据 id:唯一值 name:方法名 syncFunc:加载函数 */ class cacheManage { //cacheLen:最多缓存多少个数据 constructor(cacheLen){ this.cacheLen=cacheLen||2 阅读全文
posted @ 2021-05-20 13:05 无工时代 阅读(37) 评论(0) 推荐(0) 编辑
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>数据分类器demo</title> </head> <body> <button onclick="splitArr()">分类</button> <div i 阅读全文
posted @ 2021-05-19 16:26 无工时代 阅读(105) 评论(0) 推荐(0) 编辑
摘要:项目地址:https://www.npmjs.com/package/execfromnode-loader 让前端的js执行nodejs 配置文件 execFromNodeOptions.js const fs=require('fs') const path=require('path') // 阅读全文
posted @ 2021-01-27 17:44 无工时代 阅读(163) 评论(0) 推荐(0) 编辑
摘要:const domTags=['div','section','img','p','span'] //深度遍历html节点 function depthSearch(node,childProp='children'){ const nodeList=[] const depthEach=funct 阅读全文
posted @ 2021-01-13 16:01 无工时代 阅读(983) 评论(0) 推荐(0) 编辑
摘要:/* 并发加载函数 防止接口重复提交以及查询 id:唯一值 syncFunc:Promise函数 */ const _map={} const _startTimeMap={} function conCurentLoad (id,syncFunc) { //兼容并发加载的情况 if(!_map[i 阅读全文
posted @ 2020-12-24 22:53 无工时代 阅读(131) 评论(0) 推荐(0) 编辑
摘要:/* 缓存加载函数 cacheLen:最多缓存多少个接口 id:唯一值 name:方法名 syncFunc:加载函数 */ // 缓存最近的20个接口 const methodCacheArr = [] let cacheLen = 20 try { const arr=JSON.parse(loc 阅读全文
posted @ 2020-11-18 16:07 无工时代 阅读(123) 评论(0) 推荐(0) 编辑
摘要:/* 并发加载函数 id:唯一值 syncFunc:加载函数 */ const _map={} async function conCurentLoad (id,syncFunc) { //兼容并发加载的情况 if(!_map[id]){ _map[id]=[]; const res = await 阅读全文
posted @ 2020-11-13 19:20 无工时代 阅读(130) 评论(0) 推荐(0) 编辑
摘要:'use strict'; /* 异步数据模块加载器 功能 1、加载器存在 主任务、副任务、子任务 newRequire 表示加载主任务,主任务并发执行,newRequire(param1),执行主任务的时候,暂停副任务,主任务结束后,再执行副任务。 runFreeRequest 表示加载副任务,任 阅读全文
posted @ 2020-07-15 17:17 无工时代 阅读(184) 评论(0) 推荐(0) 编辑
摘要:使用 JavaScript 创建并下载文件 function createAndDownloadFile(fileName, content) { var aTag = document.createElement('a'); var blob = new Blob([content]); aTag 阅读全文
posted @ 2020-05-28 15:23 无工时代 阅读(332) 评论(0) 推荐(0) 编辑
摘要:function getNearNum(i,n,len) { const left=Math.max(0,i-(n>>1)); const right=Math.min(left+n,len) return [left,right] } 阅读全文
posted @ 2020-04-09 17:54 无工时代 阅读(262) 评论(0) 推荐(0) 编辑
摘要://通过木桶结构压缩数据,getMidNum获取中间数 class Tong { constructor(){ this.data=[] this.length=0; } add(num){ if(!this.data[num]){ this.data[num]=1; }else{ this.dat 阅读全文
posted @ 2020-04-07 12:47 无工时代 阅读(139) 评论(0) 推荐(0) 编辑
摘要:根据两个用户的行为记录 [ [ 0, 1, 4, 9 ], [ 8, 0, 7, 2 ] ] ,找出中间记录[4,0.5,5.5,5.5],生成特征 [ [ 0, 1, 0, 1 ],[ 1, 0, 1, 0 ] ] 求出特征出现概率 [1/2,1/2,1/2,1/2] 输入新的行为,根据中间记录, 阅读全文
posted @ 2020-04-03 19:32 无工时代 阅读(462) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示