随笔分类 -  nodejs

摘要:这样做的目的是避免循环引用,编写多余的类型文件 //global.d.ts import type { A } from "./a"; import type { B } from "./b"; declare global { var a: A; var b: B; } //index.ts im 阅读全文
posted @ 2024-05-23 08:21 Ajanuw 阅读(38) 评论(0) 推荐(0)
摘要:https://github.com/nodejs/node-addon-api hello world #include <napi.h> using namespace Napi; String Method(const CallbackInfo& info) { Env env = info. 阅读全文
posted @ 2021-04-15 09:39 Ajanuw 阅读(1757) 评论(0) 推荐(1)
摘要:1. 创建静态库 "hello.lib" release x64 编译前,选择多线程MT,否则可能出现这个错误(error LNK2038: 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MT_StaticRelease”) 生成解决方案 2. 阅读全文
posted @ 2021-04-15 09:37 Ajanuw 阅读(637) 评论(0) 推荐(0)
摘要:const fs = require("fs"); const { Writable, Readable, Duplex, Transform } = require("stream"); // 双向流 const inoutStream = new Duplex({ // 获取写入的数据 writ 阅读全文
posted @ 2021-01-15 13:04 Ajanuw 阅读(448) 评论(0) 推荐(0)
摘要:import * as path from 'path'; import * as url from 'url'; const savePath = path.join('public', 'images', 'a.jpg'); // => \public\images\a.jpg const ur 阅读全文
posted @ 2021-01-09 11:23 Ajanuw 阅读(175) 评论(0) 推荐(0)
摘要:test/package.json { "name": "test", "main": "index.js", "exports": { ".": { "require": "./index.js" }, "./a": "./functions/a.js", "./b": "./functions/ 阅读全文
posted @ 2020-12-18 13:14 Ajanuw 阅读(2649) 评论(0) 推荐(0)
摘要:github 项目地址 node版本 λ node -v v12.16.2 main.js const ffi = require("@saleae/ffi"); const child_process = require("child_process"); const W32 = require( 阅读全文
posted @ 2020-04-27 21:30 Ajanuw 阅读(1625) 评论(0) 推荐(2)
摘要:win32 api 也可以试试我写的 node-windows-x64 库 >node -v v12.16.1 >npm install -g node-gyp >npm i @saleae/ffi >node test.js 1 test.js const ffi = require("@sale 阅读全文
posted @ 2020-04-27 16:34 Ajanuw 阅读(6702) 评论(0) 推荐(1)
摘要:"psaux" "tasklist" "system tasks" win ubuntu 以下代码,只在win上测试过: js const { exec } = require("child_process"); const isWindows = process.platform == "win3 阅读全文
posted @ 2020-02-12 12:26 Ajanuw 阅读(386) 评论(0) 推荐(0)
摘要:"ora" 显示loading.. "progress" 进度条 progress ora 阅读全文
posted @ 2020-02-08 21:12 Ajanuw 阅读(3595) 评论(0) 推荐(0)
摘要:bcrypt install λ npm i bcrypt λ npm i --save-dev @types/bcrypt example import * as bcrypt from 'bcrypt'; const db = {} (async () => { const myPlaintex 阅读全文
posted @ 2019-08-11 11:52 Ajanuw 阅读(2070) 评论(0) 推荐(1)
摘要:"故障排除" 安装puppeteer,使用cnpm 解决依赖 执行代码 阅读全文
posted @ 2019-06-15 10:33 Ajanuw 阅读(197) 评论(0) 推荐(0)
摘要:"文档" mouse.click 是 mouse.move,mouse.down 和 mouse.up 的快捷方式 main.js index.html 阅读全文
posted @ 2019-06-04 21:06 Ajanuw 阅读(1187) 评论(0) 推荐(1)
摘要:"文档" main.js index.html 阅读全文
posted @ 2019-06-04 21:05 Ajanuw 阅读(570) 评论(0) 推荐(0)
摘要:$ npm i -g node-gyp $ mkdir node-addons $ cd node-addons $ npm i nan $ touch hello.cpp binding.gyp test.js hello.cpp #include <node.h> using v8::Funct 阅读全文
posted @ 2019-02-09 14:43 Ajanuw
摘要:"原文链接 https://www.cnblogs.com/ajanuw/p/10324269.html " "Request" "Response" "page.setRequestInterception(true)" 开启拦截 "req.respond()" 返回一个自定义响应 "req.co 阅读全文
posted @ 2019-01-26 17:20 Ajanuw 阅读(6682) 评论(0) 推荐(0)
摘要:main.js index.html run 阅读全文
posted @ 2019-01-23 23:25 Ajanuw 阅读(2915) 评论(0) 推荐(1)
摘要:"模式模拟GraphQL数据" const { ApolloServer, gql } = require('apollo server'); const typeDefs = gql` type Query { hello: Float resolved: String } `; const re 阅读全文
posted @ 2018-11-14 23:47 Ajanuw 阅读(242) 评论(0) 推荐(0)
摘要:"阿波罗服务器入门" const { gql, ApolloServer } = require("apollo server"); const _ = require("lodash"); const cats = [{ id: 1, name: "a" }, { id: 2, name: "b" 阅读全文
posted @ 2018-11-14 00:18 Ajanuw 阅读(256) 评论(0) 推荐(0)
摘要:$ cd <project-root-path> 进入项目根目录 $ npm run build $ pm2 start npm --name <name> -- run start:prod pm2基本命令 $ npm install pm2 -g # 命令行安装 pm2 $ pm2 start 阅读全文
posted @ 2018-11-12 22:34 Ajanuw