(value, propDefinition)
| 195 | * Serialize a single property. |
| 196 | */ |
| 197 | export function stringifyProperty (value, propDefinition) { |
| 198 | // This function stringifies but it's used in a context where |
| 199 | // there's always second stringification pass. By returning the original |
| 200 | // value when it's not an object we save one unnecessary call |
| 201 | // to JSON.stringify. |
| 202 | if (typeof value !== 'object') { return value; } |
| 203 | // if there's no schema for the property we use standard JSON stringify |
| 204 | if (!propDefinition || value === null) { return JSON.stringify(value); } |
| 205 | return propDefinition.stringify(value); |
| 206 | } |
no outgoing calls
no test coverage detected