Skip to content

Commit

Permalink
import syntax, checkObject bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
calvintwr committed Jun 20, 2020
1 parent 8f5d10d commit 3ef1e86
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 95 deletions.
23 changes: 14 additions & 9 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.3
* You-Are-Not v0.6.0
* (c) 2020 Calvin Tan
* Released under the MIT License.
*/
Expand Down Expand Up @@ -127,9 +127,7 @@ You.prepareExpect = function (expect) {
if (typeof expect === 'string') {
expect = [expect];
} else if (!Array.isArray(expect)) {
console.log(expect);
var x = TypeError("Internal error: Say what you expect to check as a string or array of strings. Found ".concat(this.list(this.type(expect), 'as'), "."));
console.log(x.stack);
throw x;
} //return expect

Expand Down Expand Up @@ -242,6 +240,7 @@ You.type = function (got) {
};

You.lodge = function (expect, got, name, note) {
if (this === You) throw Error('You cannot use #lodge on the Not prototype directly. Use Object.create(Not).');
if (!this._lodged) this._lodged = [];
var lodge = false; // don't let lodge error

Expand All @@ -257,6 +256,7 @@ You.lodge = function (expect, got, name, note) {

You.resolve = function (callback, returnedPayload) {
if (this._lodged === undefined || this._lodged.length === 0) {
console.log(this._lodged);
return typeof callback === 'function' ? callback(false, returnedPayload) : false;
}

Expand All @@ -281,16 +281,19 @@ You.checkObject = function (name, expectObject, gotObject, callback) {

if (typeof callback === 'function') {
not.walkObject(name, expectObject, gotObject);
return not.resolve(callback);
return not.resolve(callback, null); // null to specify no payload
}

if (_typeof(callback) === 'object') {
var returnedPayload = null;
var returnedPayload = null; // walk payload

if (callback.returnPayload === true) {
returnedPayload = not.walkObject(name, expectObject, gotObject, true);
if (returnedPayload === '$$empty$$') returnedPayload = {};
}
if (returnedPayload === '$$empty$$') returnedPayload = null;
} else {
not.walkObject(name, expectObject, gotObject);
} // set callback


if (typeof callback.callback === 'function') {
callback = callback.callback;
Expand Down Expand Up @@ -441,8 +444,10 @@ You._applyOptions = function (descendant, options) {
You.$$custom_optional = {
primitive: ['null', 'undefined']
};
module.exports = Object.create(You);
exports = module.exports;
var NotWontThrow = Object.create(You);
NotWontThrow.willThrowError = false;
You.NotWontThrow = NotWontThrow;
exports = module.exports = You; //exports.Not = You

},{}]},{},[1])(1)
});
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.

3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
'use strict'
const You = require('./src/index.js')
module.exports = You
module.exports = require('./src/index.js')
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.3",
"version": "0.6.0",
"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
Loading

0 comments on commit 3ef1e86

Please sign in to comment.