Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
promoting
helpers
namespace to Beta.
- Loading branch information
Showing
16 changed files
with
272 additions
and
118 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
### Query Formatting Helpers | ||
|
||
Everything in this folder is currently in its Alpha version. Use it at your own risk. | ||
Everything in this folder is currently a Beta version. | ||
|
||
See [helpers] namespace. | ||
For details see [helpers namespace]. | ||
|
||
[helpers]:http://vitaly-t.github.io/pg-promise/helpers.html | ||
[helpers namespace]:http://vitaly-t.github.io/pg-promise/helpers.html |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict'; | ||
|
||
require('../array'); | ||
|
||
var $npm = { | ||
os: require('os'), | ||
utils: require('../utils'), | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
'use strict'; | ||
|
||
require('../array'); | ||
|
||
var $npm = { | ||
os: require('os'), | ||
utils: require('../utils'), | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
'use strict'; | ||
|
||
require('../lib/array'); | ||
|
||
var data = [1, 2, 3]; | ||
|
||
describe("map", function () { | ||
|
||
describe("with context", function () { | ||
var ctx, indexes = []; | ||
var res = data.$map(function (d, idx) { | ||
ctx = this; | ||
indexes.push(idx); | ||
return d * 2; | ||
}, data); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBe(data); | ||
expect(res).toEqual([2, 4, 6]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
describe("without context", function () { | ||
var ctx, indexes = []; | ||
var res = data.$map(function (d, idx) { | ||
ctx = ctx || this; | ||
indexes.push(idx); | ||
return d * 2; | ||
}); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBeUndefined(); | ||
expect(res).toEqual([2, 4, 6]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe("filter", function () { | ||
|
||
describe("with context", function () { | ||
var ctx, indexes = []; | ||
var res = data.$filter(function (d, idx) { | ||
ctx = this; | ||
indexes.push(idx); | ||
return d != 2; | ||
}, data); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBe(data); | ||
expect(res).toEqual([1, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
describe("without context", function () { | ||
var ctx, indexes = []; | ||
var res = data.$filter(function (d, idx) { | ||
ctx = ctx || this; | ||
indexes.push(idx); | ||
return d != 2; | ||
}); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBeUndefined(); | ||
expect(res).toEqual([1, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe("forEach", function () { | ||
|
||
describe("with context", function () { | ||
var ctx, values = [], indexes = []; | ||
data.$forEach(function (d, idx) { | ||
ctx = this; | ||
values.push(d); | ||
indexes.push(idx); | ||
}, data); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBe(data); | ||
expect(values).toEqual([1, 2, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
describe("without context", function () { | ||
var ctx, values = [], indexes = []; | ||
data.$filter(function (d, idx) { | ||
ctx = ctx || this; | ||
values.push(d); | ||
indexes.push(idx); | ||
return d != 2; | ||
}); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBeUndefined(); | ||
expect(values).toEqual([1, 2, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe("countIf", function () { | ||
|
||
describe("with context", function () { | ||
var ctx, values = [], indexes = []; | ||
var res = data.$countIf(function (d, idx) { | ||
ctx = this; | ||
values.push(d); | ||
indexes.push(idx); | ||
return d != 2; | ||
}, data); | ||
it("must iterate correctly", function () { | ||
expect(res).toBe(2); | ||
expect(ctx).toBe(data); | ||
expect(values).toEqual([1, 2, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
describe("without context", function () { | ||
var ctx, values = [], indexes = []; | ||
var res = data.$countIf(function (d, idx) { | ||
ctx = ctx || this; | ||
values.push(d); | ||
indexes.push(idx); | ||
return d != 2; | ||
}); | ||
it("must iterate correctly", function () { | ||
expect(ctx).toBeUndefined(); | ||
expect(res).toBe(2); | ||
expect(values).toEqual([1, 2, 3]); | ||
expect(indexes).toEqual([0, 1, 2]); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.