Socket
Socket
Sign inDemoInstall

@wulechuan/apply-one-stage-one-method-pattern

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.9

2

build/wulechuan-one-method-one-stage-pattern-builder.min.js

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

function WulechuanApplyOneStageOneMethodProgrammingPatternTo(e){function a(e){return Array.isArray(e)&&e.length>0}function n(a,n,o){if("function"!=typeof a)throw TypeError('A so-called stage is basically a function, with some associated aliases just for conveniences, which not only does some demonded work but also exposes subsequence stages and hides past stages for a given stages operator. Among them, the demonded work is provided by you developer via the first argument, So, when defining a stage, the first argument must be a function, \nwhile the provided value was of type "'+typeof a+'".');2===arguments.length&&(o=n,n=!1),t(o);var r=m.length;o.stageIndex=r,o.usingLanguage="";var i={actionAliases:o,allowsToSkip:n,action:function(){if(c)return r===m.length-1?void 0:e;w=r;var n=a.apply(e,arguments);return s(),r===m.length-1?n:e}};return m.push(i),i}function t(e){var n=!1;if(!e||"object"!=typeof e)throw TypeError("The action aliases argument must be an object, containing at least one alias which is marked as in a specified language.");for(var t in e){var o=e[t];o&&"string"==typeof o&&(o=[o],e[t]=o),a(o)&&(n=!0,!T[t]&&(b.push(t),T[t]=!0))}if(!n)throw TypeError("At least one alias is required for a stage action to publish as a method.")}function o(e,n){var t=e[n];if(a(t))return e.usingLanguage=n,t;var o,r=!1;for(o in e)if(t=e[o],a(t)){r=!0,e.usingLanguage=o;break}if(!r)throw ReferenceError("No valid aliases in any language for stage "+e.stageIndex+"!");return console.warn("For stage",e.stageIndex,', none of the aliases is in the preferred language ("'+n+'").','\nInstead, aliases in "'+o+'" are exposed as methods.'),t}function r(e){if(!e)throw TypeError("Must specify the natural language to use.");h=e,g()}function i(){m[0].action.apply(e,arguments)}function s(){u(),m[w].action.apply(e,arguments),0===w&&l(1)}function u(){for(var a=0;a<=w;a++)for(var n=m[a].actionAliases,t=n[n.usingLanguage],o=0;o<t.length;o++){var r=t[o];delete e[r]}}function g(){m.length<1||h&&(y[v]=i,f(0,1))}function l(e){var a,n=m.length;for(a=e;a<m.length-1;a++)if(!m[a].allowsToSkip){n=a+1;break}f(e,n)}function f(a,n){for(var t=a;t<n;t++)for(var r=m[t],i=r.action,s=o(r.actionAliases,h),u=0;u<s.length;u++){var g=s[u];e[g]=i}}var c,h,p="addStage",d="setPreferredNaturalLanguageTo",v="startFromFirstStage",y=this,m=[],w=NaN,b=[],T={};y[p]=function(){c=!1,n.apply(y,arguments),y[p]=n,y[d]=r,g()},y[d]=r,y.stop=function(){c=!0,console.error("The process is stopped at stage",w)}}module.exports=WulechuanApplyOneStageOneMethodProgrammingPatternTo;
function WulechuanApplyOneStageOneMethodProgrammingPatternTo(e,a){function n(e){return Array.isArray(e)&&e.length>0}function t(a,n,t){if("function"!=typeof a)throw TypeError('A so-called stage is basically a function, with some associated aliases just for conveniences, which not only does some demonded work but also exposes subsequence stages and hides past stages for a given stages operator. Among them, the demonded work is provided by you developer via the first argument, So, when defining a stage, the first argument must be a function, \nwhile the provided value was of type "'+typeof a+'".');2===arguments.length&&(t=n,n=!1),o(t);var r=w.length;t.stageIndex=r,t.usingLanguage="";var i={actionAliases:t,allowsToSkip:n,action:function(){if(h)return r===w.length-1?void 0:e;b=r;var n=a.apply(e,arguments);return g(),r===w.length-1?n:e}};return w.push(i),i}function o(e){var a=!1;if(!e||"object"!=typeof e)throw TypeError("The action aliases argument must be an object, containing at least one alias which is marked as in a specified language.");for(var t in e){var o=e[t];o&&"string"==typeof o&&(o=[o],e[t]=o),n(o)&&(a=!0,!A[t]&&(T.push(t),A[t]=!0))}if(!a)throw TypeError("At least one alias is required for a stage action to publish as a method.")}function r(e,a){var t=e[a];if(n(t))return e.usingLanguage=a,t;var o,r=!1;for(o in e)if(t=e[o],n(t)){r=!0,e.usingLanguage=o;break}if(!r)throw ReferenceError("No valid aliases in any language for stage "+e.stageIndex+"!");return console.warn("For stage",e.stageIndex,', none of the aliases is in the preferred language ("'+a+'").','\nInstead, aliases in "'+o+'" are exposed as methods.'),t}function i(e){if(!e)throw TypeError("Must specify the natural language to use.");p=e,l()}function s(){w[0].action.apply(e,arguments)}function g(){u(),f(b+1)}function u(){for(var a=0;a<=b;a++)for(var n=w[a].actionAliases,t=n[n.usingLanguage],o=0;o<t.length;o++){var r=t[o];delete e[r]}}function l(){w.length<1||p&&(m[y]=s,c(0,1))}function f(e){var a,n=w.length;for(a=e;a<w.length-1;a++)if(!w[a].allowsToSkip){n=a+1;break}c(e,n)}function c(a,n){for(var t=a;t<n;t++)for(var o=w[t],i=o.action,s=r(o.actionAliases,p),g=0;g<s.length;g++){var u=s[g];e[u]=i}}var h,p,d="addStage",v="setPreferredNaturalLanguageTo",y="startFromFirstStage",m=this,w=[],b=NaN,T=[],A={};a&&"string"==typeof a&&(p=a),m[d]=function(){h=!1,t.apply(m,arguments),m[d]=t,m[v]=i,l()},m[v]=i,m.stop=function(){h=!0,console.error("The process is stopped at stage",b)}}module.exports=WulechuanApplyOneStageOneMethodProgrammingPatternTo;

@@ -15,8 +15,9 @@ const productionSourceGlobJs = ['source/**/*.js'];

const processArguments = require('minimist')(process.argv.slice(2));
const deleteFiles = require('del');
const gulp = require('gulp');
const runTasksInSequence = require('gulp-sequence');
const replaceFileContent = require('gulp-change');
const deleteFiles = require('del');
const renameFiles = require('gulp-rename');
const runTasksInSequence = require('gulp-sequence');
const minifyJs = require('gulp-uglify');

@@ -26,4 +27,33 @@ const pump = require('pump');

const isToBuildForRelease = isRunningInReleasingMode(processArguments);
const isToDevelopWithWatching = !isToBuildForRelease;
function isRunningInReleasingMode(processArguments) {
const thoseArgumentsStandForRelease = [
'release',
'production',
'ship',
'final',
'publish'
];
for (let i = 0; i < thoseArgumentsStandForRelease.length; i++) {
let allowedInput = thoseArgumentsStandForRelease[i];
if (typeof allowedInput !== 'string' || !allowedInput) {
continue;
}
allowedInput = allowedInput.trim();
if (processArguments[allowedInput]) return true;
}
return false;
}
(function 构建README() {

@@ -139,5 +169,13 @@ gulp.task('build: readme', (thisTaskIsDone) => {

(function 定义所谓顶级任务() {
var tasksToRun = [
'build: all'
];
if (isToDevelopWithWatching) {
tasksToRun.push('watch');
}
gulp.task('default', (thisTaskIsDone) => {
runTasksInSequence('build: all', 'watch')(thisTaskIsDone);
runTasksInSequence.apply(this, tasksToRun)(thisTaskIsDone);
});
})();
{
"name": "@wulechuan/apply-one-stage-one-method-pattern",
"version": "1.0.8",
"version": "1.0.9",
"description": "凡由本类构建的实例对象,可用于将本人设计的一种程序设计模式应用至另一“受体”对象。“受体”因而被改造,其各个所涉及之方法函数均被依次对应于各自的所谓“执行阶段”,亦可称“步骤”,每个方法函数对应一个步骤。自此时起,仅第一个步骤所对应的方法函数被公开(或称“曝露”),其余后续步骤之方法函数均被隐藏,直至各自前导执行阶段完成,这些方法函数才会陆续公开。",

@@ -23,2 +23,3 @@ "main": "build/wulechuan-one-method-one-stage-pattern-builder.min.js",

"gulp-uglify": "^3.0.0",
"minimist": "^1.2.0",
"pump": "^1.0.2"

@@ -25,0 +26,0 @@ },

@@ -211,3 +211,3 @@ module.exports = WulechuanApplyOneStageOneMethodProgrammingPatternTo;

// eslint-disable-next-line
function WulechuanApplyOneStageOneMethodProgrammingPatternTo(stageMethodsOwner) {
function WulechuanApplyOneStageOneMethodProgrammingPatternTo(stageMethodsOwner, initialPreferredLanguage) {
var methodName_addStage = 'addStage';

@@ -226,4 +226,9 @@ var methodName_setPreferredNaturalLanguageTo = 'setPreferredNaturalLanguageTo';

var knownLanguagesIndicesSoFar = {}; // Simply for easy avoiding duplications
var usingLanguage;
var preferredLanguage;
if (initialPreferredLanguage && typeof initialPreferredLanguage === 'string') {
preferredLanguage = initialPreferredLanguage;
}
thisManagerOfStages[methodName_addStage] = addFirstStage;

@@ -358,6 +363,6 @@ thisManagerOfStages[methodName_setPreferredNaturalLanguageTo] = setPreferredNaturalLanguageTo;

function _getActionAliasesBetterInThisLanguage(actionAliasesInAllLanguages, preferredLanguage) {
var foundActionAliases = actionAliasesInAllLanguages[preferredLanguage];
function _getActionAliasesBetterInThisLanguage(actionAliasesInAllLanguages, _preferredLanguage) {
var foundActionAliases = actionAliasesInAllLanguages[_preferredLanguage];
if (_isAUsableArray(foundActionAliases)) {
actionAliasesInAllLanguages.usingLanguage = preferredLanguage;
actionAliasesInAllLanguages.usingLanguage = _preferredLanguage;
return foundActionAliases;

@@ -386,3 +391,3 @@ }

console.warn('For stage', actionAliasesInAllLanguages.stageIndex,
', none of the aliases is in the preferred language ("'+preferredLanguage+'").',
', none of the aliases is in the preferred language ("'+_preferredLanguage+'").',
'\nInstead, aliases in "'+language+'" are exposed as methods.'

@@ -398,3 +403,3 @@ );

}
usingLanguage = language;
preferredLanguage = language;
_tryToExposeFirstStageSoThatTheOperatorIsUsable();

@@ -413,14 +418,7 @@ }

function _modifyMethodsOwnerByExposingOrHidingSomeMethods() {
_hideMethodsOfAllPastOrSkippedStages();
var currentStage = allStages[currentStageIndex];
currentStage.action.apply(stageMethodsOwner, arguments);
if (currentStageIndex === 0) {
_exposeMethodsOfAllStagesStartingWithIndexTillFirstRequiredStage(1);
}
_hideMethodsOfAllPastOrSkippedStagesIncludingCurrentStage();
_exposeMethodsOfAllStagesTillFirstRequiredStageStartingWithIndex(currentStageIndex+1);
}
function _hideMethodsOfAllPastOrSkippedStages() {
function _hideMethodsOfAllPastOrSkippedStagesIncludingCurrentStage() {
for (var si = 0; si <= currentStageIndex; si++) {

@@ -441,3 +439,3 @@ var stage = allStages[si];

if (allStages.length < 1) return;
if (!usingLanguage) return;
if ( ! preferredLanguage) return;

@@ -452,3 +450,3 @@ // Expose the method of the first stage with the common name,

function _exposeMethodsOfAllStagesStartingWithIndexTillFirstRequiredStage(startingStageIndex) {
function _exposeMethodsOfAllStagesTillFirstRequiredStageStartingWithIndex(startingStageIndex) {
var endingExclusiveStageIndex = allStages.length;

@@ -475,3 +473,3 @@

var actionAliasesInActuallyUsingLanuage =
_getActionAliasesBetterInThisLanguage(stage.actionAliases, usingLanguage);
_getActionAliasesBetterInThisLanguage(stage.actionAliases, preferredLanguage);

@@ -478,0 +476,0 @@ for (var ai = 0; ai < actionAliasesInActuallyUsingLanuage.length; ai++) {

Sorry, the diff of this file is not supported yet

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