Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

words.js

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

words.js - npm Package Compare versions

Comparing version 0.1.9 to 0.2.0

2

package.json
{
"name": "words.js",
"version": "0.1.9",
"version": "0.2.0",
"description": "A flexible, robust and powerful Javascript word-string manipulation library.",

@@ -5,0 +5,0 @@ "main": "words.min.js",

@@ -92,3 +92,3 @@ words.js

var words= new Words('we can be very specific and pick any word we need');
words.get( 5, -1 );
console.log( words.get(5, -1) );
// specific need

@@ -182,10 +182,11 @@ ```

> Without arguments the whole internal array(as string) is reversed. With index or indices given, the words denoted by
> indices are reversed. If index is 0, every word is reversed, but will remain on it's original/current index,
> every additional argument is ignored.
> Without arguments the internal array is reversed; not the characters, like with Strings.reverse(), but the words
> positions in the internal array are reversed. If index is 0, every word is reversed, but will remain on it's original/current index,
> every additional argument is then ignored. With index or indices given, the characters in the words
> denoted by indices are reversed.
```javascript
var words= new Words('reverse this whole string');
var words= new Words('reverse words positions');
console.log( words.reverse().$ );
// gnirts elohw siht esrever
// positions words reverse

@@ -322,2 +323,24 @@ var words= new Words('words are reversed in place when 0 is given');

**Words.prototype.startsWith**
> `<boolean> startsWith( <string>/<number> string )`
> Returns true only if the internal string/array starts with string
```javascript
var words= new Words( 'is this a start or an end?' );
console.log( words.startsWith('is this a start') );
// true
```
**Words.prototype.endsWith**
> `<boolean> endsWith( <string>/<number> string )`
> Returns true only if the internal string/array ends with string
```javascript
var words= new Words( 'is this a start or an end?' );
console.log( words.endsWith('an end?') );
// true
```
__________

@@ -328,2 +351,16 @@

**0.2.0**
Modified:
- Words.prototype.reverse() - The default reverse without arguments no longer reverses all characters. This functionality
was 100% similar to the default Strings.reverse(), so pointless to overload. Now .reverse() reverses the positions
of all words, which is more useful as addition.
Added:
- Words.prototype.startsWith()
- Words.prototype.endsWith()
Don't mind the version please, as for every typo in the readme I have to bump the version for npm..
**0.1.2**

@@ -330,0 +367,0 @@

@@ -206,3 +206,7 @@ // Generated by CoffeeScript 1.8.0

} else {
this.set(Str.reverse(this.$));
this.xs((function(_this) {
return function(word, index) {
return _this.get(_this.count - index);
};
})(this));
}

@@ -370,2 +374,29 @@ return this;

Words.prototype.startsWith = function(start) {
var result;
result = true;
start = new Words(start);
start.xs((function(_this) {
return function(word, index) {
if (word !== _this.words[index]) {
return result = false;
}
};
})(this));
return result;
};
Words.prototype.endsWith = function(end) {
var count, index, result, _i, _ref;
result = true;
count = 1;
end = new Words(end);
for (index = _i = _ref = end.count; _ref <= 1 ? _i <= 1 : _i >= 1; index = _ref <= 1 ? ++_i : --_i) {
if (end.get(index) !== this.words[this.count - count++]) {
result = false;
}
}
return result;
};
return Words;

@@ -372,0 +403,0 @@

@@ -1,1 +0,1 @@

(function(){"use strict";var t,r,n,e,s,i,o,u,h,f=[].slice,p={}.hasOwnProperty,c=function(t,r){function n(){this.constructor=t}for(var e in r)p.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t};return r=t=h=require("strings.js"),u=function(t){var r,n,e,s;for(n=t.length-1,e=[],r=s=n;0>=n?0>=s:s>=0;r=0>=n?++s:--s)e[e.length-1]!==t[r]&&e.push(t[r]);return e},o=function(t){var r,n,e,s,i;for(e=t.length-1,n=i=1;e>=1?e>=i:i>=e;n=e>=1?++i:--i){for(r=t[n],s=n-1;s>=0&&t[s]>r;)t[s+1]=t[s],--s;t[+s+1]=r}return t},s=function(r,n){var e,s,i,o,u,p,c,l,a;if(h.isString(null!=n?n[0]:void 0))return this.set(t[r].apply(t,[this.$].concat(f.call(n))));if(0===(null!=n?n[0]:void 0)){for(c=[],i=0,u=n.length;u>i;i++)s=n[i],c.push(function(){var n,i,o;for(o=[],e=n=0,i=this.count-1;i>=0?i>=n:n>=i;e=i>=0?++n:--n)o.push(this.words[e]=t[r](this.words[e],s));return o}.call(this));return c}for(n.length<1&&(n=function(){l=[];for(var t=0,r=this.count;r>=0?r>=t:t>=r;r>=0?t++:t--)l.push(t);return l}.apply(this)),a=[],o=0,p=n.length;p>o;o++)s=n[o],s=h.positiveIndex(s,this.count),a.push(this.words[s]=t[r](this.words[s]));return a},e=function(){return function(t,r,n){var e;return!1!==(e=h.positiveIndex(t,r))?n(e):void 0}}(this),i=" ",n=function(r){function n(){Object.defineProperty(this,"$",{get:function(){return this.get()}}),Object.defineProperty(this,"string",{get:function(){return this.get()}}),Object.defineProperty(this,"count",{get:function(){return this.words.length}}),this.set.apply(this,arguments)}return c(n,r),n.prototype.set=function(){var r,n,e,s,o,u,h;if(arguments.length<1)return this;for(this.words=[],e=0,o=arguments.length;o>e;e++)for(r=arguments[e],h=t.split(t.create(r),i),s=0,u=h.length;u>s;s++)n=h[s],this.words.push(n);return this},n.prototype.get=function(){var r,n,e,s;if(arguments.length<1)return this.words.join(i);for(n="",e=0,s=arguments.length;s>e;e++)r=arguments[e],r=h.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+i);return t.trim(n)},n.prototype.xs=function(t){var r,n,e,s,i,o,u;if(null==t&&(t=function(){return!0}),!(h.notFunction(t)||this.count<1)){for(e=[],u=this.words,r=i=0,o=u.length;o>i;r=++i)s=u[r],(n=t(s,r))&&(n===!0?e.push(s):h.isStringOrNumber(n)&&e.push(n+""));return this.words=e,this}},n.prototype.find=function(t){var r;return r=[],""!==(t=h.forceString(t))&&this.xs(function(n,e){return n===t&&r.push(e+1),!0}),r},n.prototype.upper=function(){return s.call(this,"upper",Array.prototype.slice.call(arguments)),this},n.prototype.lower=function(){return s.call(this,"lower",Array.prototype.slice.call(arguments)),this},n.prototype.reverse=function(){var r,n,s;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(n=0,s=arguments.length;s>n;n++)r=arguments[n],e(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.set(t.reverse(this.$));return this},n.prototype.shuffle=function(r){var n,s,i,o,u;if(null!=r)if(h.isString(r))for(s=0,o=arguments.length;o>s;s++)n=arguments[s],this.xs(function(){return function(r){return r===n?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(i=0,u=arguments.length;u>i;i++)n=arguments[i],e(n,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=h.shuffleArray(this.words);return this},n.prototype.clear=function(){return this.words=[],this},n.prototype.remove=function(){var t,r,e,s,i,f,p;if(arguments.length<1)return this;for(r=[],s=0,f=arguments.length;f>s;s++)t=arguments[s],h.isString(t)?r.unshift(t):h.isNumber(t)&&r.push(n.positiveIndex(t,this.count));for(r=u(o(r)),e=i=0,p=r.length;p>i;e=++i)t=r[e],h.isNumber(t)?this.xs(function(){return function(r,n){return n!==t?!0:void 0}}(this)):h.isString(t)&&this.xs(function(r){return r!==t?!0:void 0});return this},n.prototype.pop=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.pop();return this},n.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=h.forceString(r))&&this.words.push(t.trim(r));return this},n.prototype.shift=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.shift();return this},n.prototype.prepend=function(){var r,n,e,s;for(n=e=0,s=arguments.length;s>e;n=++e)r=arguments[n],""!==(r=h.forceString(r))&&this.words.splice(n,0,t.trim(r));return this},n.prototype.insert=function(){var r,n,e,s,i,o;for(n=arguments[0],s=2<=arguments.length?f.call(arguments,1):[],n=h.positiveIndex(n,this.count),r=i=0,o=s.length;o>i;r=++i)e=s[r],""!==(e=h.forceString(e))&&this.words.splice(n+r,0,t.trim(e));return this},n.prototype.replace=function(r,n){return null==n&&(n=""),""===(n=t.trim(n))?this:(h.isNumber(r)?e(r,this.count,function(t){return function(r){return t.words.splice(r,1,n)}}(this)):this.xs(function(t){return t===r?n:!0}),this)},n.prototype.sort=function(){return o(this.words),this},n}(r),n.prototype.unshift=n.prototype.prepend,n.Strings=r,n.Types=r.Types,n.Chars=r.Chars,"undefined"!=typeof window&&null!==window?window.Words:module?module.exports=n:void 0}).call(this);
(function(){"use strict";var t,r,n,e,s,i,o,u,h,f=[].slice,p={}.hasOwnProperty,c=function(t,r){function n(){this.constructor=t}for(var e in r)p.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t};return r=t=h=require("strings.js"),u=function(t){var r,n,e,s;for(n=t.length-1,e=[],r=s=n;0>=n?0>=s:s>=0;r=0>=n?++s:--s)e[e.length-1]!==t[r]&&e.push(t[r]);return e},o=function(t){var r,n,e,s,i;for(e=t.length-1,n=i=1;e>=1?e>=i:i>=e;n=e>=1?++i:--i){for(r=t[n],s=n-1;s>=0&&t[s]>r;)t[s+1]=t[s],--s;t[+s+1]=r}return t},s=function(r,n){var e,s,i,o,u,p,c,l,a;if(h.isString(null!=n?n[0]:void 0))return this.set(t[r].apply(t,[this.$].concat(f.call(n))));if(0===(null!=n?n[0]:void 0)){for(c=[],i=0,u=n.length;u>i;i++)s=n[i],c.push(function(){var n,i,o;for(o=[],e=n=0,i=this.count-1;i>=0?i>=n:n>=i;e=i>=0?++n:--n)o.push(this.words[e]=t[r](this.words[e],s));return o}.call(this));return c}for(n.length<1&&(n=function(){l=[];for(var t=0,r=this.count;r>=0?r>=t:t>=r;r>=0?t++:t--)l.push(t);return l}.apply(this)),a=[],o=0,p=n.length;p>o;o++)s=n[o],s=h.positiveIndex(s,this.count),a.push(this.words[s]=t[r](this.words[s]));return a},e=function(){return function(t,r,n){var e;return!1!==(e=h.positiveIndex(t,r))?n(e):void 0}}(this),i=" ",n=function(r){function n(){Object.defineProperty(this,"$",{get:function(){return this.get()}}),Object.defineProperty(this,"string",{get:function(){return this.get()}}),Object.defineProperty(this,"count",{get:function(){return this.words.length}}),this.set.apply(this,arguments)}return c(n,r),n.prototype.set=function(){var r,n,e,s,o,u,h;if(arguments.length<1)return this;for(this.words=[],e=0,o=arguments.length;o>e;e++)for(r=arguments[e],h=t.split(t.create(r),i),s=0,u=h.length;u>s;s++)n=h[s],this.words.push(n);return this},n.prototype.get=function(){var r,n,e,s;if(arguments.length<1)return this.words.join(i);for(n="",e=0,s=arguments.length;s>e;e++)r=arguments[e],r=h.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+i);return t.trim(n)},n.prototype.xs=function(t){var r,n,e,s,i,o,u;if(null==t&&(t=function(){return!0}),!(h.notFunction(t)||this.count<1)){for(e=[],u=this.words,r=i=0,o=u.length;o>i;r=++i)s=u[r],(n=t(s,r))&&(n===!0?e.push(s):h.isStringOrNumber(n)&&e.push(n+""));return this.words=e,this}},n.prototype.find=function(t){var r;return r=[],""!==(t=h.forceString(t))&&this.xs(function(n,e){return n===t&&r.push(e+1),!0}),r},n.prototype.upper=function(){return s.call(this,"upper",Array.prototype.slice.call(arguments)),this},n.prototype.lower=function(){return s.call(this,"lower",Array.prototype.slice.call(arguments)),this},n.prototype.reverse=function(){var r,n,s;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(n=0,s=arguments.length;s>n;n++)r=arguments[n],e(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.xs(function(t){return function(r,n){return t.get(t.count-n)}}(this));return this},n.prototype.shuffle=function(r){var n,s,i,o,u;if(null!=r)if(h.isString(r))for(s=0,o=arguments.length;o>s;s++)n=arguments[s],this.xs(function(){return function(r){return r===n?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(i=0,u=arguments.length;u>i;i++)n=arguments[i],e(n,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=h.shuffleArray(this.words);return this},n.prototype.clear=function(){return this.words=[],this},n.prototype.remove=function(){var t,r,e,s,i,f,p;if(arguments.length<1)return this;for(r=[],s=0,f=arguments.length;f>s;s++)t=arguments[s],h.isString(t)?r.unshift(t):h.isNumber(t)&&r.push(n.positiveIndex(t,this.count));for(r=u(o(r)),e=i=0,p=r.length;p>i;e=++i)t=r[e],h.isNumber(t)?this.xs(function(){return function(r,n){return n!==t?!0:void 0}}(this)):h.isString(t)&&this.xs(function(r){return r!==t?!0:void 0});return this},n.prototype.pop=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.pop();return this},n.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=h.forceString(r))&&this.words.push(t.trim(r));return this},n.prototype.shift=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.shift();return this},n.prototype.prepend=function(){var r,n,e,s;for(n=e=0,s=arguments.length;s>e;n=++e)r=arguments[n],""!==(r=h.forceString(r))&&this.words.splice(n,0,t.trim(r));return this},n.prototype.insert=function(){var r,n,e,s,i,o;for(n=arguments[0],s=2<=arguments.length?f.call(arguments,1):[],n=h.positiveIndex(n,this.count),r=i=0,o=s.length;o>i;r=++i)e=s[r],""!==(e=h.forceString(e))&&this.words.splice(n+r,0,t.trim(e));return this},n.prototype.replace=function(r,n){return null==n&&(n=""),""===(n=t.trim(n))?this:(h.isNumber(r)?e(r,this.count,function(t){return function(r){return t.words.splice(r,1,n)}}(this)):this.xs(function(t){return t===r?n:!0}),this)},n.prototype.sort=function(){return o(this.words),this},n.prototype.startsWith=function(t){var r;return r=!0,t=new n(t),t.xs(function(t){return function(n,e){return n!==t.words[e]?r=!1:void 0}}(this)),r},n.prototype.endsWith=function(t){var r,e,s,i,o;for(s=!0,r=1,t=new n(t),e=i=o=t.count;1>=o?1>=i:i>=1;e=1>=o?++i:--i)t.get(e)!==this.words[this.count-r++]&&(s=!1);return s},n}(r),n.prototype.unshift=n.prototype.prepend,n.Strings=r,n.Types=r.Types,n.Chars=r.Chars,"undefined"!=typeof window&&null!==window?window.Words:module?module.exports=n:void 0}).call(this);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc