@dra2020/dra-types 1.8.123 → 1.8.125
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/dist/datasets.d.ts +6 -0
- package/dist/dra-types.js +12 -3
- package/dist/dra-types.js.map +1 -1
- package/lib/datasets.ts +11 -3
- package/lib/packedfields.ts +5 -2
- package/package.json +1 -1
package/lib/datasets.ts
CHANGED
|
@@ -66,11 +66,12 @@ export interface DatasetMeta
|
|
|
66
66
|
year: number, // 4 digit year
|
|
67
67
|
title: string, // title displayed in UI
|
|
68
68
|
description?: string, // longer description
|
|
69
|
-
office?: string, // pres | comp | sc | sen | con | tre | sos | ltgov | gov | ag
|
|
69
|
+
office?: string, // pres | comp | sc | sen | con | tre | sos | ltgov | gov | ag and more
|
|
70
70
|
subtype?: string, // always general?
|
|
71
|
-
votingAge?: boolean, //
|
|
72
|
-
nhAlone?: boolean, //
|
|
71
|
+
votingAge?: boolean, // true => VAP or CVAP; false => Total population (from Census or ACS or Adjusted)
|
|
72
|
+
nhAlone?: boolean, // Non-Hispanic Alone demographic variant
|
|
73
73
|
privateKey?: string, // Old-style semi-private datasets
|
|
74
|
+
restrict?: { [key: string]: boolean }, // export, display, duplicate (true => function is not allowed)
|
|
74
75
|
members?: { [key: number]: string }, // For composites, specifies
|
|
75
76
|
fields?: DatasetFields,
|
|
76
77
|
colors?: DatasetColors, // Optional colorby expressions
|
|
@@ -106,5 +107,12 @@ export interface Dataset
|
|
|
106
107
|
labels?: string[],
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
export function datasetRestrict(ds: Dataset): { [key: string]: boolean }
|
|
111
|
+
{
|
|
112
|
+
if (ds && ds.id && ds.meta && ds.meta[ds.id] && ds.meta[ds.id].restrict)
|
|
113
|
+
return ds.meta[ds.id].restrict;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
109
117
|
// Index of database records
|
|
110
118
|
export type DatasetIndex = { [id: string]: Dataset };
|
package/lib/packedfields.ts
CHANGED
|
@@ -413,8 +413,11 @@ export function aggregatePackedFields(agg: PackedFields, pf: PackedFields): Pack
|
|
|
413
413
|
|
|
414
414
|
export function aggregateCount(agg: PackedFields): number
|
|
415
415
|
{
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
// If we have multiple packedfieldarrays, all of them track the aggregate in zero spot.
|
|
417
|
+
// So we just pick the one that happens to be come up first.
|
|
418
|
+
if (!agg) return 0;
|
|
419
|
+
let pfa = Util.nthProperty(agg) as PackedFieldsArray;
|
|
420
|
+
return pfa ? pfa[0] : 0;
|
|
418
421
|
}
|
|
419
422
|
|
|
420
423
|
export function decrementPackedFields(agg: PackedFields, pf: PackedFields): PackedFields
|