npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@medomino-170/utils

v0.0.48

Published

> build 文件夹是生成好的 js 文件和 .d.ts

Downloads

201

Readme

medo-ts2

build 文件夹是生成好的 js 文件和 .d.ts

crypto-js 3.3.0 最新版(4.x)打包体积过大

how to use

数组相关方法

byte-conversion

import { byteConversion } from "../../ts/byte-conversion";

console.log(byteConversion(1000))

deepcopy

import { deepCopy, deepProxy } from "../../src/deepcopy";
import { Logger } from "../../src/logjs-extend";

const a = { a: 1 };
Object.freeze(a)
const max = 1e5;
const logger = new Logger();
for (let i = 0; i < max; i++) {
  // const b = deepCopy(a)
  // b.a = 123
  const b = deepProxy(a, (a) => {
    a.a = 123;
  });
}
logger.log("done");

mongo

import { mongoConfigs } from "../../../../private/medomino/build/datebase/index";
import { Mongo } from "../../ts/mongo";

const mongoConfig = {
  url: `${mongoConfigs.url}/medo_mango?authSource=admin`,
  option: {
    useUnifiedTopology: true,
    useNewUrlParser: true,
    minPoolSize: 2,
    maxPoolSize: 100,
  },
};

const mgsql = new Mongo(mongoConfig);

async function init() {

  for (let i = 0; i < 100; i++) {
    await mgsql.find({
      table: "std_doctor",
      query: {},
      limit: 1,
    });
  }

  // const data = await mgsql.find({
  //   table: "std_doctor",
  //   query: {},
  //   limit: 1,
  // });


  process.exit();
}

init();

mysql

import { Mysql } from "../../ts/mysql/index";
import { mysqlConf } from "../../configs/index";
import { Logger } from "../../ts/logjs-extend";

const mysql = new Mysql(mysqlConf);

async function init() {
  const table = "nlp_entity";
  const limit = 1e5;
  const db = "new_beigene_demo_2021";
  // const ids: { id: string }[] = await mysql.query(
  //   `select id from ?? where type = '疾病' and value = '肿瘤'`,
  //   [table],
  //   db
  // );
  // const id = ids.map((x) => x.id);

  // console.log(ids.length);

  // const logger = new Logger();

  // // const data = await mysql.query(`select id from ?? where id in (?)`, [table, id], db)

  // const extend =
  //   `SELECT ? AS id UNION ALL ` +
  //   Array(id.length - 1)
  //     .fill(`SELECT ?`)
  //     .join(" UNION ALL ");
  // const params = id;

  // console.log(`SELECT id from (${extend}) AS a LEFT JOIN ?? AS b ON a.id = b.id`)
  // console.log(params.concat([table]))

  // const data = await mysql.query(
  //   `SELECT a.id from (${extend}) AS a LEFT JOIN ?? AS b ON a.id = b.id where b.id is not null`,
  //   params.concat([table]),
  //   db
  // );

  // const data = await mysql.query(
  //   `SELECT a.id from ?? as a inner join (${extend}) AS b ON a.id = b.id `,
  //   [table].concat(params),
  //   db
  // );

  // const data = await mysql.joinIn({
  //   table,
  //   ids: id,
  //   key: "id",
  //   fields: ["id"],
  //   db,
  //   custom: 'distinct a.rid'
  // });

  // console.log(data.length)

  // logger.log("done");

  // const data = await mysql.query(`show databases`, [table]);

  const data = await mysql.query(`select * from ?? limit 10`, [table], db);


  // const data = await mysql.joinIn({
  //   table,
  //   ids: ["000004ffaa584902eaa33421d4073137"],
  //   key: "id",
  //   fields: ["id"],
  //   // db,
  //   custom: "distinct a.rid",
  // });

  console.log(data);

  // process.exit();
}

init();

postgresql

import { PostgreSql } from "../../src/postgresql";
import { Logger } from "../../src/logjs-extend";
import { fse, path } from "../../src/fse";

import { pgsqlConfigs } from "../../../../private/medomino/build/datebase";

const pgsql = new PostgreSql({
  host: pgsqlConfigs.host,
  port: pgsqlConfigs.port,
  user: pgsqlConfigs.username,
  password: pgsqlConfigs.password,
  database: "medo_master",
});

async function init() {
  // const data = await pgsql.query(`select rid from ask_normalization limit ?`, [
  //   1e4
  // ]);

  // await fse.writeJSON(path.join(__dirname, '1.json'), data)

  let data: any[] = await fse.readJSON(path.join(__dirname, "1.json"));
  data = data.concat(data);
  // data = data.concat(data)
  // data = data.concat(data)
  // data = data.concat(data)
  // data = data.concat(data)

  console.log(data.length);

  const logger = new Logger();

  // SELECT regexp_split_to_table(?, ',' ) AS id

  // const res = await pgsql.query(`select rid from ask_normalization where rid in (?)`, [data.map(x => x.rid)])
  // const res = await pgsql.query(`select rid from ask_normalization where rid in (SELECT regexp_split_to_table(?, ',' ) AS id)`, [data.map(x => x.rid).join()])
  // const res = await pgsql.query(`SELECT regexp_split_to_table(?, ',' ) AS id`, [data.map(x => x.rid).join()])
  const res = await pgsql.query(
    `SELECT rid FROM ask_normalization WHERE EXISTS (SELECT 1 FROM (SELECT regexp_split_to_table(?, ',' ) AS id) as a WHERE a.id = ask_normalization.rid);`,
    [data.map((x) => x.rid).join()]
  );

  // for (let i = 0; i < 1; i++) {
  //   const res = await pgsql.joinIn({
  //     table: "ask_normalization",
  //     key: "rid",
  //     ids: data.map((x) => x.rid),
  //     fields: ["rid"],
  //   });
  //   console.log(res.length, 'res')
  //   // const res = await pgsql.query(
  //   //   `SELECT regexp_split_to_table(?, ',' ) AS id`,
  //     // [data.map(x => x.rid).join()]
  //   // );
  //   logger.log(`${i + 1} / ${10}`);
  // }

  logger.log("done");
  process.exit();
}

init();

typescript 相关基础方法

import { MedoTypes, MedoTypesM } from "../../ts/types";

console.log(MedoTypesM.getKeys);

type d = MedoTypes.GetKeys<{}>;