Skip to content

Commit

Permalink
chore(v8n): add commitizen to enforce angular commit message format
Browse files Browse the repository at this point in the history
ref #190
  • Loading branch information
brfrth committed May 24, 2021
1 parent cf030d8 commit b55b9a3
Show file tree
Hide file tree
Showing 15 changed files with 647 additions and 27 deletions.
40 changes: 39 additions & 1 deletion dist/v8n.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ define(function () { 'use strict';
}

function v8n() {
return proxyContext(new Context());
return typeof Proxy !== undefined
? proxyContext(new Context())
: proxylessContext(new Context());
}

// Custom rules
Expand Down Expand Up @@ -231,6 +233,42 @@ define(function () { 'use strict';
});
}

function proxylessContext(context) {
var addRuleSet = function (ruleSet, targetContext) {
Object.keys(ruleSet).forEach(function (prop) {
targetContext[prop] = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var newContext = proxylessContext(targetContext._clone());
var contextWithRuleApplied = newContext._applyRule(
ruleSet[prop],
prop
).apply(void 0, args);
return contextWithRuleApplied;
};
});
return targetContext;
};

var contextWithAvailableRules = addRuleSet(availableRules, context);
var contextWithAllRules = addRuleSet(
customRules,
contextWithAvailableRules
);

Object.keys(availableModifiers).forEach(function (prop) {
Object.defineProperty(contextWithAllRules, prop, {
get: function () {
var newContext = proxylessContext(contextWithAllRules._clone());
return newContext._applyModifier(availableModifiers[prop], prop);
}
});
});

return contextWithAllRules;
}

var availableModifiers = {
not: {
simple: function (fn) { return function (value) { return !fn(value); }; },
Expand Down
40 changes: 39 additions & 1 deletion dist/v8n.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ var v8n = (function () {
}

function v8n() {
return proxyContext(new Context());
return typeof Proxy !== undefined
? proxyContext(new Context())
: proxylessContext(new Context());
}

// Custom rules
Expand Down Expand Up @@ -232,6 +234,42 @@ var v8n = (function () {
});
}

function proxylessContext(context) {
var addRuleSet = function (ruleSet, targetContext) {
Object.keys(ruleSet).forEach(function (prop) {
targetContext[prop] = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var newContext = proxylessContext(targetContext._clone());
var contextWithRuleApplied = newContext._applyRule(
ruleSet[prop],
prop
).apply(void 0, args);
return contextWithRuleApplied;
};
});
return targetContext;
};

var contextWithAvailableRules = addRuleSet(availableRules, context);
var contextWithAllRules = addRuleSet(
customRules,
contextWithAvailableRules
);

Object.keys(availableModifiers).forEach(function (prop) {
Object.defineProperty(contextWithAllRules, prop, {
get: function () {
var newContext = proxylessContext(contextWithAllRules._clone());
return newContext._applyModifier(availableModifiers[prop], prop);
}
});
});

return contextWithAllRules;
}

var availableModifiers = {
not: {
simple: function (fn) { return function (value) { return !fn(value); }; },
Expand Down
2 changes: 1 addition & 1 deletion dist/v8n.browser.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/v8n.browser.min.js.map

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion dist/v8n.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ function executeAsyncRules(value, rules, resolve, reject) {
}

function v8n() {
return proxyContext(new Context());
return typeof Proxy !== undefined
? proxyContext(new Context())
: proxylessContext(new Context());
}

// Custom rules
Expand Down Expand Up @@ -231,6 +233,42 @@ function proxyContext(context) {
});
}

function proxylessContext(context) {
var addRuleSet = function (ruleSet, targetContext) {
Object.keys(ruleSet).forEach(function (prop) {
targetContext[prop] = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];

var newContext = proxylessContext(targetContext._clone());
var contextWithRuleApplied = newContext._applyRule(
ruleSet[prop],
prop
).apply(void 0, args);
return contextWithRuleApplied;
};
});
return targetContext;
};

var contextWithAvailableRules = addRuleSet(availableRules, context);
var contextWithAllRules = addRuleSet(
customRules,
contextWithAvailableRules
);

Object.keys(availableModifiers).forEach(function (prop) {
Object.defineProperty(contextWithAllRules, prop, {
get: function () {
var newContext = proxylessContext(contextWithAllRules._clone());
return newContext._applyModifier(availableModifiers[prop], prop);
}
});
});

return contextWithAllRules;
}

var availableModifiers = {
not: {
simple: function (fn) { return function (value) { return !fn(value); }; },
Expand Down
37 changes: 36 additions & 1 deletion dist/v8n.esm.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ function executeAsyncRules(value, rules, resolve, reject) {
}

function v8n() {
return proxyContext(new Context());
return typeof Proxy !== undefined
? proxyContext(new Context())
: proxylessContext(new Context());
}

// Custom rules
Expand Down Expand Up @@ -212,6 +214,39 @@ function proxyContext(context) {
});
}

function proxylessContext(context) {
const addRuleSet = (ruleSet, targetContext) => {
Object.keys(ruleSet).forEach(prop => {
targetContext[prop] = (...args) => {
const newContext = proxylessContext(targetContext._clone());
const contextWithRuleApplied = newContext._applyRule(
ruleSet[prop],
prop
)(...args);
return contextWithRuleApplied;
};
});
return targetContext;
};

const contextWithAvailableRules = addRuleSet(availableRules, context);
const contextWithAllRules = addRuleSet(
customRules,
contextWithAvailableRules
);

Object.keys(availableModifiers).forEach(prop => {
Object.defineProperty(contextWithAllRules, prop, {
get: () => {
const newContext = proxylessContext(contextWithAllRules._clone());
return newContext._applyModifier(availableModifiers[prop], prop);
}
});
});

return contextWithAllRules;
}

const availableModifiers = {
not: {
simple: fn => value => !fn(value),
Expand Down
Loading

0 comments on commit b55b9a3

Please sign in to comment.