escape-string-applescript
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -1,2 +0,7 @@ | ||
'use strict'; | ||
module.exports = x => typeof x === 'string' ? x.replace(/[\\"]/g, '\\$&') : x; | ||
export default function escapeStringAppleScript(string) { | ||
if (typeof string !== 'string') { | ||
throw new TypeError(`Expected a string, got ${typeof string}`); | ||
} | ||
return string.replace(/[\\"]/g, '\\$&'); | ||
} |
{ | ||
"name": "escape-string-applescript", | ||
"version": "2.0.0", | ||
"description": "Escape a string for use in AppleScript", | ||
"license": "MIT", | ||
"repository": "sindresorhus/escape-string-applescript", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"escape", | ||
"string", | ||
"str", | ||
"applescript", | ||
"osascript", | ||
"quote", | ||
"quotes", | ||
"backslash" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "escape-string-applescript", | ||
"version": "3.0.0", | ||
"description": "Escape a string for use in AppleScript", | ||
"license": "MIT", | ||
"repository": "sindresorhus/escape-string-applescript", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"escape", | ||
"string", | ||
"applescript", | ||
"osascript", | ||
"quote", | ||
"quotes", | ||
"backslash" | ||
], | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# escape-string-applescript [![Build Status](https://travis-ci.org/sindresorhus/escape-string-applescript.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-applescript) | ||
# escape-string-applescript | ||
@@ -7,20 +7,18 @@ > Escape a string for use in AppleScript | ||
## Install | ||
``` | ||
$ npm install --save escape-string-applescript | ||
$ npm install escape-string-applescript | ||
``` | ||
## Usage | ||
```js | ||
const {execFile} = require('child_process'); | ||
const escapeString = require('escape-string-applescript'); | ||
import {execFile} from 'child_process'; | ||
import escapeStringAppleScript from 'escape-string-applescript'; | ||
const str = escapeString('"i like unicorns"'); | ||
const string = escapeStringAppleScript('"i like unicorns"'); | ||
//=> '\"i like unicorns\"' | ||
const script = `set unicornMessage to "${str}"`; | ||
const script = `set unicornMessage to "${string}"`; | ||
@@ -30,10 +28,4 @@ execFile('osascript', ['-e', script]); | ||
## Related | ||
- [run-applescript](https://github.com/sindresorhus/run-applescript) - Run AppleScript and get the result | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
6
Yes
2854
30