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 🙏

© 2025 – Pkg Stats / Ryan Hefner

more-utils

v1.0.6

Published

a env util package

Downloads

15

Readme

more-utils.js

整合一些浏览器客户端环境下常用的函数方法

  • npm: https://www.npmjs.com/package/more-utils
  • github: https://github.com/mouday/more-utils.js

安装

npm i more-utils

已整理归纳:

file.js

// 1、上传的file转Base64 DataURL
fileToBase64(file)

// 2、Base64转Blob
base64ToBlob(base64)

// 3、将file对象或blob对象转url
getObjectURL(obj)

// 4、监听粘贴事件,从剪切板获取图片file对象
pasteImageFromClipboard(element, callback)

array.js

使用示例

<template>
  <div class="">

    <input
      type="file"
      accept="image/*"
      @change="handleImageChange"
    >

    <img
      :src="imgObj"
      alt=""
    >
  </div>
</template>

<script>
import mo from 'more-utils'

export default {
  name: '',

  props: [],

  components: {},

  data() {
    return {
      imgObj: null,
    };
  },

  computed: {},

  methods: {
    async handleImageChange(event) {
      // 1、获取选择的文件对象(不能显示)
      let file = event.target.files[0];
      // 获取文件对象的url(可以显示)
      // let url = getObjectURL(file);

      // 2、获取文件base64(可以显示)
      let b64 = await mo.fileToBase64(file);

      // 3、获取blob(不能显示)
      let blob = mo.base64ToBlob(b64);

      // 4、 获取对象url(可以显示)
      let url = mo.getObjectURL(blob);
      console.log(url);
      this.imgObj = url;
    },
  },

  created() {},
};
</script>

<style lang="scss" scoped>
</style>

示例

<img class="image"
         src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg9.51tietu.net%2Fpic%2F2019-091307%2Fntplrtyw2bvntplrtyw2bv.jpg&refer=http%3A%2F%2Fimg9.51tietu.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655389703&t=4423dd371c66b6064a1ed3c4dc5e05cd"
         alt="">

    <script src="./dist/more-utils.js"></script>
    <script>
        (async () => {
            let image = document.querySelector('.image')
            let image_size = await more_utils.getImageSize(image)
            console.log(image_size)
            // {width: 1920, height: 1200}
        })()
    </script>