Socket
Socket
Sign inDemoInstall

qclass

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.2

.travis.yml

8

package.json
{
"name": "qclass",
"version": "0.1.0",
"version": "0.1.2",

@@ -18,5 +18,5 @@ "description": "Quick and simple JavaScript class library.",

"homepage": "https://github.com/kobalicek/qclass",
"homepage": "https://github.com/jshq/qclass",
"bugs": {
"url": "https://github.com/kobalicek/qclass/issues"
"url": "https://github.com/jshq/qclass/issues"
},

@@ -40,3 +40,3 @@

"type": "git",
"url": "https://github.com/kobalicek/qclass.git"
"url": "https://github.com/jshq/qclass.git"
},

@@ -43,0 +43,0 @@

@@ -0,1 +1,4 @@

// QClass <https://github.com/jshq/qclass>
"use strict"
var assert = require("assert");

@@ -2,0 +5,0 @@ var qclass = require("./qclass");

@@ -1,3 +0,2 @@

// QClass <https://github.com/kobalicek/qclass>
// Quick and simple JavaScript class library (Unlicense).
// QClass <https://github.com/jshq/qclass>
(function($export, $as) {

@@ -4,0 +3,0 @@ "use strict";

@@ -6,7 +6,5 @@ QClass

Official Repository
-------------------
* [Official Repository (jshq/qclass)](https://github.com/jshq/qclass)
* [Unlicense] (http://unlicense.org)
https://github.com/kobalicek/qclass
Introduction

@@ -249,3 +247,4 @@ ------------

// Create an instance of `Point` and try.
// Create an instance of `Point` and use functions created by the
// `property` extension.
var point = new Point(1, 2);

@@ -263,3 +262,3 @@

Hooks are very similar to extensions, however they don't need any key in definitions and are always called. Hooks are in general more powerful, because they can use any property or multiple properties to do the job. For example in [QSql](https://github.com/kobalicek/qsql) library hooks are used to alias all "UPPER_CASED" functions which mimic SQL keyword to "camelCased" alternatives.
Hooks are very similar to extensions, however they don't need any key in definitions and are always called. Hooks are in general more powerful, because they can use any property or multiple properties to do the job. For example in [QSql](https://github.com/jshq/qsql) library hooks are used to alias all "UPPER_CASED" functions which mimic SQL keywords to "camelCased" alternatives.

@@ -269,7 +268,83 @@ Mixins

TODO:
A mixin is set of functions that can be included in another class or mixin. Mixins are defined by using `qclass.mixin(def)`, where `def` is similar definition compatible to `qclass` itself, but without `$construct` support (mixins can't be instantiated). Mixins also understand `$extensions` and `$hooks`, so it's possible to define these in the mixin and just include in other classes.
License
-------
```JS
// Create a mixin that provides `translate(x, y)` function.
var MTranslate = qclass.mixin({
translate: function(x, y) {
this.x += x;
this.y += y;
return this;
}
});
QClass follows `Unlicense`.
// Create a Point class that includes MTranslate mixin.
var Point = qclass({
$mixins: [MTranslate],
$construct: function(x, y) {
this.x = x;
this.y = y;
},
toString: function() {
return "[" + this.x + " " + this.y + "]";
}
});
// Create a Rect class that includes MTranslate mixin.
var Rect = qclass({
$mixins: [MTranslate],
$construct: function(x, y, w, h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
},
toString: function() {
return "[" + this.x + " " + this.y + " " + this.w + " " + this.h + "]";
}
});
// The translate() functions are provided to both classes.
var p = new Point(0, 0);
var r = new Rect(0, 0, 33, 67);
p.translate(1, 2);
r.translate(1, 2);
console.log(p.toString()); // Outputs `[1, 2]`.
console.log(r.toString()); // Outputs `[1, 2, 33, 67]`.
```
Combining more mixins to a single mixin:
```JS
// Create two mixins MTranslate and MScale.
var MTranslate = qclass.mixin({
translate: function(x, y) {
this.x += x;
this.y += y;
return this;
}
});
var MScale = qclass.mixin({
scale: function(x, y) {
if (y == null)
y = x;
this.x *= x;
this.y *= y;
return this;
}
});
// If a combined mixin is needed, it can be created simply by
// including MTranslate and MScale into another mixin.
var MCombined = qclass.mixin({
$mixins: [MTranslate, MScale]
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc