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

wechat-emoji-parser-lyh

v2.0.3

Published

微信表情

Downloads

4

Readme

wechat-emoji-parser

微信表情解析工具,可以实现表情解析和表情发送功能

  • 可用于公众号接收用户表情消息,将表情码转换为对应的表情 html 内容
  • 还可以获取聊天表情,可以应用于聊天应用的表情

install(安装)

npm:

npm install wechat-emoji-parser-lyh -S

yarn:

yarn add wechat-emoji-parser-lyh

How to use(使用)

getEmojis(option):获取表情

import { getEmojis } from 'wechat-emoji-parser'
let emojis = getEmojis({ size: 24 })
/*emojis
[
  {
    cn: "[右哼哼]"
    code: "/:@>"
    style:{
            background: "url(https://res.wx.qq.com/wxdoc/dist/assets/img/emoji-sprite.b5bd1fe0.png) no-repeat"
            background-position: "0px 0px"
            background-size: "599.7px"
            display: "inline-block"
            height: "50px"
            width: "50px"
	}
....
]
*/
  1. 输入:option: {size: number, emojiSpriteUrl: string}

    | 属性名 | 类型 | 默认值 | 说明 | | -------------- | ------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | size | number | 64 | emoji 大小,单位 px | | emojiSpriteUrl | string | https://res.wx.qq.com/wxdoc/dist/assets/img/emoji-sprite.b5bd1fe0.png | 雪碧图文件路径,为了避免链接失效,最好将 src/assets/emoji-sprite.png 中的文件上传自己的 cdn,然后设置为对应的资源路径 |

  2. 输出 emojis: [ { code: string, cn: string, style: { ​ display: string ​ background: string ​ width: string ​ height: string ​ 'background-position': string ​ 'background-size': string }

}]

| 属性名 | 类型 | 默认值 | 说明 | | ------ | ------ | ------ | -------------------------- | | code | string | | emoji 对应的编码,如:/:@> | | cn | string | | 中文显示,如:[右哼哼] | | style | Object | | |

parseEmoji(str) 解析表情

import { parseEmoji, configParseEmoji } from 'wechat-emoji-parser'
configParseEmoji({ size: 30 }) // 设置一些参数
const res = parseEmoji('哈哈[西瓜]') // 解析文本
  • configParseEmoji(option: object) 配置解析规则

    | 属性名 | 类型 | 默认值 | 说明 | | -------------- | ------ | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | size | number | 64 | emoji 大小,单位 px | | emojiSpriteUrl | string | https://res.wx.qq.com/wxdoc/dist/assets/img/emoji-sprite.b5bd1fe0.png | 雪碧图文件路径,为了避免链接失效,最好将 src/assets/emoji-sprite.png 中的文件上传自己的 cdn,然后设置为对应的资源路径 | | tag | string | 'a' | 解析后的 html 标签 |

  • parseEmoji(str: string)

    输入:待解析的文本

    输出:解析后的内容

example