Registry / web-framework / prettytype

prettytype

JSON →
library2.0.0jsnpmunverified

Multi-platform ES5 coding patterns and base super-prototypes for write-once, run-and-test everywhere (AngularJS, RequireJS, Node.js). Version 2.0.0 targets ES5 with no transpiler dependency, supporting Node 0.10.x+, AngularJS 1.x, RequireJS/AMD, and modern browsers. It provides reusable base prototypes, module patterns, and dependency injection for server/browser logic without build steps. Differentiators: native ES5 (no transpiler), supports multiple module systems without browserify, and includes supertype constructors for prototypal inheritance. Release cadence is low (stable, not actively updated).

npm install prettytype
INSTALL
IMPORT
SIG · PRETTYTYPE
P
prettytype
web-frameworkjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrettyType
import PrettyType from 'prettytype'
const { PrettyType } = require('prettytype')
Default export in v2. ESM requires bundler; Node CJS works with require('prettytype').
BaseProto
import { BaseProto } from 'prettytype'
const BaseProto = require('prettytype').BaseProto
Named export for base prototype class.
SuperProto
import { SuperProto } from 'prettytype'
var SuperProto = require('prettytype').SuperProto
Named export for super-prototype constructor.

Shows basic usage of PrettyType.extend() to create a prototype-based class with constructor, init, and methods, plus multi-platform export pattern.

// Example: Using PrettyType to create a multi-platform module // Assume prettytype is installed via npm or included in browser const PrettyType = require('prettytype'); // Define a simple prototype using PrettyType patterns const MyApp = PrettyType.extend({ constructor: function(config) { this.config = config || {}; this.name = this.config.name || 'default'; }, init: function() { console.log('MyApp initialized with name:', this.name); return this; }, greet: function() { return 'Hello from ' + this.name; } }); // Create an instance const app = new MyApp({ name: 'test' }); app.init(); console.log(app.greet()); // Export for multiple platforms (if needed) if (typeof define === 'function' && define.amd) { define(function() { return MyApp; }); } else if (typeof module !== 'undefined' && module.exports) { module.exports = MyApp; }
Debug
Known issues
gotchaES5-only: Polyfills required for ES6+. No Promise, Map, Set, or arrow functions.
fix
Use ES5 polyfills (e.g., core-js) if running in modern environments that drop ES5 support.
affects: >=2.0.0
deprecatedAngularJS 1.x support may be deprecated; Angular 2+ not compatible.
fix
For Angular 2+, wrap PrettyType in Angular services.
affects: >=2.0.0
gotchaBrowser global leak if not loaded via AMD or CommonJS; adds to window object.
fix
Always load via AMD/CommonJS or wrap in IIFE.
affects: >=0.0.0
breakingv2.0.0 changed export structure from v1; named exports replaced default object.
fix
Update imports: use require('prettytype') instead of require('prettytype').PrettyType.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
Cannot find module 'prettytype'
Package not installed or path incorrect.
fix
Run 'npm install prettytype' and ensure node_modules is present.
TypeError: PrettyType.extend is not a function
Importing default export incorrectly in CommonJS.
fix
Use 'const PrettyType = require('prettytype')' (no destructuring).
ReferenceError: define is not defined
AMD code running in non-browser env without RequireJS.
fix
Check if define exists before using: if (typeof define === 'function' && define.amd) { ... }
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
prettytype — npm install prettytype · libregistry