Skip to content

Commit

Permalink
[minor] replace deprecated __proto__ usage
Browse files Browse the repository at this point in the history
  • Loading branch information
calvintwr committed Jun 6, 2020
1 parent 616ad65 commit 8f5d10d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions dist/not.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Not = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/*!
* You-Are-Not v0.5.2
* You-Are-Not v0.5.3
* (c) 2020 Calvin Tan
* Released under the MIT License.
*/
Expand Down Expand Up @@ -373,7 +373,7 @@ You.walkObject = function (name, expectObject, gotObject, returnPayload) {
You.defineType = function (payload) {
var _this3 = this;

var sanitised = this.__proto__.checkObject('defineType', {
var sanitised = Object.getPrototypeOf(this).checkObject('defineType', {
primitive: ['string', 'array'],
type: 'string',
pass: ['function', 'optional']
Expand Down Expand Up @@ -419,20 +419,20 @@ You.createIs = function (options) {
return you.are.bind(you);
};

You._applyOptions = function (instance, options) {
You._applyOptions = function (descendant, options) {
var _this4 = this;

//using #_are because it's not writable and configurable
if (this._are('object', options)) {
if (this._are('boolean', options.willThrowError)) instance.willThrowError = options.willThrowError;
if (this._are('boolean', options.willThrowError)) descendant.willThrowError = options.willThrowError;

if (this._are('boolean', options.isOpinionated)) {
instance.isOpinionated = options.isOpinionated;
descendant.isOpinionated = options.isOpinionated;
return;
}

this._opinions.forEach(function (optionKey) {
if (_this4._are('boolean', options[optionKey])) instance[optionKey] = options[optionKey];
if (_this4._are('boolean', options[optionKey])) descendant[optionKey] = options[optionKey];
});
}
}; //Aggregators, or default non-primitive checks
Expand Down
2 changes: 1 addition & 1 deletion dist/not.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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "you-are-not",
"version": "0.5.2",
"version": "0.5.3",
"description": "Write accurate code. Meet deadlines. Maintain type flexibility. No compiling. A minimal, blazing fast, intuitive, and customisable type-checking helper that you are missing.",
"main": "index.js",
"browser": "dist/not.min.js",
Expand Down
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* You-Are-Not v0.5.2
* You-Are-Not v0.5.3
* (c) 2020 Calvin Tan
* Released under the MIT License.
*/
Expand Down Expand Up @@ -361,7 +361,7 @@ You.walkObject = function (name, expectObject, gotObject, returnPayload) {
}

You.defineType = function(payload) {
let sanitised = this.__proto__.checkObject('defineType', {
let sanitised = Object.getPrototypeOf(this).checkObject('defineType', {
primitive: ['string', 'array'],
type: 'string',
pass: ['function', 'optional']
Expand Down Expand Up @@ -397,17 +397,17 @@ You.createIs = function(options) {
return you.are.bind(you)
}

You._applyOptions = function (instance, options) {
You._applyOptions = function (descendant, options) {
//using #_are because it's not writable and configurable
if(this._are('object', options)) {
if(this._are('boolean', options.willThrowError)) instance.willThrowError = options.willThrowError
if(this._are('boolean', options.willThrowError)) descendant.willThrowError = options.willThrowError
if(this._are('boolean', options.isOpinionated)) {
instance.isOpinionated = options.isOpinionated
descendant.isOpinionated = options.isOpinionated
return
}

this._opinions.forEach(optionKey => {
if (this._are('boolean', options[optionKey])) instance[optionKey] = options[optionKey]
if (this._are('boolean', options[optionKey])) descendant[optionKey] = options[optionKey]
})
}
}
Expand Down

0 comments on commit 8f5d10d

Please sign in to comment.