@craftercms/utils
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -38,8 +38,7 @@ /* | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -57,3 +56,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + "/" : ''); | ||
return ("" + base + endpoint).replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -106,8 +105,7 @@ } | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -114,0 +112,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -20,3 +19,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? `${crafterConfigOrBaseUrl.baseUrl}/` : ''); | ||
return `${base}${endpoint}`.replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -23,0 +22,0 @@ } |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -17,2 +16,3 @@ * This program is distributed in the hope that it will be useful, | ||
*/ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -19,2 +18,3 @@ * This program is distributed in the hope that it will be useful, | ||
export * from './src/logging'; | ||
export * from './src/types'; | ||
//# sourceMappingURL=utils.js.map |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -20,3 +19,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + "/" : ''); | ||
return ("" + base + endpoint).replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -23,0 +22,0 @@ } |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -17,2 +16,3 @@ * This program is distributed in the hope that it will be useful, | ||
*/ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -19,2 +18,3 @@ * This program is distributed in the hope that it will be useful, | ||
export * from './src/logging'; | ||
export * from './src/types'; | ||
//# sourceMappingURL=utils.js.map |
@@ -17,8 +17,7 @@ /* | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -36,3 +35,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? `${crafterConfigOrBaseUrl.baseUrl}/` : ''); | ||
return `${base}${endpoint}`.replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -84,8 +83,7 @@ } | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -92,0 +90,0 @@ * This program is distributed in the hope that it will be useful, |
@@ -17,8 +17,7 @@ /* | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -36,3 +35,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? `${crafterConfigOrBaseUrl.baseUrl}/` : ''); | ||
return `${base}${endpoint}`.replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -84,8 +83,7 @@ } | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -92,0 +90,0 @@ * This program is distributed in the hope that it will be useful, |
@@ -17,8 +17,7 @@ /* | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -36,3 +35,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + "/" : ''); | ||
return ("" + base + endpoint).replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -85,8 +84,7 @@ } | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -93,0 +91,0 @@ * This program is distributed in the hope that it will be useful, |
@@ -17,8 +17,7 @@ /* | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -36,3 +35,3 @@ * This program is distributed in the hope that it will be useful, | ||
? crafterConfigOrBaseUrl | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + '/' : ''); | ||
: (crafterConfigOrBaseUrl.baseUrl ? crafterConfigOrBaseUrl.baseUrl + "/" : ''); | ||
return ("" + base + endpoint).replace(/([^:]\/)\/+/g, "$1"); | ||
@@ -85,8 +84,7 @@ } | ||
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -93,0 +91,0 @@ * This program is distributed in the hope that it will be useful, |
{ | ||
"name": "@craftercms/utils", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Crafter CMS utility and helper functions", | ||
@@ -32,8 +32,5 @@ "main": "./bundles/utils.umd.js", | ||
"rollup-plugin-sourcemaps": "^0.5.0", | ||
"typescript": "^3.7.5", | ||
"uglify-es": "^3.3.9" | ||
}, | ||
"dependencies": { | ||
"tslib": "^1.10.0" | ||
} | ||
"dependencies": {} | ||
} |
@@ -7,6 +7,48 @@ ![npm (scoped)](https://img.shields.io/npm/v/@craftercms/utils?style=plastic) | ||
## createLookupTable | ||
## Usage | ||
All of Crafter CMS packages can be used either via npm or in plain html/javascript via regular script imports. | ||
### Via npm | ||
- `yarn add @craftercms/utils` or `npm install @craftercms/utils` | ||
- `import` or `require` the functions you wish. | ||
### Via html script imports | ||
- Download the bundle and import them in your page. | ||
- The bundles declare a global variable named `craftercms`. You can access all craftercms' packages and functions under this root. | ||
- The `utils` package depends on rxjs, make sure to import rxjs too before the `utils` script. | ||
**Tip**: Once you've imported the scripts, type `craftercms` on your browser's dev tools console to inspect the package(s) | ||
#### Vanilla html/js example | ||
```html | ||
<div id="myFeature"></div> | ||
<script src="https://unpkg.com/rxjs"></script> | ||
<script src="https://unpkg.com/@craftercms/utils"></script> | ||
<script> | ||
(function ({ utils }) { | ||
const people = [ | ||
{ id: 1, name: 'Mary' } | ||
] | ||
const myLookup = utils.createLookupTable(people); | ||
console.log(myLookup); // => { 1: { id: 1, name: 'Mary' } } | ||
})(craftercms); | ||
</script> | ||
``` | ||
## Package Index | ||
The examples below assume usage in the style of using via npm. If you're using the bundles, | ||
directly importing as a script in the browser, these functions will be under the global variable | ||
named `craftercms.utils` (i.e. `window.craftercms.utils`). | ||
### createLookupTable | ||
Creates a lookup table based on an array of items (of a type) and the items id identifier. | ||
### Example | ||
#### Example | ||
@@ -16,7 +58,7 @@ - Create a lookup table of items: | ||
```typescript | ||
import { Item, LookupTable } from "@craftercms/models"; | ||
import { createLookupTable } from "@craftercms/utils"; | ||
import { Item, LookupTable } from "@craftercms/models"; | ||
import { createLookupTable } from "@craftercms/utils"; | ||
const items: Item[] = [/* ... */]; | ||
const itemsLookupTable: LookupTable<Item> = createLookupTable<Item>(items, 'url'); | ||
const items: Item[] = [/* ... */]; | ||
const itemsLookupTable: LookupTable<Item> = createLookupTable<Item>(items, 'url'); | ||
``` | ||
@@ -23,0 +65,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
5
40
77
91059
848
- Removedtslib@^1.10.0
- Removedtslib@1.14.1(transitive)