Commit 22804f87 authored by bsara's avatar bsara

updated dependencies, removed gulp, added rollup, ready to update build

parent 31f88e2e
{
"presets": [ "es2015" ]
}
.git/
.temp/
.tmp/
node_modules/
build/
dist/
reports/
temp/
tmp/
*cjs.*
*browser.*
......@@ -2,14 +2,36 @@
# Project Ignores #
#---------------------------------------#
/build/
/node_modules/
# compiled output
/.temp
/.tmp
/build
/dist
# dependencies
/node_modules
.package.swp
# linters
.eslintcache/
.eslintrc
.eslintrc.yaml
.eslintrc.json
.eslintrc.js
.stylelintcache/
.stylelintrc
.stylelintrc.yaml
.stylelintrc.json
.stylelintrc.js
# misc
/proto-proper-*.tgz
/connect.lock
/coverage/*
/report_*
/reports/
/temp/
/tmp/
.temp/
.tmp/
logs/
*.log
#---------------------------------------#
......@@ -18,9 +40,23 @@
# Sublime Text
/*.sublime*
.sublime-gulp.cache
# VS Code
/.vscode
# JetBrains IDEs
/.idea
.idea/
*.iml
# Eclipse
.project
.classpath
.settings
# Netbeans
nbactions*.xml
nb-configuration*.xml
#---------------------------------------#
......@@ -29,7 +65,7 @@
*~
*.orig
*.log
.vagrant
#---------------------------------------#
......@@ -81,4 +117,3 @@ Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
*.dmp
## [v1.0.0](https://github.com/bsara/proto-proper.js/tree/v1.0.0) (2017-02-24)
## [v1.0.0](https://gitlab.com/bsara/proto-proper/tree/v1.0.0) (2017-02-24)
- Initial release
ISC License (ISC)
Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)
Copyright (c) 2020 Brandon Sara (https://bsara.dev/)
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
......
# proto-proper.js [![NPM Package](https://img.shields.io/npm/v/proto-proper.svg?style=flat-square)][npm]
# proto-proper [![NPM Package](https://img.shields.io/npm/v/proto-proper.svg?style=flat-square)][npm]
[![ISC License](https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square)][license]
......@@ -224,7 +224,7 @@ $ gulp help
ISC License (ISC)
Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)
Copyright (c) 2020 Brandon Sara (https://bsara.dev/)
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
......
/**!
* proto-proper.js (1.0.1)
*
* ISC License (ISC)
*
* Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
return;
}
if (typeof exports === 'object') {
module.exports = factory(require, exports, module);
return;
}
root.Proto = factory(undefined, {}, undefined);
}(this, function(require, exports, module) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
// eslint-disable-next-line spaced-comment
/**
* A generic prototype upon which new prototypes can be based.
*
* This object contains functions useful for prototype creation, manipulation,
* inheritance, and for obtaining useful information about a prototype.
*
* @type {Object}
* @extends {Object.prototype}
*
*
* @example
* // Creating a New Prototype
*
* let MyObject = Proto.newPrototype();
*
* MyObject.init = function(options) { ... };
* MyObject.func0 = function() { ... };
*
*
* @example
* // Inheritance From a Custom Prototype
*
* let MyObject = Proto.newPrototype();
*
* MyObject.init = function(options) { ... };
* MyObject.func0 = function() { ... };
*
* let MyChildObject = MyObject.newPrototype();
*
* MyChildObject.init = function(options) { ... };
*
*
* @example
* // Object Instantiation
* let obj = MyObject.new( ... );
*/
var Proto = Object.create(Object.prototype);
Object.assign(Proto, {
/**
* TODO: Add description
* @returns TODO: Add description
*/
newPrototype: function newPrototype() {
return Object.create(this);
},
/**
* Creates a new instance of this prototype.
*
* This function is to be called **instead of** using the `new` keyword.
*
* Any arguments passed to this function will be used as the
* arguments for the call made to the `init` function.
*
* @example
* let obj = MyObject.new();
*
* @returns A newly created and initialized instance of this prototype.
*/
new: function _new() {
var newInstance = Object.create(this);
newInstance.init.apply(newInstance, arguments);
return newInstance;
},
/**
* Initializes object.
*
* This function is called whenever `new` is called and can be seen as
* the "constructor" of the prototype.
*/
init: function init() {
// Intentionally doing nothing
},
/**
* @param {Object} proto - TODO: Add description
*
* @example
* let Parent = Proto.newPrototype();
* let Child = Parent.newPrototype();
*
* let parentObj = Parent.new();
* let childObj = Child.new();
*
* Parent.instanceOf(Object); // returns `false`
* Child.instanceOf(Object); // returns `false`
*
* parentObj.instanceOf(Object); // returns `false`
* childObj.instanceOf(Object); // returns `false`
*
* Parent.instanceOf(Parent); // returns `true`
* Parent.instanceOf(Proto); // returns `true`
* Parent.instanceOf(Object.prototype); // returns `true`
*
* Child.instanceOf(Child); // returns `true`
* Child.instanceOf(Parent); // returns `true`
* Child.instanceOf(Proto); // returns `true`
* Child.instanceOf(Object.prototype); // returns `true`
*
* parentObj.instanceOf(parentObj); // returns `true`
* parentObj.instanceOf(Parent); // returns `true`
* parentObj.instanceOf(Proto); // returns `true`
* parentObj.instanceOf(Object.prototype); // returns `true`
*
* childObj.instanceOf(childObj); // returns `true`
* childObj.instanceOf(Child); // returns `true`
* childObj.instanceOf(Parent); // returns `true`
* childObj.instanceOf(Proto); // returns `true`
* childObj.instanceOf(Object.prototype); // returns `true`
*
* @returns {Boolean} `true` if the given `proto` is found in the prototype
* chain of this object; otherwise, returns `false`.
*/
instanceOf: function instanceOf(proto) {
if (proto === this || proto === Proto || proto === Object.prototype) {
return true;
}
var thisProto = Object.getPrototypeOf(this);
if (thisProto == null) {
return false;
}
return thisProto === proto || thisProto.instanceOf != null && thisProto.instanceOf(proto);
}
});
return exports.default = Proto;
}));
//# sourceMappingURL=proto-proper.es5.js.map
{"version":3,"sources":["proto-proper.js"],"names":["Proto","Object","create","prototype","assign","newPrototype","new","newInstance","init","arguments","instanceOf","proto","thisProto","getPrototypeOf"],"mappings":";;;;;AAAA;AACA;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,IAAIA,QAAQC,OAAOC,MAAP,CAAcD,OAAOE,SAArB,CAAZ;;AAIAF,OAAOG,MAAP,CAAcJ,KAAd,EAAqB;;AAEnB;;;;AAIAK,cANmB,0BAMJ;AACb,WAAOJ,OAAOC,MAAP,CAAc,IAAd,CAAP;AACD,GARkB;;;AAWnB;;;;;;;;;;;;;AAaAI,KAxBmB,kBAwBb;AACJ,QAAIC,cAAcN,OAAOC,MAAP,CAAc,IAAd,CAAlB;;AAEAK,gBAAYC,IAAZ,oBAAoBC,SAApB;;AAEA,WAAOF,WAAP;AACD,GA9BkB;;;AAkCnB;;;;;;AAMAC,MAxCmB,kBAwCZ;AACL;AACD,GA1CkB;;;AA6CnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCAE,YApFmB,sBAoFRC,KApFQ,EAoFD;AAChB,QAAIA,UAAU,IAAV,IAAkBA,UAAUX,KAA5B,IAAqCW,UAAUV,OAAOE,SAA1D,EAAqE;AACnE,aAAO,IAAP;AACD;;AAED,QAAIS,YAAYX,OAAOY,cAAP,CAAsB,IAAtB,CAAhB;;AAEA,QAAID,aAAa,IAAjB,EAAuB;AACrB,aAAO,KAAP;AACD;;AAED,WAAQA,cAAcD,KAAd,IACMC,UAAUF,UAAV,IAAwB,IAAxB,IAAgCE,UAAUF,UAAV,CAAqBC,KAArB,CAD9C;AAED;AAjGkB,CAArB;;kBAsGeX,K","file":"proto-proper.es5.js","sourcesContent":["// eslint-disable-next-line spaced-comment\n/**!\n * proto-proper.js (1.0.1)\n *\n * ISC License (ISC)\n *\n * Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n\n\n/**\n * A generic prototype upon which new prototypes can be based.\n *\n * This object contains functions useful for prototype creation, manipulation,\n * inheritance, and for obtaining useful information about a prototype.\n *\n * @type {Object}\n * @extends {Object.prototype}\n *\n *\n * @example\n * // Creating a New Prototype\n *\n * let MyObject = Proto.newPrototype();\n *\n * MyObject.init = function(options) { ... };\n * MyObject.func0 = function() { ... };\n *\n *\n * @example\n * // Inheritance From a Custom Prototype\n *\n * let MyObject = Proto.newPrototype();\n *\n * MyObject.init = function(options) { ... };\n * MyObject.func0 = function() { ... };\n *\n * let MyChildObject = MyObject.newPrototype();\n *\n * MyChildObject.init = function(options) { ... };\n *\n *\n * @example\n * // Object Instantiation\n * let obj = MyObject.new( ... );\n */\nlet Proto = Object.create(Object.prototype);\n\n\n\nObject.assign(Proto, {\n\n /**\n * TODO: Add description\n * @returns TODO: Add description\n */\n newPrototype() {\n return Object.create(this);\n },\n\n\n /**\n * Creates a new instance of this prototype.\n *\n * This function is to be called **instead of** using the `new` keyword.\n *\n * Any arguments passed to this function will be used as the\n * arguments for the call made to the `init` function.\n *\n * @example\n * let obj = MyObject.new();\n *\n * @returns A newly created and initialized instance of this prototype.\n */\n new() {\n let newInstance = Object.create(this);\n\n newInstance.init(...arguments);\n\n return newInstance;\n },\n\n\n\n /**\n * Initializes object.\n *\n * This function is called whenever `new` is called and can be seen as\n * the \"constructor\" of the prototype.\n */\n init() {\n // Intentionally doing nothing\n },\n\n\n /**\n * @param {Object} proto - TODO: Add description\n *\n * @example\n * let Parent = Proto.newPrototype();\n * let Child = Parent.newPrototype();\n *\n * let parentObj = Parent.new();\n * let childObj = Child.new();\n *\n * Parent.instanceOf(Object); // returns `false`\n * Child.instanceOf(Object); // returns `false`\n *\n * parentObj.instanceOf(Object); // returns `false`\n * childObj.instanceOf(Object); // returns `false`\n *\n * Parent.instanceOf(Parent); // returns `true`\n * Parent.instanceOf(Proto); // returns `true`\n * Parent.instanceOf(Object.prototype); // returns `true`\n *\n * Child.instanceOf(Child); // returns `true`\n * Child.instanceOf(Parent); // returns `true`\n * Child.instanceOf(Proto); // returns `true`\n * Child.instanceOf(Object.prototype); // returns `true`\n *\n * parentObj.instanceOf(parentObj); // returns `true`\n * parentObj.instanceOf(Parent); // returns `true`\n * parentObj.instanceOf(Proto); // returns `true`\n * parentObj.instanceOf(Object.prototype); // returns `true`\n *\n * childObj.instanceOf(childObj); // returns `true`\n * childObj.instanceOf(Child); // returns `true`\n * childObj.instanceOf(Parent); // returns `true`\n * childObj.instanceOf(Proto); // returns `true`\n * childObj.instanceOf(Object.prototype); // returns `true`\n *\n * @returns {Boolean} `true` if the given `proto` is found in the prototype\n * chain of this object; otherwise, returns `false`.\n */\n instanceOf(proto) {\n if (proto === this || proto === Proto || proto === Object.prototype) {\n return true;\n }\n\n let thisProto = Object.getPrototypeOf(this);\n\n if (thisProto == null) {\n return false;\n }\n\n return (thisProto === proto\n || (thisProto.instanceOf != null && thisProto.instanceOf(proto)));\n }\n});\n\n\n\nexport default Proto;\n"]}
\ No newline at end of file
/**!
* proto-proper.js (1.0.1)
* Copyright (c) 2017 Brandon Sara (http://bsara.github.io)
* Licensed under the ISC license (https://github.com/bsara/proto-proper.js/blob/master/LICENSE)
*/
!function(e,t){return"function"==typeof define&&define.amd?void define(t):"object"==typeof exports?void(module.exports=t(require,exports,module)):void(e.Proto=t(void 0,{},void 0))}(this,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=Object.create(Object.prototype);return Object.assign(i,{newPrototype:function(){return Object.create(this)},new:function(){var e=Object.create(this);return e.init.apply(e,arguments),e},init:function(){},instanceOf:function(e){if(e===this||e===i||e===Object.prototype)return!0;var t=Object.getPrototypeOf(this);return null!=t&&(t===e||null!=t.instanceOf&&t.instanceOf(e))}}),t.default=i});
//# sourceMappingURL=proto-proper.es5.min.js.map
{"version":3,"sources":["proto-proper.js"],"names":["Object","assign","Proto","newInstance","instanceOf","thisProto","proto","this","prototype"],"mappings":"oTA0EEA,QAAAC,OAAAC,+FA8BE,kCAAAC,qBAsDAC,WAAQC,SACMA,GACf,GAAAC,IAAAC,MAAAD,IAAAJ,GAAAI,IAAAN,OAAAQ,UAjGH,OAAA","file":"proto-proper.es5.min.js","sourcesContent":["// eslint-disable-next-line spaced-comment\n/**!\n * proto-proper.js (1.0.1)\n *\n * ISC License (ISC)\n *\n * Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n\n\n/**\n * A generic prototype upon which new prototypes can be based.\n *\n * This object contains functions useful for prototype creation, manipulation,\n * inheritance, and for obtaining useful information about a prototype.\n *\n * @type {Object}\n * @extends {Object.prototype}\n *\n *\n * @example\n * // Creating a New Prototype\n *\n * let MyObject = Proto.newPrototype();\n *\n * MyObject.init = function(options) { ... };\n * MyObject.func0 = function() { ... };\n *\n *\n * @example\n * // Inheritance From a Custom Prototype\n *\n * let MyObject = Proto.newPrototype();\n *\n * MyObject.init = function(options) { ... };\n * MyObject.func0 = function() { ... };\n *\n * let MyChildObject = MyObject.newPrototype();\n *\n * MyChildObject.init = function(options) { ... };\n *\n *\n * @example\n * // Object Instantiation\n * let obj = MyObject.new( ... );\n */\nlet Proto = Object.create(Object.prototype);\n\n\n\nObject.assign(Proto, {\n\n /**\n * TODO: Add description\n * @returns TODO: Add description\n */\n newPrototype() {\n return Object.create(this);\n },\n\n\n /**\n * Creates a new instance of this prototype.\n *\n * This function is to be called **instead of** using the `new` keyword.\n *\n * Any arguments passed to this function will be used as the\n * arguments for the call made to the `init` function.\n *\n * @example\n * let obj = MyObject.new();\n *\n * @returns A newly created and initialized instance of this prototype.\n */\n new() {\n let newInstance = Object.create(this);\n\n newInstance.init(...arguments);\n\n return newInstance;\n },\n\n\n\n /**\n * Initializes object.\n *\n * This function is called whenever `new` is called and can be seen as\n * the \"constructor\" of the prototype.\n */\n init() {\n // Intentionally doing nothing\n },\n\n\n /**\n * @param {Object} proto - TODO: Add description\n *\n * @example\n * let Parent = Proto.newPrototype();\n * let Child = Parent.newPrototype();\n *\n * let parentObj = Parent.new();\n * let childObj = Child.new();\n *\n * Parent.instanceOf(Object); // returns `false`\n * Child.instanceOf(Object); // returns `false`\n *\n * parentObj.instanceOf(Object); // returns `false`\n * childObj.instanceOf(Object); // returns `false`\n *\n * Parent.instanceOf(Parent); // returns `true`\n * Parent.instanceOf(Proto); // returns `true`\n * Parent.instanceOf(Object.prototype); // returns `true`\n *\n * Child.instanceOf(Child); // returns `true`\n * Child.instanceOf(Parent); // returns `true`\n * Child.instanceOf(Proto); // returns `true`\n * Child.instanceOf(Object.prototype); // returns `true`\n *\n * parentObj.instanceOf(parentObj); // returns `true`\n * parentObj.instanceOf(Parent); // returns `true`\n * parentObj.instanceOf(Proto); // returns `true`\n * parentObj.instanceOf(Object.prototype); // returns `true`\n *\n * childObj.instanceOf(childObj); // returns `true`\n * childObj.instanceOf(Child); // returns `true`\n * childObj.instanceOf(Parent); // returns `true`\n * childObj.instanceOf(Proto); // returns `true`\n * childObj.instanceOf(Object.prototype); // returns `true`\n *\n * @returns {Boolean} `true` if the given `proto` is found in the prototype\n * chain of this object; otherwise, returns `false`.\n */\n instanceOf(proto) {\n if (proto === this || proto === Proto || proto === Object.prototype) {\n return true;\n }\n\n let thisProto = Object.getPrototypeOf(this);\n\n if (thisProto == null) {\n return false;\n }\n\n return (thisProto === proto\n || (thisProto.instanceOf != null && thisProto.instanceOf(proto)));\n }\n});\n\n\n\nexport default Proto;\n"]}
\ No newline at end of file
// eslint-disable-next-line spaced-comment
/**!
* proto-proper.js (1.0.1)
*
* ISC License (ISC)
*
* Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* A generic prototype upon which new prototypes can be based.
*
* This object contains functions useful for prototype creation, manipulation,
* inheritance, and for obtaining useful information about a prototype.
*
* @type {Object}
* @extends {Object.prototype}
*
*
* @example
* // Creating a New Prototype
*
* let MyObject = Proto.newPrototype();
*
* MyObject.init = function(options) { ... };
* MyObject.func0 = function() { ... };
*
*
* @example
* // Inheritance From a Custom Prototype
*
* let MyObject = Proto.newPrototype();
*
* MyObject.init = function(options) { ... };
* MyObject.func0 = function() { ... };
*
* let MyChildObject = MyObject.newPrototype();
*
* MyChildObject.init = function(options) { ... };
*
*
* @example
* // Object Instantiation
* let obj = MyObject.new( ... );
*/
let Proto = Object.create(Object.prototype);
Object.assign(Proto, {
/**
* TODO: Add description
* @returns TODO: Add description
*/
newPrototype() {
return Object.create(this);
},
/**
* Creates a new instance of this prototype.
*
* This function is to be called **instead of** using the `new` keyword.
*
* Any arguments passed to this function will be used as the
* arguments for the call made to the `init` function.
*
* @example
* let obj = MyObject.new();
*
* @returns A newly created and initialized instance of this prototype.
*/
new() {
let newInstance = Object.create(this);
newInstance.init(...arguments);
return newInstance;
},
/**
* Initializes object.
*
* This function is called whenever `new` is called and can be seen as
* the "constructor" of the prototype.
*/
init() {
// Intentionally doing nothing
},
/**
* @param {Object} proto - TODO: Add description
*
* @example
* let Parent = Proto.newPrototype();
* let Child = Parent.newPrototype();
*
* let parentObj = Parent.new();
* let childObj = Child.new();
*
* Parent.instanceOf(Object); // returns `false`
* Child.instanceOf(Object); // returns `false`
*
* parentObj.instanceOf(Object); // returns `false`
* childObj.instanceOf(Object); // returns `false`
*
* Parent.instanceOf(Parent); // returns `true`
* Parent.instanceOf(Proto); // returns `true`
* Parent.instanceOf(Object.prototype); // returns `true`
*
* Child.instanceOf(Child); // returns `true`
* Child.instanceOf(Parent); // returns `true`
* Child.instanceOf(Proto); // returns `true`
* Child.instanceOf(Object.prototype); // returns `true`
*
* parentObj.instanceOf(parentObj); // returns `true`
* parentObj.instanceOf(Parent); // returns `true`
* parentObj.instanceOf(Proto); // returns `true`
* parentObj.instanceOf(Object.prototype); // returns `true`
*
* childObj.instanceOf(childObj); // returns `true`
* childObj.instanceOf(Child); // returns `true`
* childObj.instanceOf(Parent); // returns `true`
* childObj.instanceOf(Proto); // returns `true`
* childObj.instanceOf(Object.prototype); // returns `true`
*
* @returns {Boolean} `true` if the given `proto` is found in the prototype
* chain of this object; otherwise, returns `false`.
*/
instanceOf(proto) {
if (proto === this || proto === Proto || proto === Object.prototype) {
return true;
}
let thisProto = Object.getPrototypeOf(this);
if (thisProto == null) {
return false;
}
return (thisProto === proto
|| (thisProto.instanceOf != null && thisProto.instanceOf(proto)));
}
});
export default Proto;
/* eslint-env node */
/* eslint no-console: 'off' */
/*
* ISC License (ISC)
*
* Copyright (c) 2017 Brandon Sara (http://bsara.github.io/)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
const gulp = require('gulp');
const babel = require('gulp-babel');
const del = require('del');
const escapeRegex = require('escape-string-regexp');
const ignore = require('gulp-ignore');
const insert = require('gulp-insert');
const eslint = require('gulp-eslint');
const path = require('path');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const runSequence = require('run-sequence');
const sourcemaps = require('gulp-sourcemaps');
const uglifyHarmony = require('uglify-js-harmony');
const uglifyMinifier = require('gulp-uglify/minifier');
const util = require('gulp-util');
// ------------------------- //
// String Extensions //
// ------------------------- //
String.EMPTY = '';
String.SPACE = ' ';
// ------------------------- //
// Configuration //
// ------------------------- //
const config = {
pkg: require('./package.json'),
isDist: false,
build: { dir: 'build' },
dist: { dir: 'dist' },
src: { dir: 'src' },
test: { dir: 'test' }
};
config.partialFullLicenseComment =
`
* ISC License (ISC)
*
* Copyright (c) ${(new Date()).getFullYear()} Brandon Sara (http://bsara.github.io/)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
`;
config.oldFullFileHeader = `/**!${config.partialFullLicenseComment}`;
config.newFullFileHeader =
`/**!
* ${config.pkg.name}.js (${config.pkg.version})
*${config.partialFullLicenseComment}`;
config.minifiedFileHeader =
`/**!
* ${config.pkg.name}.js (${config.pkg.version})
* Copyright (c) ${(new Date()).getFullYear()} Brandon Sara (http://bsara.github.io)
* Licensed under the ISC license (https://github.com/${config.pkg.repository}/blob/master/LICENSE)
*/
`;
config.umdHeader =
`;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
return;
}
if (typeof exports === 'object') {
module.exports = factory(require, exports, module);
return;
}
root.Proto = factory(undefined, {}, undefined);
}(this, function(require, exports, module) {
`;
config.umdFooter = '\n}));\n';
// ------------------------- //
// Helpers //
// ------------------------- //
function onError(err) {
let msg = String.EMPTY;
if (err.fileName != null) {
msg = `ERROR IN ${err.fileName}`;
if (err.lineNumber != null) {
msg += ` (line number: ${err.lineNumber})`;
}
msg += ':\n ';
}
if (err.message != null) {
msg += err.message;
} else if (typeof err === 'string') {
msg = err;
}
util.log(util.colors.red(msg));
}
// ------------------------- //
// Tasks //
// ------------------------- //
gulp.task('default', [ 'help' ]);
gulp.task('help', function() {
const header = util.colors.bold.blue;
const task = util.colors.green;
console.log(String.EMPTY);
console.log(header(`${config.pkg.name}.js Gulp Tasks`));
console.log(header(`------------------------------------------------------------------------------`));
console.log(` ${task("help")} (${util.colors.yellow("default")}) - Displays this message.`);
console.log(String.EMPTY);
console.log(` ${task("build")} - Builds the project.`);
console.log(` ${task("rebuild")} - Cleans the build folder, then builds the project.`);
console.log(` ${task("dist")} - Performs all needed tasks to prepare the built project`);
console.log(` for a new release.`);
console.log(String.EMPTY);
console.log(` ${task("clean")} - Runs all available cleaning tasks in parallel.`);
console.log(` ${task("clean:build")} - Cleans the build output directory.`);
console.log(` ${task("clean:dist")} - Cleans the distribution output directory.`);
console.log(String.EMPTY);
console.log(` ${task("lint")} - Runs all available linting tasks in parallel.`);
console.log(String.EMPTY);
});
// Build Tasks
// ----------------
gulp.task('build', function() {
return gulp.src(path.join(config.src.dir, '**/*.js'))
.pipe(replace(new RegExp(escapeRegex(config.oldFullFileHeader), 'g'), config.newFullFileHeader))
.pipe(gulp.dest(config.build.dir))
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(replace(new RegExp(escapeRegex(config.newFullFileHeader), 'g'), String.EMPTY))
.pipe(rename({ suffix: '.es5' }))
.pipe(replace(/exports\.default\s=/g, "return exports.default ="))
.pipe(insert.prepend(config.umdHeader))
.pipe(insert.append(config.umdFooter))
.pipe(insert.prepend(config.newFullFileHeader))
.pipe(sourcemaps.write('.', { sourceRoot: null }))
.pipe(gulp.dest(config.build.dir))
.pipe(ignore.exclude('*.map'))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglifyMinifier({ verbose: true, mangle: true }, uglifyHarmony)).on('error', onError)
.pipe(insert.prepend(config.minifiedFileHeader))
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.', { sourceRoot: null }))
.pipe(gulp.dest(config.build.dir));
});
gulp.task('rebuild', function(callback) {
return runSequence('clean:build', 'build', callback);
});
gulp.task('dist', function(callback) {
config.isDist = true;
return runSequence('lint', 'test', 'clean:dist', function(err) {
if (err) {
callback(err);
return;
}
gulp.src(path.join(config.build.dir, '**/*'))
.pipe(gulp.dest(config.dist.dir));
callback();
});
});
// Test Tasks
// ----------------
gulp.task('test', [ 'rebuild' ], function() {
util.log(util.colors.yellow.bold("Tests not yet implemented!"));
});
// Clean Tasks
// ----------------
gulp.task('clean', [ 'clean:build', 'clean:dist' ]);
gulp.task('clean:build', () => del(config.build.dir));
gulp.task('clean:dist', () => del(config.dist.dir));
// Lint Tasks
// ----------------