@defra/forms-model 3.0.291 → 3.0.293

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.
@@ -1,28 +1,4 @@
1
1
  import slug from 'slug';
2
- export const serialiseAndDeserialise = obj => {
3
- if (typeof obj === 'object' && obj !== null) {
4
- return JSON.parse(JSON.stringify(obj));
5
- }
6
- return obj;
7
- };
8
- export const clone = obj => {
9
- if (obj) {
10
- if (typeof obj.clone === 'function') {
11
- return obj.clone();
12
- }
13
- return serialiseAndDeserialise(obj);
14
- }
15
- return obj;
16
- };
17
- export function filter(obj, predicate) {
18
- const result = {};
19
- for (const [key, value] of Object.entries(obj)) {
20
- if (value && predicate(value)) {
21
- result[key] = value;
22
- }
23
- }
24
- return result;
25
- }
26
2
 
27
3
  /**
28
4
  * Replace whitespace, en-dashes and em-dashes with spaces
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["slug","serialiseAndDeserialise","obj","JSON","parse","stringify","clone","filter","predicate","result","key","value","Object","entries","slugify","input","options","string","trimStart","replace","fallback","lower","trim"],"sources":["../../../src/utils/helpers.ts"],"sourcesContent":["import slug from 'slug'\n\nexport const serialiseAndDeserialise = <T>(obj: T): T => {\n if (typeof obj === 'object' && obj !== null) {\n return JSON.parse(JSON.stringify(obj))\n }\n\n return obj\n}\n\nexport const clone = <T>(obj: T & { clone?: () => T }): T => {\n if (obj) {\n if (typeof obj.clone === 'function') {\n return obj.clone()\n }\n\n return serialiseAndDeserialise<T>(obj)\n }\n return obj\n}\n\nexport function filter<T extends Record<string, unknown>>(\n obj: T,\n predicate: (value: any) => boolean\n): Partial<T> {\n const result = {}\n\n for (const [key, value] of Object.entries(obj)) {\n if (value && predicate(value)) {\n result[key] = value\n }\n }\n\n return result\n}\n\n/**\n * Replace whitespace, en-dashes and em-dashes with spaces\n * before running through the slug package\n */\nexport function slugify(input = '', options?: slug.Options) {\n const string = input.trimStart().replace(/[\\s–—]/g, ' ')\n\n return slug(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CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["slug","slugify","input","options","string","trimStart","replace","fallback","lower","trim"],"sources":["../../../src/utils/helpers.ts"],"sourcesContent":["import slug from 'slug'\n\n/**\n * Replace whitespace, en-dashes and em-dashes with spaces\n * before running through the slug package\n */\nexport function slugify(input = '', options?: slug.Options) {\n const string = input.trimStart().replace(/[\\s–—]/g, ' ')\n\n return slug(string, {\n fallback: false,\n lower: true,\n trim: true,\n ...options\n })\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,KAAK,GAAG,EAAE,EAAEC,OAAsB,EAAE;EAC1D,MAAMC,MAAM,GAAGF,KAAK,CAACG,SAAS,CAAC,CAAC,CAACC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;EAExD,OAAON,IAAI,CAACI,MAAM,EAAE;IAClBG,QAAQ,EAAE,KAAK;IACfC,KAAK,EAAE,IAAI;IACXC,IAAI,EAAE,IAAI;IACV,GAAGN;EACL,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,9 +1,4 @@
1
1
  import slug from 'slug';
2
- export declare const serialiseAndDeserialise: <T>(obj: T) => T;
3
- export declare const clone: <T>(obj: T & {
4
- clone?: () => T;
5
- }) => T;
6
- export declare function filter<T extends Record<string, unknown>>(obj: T, predicate: (value: any) => boolean): Partial<T>;
7
2
  /**
8
3
  * Replace whitespace, en-dashes and em-dashes with spaces
9
4
  * before running through the slug package
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,eAAO,MAAM,uBAAuB,GAAI,CAAC,OAAO,CAAC,KAAG,CAMnD,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,CAAC,OAAO,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,KAAG,CASvD,CAAA;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtD,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,GACjC,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAK,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,UASzD"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAK,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,UASzD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.291",
3
+ "version": "3.0.293",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "repository": {
@@ -1,39 +1,5 @@
1
1
  import slug from 'slug'
2
2
 
3
- export const serialiseAndDeserialise = <T>(obj: T): T => {
4
- if (typeof obj === 'object' && obj !== null) {
5
- return JSON.parse(JSON.stringify(obj))
6
- }
7
-
8
- return obj
9
- }
10
-
11
- export const clone = <T>(obj: T & { clone?: () => T }): T => {
12
- if (obj) {
13
- if (typeof obj.clone === 'function') {
14
- return obj.clone()
15
- }
16
-
17
- return serialiseAndDeserialise<T>(obj)
18
- }
19
- return obj
20
- }
21
-
22
- export function filter<T extends Record<string, unknown>>(
23
- obj: T,
24
- predicate: (value: any) => boolean
25
- ): Partial<T> {
26
- const result = {}
27
-
28
- for (const [key, value] of Object.entries(obj)) {
29
- if (value && predicate(value)) {
30
- result[key] = value
31
- }
32
- }
33
-
34
- return result
35
- }
36
-
37
3
  /**
38
4
  * Replace whitespace, en-dashes and em-dashes with spaces
39
5
  * before running through the slug package