feat(planning): grille hebdomadaire complète avec API et filtres
- Connexion API via proxy Angular (résolution CORS, base path /api) - Import CSS ng-zorro global pour les modales et composants - Filtres Camion/Show câblés sur l'affichage de la grille - Camions affichés via TrucksService (linkés au show du même créneau) - Panneau de détails : spectacles + camions du jour sélectionné - Modale de création de spectacle stylisée avec fond et centrage - Positionnement précis des events à la minute dans leur créneau - Auto-scroll vers l'heure courante au chargement - Ligne "maintenant" sur la colonne du jour actuel - Régénération des services OpenAPI (nouveaux noms de types) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
+33
-136
@@ -1,9 +1,6 @@
|
||||
# is What? 🙉
|
||||
|
||||
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/v/is-what.svg" alt="Total Downloads"></a>
|
||||
<a href="https://www.npmjs.com/package/is-what"><img src="https://img.shields.io/npm/dw/is-what.svg" alt="Latest Stable Version"></a>
|
||||
|
||||
Very simple & small JS type check functions. It's fully TypeScript supported!
|
||||
Very simple & small JS type check functions. It's fully TypeScript supported!
|
||||
|
||||
```
|
||||
npm i is-what
|
||||
@@ -11,14 +8,11 @@ npm i is-what
|
||||
|
||||
Or for deno available at: `"deno.land/x/is_what"`
|
||||
|
||||
> Also check out [is-where 🙈](https://github.com/mesqueeb/is-where)
|
||||
|
||||
## Motivation
|
||||
|
||||
I built is-what because the existing solutions were all too complex or too poorly built.
|
||||
|
||||
I was looking for:
|
||||
|
||||
- A simple way to check any kind of type (including non-primitives)
|
||||
- Be able to check if an object is a plain object `{}` or a special object (like a class instance) ‼️
|
||||
- Let TypeScript automatically know what type a value is when checking
|
||||
@@ -41,12 +35,6 @@ import { isString, isDate, isPlainObject } from 'is-what'
|
||||
### Simple type check functions
|
||||
|
||||
```js
|
||||
// basics
|
||||
isBoolean(true) // true
|
||||
isBoolean(false) // true
|
||||
isUndefined(undefined) // true
|
||||
isNull(null) // true
|
||||
|
||||
// strings
|
||||
isString('') // true
|
||||
isEmptyString('') // true
|
||||
@@ -54,86 +42,38 @@ isFullString('') // false
|
||||
|
||||
// numbers
|
||||
isNumber(0) // true
|
||||
isNumber('0') // false
|
||||
isNumber(NaN) // false *
|
||||
isPositiveNumber(1) // true
|
||||
isNegativeNumber(-1) // true
|
||||
// * see below for special NaN use cases!
|
||||
|
||||
// arrays
|
||||
isArray([]) // true
|
||||
isEmptyArray([]) // true
|
||||
isFullArray([1]) // true
|
||||
|
||||
// objects
|
||||
isPlainObject({}) // true *
|
||||
isEmptyObject({}) // true
|
||||
isFullObject({ a: 1 }) // true
|
||||
// * see below for special object (& class instance) use cases!
|
||||
|
||||
// functions
|
||||
isFunction(function () {}) // true
|
||||
isFunction(() => {}) // true
|
||||
isNumber(NaN) // false
|
||||
|
||||
// dates
|
||||
isDate(new Date()) // true
|
||||
isDate(new Date('invalid date')) // false
|
||||
|
||||
// maps & sets
|
||||
isMap(new Map()) // true
|
||||
isSet(new Set()) // true
|
||||
isWeakMap(new WeakMap()) // true
|
||||
isWeakSet(new WeakSet()) // true
|
||||
|
||||
// others
|
||||
isBoolean(false) // true
|
||||
isFunction(function () {}) // true
|
||||
isArray([]) // true
|
||||
isUndefined(undefined) // true
|
||||
isNull(null) // true
|
||||
isRegExp(/\s/gi) // true
|
||||
isSymbol(Symbol()) // true
|
||||
isBlob(new Blob()) // true
|
||||
isFile(new File([''], '', { type: 'text/html' })) // true
|
||||
isError(new Error('')) // true
|
||||
isPromise(new Promise((resolve) => {})) // true
|
||||
|
||||
// primitives
|
||||
isPrimitive('') // true
|
||||
// true for any of: boolean, null, undefined, number, string, symbol
|
||||
```
|
||||
|
||||
### Let's talk about NaN
|
||||
### Getting and checking for specific types
|
||||
|
||||
`isNaN` is a built-in JS Function but it really makes no sense:
|
||||
You can check for specific types with `getType` and `isType`:
|
||||
|
||||
```js
|
||||
// 1)
|
||||
typeof NaN === 'number' // true
|
||||
// 🤔 ("not a number" is a "number"...)
|
||||
import { getType, isType } from 'is-what'
|
||||
|
||||
// 2)
|
||||
isNaN('1') // false
|
||||
// 🤔 the string '1' is not-"not a number"... so it's a number??
|
||||
|
||||
// 3)
|
||||
isNaN('one') // true
|
||||
// 🤔 'one' is NaN but `NaN === 'one'` is false...
|
||||
```
|
||||
|
||||
With is-what the way we treat NaN makes a little bit more sense:
|
||||
|
||||
```js
|
||||
import { isNumber, isNaNValue } from 'is-what'
|
||||
|
||||
// 1)
|
||||
isNumber(NaN) // false!
|
||||
// let's not treat NaN as a number
|
||||
|
||||
// 2)
|
||||
isNaNValue('1') // false
|
||||
// if it's not NaN, it's not NaN!!
|
||||
|
||||
// 3)
|
||||
isNaNValue('one') // false
|
||||
// if it's not NaN, it's not NaN!!
|
||||
|
||||
isNaNValue(NaN) // true
|
||||
getType('') // returns 'String'
|
||||
// pass a Type as second param:
|
||||
isType('', String) // returns true
|
||||
```
|
||||
|
||||
### isPlainObject vs isAnyObject
|
||||
@@ -145,11 +85,11 @@ Checking for a JavaScript object can be really difficult. In JavaScript you can
|
||||
|
||||
```js
|
||||
// define a plain object
|
||||
const plainObject = { hello: 'I am a good old object.' }
|
||||
const plainObject = {hello: 'I am a good old object.'}
|
||||
|
||||
// define a special object
|
||||
class SpecialObject {
|
||||
constructor(somethingSpecial) {
|
||||
constructor (somethingSpecial) {
|
||||
this.speciality = somethingSpecial
|
||||
}
|
||||
}
|
||||
@@ -168,42 +108,18 @@ getType(specialObject) // returns 'Object'
|
||||
|
||||
> Please note that `isPlainObject` will only return `true` for normal plain JavaScript objects.
|
||||
|
||||
### Getting and checking for specific types
|
||||
|
||||
You can check for specific types with `getType` and `isType`:
|
||||
|
||||
```js
|
||||
import { getType, isType } from 'is-what'
|
||||
|
||||
getType('') // returns 'String'
|
||||
// pass a Type as second param:
|
||||
isType('', String) // returns true
|
||||
```
|
||||
|
||||
If you just want to make sure your object _inherits_ from a particular class or
|
||||
`toStringTag` value, you can use `isInstanceOf()` like this:
|
||||
|
||||
```js
|
||||
import { isInstanceOf } from 'is-what'
|
||||
|
||||
isInstanceOf(new XMLHttpRequest(), 'EventTarget')
|
||||
// returns true
|
||||
isInstanceOf(globalThis, ReadableStream)
|
||||
// returns false
|
||||
```
|
||||
|
||||
## TypeScript
|
||||
|
||||
is-what makes TypeScript know the type during if statements. This means that a check returns the type of the payload for TypeScript users.
|
||||
|
||||
```ts
|
||||
function isNumber(payload: any): payload is number {
|
||||
function isNumber (payload: any): payload is number {
|
||||
// return boolean
|
||||
}
|
||||
// As you can see above, all functions return a boolean for JavaScript, but pass the payload type to TypeScript.
|
||||
|
||||
// usage example:
|
||||
function fn(payload: string | number): number {
|
||||
function fn (payload: string | number): number {
|
||||
if (isNumber(payload)) {
|
||||
// ↑ TypeScript already knows payload is a number here!
|
||||
return payload
|
||||
@@ -215,8 +131,8 @@ function fn(payload: string | number): number {
|
||||
`isPlainObject` and `isAnyObject` with TypeScript will declare the payload to be an object type with any props:
|
||||
|
||||
```ts
|
||||
function isPlainObject(payload: any): payload is { [key: string]: any }
|
||||
function isAnyObject(payload: any): payload is { [key: string]: any }
|
||||
function isPlainObject (payload: any): payload is {[key: string]: any}
|
||||
function isAnyObject (payload: any): payload is {[key: string]: any}
|
||||
// The reason to return `{[key: string]: any}` is to be able to do
|
||||
if (isPlainObject(payload) && payload.id) return payload.id
|
||||
// if isPlainObject() would return `payload is object` then it would give an error at `payload.id`
|
||||
@@ -224,71 +140,52 @@ if (isPlainObject(payload) && payload.id) return payload.id
|
||||
|
||||
### isObjectLike
|
||||
|
||||
If you want more control over what kind of interface/type is casted when checking for objects.
|
||||
|
||||
To cast to a specific type while checking for `isAnyObject`, can use `isObjectLike<T>`:
|
||||
If you want more control over which kind of objects are allowed you can use `isObjectLike<T>`:
|
||||
|
||||
```ts
|
||||
import { isObjectLike } from 'is-what'
|
||||
|
||||
const payload = { name: 'Mesqueeb' } // current type: `{ name: string }`
|
||||
|
||||
// Without casting:
|
||||
if (isAnyObject(payload)) {
|
||||
// in here `payload` is casted to: `Record<string | number | symbol, any>`
|
||||
// WE LOOSE THE TYPE!
|
||||
}
|
||||
|
||||
// With casting:
|
||||
// you can pass a specific type for TS that will be casted when the function returns
|
||||
if (isObjectLike<{ name: string }>(payload)) {
|
||||
// in here `payload` is casted to: `{ name: string }`
|
||||
}
|
||||
// usage examples:
|
||||
isObjectLike<{specificKey: string}>(payload)
|
||||
isObjectLike<object>(payload)
|
||||
// you can pass a specific type for TS to check on.
|
||||
```
|
||||
|
||||
Please note: this library will not actually check the shape of the object, you need to do that yourself.
|
||||
|
||||
`isObjectLike<T>` works like this under the hood:
|
||||
|
||||
```ts
|
||||
function isObjectLike<T extends object>(payload: any): payload is T {
|
||||
function isObjectLike<T extends object> (payload: any): payload is T {
|
||||
return isAnyObject(payload)
|
||||
}
|
||||
```
|
||||
|
||||
## Meet the family (more tiny utils with TS support)
|
||||
## Meet the family
|
||||
|
||||
- [is-what 🙉](https://github.com/mesqueeb/is-what)
|
||||
- [is-where 🙈](https://github.com/mesqueeb/is-where)
|
||||
- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
|
||||
- [check-anything 👁](https://github.com/mesqueeb/check-anything)
|
||||
- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)
|
||||
- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)
|
||||
- [map-anything 🗺](https://github.com/mesqueeb/map-anything)
|
||||
- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
|
||||
- [find-and-replace-anything 🎣](https://github.com/mesqueeb/find-and-replace-anything)
|
||||
- [compare-anything 🛰](https://github.com/mesqueeb/compare-anything)
|
||||
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
|
||||
- [case-anything 🐫](https://github.com/mesqueeb/case-anything)
|
||||
- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
|
||||
- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)
|
||||
|
||||
## Source code
|
||||
|
||||
It's litterally just these functions:
|
||||
|
||||
```js
|
||||
function getType(payload) {
|
||||
function getType (payload) {
|
||||
return Object.prototype.toString.call(payload).slice(8, -1)
|
||||
}
|
||||
function isUndefined(payload) {
|
||||
function isUndefined (payload) {
|
||||
return getType(payload) === 'Undefined'
|
||||
}
|
||||
function isString(payload) {
|
||||
function isString (payload) {
|
||||
return getType(payload) === 'String'
|
||||
}
|
||||
function isAnyObject(payload) {
|
||||
function isAnyObject (payload) {
|
||||
return getType(payload) === 'Object'
|
||||
}
|
||||
// etc...
|
||||
```
|
||||
|
||||
See the full source code [here](https://github.com/mesqueeb/is-what/blob/production/src/index.ts).
|
||||
See the full source code [here](https://github.com/mesqueeb/is-what/blob/master/src/index.ts).
|
||||
|
||||
+45
-87
@@ -1,36 +1,19 @@
|
||||
{
|
||||
"name": "is-what",
|
||||
"version": "4.1.16",
|
||||
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
"types": "./dist/index.d.ts",
|
||||
"module": "./dist/index.js",
|
||||
"main": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=12.13"
|
||||
},
|
||||
"version": "3.14.1",
|
||||
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"typings": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"lint": "tsc --noEmit && eslint ./src --ext .ts",
|
||||
"build": "rollup -c ./rollup.config.js",
|
||||
"build:docs": "typedoc",
|
||||
"release": "npm run lint && del dist && npm run build && np"
|
||||
"test": "ava",
|
||||
"jest": "jest",
|
||||
"jest-w": "jest --watchAll",
|
||||
"lint": "tsc --noEmit src/index.ts && eslint . --ext .js,.jsx,.ts,.tsx",
|
||||
"rollup": "rollup -c ./build.js",
|
||||
"build": "rimraf types && rimraf dist && npm run lint && npm run rollup && npm run test && npm run jest",
|
||||
"release": "npm run build && np"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -58,71 +41,46 @@
|
||||
"is-plain-object"
|
||||
],
|
||||
"author": "Luca Ban - Mesqueeb",
|
||||
"funding": "https://github.com/sponsors/mesqueeb",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mesqueeb/is-what/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mesqueeb/is-what#readme",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||
"@typescript-eslint/parser": "^5.62.0",
|
||||
"del-cli": "^5.1.0",
|
||||
"eslint-config-prettier": "^8.10.0",
|
||||
"eslint-plugin-tree-shaking": "^1.10.1",
|
||||
"eslint": "^8.52.0",
|
||||
"np": "^8.0.4",
|
||||
"prettier-plugin-jsdoc": "^0.4.2",
|
||||
"prettier": "^2.8.8",
|
||||
"rollup-plugin-dts": "^5.3.1",
|
||||
"rollup-plugin-esbuild": "^5.0.0",
|
||||
"rollup": "^3.29.4",
|
||||
"typedoc": "^0.25.2",
|
||||
"typescript": "^5.2.2",
|
||||
"vitest": "^0.34.6"
|
||||
"@babel/core": "^7.12.17",
|
||||
"@types/babel-core": "^6.25.6",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
||||
"@typescript-eslint/parser": "^4.15.1",
|
||||
"ava": "^3.15.0",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"babel-jest": "^26.6.3",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-prettier": "^7.2.0",
|
||||
"eslint-plugin-tree-shaking": "^1.8.0",
|
||||
"jest": "^26.6.3",
|
||||
"np": "^7.4.0",
|
||||
"prettier": "^2.2.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.39.0",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"ts-node": "^9.1.1",
|
||||
"tsconfig-paths": "^3.9.0",
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"ava": {
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"tsconfig-paths/register",
|
||||
"ts-node/register"
|
||||
]
|
||||
},
|
||||
"np": {
|
||||
"branch": "production",
|
||||
"publish": false,
|
||||
"yarn": false
|
||||
},
|
||||
"eslintConfig": {
|
||||
"ignorePatterns": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"scripts",
|
||||
"test"
|
||||
],
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint",
|
||||
"tree-shaking"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"tree-shaking/no-side-effects-in-initialization": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "off"
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "es5",
|
||||
"semi": false,
|
||||
"bracketSpacing": true,
|
||||
"quoteProps": "consistent",
|
||||
"plugins": [
|
||||
"prettier-plugin-jsdoc"
|
||||
]
|
||||
"yarn": false,
|
||||
"branch": "production"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user