type-store 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/postgres/time_range.sql +7 -0
- package/type-store.js +27 -1
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-store",
|
|
3
3
|
"description": "type ecosystem",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.5",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"repository": "codenautas/type-store",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "type-store.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"type-store.js",
|
|
11
|
-
"postgres-interval4client.js"
|
|
11
|
+
"postgres-interval4client.js",
|
|
12
|
+
"postgres"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"big.js": "^6.2.2",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"expect.js": "^0.3.1",
|
|
22
23
|
"istanbul": "^0.4.5",
|
|
23
|
-
"mocha": "^10.
|
|
24
|
+
"mocha": "^10.8.2",
|
|
24
25
|
"postgres-interval": "^4.0.2",
|
|
25
26
|
"discrepances": "^0.2.8"
|
|
26
27
|
},
|
package/type-store.js
CHANGED
|
@@ -761,7 +761,7 @@ TypeStore.type.timestamp.prototype.toPlainString=function toPlainString(typedVal
|
|
|
761
761
|
return typedValue.toYmdHmsM();
|
|
762
762
|
};
|
|
763
763
|
|
|
764
|
-
|
|
764
|
+
// https://www.postgresql.org/docs/current/sql-createtype.html
|
|
765
765
|
TypeStore.type.time = function TypeArrayTime(){ TypeBase.apply(this, arguments); };
|
|
766
766
|
TypeStore.type.time.prototype = Object.create(TypeBase.prototype);
|
|
767
767
|
TypeStore.type.time.prototype.typeDbPg='time';
|
|
@@ -800,6 +800,32 @@ TypeStore.type.time.prototype.toLocalParts=function toLocalParts(typedValue,fPar
|
|
|
800
800
|
return fParts(rta, "time");
|
|
801
801
|
};
|
|
802
802
|
|
|
803
|
+
Object.defineProperty(TypeStore.type.time.prototype, 'align', {
|
|
804
|
+
get: function(){ return TypeStore.locale.number.align; }
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
// https://www.postgresql.org/docs/current/sql-createtype.html
|
|
809
|
+
// https://www.postgresql.org/docs/current/rangetypes.html
|
|
810
|
+
|
|
811
|
+
/** @param {{typeName:string, pg_OID?:number, typeDbPg?:string}} param */
|
|
812
|
+
function rangeOf(param){
|
|
813
|
+
var result = function TypeRangeof(){ TypeBase.apply(this, arguments); };
|
|
814
|
+
result.prototype.toPlainString=function toPlainString(typedValue){
|
|
815
|
+
return typedValue;
|
|
816
|
+
};
|
|
817
|
+
result.prototype.fromString=function fromString(textValue){
|
|
818
|
+
return textValue;
|
|
819
|
+
};
|
|
820
|
+
result.prototype.typeDbPg=param.typeDbPg || param.typeName+'_range';
|
|
821
|
+
if (param.pg_OID) result.prototype.pg_OID=param.pg_OID;
|
|
822
|
+
return result
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
TypeStore.type.time_range=rangeOf({typeName:'time'});
|
|
826
|
+
TypeStore.type.tsrange=rangeOf({typeName:'timestamp', typeDbPg:'tsrange', pg_OID:3908});
|
|
827
|
+
|
|
828
|
+
|
|
803
829
|
// PostgresInterval.prototype.typeStore={type:'interval'};
|
|
804
830
|
|
|
805
831
|
json4all.addType(bestGlobals.TimeInterval,{
|