{"id":18429433,"url":"https://github.com/bigpipe/assume","last_synced_at":"2025-10-28T05:04:23.937Z","repository":{"id":16337911,"uuid":"19087614","full_name":"bigpipe/assume","owner":"bigpipe","description":"Expect-like assertions that works seamlessly in node and browsers","archived":false,"fork":false,"pushed_at":"2020-11-24T23:40:54.000Z","size":262,"stargazers_count":46,"open_issues_count":4,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-29T08:18:50.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://assume.fail","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigpipe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-23T22:21:24.000Z","updated_at":"2024-12-20T04:50:09.000Z","dependencies_parsed_at":"2022-09-03T19:00:16.918Z","dependency_job_id":null,"html_url":"https://github.com/bigpipe/assume","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/bigpipe/assume","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Fassume","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Fassume/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Fassume/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Fassume/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigpipe","download_url":"https://codeload.github.com/bigpipe/assume/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Fassume/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265481793,"owners_count":23773955,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:17:10.939Z","updated_at":"2025-10-28T05:04:18.903Z","avatar_url":"https://github.com/bigpipe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# assume\n\n[![Version npm][version]](http://browsenpm.org/package/assume)[![Build Status][build]](https://travis-ci.org/bigpipe/assume)[![Dependencies][david]](https://david-dm.org/bigpipe/assume)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/assume?branch=master)\n\n[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square\n[version]: http://img.shields.io/npm/v/assume.svg?style=flat-square\n[build]: http://img.shields.io/travis/bigpipe/assume/master.svg?style=flat-square\n[david]: https://img.shields.io/david/bigpipe/assume.svg?style=flat-square\n[cover]: http://img.shields.io/coveralls/bigpipe/assume/master.svg?style=flat-square\n\nAssume is an `expect` inspired assertion library who's sole purpose is to create\na working and human readable assert library for browsers and node. The library\nis designed to work with different assertion styles.\n\nI've been trying out a lot of libraries over the last couple of years and none\nof the assertion libraries that I found \"tickled my fancy\". They either only\nworked in node or had really bad browser support. I wanted something that I can\nuse starting from Internet Explorer 5 to the latest version while maintaining\nthe `expect` like API that we all know and love. Writing tests should be dead\nsimple and not cause any annoyances. This library attempts to achieve all of\nthis.\n\n## Installation\n\nAssume is written with client and server-side JavaScript in mind and uses the\ncommonjs module system to export it self. The library is released in the public\nnpm registry and can be installed using:\n\n```\nnpm install --save-dev assume\n```\n\nThe `--save-dev` flag tells `npm` to automatically add this `package.json` and it's\ninstalled version to the `devDependencies` of your module.\n\nAs code is written against the commonjs module system we also ship a standalone\nversion in the module which introduces an `assume` global. The standalone\nversion can be found in the `dist` folder after installation. The dist file is\nnot commited to GitHub.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Syntax](#syntax)\n- [Configuration](#configuration)\n- [Feature Detection](#feature-detection)\n- [Performance Testing](#performance-testing)\n- [Assertion](#assertion)\n  - [Keywords](#keywords)\n- [API](#api)\n  - [a, an](#a-an)\n  - [eitherOfType, oneOfType](#eitheroftype-oneoftype)\n  - [instanceOf, instanceof, inherits, inherit](#instanceof-instanceof-inherits-inherit)\n  - [include, includes, contain, contains](#include-includes-contain-contains)\n  - [ok, okay, truthy, truely](#ok-okay-truthy-truely)\n  - [falsely, falsey](#falsely-falsey)\n  - [true](#true)\n  - [false](#false)\n  - [exists, exist](#exists-exist)\n  - [length, lengthOf, size](#length-lengthof-size)\n  - [empty](#empty)\n  - [above, gt, greater, greaterThan](#above-gt-greater-greaterthan)\n  - [least, gte, atleast](#least-gte-atleast)\n  - [below, lt, less, lessThan](#below-lt-less-lessthan)\n  - [most, lte, atmost](#most-lte-atmost)\n  - [within, between](#within-between)\n  - [hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown](#hasown-own-ownproperty-haveownproperty-property-owns-hasown)\n  - [match, matches](#match-matches)\n  - [equal, equals, eq, eqs, exactly](#equal-equals-eq-eqs-exactly)\n  - [eql, eqls](#eql-eqls)\n  - [either](#either)\n  - [throw, throws, fail, fails](#throw-throws-fail-fails)\n  - [finite, isFinite, finiteness](#finite-isfinite-finiteness)\n  - [generator](#generator)\n  - [optimisation, optimization](#optimisation-optimization)\n  - [optimised, optimized](#optimised-optimized)\n  - [start, starts, startsWith, startWith](#start-stats-startswith-startwith)\n  - [end, ends, endsWith, endWith](#end-ends-endswith-endwith)\n  - [closeTo, close, approximately, near](#closeto-close-approximately-near)\n  - [rejected, rejects, throwAsync, throwsAsync, failAsync, failsAsync](#rejected-rejects-throwasync-throwsasync-failasync-failsasync)\n  - [resolveSync, resolvesSync, resolvedSync, completeSync, completesSync, completedSync](#resolvesync-resolvessync-resolvedsync-completesync-completessync-completedsync)\n- [i.hope](#ihope)\n- [Planning](#planning)\n- [Waiting](#waiting)\n- [Plugins](#plugins)\n  - [Publishing](#publishing)\n  - [use](#use)\n  - [add](#add)\n  - [test](#test)\n  - [assign](#assign)\n  - [clone](#clone)\n\n## Syntax\n\nWe support a lot of different syntaxes and assertion styles. The only thing we\nwill no (read never) support is the `should` syntax as we will never extend\nbuild-in objects/primitives of JavaScript.\n\nThe default syntax that we support is modeled after `expect` so you can replace\nany assertion library which implements this API by simply changing the require\nto:\n\n```js\nvar expect = require('assume');\n\nexpect('foo').equals('foo');\nexpect('foo').is.a('string');\n```\n\nAs you can see in the example above the `is` property is used to make the\nassertion more readable. We support the following aliases which allow these kind\nof chains:\n\n- `to`\n- `be`\n- `been`\n- `is`\n- `was`\n- `and`\n- `has`\n- `have`\n- `had`\n- `with`\n- `that`\n- `at`\n- `of`\n- `some`\n- `does`\n- `did`\n- `itself`\n- `which`\n\nSo you can just write:\n\n```js\nassume(100).is.at.most(100);\n```\n\nBut do note that these aliases are **optionally** so the above example can also\nbe written as:\n\n```js\nassume(100).most(1000);\n```\n\n### Configuration\n\nThe module can be configured globally be changing the properties on the `config`\nobject:\n\n```js\nvar assume = require('assume');\nassume.config.includeStack = false;\n```\n\nOr locally for each assertions by supplying the `assume` function with an\noptional configuration object:\n\n```js\nassume('foo', { includeStack: false }).is.a('buffer');\n```\n\nThe following options can be configured:\n\n- **`includeStack`** Should we output a stack trace. Defaults to `true`.\n- **`showDIff`** Show difference between the given and expected values. Defaults\n  to `true`.\n\n### Feature Detection\n\nCertain assertions only work in certain JavaScript/EcmaScript environments.\nThings like the `generator` assertions only work in ES6 as the `function *` is\ninvalid syntax. The results of the feature detection is publicly stored in the\n`assume.supports` object. You can use this object to add some conditional tests\nto your test suite. The following features are currently detected:\n\n- **generators** Are generators supported in the host environment.\n- **native** Is V8 native syntax supported.\n\n```js\nif (assume.supports.native) {\n  it('does things', function () {\n    ..\n  });\n}\n```\n\nIf you are a plugin author, feel free to add your own feature detections to this\nobject (as long as you do not override any pre-existing values).\n\n### Performance Testing\n\nThe performance testing is only available for environments that use V8 and more\nspecifically the `--allow-natives-syntax` flags. These flags can be supplied in\n[chrome before you start browser][flags]. These flags are necessary to get\naccess to the V8 internals which expose optimization and de-optimization\ninformation.\n\nIf you are running `iojs` or `node` on the server, you can pass in these flags\ndirectly:\n\n```\niojs --allow-natives-syntax\n```\n\n#### Mocha\n\nIf you are using `mocha` as test runner you usually add `mocha` as executable.\nBut unfortunately, the `mocha` binary doesn't allow you to pass V8 flags. So\ninstead of using the `mocha` binary directly you can use the `node` and call the\n`_mocha` binary instead:\n\n```\nnode --allow-natives-syntax --harmony ./node_modules/mocha/bin/_mocha test/test.js\n```\n\nYou can check if your host environment supports these performance tests by\nchecking the `assume.supports.native` variable.\n\n### Assertion\n\nThere are various of assertions available in assume. If you want the failed\nassertion to include a custom message or reason you can **always** add this as last\nargument of the assertion function.\n\n```js\nassume(true).is.false('how odd, true is not a false');\n```\n\nThe behaviours of the assertions can be chained using special \"flags\" or\n\"prefixes\". We currently support the following prefixes.\n\n- `.not`, `.doesnt`, `.dont` Instead of assuming that your assertions assert to\n  `true` they will now assert for `false`.\n- `.deep`, `.deeply`, `.strict` `.strictly` Instructs the assertions to do a\n  **deep** equal, so it checks if the contents match instead of an `object` it\n  self matches.\n\nFor example:\n\n```js\nassume(false).is.not.true();\nassume({foo:'bar'}).deep.equals({foo:'bar'});\n```\n\n#### Keywords\n\nNow, a special word of caution for those of you who are using this library to\nwrite cross browser tests. Internet Explorer has issues when you use\n**keywords** as functions. Using the `true()`, `instanceof()` etc. functions to\nassert you will run in to issues. So the rule of thumb here is that if you need\nto do cross browser support do not assert with the keyword based names.\n\n## API\n\nLet's take a closer look to all assertions that we're supporting:\n\n#### a, an\n\nAsserts if the given value is the correct type. We need to use Object.toString\nhere because there are some implementation bugs the `typeof` operator:\n\n- Chrome \u003c= 9: /Regular Expressions/ are evaluated to `function`\n\nAs well as all common flaws like Arrays being seen as Objects etc. This\neliminates all these edge cases.\n\n```js\nassume([]).is.a('array');\n```\n\n[`instanceof` is a keyword and might cause cross browser issues](#keywords)\n\n#### eitherOfType, oneOfType\n\nAsserts if the given value is one of the acceptable types.\n\nThe same caveats regarding `typeof` apply as described in [a, an](#a-an).\n\n```js\nassume([]).is.oneOfType(['array', 'string']);\n```\n\n#### instanceOf, instanceof, inherits, inherit\n\nAsserts that the value is instanceof the given constructor.\n\n```js\nfunction Classy() {}\n\nvar classes = new Classy();\n\nassume(classes).is.an.instanceOf(Classy);\n```\n\n#### include, includes, contain, contains\n\nAssert that value includes a given value. I know this sounds vague but an\nexample might be more useful here. It can check this for strings, objects and\narrays.\n\n```js\nassume({foo: 'bar'}).contains('foo');\nassume('hello world').includes('world');\nassume([1,3,4]).contains(1);\n```\n\n#### ok, okay, truthy, truely\n\nAssert that the value is truthy.\n\n```js\nassume(1).is.ok();\nassume(0).is.not.ok();\nassume(true).is.ok();\n```\n\n#### falsely, falsey\n\nAssert that the value is falsey.\n\n```js\nassume(0).is.falsely();\nassume(true).is.not.falsey();\nassume(null).is.falsely;\n```\n\n#### true\n\nExplicitly check that the value is the boolean `true`.\n\n```js\nassume(true).true();\n```\n\n[`true` is a keyword and might cause cross browser issues](#keywords)\n\n#### false\n\nExplicitly check that the value is the boolean `false`.\n\n```js\nassume(false).false();\n```\n\n[`false` is a keyword and might cause cross browser issues](#keywords)\n\n#### exists, exist\n\nCheck if the value not not `null`.\n\n```js\nassume('hello').exists();\nassume(undefined).exists(); // throws\n```\n\n#### length, lengthOf, size\n\nAssert if the given value has the given length. It accepts arrays, strings,\nfunctions, object and anything else that has a `.length` property.\n\n```js\nassume({ foo: 'bar' }).has.length(1);\nassume([1,2,3,4,5,6]).is.size(6)\n```\n\n#### empty\n\nShort hand function for `assume(val).length(0)` so it can check if objects,\narrays, strings are empty.\n\n```js\nassume([]).empty();\nassume('').empty();\nassume({}).empty();\n\n//\n// Also works against everything that has a `.length` property\n//\nlocalStorage.clear();\nassume(localStorage).is.empty();\n```\n\n#### above, gt, greater, greaterThan\n\nAssert if the value is above the given value. If you need greater or equal check\nout the `least` method. If value to assert is not a number we automatically\nextract the length out of it so you can use it check the length of arrays etc.\n\n```js\nassume(100).is.above(10);\n```\n\n#### least, gte, atleast\n\nAssert if the value is above or equal to the given value. If you just need\ngreater check out the `above` method. If value to assert is not a number we\nautomatically extract the length out of it so you can use it check the length of\narrays etc.\n\n```js\nassume(100).is.least(10);\nassume(100).is.least(100);\n```\n\n#### below, lt, less, lessThan\n\nAssert if the value is less than the given value. If you need less or equal\ncheck out the `most` method. If value to assert is not a number we automatically\nextract the length out of it so you can use it check the length of arrays etc.\n\n```js\nassume(10).is.below(100);\n```\n\n#### most, lte, atmost\n\nAssert if the value is less or equal to the given value. If you just need less,\ncheck out the `less` method. If value to assert is not a number we automatically\nextract the length out of it so you can use it check the length of arrays etc.\n\n```js\nassume(10).is.most(100);\nassume(100).is.most(100);\n```\n\n#### within, between\n\nCheck if the value is between or equal to a given range. If value to assert is\nnot a number we automatically extract the length out of it so you can use it\ncheck the length of arrays etc.\n\n```js\nassume(100).is.between(90, 100);\nassume([1, 213, 13, 94, 5, 6, 7]).is.between(2, 10);\n```\n\n#### hasOwn, own, ownProperty, haveOwnProperty, property, owns, hasown\n\nAssert that the value has the specified property and optionally\ndeeply check its value.\n\n```js\nassume({foo: 'bar'}).owns('foo');\nassume({foo: 'bar'}).owns('foo', 'bar');\n```\n\n#### match, matches\n\nMatches the value against a given Regular Expression. If a string is given\ninstead of an actual Regular Expression we automatically transform it to an `new\nRegExp`.\n\n```js\nassume('hello world').matches(/world$/);\n```\n\n#### equal, equals, eq, eqs, exactly\n\nAssert that given value is strictly (===) equal to the supplied value.\n\n```js\nassume('foo').equals('foo');\nassume(13424).equals(13424);\n```\n\n#### eql, eqls\n\nAssert that the given value deeply equals the supplied value.\n\n```js\nassume([1,2]).eql([1,2]);\n```\n\n#### either\n\nAssert that the value is either one of the values of the given array. It can be\nprefixed with `.deep` for deep assertions.\n\n```js\nassume('foo').is.either(['bar', 'banana', 'foo']);\nassume({ foo: 'bar' }).is.either(['bar', 'banana', { foo: 'bar' }]);\n```\n\n#### throw, throws, fail, fails\n\nAssert that the given function throws an error. The error can match a string,\nregexp or function instance.\n\n```js\nfunction arrow() { throw new Error('you have failed this city'); }\n\nassume(arrow).throws(/failed this city/);\nassume(arrow).throws('failed this city');\nassume(arrow).does.not.throw('your mom');\nassume(function(){}).does.not.throw();\n```\n\n[`throw` is a keyword and might cause cross browser issues](#keywords)\n\n#### finite, isFinite, finiteness\n\nAssert that the given value is finite.\n\n```js\nassume(Infinity).is.finite();\n```\n\nIf `deep` assertion style is used it will use the much stricter\n`Number.isFinite` instead of the regular `isFinite` functionality.\n\n#### generator\n\nAssert that the given value is an EcmaScript 6 based generator.\n\n```js\nassume(function *() {}).is.generator();\n```\n\n**Please note that this will only work if Generators are enabled in the host\nenvironment or you might end up with false positives**\n\n#### optimisation, optimization\n\n**Please see the [Performance Testing](#performance-testing) section information\nto enable these assertions as they require specific V8 flags to be enabled.**\n\n#### optimised, optimized\n\n**Please see the [Performance Testing](#performance-testing) section information\nto enable these assertions as they require specific V8 flags to be enabled.**\n\n#### start, starts, startsWith, startWith\n\nAssert that the value starts with the given string.\n\n```js\nassume('foobar').startWith('foo');\n```\n\n#### end, ends, endsWith, endWith\n\nAssert that the value ends with the given string.\n\n```js\nassume('foor bar, banana').endsWith('ana');\n```\n\n#### closeTo, close, approximately, near\n\nAssert a float point number is near a given value within a delta margin.\n\n```js\nassume(1.5).is.approximately(1.4, 0.2);\n```\n\n### i.hope\n\nThe asserts we write are assumptions that we receive a given value. While you're\nwriting tests you hope that they all pass. We could write these tests using an\n`i.hope.that(value)` syntax:\n\n```js\nvar i = require('assume');\n\ni.hope.that('foo').is.a('string');\ni.expect.that('foo').is.a('string');\ni.assume.that('foo').equals('bar');\ni.sincerely.hope.that('foo').is.a('string');\n```\n\n### rejected, rejects, throwAsync, throwsAsync, failAsync, failsAsync\n\nAssert that the `thenable` results in a rejected state.\n\n```js\nawait assume(thisFunctionAsyncThrows()).to.throwAsync();\n```\n\n### resolveSync, resolvesSync, resolvedSync, completeSync, completesSync, completedSync\n\nAssert that the `thenable` completed and the result was filled synchronously.\n\n```js\nawait assume(thisFuncCompletesSynchronously()).to.completeSync();\n```\n\n\u003e Note that `Promise` always complete asynchronously even if it's already in a resolved or rejected state.\n\n## Planning\n\nThe `assume.plan` method allows you to plan the amount of assertions that should\nbe executed by your test suite. This method accepts 2 arguments:\n\n1. The amount of assertions you expect to run. This should always be an exact\n   number.\n2. An optional async callback that should be called with error as first argument\n   on failure instead of throwing an error. This makes it ideal for async\n   testing as you can just pass your continuation function.\n\nThe method will return a function that should be called at the end of your\ntests. This method will still allow you to pass in an error as first argument so\nthe supplied callback in second argument will be called directly with it.\n\nWhen the method is called we will count the amount of assertions that we're\nexecuted. If it's less or more than the supplied amount we will throw an error.\n\n```js\nvar end = assume.plan(10);\n\nassume(10).equals(10);\nend(); // This throws an error as we only executed 1 out of the 10 asserts.\n```\n\nAnd with optional async callback:\n\n```js\nnext = assume.plan(7, next);\n\nfor (var i = 0; i \u003c 10; i++) {\n  assume(i).equqls(i);\n}\n\nnext(); // Also throws an error as we've executed 10 assertions instead of 7.\n```\n\n## Waiting\n\nWriting async tests can be hard, especially if you have to juggle with callbacks\nand wait untill 2 callbacks are completed before you can continue with the test\nsuite. The `assume.wait` function helps you with orchestration of tests and\ncallbacks. The method accepts 3 arguments:\n\n1. The amount of times the returned callback should be called before calling the\n   supplied callback.\n2. Optionally, the amount of assertions you expect to run. We will wrap the\n   returned callback with `assume.plan` this way.\n3. Completion callback which is called after the callbacks have been called.\n\nThe method will return a function that should be used as callback for your async\ntests. It follows an error first callback pattern and instantly calls the\nsupplied callback once an error has be passed in as error argument.\n\n```js\n it('does async things', function (next) {\n   next = assume.wait(2, 4, next);\n\n   asynctask(function (err, data) {\n     assume(err).is.a('undefined');\n     assume(data).equals('testing');\n\n     next();\n   });\n\n   asynctaskfail(function (err, data) {\n     assume(err).is.a('undefined');\n     assume(data).equals('testing');\n\n     next();\n   });\n });\n ```\n\n## Plugins\n\nWe've done our best to include a bunch of assertions that should make it easier\nto test your code but it's always possible that we're missing assertions or you\njust want to eliminate repetition in your code. So we've got a plugin interface\nwhich allows you to extend the `assume` instance with even more assertions.\n\n### Publishing\n\nFor the sake of discoverablity ability of your plugins on npm we suggest to either\nsuffix or prefix your module with `assume` and adding the `assume` keyword in to\nyour keywords list.\n\n### use\n\nLet's assume that we've want to extend the library with a method for checking\nthe headers of a passed in HTTP request object. If it was released in npm we\ncould add it as following:\n\n```js\nassume.use(require('assume-headers'));\n```\n\nThe `use` method returns `assume` so it can be used to chain multiple plugin\ncalls together:\n\n```js\nassume\n.use(require('assume-headers'))\n.use(require('assume-method'));\n```\n\nThe `assume-headers` plugin/module should export a function which receives the\nassume instance to extend as illustrated by the example below:\n\n```js\nmodule.exports = function plugin(assume, util) {\n  /**\n   * Assert that the received HTTP request contains a given header.\n   *\n   * @param {String} name Name of the header that we should have received.\n   * @param {String} ms Reason of failure.\n   * @returns {Assume}\n   * @api public\n   */\n  assume.add('header', function header(name, msg) {\n    var expect = '`'+ util.string(this.value.header)'` to @ have header '+ util.string(name);\n\n    return this.test(name in this.value.headers, msg, expect);\n  });\n}\n```\n\nThe plugin receives 2 arguments:\n\n1. A reference to the `assume` instance so it can be extended.\n2. Small assertion helper library which contains all the internals we're using.\n\nThe helper library contains the following methods:\n\n- **name**, Reference to the `fn.name` module so you extract names from\n  functions.\n- **get**, Reference to the `get` method of the `pathval` module.\n- **string**, Inspection function which safely transforms objects, numbers,\n  dates etc. to a string.\n- **deep**, A deep assertion if the two argument deeply equal to each other.\n- **type**, Extract the type of an object to an lowercase string. Useful for\n  detecting the difference between `object`, `array`, `arguments`, `date`,\n  `buffer` etc.\n- **size**, A function which returns the size of given object or array.\n- **each**, Simple iterator which accepts an array/object and calls the supplied\n  callback with the value and key/index.\n- **nodejs**, Boolean indicating if we are running on `nodejs`.\n\nNew flags can be introduced by adding properties to the `flags` object. The\n`flags` object has the following structure:\n\n- `key` This is the name of the property which will be added to the `assume`\n  instance. The property is set to `false` by default and will be to `true` once\n  once of the `flags` is accessed.\n- `value` These are the aliases that can be used to the set the property to\n  `true`.\n\nFor our `.not` flags we've set the following key/value's:\n\n```js\nAssert.flags.untrue = 'doesnt, not, dont';\n```\n\nPlease do note that you should try to limit the amount of flags that you add as\nthey are quite expensive to process every single time.\n\nAdding new assertions to assume can be done using the following methods:\n\n#### add\n\nThe `assume.add` method is a convince method for adding new methods to the\nassume prototype. It was created using the [`assign`](#assign) method so it can\nautomatically add aliases/shorthand's of the method to the prototype in one go.\nThe method requires 2 arguments:\n\n1. A string which is comma or space separated or an array which contains the\n   names of the methods that should be added to the prototype.\n2. The function or value that is assigned for all these properties.\n\n```js\nmodule.exports = function (assume, util) {\n  util.each(['GET', 'POST', 'PUT', 'DELETE'], function each(method) {\n    assume.add(method, function () {\n      var expect = '`'+ util.string(this.value.method)+'` to @ be '+ method;\n\n      return this.test(this.value.method === method, msg, expect);\n    });\n  });\n}\n```\n\nIf you want to add more aliases for the `.function()` method you can simply do\na:\n\n```js\nassume.add('execute, executes, exec', function () {\n  return this.clone().is.a('function');\n});\n```\n\nThe value to assert is stored in the `value` property of the instance. If the\n`deep` flag is set, the `deeply` property is set to `true`.\n\n#### test\n\nThis is the method that handles all the assertion passing and failing. It's\n_the_ most important method of all. It accepts the following arguments:\n\n- `passed`, a boolean which indicates if the assertion failed or passed.\n- `msg`, a string which is the reason or message provided by the users.\n- `expectation`, a compiled template which explains what the assertion expected.\n- `slice`, a number which slices of stacks from the stack trace. This is keeps\n  the stack trace clear of all references to our own assertion library and only\n  contains the part of the test/suite where the assertion was initiated. This\n  value is optional and defaults to `2` so it removes the `test` and the\n  `assertion` from the stack.\n\nIf the `assertion` passes the method will return it self, or it will throw.\n\n```js\nassume.add('true', function (msg) {\n  var expectation = format('value to @ be true');\n  return this.test(this.value === true, msg, expectation);\n});\n```\n\nIn example above you might have noticed the odd `@` in the `expection` value.\nThis is a special character and will be replaced with `not` if the `.not` flag\nwas used or completely removed (including an extra whitespace at the end).\n\n#### assign\n\nAssign multiple values to a given thing. This method accepts one argument which\nis an object or prototype on where we should assign things. It will return a\nfunction that is responsible for the assignment on that given thing. The return\nfunction will require 2 arguments:\n\n1. A string which is comma or space separated or an array which contains the\n   names of the methods that should be added to the prototype.\n2. The function or value that is assigned for all these properties.\n\nTo create your own custom `add` method you could simply do:\n\n```js\nvar add = assume.assign(assign.prototype);\n```\n\nAnd the `add` function would now do exactly the same as the [`assume.add`](#add)\nmethod.\n\n#### clone\n\nCreate an exact clone of the assume instance so it all flags and options are\nidentical to the current assume instance. The method accepts one optional\nargument which is the value it should assert. If nothing is given it uses the\ncurrent value.\n\nThis can be helpful if you want to run assertions in your assertions so you can\nassert while you assert.\n\n```js\n// Yo dawg, I herd you like assertions so I put assertions in the assertions so\n// you can assert while you assert.\n\nassume.add('something', function somethign(value, msg) {\n  this.clone().is.a('string');\n  this.clone().is.endsWith('thing');\n\n  return this.test(this.value ==== 'something', msg, 'the value should be something');\n});\n```\n\n## License\n\nMIT\n\n[flags]: http://www.chromium.org/developers/how-tos/run-chromium-with-flags\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigpipe%2Fassume","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigpipe%2Fassume","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigpipe%2Fassume/lists"}