Skip to content

Commit

Permalink
promoting helpers namespace to Beta.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed May 10, 2016
1 parent dadde76 commit 915c263
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .istanbul.yml
Expand Up @@ -2,7 +2,7 @@ verbose: false
instrumentation:
root: .
default-excludes: true
excludes: ['**/helpers/**', 'column.js', 'array.js']
excludes: ['**/helpers/**']
embed-source: false
variable: __coverage__
compact: true
Expand Down
67 changes: 0 additions & 67 deletions lib/errors/column.js

This file was deleted.

10 changes: 2 additions & 8 deletions lib/errors/index.js
Expand Up @@ -4,8 +4,7 @@ var $npm = {
qResult: require('./queryResult'),
qFile: require('./queryFile'),
prepared: require('./prepared'),
paramQuery: require('./paramQuery'),
column: require('./column')
paramQuery: require('./paramQuery')
};

/**
Expand Down Expand Up @@ -38,17 +37,12 @@ var $npm = {
*
*/

// To add when ready:
// * @property {errors.ColumnError} ColumnError
// * Represents an error in parsing a column information by class {@link Columns}.

module.exports = {
QueryResultError: $npm.qResult.QueryResultError,
queryResultErrorCode: $npm.qResult.queryResultErrorCode,
PreparedStatementError: $npm.prepared,
ParameterizedQueryError: $npm.paramQuery,
QueryFileError: $npm.qFile,
ColumnError: $npm.column
QueryFileError: $npm.qFile
};

Object.freeze(module.exports);
6 changes: 3 additions & 3 deletions lib/helpers/README.md
@@ -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
2 changes: 1 addition & 1 deletion lib/helpers/column.js
Expand Up @@ -11,7 +11,7 @@ var $npm = {
* @class helpers.Column
* @description
*
* ** WARNING: Everything within the {@link helpers} namespace is currently in its Alpha version.**
* ** WARNING: Everything within the {@link helpers} namespace is currently a Beta version.**
*
* Read-only structure that represents formatting details for a single column.
*
Expand Down
4 changes: 1 addition & 3 deletions lib/helpers/columnSet.js
@@ -1,7 +1,5 @@
'use strict';

require('../array');

var $npm = {
os: require('os'),
utils: require('../utils'),
Expand All @@ -14,7 +12,7 @@ var $npm = {
* @class helpers.ColumnSet
* @description
*
* ** WARNING: Everything within the {@link helpers} namespace is currently in its Alpha version.**
* ** WARNING: Everything within the {@link helpers} namespace is currently a Beta version.**
*
* Performance-optimized, read-only structure about all query-formatting columns.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/index.js
Expand Up @@ -12,7 +12,7 @@ var $npm = {
* @namespace helpers
* @description
*
* ** WARNING: Everything within the {@link helpers} namespace is currently in its Alpha version.**
* ** WARNING: Everything within the {@link helpers} namespace is currently a Beta version.**
*
* Namespace for automated query formatting helpers, available as `pgp.helpers` after initializing the library.
*
Expand Down
3 changes: 3 additions & 0 deletions lib/helpers/tableName.js
Expand Up @@ -8,6 +8,9 @@ var $npm = {
/**
* @class helpers.TableName
* @description
*
* ** WARNING: Everything within the {@link helpers} namespace is currently a Beta version.**
*
* **Alternative Syntax:** `TableName({table, [schema]})` ⇒ {@link helpers.TableName}
*
* Prepares and escapes a full table name that can be injected into queries directly.
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Expand Up @@ -3,6 +3,7 @@
var $npm = {
pg: require('pg'),
minify: require('pg-minify'),
array: require('./array'),
adapter: require('./adapter'),
result: require('./result'),
promise: require('./promise'),
Expand Down
2 changes: 0 additions & 2 deletions lib/types/parameterized.js
@@ -1,7 +1,5 @@
'use strict';

require('../array');

var $npm = {
os: require('os'),
utils: require('../utils'),
Expand Down
2 changes: 0 additions & 2 deletions lib/types/prepared.js
@@ -1,7 +1,5 @@
'use strict';

require('../array');

var $npm = {
os: require('os'),
utils: require('../utils'),
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "4.0.13",
"version": "4.0.14",
"description": "PostgreSQL via promises",
"main": "lib/index.js",
"scripts": {
Expand Down
138 changes: 138 additions & 0 deletions test/arraySpec.js
@@ -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]);
});
});

});

0 comments on commit 915c263

Please sign in to comment.