如何检查 NPM 包中包含的内容

问题描述

我安装了这个包:npm install @mediapipe/camera_utils

我想知道如何查找包中的内容

解决方法

我发现的一个好技巧是使用网站 npmfs.com 而不是 npmjs.com(只需在包 url 中将“s”替换为“f”)。

Here're the contents of that particular package(每个版本) 这是最新版本中 camera_utils.jscontents

(function(){/*
 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
'use strict';var e="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};function f(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var h=f(this);
function k(a,b){if(b)a:{var c=h;a=a.split(".");for(var d=0;d<a.length-1;d++){var g=a[d];if(!(g in c))break a;c=c[g]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&e(c,{configurable:!0,writable:!0,value:b})}}var l="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var g in d)Object.prototype.hasOwnProperty.call(d,g)&&(a[g]=d[g])}return a};k("Object.assign",function(a){return a||l});var m=this||self;var n={facingMode:"user",width:640,height:480};function p(a,b){this.video=a;this.h=0;this.g=Object.assign(Object.assign({},n),b)}function q(a){window.requestAnimationFrame(function(){r(a)})}function t(a,b){a.video.srcObject=b;a.video.onloadedmetadata=function(){a.video.play();q(a)}}function r(a){var b=null;a.video.paused||a.video.currentTime===a.h||(a.h=a.video.currentTime,b=a.g.onFrame());b?b.then(function(){q(a)}):q(a)}
p.prototype.start=function(){var a=this;navigator.mediaDevices&&navigator.mediaDevices.getUserMedia||alert("No navigator.mediaDevices.getUserMedia exists.");var b=this.g;return navigator.mediaDevices.getUserMedia({video:{facingMode:b.facingMode,width:b.width,height:b.height}}).then(function(c){t(a,c)}).catch(function(c){console.error("Failed to acquire camera feed: "+c);alert("Failed to acquire camera feed: "+c);throw c;})};var u=["Camera"],v=m;
u[0]in v||"undefined"==typeof v.execScript||v.execScript("var "+u[0]);for(var w;u.length&&(w=u.shift());)u.length||void 0===p?v[w]&&v[w]!==Object.prototype[w]?v=v[w]:v=v[w]={}:v[w]=p;}).call(this);

注意:NPM 实际上是通过“探索”选项卡原生添加此功能的,但目前处于测试阶段。

enter image description here

,
  • 首先,最好的检查方法是 npm website 本身来自您所在的位置 下载这个插件。
  • 在安装过程中,您可以通过命令 npm install -ddd
  • 如果您愿意了解更多您需要了解的所有包裹内容 转到 node_modules 文件夹,找到您所在的包名 寻找。在该文件夹中,您可以找到它自己的 pacakge.json 文件,其中包含其所有依赖项。