Index: sky/examples/data/cities.sky |
diff --git a/sky/examples/city-list/city-data-service.sky b/sky/examples/data/cities.sky |
similarity index 99% |
copy from sky/examples/city-list/city-data-service.sky |
copy to sky/examples/data/cities.sky |
index cd1855ff1dad44ece97559f9dd538712252e792b..32b8bfedcf694fee62df8880abc21f0d7fe2b522 100644 |
--- a/sky/examples/city-list/city-data-service.sky |
+++ b/sky/examples/data/cities.sky |
@@ -4,7 +4,7 @@ |
// found in the LICENSE file. |
--> |
<script> |
-var cities = [ |
+module.exports = [ |
{"name":"New York","state":"New York","population":8363710}, |
{"name":"Los Angeles","state":"California","population":3833995}, |
{"name":"Chicago","state":"Illinois","population":2853114}, |
@@ -5005,44 +5005,4 @@ var cities = [ |
{"name":"Hartwell","state":"Georgia","population":4298}, |
{"name":"Newport","state":"North Carolina","population":4298} |
]; |
- |
-function CityDataService(cities) { |
- this.cities = cities; |
- |
- // sort by state, city name. |
- this.cities.sort(function(a, b) { |
- if (a.state != b.state) { |
- return a.state < b.state ? -1 : 1; |
- } |
- |
- return a.name < b.name ? -1 : 1; |
- }); |
-} |
- |
-CityDataService.prototype.get = function(index, count) { |
- var self = this; |
- |
- return new Promise(function(fulfill) { |
- var result = []; |
- while (count-- > 0) { |
- while (index < 0) { |
- index += self.cities.length; |
- } |
- if (index >= self.cities.length) |
- index = index % self.cities.length; |
- |
- result.push(self.cities[index]); |
- index++; |
- } |
- |
- fulfill(result); |
- }); |
-} |
- |
-module.exports = { |
- service: new Promise(function(fulfill) { |
- fulfill(new CityDataService(cities)); |
- }) |
-}; |
- |
</script> |