Skip to content

Instantly share code, notes, and snippets.

@dotsonjb14
Created August 21, 2015 15:39
Show Gist options
  • Save dotsonjb14/e1832a933b28d15fcf44 to your computer and use it in GitHub Desktop.
Save dotsonjb14/e1832a933b28d15fcf44 to your computer and use it in GitHub Desktop.
<!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