údržba
This commit is contained in:
		
							
								
								
									
										22
									
								
								CyLukTs/lukan/node_modules/lazy-ass/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								CyLukTs/lukan/node_modules/lazy-ass/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
Copyright (c) 2014 Gleb Bahmutov
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										269
									
								
								CyLukTs/lukan/node_modules/lazy-ass/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										269
									
								
								CyLukTs/lukan/node_modules/lazy-ass/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,269 @@
 | 
			
		||||
# lazy-ass
 | 
			
		||||
 | 
			
		||||
> Lazy assertions without performance penalty
 | 
			
		||||
 | 
			
		||||
[![NPM][lazy-ass-icon] ][lazy-ass-url]
 | 
			
		||||
 | 
			
		||||
[![Build status][lazy-ass-ci-image] ][lazy-ass-ci-url]
 | 
			
		||||
[](https://github.com/bahmutov/manpm)
 | 
			
		||||
[![dependencies][lazy-ass-dependencies-image] ][lazy-ass-dependencies-url]
 | 
			
		||||
[![devdependencies][lazy-ass-devdependencies-image] ][lazy-ass-devdependencies-url]
 | 
			
		||||
 | 
			
		||||
[![semantic-release][semantic-image] ][semantic-url]
 | 
			
		||||
[![Coverage Status][lazy-ass-coverage-image]][lazy-ass-coverage-url]
 | 
			
		||||
[![Codacy][lazy-ass-codacy-image]][lazy-ass-codacy-url]
 | 
			
		||||
[![Code Climate][lazy-ass-code-climate-image]][lazy-ass-code-climate-url]
 | 
			
		||||
 | 
			
		||||
[Demo](http://glebbahmutov.com/lazy-ass/)
 | 
			
		||||
 | 
			
		||||
Is the current code breaking dependencies if released?
 | 
			
		||||
[![Dont-break][circle-ci-image] ][circle-ci-url] - checks using
 | 
			
		||||
[dont-break](https://github.com/bahmutov/dont-break)
 | 
			
		||||
[circle-ci-image]: https://circleci.com/gh/bahmutov/lazy-ass.svg?style=svg
 | 
			
		||||
[circle-ci-url]: https://circleci.com/gh/bahmutov/lazy-ass
 | 
			
		||||
 | 
			
		||||
## Example
 | 
			
		||||
 | 
			
		||||
Regular assertions evaluate all arguments and concatenate message
 | 
			
		||||
EVERY time, even if the condition is true.
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
console.assert(typeof foo === 'object',
 | 
			
		||||
  'expected ' + JSON.stringify(foo, null, 2) + ' to be an object');
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Lazy assertion function evaluates its arguments and forms
 | 
			
		||||
a message ONLY IF the condition is false
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
lazyAss(typeof foo === 'object', 'expected', foo, 'to be an object');
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Concatenates strings, stringifies objects, calls functions - only if
 | 
			
		||||
condition is false.
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
function environment() {
 | 
			
		||||
  // returns string
 | 
			
		||||
}
 | 
			
		||||
var user = {} // an object
 | 
			
		||||
lazyAsync(condition, 'something went wrong for', user, 'in', environment);
 | 
			
		||||
// throws an error with message equivalent of
 | 
			
		||||
// 'something went wrong for ' + JSON.stringify(user) + ' in ' + environment()
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Why?
 | 
			
		||||
 | 
			
		||||
* Passing an object reference to a function is about
 | 
			
		||||
[2000-3000 times faster](http://jsperf.com/object-json-stringify)
 | 
			
		||||
than serializing an object and passing it as a string.
 | 
			
		||||
* Concatenating 2 strings before passing to a function is about
 | 
			
		||||
[30% slower](http://jsperf.com/string-concat-vs-pass-string-reference)
 | 
			
		||||
than passing 2 separate strings.
 | 
			
		||||
 | 
			
		||||
## Install
 | 
			
		||||
 | 
			
		||||
Node: `npm install lazy-ass --save` then `var la = require('lazy-ass');`.
 | 
			
		||||
You can attach the methods to the global object using
 | 
			
		||||
`require('lazy-ass').globalRegister();`.
 | 
			
		||||
 | 
			
		||||
Browser: `bower install lazy-ass --save`, include `index.js`,
 | 
			
		||||
attaches functions `lazyAss` and `la` to `window` object.
 | 
			
		||||
 | 
			
		||||
## Notes
 | 
			
		||||
 | 
			
		||||
You can pass as many arguments to *lazyAss* after the condition. The condition
 | 
			
		||||
will be evaluated every time (this is required for any assertion). The rest of arguments
 | 
			
		||||
will be concatenated according to rules
 | 
			
		||||
 | 
			
		||||
* string will be left unchanged.
 | 
			
		||||
* function will be called and its output will be concatenated.
 | 
			
		||||
* any array or object will be JSON stringified.
 | 
			
		||||
 | 
			
		||||
There will be single space between the individual parts.
 | 
			
		||||
 | 
			
		||||
## Lazy async assertions
 | 
			
		||||
 | 
			
		||||
Sometimes you do not want to throw an error synchronously, breaking the entire
 | 
			
		||||
execution stack. Instead you can throw an error asynchronously using `lazyAssync`,
 | 
			
		||||
which internally implements logic like this:
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
if (!condition) {
 | 
			
		||||
  setTimeout(function () {
 | 
			
		||||
    throw new Error('Conditions is false!');
 | 
			
		||||
  }, 0);
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This allows the execution to continue, while your global error handler (like
 | 
			
		||||
my favorite [Sentry](http://glebbahmutov.com/blog/know-unknown-unknowns-with-sentry/))
 | 
			
		||||
can still forward the error with all specified information to your server.
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
lazyAss.async(false, 'foo');
 | 
			
		||||
console.log('after assync');
 | 
			
		||||
// output
 | 
			
		||||
after assync
 | 
			
		||||
Uncaught Error: foo
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
In this case, there is no meaningful error stack, so use good message
 | 
			
		||||
arguments - there is no performance penalty!
 | 
			
		||||
 | 
			
		||||
## Rethrowing errors
 | 
			
		||||
 | 
			
		||||
If the condition itself is an instance of Error, it is simply rethrown (synchronously or
 | 
			
		||||
asynchronously).
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
lazyAss(new Error('foo'));
 | 
			
		||||
// Uncaught Error: foo
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Useful to make sure errors in the promise chains are
 | 
			
		||||
[not silently ignored](https://glebbahmutov.com/blog/why-promises-need-to-be-done/).
 | 
			
		||||
 | 
			
		||||
For example, a rejected promise below this will be ignored.
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
var p = new Promise(function (resolve, reject) {
 | 
			
		||||
  reject(new Error('foo'));
 | 
			
		||||
});
 | 
			
		||||
p.then(...);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
We can catch it and rethrow it *synchronously*, but it will be ignored too (same way,
 | 
			
		||||
only one step further)
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
var p = new Promise(function (resolve, reject) {
 | 
			
		||||
  reject(new Error('foo'));
 | 
			
		||||
});
 | 
			
		||||
p.then(..., lazyAss);
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
But we can actually trigger global error if we rethrow the error *asynchronously*
 | 
			
		||||
 | 
			
		||||
```js
 | 
			
		||||
var p = new Promise(function (resolve, reject) {
 | 
			
		||||
  reject(new Error('foo'));
 | 
			
		||||
});
 | 
			
		||||
p.then(..., lazyAssync);
 | 
			
		||||
// Uncaught Error: foo
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Predicate function as a condition
 | 
			
		||||
 | 
			
		||||
Typically, JavaScript evaluates the condition expression first, then calls *lazyAss*.
 | 
			
		||||
This means the function itself sees only the true / false result, and not the expression
 | 
			
		||||
itself. This makes makes the error messages cryptic
 | 
			
		||||
 | 
			
		||||
    lazyAss(2 + 2 === 5);
 | 
			
		||||
    // Error
 | 
			
		||||
 | 
			
		||||
We usually get around this by giving at least one additional message argument to
 | 
			
		||||
explain the condition tested
 | 
			
		||||
 | 
			
		||||
    lazyAss(2 + 2 === 5, 'addition')
 | 
			
		||||
    // Error: addition
 | 
			
		||||
 | 
			
		||||
*lazyAss* has a better solution: if you give a function that evaluates the condition
 | 
			
		||||
expression, if the function returns false, the error message will include the source
 | 
			
		||||
of the function, making the extra arguments unnecessary
 | 
			
		||||
 | 
			
		||||
    lazyAss(function () { return 2 + 2 === 5; });
 | 
			
		||||
    // Error: function () { return 2 + 2 === 5; }
 | 
			
		||||
 | 
			
		||||
The condition function has access to any variables in the scope, making it extremely
 | 
			
		||||
powerful
 | 
			
		||||
 | 
			
		||||
    var foo = 2, bar = 2;
 | 
			
		||||
    lazyAss(function () { return foo + bar === 5; });
 | 
			
		||||
    // Error: function () { return foo + bar === 5; }
 | 
			
		||||
 | 
			
		||||
In practical terms, I recommend using separate predicates function and
 | 
			
		||||
passing relevant values to the *lazyAss* function. Remember, there is no performance
 | 
			
		||||
penalty!
 | 
			
		||||
 | 
			
		||||
    var foo = 2, bar = 2;
 | 
			
		||||
    function isValidPair() {
 | 
			
		||||
      return foo + bar === 5;
 | 
			
		||||
    }
 | 
			
		||||
    lazyAss(isValidPair, 'foo', foo, 'bar', bar);
 | 
			
		||||
    // Error: function isValidPair() {
 | 
			
		||||
    //   return foo + bar === 5;
 | 
			
		||||
    // } foo 2 bar 2
 | 
			
		||||
 | 
			
		||||
## Testing
 | 
			
		||||
 | 
			
		||||
This library is fully tested under Node and inside browser environment (CasperJs).
 | 
			
		||||
I described how one can test asynchronous assertion throwing in your own projects
 | 
			
		||||
using Jasmine in [a blog post](http://glebbahmutov.com/blog/testing-async-lazy-assertion/).
 | 
			
		||||
 | 
			
		||||
## TypeScript
 | 
			
		||||
 | 
			
		||||
If you use this function from a TypeScript project, we provide ambient type
 | 
			
		||||
definition file. Because this is CommonJS library, use it like this
 | 
			
		||||
 | 
			
		||||
```ts
 | 
			
		||||
import la = require('lazy-ass')
 | 
			
		||||
// la should have type signature
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Small print
 | 
			
		||||
 | 
			
		||||
Author: Gleb Bahmutov © 2014
 | 
			
		||||
 | 
			
		||||
* [@bahmutov](https://twitter.com/bahmutov)
 | 
			
		||||
* [glebbahmutov.com](http://glebbahmutov.com)
 | 
			
		||||
* [blog](http://glebbahmutov.com/blog)
 | 
			
		||||
 | 
			
		||||
License: MIT - do anything with the code, but don't blame me if it does not work.
 | 
			
		||||
 | 
			
		||||
Spread the word: tweet, star on github, etc.
 | 
			
		||||
 | 
			
		||||
Support: if you find any problems with this module, email / tweet /
 | 
			
		||||
[open issue](https://github.com/bahmutov/lazy-ass/issues) on Github
 | 
			
		||||
 | 
			
		||||
## MIT License
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2014 Gleb Bahmutov
 | 
			
		||||
 | 
			
		||||
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:
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
[lazy-ass-icon]: https://nodei.co/npm/lazy-ass.svg?downloads=true
 | 
			
		||||
[lazy-ass-url]: https://npmjs.org/package/lazy-ass
 | 
			
		||||
[lazy-ass-ci-image]: https://travis-ci.org/bahmutov/lazy-ass.svg?branch=master
 | 
			
		||||
[lazy-ass-ci-url]: https://travis-ci.org/bahmutov/lazy-ass
 | 
			
		||||
[lazy-ass-coverage-image]: https://coveralls.io/repos/bahmutov/lazy-ass/badge.svg
 | 
			
		||||
[lazy-ass-coverage-url]: https://coveralls.io/r/bahmutov/lazy-ass
 | 
			
		||||
[lazy-ass-code-climate-image]: https://codeclimate.com/github/bahmutov/lazy-ass/badges/gpa.svg
 | 
			
		||||
[lazy-ass-code-climate-url]: https://codeclimate.com/github/bahmutov/lazy-ass
 | 
			
		||||
[lazy-ass-codacy-image]: https://www.codacy.com/project/badge/b60a0810c9af4fe4b2ae685932dbbdb8
 | 
			
		||||
[lazy-ass-codacy-url]: https://www.codacy.com/public/bahmutov/lazy-ass.git
 | 
			
		||||
[lazy-ass-dependencies-image]: https://david-dm.org/bahmutov/lazy-ass.svg
 | 
			
		||||
[lazy-ass-dependencies-url]: https://david-dm.org/bahmutov/lazy-ass
 | 
			
		||||
[lazy-ass-devdependencies-image]: https://david-dm.org/bahmutov/lazy-ass/dev-status.svg
 | 
			
		||||
[lazy-ass-devdependencies-url]: https://david-dm.org/bahmutov/lazy-ass#info=devDependencies
 | 
			
		||||
[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
 | 
			
		||||
[semantic-url]: https://github.com/semantic-release/semantic-release
 | 
			
		||||
							
								
								
									
										30
									
								
								CyLukTs/lukan/node_modules/lazy-ass/bower.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								CyLukTs/lukan/node_modules/lazy-ass/bower.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "lazy-ass",
 | 
			
		||||
  "main": "index.js",
 | 
			
		||||
  "version": "0.0.0-semantic-release",
 | 
			
		||||
  "homepage": "https://github.com/bahmutov/lazy-ass",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "ignore": [
 | 
			
		||||
    "**/.*",
 | 
			
		||||
    "node_modules",
 | 
			
		||||
    "bower_components",
 | 
			
		||||
    "test",
 | 
			
		||||
    "tests",
 | 
			
		||||
    "Gruntfile.js",
 | 
			
		||||
    "package.json",
 | 
			
		||||
    "index.html"
 | 
			
		||||
  ],
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "assertion",
 | 
			
		||||
    "assertions",
 | 
			
		||||
    "browser",
 | 
			
		||||
    "debugging",
 | 
			
		||||
    "defensive",
 | 
			
		||||
    "lazy",
 | 
			
		||||
    "node"
 | 
			
		||||
  ],
 | 
			
		||||
  "authors": [
 | 
			
		||||
    "Gleb Bahmutov <gleb.bahmutov@gmail.com>"
 | 
			
		||||
  ],
 | 
			
		||||
  "description": "Lazy assertions without performance penalty"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.d.ts
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
declare function lazyAss(predicate: any, ...args:any[]): void;
 | 
			
		||||
export = lazyAss;
 | 
			
		||||
							
								
								
									
										52
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.html
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.html
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="utf-8">
 | 
			
		||||
    <title>lazy-ass</title>
 | 
			
		||||
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.3.1/es5-shim.js"></script>
 | 
			
		||||
    <script src="index.js"></script>
 | 
			
		||||
    <style>
 | 
			
		||||
      #log {
 | 
			
		||||
        margin: 10px 0px;
 | 
			
		||||
        display: block;
 | 
			
		||||
        white-space: pre;
 | 
			
		||||
        font-family: monospace;
 | 
			
		||||
      }
 | 
			
		||||
      #log:before {
 | 
			
		||||
        content: "the javascript:";
 | 
			
		||||
        font-style: italic;
 | 
			
		||||
        color: #555;
 | 
			
		||||
      }
 | 
			
		||||
    </style>
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <h1>lazy-ass</h1>
 | 
			
		||||
    <p>Simple assertions with as many arguments as needed and intelligent serialization</p>
 | 
			
		||||
 | 
			
		||||
    <script src="https://rawgit.com/bahmutov/console-log-div/master/console-log-div.js"></script>
 | 
			
		||||
 | 
			
		||||
    <script id="log">
 | 
			
		||||
      if (typeof lazyAss === 'undefined') {
 | 
			
		||||
        throw new Error('Cannot find lazyAss object');
 | 
			
		||||
      }
 | 
			
		||||
      console.log('Found lazyAss function');
 | 
			
		||||
      var foo = 3;
 | 
			
		||||
      lac(foo === 'foo', 'this is an async exception', foo);
 | 
			
		||||
      console.log('after async exception');
 | 
			
		||||
 | 
			
		||||
      // cannot be serialized to JSON due to circular reference
 | 
			
		||||
      var bar = {
 | 
			
		||||
        name: 'bar'
 | 
			
		||||
      };
 | 
			
		||||
      bar.bar = bar;
 | 
			
		||||
      lac(false, 'example printing a circular object', bar);
 | 
			
		||||
 | 
			
		||||
      lac(false, {foo: 'foo', bar: undefined},
 | 
			
		||||
        'this object has property "bar" with undefined value')
 | 
			
		||||
 | 
			
		||||
      la(typeof foo === 'string',
 | 
			
		||||
        'sync exception, variable foo is NOT a string, but', typeof foo, foo);
 | 
			
		||||
      // nothing runs after sync exception
 | 
			
		||||
    </script>
 | 
			
		||||
  </body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										169
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								CyLukTs/lukan/node_modules/lazy-ass/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,169 @@
 | 
			
		||||
(function initLazyAss() {
 | 
			
		||||
 | 
			
		||||
  function isArrayLike(a) {
 | 
			
		||||
    return a && typeof a.length === 'number';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function toStringArray(arr) {
 | 
			
		||||
    return 'array with ' + arr.length + ' items.\n[' +
 | 
			
		||||
      arr.map(toString).join(',') + ']\n';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function isPrimitive(arg) {
 | 
			
		||||
    return typeof arg === 'string' ||
 | 
			
		||||
      typeof arg === 'number' ||
 | 
			
		||||
      typeof arg === 'boolean';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function isError(e) {
 | 
			
		||||
    return e instanceof Error;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
    custom JSON.stringify replacer to make sure we do not
 | 
			
		||||
    hide properties that have value "undefined"
 | 
			
		||||
    var o = {
 | 
			
		||||
      foo: 42,
 | 
			
		||||
      bar: undefined
 | 
			
		||||
    }
 | 
			
		||||
    // standard JSON.stringify returns '{"foo": 42}'
 | 
			
		||||
    // this replacer returns '{"foo": 42, "bar": null}'
 | 
			
		||||
  */
 | 
			
		||||
  function replacer(key, value) {
 | 
			
		||||
    if (value === undefined) {
 | 
			
		||||
      return null;
 | 
			
		||||
    }
 | 
			
		||||
    return value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function toString(arg, k) {
 | 
			
		||||
    if (isPrimitive(arg)) {
 | 
			
		||||
      return JSON.stringify(arg);
 | 
			
		||||
    }
 | 
			
		||||
    if (arg instanceof Error) {
 | 
			
		||||
      return arg.name + ' ' + arg.message;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (Array.isArray(arg)) {
 | 
			
		||||
      return toStringArray(arg);
 | 
			
		||||
    }
 | 
			
		||||
    if (isArrayLike(arg)) {
 | 
			
		||||
      return toStringArray(Array.prototype.slice.call(arg, 0));
 | 
			
		||||
    }
 | 
			
		||||
    var argString;
 | 
			
		||||
    try {
 | 
			
		||||
      argString = JSON.stringify(arg, replacer, 2);
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      argString = '{ cannot stringify arg ' + k + ', it has type "' + typeof arg + '"';
 | 
			
		||||
      if (typeof arg === 'object') {
 | 
			
		||||
        argString += ' with keys ' + Object.keys(arg).join(', ') + ' }';
 | 
			
		||||
      } else {
 | 
			
		||||
        argString += ' }';
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return argString;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function endsWithNewLine(s) {
 | 
			
		||||
    return /\n$/.test(s);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function formMessage(args) {
 | 
			
		||||
    var msg = args.reduce(function (total, arg, k) {
 | 
			
		||||
      if (k && !endsWithNewLine(total)) {
 | 
			
		||||
        total += ' ';
 | 
			
		||||
      }
 | 
			
		||||
      if (typeof arg === 'string') {
 | 
			
		||||
        return total + arg;
 | 
			
		||||
      }
 | 
			
		||||
      if (typeof arg === 'function') {
 | 
			
		||||
        var fnResult;
 | 
			
		||||
        try {
 | 
			
		||||
          fnResult = arg();
 | 
			
		||||
        } catch (err) {
 | 
			
		||||
          // ignore the error
 | 
			
		||||
          fnResult = '[function ' + arg.name + ' threw error!]';
 | 
			
		||||
        }
 | 
			
		||||
        return total + fnResult;
 | 
			
		||||
      }
 | 
			
		||||
      var argString = toString(arg, k);
 | 
			
		||||
      return total + argString;
 | 
			
		||||
    }, '');
 | 
			
		||||
    return msg;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function lazyAssLogic(condition) {
 | 
			
		||||
    if (isError(condition)) {
 | 
			
		||||
      return condition;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var fn = typeof condition === 'function' ? condition : null;
 | 
			
		||||
 | 
			
		||||
    if (fn) {
 | 
			
		||||
      condition = fn();
 | 
			
		||||
    }
 | 
			
		||||
    if (!condition) {
 | 
			
		||||
      var args = [].slice.call(arguments, 1);
 | 
			
		||||
      if (fn) {
 | 
			
		||||
        args.unshift(fn.toString());
 | 
			
		||||
      }
 | 
			
		||||
      return new Error(formMessage(args));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  var lazyAss = function lazyAss() {
 | 
			
		||||
    var err = lazyAssLogic.apply(null, arguments);
 | 
			
		||||
    if (err) {
 | 
			
		||||
      throw err;
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  var lazyAssync = function lazyAssync() {
 | 
			
		||||
    var err = lazyAssLogic.apply(null, arguments);
 | 
			
		||||
    if (err) {
 | 
			
		||||
      setTimeout(function () {
 | 
			
		||||
        throw err;
 | 
			
		||||
      }, 0);
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  lazyAss.async = lazyAssync;
 | 
			
		||||
 | 
			
		||||
  function isNode() {
 | 
			
		||||
    return typeof global === 'object';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function isBrowser() {
 | 
			
		||||
    return typeof window === 'object';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function isCommonJS() {
 | 
			
		||||
    return typeof module === 'object';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function globalRegister() {
 | 
			
		||||
    if (isNode()) {
 | 
			
		||||
      /* global global */
 | 
			
		||||
      register(global, lazyAss, 'lazyAss', 'la');
 | 
			
		||||
      register(global, lazyAssync, 'lazyAssync', 'lac');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function register(root, value, name, alias) {
 | 
			
		||||
    root[name] = root[alias] = value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  lazyAss.globalRegister = globalRegister;
 | 
			
		||||
 | 
			
		||||
  if (isBrowser()) {
 | 
			
		||||
    /* global window */
 | 
			
		||||
    register(window, lazyAss, 'lazyAss', 'la');
 | 
			
		||||
    register(window, lazyAssync, 'lazyAssync', 'lac');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (isCommonJS()) {
 | 
			
		||||
    /* global module */
 | 
			
		||||
    module.exports = lazyAss;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}());
 | 
			
		||||
							
								
								
									
										113
									
								
								CyLukTs/lukan/node_modules/lazy-ass/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								CyLukTs/lukan/node_modules/lazy-ass/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "lazy-ass",
 | 
			
		||||
  "description": "Lazy assertions without performance penalty",
 | 
			
		||||
  "version": "1.6.0",
 | 
			
		||||
  "author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/bahmutov/lazy-ass/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "config": {
 | 
			
		||||
    "pre-git": {
 | 
			
		||||
      "commit-msg": "simple",
 | 
			
		||||
      "pre-commit": [
 | 
			
		||||
        "npm test"
 | 
			
		||||
      ],
 | 
			
		||||
      "pre-push": [
 | 
			
		||||
        "npm run size"
 | 
			
		||||
      ],
 | 
			
		||||
      "post-commit": [],
 | 
			
		||||
      "post-merge": []
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "contributors": [],
 | 
			
		||||
  "dependencies": {},
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@semantic-release/condition-travis": "4.1.4",
 | 
			
		||||
    "bad-line": "0.1.1",
 | 
			
		||||
    "condition-node-version": "1.2.0",
 | 
			
		||||
    "coveralls": "2.11.6",
 | 
			
		||||
    "expect.js": "0.3.1",
 | 
			
		||||
    "git-issues": "1.2.0",
 | 
			
		||||
    "grunt": "0.4.5",
 | 
			
		||||
    "grunt-banner": "0.6.0",
 | 
			
		||||
    "grunt-clean-console": "0.1.1",
 | 
			
		||||
    "grunt-cli": "1.0.0-rc1",
 | 
			
		||||
    "grunt-contrib-concat": "0.5.1",
 | 
			
		||||
    "grunt-contrib-copy": "0.8.2",
 | 
			
		||||
    "grunt-contrib-jshint": "1.0.0",
 | 
			
		||||
    "grunt-contrib-uglify": "0.11.1",
 | 
			
		||||
    "grunt-contrib-watch": "0.6.1",
 | 
			
		||||
    "grunt-deps-ok": "0.9.0",
 | 
			
		||||
    "grunt-gh-pages": "1.0.0",
 | 
			
		||||
    "grunt-karma": "0.10.1",
 | 
			
		||||
    "grunt-mocha-test": "0.12.7",
 | 
			
		||||
    "grunt-nice-package": "0.10.3",
 | 
			
		||||
    "grunt-npm2bower-sync": "0.9.1",
 | 
			
		||||
    "jshint-stylish": "2.1.0",
 | 
			
		||||
    "karma": "0.12.32",
 | 
			
		||||
    "karma-chrome-launcher": "0.2.2",
 | 
			
		||||
    "karma-coverage": "0.5.3",
 | 
			
		||||
    "karma-mocha": "0.2.2",
 | 
			
		||||
    "karma-phantomjs-launcher": "1.0.0",
 | 
			
		||||
    "matchdep": "1.0.1",
 | 
			
		||||
    "mocha": "2.4.5",
 | 
			
		||||
    "phantomjs": "2.1.3",
 | 
			
		||||
    "phantomjs-prebuilt": "2.1.12",
 | 
			
		||||
    "pkgfiles": "2.3.2",
 | 
			
		||||
    "pre-git": "3.4.0",
 | 
			
		||||
    "semantic-release": "6.3.6",
 | 
			
		||||
    "time-grunt": "1.4.0"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": "> 0.8"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "index.js",
 | 
			
		||||
    "index.html",
 | 
			
		||||
    "bower.json",
 | 
			
		||||
    "test/demo.js",
 | 
			
		||||
    "index.d.ts"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://github.com/bahmutov/lazy-ass",
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "assertion",
 | 
			
		||||
    "assertions",
 | 
			
		||||
    "browser",
 | 
			
		||||
    "debugging",
 | 
			
		||||
    "defensive",
 | 
			
		||||
    "lazy",
 | 
			
		||||
    "node"
 | 
			
		||||
  ],
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "main": "index.js",
 | 
			
		||||
  "release": {
 | 
			
		||||
    "verifyConditions": [
 | 
			
		||||
      {
 | 
			
		||||
        "path": "@semantic-release/condition-travis"
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        "path": "condition-node-version",
 | 
			
		||||
        "node": "4.2.2"
 | 
			
		||||
      }
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "https://github.com/bahmutov/lazy-ass.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "grunt",
 | 
			
		||||
    "commit": "git-issues && commit-wizard",
 | 
			
		||||
    "coveralls": "cat coverage/PhantomJS*/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
 | 
			
		||||
    "demo": "grunt gh-pages",
 | 
			
		||||
    "dont-break": "dont-break --timeout 30",
 | 
			
		||||
    "issues": "git-issues",
 | 
			
		||||
    "mocha": "mocha test/*.spec.js",
 | 
			
		||||
    "pkgfiles": "pkgfiles",
 | 
			
		||||
    "semantic-release": "semantic-release pre && npm publish && semantic-release post",
 | 
			
		||||
    "size": "tarball=\"$(npm pack .)\"; wc -c \"${tarball}\"; tar tvf \"${tarball}\"; rm \"${tarball}\";",
 | 
			
		||||
    "test": "grunt test",
 | 
			
		||||
    "watch": "grunt watch"
 | 
			
		||||
  },
 | 
			
		||||
  "types": "index.d.ts"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										5
									
								
								CyLukTs/lukan/node_modules/lazy-ass/test/demo.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								CyLukTs/lukan/node_modules/lazy-ass/test/demo.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
var lazyAss = require('..');
 | 
			
		||||
function bad(foo, bar) {
 | 
			
		||||
  lazyAss(false, 'this fails on purpose, foo =', foo, 'bar =', bar);
 | 
			
		||||
}
 | 
			
		||||
bad('foo', 'bar');
 | 
			
		||||
		Reference in New Issue
	
	Block a user