用于 JavaScript 的不差的类。
P.js is a lightweight layer over javascript's built-in inheritance system that keeps all the good stuff and hides all the crap.
Okay.
…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).
Unlike some other frameworks out there, Pjs doesn't do any of this:
instanceofthis at runtimeinit)init method)super on public methods without any dirty hacksYou can call P in a few different ways:
…Assuming you have it installed (via npm install pjs), you can import it with
var P = require('pjs').P;and go about your business.
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
npm installfrom 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,或尚未同步最近议题。