# dotq

> Yet another [Q](https://github.com/kriskowal/q).

Latest version **0.1.1** (published 2013-09-04) · 0 weekly downloads

## Install

```sh
npm install dotq
pnpm add dotq
yarn add dotq
bun add dotq
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2013-09-04 |
| First published | 2013-09-04 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Maintainers | luin |
| Keywords | promise, q |

## Links

- npm: https://www.npmjs.com/package/dotq
- Repository: https://github.com/luin/dotq
- Issues: https://github.com/luin/dotq/issues
- npm.io page: https://npm.io/package/dotq

## Dependencies (1)

- [q](https://npm.io/package/q.md) ~0.9.6

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2013-09-04
- 0.1.0 — 2013-09-04

## README

# dotQ
Yet another [Q](https://github.com/kriskowal/q).

## Introduce
The following code shows a pretty common case of deeply nested callbacks in JavaScript. It doesn't take a genius to figure out that these nested callbacks will eventually become a bit of a headache:

	step1(function (value1) {
	  step2(value1, function(value2) {
	    step3(value2, function(value3) {
	      step4(value3, function(value4) {
	        // Do something with value4
	      });
	    });
	  });
	});

With the dotQ library, you can flatten the pyramid.

	require('dotq');

	step1.promise()
	  .then(function(value1) {
	    return step2.promise(value1);
	  })
	  .then(function(value2) {
	    return step3.promise(value2);
	  })
	  .then(function(value3) {
	    return step4.promise(value3);
	  })
	  .then(function(value4) {
	    // Do something with value4
	  });

## Install
    npm install dotq

## Difference between dotQ and Q
dotQ is based on Q. dotQ extends the `Function` object with a `promise` method in order to convert the Node.js style callbacks(`function(err, result)`) into Q Promises.

What's more, the style of dotQ works better with the express-promise library.

## Shortcuts

### map / reduce / filter / some / every
dotQ also extends the Q Promise with some useful methods of Array object. For example:

	function anAsyncFunction(number, callback) {
	  callback(null, [number, number + 1, number + 2]);
	}

	anAsyncFunction.promise(3)
	  .map(function(n) {
	    return n + 10;
	  })
	  .then(function(result) {
	    console.log(result); // [ 13, 14, 15 ]
	  });


## How to use
In node.js, Each file loaded shares the same primordial objects like Object, Array, etc,
so you can just require dotQ once in your initialization, after which you can use dotQ everywhere.

## OMG IT EXTENDS FUNCTION???!?!@
https://github.com/visionmedia/should.js/#omg-it-extends-object

http://sugarjs.com/native

## License
The MIT License (MIT)

Copyright (c) 2013 Zihua Li

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.

---
_Source: https://npm.io/package/dotq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
