1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-13 11:12:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 719ae331ae
commit c96a84d0ff
13249 changed files with 317868 additions and 2101398 deletions

View File

@@ -0,0 +1,6 @@
components
node_modules
test
.gitignore
.travis.yml
component.json

View File

@@ -0,0 +1,85 @@
[![Build Status](https://travis-ci.org/then/promise.png)](https://travis-ci.org/then/promise)
<a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" /></a>
# promise
This a bare bones [Promises/A+](http://promises-aplus.github.com/promises-spec/) implementation.
It is designed to get the basics spot on correct, so that you can build extended promise implementations on top of it.
## Installation
Server:
$ npm install promise
Client:
$ component install then/promise
## API
In the example below shows how you can load the promise library (in a way that works on both client and server). It then demonstrates creating a promise from scratch. You simply call `new Promise(fn)`. There is a complete specification for what is returned by this method in [Promises/A+](http://promises-aplus.github.com/promises-spec/).
```javascript
var Promise = require('promise');
var promise = new Promise(function (resolve, reject) {
get('http://www.google.com', function (err, res) {
if (err) reject(err);
else resolve(res);
});
});
```
## Extending Promises
There are three options for extending the promises created by this library.
### Inheritance
You can use inheritance if you want to create your own complete promise library with this as your basic starting point, perfect if you have lots of cool features you want to add. Here is an example of a promise library called `Awesome`, which is built on top of `Promise` correctly.
```javascript
var Promise = require('promise');
function Awesome(fn) {
if (!(this instanceof Awesome)) return new Awesome(fn);
Promise.call(this, fn);
}
Awesome.prototype = Object.create(Promise.prototype);
Awesome.prototype.constructor = Awesome;
//Awesome extension
Awesome.prototype.spread = function (cb) {
return this.then(function (arr) {
return cb.apply(this, arr);
})
};
```
N.B. if you fail to set the prototype and constructor properly or fail to do Promise.call, things can fail in really subtle ways.
### Wrap
This is the nuclear option, for when you want to start from scratch. It ensures you won't be impacted by anyone who is extending the prototype (see below).
```javascript
function Uber(fn) {
if (!(this instanceof Uber)) return new Uber(fn);
var _prom = new Promise(fn);
this.then = _prom.then;
}
Uber.prototype.spread = function (cb) {
return this.then(function (arr) {
return cb.apply(this, arr);
})
};
```
### Extending the Prototype
In general, you should never extend the prototype of this promise implimenation because your extensions could easily conflict with someone elses extensions. However, this organisation will host a library of extensions which do not conflict with each other, so you can safely enable any of those. If you think of an extension that we don't provide and you want to write it, submit an issue on this repository and (if I agree) I'll set you up with a repository and give you permission to commit to it.
## License
MIT

164
node_modules/transformers/node_modules/promise/index.js generated vendored Normal file
View File

@@ -0,0 +1,164 @@
var isPromise = require('is-promise')
var nextTick
if (typeof setImediate === 'function') nextTick = setImediate
else if (typeof process === 'object' && process && process.nextTick) nextTick = process.nextTick
else nextTick = function (cb) { setTimeout(cb, 0) }
var extensions = []
module.exports = Promise
function Promise(fn) {
if (!(this instanceof Promise)) {
return fn ? new Promise(fn) : defer()
}
if (typeof fn !== 'function') {
throw new TypeError('fn is not a function')
}
var state = {
isResolved: false,
isSettled: false,
isFulfilled: false,
value: null,
waiting: [],
running: false
}
function _resolve(val) {
resolve(state, val);
}
function _reject(err) {
reject(state, err);
}
this.then = function _then(onFulfilled, onRejected) {
return then(state, onFulfilled, onRejected);
}
_resolve.fulfill = deprecate(_resolve, 'resolver.fulfill(x)', 'resolve(x)')
_resolve.reject = deprecate(_reject, 'resolver.reject', 'reject(x)')
try {
fn(_resolve, _reject)
} catch (ex) {
_reject(ex)
}
}
function resolve(promiseState, value) {
if (promiseState.isResolved) return
if (isPromise(value)) {
assimilate(promiseState, value)
} else {
settle(promiseState, true, value)
}
}
function reject(promiseState, reason) {
if (promiseState.isResolved) return
settle(promiseState, false, reason)
}
function then(promiseState, onFulfilled, onRejected) {
return new Promise(function (resolve, reject) {
function done(next, skipTimeout) {
var callback = promiseState.isFulfilled ? onFulfilled : onRejected
if (typeof callback === 'function') {
function timeoutDone() {
var val
try {
val = callback(promiseState.value)
} catch (ex) {
reject(ex)
return next(true)
}
resolve(val)
next(true)
}
if (skipTimeout) timeoutDone()
else nextTick(timeoutDone)
} else if (promiseState.isFulfilled) {
resolve(promiseState.value)
next(skipTimeout)
} else {
reject(promiseState.value)
next(skipTimeout)
}
}
promiseState.waiting.push(done)
if (promiseState.isSettled && !promiseState.running) processQueue(promiseState)
})
}
function processQueue(promiseState) {
function next(skipTimeout) {
if (promiseState.waiting.length) {
promiseState.running = true
promiseState.waiting.shift()(next, skipTimeout)
} else {
promiseState.running = false
}
}
next(false)
}
function settle(promiseState, isFulfilled, value) {
if (promiseState.isSettled) return
promiseState.isResolved = promiseState.isSettled = true
promiseState.value = value
promiseState.isFulfilled = isFulfilled
processQueue(promiseState)
}
function assimilate(promiseState, thenable) {
try {
promiseState.isResolved = true
thenable.then(function (res) {
if (isPromise(res)) {
assimilate(promiseState, res)
} else {
settle(promiseState, true, res)
}
}, function (err) {
settle(promiseState, false, err)
})
} catch (ex) {
settle(promiseState, false, ex)
}
}
Promise.use = function (extension) {
extensions.push(extension)
}
function deprecate(method, name, alternative) {
return function () {
var err = new Error(name + ' is deprecated use ' + alternative)
if (typeof console !== 'undefined' && console && typeof console.warn === 'function') {
console.warn(name + ' is deprecated use ' + alternative)
if (err.stack) console.warn(err.stack)
} else {
nextTick(function () {
throw err
})
}
method.apply(this, arguments)
}
}
function defer() {
var err = new Error('promise.defer() is deprecated')
if (typeof console !== 'undefined' && console && typeof console.warn === 'function') {
console.warn('promise.defer() is deprecated')
if (err.stack) console.warn(err.stack)
} else {
nextTick(function () {
throw err
})
}
var resolver
var promise = new Promise(function (res) { resolver = res })
return {resolver: resolver, promise: promise}
}

View File

@@ -0,0 +1,75 @@
{
"_args": [
[
"promise@~2.0",
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/transformers"
]
],
"_from": "promise@>=2.0.0 <2.1.0",
"_id": "promise@2.0.0",
"_inCache": true,
"_installable": true,
"_location": "/transformers/promise",
"_npmUser": {
"email": "forbes@lindesay.co.uk",
"name": "forbeslindesay"
},
"_npmVersion": "1.2.10",
"_phantomChildren": {},
"_requested": {
"name": "promise",
"raw": "promise@~2.0",
"rawSpec": "~2.0",
"scope": null,
"spec": ">=2.0.0 <2.1.0",
"type": "range"
},
"_requiredBy": [
"/transformers"
],
"_resolved": "https://registry.npmjs.org/promise/-/promise-2.0.0.tgz",
"_shasum": "46648aa9d605af5d2e70c3024bf59436da02b80e",
"_shrinkwrap": null,
"_spec": "promise@~2.0",
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/transformers",
"author": {
"name": "ForbesLindesay"
},
"bugs": {
"url": "https://github.com/then/promise/issues"
},
"dependencies": {
"is-promise": "~1"
},
"description": "Bare bones Promises/A+ implementation",
"devDependencies": {
"better-assert": "~1.0.0",
"mocha-as-promised": "~1.2.1",
"promises-aplus-tests": "*"
},
"directories": {},
"dist": {
"shasum": "46648aa9d605af5d2e70c3024bf59436da02b80e",
"tarball": "http://registry.npmjs.org/promise/-/promise-2.0.0.tgz"
},
"homepage": "https://github.com/then/promise#readme",
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "forbeslindesay",
"email": "forbes@lindesay.co.uk"
}
],
"name": "promise",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/then/promise.git"
},
"scripts": {
"test": "mocha -R spec --timeout 200 --slow 99999"
},
"version": "2.0.0"
}