twitter-utils
v0.4.1
Published
Twitter / tweet utils that I find myself reusing often.
Downloads
12
Maintainers
Readme
twitter-utils
Twitter / tweet utils that I find myself reusing often.
Install
npm install twitter-utils
Usage
import {
getTweetUrl,
maxTwitterId,
minTwitterId,
sanitizeTweetText,
stripUserMentions
} from 'twitter-utils'
// This can be a really long tweet with diff URLs and it will truncate the text
// intelligently while preserving URLs
const tweetText = sanitizeTweetText(
'Lorem ipsum dolor sit amet, https://dexa.ai consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum https://transitivebullsh.it/about'
)
// tweetText = 'Lorem ipsum dolor sit amet, https://dexa.ai consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequa... https://transitivebullsh.it/about'
const tweetUrl = getTweetUrl({
username: 'transitive_bs',
id: '1643017583917174784'
})
// tweetUrl = 'https://twitter.com/transitive_bs/status/1643017583917174784'
const id0 = minTwitterId('1759532018956656921', '1733299213503787018')
// id0 = '1733299213503787018'
const id1 = maxTwitterId('1726313076444795273', undefined)
// id1 = '1726313076444795273'
const text = stripUserMentions('hey @transitive_bs ')
// text = 'hey'
License
MIT © Travis Fischer
If you found this project interesting, please consider sponsoring me or following me on twitter