![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
string-cook
Advanced tools
Cook (interpolate) raw template literal strings without unsafe dynamic code execution.
Cook (interpolate) raw template literal strings without unsafe dynamic code execution.
sample.txt
Hello, ${user.name}!\nYou are currently ${user.age} years old.
sample.js
import cookString from 'string-cook';
import fs from 'fs';
const rawString = fs.readFileSync('sample.txt', 'utf8');
// 'Hello, ${user.name}!\\nYou are currently ${user.age} years old.'
const user = { name: 'Bill', age: 27 };
const cooked = cookString(rawString, { user });
// Hello, Bill!
// You are currently 27 years old.
/* Obviously, you can also pass strings directly from code rather than a file: */
const welcomeBack = 'Welcome back ${user.name}!';
const cooked2 = cookString(welcomeBack, { user });
// Welcome back Bill!
There is only one function:
cook(str: string, scope?: Record<string, unknown> = {}): string
This function is both the default export and a named export.
str
: The input string to cook / interpolate.scope
: An object containing the variables which are exposed to the string interpolation. ${title}
on the input string will attempt to map to the value of a property named title in the scope
object.
${foo.bar.baz}
is valid and maps to the value of 123 with an example scope
object of { foo: { bar: { baz: 123 } } }
scope
object can contain properties not used by the input string.scope
object does not contain a property used within the input string, the current behavior is to fallback to leaving the ${...}
text in place. (Proper error handling coming soon)scope
object is optional and can be empty or omitted.
scope
object is still useful to cook escape sequences, such as \\n
(the \
character followed by n
) to \n
(the newline character escape sequence)${1invalid}
)${user.age + 1}
, is not supported and will be ignored.${user['age']}
or ${user["age"]}
${user?.email}
or ${user?.['email']}
?.
is parsed but treated identical to .
, proper optional chaining behavior mimicking will come at a later update.${us\u0065r}
or ${user['ag\u0065']}
\u{000000}
) are not supported due to breaking the parsing of ${...}
\x00
) or octal (\0
) are not supported in identifiers as the spec disallows it. However they are supported in indexed access strings.${user.friends[0]}
0x00
), octal literals (0o00
) and binary literals (0b00
)1e9
, 3E+7
, 2.7e-4
).5
, 0.5
, 5.
, 5.0
, 967.830041
)1_500_000
, 0xFFFF_FFFF
)+
operator (+42
)-
operator / negative numbers (-81
)Infinity
, -Infinity
and NaN
${ user . age }
is correctly parsed as ${user.age}
FAQs
Cook (interpolate) raw template literal strings without unsafe dynamic code execution.
We found that string-cook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.