Introduction
Sqimitive.js – A Universal Primitive
Sqimitive.js is a minimalistic paradigm-agnostic building block for applications written in JavaScript (not necessary in-browser or DOM-related). It provides core infrastructure without much domain-specific logic that you can quickly develop thanks to its flexible API.
- Declaration-time and run-time mix-ins and traditional OOP inheritance using events. evt events mixIn _mergeProps
- Collections with Underscore integration and assisted management of children. util _childEvents autoOff
- Transparently ordered collections. Ordered _repos
- Attributes with normalization and on-change notifications. opt change_OPT
- Unserialization of data in arbitrary format. assignChildren assignResp
- DOM integration for “views”. jQuery Base.elEvents
- Fractal Promise on steroids. Async
Sqimitive.js is under 20K (minified), sports documentation that is nearly a hundred pages long (printed A4), needs no transpilers (plain pre-ES6 JavaScript, IE 11+) and depends only on a compatible utility library (NoDash +15K, Underscore.js un: or LoDash) and, optionally, on jQuery jq: or Zepto (for Sqimitive\jQuery).
And it’s in public domain (unlicense.org).
from jqex
Resources
npm install sqimitive
bower install sqimitive
- New to Sqimitive? Start with the overview: ov
- Download for development: github.com/ProgerXP/Sqimitive/…
- Download for production (minified):github.com/ProgerXP/Sqimitive/…
- Check out the sample To-Do application: squizzle.me/js/sqimitive/demo/t…
- Report issues: github.com/ProgerXP/Sqimitive/…
- Get the code on GitHub: github.com/ProgerXP/Sqimitive
If you spot a typo – select the fragment and press Ctrl+Enter. Help us keep this memo free of vexatious mistakes! Powered by github.com/ProgerXP/Orphus.
Basic code conventions
- Protected fields begin with underscore (
_
) – such fields (data properties and methods) are meant to be read or written only by the class they are defined in, or by one of its subclasses. It’s bad practice to try to access them from an ancestor (not the descendant they’re defined in) or, mind you, from an unrelated class – this is only justified, if ever, by really severe optimizations (such as tons of Base._opt calls bypassing get()). - Naming style: underscores separating camelCase – when an identifier (
oneId
) needs to be combined with another (twoId
) it becomes simplyoneId_twoId
instead ofoneIdTwoId
,one_id_two_id
or something else dictated by “pretty printing” identifiers. For example, Base fires events of form “change_OPT” so the event name used whenattrName
option (Base._opt) was changed ischange_attrName
. - Semicolon-free zone – JavaScript is one of those languages where operation separators are optional, much like in Lua. You just need to remember to put
;
before any operation beginning with(
(which most of the time has to do with IIFE):foo = 123 ;(function () { ... })() // without ; above is equivalent to 123(function () { {... })()
null
isundefined
– unless mentioned, these two values are used interchangeably: when testing, usevalue == null
instead of===
; when supplying, give any of the two. One case whenundefined
is different are event handler results (see ::fire()).