百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

pjs

> 编程语言
开源

用于 JavaScript 的不差的类。

196 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于 JavaScript 的不差的类。

P.js

P.js is a lightweight layer over javascript's built-in inheritance system that keeps all the good stuff and hides all the crap.

just show me some code already

Okay.

…

how is pjs different from X

Most class systems for JS let you define classes by passing an object. P.js lets you pass a function instead, which allows you to closure private methods and macros. It's also <0.4kb minified (make report: 467).

why doesn't pjs suck?

Unlike some other frameworks out there, Pjs doesn't do any of this:

  • interfaces, abstract static factory factories, and other bloat
  • use Object.create (it even works in IE < 8!)
  • break instanceof
  • hack functions onto this at runtime
  • rely on magical object keys which don't minify (the only special name is init)

what can i do with pjs?

  • inheritable constructors (via the optional init method)
  • closure-based "private" methods (see below)
  • easily call super on public methods without any dirty hacks
  • instantiate your objects without calling the constructor (absolutely necessary for inheritance)
  • construct objects with variable arguments

how do i use pjs?

You can call P in a few different ways:

…

how do i use pjs in node.js?

Assuming you have it installed (via npm install pjs), you can import it with

javascript
var P = require('pjs').P;

and go about your business.

what is all this Makefile stuff about

It's super useful! In addition to make, Pjs uses some build tools written on Node. With the Node Package Manager that comes with recent versions of it, just run

bash
npm install

from the root directory of the repo and make will start working.

Here are the things you can build:

  • make minify generates build/p.min.js

  • make commonjs generates build/p.commonjs.js, which is the same but has exports.P = P at the end

  • make amd generates build/p.amd.js, which is the same but has define(P) at the end

  • make test runs the test suite using the commonjs version. Requires mocha.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言