twitter-text
Advanced tools
Comparing version 1.14.7 to 2.0.0-rc1
{ | ||
"name": "twitter-text", | ||
"description": "official twitter text linkification", | ||
"version": "1.14.7", | ||
"main": "./twitter-text.js", | ||
"version": "2.0.0-rc1", | ||
"main": "build/twitter-text.js", | ||
"files": [ | ||
"twitter-text.js" | ||
"build/twitter-text.js" | ||
], | ||
@@ -16,7 +16,30 @@ "homepage": "https://github.com/twitter/twitter-text-js", | ||
"devDependencies": { | ||
"uglify-js": "~2.4.3", | ||
"qunitjs": "~1.13.0", | ||
"grunt": "~0.4.2", | ||
"grunt-contrib-qunit": "~0.3.0" | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"fs-extra": "^4.0.2", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-qunit": "~2.0.0", | ||
"optimist": "^0.6.1", | ||
"qunitjs": "^1.23.1", | ||
"rollup": "^0.49.2", | ||
"rollup-plugin-babel": "^3.0.2", | ||
"rollup-plugin-commonjs": "^8.2.6", | ||
"rollup-plugin-json": "^2.3.0", | ||
"rollup-plugin-license": "^0.5.0", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"uglify-js": "~2.4.3" | ||
}, | ||
"scripts": { | ||
"build:config": "node scripts/buildConfig.js", | ||
"build:prepare": "npm run build:config && rake test:conformance:prepare", | ||
"build": "npm run build:config && rollup -c", | ||
"build:watch": "npm run build -- -w", | ||
"build:prod": "rollup -c rollup.config.js --prod", | ||
"test": "rollup -c && rake test && rake test:conformance" | ||
}, | ||
"dependencies": { | ||
"punycode": "^2.1.0" | ||
} | ||
} |
@@ -43,9 +43,34 @@ [](https://www.npmjs.com/package/twitter-text) | ||
## Remaining character count example | ||
## Tweet Parsing | ||
Previous versions of Twitter-Text provided different helper methods for Tweet validation, Tweet length, and remaining characters calculation. To simplify the API and obtain this information with just one call, Twitter-Text now exposes a new “parseTweet” method that will return the following fields: | ||
var tweet = "This is a test tweet"; | ||
var remainingCharacters = 140 - twttr.txt.getTweetLength(tweet); | ||
`getTweetLength` returns the computed length of a tweet after taking into consideration t.co URL shortening and non UTF-16 characters | ||
* **weightedLength:** Integer that indicates the weighted length calculated by the algorithm above. | ||
* **permillage:** Integer value corresponding to the ratio of consumed weighted length to the maximum weighted length. | ||
* **valid:** Boolean indicating whether it is a valid Tweet. | ||
* **dispayRangeStart:** Integer with start index on the Tweet string | ||
* **displayRangeEnd:** Integer with end index on the Tweet string (inclusive) | ||
* **validDisplayRangeStart:** Integer indicating the valid start index on the Tweet string | ||
* **validDisplayRangeEnd:** Integer indicating the valid end index on the Tweet string. This can be lesser than displayRangeEnd (inclusive). | ||
```js | ||
var tweet = "This is a test tweet"; | ||
twttr.txt.parseTweet(tweet); | ||
/* Returns: | ||
{ | ||
weightedLength: 20, | ||
permillage: 71, | ||
valid: true, | ||
displayRangeEnd: 19, | ||
displayRangeStart: 0, | ||
validRangeEnd: 19, | ||
validRangeStart: 0 | ||
} | ||
*/ | ||
``` | ||
Details about Twitter's weighted counting scheme are available on the [official developer website](https://developer.twitter.com/en/docs/developer-utilities/twitter-text). | ||
### Marked for Deprecation | ||
`getTweetLength` returns the weighted length of a tweet that is calculated by parseTweet. It will be deprecated in a subsequent release. Please use parseTweet instead. | ||
## Usernames | ||
@@ -72,3 +97,3 @@ | ||
For this reason twitter-text currently does not support extracting or auto-linking | ||
For this reason Twitter-Text currently does not support extracting or auto-linking | ||
of URLs immediately followed by non-Latin characters. | ||
@@ -93,2 +118,8 @@ | ||
For all Twitter-Text tests, run: | ||
npm run test | ||
This will run conformance and javascript tests. | ||
### Conformance | ||
@@ -95,0 +126,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
97089
1563
165
1
16
1
2
+ Addedpunycode@^2.1.0
+ Addedpunycode@2.3.1(transitive)