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

@unblockneteasemusic/rust-napi

v0.4.0

Published

Node.js binding for UNM Rust

Downloads

666

Readme

UnblockNeteaseMusic/server-rust 的 N-API binding

FOSSA Status

目前使用者文件及開發文件 仍在撰寫,在此之前有任何問題,歡迎開 Discussion 詢問。

使用

您可以直接從 https://www.npmjs.com 引用 @unblockneteasemusic/rust-napi 函式庫。 這個函式庫會協助您取回符合系統架構的套件。

就如〈架構〉所說,rust-napi 函式庫的引擎和類型定義,現階段內建在函式庫, 因此可以省去註冊引擎的步驟。但與舊版 JS 不同,UNM 輸往 console 的 logging 需手動開啟:

const UNM = require("@unblockneteasemusic/rust-napi");

// 啟用後,可以使用 `RUST_LOG` 環境變數調整 log 的詳細程度
UNM.enableLogging(UNM.LoggingType.ConsoleEnv);

然後我們可以建立一個 executor 實體,並定義想要的 context:

const executor = new UNM.Executor();
const ctx = {}; // 假如不需要任何設定
/* const ctx = { enableFlac: true }; // 每個欄位的說明資訊,現階段可參考函式庫中 `index.d.ts` 的定義。 */

接下來的使用方式與 Rust 函式庫相似:

const searchResult = await executor.search(
  // 使用所有可以使用的引擎。
  //
  // executor.list() 會列出所有可用的引擎。我們直接把這個引擎名單傳入 .search()。
  // 您亦可自訂要使用的引擎,如 ["bilibili", "kugou"]。
  //
  // 所有可使用的引擎,現階段可以參考 executor.rs 檔案中
  // construct_executor() 函式的定義。
  executor.list(),
  {
    id: "12345",
    name: "青花瓷",
    artists: [
      {
        id: "114514",
        name: "周杰伦",
      },
    ],
  },
  ctx
);

const retrieveResult = await executor.retrieve(searchResult, ctx);

設定

與 Rust 版通用的設定,請見 https://github.com/UnblockNeteaseMusic/server-rust/blob/main/README.md

授權條款

This project is licensed under LGPL-3.0-only.

FOSSA Status