Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns a promise', function () {
var testFolder = path.join(__dirname, '../examples/jasmine-module');
var p = xplain.document({
patterns: testFolder + '/sp*.js',
outputFolder: testFolder + '/docs',
title: 'as module works'
});
lazyAss(Q.isPromise(p));
return p.done();
});
context.onReady(function(){
var promise = context.Items.toArray();
var q = require('q');
test.equal(q.isPromise(new $data.PromiseHandlerBase().getPromise()), false, '$data.PromiseHandlerBase returns Q promise failed!');
test.equal(q.isPromise(promise), true, '$data.PromiseHandler returns Q promise failed!' + promise);
test.done();
});
},
.then(function (response) {
ASSERT.ok(!Q.isPromise(response.body), "body is not a promise")
var acc = [];
return response.body.forEach(function (chunk) {
acc.push(chunk.toString("utf-8"));
}).then(function () {
ASSERT.equal(acc.join(""), "Hello, World!", "body is hello world");
});
})
})
sails.emit("hook:"+name+":"+hook,v, function gatherListenerResult( result ){
if(q.isPromise( result) ){
_promises.push(result)
}
})
if( _promises.length == 0 ){
function eagerWhen(valueOrPromise, callback) {
if (Q.isPromise(valueOrPromise))
return valueOrPromise.then(callback);
else
return callback(valueOrPromise);
}
function encode(object) {
if (Q.isPromise(object)) {
var id = makeId();
makeLocal(id);
resolveLocal(id, object);
return {"@": id};
} else if (Array.isArray(object)) {
return object.map(encode);
} else if (typeof object === "object") {
var result = {};
for (var key in object) {
if (has.call(object, key)) {
var newKey = key;
if (/^[!@]$/.exec(key))
newKey = key + key;
result[newKey] = encode(object[key]);
}
}
var result;
if (_.isFunction(object)) {
result = self.evaluateObject(injection.resolveFuncArgs(object, function (dependency) {
if (dependency === '$parentProperty') {
return parent && name && self.evaluateObject(parent[name], parent.__proto__, name).obj;
} else {
return injection.lookup(dependency);
}
}));
} else if (_.isArray(object)) {
result = object.map(function (i) {
return self.evaluateObject(i)
});
} else if (_.isDate(object)) {
return object;
} else if (Q.isPromise(object) || object && object.then) {
result = Q(object); //TODO .then(evaluateObject) ?
} else if (_.isObject(object)) {
result = new self.ConfigObject(object);
} else {
result = object;
}
return result;
}
};
.then(function (response) {
expect(Q.isPromise(response.body)).toBe(false);
var acc = [];
return response.body.read()
.then(function (body) {
expect(body.toString("utf-8")).toBe("Hello, World!");
});
})
})
function encode(object) {
if (Q.isPromise(object)) {
var id = makeId();
makeLocal(id);
resolveLocal(id, object);
return {"@": id};
} else if (Array.isArray(object)) {
return object.map(encode);
} else if (typeof object === "object") {
var result = {};
for (var key in object) {
if (has.call(object, key)) {
var newKey = key;
if (/^[!@]$/.exec(key))
newKey = key + key;
result[newKey] = encode(object[key]);
}
}
} else if (object === Number.NEGATIVE_INFINITY) {
return {"%": "-Infinity"};
} else if (isNaN(object)) {
return {"%": "NaN"};
}
}
return object;
} else {
var id;
if (memo.has(object)) {
return {"$": memo.get(object)};
} else {
memo.set(object, path);
}
if (Q.isPromise(object) || typeof object === "function") {
id = makeId();
makeLocal(id);
dispatchLocal(id, "resolve", object);
return {"@": id, "type": typeof object};
} else if (Array.isArray(object)) {
return object.map(function (value, index) {
return encode(value, memo, path + "/" + index);
});
} else if (
(
object.constructor === Object &&
Object.getPrototypeOf(object) === Object.prototype
) ||
object instanceof Error
) {
var result = {};