New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jeefo_core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jeefo_core - npm Package Compare versions

Comparing version 0.0.4 to 0.0.6

build/header_compiler.js

119

build/index.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : index.js
* Created at : 2016-09-01
* Updated at : 2017-04-28
* Created at : 2017-04-29
* Updated at : 2017-05-03
* Author : jeefo

@@ -9,12 +9,18 @@ * Purpose :

_._._._._._._._._._._._._._._._._._._._._.*/
//ignore:start
"use strict";
var fse = require("fs-extra"),
path = require("path"),
uglify = require("uglify-js"),
_package = require("../package");
/* global */
/* exported */
/* exported */
var IGNORE_REGEX = /\/\/ignore\:start(?:(?!\/\/ignore\:end)[.\s\S])+.*\n/ig;
//ignore:end
var fse = require("fs-extra"),
path = require("path"),
uglify = require("uglify-js"),
_package = require("../package"),
preprocessor = require("./preprocessor"),
header_compiler = require("./header_compiler");
var get_filesize = function (path) {

@@ -27,12 +33,9 @@ return fse.statSync(path).size;

var source = source_files.map(function (file) {
var ignore;
var code = fse.readFileSync(`./${ file }`, "utf8").
replace(IGNORE_REGEX, function ($1) {
if (! ignore) {
ignore = $1;
}
return '';
});
var code = fse.readFileSync(`./${ file }`, "utf8");
return code.trim();
if (! file.startsWith("node_modules")) {
code = preprocessor(file, code).trim();
}
return code;
}).join("\n\n");

@@ -42,45 +45,61 @@

var license = `The ${ _package.license } license`;
var header = header_compiler({
[_package.name] : `v${ _package.version }`,
Author : `${ _package.author.name }, <${ _package.author.email }>`,
Homepage : _package.homepage,
License : license,
Copyright : _package.copyright
});
var browser_source = `(function (jeefo, $window, $document) { "use strict";\n\n${ source }\n\n}(window.jeefo, window, document));`;
var build_source = `function fn (jeefo) {${ source }}`;
var node_source = `"use strict";module.exports=function (jeefo) {${ source }};`;
var node_source = `${ header }\n"use strict";\n\nmodule.exports = function (jeefo) {\n\n${ source }\n\nreturn jeefo;\n\n};`;
var output_source = `${ header }(function (jeefo) {\n\n${ source }\n\n}(jeefo));`;
var node_min_source;
browser_source = uglify.minify(browser_source, _package.uglify_config).code;
build_source = uglify.minify(build_source, _package.uglify_config).code;
node_source = uglify.minify(node_source, _package.uglify_config).code;
browser_source = header + uglify.minify(browser_source, _package.uglify_config).code;
node_min_source = header + uglify.minify(node_source, _package.uglify_config).code;
// Final step
var output_filename = path.resolve(__dirname, `../dist/${ _package.name }.js`);
var node_filename = path.resolve(__dirname, `../dist/${ _package.name }.node.js`);
var build_filename = path.resolve(__dirname, `../dist/${ _package.name }.build.js`);
var browser_filename = path.resolve(__dirname, `../dist/${ _package.name }.min.js`);
var output_filename = path.resolve(__dirname, `../dist/${ _package.name }.js`);
var node_filename = path.resolve(__dirname, `../dist/${ _package.name }.node.js`);
var node_min_filename = path.resolve(__dirname, `../dist/${ _package.name }.node.min.js`);
var browser_filename = path.resolve(__dirname, `../dist/${ _package.name }.min.js`);
var MAX_LENGTH = _package.name.length > "copyright".length ? _package.name.length : "copyright".length;
var align = function (str) {
var i = 0, space = '', len = MAX_LENGTH - str.length;
for (; i < len; ++i) {
space += ' ';
}
fse.outputFileSync(output_filename, output_source);
fse.outputFileSync(node_filename, node_source);
fse.outputFileSync(node_min_filename, node_min_source);
fse.outputFileSync(browser_filename, browser_source);
return `${ str }${ space }`;
};
console.log(`Raw source: ${ get_filesize(output_filename) } bytes.`);
console.log(`Node source: ${ get_filesize(node_filename) } bytes.`);
console.log(`Node min source: ${ get_filesize(node_min_filename) } bytes.`);
console.log(`Browser source: ${ get_filesize(browser_filename) } bytes.`);
browser_source = `/**
* ${ align(_package.name) } : v${ _package.version }
* ${ align("Author") } : ${ _package.author }
* ${ align("Homepage") } : ${ _package.homepage }
* ${ align("License") } : ${ _package.license }
* ${ align("Copyright") } : 2017
**/
${ browser_source }`;
// License {{{1
license = `${ license }
Copyright (c) ${ _package.copyright } - ${ _package.name }, ${ _package.homepage }
fse.outputFileSync(output_filename, source);
fse.outputFileSync(node_filename, node_source);
fse.outputFileSync(build_filename, build_source);
fse.outputFileSync(browser_filename, browser_source);
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
console.log(`Raw source: ${ get_filesize(output_filename) } bytes.`);
console.log(`Node source: ${ get_filesize(build_filename) } bytes.`);
console.log(`Build source: ${ get_filesize(build_filename) } bytes.`);
console.log(`Browser source: ${ get_filesize(browser_filename) } bytes.`);
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.`;
var license_path = path.resolve(__dirname, "../LICENSE");
fse.outputFileSync(license_path, license);
// }}}1

@@ -0,5 +1,14 @@

/**
* jeefo_core : v0.0.6
* Author : je3f0o, <je3f0o@gmail.com>
* Homepage : https://github.com/je3f0o/jeefo_core
* License : The MIT license
* Copyright : undefined
**/
(function (jeefo) {
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : core.js
* Created at : 2017-04-08
* Updated at : 2017-04-27
* Updated at : 2017-05-03
* Author : jeefo

@@ -10,72 +19,70 @@ * Purpose :

var core_module = jeefo.module("jeefo_core", []),
var core_module = jeefo.module("jeefo_core", []);
var _transformer = {
CAMEL_CASE_REGEXP : /[A-Z]/g,
snake_replacer : function (letter, pos) {
return (pos ? '_' : '') + letter.toLowerCase();
},
dash_replacer : function (letter, pos) {
return (pos ? '-' : '') + letter.toLowerCase();
},
snake_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.snake_replacer);
},
dash_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.dash_replacer);
}
};
// TODO: move it into jeefo.js
make_injectable = function (factory) {
return function (name, dependencies, fn, resolve_once) {
if (typeof dependencies === "function") {
resolve_once = fn;
fn = dependencies;
dependencies = [];
} else if (typeof dependencies === "string") {
dependencies = [dependencies];
}
core_module.extend("curry", ["$injector"], function ($injector) {
if (resolve_once === void 0) {
resolve_once = true;
}
var make_injectable = function (factory) {
return function (name, dependencies, fn, resolve_once) {
if (typeof dependencies === "function") {
resolve_once = fn;
fn = dependencies;
dependencies = [];
} else if (typeof dependencies === "string") {
dependencies = [dependencies];
}
return factory.call(this, name, {
fn : fn,
dependencies : dependencies,
resolve_once : resolve_once,
});
};
};
if (resolve_once === void 0) {
resolve_once = true;
}
var CAMEL_CASE_REGEXP = /[A-Z]/g;
var make_case_changer = function (separator) {
var LOCAL_REGEXP = CAMEL_CASE_REGEXP;
var changer = function (letter, pos) {
return (pos ? separator : '') + letter.toLowerCase();
return factory.call(this, name, {
fn : fn,
dependencies : dependencies,
resolve_once : resolve_once,
});
};
};
return function () {
return this.replace(LOCAL_REGEXP, changer);
};
};
var t = _transformer;
var curry_maker = make_injectable(function (name, injectable) {
$injector.register(t.snake_case(name + "Curry"), injectable);
});
String.prototype.dash_case = make_case_changer('-');
String.prototype.snake_case = make_case_changer('_');
curry_maker("makeInjectable", function () {
return make_injectable;
});
core_module.extend("curry", ["$injector"], function ($injector) {
// Local references
var make_injectable_local = make_injectable;
return make_injectable_local(function (name, injectable) {
$injector.register((name + "Curry").snake_case(), injectable);
});
return curry_maker;
});
// TODO: move it into jeefo.js
core_module.curry("makeInjectable", function () { return make_injectable; });
core_module.extend("run", ["$injector"], function ($injector) {
var LocalArray = Array;
return function (dependencies, fn) {
var i = 0, len, args;
if (typeof dependencies === "function") {
fn = dependencies;
args = [];
return dependencies.call(this);
} else if (typeof dependencies === "string") {
args = [$injector.resolve_sync(dependencies)];
} else {
i = 0;
len = dependencies.length;
args = new LocalArray(len);
for (; i < len; ++i) {
args[i] = $injector.resolve_sync(dependencies[i]);
}
return fn.call(this, $injector.resolve_sync(dependencies));
}
for (var args = new LocalArray(dependencies.length), i = args.length - 1; i >= 0; --i) {
args[i] = $injector.resolve_sync(dependencies[i]);
}
return fn.apply(this, args);

@@ -86,9 +93,13 @@ };

core_module.extend("namespace", ["$injector", "make_injectable_curry"], function (injector, make_injectable_curry) {
return make_injectable_curry(function (full_name, injectable) {
var Empty = function () {};
var object_maker = function () {
return new Empty();
};
var namespace_maker = make_injectable_curry(function (full_name, injectable) {
var namespaces = full_name.split('.'),
name = namespaces.pop(),
i = 0, len = namespaces.length,
namespace = '', part, container;
i = 0, namespace = '', part, container;
for (; i < len; ++i) {
for (; i < namespaces.length; ++i) {
part = namespaces[i];

@@ -100,9 +111,9 @@

namespace = namespace ? (namespace + '.' + part) : part;
namespace = namespace ? namespace + '.' + part : part;
if (! injector.has(namespace)) {
injector.register(namespace, {
fn : object_maker,
dependencies : [],
resolve_once : true,
fn : function () { return {}; }
});

@@ -123,2 +134,16 @@

});
var local_transformer = _transformer;
namespace_maker("transform.dash_case", function () {
return function (str) {
return local_transformer.dash_case(str);
};
});
namespace_maker("transform.snake_case", function () {
return function (str) {
return local_transformer.snake_case(str);
};
});
return namespace_maker;
});

@@ -128,6 +153,7 @@

"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, make_injectable_curry) {
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injector.register((name + "Factory").snake_case(), injectable);
injector.register(snake_case(name + "Factory"), injectable);
});

@@ -138,8 +164,11 @@ });

"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, make_injectable_curry) {
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injectable.is_constructor = true;
injector.register((name + "Service").snake_case(), injectable);
injector.register(snake_case(name + "Service"), injectable);
});
});
});
}(jeefo));
/**
* jeefo_core : v0.0.4
* Author : je3f0o <je3f0o@gmail.com>
* jeefo_core : v0.0.6
* Author : je3f0o, <je3f0o@gmail.com>
* Homepage : https://github.com/je3f0o/jeefo_core
* License : MIT
* Copyright : 2017
* License : The MIT license
* Copyright : undefined
**/
!function(e,n,r){"use strict";var t=e.module("jeefo_core",[]),c=function(e){return function(n,r,t,c){return"function"===typeof r?(c=t,t=r,r=[]):"string"===typeof r&&(r=[r]),void 0===c&&(c=!0),e.call(this,n,{fn:t,dependencies:r,resolve_once:c})}},o=function(e){var n=function(n,r){return(r?e:"")+n.toLowerCase()};return function(){return this.replace(/[A-Z]/g,n)}};String.prototype.dash_case=o("-"),String.prototype.snake_case=o("_"),t.extend("curry",["$injector"],function(e){return c(function(n,r){e.register((n+"Curry").snake_case(),r)})}),t.curry("makeInjectable",function(){return c}),t.extend("run",["$injector"],function(e){var n=Array;return function(r,t){var c,o,i=0;if("function"===typeof r)t=r,o=[];else if("string"===typeof r)o=[e.resolve_sync(r)];else for(i=0,c=r.length,o=new n(c);i<c;++i)o[i]=e.resolve_sync(r[i]);return t.apply(this,o)}}),t.extend("namespace",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){for(var t,c,o=n.split("."),i=o.pop(),s=0,u=o.length,a="";s<u;++s)t=o[s],a&&(c=e.resolve_sync(a)),a=a?a+"."+t:t,e.has(a)||(e.register(a,{dependencies:[],resolve_once:!0,fn:function(){return{}}}),c&&(c[t]=e.resolve_sync(a)));e.register(n,r),a&&(c=e.resolve_sync(a),c[i]=e.resolve_sync(n))})}),t.extend("factory",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){e.register((n+"Factory").snake_case(),r)})}),t.extend("service",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){r.is_constructor=!0,e.register((n+"Service").snake_case(),r)})})}(window.jeefo,window,document);
!function(e,n,r){"use strict";var t=e.module("jeefo_core",[]),c={CAMEL_CASE_REGEXP:/[A-Z]/g,snake_replacer:function(e,n){return(n?"_":"")+e.toLowerCase()},dash_replacer:function(e,n){return(n?"-":"")+e.toLowerCase()},snake_case:function(e){return e.replace(this.CAMEL_CASE_REGEXP,this.snake_replacer)},dash_case:function(e){return e.replace(this.CAMEL_CASE_REGEXP,this.dash_replacer)}};t.extend("curry",["$injector"],function(e){var n=function(e){return function(n,r,t,c){return"function"===typeof r?(c=t,t=r,r=[]):"string"===typeof r&&(r=[r]),void 0===c&&(c=!0),e.call(this,n,{fn:t,dependencies:r,resolve_once:c})}},r=c,t=n(function(n,t){e.register(r.snake_case(n+"Curry"),t)});return t("makeInjectable",function(){return n}),t}),t.extend("run",["$injector"],function(e){var n=Array;return function(r,t){if("function"===typeof r)return r.call(this);if("string"===typeof r)return t.call(this,e.resolve_sync(r));for(var c=new n(r.length),o=c.length-1;o>=0;--o)c[o]=e.resolve_sync(r[o]);return t.apply(this,c)}}),t.extend("namespace",["$injector","make_injectable_curry"],function(e,n){var r=function(){},t=function(){return new r},o=n(function(n,r){for(var c,o,s=n.split("."),i=s.pop(),a=0,u="";a<s.length;++a)c=s[a],u&&(o=e.resolve_sync(u)),u=u?u+"."+c:c,e.has(u)||(e.register(u,{fn:t,dependencies:[],resolve_once:!0}),o&&(o[c]=e.resolve_sync(u)));e.register(n,r),u&&(o=e.resolve_sync(u),o[i]=e.resolve_sync(n))}),s=c;return o("transform.dash_case",function(){return function(e){return s.dash_case(e)}}),o("transform.snake_case",function(){return function(e){return s.snake_case(e)}}),o}),t.extend("factory",["$injector","transform.snake_case","make_injectable_curry"],function(e,n,r){return r(function(r,t){e.register(n(r+"Factory"),t)})}),t.extend("service",["$injector","transform.snake_case","make_injectable_curry"],function(e,n,r){return r(function(r,t){t.is_constructor=!0,e.register(n(r+"Service"),t)})})}(window.jeefo,window,document);

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

"use strict";module.exports=function(e){var n=e.module("jeefo_core",[]),r=function(e){return function(n,r,t,c){return"function"===typeof r?(c=t,t=r,r=[]):"string"===typeof r&&(r=[r]),void 0===c&&(c=!0),e.call(this,n,{fn:t,dependencies:r,resolve_once:c})}},t=function(e){var n=function(n,r){return(r?e:"")+n.toLowerCase()};return function(){return this.replace(/[A-Z]/g,n)}};String.prototype.dash_case=t("-"),String.prototype.snake_case=t("_"),n.extend("curry",["$injector"],function(e){return r(function(n,r){e.register((n+"Curry").snake_case(),r)})}),n.curry("makeInjectable",function(){return r}),n.extend("run",["$injector"],function(e){var n=Array;return function(r,t){var c,o,i=0;if("function"===typeof r)t=r,o=[];else if("string"===typeof r)o=[e.resolve_sync(r)];else for(i=0,c=r.length,o=new n(c);i<c;++i)o[i]=e.resolve_sync(r[i]);return t.apply(this,o)}}),n.extend("namespace",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){for(var t,c,o=n.split("."),i=o.pop(),s=0,u=o.length,a="";s<u;++s)t=o[s],a&&(c=e.resolve_sync(a)),a=a?a+"."+t:t,e.has(a)||(e.register(a,{dependencies:[],resolve_once:!0,fn:function(){return{}}}),c&&(c[t]=e.resolve_sync(a)));e.register(n,r),a&&(c=e.resolve_sync(a),c[i]=e.resolve_sync(n))})}),n.extend("factory",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){e.register((n+"Factory").snake_case(),r)})}),n.extend("service",["$injector","make_injectable_curry"],function(e,n){return n(function(n,r){r.is_constructor=!0,e.register((n+"Service").snake_case(),r)})})};
/**
* jeefo_core : v0.0.6
* Author : je3f0o, <je3f0o@gmail.com>
* Homepage : https://github.com/je3f0o/jeefo_core
* License : The MIT license
* Copyright : undefined
**/
"use strict";
module.exports = function (jeefo) {
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : core.js
* Created at : 2017-04-08
* Updated at : 2017-05-03
* Author : jeefo
* Purpose :
* Description :
_._._._._._._._._._._._._._._._._._._._._.*/
var core_module = jeefo.module("jeefo_core", []);
var _transformer = {
CAMEL_CASE_REGEXP : /[A-Z]/g,
snake_replacer : function (letter, pos) {
return (pos ? '_' : '') + letter.toLowerCase();
},
dash_replacer : function (letter, pos) {
return (pos ? '-' : '') + letter.toLowerCase();
},
snake_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.snake_replacer);
},
dash_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.dash_replacer);
}
};
// TODO: move it into jeefo.js
core_module.extend("curry", ["$injector"], function ($injector) {
var make_injectable = function (factory) {
return function (name, dependencies, fn, resolve_once) {
if (typeof dependencies === "function") {
resolve_once = fn;
fn = dependencies;
dependencies = [];
} else if (typeof dependencies === "string") {
dependencies = [dependencies];
}
if (resolve_once === void 0) {
resolve_once = true;
}
return factory.call(this, name, {
fn : fn,
dependencies : dependencies,
resolve_once : resolve_once,
});
};
};
var t = _transformer;
var curry_maker = make_injectable(function (name, injectable) {
$injector.register(t.snake_case(name + "Curry"), injectable);
});
curry_maker("makeInjectable", function () {
return make_injectable;
});
return curry_maker;
});
core_module.extend("run", ["$injector"], function ($injector) {
var LocalArray = Array;
return function (dependencies, fn) {
if (typeof dependencies === "function") {
return dependencies.call(this);
} else if (typeof dependencies === "string") {
return fn.call(this, $injector.resolve_sync(dependencies));
}
for (var args = new LocalArray(dependencies.length), i = args.length - 1; i >= 0; --i) {
args[i] = $injector.resolve_sync(dependencies[i]);
}
return fn.apply(this, args);
};
});
core_module.extend("namespace", ["$injector", "make_injectable_curry"], function (injector, make_injectable_curry) {
var Empty = function () {};
var object_maker = function () {
return new Empty();
};
var namespace_maker = make_injectable_curry(function (full_name, injectable) {
var namespaces = full_name.split('.'),
name = namespaces.pop(),
i = 0, namespace = '', part, container;
for (; i < namespaces.length; ++i) {
part = namespaces[i];
if (namespace) {
container = injector.resolve_sync(namespace);
}
namespace = namespace ? namespace + '.' + part : part;
if (! injector.has(namespace)) {
injector.register(namespace, {
fn : object_maker,
dependencies : [],
resolve_once : true,
});
if (container) {
container[part] = injector.resolve_sync(namespace);
}
}
}
injector.register(full_name, injectable);
if (namespace) {
container = injector.resolve_sync(namespace);
container[name] = injector.resolve_sync(full_name);
}
});
var local_transformer = _transformer;
namespace_maker("transform.dash_case", function () {
return function (str) {
return local_transformer.dash_case(str);
};
});
namespace_maker("transform.snake_case", function () {
return function (str) {
return local_transformer.snake_case(str);
};
});
return namespace_maker;
});
core_module.extend("factory", [
"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injector.register(snake_case(name + "Factory"), injectable);
});
});
core_module.extend("service", [
"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injectable.is_constructor = true;
injector.register(snake_case(name + "Service"), injectable);
});
});
return jeefo;
};
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : index.js
* Created at : 2017-04-27
* Updated at : 2017-04-27
* Updated at : 2017-05-03
* Author : jeefo

@@ -18,7 +18,4 @@ * Purpose :

var jeefo = require("jeefo"),
_package = require("./package");
var _package = require("./package");
require(`./dist/${ _package.name }.node`)(jeefo);
module.exports = jeefo.module(_package.name);
module.exports = require(`./dist/${ _package.name }.node.min`);
{
"name": "jeefo_core",
"version": "0.0.4",
"version": "0.0.6",
"homepage": "https://github.com/je3f0o/jeefo_core",
"description": "jeefo core",
"author": "je3f0o <je3f0o@gmail.com>",
"author": {
"name": "je3f0o",
"email": "je3f0o@gmail.com"
},
"license": "MIT",

@@ -18,4 +21,3 @@ "main": "index.js",

"jeefo",
"token",
"tokenizer"
"core"
],

@@ -22,0 +24,0 @@ "devDependencies": {

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : core.js
* Created at : 2017-04-08
* Updated at : 2017-04-27
* Updated at : 2017-05-03
* Author : jeefo

@@ -14,78 +14,75 @@ * Purpose :

/* global */
/* globals IS_FUNCTION, IS_STRING, IS_UNDEFINED */
/* exported */
/* exported */
//ignore:end
var core_module = jeefo.module("jeefo_core", []),
var core_module = jeefo.module("jeefo_core", []);
var _transformer = {
CAMEL_CASE_REGEXP : /[A-Z]/g,
snake_replacer : function (letter, pos) {
return (pos ? '_' : '') + letter.toLowerCase();
},
dash_replacer : function (letter, pos) {
return (pos ? '-' : '') + letter.toLowerCase();
},
snake_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.snake_replacer);
},
dash_case : function (str) {
return str.replace(this.CAMEL_CASE_REGEXP, this.dash_replacer);
}
};
// TODO: move it into jeefo.js
make_injectable = function (factory) {
return function (name, dependencies, fn, resolve_once) {
if (typeof dependencies === "function") {
resolve_once = fn;
fn = dependencies;
dependencies = [];
} else if (typeof dependencies === "string") {
dependencies = [dependencies];
}
core_module.extend("curry", ["$injector"], function ($injector) {
if (resolve_once === void 0) {
resolve_once = true;
}
var make_injectable = function (factory) {
return function (name, dependencies, fn, resolve_once) {
if (IS_FUNCTION(dependencies)) {
resolve_once = fn;
fn = dependencies;
dependencies = [];
} else if (IS_STRING(dependencies)) {
dependencies = [dependencies];
}
return factory.call(this, name, {
fn : fn,
dependencies : dependencies,
resolve_once : resolve_once,
});
};
};
if (IS_UNDEFINED(resolve_once)) {
resolve_once = true;
}
var CAMEL_CASE_REGEXP = /[A-Z]/g;
var make_case_changer = function (separator) {
var LOCAL_REGEXP = CAMEL_CASE_REGEXP;
var changer = function (letter, pos) {
return (pos ? separator : '') + letter.toLowerCase();
return factory.call(this, name, {
fn : fn,
dependencies : dependencies,
resolve_once : resolve_once,
});
};
};
return function () {
return this.replace(LOCAL_REGEXP, changer);
};
};
var t = _transformer;
var curry_maker = make_injectable(function (name, injectable) {
$injector.register(t.snake_case(`${ name }Curry`), injectable);
});
String.prototype.dash_case = make_case_changer('-');
String.prototype.snake_case = make_case_changer('_');
curry_maker("makeInjectable", function () {
return make_injectable;
});
core_module.extend("curry", ["$injector"], function ($injector) {
// Local references
var make_injectable_local = make_injectable;
return make_injectable_local(function (name, injectable) {
$injector.register((name + "Curry").snake_case(), injectable);
});
return curry_maker;
});
// TODO: move it into jeefo.js
core_module.curry("makeInjectable", function () { return make_injectable; });
core_module.extend("run", ["$injector"], function ($injector) {
var LocalArray = Array;
return function (dependencies, fn) {
var i = 0, len, args;
if (typeof dependencies === "function") {
fn = dependencies;
args = [];
} else if (typeof dependencies === "string") {
args = [$injector.resolve_sync(dependencies)];
} else {
i = 0;
len = dependencies.length;
args = new LocalArray(len);
for (; i < len; ++i) {
args[i] = $injector.resolve_sync(dependencies[i]);
}
if (IS_FUNCTION(dependencies)) {
return dependencies.call(this);
} else if (IS_STRING(dependencies)) {
return fn.call(this, $injector.resolve_sync(dependencies));
}
for (var args = new LocalArray(dependencies.length), i = args.length - 1; i >= 0; --i) {
args[i] = $injector.resolve_sync(dependencies[i]);
}
return fn.apply(this, args);

@@ -96,9 +93,13 @@ };

core_module.extend("namespace", ["$injector", "make_injectable_curry"], function (injector, make_injectable_curry) {
return make_injectable_curry(function (full_name, injectable) {
var Empty = function () {};
var object_maker = function () {
return new Empty();
};
var namespace_maker = make_injectable_curry(function (full_name, injectable) {
var namespaces = full_name.split('.'),
name = namespaces.pop(),
i = 0, len = namespaces.length,
namespace = '', part, container;
i = 0, namespace = '', part, container;
for (; i < len; ++i) {
for (; i < namespaces.length; ++i) {
part = namespaces[i];

@@ -110,9 +111,9 @@

namespace = namespace ? (namespace + '.' + part) : part;
namespace = namespace ? `${ namespace }.${ part }` : part;
if (! injector.has(namespace)) {
injector.register(namespace, {
fn : object_maker,
dependencies : [],
resolve_once : true,
fn : function () { return {}; }
});

@@ -133,2 +134,16 @@

});
var local_transformer = _transformer;
namespace_maker("transform.dash_case", function () {
return function (str) {
return local_transformer.dash_case(str);
};
});
namespace_maker("transform.snake_case", function () {
return function (str) {
return local_transformer.snake_case(str);
};
});
return namespace_maker;
});

@@ -138,6 +153,7 @@

"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, make_injectable_curry) {
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injector.register((name + "Factory").snake_case(), injectable);
injector.register(snake_case(`${ name }Factory`), injectable);
});

@@ -148,8 +164,9 @@ });

"$injector",
"transform.snake_case",
"make_injectable_curry",
], function (injector, make_injectable_curry) {
], function (injector, snake_case, make_injectable_curry) {
return make_injectable_curry(function (name, injectable) {
injectable.is_constructor = true;
injector.register((name + "Service").snake_case(), injectable);
injector.register(snake_case(`${ name }Service`), injectable);
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc