Created
August 21, 2015 15:39
-
-
Save dotsonjb14/e1832a933b28d15fcf44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
<script> | |
function transformData(data) { | |
return data.results; | |
} | |
function getDataWithoutPipe(data) { | |
var d = $.Deferred(); | |
window.setTimeout(function () { | |
d.resolve({results: data}); | |
}, 2000); | |
return d.promise(); | |
} | |
function getDataWithPipe(data) { | |
return getDataWithoutPipe(data) | |
.pipe(transformData); | |
} | |
getDataWithoutPipe({ | |
a: 1, | |
b: 2 | |
}).then(function (data) { | |
console.log("With Pipe: ", data); | |
}); | |
getDataWithPipe({ | |
a: 1, | |
b: 2 | |
}).then(function (data) { | |
console.log("Without Pipe: ", data); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment